Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SfdxProjectJson

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 SfdxProjectJson.retrieve();
const myPluginProperties = project.get('myplugin') || {};
myPluginProperties.myprop = 'someValue';
project.set('myplugin', myPluginProperties);
await project.write();

See force:project:create

Hierarchy

Implements

Index

Constructors

constructor

Properties

Protected options

options: Options

Static BLACKLIST

BLACKLIST: string[] = ['packageAliases']

Methods

access

  • access(perm: number): Promise<boolean>

awaitEach

  • awaitEach(actionFn: function): Promise<void>
  • Asynchronously invokes actionFn once for each key-value pair present in the config object.

    Parameters

    • actionFn: function

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

        • Parameters

          Returns Promise<void>

    Returns Promise<void>

clear

  • clear(): void

entries

exists

  • exists(): Promise<boolean>
  • Check to see if the config file exists. Returns true if the config file exists and has access, false otherwise.

    Returns Promise<boolean>

forEach

  • forEach(actionFn: function): void
  • Invokes actionFn once for each key-value pair present in the config object.

    Parameters

    • actionFn: function

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

    Returns void

get

getContents

getDefaultOptions

getKeysByValue

getPath

  • getPath(): string

has

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

    Parameters

    • key: string

      The key.

    Returns boolean

Protected init

  • init(): Promise<void>
  • Used to initialize asynchronous components.

    Throws Error{ code: 'ENOENT' } If the {@link ConfigFile.getFilename} file is not found when options.throwOnNotFound is true.

    Returns Promise<void>

isGlobal

  • isGlobal(): boolean

keys

  • keys(): string[]
  • Returns an array that contains the keys for each element in the config object.

    Returns string[]

read

set

setContents

setContentsFromObject

  • setContentsFromObject<U>(obj: U): void
  • Convert an object to a ConfigContents and set it as the config contents.

    Type parameters

    • U: any

    Parameters

    • obj: U

      The object.

    Returns void

Protected setMethod

stat

  • stat(): Promise<fsStats>

toObject

  • toObject(): JsonMap

unlink

  • unlink(): Promise<void>

unset

  • unset(key: string): boolean
  • Returns true if an element in the config object existed and has been removed, or false if the element does not exist. {@link BaseConfigStore.has} will return false afterwards.

    Parameters

    • key: string

      The key.

    Returns boolean

unsetAll

  • unsetAll(keys: string[]): 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). {@link BaseConfigStore.has(key)} will return false afterwards.

    Parameters

    • keys: string[]

      The keys.

    Returns boolean

values

write

Static create

  • create<P, T>(this: object, options: P): Promise<T>
  • Asynchronously constructs and initializes a new instance of a concrete subclass with the provided options.

    Type parameters

    • P

    • T: AsyncCreatable<P>

    Parameters

    • this: object
    • options: P

      An options object providing initialization params to the async constructor.

    Returns Promise<T>

Static getDefaultOptions

  • getDefaultOptions(isGlobal?: boolean): Options

Static getFileName

  • getFileName(): string

Static resolveRootFolder

  • resolveRootFolder(isGlobal: boolean): Promise<string>
  • Helper used to determined 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>