@salesforce/core-bundle 8.0.5 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +35 -4
- package/lib/index.js +41 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
@@ -4539,14 +4539,21 @@ declare module '@salesforce/core-bundle/sfProject' {
|
|
4539
4539
|
* The sfdx-project.json config object. This file determines if a folder is a valid sfdx project.
|
4540
4540
|
*
|
4541
4541
|
* *Note:* Any non-standard (not owned by Salesforce) properties stored in sfdx-project.json should
|
4542
|
-
* be in a top level property that represents your project
|
4542
|
+
* be in a top level property that represents your project.
|
4543
|
+
* Plugins should store their configuration @see SfProject.getPluginConfiguration and @see SfProject.setPluginConfiguration
|
4543
4544
|
*
|
4545
|
+
* @example reading a standard property
|
4544
4546
|
* ```
|
4545
4547
|
* const project = await SfProject.resolve();
|
4546
4548
|
* const projectJson = await project.resolveProjectConfig();
|
4547
|
-
* const
|
4548
|
-
*
|
4549
|
-
*
|
4549
|
+
* const namespace = projectJson.get('namespace');
|
4550
|
+
* ```
|
4551
|
+
*
|
4552
|
+
* ```
|
4553
|
+
* @example writing
|
4554
|
+
* const project = await SfProject.resolve();
|
4555
|
+
* const projectJson = await project.resolveProjectConfig();
|
4556
|
+
* projectJson.set('namespace', 'new');
|
4550
4557
|
* await projectJson.write();
|
4551
4558
|
* ```
|
4552
4559
|
*
|
@@ -4835,6 +4842,30 @@ declare module '@salesforce/core-bundle/sfProject' {
|
|
4835
4842
|
getPackageAliases(): Nullable<Dictionary<string>>;
|
4836
4843
|
getPackageIdFromAlias(alias: string): Optional<string>;
|
4837
4844
|
getAliasesFromPackageId(id: string): string[];
|
4845
|
+
/**
|
4846
|
+
* retrieve the configuration for a named plugin from sfdx-project.json.plugins.pluginName
|
4847
|
+
*
|
4848
|
+
* @example
|
4849
|
+
* ```
|
4850
|
+
* const project = await SfProject.resolve();
|
4851
|
+
* const pluginConfig = await project.getPluginConfiguration('myPlugin');
|
4852
|
+
* ```
|
4853
|
+
*
|
4854
|
+
* optionally pass a type parameter for your plugin configuration's schema
|
4855
|
+
* */
|
4856
|
+
getPluginConfiguration<T extends Record<string, unknown>>(pluginName: string): Promise<Readonly<T>>;
|
4857
|
+
/**
|
4858
|
+
* set the configuration for a named plugin from sfdx-project.json.plugins.pluginName, overwriting existing configuration
|
4859
|
+
*
|
4860
|
+
* @example
|
4861
|
+
* ```
|
4862
|
+
* const project = await SfProject.resolve();
|
4863
|
+
* const pluginConfig = await project.setPluginConfiguration('myPlugin', {foo: 'bar', myLimit: 25});
|
4864
|
+
* ```
|
4865
|
+
*
|
4866
|
+
* optionally pass a type parameter for your plugin configuration's schema
|
4867
|
+
* */
|
4868
|
+
setPluginConfiguration<T extends Record<string, unknown>>(pluginName: string, config: T): Promise<void>;
|
4838
4869
|
}
|
4839
4870
|
/** 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 */
|
4840
4871
|
export const isPackagingDirectory: (packageDir: PackageDir) => packageDir is PackagePackageDir;
|
package/lib/index.js
CHANGED
@@ -12088,7 +12088,7 @@ var require_package2 = __commonJS({
|
|
12088
12088
|
"package.json"(exports2, module2) {
|
12089
12089
|
module2.exports = {
|
12090
12090
|
name: "@salesforce/core-bundle",
|
12091
|
-
version: "8.0
|
12091
|
+
version: "8.1.0",
|
12092
12092
|
description: "Core libraries to interact with SFDX projects, orgs, and APIs.",
|
12093
12093
|
main: "lib/index",
|
12094
12094
|
types: "lib/index.d.ts",
|
@@ -94197,6 +94197,46 @@ var require_sfProject = __commonJS({
|
|
94197
94197
|
}
|
94198
94198
|
return Object.entries(this.getPackageAliases() ?? {}).filter(([, value]) => value?.startsWith(id)).map(([key]) => key);
|
94199
94199
|
}
|
94200
|
+
/**
|
94201
|
+
* retrieve the configuration for a named plugin from sfdx-project.json.plugins.pluginName
|
94202
|
+
*
|
94203
|
+
* @example
|
94204
|
+
* ```
|
94205
|
+
* const project = await SfProject.resolve();
|
94206
|
+
* const pluginConfig = await project.getPluginConfiguration('myPlugin');
|
94207
|
+
* ```
|
94208
|
+
*
|
94209
|
+
* optionally pass a type parameter for your plugin configuration's schema
|
94210
|
+
* */
|
94211
|
+
async getPluginConfiguration(pluginName) {
|
94212
|
+
await this.retrieveSfProjectJson();
|
94213
|
+
const plugins = this.sfProjectJson.get("plugins");
|
94214
|
+
if (!plugins) {
|
94215
|
+
throw new sfError_12.SfError("No plugins defined in sfdx-project.json", "NoPluginsDefined");
|
94216
|
+
}
|
94217
|
+
if (!plugins[pluginName]) {
|
94218
|
+
throw new sfError_12.SfError(`No configuration defined in sfdx-project.json for plugin ${pluginName}`, "PluginNotFound");
|
94219
|
+
}
|
94220
|
+
return plugins[pluginName];
|
94221
|
+
}
|
94222
|
+
/**
|
94223
|
+
* set the configuration for a named plugin from sfdx-project.json.plugins.pluginName, overwriting existing configuration
|
94224
|
+
*
|
94225
|
+
* @example
|
94226
|
+
* ```
|
94227
|
+
* const project = await SfProject.resolve();
|
94228
|
+
* const pluginConfig = await project.setPluginConfiguration('myPlugin', {foo: 'bar', myLimit: 25});
|
94229
|
+
* ```
|
94230
|
+
*
|
94231
|
+
* optionally pass a type parameter for your plugin configuration's schema
|
94232
|
+
* */
|
94233
|
+
async setPluginConfiguration(pluginName, config) {
|
94234
|
+
await this.retrieveSfProjectJson();
|
94235
|
+
const plugins = this.getSfProjectJson().get("plugins") ?? {};
|
94236
|
+
const modified = { ...plugins, [pluginName]: config };
|
94237
|
+
this.sfProjectJson.set("plugins", modified);
|
94238
|
+
this.sfProjectJson.writeSync();
|
94239
|
+
}
|
94200
94240
|
};
|
94201
94241
|
exports2.SfProject = SfProject;
|
94202
94242
|
var isPackagingDirectory = (packageDir) => isPackagingDir(packageDir);
|