@salesforce/b2c-cli 0.7.0 → 0.7.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.
|
@@ -14,6 +14,9 @@ export default class CloneCreate extends OdsCommand<typeof CloneCreate> {
|
|
|
14
14
|
'target-profile': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
15
|
emails: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
ttl: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
wait: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
'poll-interval': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
timeout: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
20
|
};
|
|
18
21
|
run(): Promise<{
|
|
19
22
|
cloneId?: string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Args, Flags, Errors } from '@oclif/core';
|
|
7
7
|
import { OdsCommand } from '@salesforce/b2c-tooling-sdk/cli';
|
|
8
|
-
import { getApiErrorMessage } from '@salesforce/b2c-tooling-sdk';
|
|
8
|
+
import { getApiErrorMessage, waitForClone, ClonePollingTimeoutError, ClonePollingError, CloneFailedError, } from '@salesforce/b2c-tooling-sdk';
|
|
9
9
|
import { t } from '../../../i18n/index.js';
|
|
10
10
|
/**
|
|
11
11
|
* Command to create a sandbox clone.
|
|
@@ -25,6 +25,8 @@ export default class CloneCreate extends OdsCommand {
|
|
|
25
25
|
'<%= config.bin %> <%= command.id %> <sandboxId> --target-profile large',
|
|
26
26
|
'<%= config.bin %> <%= command.id %> <sandboxId> --ttl 48',
|
|
27
27
|
'<%= config.bin %> <%= command.id %> <sandboxId> --target-profile large --ttl 48 --emails dev@example.com,qa@example.com',
|
|
28
|
+
'<%= config.bin %> <%= command.id %> <sandboxId> --wait',
|
|
29
|
+
'<%= config.bin %> <%= command.id %> <sandboxId> --wait --poll-interval 15',
|
|
28
30
|
];
|
|
29
31
|
static flags = {
|
|
30
32
|
'target-profile': Flags.string({
|
|
@@ -42,10 +44,25 @@ export default class CloneCreate extends OdsCommand {
|
|
|
42
44
|
required: false,
|
|
43
45
|
default: 24,
|
|
44
46
|
}),
|
|
47
|
+
wait: Flags.boolean({
|
|
48
|
+
char: 'w',
|
|
49
|
+
description: 'Wait for the clone to complete before returning',
|
|
50
|
+
default: false,
|
|
51
|
+
}),
|
|
52
|
+
'poll-interval': Flags.integer({
|
|
53
|
+
description: 'Polling interval in seconds when using --wait',
|
|
54
|
+
default: 10,
|
|
55
|
+
dependsOn: ['wait'],
|
|
56
|
+
}),
|
|
57
|
+
timeout: Flags.integer({
|
|
58
|
+
description: 'Maximum time to wait in seconds when using --wait (0 for no timeout)',
|
|
59
|
+
default: 1800,
|
|
60
|
+
dependsOn: ['wait'],
|
|
61
|
+
}),
|
|
45
62
|
};
|
|
46
63
|
async run() {
|
|
47
64
|
const { sandboxId: rawSandboxId } = this.args;
|
|
48
|
-
const { 'target-profile': targetProfile, emails, ttl } = this.flags;
|
|
65
|
+
const { 'target-profile': targetProfile, emails, ttl, wait, 'poll-interval': pollInterval, timeout } = this.flags;
|
|
49
66
|
// Validate TTL
|
|
50
67
|
if (ttl > 0 && ttl < 24) {
|
|
51
68
|
throw new Errors.CLIError(t('commands.clone.create.invalidTTL', 'TTL must be 0 or negative (infinite), or 24 hours or greater. Values between 1-23 are not allowed. Received: {{ttl}}', { ttl }));
|
|
@@ -75,12 +92,48 @@ export default class CloneCreate extends OdsCommand {
|
|
|
75
92
|
this.error(t('commands.clone.create.error', 'Failed to create sandbox clone: {{message}}', { message }));
|
|
76
93
|
}
|
|
77
94
|
const cloneId = result.data.data?.cloneId;
|
|
78
|
-
if (this.jsonEnabled()) {
|
|
79
|
-
|
|
95
|
+
if (!this.jsonEnabled()) {
|
|
96
|
+
this.log(t('commands.clone.create.success', '✓ Sandbox clone creation started successfully'));
|
|
97
|
+
this.log(t('commands.clone.create.cloneId', 'Clone ID: {{cloneId}}', { cloneId }));
|
|
98
|
+
}
|
|
99
|
+
if (wait && cloneId) {
|
|
100
|
+
this.log(t('commands.clone.create.waiting', 'Waiting for clone to complete...'));
|
|
101
|
+
try {
|
|
102
|
+
await waitForClone(this.odsClient, {
|
|
103
|
+
sandboxId,
|
|
104
|
+
cloneId,
|
|
105
|
+
pollIntervalSeconds: pollInterval,
|
|
106
|
+
timeoutSeconds: timeout,
|
|
107
|
+
onPoll: ({ elapsedSeconds, status, progressPercentage }) => {
|
|
108
|
+
const progress = progressPercentage === undefined ? '' : ` (${progressPercentage}%)`;
|
|
109
|
+
this.logger.info({ sandboxId, cloneId, elapsed: elapsedSeconds, status }, `[${elapsedSeconds}s] Status: ${status}${progress}`);
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (error instanceof ClonePollingTimeoutError) {
|
|
115
|
+
this.error(t('commands.clone.create.timeout', 'Timeout waiting for clone after {{seconds}} seconds', {
|
|
116
|
+
seconds: String(error.timeoutSeconds),
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
if (error instanceof CloneFailedError) {
|
|
120
|
+
this.error(t('commands.clone.create.failed', 'Clone operation failed'));
|
|
121
|
+
}
|
|
122
|
+
if (error instanceof ClonePollingError) {
|
|
123
|
+
this.error(t('commands.clone.create.pollError', 'Failed to fetch clone status: {{message}}', {
|
|
124
|
+
message: error.message,
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
if (!this.jsonEnabled()) {
|
|
130
|
+
this.log(t('commands.clone.create.completed', '✓ Clone completed successfully'));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else if (!this.jsonEnabled()) {
|
|
134
|
+
const bin = this.config.bin;
|
|
135
|
+
this.log(t('commands.clone.create.checkStatus', '\nTo check the clone status, run:\n {{bin}} sandbox clone get {{sandboxId}} {{cloneId}}', { bin, sandboxId, cloneId }));
|
|
80
136
|
}
|
|
81
|
-
this.log(t('commands.clone.create.success', '✓ Sandbox clone creation started successfully'));
|
|
82
|
-
this.log(t('commands.clone.create.cloneId', 'Clone ID: {{cloneId}}', { cloneId }));
|
|
83
|
-
this.log(t('commands.clone.create.checkStatus', '\nTo check the clone status, run:\n <%= config.bin %> ods clone get {{sandboxId}} {{cloneId}}', { sandboxId, cloneId }));
|
|
84
137
|
return { cloneId };
|
|
85
138
|
}
|
|
86
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/sandbox/clone/create.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAC,MAAM,aAAa,CAAC;AAChD,OAAO,EAAC,UAAU,EAAC,MAAM,iCAAiC,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/sandbox/clone/create.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAC,MAAM,aAAa,CAAC;AAChD,OAAO,EAAC,UAAU,EAAC,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAC,CAAC,EAAC,MAAM,wBAAwB,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAA8B;IACrE,MAAM,CAAC,OAAO,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAEtC,MAAM,CAAC,IAAI,GAAG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