@salesforce/packaging 0.0.10 → 0.0.13
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 +18 -0
- package/lib/interfaces/packagingInterfacesAndType.d.ts +1 -0
- package/lib/package/packageProfileApi.js +6 -6
- package/lib/package1/index.d.ts +2 -0
- package/lib/package1/index.js +2 -0
- package/lib/package1/package1VersionCreate.d.ts +7 -0
- package/lib/package1/package1VersionCreate.js +55 -0
- package/lib/package1/package1VersionList.d.ts +11 -0
- package/lib/package1/package1VersionList.js +31 -0
- package/messages/messages.md +9 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
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.13](https://github.com/forcedotcom/packaging/compare/v0.0.12...v0.0.13) (2022-08-05)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- use regular xmlDom package ([57262c5](https://github.com/forcedotcom/packaging/commit/57262c574b54aa2690a47d5e702fe48dbdf475c7))
|
|
10
|
+
|
|
11
|
+
### [0.0.12](https://github.com/forcedotcom/packaging/compare/v0.0.11...v0.0.12) (2022-07-29)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- add package1VersionCreate command, refactor tests, allow .test.ts ([aa34e8c](https://github.com/forcedotcom/packaging/commit/aa34e8cfe4ad865bb299baa6db51b2af22454a86))
|
|
16
|
+
|
|
17
|
+
### [0.0.11](https://github.com/forcedotcom/packaging/compare/v0.0.10...v0.0.11) (2022-07-27)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- add package1 version list query, UTs ([302653b](https://github.com/forcedotcom/packaging/commit/302653b8bd355d59aa0efbcc2f226ab4dff82baa))
|
|
22
|
+
|
|
5
23
|
### [0.0.10](https://github.com/forcedotcom/packaging/compare/v0.0.9...v0.0.10) (2022-07-26)
|
|
6
24
|
|
|
7
25
|
### Bug Fixes
|
|
@@ -188,3 +188,4 @@ export declare type PackageVersionReportResult = Partial<PackagingSObjects.Packa
|
|
|
188
188
|
export declare type PackageVersionCreateReportProgress = PackageVersionCreateRequestResult & {
|
|
189
189
|
remainingWaitTime: Duration;
|
|
190
190
|
};
|
|
191
|
+
export declare type Package1VersionCreateRequest = Pick<PackagingSObjects.PackageUploadRequest, 'VersionName'> & Partial<Pick<PackagingSObjects.PackageUploadRequest, 'MetadataPackageId' | 'Description' | 'MajorVersion' | 'MinorVersion' | 'IsReleaseVersion' | 'ReleaseNotesUrl' | 'PostInstallUrl' | 'Password'>>;
|
|
@@ -10,7 +10,7 @@ exports.PackageProfileApi = void 0;
|
|
|
10
10
|
const path = require("path");
|
|
11
11
|
const fs = require("fs");
|
|
12
12
|
const glob = require("glob");
|
|
13
|
-
const
|
|
13
|
+
const xmldom_1 = require("@xmldom/xmldom");
|
|
14
14
|
const core_1 = require("@salesforce/core");
|
|
15
15
|
const kit_1 = require("@salesforce/kit");
|
|
16
16
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
@@ -109,8 +109,8 @@ class PackageProfileApi extends kit_1.AsyncCreatable {
|
|
|
109
109
|
profilePaths.forEach((profilePath) => {
|
|
110
110
|
// profile metadata can present in any directory in the package structure
|
|
111
111
|
const profileName = profilePath.match(/([^/]+)\.profile-meta.xml/)[1];
|
|
112
|
-
const profileDom = new
|
|
113
|
-
const newDom = new
|
|
112
|
+
const profileDom = new xmldom_1.DOMParser().parseFromString(fs.readFileSync(profilePath, 'utf-8'));
|
|
113
|
+
const newDom = new xmldom_1.DOMParser().parseFromString('<?xml version="1.0" encoding="UTF-8"?><Profile xmlns="http://soap.sforce.com/2006/04/metadata"></Profile>');
|
|
114
114
|
const profileNode = newDom.getElementsByTagName('Profile')[0];
|
|
115
115
|
let hasNodes = false;
|
|
116
116
|
// We need to keep track of all the members for when we package up the "OtherProfileSettings"
|
|
@@ -141,7 +141,7 @@ class PackageProfileApi extends kit_1.AsyncCreatable {
|
|
|
141
141
|
const userLicenses = profileDom.getElementsByTagName('userLicense');
|
|
142
142
|
if (userLicenses) {
|
|
143
143
|
hasNodes = true;
|
|
144
|
-
for (const userLicense of userLicenses) {
|
|
144
|
+
for (const userLicense of Array.from(userLicenses)) {
|
|
145
145
|
profileNode.appendChild(userLicense.cloneNode(true));
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -150,7 +150,7 @@ class PackageProfileApi extends kit_1.AsyncCreatable {
|
|
|
150
150
|
const xmlFile = xmlSrcFile.replace(/(.*)(-meta.xml)/, '$1');
|
|
151
151
|
const destFilePath = path.join(destPath, xmlFile);
|
|
152
152
|
if (hasNodes) {
|
|
153
|
-
const serializer = new
|
|
153
|
+
const serializer = new xmldom_1.XMLSerializer();
|
|
154
154
|
serializer.serializeToString(newDom);
|
|
155
155
|
fs.writeFileSync(destFilePath, serializer.serializeToString(newDom), 'utf-8');
|
|
156
156
|
}
|
|
@@ -169,7 +169,7 @@ class PackageProfileApi extends kit_1.AsyncCreatable {
|
|
|
169
169
|
fs.unlinkSync(destFilePath);
|
|
170
170
|
}
|
|
171
171
|
catch (err) {
|
|
172
|
-
// It is normal for the file to not exist if the profile is in the
|
|
172
|
+
// It is normal for the file to not exist if the profile is in the workspace but not in the directory being packaged.
|
|
173
173
|
if (err.code !== 'ENOENT') {
|
|
174
174
|
throw err;
|
|
175
175
|
}
|
package/lib/package1/index.d.ts
CHANGED
package/lib/package1/index.js
CHANGED
|
@@ -23,4 +23,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
__exportStar(require("./packageVersion1GP"), exports);
|
|
24
24
|
__exportStar(require("./packageDisplay"), exports);
|
|
25
25
|
__exportStar(require("./package1VersionCreateGet"), exports);
|
|
26
|
+
__exportStar(require("./package1VersionCreate"), exports);
|
|
27
|
+
__exportStar(require("./package1VersionList"), exports);
|
|
26
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
import { Duration } from '@salesforce/kit';
|
|
3
|
+
import { Package1VersionCreateRequest, PackagingSObjects } from '../interfaces';
|
|
4
|
+
export declare function package1VersionCreate(connection: Connection, options: Package1VersionCreateRequest, pollingOptions?: {
|
|
5
|
+
frequency: Duration;
|
|
6
|
+
timeout: Duration;
|
|
7
|
+
}): Promise<PackagingSObjects.PackageUploadRequest>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.package1VersionCreate = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2020, 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 os = require("os");
|
|
11
|
+
const core_1 = require("@salesforce/core");
|
|
12
|
+
const kit_1 = require("@salesforce/kit");
|
|
13
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
14
|
+
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'messages');
|
|
15
|
+
const packageUploadRequestStatus = async (id, connection, timeout, frequency) => {
|
|
16
|
+
const pollingResult = await connection.tooling.sobject('PackageUploadRequest').retrieve(id);
|
|
17
|
+
switch (pollingResult.Status) {
|
|
18
|
+
case 'SUCCESS':
|
|
19
|
+
return { completed: true, payload: pollingResult };
|
|
20
|
+
case 'IN_PROGRESS':
|
|
21
|
+
case 'QUEUED':
|
|
22
|
+
timeout -= frequency;
|
|
23
|
+
await core_1.Lifecycle.getInstance().emit('package1VersionCreate:progress', { timeout, pollingResult });
|
|
24
|
+
return { completed: false, payload: pollingResult };
|
|
25
|
+
default: {
|
|
26
|
+
if (pollingResult?.Errors?.errors?.length > 0) {
|
|
27
|
+
throw messages.createError('package1VersionCreateCommandUploadFailure', [
|
|
28
|
+
pollingResult.Errors.errors.map((e) => e.message).join(os.EOL),
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw messages.createError('package1VersionCreateCommandUploadFailureDefault');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
async function package1VersionCreate(connection, options, pollingOptions = { frequency: kit_1.Duration.seconds(5), timeout: kit_1.Duration.seconds(0) }) {
|
|
38
|
+
const createRequest = await connection.tooling.sobject('PackageUploadRequest').create(options);
|
|
39
|
+
if (pollingOptions.timeout.seconds) {
|
|
40
|
+
const timeout = pollingOptions.timeout.seconds;
|
|
41
|
+
const pollingClient = await core_1.PollingClient.create({
|
|
42
|
+
poll: () => packageUploadRequestStatus(createRequest.id, connection, timeout, pollingOptions.frequency.seconds),
|
|
43
|
+
...pollingOptions,
|
|
44
|
+
});
|
|
45
|
+
return pollingClient.subscribe();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// jsforce templates weren't working when setting the type to PackageUploadRequest, so we have to cast `as unknown as PackagingSObjects.PackageUploadRequest`
|
|
49
|
+
return (await connection.tooling
|
|
50
|
+
.sobject('PackageUploadRequest')
|
|
51
|
+
.retrieve(createRequest.id));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.package1VersionCreate = package1VersionCreate;
|
|
55
|
+
//# sourceMappingURL=package1VersionCreate.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
import { Package1Display } from '../interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Lists package versions available in dev org. If package ID is supplied, only list versions of that package,
|
|
5
|
+
* otherwise, list all package versions
|
|
6
|
+
*
|
|
7
|
+
* @param connection: sfdx-core Connection to the org
|
|
8
|
+
* @param metadataPackageId: optional, if present ID of package to list versions for (starts with 033)
|
|
9
|
+
* @returns Array of package version results
|
|
10
|
+
*/
|
|
11
|
+
export declare function package1VersionList(connection: Connection, metadataPackageId?: string): Promise<Package1Display[]>;
|
|
@@ -0,0 +1,31 @@
|
|
|
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.package1VersionList = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Lists package versions available in dev org. If package ID is supplied, only list versions of that package,
|
|
12
|
+
* otherwise, list all package versions
|
|
13
|
+
*
|
|
14
|
+
* @param connection: sfdx-core Connection to the org
|
|
15
|
+
* @param metadataPackageId: optional, if present ID of package to list versions for (starts with 033)
|
|
16
|
+
* @returns Array of package version results
|
|
17
|
+
*/
|
|
18
|
+
async function package1VersionList(connection, metadataPackageId) {
|
|
19
|
+
const query = `SELECT Id,MetadataPackageId,Name,ReleaseState,MajorVersion,MinorVersion,PatchVersion,BuildNumber FROM MetadataPackageVersion ${metadataPackageId ? `WHERE MetadataPackageId = '${metadataPackageId}'` : ''} ORDER BY MetadataPackageId, MajorVersion, MinorVersion, PatchVersion, BuildNumber`;
|
|
20
|
+
const queryResult = await connection.tooling.query(query);
|
|
21
|
+
return queryResult.records?.map((record) => ({
|
|
22
|
+
MetadataPackageVersionId: record.Id,
|
|
23
|
+
MetadataPackageId: record.MetadataPackageId,
|
|
24
|
+
Name: record.Name,
|
|
25
|
+
ReleaseState: record.ReleaseState,
|
|
26
|
+
Version: `${record.MajorVersion}.${record.MinorVersion}.${record.PatchVersion}`,
|
|
27
|
+
BuildNumber: record.BuildNumber,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
exports.package1VersionList = package1VersionList;
|
|
31
|
+
//# sourceMappingURL=package1VersionList.js.map
|
package/messages/messages.md
CHANGED
|
@@ -238,3 +238,12 @@ Un-packaged metadata directory %s was specified but does not exist.
|
|
|
238
238
|
# directoryDoesNotExist
|
|
239
239
|
|
|
240
240
|
Directory %s does not exist.
|
|
241
|
+
|
|
242
|
+
# package1VersionCreateCommandUploadFailureDefault
|
|
243
|
+
|
|
244
|
+
Package version creation failed with unknown error
|
|
245
|
+
|
|
246
|
+
# package1VersionCreateCommandUploadFailure
|
|
247
|
+
|
|
248
|
+
Package upload failed.
|
|
249
|
+
%s
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/packaging",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "packing libraries to Salesforce packaging platform",
|
|
5
5
|
"main": "lib/exported",
|
|
6
6
|
"types": "lib/exported.d.ts",
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"@salesforce/schemas": "^1.2.0",
|
|
41
41
|
"@salesforce/source-deploy-retrieve": "^6.2.0",
|
|
42
42
|
"@salesforce/ts-types": "^1.5.20",
|
|
43
|
+
"@xmldom/xmldom": "^0.8.2",
|
|
43
44
|
"debug": "^4.3.4",
|
|
44
45
|
"globby": "^11",
|
|
45
46
|
"js2xmlparser": "^4.0.2",
|
|
46
47
|
"jsforce": "beta",
|
|
48
|
+
"jszip": "^3.10.0",
|
|
47
49
|
"mkdirp": "1.0.4",
|
|
48
50
|
"ts-retry-promise": "^0.6.1",
|
|
49
|
-
"
|
|
50
|
-
"xml2js": "^0.4.23",
|
|
51
|
-
"xmldom-sfdx-encoding": "^0.1.30"
|
|
51
|
+
"xml2js": "^0.4.23"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@salesforce/cli-plugins-testkit": "^2.3.4",
|