@salesforce/packaging 0.0.22 → 0.0.25
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 +19 -0
- package/lib/package/packageConvert.js +2 -2
- package/lib/package/packageVersion.d.ts +0 -1
- package/lib/package/packageVersion.js +10 -30
- package/lib/package/packageVersionCreate.js +7 -5
- package/lib/utils/packageUtils.d.ts +1 -3
- package/lib/utils/packageUtils.js +1 -1
- package/lib/utils/uniqid.d.ts +14 -0
- package/lib/utils/uniqid.js +34 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
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.25](https://github.com/forcedotcom/packaging/compare/v0.0.24...v0.0.25) (2022-08-25)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- improve packge property maintenance ([c62acf8](https://github.com/forcedotcom/packaging/commit/c62acf84ad84deec6d77079200290ab09064f6d7))
|
|
10
|
+
|
|
11
|
+
### [0.0.24](https://github.com/forcedotcom/packaging/compare/v0.0.23...v0.0.24) (2022-08-24)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- correct package alias generation ([c4617bd](https://github.com/forcedotcom/packaging/commit/c4617bd16eac1f2bfe5efadafc1062ea78ee352c))
|
|
16
|
+
|
|
17
|
+
### [0.0.23](https://github.com/forcedotcom/packaging/compare/v0.0.22...v0.0.23) (2022-08-22)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- increase pvc ut timeout to 10 secs ([08e667f](https://github.com/forcedotcom/packaging/commit/08e667f574abf5a3de0686c5dcfd654d9fa4c0fa))
|
|
22
|
+
- remove ref to dev dep ([a51323a](https://github.com/forcedotcom/packaging/commit/a51323aaf699eb82fc515722681c6f1b56edb5f4))
|
|
23
|
+
|
|
5
24
|
### [0.0.22](https://github.com/forcedotcom/packaging/compare/v0.0.21...v0.0.22) (2022-08-22)
|
|
6
25
|
|
|
7
26
|
### Bug Fixes
|
|
@@ -13,7 +13,7 @@ const os = require("os");
|
|
|
13
13
|
const fs = require("fs");
|
|
14
14
|
const core_1 = require("@salesforce/core");
|
|
15
15
|
const kit_1 = require("@salesforce/kit");
|
|
16
|
-
const
|
|
16
|
+
const uniqid_1 = require("../utils/uniqid");
|
|
17
17
|
const pkgUtils = require("../utils/packageUtils");
|
|
18
18
|
const constants_1 = require("../constants");
|
|
19
19
|
const srcDevUtil = require("../utils/srcDevUtils");
|
|
@@ -55,7 +55,7 @@ exports.convertPackage = convertPackage;
|
|
|
55
55
|
* @private
|
|
56
56
|
*/
|
|
57
57
|
async function createPackageVersionCreateRequest(context, packageId) {
|
|
58
|
-
const uniqueId = (0,
|
|
58
|
+
const uniqueId = (0, uniqid_1.uniqid)({ template: `${packageId}-%s` });
|
|
59
59
|
const packageVersTmpRoot = path.join(os.tmpdir(), uniqueId);
|
|
60
60
|
const packageVersBlobDirectory = path.join(packageVersTmpRoot, 'package-version-info');
|
|
61
61
|
const packageVersBlobZipFile = path.join(packageVersTmpRoot, constants_1.consts.PACKAGE_VERSION_INFO_FILE_ZIP);
|
|
@@ -13,7 +13,6 @@ const utils_1 = require("../utils");
|
|
|
13
13
|
const packageVersionCreate_1 = require("./packageVersionCreate");
|
|
14
14
|
const packageVersionReport_1 = require("./packageVersionReport");
|
|
15
15
|
const packageVersionCreateRequestReport_1 = require("./packageVersionCreateRequestReport");
|
|
16
|
-
const package_1 = require("./package");
|
|
17
16
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
18
17
|
class PackageVersion {
|
|
19
18
|
constructor(options) {
|
|
@@ -129,19 +128,8 @@ class PackageVersion {
|
|
|
129
128
|
payload: report,
|
|
130
129
|
};
|
|
131
130
|
case 'Success':
|
|
132
|
-
await this.updateProjectWithPackageVersion(this.project, report);
|
|
133
131
|
await core_1.Lifecycle.getInstance().emit('success', report);
|
|
134
|
-
|
|
135
|
-
// get the newly created package version from the server
|
|
136
|
-
const versionResult = (await this.connection.tooling.query(`SELECT Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber FROM Package2Version WHERE SubscriberPackageVersionId='${report.SubscriberPackageVersionId}'`)).records[0];
|
|
137
|
-
const version = `${(0, utils_1.getPackageAliasesFromId)(report.Package2Id, this.project).join()}@${versionResult.MajorVersion ?? 0}.${versionResult.MinorVersion ?? 0}.${versionResult.PatchVersion ?? 0}`;
|
|
138
|
-
const build = versionResult.BuildNumber ? `-${versionResult.BuildNumber}` : '';
|
|
139
|
-
const branch = versionResult.Branch ? `-${versionResult.Branch}` : '';
|
|
140
|
-
// set packageAliases entry '<package>@<major>.<minor>.<patch>-<build>-<branch>: <result.subscriberPackageVersionId>'
|
|
141
|
-
this.project.getSfProjectJson().getContents().packageAliases[`${version}${build}${branch}`] =
|
|
142
|
-
report.SubscriberPackageVersionId;
|
|
143
|
-
await this.project.getSfProjectJson().write();
|
|
144
|
-
}
|
|
132
|
+
await this.updateProjectWithPackageVersion(this.project, report);
|
|
145
133
|
return { completed: true, payload: report };
|
|
146
134
|
case 'Error':
|
|
147
135
|
await core_1.Lifecycle.getInstance().emit('error', report);
|
|
@@ -201,25 +189,17 @@ class PackageVersion {
|
|
|
201
189
|
}
|
|
202
190
|
async updateProjectWithPackageVersion(withProject, results) {
|
|
203
191
|
if (withProject && !process.env.SFDX_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE) {
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
await
|
|
192
|
+
// get the newly created package version from the server
|
|
193
|
+
const versionResult = (await this.connection.tooling.query(`SELECT Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber FROM Package2Version WHERE SubscriberPackageVersionId='${results.SubscriberPackageVersionId}'`)).records[0];
|
|
194
|
+
const version = `${(0, utils_1.getPackageAliasesFromId)(results.Package2Id, this.project).join()}@${versionResult.MajorVersion ?? 0}.${versionResult.MinorVersion ?? 0}.${versionResult.PatchVersion ?? 0}`;
|
|
195
|
+
const build = versionResult.BuildNumber ? `-${versionResult.BuildNumber}` : '';
|
|
196
|
+
const branch = versionResult.Branch ? `-${versionResult.Branch}` : '';
|
|
197
|
+
// set packageAliases entry '<package>@<major>.<minor>.<patch>-<build>-<branch>: <result.subscriberPackageVersionId>'
|
|
198
|
+
this.project.getSfProjectJson().getContents().packageAliases[`${version}${build}${branch}`] =
|
|
199
|
+
results.SubscriberPackageVersionId;
|
|
200
|
+
await this.project.getSfProjectJson().write();
|
|
213
201
|
}
|
|
214
202
|
}
|
|
215
|
-
async generatePackageDirectory(packageVersion, withProject, packageVersionVersionString) {
|
|
216
|
-
const pkg = await (await package_1.Package.create({ connection: this.connection })).getPackage(packageVersion.Package2Id);
|
|
217
|
-
const pkgDir = (0, utils_1.getConfigPackageDirectory)(withProject.getPackageDirectories(), 'id', pkg.Id) ?? {};
|
|
218
|
-
pkgDir.versionNumber = packageVersionVersionString;
|
|
219
|
-
pkgDir.versionDescription = packageVersion.Description;
|
|
220
|
-
const packageDirs = withProject.getPackageDirectories().map((pd) => (pkgDir['id'] === pd['id'] ? pkgDir : pd));
|
|
221
|
-
withProject.getSfProjectJson().set('packageDirectories', packageDirs);
|
|
222
|
-
}
|
|
223
203
|
}
|
|
224
204
|
exports.PackageVersion = PackageVersion;
|
|
225
205
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -12,10 +12,10 @@ const os = require("os");
|
|
|
12
12
|
const fs = require("fs");
|
|
13
13
|
const core_1 = require("@salesforce/core");
|
|
14
14
|
const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
|
|
15
|
-
const testSetup_1 = require("@salesforce/core/lib/testSetup");
|
|
16
15
|
const scratchOrgSettingsGenerator_1 = require("@salesforce/core/lib/org/scratchOrgSettingsGenerator");
|
|
17
16
|
const xml2js = require("xml2js");
|
|
18
17
|
const scratchOrgInfoGenerator_1 = require("@salesforce/core/lib/org/scratchOrgInfoGenerator");
|
|
18
|
+
const uniqid_1 = require("../utils/uniqid");
|
|
19
19
|
const pkgUtils = require("../utils/packageUtils");
|
|
20
20
|
const versionNumber_1 = require("../utils/versionNumber");
|
|
21
21
|
const utils_1 = require("../utils");
|
|
@@ -221,7 +221,7 @@ class PackageVersionCreate {
|
|
|
221
221
|
*/
|
|
222
222
|
async createPackageVersionCreateRequestFromOptions() {
|
|
223
223
|
const preserveFiles = !!(this.options.preserve || process.env.SFDX_PACKAGE2_VERSION_CREATE_PRESERVE);
|
|
224
|
-
const uniqueHash = (0,
|
|
224
|
+
const uniqueHash = (0, uniqid_1.uniqid)({ template: `${this.packageId}-%s` });
|
|
225
225
|
const packageVersTmpRoot = path.join(os.tmpdir(), `${uniqueHash}`);
|
|
226
226
|
const packageVersMetadataFolder = path.join(packageVersTmpRoot, 'md-files');
|
|
227
227
|
const unpackagedMetadataFolder = path.join(packageVersTmpRoot, 'unpackaged-md-files');
|
|
@@ -415,10 +415,12 @@ class PackageVersionCreate {
|
|
|
415
415
|
}
|
|
416
416
|
// from the packageDirectories in sfdx-project.json, find the correct package entry either by finding a matching package (name) or path
|
|
417
417
|
this.packageAlias = (0, utils_1.getPackageAliasesFromId)(this.options.packageId, this.options.project).join();
|
|
418
|
-
|
|
419
|
-
|
|
418
|
+
this.packageId = this.options.packageId;
|
|
419
|
+
// set on the class, so we can access them in other methods without redoing this logic
|
|
420
|
+
this.packageObject = this.project
|
|
421
|
+
.getPackageDirectories()
|
|
422
|
+
.find((pkg) => pkg.package === this.packageAlias || pkg['id'] === this.options.packageId);
|
|
420
423
|
this.options.profileApi = await this.resolveUserLicenses(this.packageObject.includeProfileUserLicenses);
|
|
421
|
-
this.packageId = (0, utils_1.getPackageIdFromAlias)(this.packageObject.package, this.project);
|
|
422
424
|
// At this point, the packageIdFromAlias should have been resolved to an Id. Now, we
|
|
423
425
|
// need to validate that the Id is correct.
|
|
424
426
|
pkgUtils.validateId(pkgUtils.BY_LABEL.PACKAGE_ID, this.packageId);
|
|
@@ -148,9 +148,7 @@ export declare function pollForStatusWithInterval(id: string, retries: number, p
|
|
|
148
148
|
* @private
|
|
149
149
|
*/
|
|
150
150
|
export declare function generatePackageAliasEntry(connection: Connection, project: SfProject, packageVersionId: string, packageVersionNumber: string, branch: string, packageId: string): Promise<{
|
|
151
|
-
|
|
152
|
-
[p: string]: string;
|
|
153
|
-
};
|
|
151
|
+
[p: string]: string;
|
|
154
152
|
}>;
|
|
155
153
|
export declare function formatDate(date: Date): string;
|
|
156
154
|
export declare function combineSaveErrors(sObject: string, crudOperation: string, errors: SaveError[]): SfError;
|
|
@@ -653,7 +653,7 @@ async function generatePackageAliasEntry(connection, project, packageVersionId,
|
|
|
653
653
|
? `${packageName}@${packageVersionNumber}-${branch}`
|
|
654
654
|
: `${packageName}@${packageVersionNumber}`;
|
|
655
655
|
packageAliases[packageAlias] = packageVersionId;
|
|
656
|
-
return
|
|
656
|
+
return packageAliases;
|
|
657
657
|
}
|
|
658
658
|
exports.generatePackageAliasEntry = generatePackageAliasEntry;
|
|
659
659
|
/**
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A function to generate a unique id and return it in the context of a template, if supplied.
|
|
3
|
+
*
|
|
4
|
+
* A template is a string that can contain `${%s}` to be replaced with a unique id.
|
|
5
|
+
* If the template contains the "%s" placeholder, it will be replaced with the unique id otherwise the id will be appended to the template.
|
|
6
|
+
*
|
|
7
|
+
* @param options an object with the following properties:
|
|
8
|
+
* - template: a template string.
|
|
9
|
+
* - length: the length of the unique id as presented in hexadecimal.
|
|
10
|
+
*/
|
|
11
|
+
export declare function uniqid(options?: {
|
|
12
|
+
template?: string;
|
|
13
|
+
length?: number;
|
|
14
|
+
}): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniqid = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2022, salesforce.com, inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
* Licensed under the BSD 3-Clause license.
|
|
8
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
|
+
*/
|
|
10
|
+
const crypto_1 = require("crypto");
|
|
11
|
+
const util = require("util");
|
|
12
|
+
/**
|
|
13
|
+
* A function to generate a unique id and return it in the context of a template, if supplied.
|
|
14
|
+
*
|
|
15
|
+
* A template is a string that can contain `${%s}` to be replaced with a unique id.
|
|
16
|
+
* If the template contains the "%s" placeholder, it will be replaced with the unique id otherwise the id will be appended to the template.
|
|
17
|
+
*
|
|
18
|
+
* @param options an object with the following properties:
|
|
19
|
+
* - template: a template string.
|
|
20
|
+
* - length: the length of the unique id as presented in hexadecimal.
|
|
21
|
+
*/
|
|
22
|
+
function uniqid(options) {
|
|
23
|
+
const uniqueString = (0, crypto_1.randomBytes)(Math.ceil((options?.length ?? 32) / 2.0))
|
|
24
|
+
.toString('hex')
|
|
25
|
+
.slice(0, options?.length ?? 32);
|
|
26
|
+
if (!options?.template) {
|
|
27
|
+
return uniqueString;
|
|
28
|
+
}
|
|
29
|
+
return options.template.includes('%s')
|
|
30
|
+
? util.format(options.template, uniqueString)
|
|
31
|
+
: `${options.template}${uniqueString}`;
|
|
32
|
+
}
|
|
33
|
+
exports.uniqid = uniqid;
|
|
34
|
+
//# sourceMappingURL=uniqid.js.map
|