@salesforce/packaging 0.1.20 → 1.0.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/interfaces/packagingInterfacesAndType.d.ts +1 -1
- package/lib/package/index.d.ts +1 -5
- package/lib/package/index.js +3 -5
- package/lib/package/package.d.ts +9 -0
- package/lib/package/package.js +22 -6
- package/lib/package/packageAncestry.d.ts +1 -1
- package/lib/package/packageAncestry.js +5 -5
- package/lib/package/packageConvert.js +13 -16
- package/lib/package/packageDelete.js +3 -5
- package/lib/package/packageInstall.js +7 -8
- package/lib/package/packageUninstall.js +2 -2
- package/lib/package/packageVersion.js +17 -17
- package/lib/package/packageVersionCreate.js +38 -36
- package/lib/package/packageVersionCreateRequest.js +2 -2
- package/lib/package/packageVersionList.js +2 -2
- package/lib/package/subscriberPackageVersion.d.ts +8 -2
- package/lib/package/subscriberPackageVersion.js +21 -6
- package/lib/{utils → package}/versionNumber.d.ts +0 -0
- package/lib/{utils → package}/versionNumber.js +0 -0
- package/lib/package1/index.d.ts +1 -1
- package/lib/package1/index.js +3 -15
- package/lib/utils/index.d.ts +1 -3
- package/lib/utils/index.js +5 -17
- package/lib/utils/packageUtils.d.ts +25 -48
- package/lib/utils/packageUtils.js +82 -71
- package/package.json +2 -2
- package/lib/constants.d.ts +0 -26
- package/lib/constants.js +0 -45
- package/lib/package/packageInstalledList.d.ts +0 -3
- package/lib/package/packageInstalledList.js +0 -15
- package/lib/utils/srcDevUtils.d.ts +0 -11
- package/lib/utils/srcDevUtils.js +0 -65
- package/lib/utils/uniqid.d.ts +0 -14
- package/lib/utils/uniqid.js +0 -34
|
@@ -4,7 +4,7 @@ import { SaveResult } from 'jsforce';
|
|
|
4
4
|
import { Attributes } from 'graphology-types';
|
|
5
5
|
import { Optional } from '@salesforce/ts-types';
|
|
6
6
|
import { PackageProfileApi } from '../package/packageProfileApi';
|
|
7
|
-
import { PackageAncestryNode } from '../package';
|
|
7
|
+
import { PackageAncestryNode } from '../package/packageAncestry';
|
|
8
8
|
import { PackagingSObjects } from './packagingSObjects';
|
|
9
9
|
import Package2VersionStatus = PackagingSObjects.Package2VersionStatus;
|
|
10
10
|
import PackageInstallRequest = PackagingSObjects.PackageInstallRequest;
|
package/lib/package/index.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export * from './package';
|
|
2
|
-
export * from './packageInstall';
|
|
3
2
|
export * from './packageVersion';
|
|
4
|
-
export * from './packageVersionCreateRequest';
|
|
5
|
-
export * from './packageInstalledList';
|
|
6
|
-
export * from './packageVersionCreateRequestReport';
|
|
7
|
-
export * from './packageAncestry';
|
|
8
3
|
export * from './subscriberPackageVersion';
|
|
4
|
+
export { VersionNumber } from './versionNumber';
|
package/lib/package/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.VersionNumber = void 0;
|
|
17
18
|
/*
|
|
18
19
|
* Copyright (c) 2022, salesforce.com, inc.
|
|
19
20
|
* All rights reserved.
|
|
@@ -21,11 +22,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
22
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
22
23
|
*/
|
|
23
24
|
__exportStar(require("./package"), exports);
|
|
24
|
-
__exportStar(require("./packageInstall"), exports);
|
|
25
25
|
__exportStar(require("./packageVersion"), exports);
|
|
26
|
-
__exportStar(require("./packageVersionCreateRequest"), exports);
|
|
27
|
-
__exportStar(require("./packageInstalledList"), exports);
|
|
28
|
-
__exportStar(require("./packageVersionCreateRequestReport"), exports);
|
|
29
|
-
__exportStar(require("./packageAncestry"), exports);
|
|
30
26
|
__exportStar(require("./subscriberPackageVersion"), exports);
|
|
27
|
+
var versionNumber_1 = require("./versionNumber");
|
|
28
|
+
Object.defineProperty(exports, "VersionNumber", { enumerable: true, get: function () { return versionNumber_1.VersionNumber; } });
|
|
31
29
|
//# sourceMappingURL=index.js.map
|
package/lib/package/package.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Connection, SfProject } from '@salesforce/core';
|
|
2
2
|
import { ConvertPackageOptions, PackageCreateOptions, PackageOptions, PackageSaveResult, PackageType, PackageUpdateOptions, PackageVersionCreateRequestResult, PackageVersionListOptions, PackageVersionListResult, PackagingSObjects } from '../interfaces';
|
|
3
|
+
import { PackageAncestry } from './packageAncestry';
|
|
3
4
|
export declare const Package2Fields: string[];
|
|
4
5
|
/**
|
|
5
6
|
* Package class.
|
|
@@ -38,6 +39,14 @@ export declare class Package {
|
|
|
38
39
|
* @param options - see {@link PackageVersionListOptions}
|
|
39
40
|
*/
|
|
40
41
|
static listVersions(connection: Connection, project: SfProject, options?: PackageVersionListOptions): Promise<PackageVersionListResult[]>;
|
|
42
|
+
/**
|
|
43
|
+
* create a PackageAncestry instance
|
|
44
|
+
*
|
|
45
|
+
* @param packageId to get version information for
|
|
46
|
+
* @param project SfProject instance
|
|
47
|
+
* @param connection Hub Org Connection
|
|
48
|
+
*/
|
|
49
|
+
static getAncestry(packageId: string, project: SfProject, connection: Connection): Promise<PackageAncestry>;
|
|
41
50
|
/**
|
|
42
51
|
* Convert a 1st generation package to a 2nd generation package.
|
|
43
52
|
* See {@link ConvertPackageOptions} for conversion options.
|
package/lib/package/package.js
CHANGED
|
@@ -8,11 +8,12 @@ exports.Package = exports.Package2Fields = void 0;
|
|
|
8
8
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
9
|
*/
|
|
10
10
|
const core_1 = require("@salesforce/core");
|
|
11
|
-
const
|
|
11
|
+
const packageUtils_1 = require("../utils/packageUtils");
|
|
12
12
|
const packageCreate_1 = require("./packageCreate");
|
|
13
13
|
const packageConvert_1 = require("./packageConvert");
|
|
14
14
|
const packageVersionList_1 = require("./packageVersionList");
|
|
15
15
|
const packageDelete_1 = require("./packageDelete");
|
|
16
|
+
const packageAncestry_1 = require("./packageAncestry");
|
|
16
17
|
const packagePrefixes = {
|
|
17
18
|
PackageId: '0Ho',
|
|
18
19
|
SubscriberPackageVersionId: '04t',
|
|
@@ -50,7 +51,8 @@ class Package {
|
|
|
50
51
|
this.options = options;
|
|
51
52
|
let packageId = this.options.packageAliasOrId;
|
|
52
53
|
if (!packageId.startsWith(packagePrefixes.PackageId)) {
|
|
53
|
-
packageId =
|
|
54
|
+
packageId =
|
|
55
|
+
this.options.project.getPackageIdFromAlias(this.options.packageAliasOrId) ?? this.options.packageAliasOrId;
|
|
54
56
|
if (packageId === this.options.packageAliasOrId) {
|
|
55
57
|
throw messages.createError('packageAliasNotFound', [this.options.packageAliasOrId]);
|
|
56
58
|
}
|
|
@@ -93,10 +95,10 @@ class Package {
|
|
|
93
95
|
static async listVersions(connection, project, options) {
|
|
94
96
|
// resolve/verify packages
|
|
95
97
|
const packages = options?.packages?.map((pkg) => {
|
|
96
|
-
const id =
|
|
98
|
+
const id = project.getPackageIdFromAlias(pkg) ?? pkg;
|
|
97
99
|
// validate ID
|
|
98
100
|
if (id.startsWith('0Ho')) {
|
|
99
|
-
(0,
|
|
101
|
+
(0, packageUtils_1.validateId)(packageUtils_1.BY_LABEL.PACKAGE_ID, id);
|
|
100
102
|
return id;
|
|
101
103
|
}
|
|
102
104
|
else {
|
|
@@ -107,6 +109,20 @@ class Package {
|
|
|
107
109
|
opts.packages = packages || [];
|
|
108
110
|
return (await (0, packageVersionList_1.listPackageVersions)({ ...opts, ...{ connection } })).records;
|
|
109
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* create a PackageAncestry instance
|
|
114
|
+
*
|
|
115
|
+
* @param packageId to get version information for
|
|
116
|
+
* @param project SfProject instance
|
|
117
|
+
* @param connection Hub Org Connection
|
|
118
|
+
*/
|
|
119
|
+
static async getAncestry(packageId, project, connection) {
|
|
120
|
+
return packageAncestry_1.PackageAncestry.create({
|
|
121
|
+
packageId,
|
|
122
|
+
project,
|
|
123
|
+
connection,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
110
126
|
/**
|
|
111
127
|
* Convert a 1st generation package to a 2nd generation package.
|
|
112
128
|
* See {@link ConvertPackageOptions} for conversion options.
|
|
@@ -182,7 +198,7 @@ class Package {
|
|
|
182
198
|
return result;
|
|
183
199
|
}
|
|
184
200
|
catch (err) {
|
|
185
|
-
throw (0,
|
|
201
|
+
throw (0, packageUtils_1.applyErrorAction)((0, packageUtils_1.massageErrorMessage)(err));
|
|
186
202
|
}
|
|
187
203
|
}
|
|
188
204
|
/**
|
|
@@ -199,7 +215,7 @@ class Package {
|
|
|
199
215
|
return this.packageData;
|
|
200
216
|
}
|
|
201
217
|
verifyAliasForId() {
|
|
202
|
-
if (
|
|
218
|
+
if (this.options.project.getAliasesFromPackageId(this.packageId).length === 0) {
|
|
203
219
|
throw new core_1.SfError(messages.getMessage('couldNotFindAliasForId', [this.packageId]));
|
|
204
220
|
}
|
|
205
221
|
}
|
|
@@ -3,7 +3,7 @@ import { AsyncCreatable } from '@salesforce/kit';
|
|
|
3
3
|
import { Tree } from '@oclif/core/lib/cli-ux/styled/tree';
|
|
4
4
|
import { Attributes } from 'graphology-types';
|
|
5
5
|
import { AncestryRepresentationProducer, AncestryRepresentationProducerOptions, PackageAncestryNodeOptions, PackageAncestryOptions } from '../interfaces';
|
|
6
|
-
import { VersionNumber } from '
|
|
6
|
+
import { VersionNumber } from './versionNumber';
|
|
7
7
|
/**
|
|
8
8
|
* A class that represents the package ancestry graph.
|
|
9
9
|
* Given a package Id (0Ho) or a package version Id (04t), it will build a graph of the package's ancestors.
|
|
@@ -26,17 +26,17 @@ const kit_1 = require("@salesforce/kit");
|
|
|
26
26
|
const tree_1 = require("@oclif/core/lib/cli-ux/styled/tree");
|
|
27
27
|
const graphology_traversal_1 = require("graphology-traversal");
|
|
28
28
|
const pkgUtils = require("../utils/packageUtils");
|
|
29
|
-
const utils_1 = require("../utils");
|
|
30
29
|
const packageVersion_1 = require("./packageVersion");
|
|
31
30
|
const package_1 = require("./package");
|
|
31
|
+
const versionNumber_1 = require("./versionNumber");
|
|
32
32
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
33
33
|
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'package_ancestry');
|
|
34
34
|
const SELECT_PACKAGE_VERSION = 'SELECT AncestorId, SubscriberPackageVersionId, MajorVersion, MinorVersion, PatchVersion, BuildNumber FROM Package2Version';
|
|
35
35
|
// Add this to query calls to only show released package versions in the output
|
|
36
36
|
const releasedOnlyFilter = ' AND IsReleased = true';
|
|
37
37
|
const sortAncestryNodeData = (a, b) => {
|
|
38
|
-
const aVersion = new
|
|
39
|
-
const bVersion = new
|
|
38
|
+
const aVersion = new versionNumber_1.VersionNumber(a.options.node.MajorVersion, a.options.node.MinorVersion, a.options.node.PatchVersion, a.options.node.BuildNumber);
|
|
39
|
+
const bVersion = new versionNumber_1.VersionNumber(b.options.node.MajorVersion, b.options.node.MinorVersion, b.options.node.PatchVersion, b.options.node.BuildNumber);
|
|
40
40
|
return aVersion.compareTo(bVersion);
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
@@ -161,7 +161,7 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
161
161
|
}
|
|
162
162
|
async getRoots() {
|
|
163
163
|
let roots = [];
|
|
164
|
-
__classPrivateFieldSet(this, _PackageAncestry_requestedPackageId,
|
|
164
|
+
__classPrivateFieldSet(this, _PackageAncestry_requestedPackageId, this.options.project.getPackageIdFromAlias(this.options.packageId) ?? this.options.packageId, "f");
|
|
165
165
|
switch (this.requestedPackageId.slice(0, 3)) {
|
|
166
166
|
case '0Ho':
|
|
167
167
|
pkgUtils.validateId(pkgUtils.BY_LABEL.PACKAGE_ID, this.requestedPackageId);
|
|
@@ -408,7 +408,7 @@ class PackageAncestryNode extends kit_1.AsyncCreatable {
|
|
|
408
408
|
_PackageAncestryNode_AncestorId.set(this, void 0);
|
|
409
409
|
_PackageAncestryNode_SubscriberPackageVersionId.set(this, void 0);
|
|
410
410
|
_PackageAncestryNode_depthCounter.set(this, void 0);
|
|
411
|
-
__classPrivateFieldSet(this, _PackageAncestryNode_version, new
|
|
411
|
+
__classPrivateFieldSet(this, _PackageAncestryNode_version, new versionNumber_1.VersionNumber(this.options.MajorVersion, this.options.MinorVersion, this.options.PatchVersion, this.options.BuildNumber), "f");
|
|
412
412
|
__classPrivateFieldSet(this, _PackageAncestryNode_AncestorId, this.options.AncestorId, "f");
|
|
413
413
|
__classPrivateFieldSet(this, _PackageAncestryNode_SubscriberPackageVersionId, this.options.SubscriberPackageVersionId, "f");
|
|
414
414
|
__classPrivateFieldSet(this, _PackageAncestryNode_MajorVersion, typeof this.options.MajorVersion === 'number'
|
|
@@ -13,12 +13,9 @@ const fs = require("fs");
|
|
|
13
13
|
const core_1 = require("@salesforce/core");
|
|
14
14
|
const kit_1 = require("@salesforce/kit");
|
|
15
15
|
const scratchOrgSettingsGenerator_1 = require("@salesforce/core/lib/org/scratchOrgSettingsGenerator");
|
|
16
|
-
const uniqid_1 = require("../utils/uniqid");
|
|
17
16
|
const pkgUtils = require("../utils/packageUtils");
|
|
18
17
|
const interfaces_1 = require("../interfaces");
|
|
19
|
-
const
|
|
20
|
-
const srcDevUtil = require("../utils/srcDevUtils");
|
|
21
|
-
const utils_1 = require("../utils");
|
|
18
|
+
const packageUtils_1 = require("../utils/packageUtils");
|
|
22
19
|
const packageVersionCreateRequest_1 = require("./packageVersionCreateRequest");
|
|
23
20
|
const pvcr = require("./packageVersionCreateRequest");
|
|
24
21
|
var Package2VersionStatus = interfaces_1.PackagingSObjects.Package2VersionStatus;
|
|
@@ -67,7 +64,7 @@ async function convertPackage(pkg, connection, options, project) {
|
|
|
67
64
|
maxRetries = (60 / pkgUtils.POLL_INTERVAL_SECONDS) * options.wait.minutes;
|
|
68
65
|
}
|
|
69
66
|
const packageId = await findOrCreatePackage2(pkg, connection);
|
|
70
|
-
const apiVersion =
|
|
67
|
+
const apiVersion = project?.getSfProjectJson()?.get('sourceApiVersion');
|
|
71
68
|
const request = await createPackageVersionCreateRequest({
|
|
72
69
|
installationkey: options.installationKey,
|
|
73
70
|
definitionfile: options.definitionfile,
|
|
@@ -101,13 +98,13 @@ exports.convertPackage = convertPackage;
|
|
|
101
98
|
* @private
|
|
102
99
|
*/
|
|
103
100
|
async function createPackageVersionCreateRequest(context, packageId, apiVersion) {
|
|
104
|
-
const uniqueId = (0,
|
|
101
|
+
const uniqueId = (0, packageUtils_1.uniqid)({ template: `${packageId}-%s` });
|
|
105
102
|
const packageVersTmpRoot = path.join(os.tmpdir(), uniqueId);
|
|
106
103
|
const packageVersMetadataFolder = path.join(packageVersTmpRoot, 'md-files');
|
|
107
104
|
const packageVersBlobDirectory = path.join(packageVersTmpRoot, 'package-version-info');
|
|
108
105
|
const settingsZipFile = path.join(packageVersBlobDirectory, 'settings.zip');
|
|
109
106
|
const metadataZipFile = path.join(packageVersBlobDirectory, 'package.zip');
|
|
110
|
-
const packageVersBlobZipFile = path.join(packageVersTmpRoot,
|
|
107
|
+
const packageVersBlobZipFile = path.join(packageVersTmpRoot, 'package-version-info.zip');
|
|
111
108
|
const packageDescriptorJson = {
|
|
112
109
|
id: packageId,
|
|
113
110
|
};
|
|
@@ -140,15 +137,15 @@ async function createPackageVersionCreateRequest(context, packageId, apiVersion)
|
|
|
140
137
|
await fs.promises.mkdir(packageVersMetadataFolder, { recursive: true });
|
|
141
138
|
await settingsGenerator.createDeploy();
|
|
142
139
|
await settingsGenerator.createDeployPackageContents(apiVersion);
|
|
143
|
-
await
|
|
140
|
+
await pkgUtils.zipDir(`${settingsGenerator.getDestinationPath()}${path.sep}${settingsGenerator.getShapeDirName()}`, settingsZipFile);
|
|
144
141
|
const shapeDirectory = `${settingsGenerator.getDestinationPath()}${path.sep}${settingsGenerator.getShapeDirName()}`;
|
|
145
142
|
const currentPackageXml = await fs.promises.readFile(path.join(shapeDirectory, 'package.xml'), 'utf8');
|
|
146
143
|
await fs.promises.writeFile(path.join(packageVersMetadataFolder, 'package.xml'), currentPackageXml, 'utf-8');
|
|
147
144
|
// Zip the packageVersMetadataFolder folder and put the zip in {packageVersBlobDirectory}/package.zip
|
|
148
|
-
await
|
|
149
|
-
await fs.promises.writeFile(path.join(packageVersBlobDirectory,
|
|
145
|
+
await pkgUtils.zipDir(packageVersMetadataFolder, metadataZipFile);
|
|
146
|
+
await fs.promises.writeFile(path.join(packageVersBlobDirectory, 'package2-descriptor.json'), JSON.stringify(packageDescriptorJson, undefined, 2));
|
|
150
147
|
// Zip the Version Info and package.zip files into another zip
|
|
151
|
-
await
|
|
148
|
+
await pkgUtils.zipDir(packageVersBlobDirectory, packageVersBlobZipFile);
|
|
152
149
|
return createRequestObject(packageId, context, packageVersTmpRoot, packageVersBlobZipFile);
|
|
153
150
|
}
|
|
154
151
|
exports.createPackageVersionCreateRequest = createPackageVersionCreateRequest;
|
|
@@ -164,7 +161,7 @@ async function createRequestObject(packageId, options, packageVersTmpRoot, packa
|
|
|
164
161
|
await fs.promises.rm(packageVersTmpRoot, { recursive: true });
|
|
165
162
|
return requestObject;
|
|
166
163
|
}
|
|
167
|
-
async function pollForStatusWithInterval(id, retries, packageId, branch,
|
|
164
|
+
async function pollForStatusWithInterval(id, retries, packageId, branch, project, connection, interval) {
|
|
168
165
|
let remainingRetries = retries;
|
|
169
166
|
const pollingClient = await core_1.PollingClient.create({
|
|
170
167
|
poll: async () => {
|
|
@@ -174,7 +171,7 @@ async function pollForStatusWithInterval(id, retries, packageId, branch, withPro
|
|
|
174
171
|
if (isStatusEqualTo(results, [Package2VersionStatus.success])) {
|
|
175
172
|
// update sfdx-project.json
|
|
176
173
|
let projectUpdated = false;
|
|
177
|
-
if (
|
|
174
|
+
if (project && !process.env.SFDX_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE) {
|
|
178
175
|
projectUpdated = true;
|
|
179
176
|
const query = `SELECT MajorVersion, MinorVersion, PatchVersion, BuildNumber FROM Package2Version WHERE Id = '${results[0].Package2VersionId}'`;
|
|
180
177
|
const packageVersionVersionString = await connection.tooling
|
|
@@ -183,9 +180,9 @@ async function pollForStatusWithInterval(id, retries, packageId, branch, withPro
|
|
|
183
180
|
const record = pkgQueryResult.records[0];
|
|
184
181
|
return `${record.MajorVersion}.${record.MinorVersion}.${record.PatchVersion}-${record.BuildNumber}`;
|
|
185
182
|
});
|
|
186
|
-
const [alias, writtenId] = await (0,
|
|
187
|
-
|
|
188
|
-
await
|
|
183
|
+
const [alias, writtenId] = await (0, packageUtils_1.generatePackageAliasEntry)(connection, project, results[0].SubscriberPackageVersionId, packageVersionVersionString, branch, packageId);
|
|
184
|
+
project.getSfProjectJson().addPackageAlias(alias, writtenId);
|
|
185
|
+
await project.getSfProjectJson().write();
|
|
189
186
|
}
|
|
190
187
|
await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageEvents.convert.success, {
|
|
191
188
|
id,
|
|
@@ -7,12 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.deletePackage = void 0;
|
|
10
|
-
const pkgUtils = require("../utils/packageUtils");
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
10
|
const packageUtils_1 = require("../utils/packageUtils");
|
|
13
11
|
async function deletePackage(idOrAlias, project, connection, undelete) {
|
|
14
|
-
const packageId =
|
|
15
|
-
|
|
12
|
+
const packageId = project.getPackageIdFromAlias(idOrAlias) ?? idOrAlias;
|
|
13
|
+
(0, packageUtils_1.validateId)(packageUtils_1.BY_LABEL.PACKAGE_ID, packageId);
|
|
16
14
|
const request = {};
|
|
17
15
|
request.Id = packageId;
|
|
18
16
|
const isUndelete = undelete;
|
|
@@ -21,7 +19,7 @@ async function deletePackage(idOrAlias, project, connection, undelete) {
|
|
|
21
19
|
throw (0, packageUtils_1.applyErrorAction)((0, packageUtils_1.massageErrorMessage)(err));
|
|
22
20
|
});
|
|
23
21
|
if (!updateResult.success) {
|
|
24
|
-
throw (0,
|
|
22
|
+
throw (0, packageUtils_1.combineSaveErrors)('Package2', 'update', updateResult.errors);
|
|
25
23
|
}
|
|
26
24
|
return updateResult;
|
|
27
25
|
}
|
|
@@ -9,9 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.pollStatus = exports.waitForPublish = exports.getInstallationStatus = exports.isErrorPackageNotAvailable = exports.isErrorFromSPVQueryRestriction = exports.getStatus = exports.createPackageInstallRequest = void 0;
|
|
10
10
|
const core_1 = require("@salesforce/core");
|
|
11
11
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
12
|
-
const
|
|
12
|
+
const packageUtils_1 = require("../utils/packageUtils");
|
|
13
13
|
const interfaces_1 = require("../interfaces");
|
|
14
|
-
const constants_1 = require("../constants");
|
|
15
14
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
16
15
|
const installMsgs = core_1.Messages.loadMessages('@salesforce/packaging', 'package_install');
|
|
17
16
|
let logger;
|
|
@@ -32,7 +31,7 @@ async function createPackageInstallRequest(connection, pkgInstallCreateRequest,
|
|
|
32
31
|
};
|
|
33
32
|
const request = Object.assign({}, defaults, pkgInstallCreateRequest);
|
|
34
33
|
if (request.Password) {
|
|
35
|
-
request.Password = (0,
|
|
34
|
+
request.Password = (0, packageUtils_1.escapeInstallationKey)(request.Password);
|
|
36
35
|
}
|
|
37
36
|
// Only unlocked packages can change the UpgradeType and ApexCompile options from the defaults.
|
|
38
37
|
if (packageType !== 'Unlocked') {
|
|
@@ -78,20 +77,20 @@ function isErrorPackageNotAvailable(err) {
|
|
|
78
77
|
exports.isErrorPackageNotAvailable = isErrorPackageNotAvailable;
|
|
79
78
|
async function getInstallationStatus(subscriberPackageVersionId, installationKey, connection) {
|
|
80
79
|
const QUERY_NO_KEY = `SELECT Id, SubscriberPackageId, InstallValidationStatus FROM SubscriberPackageVersion WHERE Id ='${subscriberPackageVersionId}'`;
|
|
81
|
-
const escapedInstallationKey = installationKey ? (0,
|
|
80
|
+
const escapedInstallationKey = installationKey ? (0, packageUtils_1.escapeInstallationKey)(installationKey) : null;
|
|
82
81
|
const queryWithKey = `${QUERY_NO_KEY} AND InstallationKey ='${escapedInstallationKey}'`;
|
|
83
82
|
return connection.tooling.query(queryWithKey);
|
|
84
83
|
}
|
|
85
84
|
exports.getInstallationStatus = getInstallationStatus;
|
|
86
85
|
async function waitForPublish(connection, subscriberPackageVersionId, frequency, timeout, installationKey) {
|
|
87
|
-
const pollingTimeout = (0,
|
|
86
|
+
const pollingTimeout = (0, packageUtils_1.numberToDuration)(timeout || 0);
|
|
88
87
|
if (pollingTimeout.milliseconds <= 0) {
|
|
89
88
|
return;
|
|
90
89
|
}
|
|
91
90
|
let queryResult;
|
|
92
91
|
let installValidationStatus;
|
|
93
92
|
const pollingOptions = {
|
|
94
|
-
frequency: (0,
|
|
93
|
+
frequency: (0, packageUtils_1.numberToDuration)(frequency || 0),
|
|
95
94
|
timeout: pollingTimeout,
|
|
96
95
|
poll: async () => {
|
|
97
96
|
queryResult = await getInstallationStatus(subscriberPackageVersionId, installationKey, connection);
|
|
@@ -133,8 +132,8 @@ exports.waitForPublish = waitForPublish;
|
|
|
133
132
|
async function pollStatus(connection, installRequestId, options) {
|
|
134
133
|
let packageInstallRequest;
|
|
135
134
|
const { pollingFrequency, pollingTimeout } = options;
|
|
136
|
-
const frequency = (0,
|
|
137
|
-
const timeout = (0,
|
|
135
|
+
const frequency = (0, packageUtils_1.numberToDuration)(pollingFrequency || 5000);
|
|
136
|
+
const timeout = (0, packageUtils_1.numberToDuration)(pollingTimeout || 300000);
|
|
138
137
|
const pollingOptions = {
|
|
139
138
|
frequency,
|
|
140
139
|
timeout,
|
|
@@ -11,7 +11,7 @@ const os = require("os");
|
|
|
11
11
|
const core_1 = require("@salesforce/core");
|
|
12
12
|
const kit_1 = require("@salesforce/kit");
|
|
13
13
|
const interfaces_1 = require("../interfaces");
|
|
14
|
-
const
|
|
14
|
+
const packageUtils_1 = require("../utils/packageUtils");
|
|
15
15
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
16
16
|
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'package_uninstall');
|
|
17
17
|
const pkgMessages = core_1.Messages.loadMessages('@salesforce/packaging', 'package');
|
|
@@ -68,7 +68,7 @@ async function uninstallPackage(id, conn, frequency = kit_1.Duration.seconds(0),
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
catch (err) {
|
|
71
|
-
throw (0,
|
|
71
|
+
throw (0, packageUtils_1.applyErrorAction)((0, packageUtils_1.massageErrorMessage)(err));
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
exports.uninstallPackage = uninstallPackage;
|
|
@@ -10,7 +10,7 @@ exports.PackageVersion = exports.Package2VersionFields = void 0;
|
|
|
10
10
|
const core_1 = require("@salesforce/core");
|
|
11
11
|
const kit_1 = require("@salesforce/kit");
|
|
12
12
|
const interfaces_1 = require("../interfaces");
|
|
13
|
-
const
|
|
13
|
+
const packageUtils_1 = require("../utils/packageUtils");
|
|
14
14
|
const packageVersionCreate_1 = require("./packageVersionCreate");
|
|
15
15
|
const packageVersionReport_1 = require("./packageVersionReport");
|
|
16
16
|
const packageVersionCreateRequestReport_1 = require("./packageVersionCreateRequestReport");
|
|
@@ -59,11 +59,11 @@ class PackageVersion {
|
|
|
59
59
|
const id = this.resolveId();
|
|
60
60
|
// validate ID
|
|
61
61
|
if (id.startsWith('04t')) {
|
|
62
|
-
(0,
|
|
62
|
+
(0, packageUtils_1.validateId)(packageUtils_1.BY_LABEL.SUBSCRIBER_PACKAGE_VERSION_ID, id);
|
|
63
63
|
this.data.SubscriberPackageVersionId = id;
|
|
64
64
|
}
|
|
65
65
|
else if (id.startsWith('05i')) {
|
|
66
|
-
(0,
|
|
66
|
+
(0, packageUtils_1.validateId)(packageUtils_1.BY_LABEL.PACKAGE_VERSION_ID, id);
|
|
67
67
|
this.data.Id = id;
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
@@ -88,7 +88,7 @@ class PackageVersion {
|
|
|
88
88
|
return PackageVersion.pollCreateStatus(createResult.Id, options.connection, options.project, polling).catch((err) => {
|
|
89
89
|
// TODO
|
|
90
90
|
// until package2 is GA, wrap perm-based errors w/ 'contact sfdc' action (REMOVE once package2 is GA'd)
|
|
91
|
-
throw (0,
|
|
91
|
+
throw (0, packageUtils_1.applyErrorAction)((0, packageUtils_1.massageErrorMessage)(err));
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
@@ -104,7 +104,7 @@ class PackageVersion {
|
|
|
104
104
|
}).catch((err) => {
|
|
105
105
|
// TODO
|
|
106
106
|
// until package2 is GA, wrap perm-based errors w/ 'contact sfdc' action (REMOVE once package2 is GA'd)
|
|
107
|
-
throw (0,
|
|
107
|
+
throw (0, packageUtils_1.applyErrorAction)((0, packageUtils_1.massageErrorMessage)(err));
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
@@ -183,7 +183,7 @@ class PackageVersion {
|
|
|
183
183
|
}
|
|
184
184
|
catch (err) {
|
|
185
185
|
await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create['timed-out'], report);
|
|
186
|
-
throw (0,
|
|
186
|
+
throw (0, packageUtils_1.applyErrorAction)(err);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
@@ -199,7 +199,7 @@ class PackageVersion {
|
|
|
199
199
|
}).catch((err) => {
|
|
200
200
|
// TODO
|
|
201
201
|
// until package2 is GA, wrap perm-based errors w/ 'contact sfdc' action (REMOVE once package2 is GA'd)
|
|
202
|
-
throw (0,
|
|
202
|
+
throw (0, packageUtils_1.applyErrorAction)((0, packageUtils_1.massageErrorMessage)(err));
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
@@ -266,7 +266,7 @@ class PackageVersion {
|
|
|
266
266
|
}
|
|
267
267
|
catch (err) {
|
|
268
268
|
await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create['timed-out'], report);
|
|
269
|
-
throw (0,
|
|
269
|
+
throw (0, packageUtils_1.applyErrorAction)(err);
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
/**
|
|
@@ -326,16 +326,16 @@ class PackageVersion {
|
|
|
326
326
|
queryConfig = {
|
|
327
327
|
id: this.data.Id,
|
|
328
328
|
clause: `Id = '${this.data.Id}'`,
|
|
329
|
-
label1:
|
|
330
|
-
label2:
|
|
329
|
+
label1: packageUtils_1.BY_LABEL.PACKAGE_VERSION_ID.label,
|
|
330
|
+
label2: packageUtils_1.BY_LABEL.SUBSCRIBER_PACKAGE_VERSION_ID.label,
|
|
331
331
|
};
|
|
332
332
|
}
|
|
333
333
|
else {
|
|
334
334
|
queryConfig = {
|
|
335
335
|
id: this.data.SubscriberPackageVersionId,
|
|
336
336
|
clause: `SubscriberPackageVersionId = '${this.data.SubscriberPackageVersionId}'`,
|
|
337
|
-
label1:
|
|
338
|
-
label2:
|
|
337
|
+
label1: packageUtils_1.BY_LABEL.SUBSCRIBER_PACKAGE_VERSION_ID.label,
|
|
338
|
+
label2: packageUtils_1.BY_LABEL.PACKAGE_VERSION_ID.label,
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
341
|
const allFields = exports.Package2VersionFields.toString();
|
|
@@ -376,7 +376,7 @@ class PackageVersion {
|
|
|
376
376
|
}).catch((err) => {
|
|
377
377
|
// TODO
|
|
378
378
|
// until package2 is GA, wrap perm-based errors w/ 'contact sfdc' action (REMOVE once package2 is GA'd)
|
|
379
|
-
throw (0,
|
|
379
|
+
throw (0, packageUtils_1.applyErrorAction)((0, packageUtils_1.massageErrorMessage)(err));
|
|
380
380
|
});
|
|
381
381
|
return results[0];
|
|
382
382
|
}
|
|
@@ -423,7 +423,7 @@ class PackageVersion {
|
|
|
423
423
|
return PackageVersion.waitForCreateVersion(createResult.Id, this.project, this.connection, polling).catch((err) => {
|
|
424
424
|
// TODO
|
|
425
425
|
// until package2 is GA, wrap perm-based errors w/ 'contact sfdc' action (REMOVE once package2 is GA'd)
|
|
426
|
-
throw (0,
|
|
426
|
+
throw (0, packageUtils_1.applyErrorAction)((0, packageUtils_1.massageErrorMessage)(err));
|
|
427
427
|
});
|
|
428
428
|
}
|
|
429
429
|
return createResult;
|
|
@@ -437,7 +437,7 @@ class PackageVersion {
|
|
|
437
437
|
};
|
|
438
438
|
const updateResult = await this.connection.tooling.update('Package2Version', request);
|
|
439
439
|
if (!updateResult.success) {
|
|
440
|
-
throw (0,
|
|
440
|
+
throw (0, packageUtils_1.combineSaveErrors)('Package2', 'update', updateResult.errors);
|
|
441
441
|
}
|
|
442
442
|
updateResult.id = await this.getSubscriberId();
|
|
443
443
|
return updateResult;
|
|
@@ -446,7 +446,7 @@ class PackageVersion {
|
|
|
446
446
|
if (!process.env.SFDX_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE) {
|
|
447
447
|
// get the newly created package version from the server
|
|
448
448
|
const versionResult = (await this.connection.tooling.query(`SELECT Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber FROM Package2Version WHERE SubscriberPackageVersionId='${results.SubscriberPackageVersionId}'`)).records[0];
|
|
449
|
-
const version = `${
|
|
449
|
+
const version = `${this.project.getAliasesFromPackageId(results.Package2Id).join()}@${versionResult.MajorVersion ?? 0}.${versionResult.MinorVersion ?? 0}.${versionResult.PatchVersion ?? 0}`;
|
|
450
450
|
const build = versionResult.BuildNumber ? `-${versionResult.BuildNumber}` : '';
|
|
451
451
|
const branch = versionResult.Branch ? `-${versionResult.Branch}` : '';
|
|
452
452
|
// set packageAliases entry '<package>@<major>.<minor>.<patch>-<build>-<branch>: <result.subscriberPackageVersionId>'
|
|
@@ -456,7 +456,7 @@ class PackageVersion {
|
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
458
|
resolveId() {
|
|
459
|
-
return
|
|
459
|
+
return this.project.getPackageIdFromAlias(this.options.idOrAlias) ?? this.options.idOrAlias;
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
462
|
exports.PackageVersion = PackageVersion;
|