The sfdx-project.json config object. This file determines if a folder is a valid sfdx project.

Note: Any non-standard (not owned by Salesforce) properties stored in sfdx-project.json should be in a top level property that represents your project or plugin.

const project = await SfProject.resolve();
const projectJson = await project.resolveProjectConfig();
const myPluginProperties = projectJson.get('myplugin') || {};
myPluginProperties.myprop = 'someValue';
projectJson.set('myplugin', myPluginProperties);
await projectJson.write();

See force:project:create

Hierarchy (view full)

Properties

BLOCKLIST: string[] = ...

Methods

  • Add a package alias to the project. If the alias already exists, it will be overwritten.

    Parameters

    • alias: string
    • id: string

    Returns void

  • Add a package directory to the project. If the package directory already exists, the new directory properties will be merged with the existing properties.

    Parameters

    Returns void

  • Check to see if the config file exists. Returns true if the config file exists and has access, false otherwise.

    Returns Promise<boolean>

  • Invokes actionFn once for each key-value pair present in the config object.

    Parameters

    • actionFn: ((key, value) => void)

      The function (key: string, value: ConfigValue) => void to be called for each element.

        • (key, value): void
        • Parameters

          • key: string
          • value: AnyJson

          Returns void

    Returns void

  • Returns the value associated to the key, or undefined if there is none.

    Type Parameters

    • K extends string

    Parameters

    • key: K

      The key (object property)

    • Optional decrypt: boolean

      If it is an encrypted key, decrypt the value. If the value is an object, a clone will be returned.

    Returns ProjectJson[K]

  • Type Parameters

    • V = AnyJson

    Parameters

    • key: string
    • Optional decrypt: boolean

    Returns V

  • Returns the entire config contents.

    NOTE: Data will still be encrypted unless decrypt is passed in. A clone of the data will be returned to prevent storing un-encrypted data in memory and potentially saving to the file system.

    Parameters

    • decrypt: boolean = false

    Returns Readonly<ProjectJson>

  • Get package aliases defined in the project.

    Returns Nullable<Dictionary<string>>

  • Returns the packageDirectories within sfdx-project.json, first reading and validating the file if necessary.

    Returns Promise<PackageDir[]>

  • Returns a read-only list of packageDirectories within sfdx-project.json, first reading and validating the file if necessary. i.e. modifying this array will not affect the sfdx-project.json file.

    Returns NamedPackageDir[]

  • Returns the absolute path to the config file.

    The first time getPath is called, the path is resolved and becomes immutable. This allows implementers to override options properties, like filePath, on the init method for async creation. If that is required for creation, the config files can not be synchronously created.

    Returns string

  • Returns a read-only list of packageDirectories within sfdx-project.json, first reading and validating the file if necessary. i.e. modifying this array will not affect the sfdx-project.json file.

    There can be multiple packages in packageDirectories that point to the same directory. This method only returns one packageDirectory entry per unique directory path. This is useful when doing source operations based on directories but probably not as useful for packaging operations that want to do something for each package entry.

    Returns NamedPackageDir[]

  • Returns a boolean asserting whether a value has been associated to the key in the config object or not.

    Parameters

    • key: string

    Returns boolean

  • Has multiple package directories (MPD) defined in the project.

    Returns boolean

  • Has at least one package alias defined in the project.

    Returns Promise<boolean>

  • Has package directories defined in the project.

    Returns boolean

  • Read the config file and set the config contents. Returns the config contents of the config file. As an optimization, files are only read once per process and updated in memory and via write(). To force a read from the filesystem pass force=true. Throws SfError{ name: 'UnexpectedJsonFileFormat' } There was a problem reading or parsing the file.

    Returns Promise<ProjectJson>

  • Read the config file and set the config contents. Returns the config contents of the config file. As an optimization, files are only read once per process and updated in memory and via write(). To force a read from the filesystem pass force=true. Throws SfError{ name: 'UnexpectedJsonFileFormat' } There was a problem reading or parsing the file.

    Returns ProjectJson

  • Sets the value for the key in the config object. This will override the existing value. To do a partial update, use BaseConfigStore.update.

    Type Parameters

    • K extends string

    Parameters

    Returns void

  • Delete the config file if it exists.

    Throws Error{ name: 'TargetFileNotFound' } If the ConfigFile.getFilename file is not found. fs.unlink

    Returns Promise<void>

  • Delete the config file if it exists.

    Throws Error{ name: 'TargetFileNotFound' } If the ConfigFile.getFilename file is not found. fs.unlink

    Returns void

  • Returns true if an element in the config object existed and has been removed, or false if the element does not exist. BaseConfigStore.has will return false afterwards.

    Type Parameters

    • K extends string

    Parameters

    • key: K

      The key

    Returns boolean

  • Returns true if all elements in the config object existed and have been removed, or false if all the elements do not exist (some may have been removed). BaseConfigStore.has(key) will return false afterwards.

    Parameters

    • keys: string[]

      The keys

    Returns boolean

  • Updates the value for the key in the config object. If the value is an object, it will be merged with the existing object.

    Type Parameters

    • K extends string

    Parameters

    Returns void

  • Write the config file with new contents. If no new contents are provided it will write the existing config contents that were set from ConfigFile.read, or an empty file if ConfigFile.read was not called.

    Returns Promise<ProjectJson>

  • Write the config file with new contents. If no new contents are provided it will write the existing config contents that were set from ConfigFile.read, or an empty file if ConfigFile.read was not called.

    Returns ProjectJson

  • Helper used to determine what the local and global folder point to. Returns the file path of the root folder.

    Parameters

    • isGlobal: boolean

      True if the config should be global. False for local.

    Returns Promise<string>

  • Helper used to determine what the local and global folder point to. Returns the file path of the root folder.

    Parameters

    • isGlobal: boolean

      True if the config should be global. False for local.

    Returns string