Represents an SFDX project directory. This directory contains a SfProjectJson config file as well as a hidden .sfdx folder that contains all the other local project config files.

const project = await SfProject.resolve();
const projectJson = await project.resolveProjectConfig();
console.log(projectJson.sfdcLoginUrl);

Hierarchy

  • SfProject

Methods

  • Get the currently activated package on the project. This has no implication on sfdx-project.json but is useful for keeping track of package and source specific options in a process.

    Returns Nullable<NamedPackageDir>

  • Parameters

    • id: string

    Returns string[]

  • Get the project's default package directory defined in sfdx-project.json using first 'default: true' found. The first entry is returned if no default is specified.

    Returns NamedPackageDir

  • 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 Nullable<Dictionary<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.

    Returns NamedPackageDir[]

  • Returns the package from a file path.

    Parameters

    • path: string

      A file path. E.g. /Users/jsmith/projects/ebikes-lwc/force-app/apex/my-cls.cls

    Returns Optional<NamedPackageDir>

  • Parameters

    • alias: string

    Returns Optional<string>

  • Returns the package name, E.g. 'force-app', from a file path.

    Parameters

    • path: string

      A file path. E.g. /Users/jsmith/projects/ebikes-lwc/force-app/apex/my-cls.cls

    Returns Optional<string>

  • Returns the absolute path of the package directory ending with the path separator. E.g., /Users/jsmith/projects/ebikes-lwc/force-app/

    Parameters

    • packageName: string

      Name of the package directory. E.g., 'force-app'

    Returns Optional<string>

  • Get the sfdx-project.json config. The global sfdx-project.json is used for user defaults that are not checked in to the project specific file.

    Note: When reading values from SfProjectJson, it is recommended to use SfProject.resolveProjectConfig instead.

    This is the sync method of SfProject.resolveSfProjectJson

    Parameters

    • isGlobal: boolean = false

      True to get the global project file, otherwise the local project config.

    Returns SfProjectJson

  • 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[]

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

    Returns boolean

  • Has package directories defined in the project.

    Returns boolean

  • The project config is resolved from local and global SfProjectJson, ConfigAggregator, and a set of defaults. It is recommended to use this when reading values from SfProjectJson.

    The global SfProjectJson is used to allow the user to provide default values they may not want checked into their project's source.

    Returns Promise<JsonMap>

    A resolved config object that contains a bunch of different properties, including some 3rd party custom properties.

  • Get the sfdx-project.json config. The global sfdx-project.json is used for user defaults that are not checked in to the project specific file.

    Note: When reading values from SfProjectJson, it is recommended to use SfProject.resolveProjectConfig instead.

    Parameters

    • isGlobal: boolean = false

      True to get the global project file, otherwise the local project config.

    Returns Promise<SfProjectJson>

  • Set the currently activated package on the project. This has no implication on sfdx-project.json but is useful for keeping track of package and source specific options in a process.

    Parameters

    • packageName: Nullable<string>

      The package name to activate. E.g. 'force-app'

    Returns void

  • Get a Project from a given path or from the working directory.

    Parameters

    • Optional path: string

      The path of the project.

      Throws SfError{ name: 'InvalidProjectWorkspaceError' } If the current folder is not located in a workspace.

    Returns SfProject

  • Get a Project from a given path or from the working directory.

    Parameters

    • Optional path: string

      The path of the project.

      Throws SfError{ name: 'InvalidProjectWorkspaceError' } If the current folder is not located in a workspace.

    Returns Promise<SfProject>

  • Performs an upward directory search for an sfdx project file. Returns the absolute path to the project.

    Parameters

    • Optional dir: string

      The directory path to start traversing from.

      Throws SfError{ name: 'InvalidProjectWorkspaceError' } If the current folder is not located in a workspace.

      See traverseForFile

      See process.cwd()

    Returns Promise<string>

  • Performs a synchronous upward directory search for an sfdx project file. Returns the absolute path to the project.

    Parameters

    • Optional dir: string

      The directory path to start traversing from.

      Throws SfError{ name: 'InvalidProjectWorkspaceError' } If the current folder is not located in a workspace.

      See traverseForFileSync

      See process.cwd()

    Returns string