@salesforce/packaging 4.14.1 → 4.15.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/bundleSObjects.d.ts +4 -0
- package/lib/interfaces/bundleSObjects.js +2 -0
- package/lib/interfaces/packagingInterfacesAndType.d.ts +1 -0
- package/lib/interfaces/packagingSObjects.d.ts +1 -0
- package/lib/package/package.js +5 -1
- package/lib/package/packageBundle.js +1 -1
- package/lib/package/packageBundleInstall.js +52 -16
- package/lib/package/packageBundleVersion.d.ts +1 -4
- package/lib/package/packageBundleVersion.js +14 -5
- package/lib/package/packageBundleVersionCreate.d.ts +1 -1
- package/lib/package/packageBundleVersionCreate.js +60 -29
- package/messages/package.md +4 -0
- package/package.json +1 -1
|
@@ -96,14 +96,17 @@ export declare namespace BundleSObjects {
|
|
|
96
96
|
CreatedDate: string;
|
|
97
97
|
CreatedById: string;
|
|
98
98
|
Error?: string[];
|
|
99
|
+
ValidationError?: string;
|
|
99
100
|
};
|
|
100
101
|
enum PkgBundleVersionCreateReqStatus {
|
|
101
102
|
queued = "Queued",
|
|
103
|
+
inProgress = "InProgress",
|
|
102
104
|
success = "Success",
|
|
103
105
|
error = "Error"
|
|
104
106
|
}
|
|
105
107
|
enum PkgBundleVersionInstallReqStatus {
|
|
106
108
|
queued = "Queued",
|
|
109
|
+
inProgress = "InProgress",
|
|
107
110
|
success = "Success",
|
|
108
111
|
error = "Error"
|
|
109
112
|
}
|
|
@@ -120,6 +123,7 @@ export declare namespace BundleSObjects {
|
|
|
120
123
|
CreatedDate: string;
|
|
121
124
|
CreatedById: string;
|
|
122
125
|
Error?: string[];
|
|
126
|
+
ValidationError?: string;
|
|
123
127
|
} & Schema;
|
|
124
128
|
type PkgBundleVersionInstallReq = {
|
|
125
129
|
PackageBundleVersionID: string;
|
|
@@ -6,12 +6,14 @@ var BundleSObjects;
|
|
|
6
6
|
let PkgBundleVersionCreateReqStatus;
|
|
7
7
|
(function (PkgBundleVersionCreateReqStatus) {
|
|
8
8
|
PkgBundleVersionCreateReqStatus["queued"] = "Queued";
|
|
9
|
+
PkgBundleVersionCreateReqStatus["inProgress"] = "InProgress";
|
|
9
10
|
PkgBundleVersionCreateReqStatus["success"] = "Success";
|
|
10
11
|
PkgBundleVersionCreateReqStatus["error"] = "Error";
|
|
11
12
|
})(PkgBundleVersionCreateReqStatus = BundleSObjects.PkgBundleVersionCreateReqStatus || (BundleSObjects.PkgBundleVersionCreateReqStatus = {}));
|
|
12
13
|
let PkgBundleVersionInstallReqStatus;
|
|
13
14
|
(function (PkgBundleVersionInstallReqStatus) {
|
|
14
15
|
PkgBundleVersionInstallReqStatus["queued"] = "Queued";
|
|
16
|
+
PkgBundleVersionInstallReqStatus["inProgress"] = "InProgress";
|
|
15
17
|
PkgBundleVersionInstallReqStatus["success"] = "Success";
|
|
16
18
|
PkgBundleVersionInstallReqStatus["error"] = "Error";
|
|
17
19
|
})(PkgBundleVersionInstallReqStatus = BundleSObjects.PkgBundleVersionInstallReqStatus || (BundleSObjects.PkgBundleVersionInstallReqStatus = {}));
|
|
@@ -36,6 +36,7 @@ export type PackageUpdateOptions = {
|
|
|
36
36
|
Description?: string;
|
|
37
37
|
PackageErrorUsername?: string;
|
|
38
38
|
AppAnalyticsEnabled?: boolean;
|
|
39
|
+
RecommendedVersionId?: string;
|
|
39
40
|
};
|
|
40
41
|
export type PackageIdType = 'PackageId' | 'SubscriberPackageVersionId' | 'PackageInstallRequestId' | 'PackageUninstallRequestId';
|
|
41
42
|
export type PackageVersionOptions1GP = Record<string, unknown>;
|
package/lib/package/package.js
CHANGED
|
@@ -36,6 +36,7 @@ exports.Package2Fields = [
|
|
|
36
36
|
'ConvertedFromPackageId',
|
|
37
37
|
'PackageErrorUsername',
|
|
38
38
|
'AppAnalyticsEnabled',
|
|
39
|
+
'RecommendedVersionId',
|
|
39
40
|
];
|
|
40
41
|
/**
|
|
41
42
|
* Provides the ability to list, create, update, delete, convert, and get version
|
|
@@ -179,7 +180,7 @@ class Package {
|
|
|
179
180
|
}
|
|
180
181
|
static getPackage2Fields(connection) {
|
|
181
182
|
const apiVersion = connection.getApiVersion();
|
|
182
|
-
return exports.Package2Fields.filter((field) => (apiVersion >= '59.0' ? true : field !== 'AppAnalyticsEnabled'));
|
|
183
|
+
return exports.Package2Fields.filter((field) => (apiVersion >= '59.0' ? true : field !== 'AppAnalyticsEnabled')).filter((field) => (apiVersion >= '66.0' ? true : field !== 'RecommendedVersionId'));
|
|
183
184
|
}
|
|
184
185
|
/**
|
|
185
186
|
* Returns the package ID of the package.
|
|
@@ -240,6 +241,9 @@ class Package {
|
|
|
240
241
|
if (opts.AppAnalyticsEnabled !== undefined && this.options.connection.getApiVersion() < '59.0') {
|
|
241
242
|
throw messages.createError('appAnalyticsEnabledApiPriorTo59Error');
|
|
242
243
|
}
|
|
244
|
+
if (opts.RecommendedVersionId !== undefined && this.options.connection.getApiVersion() < '66.0') {
|
|
245
|
+
throw messages.createError('recommendedVersionIdApiPriorTo66Error');
|
|
246
|
+
}
|
|
243
247
|
const result = await this.options.connection.tooling.update('Package2', opts);
|
|
244
248
|
if (!result.success) {
|
|
245
249
|
throw new core_1.SfError(result.errors.join(', '));
|
|
@@ -55,7 +55,7 @@ class PackageBundle {
|
|
|
55
55
|
frequency: kit_1.Duration.seconds(0),
|
|
56
56
|
timeout: kit_1.Duration.seconds(0),
|
|
57
57
|
}) {
|
|
58
|
-
return packageBundleVersion_1.PackageBundleVersion.create(options, polling);
|
|
58
|
+
return packageBundleVersion_1.PackageBundleVersion.create({ ...options, polling });
|
|
59
59
|
}
|
|
60
60
|
static async delete(connection, project, idOrAlias) {
|
|
61
61
|
// Check if it's already an ID (1Fl followed by 15 characters)
|
|
@@ -17,6 +17,7 @@ exports.PackageBundleInstall = void 0;
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
const core_1 = require("@salesforce/core");
|
|
20
|
+
const kit_1 = require("@salesforce/kit");
|
|
20
21
|
const interfaces_1 = require("../interfaces");
|
|
21
22
|
const bundleUtils_1 = require("../utils/bundleUtils");
|
|
22
23
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
@@ -24,8 +25,26 @@ const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'bundle_i
|
|
|
24
25
|
class PackageBundleInstall {
|
|
25
26
|
static async getInstallStatus(installRequestId, connection) {
|
|
26
27
|
try {
|
|
27
|
-
const
|
|
28
|
-
|
|
28
|
+
const query = 'SELECT Id, InstallStatus, PackageBundleVersionID, DevelopmentOrganization, ValidationError, ' +
|
|
29
|
+
'CreatedDate, CreatedById ' +
|
|
30
|
+
`FROM PkgBundleVersionInstallReq WHERE Id = '${installRequestId}'`;
|
|
31
|
+
const queryResult = await connection.autoFetchQuery(query, {
|
|
32
|
+
tooling: true,
|
|
33
|
+
});
|
|
34
|
+
if (!queryResult.records || queryResult.records.length === 0) {
|
|
35
|
+
throw new Error(messages.getMessage('failedToGetPackageBundleInstallStatus'));
|
|
36
|
+
}
|
|
37
|
+
const record = queryResult.records[0];
|
|
38
|
+
return {
|
|
39
|
+
Id: record.Id,
|
|
40
|
+
InstallStatus: record.InstallStatus,
|
|
41
|
+
PackageBundleVersionID: record.PackageBundleVersionID ?? '',
|
|
42
|
+
DevelopmentOrganization: record.DevelopmentOrganization ?? '',
|
|
43
|
+
ValidationError: record.ValidationError ?? '',
|
|
44
|
+
CreatedDate: record.CreatedDate ?? '',
|
|
45
|
+
CreatedById: record.CreatedById ?? '',
|
|
46
|
+
Error: record.Error,
|
|
47
|
+
};
|
|
29
48
|
}
|
|
30
49
|
catch (err) {
|
|
31
50
|
const error = err instanceof Error ? err : new Error(messages.getMessage('failedToGetPackageBundleInstallStatus'));
|
|
@@ -56,6 +75,7 @@ class PackageBundleInstall {
|
|
|
56
75
|
ValidationError: record.ValidationError ?? '',
|
|
57
76
|
CreatedDate: record.CreatedDate ?? '',
|
|
58
77
|
CreatedById: record.CreatedById ?? '',
|
|
78
|
+
Error: record.Error,
|
|
59
79
|
}));
|
|
60
80
|
}
|
|
61
81
|
static async installBundle(connection, project, options) {
|
|
@@ -80,15 +100,8 @@ class PackageBundleInstall {
|
|
|
80
100
|
if (options.polling) {
|
|
81
101
|
return PackageBundleInstall.pollInstallStatus(installResult.id, connection, options.polling);
|
|
82
102
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
PackageBundleVersionID: packageBundleVersionId,
|
|
86
|
-
DevelopmentOrganization: options.DevelopmentOrganization,
|
|
87
|
-
InstallStatus: interfaces_1.BundleSObjects.PkgBundleVersionInstallReqStatus.queued,
|
|
88
|
-
ValidationError: '',
|
|
89
|
-
CreatedDate: new Date().toISOString(),
|
|
90
|
-
CreatedById: connection.getUsername() ?? 'unknown',
|
|
91
|
-
};
|
|
103
|
+
// When not polling, query the actual status from the server to get accurate information
|
|
104
|
+
return PackageBundleInstall.getInstallStatus(installResult.id, connection);
|
|
92
105
|
}
|
|
93
106
|
static parsePackageBundleVersionId(packageBundleVersion, project) {
|
|
94
107
|
// Check if it's already an ID (starts with appropriate prefix)
|
|
@@ -106,13 +119,33 @@ class PackageBundleInstall {
|
|
|
106
119
|
if (polling.timeout?.milliseconds <= 0) {
|
|
107
120
|
return PackageBundleInstall.getInstallStatus(installRequestId, connection);
|
|
108
121
|
}
|
|
122
|
+
let remainingWaitTime = polling.timeout;
|
|
109
123
|
const pollingClient = await core_1.PollingClient.create({
|
|
110
124
|
poll: async () => {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
125
|
+
const report = await PackageBundleInstall.getInstallStatus(installRequestId, connection);
|
|
126
|
+
switch (report.InstallStatus) {
|
|
127
|
+
case interfaces_1.BundleSObjects.PkgBundleVersionInstallReqStatus.queued:
|
|
128
|
+
case interfaces_1.BundleSObjects.PkgBundleVersionInstallReqStatus.inProgress:
|
|
129
|
+
// Emit progress event for UI updates
|
|
130
|
+
await core_1.Lifecycle.getInstance().emit('bundle-install-progress', { ...report, remainingWaitTime });
|
|
131
|
+
remainingWaitTime = kit_1.Duration.seconds(remainingWaitTime.seconds - polling.frequency.seconds);
|
|
132
|
+
return {
|
|
133
|
+
completed: false,
|
|
134
|
+
payload: report,
|
|
135
|
+
};
|
|
136
|
+
case interfaces_1.BundleSObjects.PkgBundleVersionInstallReqStatus.success:
|
|
137
|
+
return { completed: true, payload: report };
|
|
138
|
+
case interfaces_1.BundleSObjects.PkgBundleVersionInstallReqStatus.error:
|
|
139
|
+
return { completed: true, payload: report };
|
|
140
|
+
default:
|
|
141
|
+
// Handle any unexpected status by continuing to poll
|
|
142
|
+
await core_1.Lifecycle.getInstance().emit('bundle-install-progress', { ...report, remainingWaitTime });
|
|
143
|
+
remainingWaitTime = kit_1.Duration.seconds(remainingWaitTime.seconds - polling.frequency.seconds);
|
|
144
|
+
return {
|
|
145
|
+
completed: false,
|
|
146
|
+
payload: report,
|
|
147
|
+
};
|
|
114
148
|
}
|
|
115
|
-
return { completed: false, payload: status };
|
|
116
149
|
},
|
|
117
150
|
frequency: polling.frequency,
|
|
118
151
|
timeout: polling.timeout,
|
|
@@ -121,8 +154,11 @@ class PackageBundleInstall {
|
|
|
121
154
|
return await pollingClient.subscribe();
|
|
122
155
|
}
|
|
123
156
|
catch (err) {
|
|
157
|
+
const report = await PackageBundleInstall.getInstallStatus(installRequestId, connection);
|
|
124
158
|
if (err instanceof Error) {
|
|
125
|
-
|
|
159
|
+
const timeoutError = new core_1.SfError(`Install request timed out. Run 'sf package bundle install report -i ${installRequestId} -o <target-org>' to check the status.`);
|
|
160
|
+
timeoutError.setData({ InstallRequestId: installRequestId, ...report });
|
|
161
|
+
throw timeoutError;
|
|
126
162
|
}
|
|
127
163
|
throw err;
|
|
128
164
|
}
|
|
@@ -3,10 +3,7 @@ import { SfProject } from '@salesforce/core';
|
|
|
3
3
|
import { Duration } from '@salesforce/kit';
|
|
4
4
|
import { BundleVersionCreateOptions, BundleSObjects, PackagingSObjects } from '../interfaces';
|
|
5
5
|
export declare class PackageBundleVersion {
|
|
6
|
-
static create(options: BundleVersionCreateOptions
|
|
7
|
-
frequency: Duration;
|
|
8
|
-
timeout: Duration;
|
|
9
|
-
}): Promise<BundleSObjects.PackageBundleVersionCreateRequestResult>;
|
|
6
|
+
static create(options: BundleVersionCreateOptions): Promise<BundleSObjects.PackageBundleVersionCreateRequestResult>;
|
|
10
7
|
static pollCreateStatus(createPackageVersionRequestId: string, connection: Connection, project: SfProject, polling: {
|
|
11
8
|
frequency: Duration;
|
|
12
9
|
timeout: Duration;
|
|
@@ -19,16 +19,16 @@ exports.PackageBundleVersion = void 0;
|
|
|
19
19
|
const core_1 = require("@salesforce/core");
|
|
20
20
|
const kit_1 = require("@salesforce/kit");
|
|
21
21
|
const interfaces_1 = require("../interfaces");
|
|
22
|
-
const bundleUtils_1 = require("../utils/bundleUtils");
|
|
23
22
|
const packageUtils_1 = require("../utils/packageUtils");
|
|
23
|
+
const bundleUtils_1 = require("../utils/bundleUtils");
|
|
24
24
|
const packageBundleVersionCreate_1 = require("./packageBundleVersionCreate");
|
|
25
25
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
26
26
|
const bundleVersionMessages = core_1.Messages.loadMessages('@salesforce/packaging', 'bundle_version');
|
|
27
27
|
class PackageBundleVersion {
|
|
28
|
-
static async create(options
|
|
28
|
+
static async create(options) {
|
|
29
29
|
const createResult = await packageBundleVersionCreate_1.PackageBundleVersionCreate.createBundleVersion(options.connection, options.project, options);
|
|
30
|
-
if (polling) {
|
|
31
|
-
return PackageBundleVersion.pollCreateStatus(createResult.Id, options.connection, options.project, polling).catch((error) => {
|
|
30
|
+
if (options.polling) {
|
|
31
|
+
return PackageBundleVersion.pollCreateStatus(createResult.Id, options.connection, options.project, options.polling).catch((error) => {
|
|
32
32
|
if (error.name === 'PollingClientTimeout') {
|
|
33
33
|
const modifiedError = new core_1.SfError(error.message);
|
|
34
34
|
modifiedError.setData({ VersionCreateRequestId: createResult.Id });
|
|
@@ -50,7 +50,8 @@ class PackageBundleVersion {
|
|
|
50
50
|
const report = await packageBundleVersionCreate_1.PackageBundleVersionCreate.getCreateStatus(createPackageVersionRequestId, connection);
|
|
51
51
|
switch (report.RequestStatus) {
|
|
52
52
|
case interfaces_1.BundleSObjects.PkgBundleVersionCreateReqStatus.queued:
|
|
53
|
-
|
|
53
|
+
case interfaces_1.BundleSObjects.PkgBundleVersionCreateReqStatus.inProgress:
|
|
54
|
+
await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.progress, { ...report, remainingWaitTime });
|
|
54
55
|
remainingWaitTime = kit_1.Duration.seconds(remainingWaitTime.seconds - polling.frequency.seconds);
|
|
55
56
|
return {
|
|
56
57
|
completed: false,
|
|
@@ -63,6 +64,14 @@ class PackageBundleVersion {
|
|
|
63
64
|
case interfaces_1.BundleSObjects.PkgBundleVersionCreateReqStatus.error:
|
|
64
65
|
await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.error, report);
|
|
65
66
|
return { completed: true, payload: report };
|
|
67
|
+
default:
|
|
68
|
+
// Handle any unexpected status by continuing to poll
|
|
69
|
+
await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.progress, { ...report, remainingWaitTime });
|
|
70
|
+
remainingWaitTime = kit_1.Duration.seconds(remainingWaitTime.seconds - polling.frequency.seconds);
|
|
71
|
+
return {
|
|
72
|
+
completed: false,
|
|
73
|
+
payload: report,
|
|
74
|
+
};
|
|
66
75
|
}
|
|
67
76
|
},
|
|
68
77
|
frequency: polling.frequency,
|
|
@@ -5,7 +5,7 @@ export declare class PackageBundleVersionCreate {
|
|
|
5
5
|
static getCreateStatuses(connection: Connection, status?: BundleSObjects.PkgBundleVersionCreateReqStatus, createdLastDays?: number): Promise<BundleSObjects.PackageBundleVersionCreateRequestResult[]>;
|
|
6
6
|
static createBundleVersion(connection: Connection, project: SfProject, options: BundleVersionCreateOptions): Promise<BundleSObjects.PackageBundleVersionCreateRequestResult>;
|
|
7
7
|
private static readBundleVersionComponents;
|
|
8
|
-
private static
|
|
8
|
+
private static getVersionNameFromBundle;
|
|
9
9
|
private static parsePackageBundleId;
|
|
10
10
|
private static getPackageVersion;
|
|
11
11
|
}
|
|
@@ -51,28 +51,46 @@ exports.PackageBundleVersionCreate = void 0;
|
|
|
51
51
|
*/
|
|
52
52
|
const fs = __importStar(require("node:fs"));
|
|
53
53
|
const core_1 = require("@salesforce/core");
|
|
54
|
-
const interfaces_1 = require("../interfaces");
|
|
55
54
|
const bundleUtils_1 = require("../utils/bundleUtils");
|
|
56
|
-
const packageBundleVersion_1 = require("./packageBundleVersion");
|
|
57
55
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
58
56
|
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'bundle_version_create');
|
|
59
57
|
class PackageBundleVersionCreate {
|
|
60
58
|
static async getCreateStatus(createPackageVersionRequestId, connection) {
|
|
61
59
|
try {
|
|
62
|
-
const
|
|
63
|
-
.
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
const query = 'SELECT Id, RequestStatus, PackageBundle.Id, PackageBundle.BundleName, PackageBundleVersion.Id, ' +
|
|
61
|
+
'VersionName, MajorVersion, MinorVersion, Ancestor.Id, BundleVersionComponents, ' +
|
|
62
|
+
'CreatedDate, CreatedById, ValidationError ' +
|
|
63
|
+
`FROM PkgBundleVersionCreateReq WHERE Id = '${createPackageVersionRequestId}'`;
|
|
64
|
+
const queryResult = await connection.autoFetchQuery(query, {
|
|
65
|
+
tooling: true,
|
|
66
|
+
});
|
|
67
|
+
if (!queryResult.records || queryResult.records.length === 0) {
|
|
68
|
+
throw new Error(messages.getMessage('failedToGetPackageBundleVersionCreateStatus'));
|
|
69
|
+
}
|
|
70
|
+
const record = queryResult.records[0];
|
|
71
|
+
return {
|
|
72
|
+
Id: record.Id,
|
|
73
|
+
RequestStatus: record.RequestStatus,
|
|
74
|
+
PackageBundleId: record.PackageBundle?.Id ?? '',
|
|
75
|
+
PackageBundleVersionId: record.PackageBundleVersion?.Id ?? '',
|
|
76
|
+
VersionName: record.VersionName ?? '',
|
|
77
|
+
MajorVersion: record.MajorVersion ?? '',
|
|
78
|
+
MinorVersion: record.MinorVersion ?? '',
|
|
79
|
+
Ancestor: record.Ancestor?.Id ?? '',
|
|
80
|
+
BundleVersionComponents: record.BundleVersionComponents ?? '',
|
|
81
|
+
CreatedDate: record.CreatedDate ?? '',
|
|
82
|
+
CreatedById: record.CreatedById ?? '',
|
|
83
|
+
ValidationError: record.ValidationError ?? '',
|
|
84
|
+
};
|
|
66
85
|
}
|
|
67
|
-
catch (
|
|
68
|
-
|
|
69
|
-
throw core_1.SfError.wrap((0, bundleUtils_1.massageErrorMessage)(error));
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw (0, bundleUtils_1.massageErrorMessage)(error);
|
|
70
88
|
}
|
|
71
89
|
}
|
|
72
90
|
static async getCreateStatuses(connection, status, createdLastDays) {
|
|
73
91
|
let query = 'SELECT Id, RequestStatus, PackageBundle.Id, PackageBundle.BundleName, PackageBundleVersion.Id, ' +
|
|
74
92
|
'VersionName, MajorVersion, MinorVersion, Ancestor.Id, BundleVersionComponents, ' +
|
|
75
|
-
'CreatedDate, CreatedById ' +
|
|
93
|
+
'CreatedDate, CreatedById, ValidationError ' +
|
|
76
94
|
'FROM PkgBundleVersionCreateReq';
|
|
77
95
|
if (status && createdLastDays) {
|
|
78
96
|
query += ` WHERE RequestStatus = '${status}' AND CreatedDate = LAST_N_DAYS: ${createdLastDays}`;
|
|
@@ -98,6 +116,7 @@ class PackageBundleVersionCreate {
|
|
|
98
116
|
BundleVersionComponents: record.BundleVersionComponents ?? '',
|
|
99
117
|
CreatedDate: record.CreatedDate ?? '',
|
|
100
118
|
CreatedById: record.CreatedById ?? '',
|
|
119
|
+
ValidationError: record.ValidationError ?? '',
|
|
101
120
|
}));
|
|
102
121
|
}
|
|
103
122
|
static async createBundleVersion(connection, project, options) {
|
|
@@ -107,9 +126,11 @@ class PackageBundleVersionCreate {
|
|
|
107
126
|
const version = options.MajorVersion && options.MinorVersion
|
|
108
127
|
? { MajorVersion: options.MajorVersion, MinorVersion: options.MinorVersion }
|
|
109
128
|
: await PackageBundleVersionCreate.getPackageVersion(options, project, connection);
|
|
129
|
+
// Get the versionName from the bundle configuration
|
|
130
|
+
const versionName = await PackageBundleVersionCreate.getVersionNameFromBundle(options.PackageBundle, project, connection);
|
|
110
131
|
const request = {
|
|
111
132
|
PackageBundleId: packageBundleId,
|
|
112
|
-
VersionName:
|
|
133
|
+
VersionName: versionName,
|
|
113
134
|
MajorVersion: version.MajorVersion,
|
|
114
135
|
MinorVersion: version.MinorVersion,
|
|
115
136
|
BundleVersionComponents: JSON.stringify(bundleVersionComponents),
|
|
@@ -126,23 +147,18 @@ class PackageBundleVersionCreate {
|
|
|
126
147
|
throw core_1.SfError.wrap((0, bundleUtils_1.massageErrorMessage)(error));
|
|
127
148
|
}
|
|
128
149
|
if (!createResult?.success) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
150
|
+
let errorMessage = messages.getMessage('failedToCreatePackageBundleVersion');
|
|
151
|
+
if (createResult.errors?.length) {
|
|
152
|
+
errorMessage = createResult.errors.join(', ');
|
|
153
|
+
}
|
|
154
|
+
else if (createResult.errors && createResult.errors.length === 0) {
|
|
155
|
+
errorMessage = 'No specific error details available from Salesforce API';
|
|
156
|
+
}
|
|
157
|
+
throw core_1.SfError.wrap((0, bundleUtils_1.massageErrorMessage)(new Error(errorMessage)));
|
|
133
158
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
PackageBundleId: packageBundleId,
|
|
138
|
-
VersionName: PackageBundleVersionCreate.getVersionName(options.PackageBundle, version.MajorVersion, version.MinorVersion),
|
|
139
|
-
MajorVersion: version.MajorVersion,
|
|
140
|
-
MinorVersion: version.MinorVersion,
|
|
141
|
-
BundleVersionComponents: JSON.stringify(bundleVersionComponents),
|
|
142
|
-
RequestStatus: interfaces_1.BundleSObjects.PkgBundleVersionCreateReqStatus.success,
|
|
143
|
-
CreatedDate: new Date().toISOString(),
|
|
144
|
-
CreatedById: connection.getUsername() ?? 'unknown',
|
|
145
|
-
};
|
|
159
|
+
// Return the request result with the ID - polling will be handled by the caller if needed
|
|
160
|
+
// Query the actual status from the server to get accurate information including the request ID
|
|
161
|
+
return PackageBundleVersionCreate.getCreateStatus(createResult.id, connection);
|
|
146
162
|
}
|
|
147
163
|
static readBundleVersionComponents(filePath, project) {
|
|
148
164
|
try {
|
|
@@ -177,8 +193,23 @@ class PackageBundleVersionCreate {
|
|
|
177
193
|
throw core_1.SfError.wrap((0, bundleUtils_1.massageErrorMessage)(error));
|
|
178
194
|
}
|
|
179
195
|
}
|
|
180
|
-
static
|
|
181
|
-
|
|
196
|
+
static async getVersionNameFromBundle(packageBundle, project, connection) {
|
|
197
|
+
const packageBundleId = PackageBundleVersionCreate.parsePackageBundleId(packageBundle, project);
|
|
198
|
+
const query = `SELECT BundleName FROM PackageBundle WHERE Id = '${packageBundleId}'`;
|
|
199
|
+
const result = await connection.tooling.query(query);
|
|
200
|
+
if (!result.records || result.records.length === 0) {
|
|
201
|
+
throw new core_1.SfError(messages.getMessage('noBundleFoundWithId', [packageBundleId]));
|
|
202
|
+
}
|
|
203
|
+
const bundleName = result.records[0].BundleName;
|
|
204
|
+
const bundles = project.getSfProjectJson().getPackageBundles();
|
|
205
|
+
const bundle = bundles.find((b) => b.name === bundleName);
|
|
206
|
+
if (!bundle) {
|
|
207
|
+
throw new core_1.SfError(messages.getMessage('noBundleFoundWithName', [bundleName]));
|
|
208
|
+
}
|
|
209
|
+
if (!bundle.versionName) {
|
|
210
|
+
throw new core_1.SfError(`Bundle '${bundleName}' is missing versionName in sfdx-project.json. Please add a versionName field to the bundle configuration.`);
|
|
211
|
+
}
|
|
212
|
+
return bundle.versionName;
|
|
182
213
|
}
|
|
183
214
|
static parsePackageBundleId(packageBundle, project) {
|
|
184
215
|
if (/^1Fl.{15}$/.test(packageBundle)) {
|
package/messages/package.md
CHANGED
|
@@ -45,3 +45,7 @@ Can't retrieve package metadata. We're unable to retrieve metadata for the packa
|
|
|
45
45
|
# packagingNotEnabledOnOrg
|
|
46
46
|
|
|
47
47
|
Can't retrieve package metadata. The org you specified doesn't have the required second-generation packaging permission enabled. Enable this permission on your Dev Hub org, and try again.
|
|
48
|
+
|
|
49
|
+
# recommendedVersionIdApiPriorTo66Error
|
|
50
|
+
|
|
51
|
+
To enable Recommended Version, use API version 66.0 or higher.
|