@salesforce/packaging 0.0.8 → 0.0.9
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/CHANGELOG.md +6 -0
- package/lib/interfaces/packagingInterfacesAndType.d.ts +8 -0
- package/lib/interfaces/packagingSObjects.d.ts +11 -0
- package/lib/package/packageCreate.js +3 -4
- package/lib/package/packageVersionCreate.js +4 -6
- package/lib/package/packageVersionList.js +1 -1
- package/lib/package1/index.d.ts +1 -0
- package/lib/package1/index.js +1 -0
- package/lib/package1/packageDisplay.d.ts +9 -0
- package/lib/package1/packageDisplay.js +29 -0
- package/lib/utils/packageUtils.js +10 -13
- package/lib/utils/versionNumber.js +1 -1
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.0.9](https://github.com/forcedotcom/packaging/compare/v0.0.8...v0.0.9) (2022-07-19)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- add package1Display method for use with package1:version:display command ([ef3df30](https://github.com/forcedotcom/packaging/commit/ef3df309147bafb16367c957981a04470c6ad7df))
|
|
10
|
+
|
|
5
11
|
### [0.0.8](https://github.com/forcedotcom/packaging/compare/v0.0.7...v0.0.8) (2022-07-18)
|
|
6
12
|
|
|
7
13
|
### Features
|
|
@@ -92,6 +92,14 @@ export declare type PackageVersionListResult = {
|
|
|
92
92
|
BuildDurationInSeconds?: number;
|
|
93
93
|
HasMetadataRemoved?: boolean;
|
|
94
94
|
};
|
|
95
|
+
export declare type Package1Display = {
|
|
96
|
+
MetadataPackageVersionId: string;
|
|
97
|
+
MetadataPackageId: string;
|
|
98
|
+
Name: string;
|
|
99
|
+
Version: string;
|
|
100
|
+
ReleaseState: string;
|
|
101
|
+
BuildNumber: number;
|
|
102
|
+
};
|
|
95
103
|
export declare type PackageType = 'Managed' | 'Unlocked';
|
|
96
104
|
export declare type PackageCreateOptions = {
|
|
97
105
|
name: string;
|
|
@@ -223,4 +223,15 @@ export declare namespace PackagingSObjects {
|
|
|
223
223
|
SubscriberPackageVersionId: string;
|
|
224
224
|
MinPackageVersionId: string;
|
|
225
225
|
};
|
|
226
|
+
type MetadataPackageVersion = {
|
|
227
|
+
Id: string;
|
|
228
|
+
MetadataPackageId: string;
|
|
229
|
+
Name: string;
|
|
230
|
+
ReleaseState: 'Beta' | 'Released';
|
|
231
|
+
MajorVersion: number;
|
|
232
|
+
MinorVersion: number;
|
|
233
|
+
PatchVersion: number;
|
|
234
|
+
BuildNumber: number;
|
|
235
|
+
IsDeprecated: boolean;
|
|
236
|
+
};
|
|
226
237
|
}
|
|
@@ -32,7 +32,6 @@ exports._createPackageRequestFromContext = _createPackageRequestFromContext;
|
|
|
32
32
|
* @private
|
|
33
33
|
*/
|
|
34
34
|
function _generatePackageDirEntry(project, options) {
|
|
35
|
-
var _a, _b;
|
|
36
35
|
let packageDirs = project.getPackageDirectories();
|
|
37
36
|
if (!packageDirs) {
|
|
38
37
|
packageDirs = [];
|
|
@@ -47,8 +46,8 @@ function _generatePackageDirEntry(project, options) {
|
|
|
47
46
|
if (packageDir) {
|
|
48
47
|
// update existing entry
|
|
49
48
|
packageDir.package = options.name;
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
packageDir.versionName ?? (packageDir.versionName = pkgUtils.DEFAULT_PACKAGE_DIR.versionName);
|
|
50
|
+
packageDir.versionNumber ?? (packageDir.versionNumber = pkgUtils.DEFAULT_PACKAGE_DIR.versionNumber);
|
|
52
51
|
// set as default if this is the only entry or no other entry is the default
|
|
53
52
|
if (!Reflect.getOwnPropertyDescriptor(packageDir, 'default')) {
|
|
54
53
|
packageDir.default = !pkgUtils.getConfigPackageDirectory(packageDirs, 'default', true);
|
|
@@ -97,7 +96,7 @@ async function createPackage(connection, project, options) {
|
|
|
97
96
|
}
|
|
98
97
|
packageId = createResult.id;
|
|
99
98
|
const queryResult = await connection.tooling.query(`SELECT Id FROM Package2 WHERE Id='${packageId}'`);
|
|
100
|
-
if (!
|
|
99
|
+
if (!queryResult?.records[0]) {
|
|
101
100
|
throw messages.createError('unableToFindPackageWithId', [packageId]);
|
|
102
101
|
}
|
|
103
102
|
const record = queryResult.records[0];
|
|
@@ -48,8 +48,7 @@ class PackageVersionCreate {
|
|
|
48
48
|
}
|
|
49
49
|
// convert source to mdapi format and copy to tmp dir packaging up
|
|
50
50
|
async generateMDFolderForArtifact(options) {
|
|
51
|
-
|
|
52
|
-
const sourcepath = (_a = options.sourcePaths) !== null && _a !== void 0 ? _a : [options.sourceDir];
|
|
51
|
+
const sourcepath = options.sourcePaths ?? [options.sourceDir];
|
|
53
52
|
const componentSet = await source_deploy_retrieve_1.ComponentSetBuilder.build({
|
|
54
53
|
sourceapiversion: this.project.getSfProjectJson().get('sourceApiVersion'),
|
|
55
54
|
sourcepath,
|
|
@@ -558,10 +557,9 @@ class PackageVersionCreate {
|
|
|
558
557
|
return value;
|
|
559
558
|
}
|
|
560
559
|
async packageVersionCreate(options) {
|
|
561
|
-
var _a, _b;
|
|
562
560
|
let pollInterval = kit_1.Duration.seconds(pkgUtils.POLL_INTERVAL_SECONDS);
|
|
563
561
|
let maxRetries = 0;
|
|
564
|
-
if (
|
|
562
|
+
if (options.wait?.milliseconds > 0) {
|
|
565
563
|
if (options.skipvalidation === true) {
|
|
566
564
|
pollInterval = kit_1.Duration.seconds(POLL_INTERVAL_WITHOUT_VALIDATION_SECONDS);
|
|
567
565
|
}
|
|
@@ -573,7 +571,7 @@ class PackageVersionCreate {
|
|
|
573
571
|
await this.project.getSfProjectJson().schemaValidate();
|
|
574
572
|
}
|
|
575
573
|
// Check for empty packageDirectories
|
|
576
|
-
if (
|
|
574
|
+
if (this.project.getPackageDirectories()?.length === 0) {
|
|
577
575
|
throw messages.createError('errorEmptyPackageDirs');
|
|
578
576
|
}
|
|
579
577
|
const canonicalPackageProperty = this.resolveCanonicalPackageProperty(options);
|
|
@@ -602,7 +600,7 @@ class PackageVersionCreate {
|
|
|
602
600
|
}
|
|
603
601
|
let result;
|
|
604
602
|
if (options.wait && options.wait.milliseconds > 0) {
|
|
605
|
-
pollInterval = pollInterval
|
|
603
|
+
pollInterval = pollInterval ?? kit_1.Duration.seconds(options.wait.seconds / maxRetries);
|
|
606
604
|
if (pollInterval) {
|
|
607
605
|
result = await pkgUtils.pollForStatusWithInterval(createResult.id, maxRetries, resolvedPackageId, options.branch, this.project, this.connection, pollInterval);
|
|
608
606
|
}
|
|
@@ -51,7 +51,7 @@ exports._assembleQueryParts = _assembleQueryParts;
|
|
|
51
51
|
function _constructWhere(idsOrAliases, createdLastDays, lastModLastDays, project) {
|
|
52
52
|
const where = [];
|
|
53
53
|
// filter on given package ids
|
|
54
|
-
if (
|
|
54
|
+
if (idsOrAliases?.length > 0) {
|
|
55
55
|
// remove dups
|
|
56
56
|
const aliasesOrIds = [...new Set(idsOrAliases)];
|
|
57
57
|
// resolve any aliases
|
package/lib/package1/index.d.ts
CHANGED
package/lib/package1/index.js
CHANGED
|
@@ -21,5 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
22
22
|
*/
|
|
23
23
|
__exportStar(require("./packageVersion1GP"), exports);
|
|
24
|
+
__exportStar(require("./packageDisplay"), exports);
|
|
24
25
|
__exportStar(require("./package1VersionCreateGet"), exports);
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
import { Package1Display } from '../interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Executes server-side logic for the package1:display command
|
|
5
|
+
*
|
|
6
|
+
* @param connection
|
|
7
|
+
* @param id: id of the MetadataPackageVersion sObject
|
|
8
|
+
*/
|
|
9
|
+
export declare function package1Display(connection: Connection, id: string): Promise<Package1Display[]>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.package1Display = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Executes server-side logic for the package1:display command
|
|
12
|
+
*
|
|
13
|
+
* @param connection
|
|
14
|
+
* @param id: id of the MetadataPackageVersion sObject
|
|
15
|
+
*/
|
|
16
|
+
async function package1Display(connection, id) {
|
|
17
|
+
const query = `SELECT Id,MetadataPackageId,Name,ReleaseState,MajorVersion,MinorVersion,PatchVersion,BuildNumber FROM MetadataPackageVersion WHERE id = '${id}'`;
|
|
18
|
+
const results = (await connection.tooling.query(query)).records;
|
|
19
|
+
return results.map((result) => ({
|
|
20
|
+
MetadataPackageVersionId: result.Id,
|
|
21
|
+
MetadataPackageId: result.MetadataPackageId,
|
|
22
|
+
Name: result.Name,
|
|
23
|
+
ReleaseState: result.ReleaseState,
|
|
24
|
+
Version: `${result.MajorVersion}.${result.MinorVersion}.${result.PatchVersion}`,
|
|
25
|
+
BuildNumber: result.BuildNumber,
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
exports.package1Display = package1Display;
|
|
29
|
+
//# sourceMappingURL=packageDisplay.js.map
|
|
@@ -195,7 +195,7 @@ exports.applyErrorAction = applyErrorAction;
|
|
|
195
195
|
*/
|
|
196
196
|
async function getPackageVersionId(versionId, connection) {
|
|
197
197
|
// if it's already a 05i return it, otherwise query for it
|
|
198
|
-
if (versionId
|
|
198
|
+
if (versionId?.startsWith(exports.BY_LABEL.PACKAGE_VERSION_ID.prefix)) {
|
|
199
199
|
return versionId;
|
|
200
200
|
}
|
|
201
201
|
const query = `SELECT Id FROM Package2Version WHERE SubscriberPackageVersionId = '${versionId}'`;
|
|
@@ -410,9 +410,8 @@ exports.getInClauseItemsCount = getInClauseItemsCount;
|
|
|
410
410
|
async function getAncestorId(packageDescriptorJson, connection, project, versionNumberString, skipAncestorCheck) {
|
|
411
411
|
// eslint-disable-next-line complexity
|
|
412
412
|
return Promise.resolve().then(async () => {
|
|
413
|
-
var _a;
|
|
414
413
|
// If an id property is present, use it. Otherwise, look up the package id from the package property.
|
|
415
|
-
const packageId =
|
|
414
|
+
const packageId = packageDescriptorJson['id'] ?? getPackageIdFromAlias(packageDescriptorJson.package, project);
|
|
416
415
|
// No need to proceed if Unlocked
|
|
417
416
|
const packageType = await getPackageType(packageId, connection);
|
|
418
417
|
if (packageType === 'Unlocked') {
|
|
@@ -540,7 +539,7 @@ async function getAncestorIdHighestRelease(connection, packageId, versionNumberS
|
|
|
540
539
|
'ORDER BY MajorVersion Desc, MinorVersion Desc, PatchVersion Desc, BuildNumber Desc LIMIT 1';
|
|
541
540
|
const majorMinorVersionResult = await connection.tooling.query(query);
|
|
542
541
|
const majorMinorVersionRecords = majorMinorVersionResult.records;
|
|
543
|
-
if (majorMinorVersionRecords &&
|
|
542
|
+
if (majorMinorVersionRecords && majorMinorVersionRecords?.length === 1 && majorMinorVersionRecords[0]) {
|
|
544
543
|
result.finalAncestorId = majorMinorVersionRecords[0].Id;
|
|
545
544
|
}
|
|
546
545
|
else {
|
|
@@ -587,7 +586,7 @@ function getConfigPackageDirectories(project) {
|
|
|
587
586
|
}
|
|
588
587
|
exports.getConfigPackageDirectories = getConfigPackageDirectories;
|
|
589
588
|
function getConfigPackageDirectory(packageDirs, lookupProperty, lookupValue) {
|
|
590
|
-
return packageDirs
|
|
589
|
+
return packageDirs?.find((pkgDir) => pkgDir[lookupProperty] === lookupValue);
|
|
591
590
|
}
|
|
592
591
|
exports.getConfigPackageDirectory = getConfigPackageDirectory;
|
|
593
592
|
/**
|
|
@@ -619,7 +618,7 @@ exports.convertCamelCaseStringToSentence = convertCamelCaseStringToSentence;
|
|
|
619
618
|
* @returns an array of alias for the given id.
|
|
620
619
|
*/
|
|
621
620
|
function getPackageAliasesFromId(packageId, project) {
|
|
622
|
-
const packageAliases =
|
|
621
|
+
const packageAliases = project?.getSfProjectJson().getContents().packageAliases || {};
|
|
623
622
|
// check for a matching alias
|
|
624
623
|
return Object.entries(packageAliases)
|
|
625
624
|
.filter((alias) => alias[1] === packageId)
|
|
@@ -664,7 +663,6 @@ async function pollForStatusWithInterval(id, retries, packageId, branch, withPro
|
|
|
664
663
|
let remainingRetries = retries;
|
|
665
664
|
const pollingClient = await core_1.PollingClient.create({
|
|
666
665
|
poll: async () => {
|
|
667
|
-
var _a;
|
|
668
666
|
const results = await pvcr.byId(id, connection);
|
|
669
667
|
if (_isStatusEqualTo(results, [Package2VersionStatus.success, Package2VersionStatus.error])) {
|
|
670
668
|
// complete
|
|
@@ -693,7 +691,7 @@ async function pollForStatusWithInterval(id, retries, packageId, branch, withPro
|
|
|
693
691
|
}
|
|
694
692
|
else {
|
|
695
693
|
let status = 'Unknown Error';
|
|
696
|
-
if (
|
|
694
|
+
if (results?.length > 0 && results[0].Error.length > 0) {
|
|
697
695
|
const errors = [];
|
|
698
696
|
// for multiple errors, display one per line prefixed with (x)
|
|
699
697
|
if (results[0].Error.length > 1) {
|
|
@@ -716,7 +714,7 @@ async function pollForStatusWithInterval(id, retries, packageId, branch, withPro
|
|
|
716
714
|
message: '',
|
|
717
715
|
remainingTime,
|
|
718
716
|
});
|
|
719
|
-
logger.info(`Request in progress. Sleeping ${interval} seconds. Will wait a total of ${remainingTime.seconds} more seconds before timing out. Current Status='${convertCamelCaseStringToSentence(
|
|
717
|
+
logger.info(`Request in progress. Sleeping ${interval} seconds. Will wait a total of ${remainingTime.seconds} more seconds before timing out. Current Status='${convertCamelCaseStringToSentence(results[0]?.Status)}'`);
|
|
720
718
|
remainingRetries--;
|
|
721
719
|
return { completed: false, payload: results[0] };
|
|
722
720
|
}
|
|
@@ -747,7 +745,7 @@ async function _generatePackageAliasEntry(connection, project, packageVersionId,
|
|
|
747
745
|
const query = `SELECT Name FROM Package2 WHERE Id = '${packageId}'`;
|
|
748
746
|
packageName = await connection.tooling
|
|
749
747
|
.query(query)
|
|
750
|
-
.then((pkgQueryResult) =>
|
|
748
|
+
.then((pkgQueryResult) => pkgQueryResult.records[0]?.Name);
|
|
751
749
|
}
|
|
752
750
|
else {
|
|
753
751
|
packageName = aliasForPackageId[0];
|
|
@@ -766,7 +764,7 @@ async function _generatePackageAliasEntry(connection, project, packageVersionId,
|
|
|
766
764
|
* @returns {boolean} if one of the values in status is found.
|
|
767
765
|
*/
|
|
768
766
|
function _isStatusEqualTo(results, statuses) {
|
|
769
|
-
return
|
|
767
|
+
return results?.length <= 0 ? false : statuses?.some((status) => results[0].Status === status);
|
|
770
768
|
}
|
|
771
769
|
// added for unit testing
|
|
772
770
|
function getSoqlWhereClauseMaxLength() {
|
|
@@ -782,8 +780,7 @@ function formatDate(date) {
|
|
|
782
780
|
exports.formatDate = formatDate;
|
|
783
781
|
function combineSaveErrors(sObject, crudOperation, errors) {
|
|
784
782
|
const errorMessages = errors.map((error) => {
|
|
785
|
-
|
|
786
|
-
const fieldsString = ((_a = error.fields) === null || _a === void 0 ? void 0 : _a.length) > 0 ? `Fields: [${error.fields.join(', ')}]` : '';
|
|
783
|
+
const fieldsString = error.fields?.length > 0 ? `Fields: [${error.fields.join(', ')}]` : '';
|
|
787
784
|
return `Error: ${error.errorCode} Message: ${error.message} ${fieldsString}`;
|
|
788
785
|
});
|
|
789
786
|
const sfError = messages.createError('errorDuringSObjectCRUDOperation', [
|
|
@@ -30,7 +30,7 @@ class VersionNumber {
|
|
|
30
30
|
throw messages.createError('errorMissingVersionNumber');
|
|
31
31
|
}
|
|
32
32
|
const version = versionString.split('.');
|
|
33
|
-
if (
|
|
33
|
+
if (version?.length === 4) {
|
|
34
34
|
const [major, minor, patch, build] = version;
|
|
35
35
|
const asNumbers = [major, minor, patch, build].map((v) => parseInt(v, 10));
|
|
36
36
|
if (asNumbers.slice(0, 3).some((v) => isNaN(v))) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/packaging",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "packing libraries to Salesforce packaging platform",
|
|
5
5
|
"main": "lib/exported",
|
|
6
6
|
"types": "lib/exported.d.ts",
|
|
@@ -43,13 +43,15 @@
|
|
|
43
43
|
"debug": "^4.3.4",
|
|
44
44
|
"globby": "^11",
|
|
45
45
|
"js2xmlparser": "^4.0.2",
|
|
46
|
-
"jsforce": "
|
|
46
|
+
"jsforce": "beta",
|
|
47
|
+
"mkdirp": "1.0.4",
|
|
48
|
+
"ts-retry-promise": "^0.6.1",
|
|
47
49
|
"jszip": "^3.10.0",
|
|
48
50
|
"xml2js": "^0.4.23",
|
|
49
51
|
"xmldom-sfdx-encoding": "^0.1.30"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
|
-
"@salesforce/cli-plugins-testkit": "^2.3.
|
|
54
|
+
"@salesforce/cli-plugins-testkit": "^2.3.4",
|
|
53
55
|
"@salesforce/dev-config": "^3.0.1",
|
|
54
56
|
"@salesforce/dev-scripts": "^2.0.2",
|
|
55
57
|
"@salesforce/prettier-config": "^0.0.2",
|