@salesforce/core-bundle 8.0.5 → 8.1.1
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 +36 -5
- package/lib/index.js +45 -2
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
@@ -1790,7 +1790,7 @@ declare module '@salesforce/core-bundle/lifecycleEvents' {
|
|
1790
1790
|
*/
|
1791
1791
|
emit<T = AnyJson>(eventName: string, data: T): Promise<void>;
|
1792
1792
|
}
|
1793
|
-
export const cloneUniqueListeners: (uniqueListeners: UniqueListenerMap) => UniqueListenerMap;
|
1793
|
+
export const cloneUniqueListeners: (uniqueListeners: UniqueListenerMap | undefined) => UniqueListenerMap;
|
1794
1794
|
export {};
|
1795
1795
|
|
1796
1796
|
}
|
@@ -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.
|
12091
|
+
version: "8.1.1",
|
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",
|
@@ -12446,7 +12446,10 @@ var require_lifecycleEvents = __commonJS({
|
|
12446
12446
|
};
|
12447
12447
|
exports2.Lifecycle = Lifecycle;
|
12448
12448
|
var cloneListeners = (listeners) => new Map(Array.from(listeners.entries()));
|
12449
|
-
var cloneUniqueListeners = (uniqueListeners) =>
|
12449
|
+
var cloneUniqueListeners = (uniqueListeners) => (
|
12450
|
+
// in case we're crossing major sfdx-core versions where uniqueListeners might be undefined
|
12451
|
+
new Map(Array.from(uniqueListeners?.entries() ?? []).map(([key, value]) => [key, cloneListeners(value)]))
|
12452
|
+
);
|
12450
12453
|
exports2.cloneUniqueListeners = cloneUniqueListeners;
|
12451
12454
|
}
|
12452
12455
|
});
|
@@ -94197,6 +94200,46 @@ var require_sfProject = __commonJS({
|
|
94197
94200
|
}
|
94198
94201
|
return Object.entries(this.getPackageAliases() ?? {}).filter(([, value]) => value?.startsWith(id)).map(([key]) => key);
|
94199
94202
|
}
|
94203
|
+
/**
|
94204
|
+
* retrieve the configuration for a named plugin from sfdx-project.json.plugins.pluginName
|
94205
|
+
*
|
94206
|
+
* @example
|
94207
|
+
* ```
|
94208
|
+
* const project = await SfProject.resolve();
|
94209
|
+
* const pluginConfig = await project.getPluginConfiguration('myPlugin');
|
94210
|
+
* ```
|
94211
|
+
*
|
94212
|
+
* optionally pass a type parameter for your plugin configuration's schema
|
94213
|
+
* */
|
94214
|
+
async getPluginConfiguration(pluginName) {
|
94215
|
+
await this.retrieveSfProjectJson();
|
94216
|
+
const plugins = this.sfProjectJson.get("plugins");
|
94217
|
+
if (!plugins) {
|
94218
|
+
throw new sfError_12.SfError("No plugins defined in sfdx-project.json", "NoPluginsDefined");
|
94219
|
+
}
|
94220
|
+
if (!plugins[pluginName]) {
|
94221
|
+
throw new sfError_12.SfError(`No configuration defined in sfdx-project.json for plugin ${pluginName}`, "PluginNotFound");
|
94222
|
+
}
|
94223
|
+
return plugins[pluginName];
|
94224
|
+
}
|
94225
|
+
/**
|
94226
|
+
* set the configuration for a named plugin from sfdx-project.json.plugins.pluginName, overwriting existing configuration
|
94227
|
+
*
|
94228
|
+
* @example
|
94229
|
+
* ```
|
94230
|
+
* const project = await SfProject.resolve();
|
94231
|
+
* const pluginConfig = await project.setPluginConfiguration('myPlugin', {foo: 'bar', myLimit: 25});
|
94232
|
+
* ```
|
94233
|
+
*
|
94234
|
+
* optionally pass a type parameter for your plugin configuration's schema
|
94235
|
+
* */
|
94236
|
+
async setPluginConfiguration(pluginName, config) {
|
94237
|
+
await this.retrieveSfProjectJson();
|
94238
|
+
const plugins = this.getSfProjectJson().get("plugins") ?? {};
|
94239
|
+
const modified = { ...plugins, [pluginName]: config };
|
94240
|
+
this.sfProjectJson.set("plugins", modified);
|
94241
|
+
this.sfProjectJson.writeSync();
|
94242
|
+
}
|
94200
94243
|
};
|
94201
94244
|
exports2.SfProject = SfProject;
|
94202
94245
|
var isPackagingDirectory = (packageDir) => isPackagingDir(packageDir);
|