@salesforce/core
Advanced tools
Comparing version 8.0.5 to 8.1.0
@@ -22,10 +22,17 @@ import { Dictionary, JsonMap, Nullable, Optional } from '@salesforce/ts-types'; | ||
* *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. | ||
* be in a top level property that represents your project. | ||
* Plugins should store their configuration @see SfProject.getPluginConfiguration and @see SfProject.setPluginConfiguration | ||
* | ||
* @example reading a standard property | ||
* ``` | ||
* const project = await SfProject.resolve(); | ||
* const projectJson = await project.resolveProjectConfig(); | ||
* const myPluginProperties = projectJson.get('myplugin') || {}; | ||
* myPluginProperties.myprop = 'someValue'; | ||
* projectJson.set('myplugin', myPluginProperties); | ||
* const namespace = projectJson.get('namespace'); | ||
* ``` | ||
* | ||
* ``` | ||
* @example writing | ||
* const project = await SfProject.resolve(); | ||
* const projectJson = await project.resolveProjectConfig(); | ||
* projectJson.set('namespace', 'new'); | ||
* await projectJson.write(); | ||
@@ -319,2 +326,26 @@ * ``` | ||
getAliasesFromPackageId(id: string): string[]; | ||
/** | ||
* retrieve the configuration for a named plugin from sfdx-project.json.plugins.pluginName | ||
* | ||
* @example | ||
* ``` | ||
* const project = await SfProject.resolve(); | ||
* const pluginConfig = await project.getPluginConfiguration('myPlugin'); | ||
* ``` | ||
* | ||
* optionally pass a type parameter for your plugin configuration's schema | ||
* */ | ||
getPluginConfiguration<T extends Record<string, unknown>>(pluginName: string): Promise<Readonly<T>>; | ||
/** | ||
* set the configuration for a named plugin from sfdx-project.json.plugins.pluginName, overwriting existing configuration | ||
* | ||
* @example | ||
* ``` | ||
* const project = await SfProject.resolve(); | ||
* const pluginConfig = await project.setPluginConfiguration('myPlugin', {foo: 'bar', myLimit: 25}); | ||
* ``` | ||
* | ||
* optionally pass a type parameter for your plugin configuration's schema | ||
* */ | ||
setPluginConfiguration<T extends Record<string, unknown>>(pluginName: string, config: T): Promise<void>; | ||
} | ||
@@ -321,0 +352,0 @@ /** differentiate between the Base PackageDir (path, maybe default) and the Packaging version (package and maybe a LOT of other fields) by whether is has the `package` property */ |
@@ -51,10 +51,17 @@ "use strict"; | ||
* *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. | ||
* be in a top level property that represents your project. | ||
* Plugins should store their configuration @see SfProject.getPluginConfiguration and @see SfProject.setPluginConfiguration | ||
* | ||
* @example reading a standard property | ||
* ``` | ||
* const project = await SfProject.resolve(); | ||
* const projectJson = await project.resolveProjectConfig(); | ||
* const myPluginProperties = projectJson.get('myplugin') || {}; | ||
* myPluginProperties.myprop = 'someValue'; | ||
* projectJson.set('myplugin', myPluginProperties); | ||
* const namespace = projectJson.get('namespace'); | ||
* ``` | ||
* | ||
* ``` | ||
* @example writing | ||
* const project = await SfProject.resolve(); | ||
* const projectJson = await project.resolveProjectConfig(); | ||
* projectJson.set('namespace', 'new'); | ||
* await projectJson.write(); | ||
@@ -658,2 +665,42 @@ * ``` | ||
} | ||
/** | ||
* retrieve the configuration for a named plugin from sfdx-project.json.plugins.pluginName | ||
* | ||
* @example | ||
* ``` | ||
* const project = await SfProject.resolve(); | ||
* const pluginConfig = await project.getPluginConfiguration('myPlugin'); | ||
* ``` | ||
* | ||
* optionally pass a type parameter for your plugin configuration's schema | ||
* */ | ||
async getPluginConfiguration(pluginName) { | ||
await this.retrieveSfProjectJson(); | ||
const plugins = this.sfProjectJson.get('plugins'); | ||
if (!plugins) { | ||
throw new sfError_1.SfError('No plugins defined in sfdx-project.json', 'NoPluginsDefined'); | ||
} | ||
if (!plugins[pluginName]) { | ||
throw new sfError_1.SfError(`No configuration defined in sfdx-project.json for plugin ${pluginName}`, 'PluginNotFound'); | ||
} | ||
return plugins[pluginName]; | ||
} | ||
/** | ||
* set the configuration for a named plugin from sfdx-project.json.plugins.pluginName, overwriting existing configuration | ||
* | ||
* @example | ||
* ``` | ||
* const project = await SfProject.resolve(); | ||
* const pluginConfig = await project.setPluginConfiguration('myPlugin', {foo: 'bar', myLimit: 25}); | ||
* ``` | ||
* | ||
* optionally pass a type parameter for your plugin configuration's schema | ||
* */ | ||
async setPluginConfiguration(pluginName, config) { | ||
await this.retrieveSfProjectJson(); | ||
const plugins = this.getSfProjectJson().get('plugins') ?? {}; | ||
const modified = { ...plugins, [pluginName]: config }; | ||
this.sfProjectJson.set('plugins', modified); | ||
this.sfProjectJson.writeSync(); | ||
} | ||
} | ||
@@ -660,0 +707,0 @@ exports.SfProject = SfProject; |
{ | ||
"name": "@salesforce/core", | ||
"version": "8.0.5", | ||
"version": "8.1.0", | ||
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1040694
22134