Skip to content

Commit cd5ada7

Browse files
Merge pull request #1019 from salesforcecli/t/packaging-distribution/W-19170618/Bug-Fixes
T/packaging distribution/w 19170618/bug fixes
2 parents 42774b3 + 8d8b525 commit cd5ada7

10 files changed

Lines changed: 85 additions & 32 deletions

File tree

command-snapshot.json

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,18 @@
6363
"flags": ["api-version", "description", "flags-dir", "json", "loglevel", "name", "target-dev-hub"],
6464
"plugin": "@salesforce/plugin-packaging"
6565
},
66+
{
67+
"alias": [],
68+
"command": "package:bundle:delete",
69+
"flagAliases": ["apiversion", "noprompt", "target-hub-org", "targetdevhubusername"],
70+
"flagChars": ["b", "n", "v"],
71+
"flags": ["api-version", "bundle", "flags-dir", "json", "loglevel", "no-prompt", "target-dev-hub"],
72+
"plugin": "@salesforce/plugin-packaging"
73+
},
6674
{
6775
"alias": [],
6876
"command": "package:bundle:install",
69-
"flagAliases": ["apiversion", "target-hub-org", "targetdevhubusername", "targetusername", "u"],
77+
"flagAliases": ["apiversion", "targetusername", "u"],
7078
"flagChars": ["b", "o", "v", "w"],
7179
"flags": [
7280
"api-version",
@@ -84,27 +92,19 @@
8492
{
8593
"alias": [],
8694
"command": "package:bundle:install:list",
87-
"flagAliases": ["apiversion", "createdlastdays", "target-hub-org", "targetdevhubusername"],
88-
"flagChars": ["c", "s", "v"],
95+
"flagAliases": ["apiversion", "createdlastdays", "targetusername", "u"],
96+
"flagChars": ["c", "o", "s"],
8997
"flags": ["api-version", "created-last-days", "flags-dir", "json", "loglevel", "status", "target-org", "verbose"],
9098
"plugin": "@salesforce/plugin-packaging"
9199
},
92100
{
93101
"alias": [],
94102
"command": "package:bundle:install:report",
95-
"flagAliases": ["apiversion", "packageinstallrequestid", "target-hub-org", "targetdevhubusername"],
96-
"flagChars": ["i", "v"],
103+
"flagAliases": ["apiversion", "packageinstallrequestid", "targetusername", "u"],
104+
"flagChars": ["i", "o"],
97105
"flags": ["api-version", "flags-dir", "json", "loglevel", "package-install-request-id", "target-org", "verbose"],
98106
"plugin": "@salesforce/plugin-packaging"
99107
},
100-
{
101-
"alias": [],
102-
"command": "package:bundle:delete",
103-
"flagAliases": ["apiversion", "noprompt", "target-hub-org", "targetdevhubusername"],
104-
"flagChars": ["b", "n", "v"],
105-
"flags": ["api-version", "bundle", "flags-dir", "json", "loglevel", "no-prompt", "target-dev-hub"],
106-
"plugin": "@salesforce/plugin-packaging"
107-
},
108108
{
109109
"alias": [],
110110
"command": "package:bundle:list",
@@ -116,8 +116,8 @@
116116
{
117117
"alias": [],
118118
"command": "package:bundle:version:create",
119-
"flagAliases": ["apiversion", "target-hub-org", "targetdevhubusername"],
120-
"flagChars": ["b", "d", "p", "v", "w"],
119+
"flagAliases": ["apiversion", "target-hub-org", "targetdevhubusername", "versionnumber"],
120+
"flagChars": ["b", "d", "n", "p", "v", "w"],
121121
"flags": [
122122
"api-version",
123123
"bundle",
@@ -128,6 +128,7 @@
128128
"loglevel",
129129
"target-dev-hub",
130130
"verbose",
131+
"version-number",
131132
"wait"
132133
],
133134
"plugin": "@salesforce/plugin-packaging"

messages/bundle_install.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Package bundle version to install (format: BundleName@Version).
2020

2121
Target org for the bundle installation.
2222

23+
# flags.target-dev-hub.summary
24+
25+
Username, alias, or org ID of the target dev hub org.
26+
2327
# flags.wait.summary
2428

2529
Number of minutes to wait for the installation to complete.

messages/bundle_version_create.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ Show verbose output of the command execution.
3232

3333
Show detailed information about the bundle version creation process.
3434

35+
# flags.version-number.summary
36+
37+
Version number of the package bundle version to be created; overrides the sfdx-project.json value.
38+
3539
# flags.description.summary
3640

3741
Description of the package bundle version.
@@ -46,7 +50,8 @@ Package Bundle version creation completed with status: %s
4650

4751
# multipleErrors
4852

49-
The following errors occurred during bundle version creation:%s
53+
The following errors occurred during bundle version creation:
54+
%s
5055

5156
# InProgress
5257

src/commands/package/bundle/install.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
import { BundleSObjects, BundleInstallOptions, PackageBundleInstall } from '@salesforce/packaging';
1616
import { Messages, Lifecycle } from '@salesforce/core';
1717
import { camelCaseToTitleCase, Duration } from '@salesforce/kit';
18-
import { requiredHubFlag } from '../../../utils/hubFlag.js';
1918

2019
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
2120
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'bundle_install');
@@ -37,7 +36,11 @@ export class PackageBundlesInstall extends SfCommand<BundleSObjects.PkgBundleVer
3736
}),
3837
'target-org': requiredOrgFlagWithDeprecations,
3938
'api-version': orgApiVersionFlagWithDeprecations,
40-
'target-dev-hub': requiredHubFlag,
39+
'target-dev-hub': Flags.string({
40+
char: 'v',
41+
summary: messages.getMessage('flags.target-dev-hub.summary'),
42+
required: true,
43+
}),
4144
wait: Flags.integer({
4245
char: 'w',
4346
summary: messages.getMessage('flags.wait.summary'),
@@ -53,14 +56,28 @@ export class PackageBundlesInstall extends SfCommand<BundleSObjects.PkgBundleVer
5356

5457
// Get the target org connection
5558
const targetOrg = flags['target-org'];
56-
const targetDevHub = flags['target-dev-hub'];
59+
const targetDevHubFlag = flags['target-dev-hub'];
5760
const connection = targetOrg.getConnection(flags['api-version']);
5861

62+
// Check if targetDevHub is already a valid org ID (starts with 00D and is 18 characters)
63+
const orgIdRegex = /^00D[a-zA-Z0-9]{15}$/;
64+
let targetDevHub: string;
65+
66+
if (orgIdRegex.test(targetDevHubFlag)) {
67+
// It's already an org ID, use it directly
68+
targetDevHub = targetDevHubFlag;
69+
} else {
70+
// It's a username/alias, resolve it to an org and get the org ID
71+
const { Org } = await import('@salesforce/core');
72+
const devHubOrg = await Org.create({ aliasOrUsername: targetDevHubFlag, isDevHub: true });
73+
targetDevHub = devHubOrg.getOrgId();
74+
}
75+
5976
const options: BundleInstallOptions = {
6077
connection,
6178
project: this.project!,
6279
PackageBundleVersion: flags.bundle,
63-
DevelopmentOrganization: targetDevHub.getOrgId() ?? '',
80+
DevelopmentOrganization: targetDevHub,
6481
};
6582

6683
// Set up lifecycle events for progress tracking

src/commands/package/bundle/install/list.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
8+
import {
9+
Flags,
10+
loglevel,
11+
orgApiVersionFlagWithDeprecations,
12+
requiredOrgFlagWithDeprecations,
13+
SfCommand,
14+
} from '@salesforce/sf-plugins-core';
915
import { Connection, Messages } from '@salesforce/core';
1016
import { BundleSObjects, PackageBundleInstall } from '@salesforce/packaging';
1117
import chalk from 'chalk';
12-
import { requiredHubFlag } from '../../../../utils/hubFlag.js';
1318

1419
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
1520
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'bundle_install_list');
@@ -25,7 +30,7 @@ export class PackageBundleInstallListCommand extends SfCommand<PackageBundleInst
2530
public static readonly examples = messages.getMessages('examples');
2631
public static readonly flags = {
2732
loglevel,
28-
'target-org': requiredHubFlag,
33+
'target-org': requiredOrgFlagWithDeprecations,
2934
'api-version': orgApiVersionFlagWithDeprecations,
3035
'created-last-days': Flags.integer({
3136
char: 'c',

src/commands/package/bundle/install/report.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
8+
import {
9+
Flags,
10+
loglevel,
11+
orgApiVersionFlagWithDeprecations,
12+
requiredOrgFlagWithDeprecations,
13+
SfCommand,
14+
} from '@salesforce/sf-plugins-core';
915
import { Messages } from '@salesforce/core';
1016
import { BundleSObjects, PackageBundleInstall } from '@salesforce/packaging';
1117
import chalk from 'chalk';
1218
import { camelCaseToTitleCase } from '@salesforce/kit';
13-
import { requiredHubFlag } from '../../../../utils/hubFlag.js';
1419

1520
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
1621
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'bundle_install_report');
@@ -25,7 +30,7 @@ export class PackageBundleInstallReportCommand extends SfCommand<ReportCommandRe
2530
public static readonly examples = messages.getMessages('examples');
2631
public static readonly flags = {
2732
loglevel,
28-
'target-org': requiredHubFlag,
33+
'target-org': requiredOrgFlagWithDeprecations,
2934
'api-version': orgApiVersionFlagWithDeprecations,
3035
// eslint-disable-next-line sf-plugin/id-flag-suggestions
3136
'package-install-request-id': Flags.salesforceId({

src/commands/package/bundle/version/create.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,34 @@ export class PackageBundlesCreate extends SfCommand<BundleSObjects.PackageBundle
5454
verbose: Flags.boolean({
5555
summary: messages.getMessage('flags.verbose.summary'),
5656
}),
57+
'version-number': Flags.string({
58+
deprecateAliases: true,
59+
aliases: ['versionnumber'],
60+
char: 'n',
61+
summary: messages.getMessage('flags.version-number.summary'),
62+
}),
5763
};
5864

5965
public async run(): Promise<BundleSObjects.PackageBundleVersionCreateRequestResult> {
6066
const { flags } = await this.parse(PackageBundlesCreate);
67+
68+
// Parse version number if provided
69+
let majorVersion = '';
70+
let minorVersion = '';
71+
if (flags['version-number']) {
72+
const versionParts = flags['version-number'].split('.');
73+
majorVersion = versionParts[0] || '';
74+
minorVersion = versionParts[1] || '';
75+
}
76+
6177
const options: BundleVersionCreateOptions = {
6278
connection: flags['target-dev-hub'].getConnection(flags['api-version']),
6379
project: this.project!,
6480
PackageBundle: flags.bundle,
6581
BundleVersionComponentsPath: flags['definition-file'],
6682
Description: flags.description,
67-
MajorVersion: '',
68-
MinorVersion: '',
83+
MajorVersion: majorVersion,
84+
MinorVersion: minorVersion,
6985
Ancestor: '',
7086
};
7187
Lifecycle.getInstance().on(
@@ -106,7 +122,7 @@ export class PackageBundlesCreate extends SfCommand<BundleSObjects.PackageBundle
106122

107123
switch (result.RequestStatus) {
108124
case BundleSObjects.PkgBundleVersionCreateReqStatus.error:
109-
throw messages.createError('multipleErrors', ['Unknown error']);
125+
throw messages.createError('multipleErrors', [result.Error?.join('\n') ?? 'Unknown error']);
110126
case BundleSObjects.PkgBundleVersionCreateReqStatus.success:
111127
this.log(messages.getMessage('bundleVersionCreateSuccess', [result.Id]));
112128
break;

src/commands/package/bundle/version/report.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export class PackageBundleVersionReportCommand extends SfCommand<BundleVersionRe
194194
'Package Name': component.Name,
195195
'Package Version Number': `${component.MajorVersion}.${component.MinorVersion}.${component.PatchVersion}.${component.BuildNumber}`,
196196
'Package Version Id': component.Id,
197-
'Package Subscriber Id': component.SubscriberPackageId,
197+
'Package Id': component.SubscriberPackageId,
198198
}));
199199

200200
this.table({ data: displayRecords, title: chalk.blue('Component Packages') });

test/commands/bundle/bundleInstallReport.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('package:bundle:install:report - tests', () => {
104104
await cmd.run();
105105
expect.fail('Expected error was not thrown');
106106
} catch (error) {
107-
expect((error as Error).message).to.include('No default dev hub found');
107+
expect((error as Error).message).to.include('No default environment found');
108108
}
109109
});
110110

test/commands/bundle/packageBundleVersionCreate.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ describe('package:bundle:version:create - tests', () => {
222222
assert.fail('the above should throw multiple errors');
223223
} catch (e) {
224224
expect((e as Error).message).to.equal(
225-
'The following errors occurred during bundle version creation:Unknown error'
225+
'The following errors occurred during bundle version creation:\nPropertyController: Invalid type: Schema.Property__c\nSampleDataController: Invalid type: Schema.Property__c\nSampleDataController: Invalid type: Schema.Broker__c'
226226
);
227227
}
228228
});

0 commit comments

Comments
 (0)