@salesforce/core 8.22.0 → 8.23.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/sfProject.d.ts +42 -2
- package/lib/sfProject.js +81 -2
- package/package.json +3 -3
package/lib/sfProject.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dictionary, JsonMap, Nullable, Optional } from '@salesforce/ts-types';
|
|
2
|
-
import { PackageDir, ProjectJson as ProjectJsonSchema, PackagePackageDir } from '@salesforce/schemas';
|
|
2
|
+
import { PackageDir, ProjectJson as ProjectJsonSchema, PackagePackageDir, BundleEntry } from '@salesforce/schemas';
|
|
3
3
|
import { ConfigFile } from './config/configFile';
|
|
4
4
|
import { ConfigContents } from './config/configStackTypes';
|
|
5
5
|
type NameAndFullPath = {
|
|
@@ -14,6 +14,7 @@ type NameAndFullPath = {
|
|
|
14
14
|
};
|
|
15
15
|
export type NamedPackagingDir = PackagePackageDir & NameAndFullPath;
|
|
16
16
|
export type NamedPackageDir = PackageDir & NameAndFullPath;
|
|
17
|
+
export type { BundleEntry };
|
|
17
18
|
export type ProjectJson = ConfigContents & ProjectJsonSchema;
|
|
18
19
|
/**
|
|
19
20
|
* The sfdx-project.json config object. This file determines if a folder is a valid sfdx project.
|
|
@@ -104,6 +105,10 @@ export declare class SfProjectJson extends ConfigFile<ConfigFile.Options, Projec
|
|
|
104
105
|
* Has multiple package directories (MPD) defined in the project.
|
|
105
106
|
*/
|
|
106
107
|
hasMultiplePackages(): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Has multiple package bundles defined in the project.
|
|
110
|
+
*/
|
|
111
|
+
hasMultiplePackageBundles(): boolean;
|
|
107
112
|
/**
|
|
108
113
|
* Has at least one package alias defined in the project.
|
|
109
114
|
*/
|
|
@@ -128,6 +133,34 @@ export declare class SfProjectJson extends ConfigFile<ConfigFile.Options, Projec
|
|
|
128
133
|
* @param packageDir
|
|
129
134
|
*/
|
|
130
135
|
addPackageDirectory(packageDir: PackageDir): void;
|
|
136
|
+
/**
|
|
137
|
+
* Get package bundles defined in the project.
|
|
138
|
+
*/
|
|
139
|
+
getPackageBundles(): BundleEntry[];
|
|
140
|
+
/**
|
|
141
|
+
* Add a bundle entry to the project.
|
|
142
|
+
* If the bundle entry already exists, the new entry
|
|
143
|
+
* properties will be merged with the existing properties.
|
|
144
|
+
*
|
|
145
|
+
* @param bundleEntry
|
|
146
|
+
*/
|
|
147
|
+
addPackageBundle(bundleEntry: BundleEntry): void;
|
|
148
|
+
/**
|
|
149
|
+
* Has at least one package bundle alias defined in the project.
|
|
150
|
+
*/
|
|
151
|
+
hasPackageBundleAliases(): boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Get package bundle aliases defined in the project.
|
|
154
|
+
*/
|
|
155
|
+
getPackageBundleAliases(): Nullable<Dictionary<string>>;
|
|
156
|
+
/**
|
|
157
|
+
* Add a bundle alias to the project.
|
|
158
|
+
* If the bundle alias already exists, it will be overwritten.
|
|
159
|
+
*
|
|
160
|
+
* @param alias The alias name
|
|
161
|
+
* @param id The bundle ID
|
|
162
|
+
*/
|
|
163
|
+
addPackageBundleAlias(alias: string, id: string): void;
|
|
131
164
|
private doesPackageExist;
|
|
132
165
|
private validateKeys;
|
|
133
166
|
}
|
|
@@ -150,6 +183,7 @@ export declare class SfProject {
|
|
|
150
183
|
private packageDirectories?;
|
|
151
184
|
private activePackage;
|
|
152
185
|
private packageAliases;
|
|
186
|
+
private packageBundleAliases;
|
|
153
187
|
/**
|
|
154
188
|
* Do not directly construct instances of this class -- use {@link SfProject.resolve} instead.
|
|
155
189
|
*
|
|
@@ -292,6 +326,10 @@ export declare class SfProject {
|
|
|
292
326
|
* Has multiple package directories (MPD) defined in the project.
|
|
293
327
|
*/
|
|
294
328
|
hasMultiplePackages(): boolean;
|
|
329
|
+
/**
|
|
330
|
+
* Has multiple package bundles defined in the project.
|
|
331
|
+
*/
|
|
332
|
+
hasMultiplePackageBundles(): boolean;
|
|
295
333
|
/**
|
|
296
334
|
* Get the currently activated package on the project. This has no implication on sfdx-project.json
|
|
297
335
|
* but is useful for keeping track of package and source specific options in a process.
|
|
@@ -330,6 +368,9 @@ export declare class SfProject {
|
|
|
330
368
|
getPackageAliases(): Nullable<Dictionary<string>>;
|
|
331
369
|
getPackageIdFromAlias(alias: string): Optional<string>;
|
|
332
370
|
getAliasesFromPackageId(id: string): string[];
|
|
371
|
+
getPackageBundleAliases(): Nullable<Dictionary<string>>;
|
|
372
|
+
getPackageBundleIdFromAlias(alias: string): Optional<string>;
|
|
373
|
+
getAliasesFromPackageBundleId(id: string): string[];
|
|
333
374
|
/**
|
|
334
375
|
* retrieve the configuration for a named plugin from sfdx-project.json.plugins.pluginName
|
|
335
376
|
*
|
|
@@ -359,4 +400,3 @@ export declare class SfProject {
|
|
|
359
400
|
export declare const isPackagingDirectory: (packageDir: PackageDir) => packageDir is PackagePackageDir;
|
|
360
401
|
/** 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 */
|
|
361
402
|
export declare const isNamedPackagingDirectory: (packageDir: NamedPackageDir) => packageDir is NamedPackagingDir;
|
|
362
|
-
export {};
|
package/lib/sfProject.js
CHANGED
|
@@ -47,7 +47,7 @@ const messages = new messages_1.Messages('@salesforce/core', 'config', new Map([
|
|
|
47
47
|
*/
|
|
48
48
|
class SfProjectJson extends configFile_1.ConfigFile {
|
|
49
49
|
/** json properties that are uppercase, or allow uppercase keys inside them */
|
|
50
|
-
static BLOCKLIST = ['packageAliases', 'plugins'];
|
|
50
|
+
static BLOCKLIST = ['packageAliases', 'plugins', 'packageBundleAliases'];
|
|
51
51
|
static getFileName() {
|
|
52
52
|
return internal_1.SFDX_PROJECT_JSON;
|
|
53
53
|
}
|
|
@@ -235,10 +235,16 @@ class SfProjectJson extends configFile_1.ConfigFile {
|
|
|
235
235
|
hasMultiplePackages() {
|
|
236
236
|
return this.getContents()?.packageDirectories?.length > 1;
|
|
237
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Has multiple package bundles defined in the project.
|
|
240
|
+
*/
|
|
241
|
+
hasMultiplePackageBundles() {
|
|
242
|
+
return (this.getContents()?.packageBundles?.length ?? 0) > 1;
|
|
243
|
+
}
|
|
238
244
|
/**
|
|
239
245
|
* Has at least one package alias defined in the project.
|
|
240
246
|
*/
|
|
241
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
242
248
|
async hasPackageAliases() {
|
|
243
249
|
return Object.keys(this.getContents().packageAliases ?? {}).length > 0;
|
|
244
250
|
}
|
|
@@ -281,6 +287,54 @@ class SfProjectJson extends configFile_1.ConfigFile {
|
|
|
281
287
|
[...(this.getContents()?.packageDirectories ?? []), packageDirEntry];
|
|
282
288
|
this.set('packageDirectories', modifiedPackagesDirs);
|
|
283
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Get package bundles defined in the project.
|
|
292
|
+
*/
|
|
293
|
+
getPackageBundles() {
|
|
294
|
+
return this.get('packageBundles') ?? [];
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Add a bundle entry to the project.
|
|
298
|
+
* If the bundle entry already exists, the new entry
|
|
299
|
+
* properties will be merged with the existing properties.
|
|
300
|
+
*
|
|
301
|
+
* @param bundleEntry
|
|
302
|
+
*/
|
|
303
|
+
addPackageBundle(bundleEntry) {
|
|
304
|
+
const bundles = this.getPackageBundles();
|
|
305
|
+
const bundleIndex = bundles.findIndex((b) => b.name === bundleEntry.name);
|
|
306
|
+
const bundleEntryJson = {
|
|
307
|
+
...(bundleIndex > -1 ? bundles[bundleIndex] : bundleEntry),
|
|
308
|
+
...bundleEntry,
|
|
309
|
+
};
|
|
310
|
+
const modifiedBundles = bundleIndex > -1
|
|
311
|
+
? bundles.map((b) => (b.name === bundleEntry.name ? bundleEntryJson : b))
|
|
312
|
+
: [...bundles, bundleEntryJson];
|
|
313
|
+
this.set('packageBundles', modifiedBundles);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Has at least one package bundle alias defined in the project.
|
|
317
|
+
*/
|
|
318
|
+
hasPackageBundleAliases() {
|
|
319
|
+
return Object.keys(this.getContents().packageBundleAliases ?? {}).length > 0;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Get package bundle aliases defined in the project.
|
|
323
|
+
*/
|
|
324
|
+
getPackageBundleAliases() {
|
|
325
|
+
return this.get('packageBundleAliases');
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Add a bundle alias to the project.
|
|
329
|
+
* If the bundle alias already exists, it will be overwritten.
|
|
330
|
+
*
|
|
331
|
+
* @param alias The alias name
|
|
332
|
+
* @param id The bundle ID
|
|
333
|
+
*/
|
|
334
|
+
addPackageBundleAlias(alias, id) {
|
|
335
|
+
const newAliases = { ...(this.get('packageBundleAliases') ?? {}), [alias]: id };
|
|
336
|
+
this.set('packageBundleAliases', newAliases);
|
|
337
|
+
}
|
|
284
338
|
// keep it because testSetup stubs it!
|
|
285
339
|
// eslint-disable-next-line class-methods-use-this
|
|
286
340
|
doesPackageExist(packagePath) {
|
|
@@ -313,6 +367,7 @@ class SfProject {
|
|
|
313
367
|
packageDirectories;
|
|
314
368
|
activePackage;
|
|
315
369
|
packageAliases;
|
|
370
|
+
packageBundleAliases;
|
|
316
371
|
/**
|
|
317
372
|
* Do not directly construct instances of this class -- use {@link SfProject.resolve} instead.
|
|
318
373
|
*
|
|
@@ -548,6 +603,12 @@ class SfProject {
|
|
|
548
603
|
hasMultiplePackages() {
|
|
549
604
|
return this.getSfProjectJson().hasMultiplePackages();
|
|
550
605
|
}
|
|
606
|
+
/**
|
|
607
|
+
* Has multiple package bundles defined in the project.
|
|
608
|
+
*/
|
|
609
|
+
hasMultiplePackageBundles() {
|
|
610
|
+
return this.getSfProjectJson().hasMultiplePackageBundles();
|
|
611
|
+
}
|
|
551
612
|
/**
|
|
552
613
|
* Get the currently activated package on the project. This has no implication on sfdx-project.json
|
|
553
614
|
* but is useful for keeping track of package and source specific options in a process.
|
|
@@ -651,6 +712,24 @@ class SfProject {
|
|
|
651
712
|
.filter(([, value]) => value?.startsWith(id))
|
|
652
713
|
.map(([key]) => key);
|
|
653
714
|
}
|
|
715
|
+
getPackageBundleAliases() {
|
|
716
|
+
if (!this.packageBundleAliases) {
|
|
717
|
+
this.packageBundleAliases = this.getSfProjectJson().getPackageBundleAliases();
|
|
718
|
+
}
|
|
719
|
+
return this.packageBundleAliases;
|
|
720
|
+
}
|
|
721
|
+
getPackageBundleIdFromAlias(alias) {
|
|
722
|
+
const packageBundleAliases = this.getPackageBundleAliases();
|
|
723
|
+
return packageBundleAliases ? packageBundleAliases[alias] : undefined;
|
|
724
|
+
}
|
|
725
|
+
getAliasesFromPackageBundleId(id) {
|
|
726
|
+
if (!/^.{15,18}$/.test(id)) {
|
|
727
|
+
throw messages.createError('invalidId', [id]);
|
|
728
|
+
}
|
|
729
|
+
return Object.entries(this.getPackageBundleAliases() ?? {})
|
|
730
|
+
.filter(([, value]) => value?.startsWith(id))
|
|
731
|
+
.map(([key]) => key);
|
|
732
|
+
}
|
|
654
733
|
/**
|
|
655
734
|
* retrieve the configuration for a named plugin from sfdx-project.json.plugins.pluginName
|
|
656
735
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.23.0",
|
|
4
4
|
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@jsforce/jsforce-node": "^3.10.4",
|
|
59
59
|
"@salesforce/kit": "^3.2.2",
|
|
60
|
-
"@salesforce/schemas": "^1.
|
|
60
|
+
"@salesforce/schemas": "^1.10.0",
|
|
61
61
|
"@salesforce/ts-types": "^2.0.11",
|
|
62
62
|
"ajv": "^8.17.1",
|
|
63
63
|
"change-case": "^4.1.2",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@salesforce/dev-scripts": "^10.1.1",
|
|
80
|
-
"@salesforce/ts-sinon": "^1.4.
|
|
80
|
+
"@salesforce/ts-sinon": "^1.4.31",
|
|
81
81
|
"@types/benchmark": "^2.1.5",
|
|
82
82
|
"@types/fast-levenshtein": "^0.0.4",
|
|
83
83
|
"@types/jsonwebtoken": "9.0.9",
|