@salesforce/packaging 4.15.0 → 4.16.0
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/package/packageBundle.js +1 -1
- package/lib/package/packageBundleInstall.js +52 -16
- package/lib/package/packageBundleVersion.d.ts +9 -4
- package/lib/package/packageBundleVersion.js +47 -5
- package/lib/package/packageBundleVersionCreate.d.ts +1 -1
- package/lib/package/packageBundleVersionCreate.js +60 -29
- 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 = {}));
|
|
@@ -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;
|
|
@@ -18,4 +15,12 @@ export declare class PackageBundleVersion {
|
|
|
18
15
|
private static mapPackageBundle;
|
|
19
16
|
private static mapAncestor;
|
|
20
17
|
private static mapAncestorPackageBundle;
|
|
18
|
+
/**
|
|
19
|
+
* Add a bundle version alias to the sfdx-project.json file after successful bundle version creation.
|
|
20
|
+
* Creates an alias in the format: <BundleName>@<MajorVersion>.<MinorVersion>
|
|
21
|
+
*
|
|
22
|
+
* @param project The SfProject instance
|
|
23
|
+
* @param result The bundle version create result containing bundle information
|
|
24
|
+
*/
|
|
25
|
+
private static addBundleVersionAlias;
|
|
21
26
|
}
|
|
@@ -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
|
-
|
|
30
|
+
if (options.polling) {
|
|
31
|
+
const finalResult = await 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 });
|
|
@@ -37,6 +37,17 @@ class PackageBundleVersion {
|
|
|
37
37
|
}
|
|
38
38
|
throw (0, packageUtils_1.applyErrorAction)((0, bundleUtils_1.massageErrorMessage)(error));
|
|
39
39
|
});
|
|
40
|
+
// Add bundle version alias to sfdx-project.json after successful creation
|
|
41
|
+
if (finalResult.RequestStatus === interfaces_1.BundleSObjects.PkgBundleVersionCreateReqStatus.success && finalResult.PackageBundleVersionId) {
|
|
42
|
+
await PackageBundleVersion.addBundleVersionAlias(options.project, finalResult);
|
|
43
|
+
}
|
|
44
|
+
return finalResult;
|
|
45
|
+
}
|
|
46
|
+
// Add bundle version alias to sfdx-project.json after successful creation (non-polling case)
|
|
47
|
+
// Note: In the non-polling case, the bundle version may not be created yet (status is 'Queued' or 'InProgress')
|
|
48
|
+
// So we only add the alias if the status is already 'Success'
|
|
49
|
+
if (createResult.RequestStatus === interfaces_1.BundleSObjects.PkgBundleVersionCreateReqStatus.success && createResult.PackageBundleVersionId) {
|
|
50
|
+
await PackageBundleVersion.addBundleVersionAlias(options.project, createResult);
|
|
40
51
|
}
|
|
41
52
|
return createResult;
|
|
42
53
|
}
|
|
@@ -50,7 +61,8 @@ class PackageBundleVersion {
|
|
|
50
61
|
const report = await packageBundleVersionCreate_1.PackageBundleVersionCreate.getCreateStatus(createPackageVersionRequestId, connection);
|
|
51
62
|
switch (report.RequestStatus) {
|
|
52
63
|
case interfaces_1.BundleSObjects.PkgBundleVersionCreateReqStatus.queued:
|
|
53
|
-
|
|
64
|
+
case interfaces_1.BundleSObjects.PkgBundleVersionCreateReqStatus.inProgress:
|
|
65
|
+
await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.progress, { ...report, remainingWaitTime });
|
|
54
66
|
remainingWaitTime = kit_1.Duration.seconds(remainingWaitTime.seconds - polling.frequency.seconds);
|
|
55
67
|
return {
|
|
56
68
|
completed: false,
|
|
@@ -63,6 +75,14 @@ class PackageBundleVersion {
|
|
|
63
75
|
case interfaces_1.BundleSObjects.PkgBundleVersionCreateReqStatus.error:
|
|
64
76
|
await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.error, report);
|
|
65
77
|
return { completed: true, payload: report };
|
|
78
|
+
default:
|
|
79
|
+
// Handle any unexpected status by continuing to poll
|
|
80
|
+
await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.progress, { ...report, remainingWaitTime });
|
|
81
|
+
remainingWaitTime = kit_1.Duration.seconds(remainingWaitTime.seconds - polling.frequency.seconds);
|
|
82
|
+
return {
|
|
83
|
+
completed: false,
|
|
84
|
+
payload: report,
|
|
85
|
+
};
|
|
66
86
|
}
|
|
67
87
|
},
|
|
68
88
|
frequency: polling.frequency,
|
|
@@ -220,6 +240,28 @@ class PackageBundleVersion {
|
|
|
220
240
|
SystemModstamp: packageBundle?.SystemModstamp ?? '',
|
|
221
241
|
};
|
|
222
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Add a bundle version alias to the sfdx-project.json file after successful bundle version creation.
|
|
245
|
+
* Creates an alias in the format: <BundleName>@<MajorVersion>.<MinorVersion>
|
|
246
|
+
*
|
|
247
|
+
* @param project The SfProject instance
|
|
248
|
+
* @param result The bundle version create result containing bundle information
|
|
249
|
+
*/
|
|
250
|
+
static async addBundleVersionAlias(project, result) {
|
|
251
|
+
// Skip if auto-update is disabled
|
|
252
|
+
if (kit_1.env.getBoolean('SF_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_CREATE')) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
// Ensure we have the necessary information to create the alias
|
|
256
|
+
if (!result.PackageBundleVersionId || !result.VersionName || !result.MajorVersion || !result.MinorVersion) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
// Create alias in format: BundleName@MajorVersion.MinorVersion
|
|
260
|
+
const alias = `${result.VersionName}@${result.MajorVersion}.${result.MinorVersion}`;
|
|
261
|
+
// Add the alias to the sfdx-project.json file
|
|
262
|
+
project.getSfProjectJson().addPackageBundleAlias(alias, result.PackageBundleVersionId);
|
|
263
|
+
await project.getSfProjectJson().write();
|
|
264
|
+
}
|
|
223
265
|
}
|
|
224
266
|
exports.PackageBundleVersion = PackageBundleVersion;
|
|
225
267
|
//# sourceMappingURL=packageBundleVersion.js.map
|
|
@@ -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)) {
|