@salesforce/packaging 0.0.33 → 0.0.34
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 +7 -0
- package/lib/interfaces/packagingInterfacesAndType.d.ts +7 -1
- package/lib/package/package.d.ts +3 -2
- package/lib/package/package.js +3 -2
- package/lib/package/packageConvert.d.ts +15 -11
- package/lib/package/packageConvert.js +10 -9
- package/lib/package/packageVersionCreateRequest.js +1 -1
- package/lib/utils/packageUtils.d.ts +1 -1
- package/lib/utils/packageUtils.js +17 -20
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.34](https://github.com/forcedotcom/packaging/compare/v0.0.33...v0.0.34) (2022-09-08)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- default ut timeout to 20 seconds ([e8dc2c1](https://github.com/forcedotcom/packaging/commit/e8dc2c10650ad2fd3d33fba212bf4ff5908e775e))
|
|
10
|
+
- only required refactoring - waiting on packaging to enable na40 to convert ([5e6365c](https://github.com/forcedotcom/packaging/commit/5e6365ccbc2086a40652ddf518c369bd0584f926))
|
|
11
|
+
|
|
5
12
|
### [0.0.33](https://github.com/forcedotcom/packaging/compare/v0.0.32...v0.0.33) (2022-09-08)
|
|
6
13
|
|
|
7
14
|
### Bug Fixes
|
|
@@ -10,7 +10,7 @@ import PackageInstallRequest = PackagingSObjects.PackageInstallRequest;
|
|
|
10
10
|
import MetadataPackageVersion = PackagingSObjects.MetadataPackageVersion;
|
|
11
11
|
export interface IPackage {
|
|
12
12
|
create(): Promise<void>;
|
|
13
|
-
convert(): Promise<
|
|
13
|
+
convert(pkgId: string, options: ConvertPackageOptions, project?: SfProject): Promise<PackageVersionCreateRequestResult>;
|
|
14
14
|
delete(): Promise<void>;
|
|
15
15
|
install(pkgInstallCreateRequest: PackageInstallCreateRequest, options?: PackageInstallOptions): Promise<PackageInstallRequest>;
|
|
16
16
|
getInstallStatus(installRequestId: string): Promise<PackageInstallRequest>;
|
|
@@ -208,6 +208,12 @@ export declare type PackageVersionOptions = {
|
|
|
208
208
|
connection: Connection;
|
|
209
209
|
project: SfProject;
|
|
210
210
|
};
|
|
211
|
+
export declare type ConvertPackageOptions = {
|
|
212
|
+
installationKey: string;
|
|
213
|
+
installationKeyBypass: boolean;
|
|
214
|
+
wait: Duration;
|
|
215
|
+
buildInstance: string;
|
|
216
|
+
};
|
|
211
217
|
export declare type PackageVersionCreateOptions = Partial<PackageVersionOptions & {
|
|
212
218
|
branch: string;
|
|
213
219
|
buildinstance: string;
|
package/lib/package/package.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { SfProject } from '@salesforce/core';
|
|
1
2
|
import { AsyncCreatable, Duration } from '@salesforce/kit';
|
|
2
3
|
import { QueryResult } from 'jsforce';
|
|
3
4
|
import { Optional } from '@salesforce/ts-types';
|
|
4
|
-
import { IPackage, PackageOptions, PackagingSObjects, PackageInstallOptions, PackageInstallCreateRequest, PackageIdType, PackageSaveResult, PackageUpdateOptions } from '../interfaces';
|
|
5
|
+
import { IPackage, PackageOptions, PackagingSObjects, PackageInstallOptions, PackageInstallCreateRequest, PackageIdType, ConvertPackageOptions, PackageVersionCreateRequestResult, PackageSaveResult, PackageUpdateOptions } from '../interfaces';
|
|
5
6
|
declare type PackageInstallRequest = PackagingSObjects.PackageInstallRequest;
|
|
6
7
|
/**
|
|
7
8
|
* Package class.
|
|
@@ -25,7 +26,7 @@ export declare class Package extends AsyncCreatable<PackageOptions> implements I
|
|
|
25
26
|
* @param type The type of package ID
|
|
26
27
|
*/
|
|
27
28
|
static validateId(id: string, type: PackageIdType): void;
|
|
28
|
-
convert(): Promise<
|
|
29
|
+
convert(pkgId: string, options: ConvertPackageOptions, project?: SfProject): Promise<PackageVersionCreateRequestResult>;
|
|
29
30
|
create(): Promise<void>;
|
|
30
31
|
delete(): Promise<void>;
|
|
31
32
|
install(pkgInstallCreateRequest: PackageInstallCreateRequest, options?: PackageInstallOptions): Promise<PackageInstallRequest>;
|
package/lib/package/package.js
CHANGED
|
@@ -11,6 +11,7 @@ const core_1 = require("@salesforce/core");
|
|
|
11
11
|
const kit_1 = require("@salesforce/kit");
|
|
12
12
|
const packageList_1 = require("./packageList");
|
|
13
13
|
const packageInstall_1 = require("./packageInstall");
|
|
14
|
+
const packageConvert_1 = require("./packageConvert");
|
|
14
15
|
const packagePrefixes = {
|
|
15
16
|
PackageId: '0Ho',
|
|
16
17
|
SubscriberPackageVersionId: '04t',
|
|
@@ -51,8 +52,8 @@ class Package extends kit_1.AsyncCreatable {
|
|
|
51
52
|
throw messages.createError('invalidIdLength', [type, id]);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
convert() {
|
|
55
|
-
return
|
|
55
|
+
async convert(pkgId, options, project) {
|
|
56
|
+
return await (0, packageConvert_1.convertPackage)(pkgId, this.options.connection, options, project);
|
|
56
57
|
}
|
|
57
58
|
create() {
|
|
58
59
|
return Promise.resolve(undefined);
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { Connection,
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { Connection, SfProject } from '@salesforce/core';
|
|
2
|
+
import { PackagingSObjects, PackageVersionCreateRequestResult, ConvertPackageOptions } from '../interfaces';
|
|
3
|
+
export declare function convertPackage(pkg: string, connection: Connection, options: ConvertPackageOptions, project?: SfProject): Promise<PackageVersionCreateRequestResult>;
|
|
4
|
+
/**
|
|
5
|
+
* Convert the list of command line options to a JSON object that can be used to create an Package2VersionCreateRequest entity.
|
|
6
|
+
*
|
|
7
|
+
* @param context: command context
|
|
8
|
+
* @param packageId: package2 id to create a package version for
|
|
9
|
+
* @returns {{Package2Id: string, Package2VersionMetadata: *, Tag: *, Branch: number}}
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
export declare function createPackageVersionCreateRequest(context: {
|
|
13
|
+
installationkey?: string;
|
|
14
|
+
buildinstance?: string;
|
|
15
|
+
}, packageId: string): Promise<PackagingSObjects.Package2VersionCreateRequest>;
|
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.convertPackage = void 0;
|
|
9
|
+
exports.createPackageVersionCreateRequest = exports.convertPackage = void 0;
|
|
10
10
|
const path = require("path");
|
|
11
|
-
const util = require("util");
|
|
12
11
|
const os = require("os");
|
|
13
12
|
const fs = require("fs");
|
|
14
13
|
const core_1 = require("@salesforce/core");
|
|
@@ -19,15 +18,16 @@ const constants_1 = require("../constants");
|
|
|
19
18
|
const srcDevUtil = require("../utils/srcDevUtils");
|
|
20
19
|
const packageVersionCreateRequest_1 = require("./packageVersionCreateRequest");
|
|
21
20
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
22
|
-
const messages = core_1.Messages.loadMessages('@salesforce/packaging', '
|
|
23
|
-
async function convertPackage(pkg,
|
|
21
|
+
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'packageVersionCreate');
|
|
22
|
+
async function convertPackage(pkg, connection, options, project) {
|
|
24
23
|
let maxRetries = 0;
|
|
25
24
|
const branch = 'main';
|
|
26
25
|
if (options.wait) {
|
|
27
|
-
maxRetries = (60 / pkgUtils.POLL_INTERVAL_SECONDS) * options.wait.
|
|
26
|
+
maxRetries = (60 / pkgUtils.POLL_INTERVAL_SECONDS) * options.wait.minutes;
|
|
28
27
|
}
|
|
29
|
-
const packageId = await pkgUtils.
|
|
30
|
-
const request = await createPackageVersionCreateRequest(
|
|
28
|
+
const packageId = await pkgUtils.findOrCreatePackage2(pkg, connection);
|
|
29
|
+
const request = await createPackageVersionCreateRequest({ installationkey: options.installationKey, buildinstance: options.buildInstance }, packageId);
|
|
30
|
+
// TODO: a lot of this is duplicated from PC, PVC, and PVCR.
|
|
31
31
|
const createResult = await connection.tooling.create('Package2VersionCreateRequest', request);
|
|
32
32
|
if (!createResult.success) {
|
|
33
33
|
const errStr = createResult.errors && createResult.errors.length ? createResult.errors.join(', ') : createResult.errors;
|
|
@@ -43,7 +43,7 @@ async function convertPackage(pkg, org, connection, project, options) {
|
|
|
43
43
|
else {
|
|
44
44
|
results = await (0, packageVersionCreateRequest_1.byId)(packageId, connection);
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return Array.isArray(results) ? results[0] : results;
|
|
47
47
|
}
|
|
48
48
|
exports.convertPackage = convertPackage;
|
|
49
49
|
/**
|
|
@@ -69,6 +69,7 @@ async function createPackageVersionCreateRequest(context, packageId) {
|
|
|
69
69
|
await srcDevUtil.zipDir(packageVersBlobDirectory, packageVersBlobZipFile);
|
|
70
70
|
return createRequestObject(packageId, context, packageVersTmpRoot, packageVersBlobZipFile);
|
|
71
71
|
}
|
|
72
|
+
exports.createPackageVersionCreateRequest = createPackageVersionCreateRequest;
|
|
72
73
|
async function createRequestObject(packageId, options, packageVersTmpRoot, packageVersBlobZipFile) {
|
|
73
74
|
const zipFileBase64 = (await fs.promises.readFile(packageVersBlobZipFile)).toString('base64');
|
|
74
75
|
const requestObject = {
|
|
@@ -78,7 +79,7 @@ async function createRequestObject(packageId, options, packageVersTmpRoot, packa
|
|
|
78
79
|
Instance: options.buildinstance,
|
|
79
80
|
IsConversionRequest: true,
|
|
80
81
|
};
|
|
81
|
-
await fs.promises.
|
|
82
|
+
await fs.promises.rm(packageVersTmpRoot, { recursive: true });
|
|
82
83
|
return requestObject;
|
|
83
84
|
}
|
|
84
85
|
//# sourceMappingURL=packageConvert.js.map
|
|
@@ -50,7 +50,7 @@ async function _query(query, connection) {
|
|
|
50
50
|
}
|
|
51
51
|
async function _queryErrors(packageVersionCreateRequestId, connection) {
|
|
52
52
|
const errorResults = [];
|
|
53
|
-
const queryResult = connection.tooling.query(util.format(ERROR_QUERY, packageVersionCreateRequestId));
|
|
53
|
+
const queryResult = await connection.tooling.query(util.format(ERROR_QUERY, packageVersionCreateRequestId));
|
|
54
54
|
if (queryResult.records) {
|
|
55
55
|
queryResult.records.forEach((record) => {
|
|
56
56
|
errorResults.push(record.Message);
|
|
@@ -135,7 +135,7 @@ export declare function convertCamelCaseStringToSentence(stringIn: string): stri
|
|
|
135
135
|
* @returns an array of alias for the given id.
|
|
136
136
|
*/
|
|
137
137
|
export declare function getPackageAliasesFromId(packageId: string, project: SfProject): string[];
|
|
138
|
-
export declare function
|
|
138
|
+
export declare function findOrCreatePackage2(seedPackage: string, connection: Connection): Promise<string>;
|
|
139
139
|
export declare function pollForStatusWithInterval(id: string, retries: number, packageId: string, branch: string, withProject: SfProject, connection: Connection, interval: Duration): Promise<PackageVersionCreateRequestResult>;
|
|
140
140
|
/**
|
|
141
141
|
* Generate package alias json entry for this package version that can be written to sfdx-project.json
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.combineSaveErrors = exports.formatDate = exports.generatePackageAliasEntry = exports.pollForStatusWithInterval = exports.
|
|
3
|
+
exports.combineSaveErrors = exports.formatDate = exports.generatePackageAliasEntry = exports.pollForStatusWithInterval = exports.findOrCreatePackage2 = exports.getPackageAliasesFromId = exports.convertCamelCaseStringToSentence = exports.getPackageIdFromAlias = exports.getConfigPackageDirectory = exports.getConfigPackageDirectories = exports.getPackageVersionNumber = exports.concatVersion = exports.getAncestorIdHighestRelease = exports.getAncestorId = exports.validateAncestorId = exports.getInClauseItemsCount = exports.queryWithInConditionChunking = exports.getPackageVersionStrings = exports.getHasMetadataRemoved = exports.getContainerOptions = exports.getSubscriberPackageVersionId = exports.getPackageTypeBy04t = exports.getPackageType = exports.escapeInstallationKey = exports.getPackageVersionId = exports.applyErrorAction = exports.massageErrorMessage = exports.isErrorPackageNotAvailable = exports.isErrorFromSPVQueryRestriction = exports.validatePatchVersion = exports.validateVersionNumber = exports.validateIdNoThrow = exports.validateId = exports.BY_LABEL = exports.BY_PREFIX = exports.DEFAULT_PACKAGE_DIR = exports.POLL_INTERVAL_SECONDS = exports.SOQL_WHERE_CLAUSE_MAX_LENGTH = exports.INSTALL_URL_BASE = exports.VERSION_NUMBER_SEP = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (c) 2022, salesforce.com, inc.
|
|
6
6
|
* All rights reserved.
|
|
@@ -612,30 +612,27 @@ function getPackageAliasesFromId(packageId, project) {
|
|
|
612
612
|
.map((alias) => alias[0]);
|
|
613
613
|
}
|
|
614
614
|
exports.getPackageAliasesFromId = getPackageAliasesFromId;
|
|
615
|
-
|
|
616
|
-
async function findOrCreatePackage(seedPackage, connection) {
|
|
615
|
+
async function findOrCreatePackage2(seedPackage, connection) {
|
|
617
616
|
const query = `SELECT Id FROM Package2 WHERE ConvertedFromPackageId = '${seedPackage}'`;
|
|
618
|
-
const queryResult = await connection.tooling.query(query);
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
const ids = records.map((r) => r.Id);
|
|
617
|
+
const queryResult = (await connection.tooling.query(query)).records;
|
|
618
|
+
if (queryResult?.length > 1) {
|
|
619
|
+
const ids = queryResult.map((r) => r.Id);
|
|
622
620
|
throw messages.createError('errorMoreThanOnePackage2WithSeed', [ids.join(', ')]);
|
|
623
621
|
}
|
|
624
|
-
if (
|
|
622
|
+
if (queryResult?.length === 1) {
|
|
625
623
|
// return the package2 object
|
|
626
|
-
return
|
|
624
|
+
return queryResult[0].Id;
|
|
627
625
|
}
|
|
628
626
|
// Need to create a new Package2
|
|
629
627
|
const subQuery = `SELECT Name, Description, NamespacePrefix FROM SubscriberPackage WHERE Id = '${seedPackage}'`;
|
|
630
|
-
const subscriberResult = await connection.tooling.query(subQuery);
|
|
631
|
-
|
|
632
|
-
if (!subscriberRecords || subscriberRecords.length <= 0) {
|
|
628
|
+
const subscriberResult = (await connection.tooling.query(subQuery)).records;
|
|
629
|
+
if (!subscriberResult || subscriberResult?.length <= 0) {
|
|
633
630
|
throw messages.createError('errorNoSubscriberPackageRecord', [seedPackage]);
|
|
634
631
|
}
|
|
635
632
|
const request = {
|
|
636
|
-
Name:
|
|
637
|
-
Description:
|
|
638
|
-
NamespacePrefix:
|
|
633
|
+
Name: subscriberResult[0].Name,
|
|
634
|
+
Description: subscriberResult[0].Description,
|
|
635
|
+
NamespacePrefix: subscriberResult[0].NamespacePrefix,
|
|
639
636
|
ContainerOptions: 'Managed',
|
|
640
637
|
ConvertedFromPackageId: seedPackage,
|
|
641
638
|
};
|
|
@@ -645,7 +642,7 @@ async function findOrCreatePackage(seedPackage, connection) {
|
|
|
645
642
|
}
|
|
646
643
|
return createResult.id;
|
|
647
644
|
}
|
|
648
|
-
exports.
|
|
645
|
+
exports.findOrCreatePackage2 = findOrCreatePackage2;
|
|
649
646
|
async function pollForStatusWithInterval(id, retries, packageId, branch, withProject, connection, interval) {
|
|
650
647
|
let remainingRetries = retries;
|
|
651
648
|
const pollingClient = await core_1.PollingClient.create({
|
|
@@ -695,20 +692,20 @@ async function pollForStatusWithInterval(id, retries, packageId, branch, withPro
|
|
|
695
692
|
}
|
|
696
693
|
}
|
|
697
694
|
else {
|
|
698
|
-
const remainingTime = kit_1.Duration.
|
|
695
|
+
const remainingTime = kit_1.Duration.seconds(interval.seconds * remainingRetries);
|
|
699
696
|
await core_1.Lifecycle.getInstance().emit(Package2VersionStatus.inProgress, {
|
|
700
697
|
id,
|
|
701
698
|
packageVersionCreateRequestResult: results[0],
|
|
702
699
|
message: '',
|
|
703
|
-
remainingTime,
|
|
700
|
+
timeRemaining: remainingTime,
|
|
704
701
|
});
|
|
705
702
|
logger.info(`Request in progress. Sleeping ${interval.seconds} seconds. Will wait a total of ${remainingTime.seconds} more seconds before timing out. Current Status='${convertCamelCaseStringToSentence(results[0]?.Status)}'`);
|
|
706
703
|
remainingRetries--;
|
|
707
704
|
return { completed: false, payload: results[0] };
|
|
708
705
|
}
|
|
709
706
|
},
|
|
710
|
-
frequency: kit_1.Duration.
|
|
711
|
-
timeout: kit_1.Duration.
|
|
707
|
+
frequency: kit_1.Duration.seconds(interval.seconds),
|
|
708
|
+
timeout: kit_1.Duration.seconds(interval.seconds * retries),
|
|
712
709
|
});
|
|
713
710
|
return pollingClient.subscribe();
|
|
714
711
|
}
|