@salesforce/b2c-cli 0.6.0 → 0.7.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.
@@ -0,0 +1,24 @@
1
+ import { OdsCommand } from '@salesforce/b2c-tooling-sdk/cli';
2
+ import { type OdsComponents } from '@salesforce/b2c-tooling-sdk';
3
+ type SandboxModel = OdsComponents['schemas']['SandboxModel'];
4
+ /**
5
+ * Command to update an on-demand sandbox.
6
+ */
7
+ export default class SandboxUpdate extends OdsCommand<typeof SandboxUpdate> {
8
+ static aliases: string[];
9
+ static args: {
10
+ sandboxId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
11
+ };
12
+ static description: string;
13
+ static enableJsonFlag: boolean;
14
+ static examples: string[];
15
+ static flags: {
16
+ ttl: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ 'auto-scheduled': import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ tags: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ emails: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ };
21
+ run(): Promise<SandboxModel>;
22
+ private printSandboxSummary;
23
+ }
24
+ export {};
@@ -0,0 +1,111 @@
1
+ /*
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * SPDX-License-Identifier: Apache-2
4
+ * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
5
+ */
6
+ import { Args, Flags, ux } from '@oclif/core';
7
+ import cliui from 'cliui';
8
+ import { OdsCommand } from '@salesforce/b2c-tooling-sdk/cli';
9
+ import { getApiErrorMessage } from '@salesforce/b2c-tooling-sdk';
10
+ import { t, withDocs } from '../../i18n/index.js';
11
+ /**
12
+ * Command to update an on-demand sandbox.
13
+ */
14
+ export default class SandboxUpdate extends OdsCommand {
15
+ static aliases = ['ods:update'];
16
+ static args = {
17
+ sandboxId: Args.string({
18
+ description: 'Sandbox ID (UUID or realm-instance, e.g., abcd-123)',
19
+ required: true,
20
+ }),
21
+ };
22
+ static description = withDocs(t('commands.sandbox.update.description', 'Update a sandbox (extend TTL, change scheduling, update tags or emails)'), '/cli/sandbox.html#b2c-sandbox-update');
23
+ static enableJsonFlag = true;
24
+ static examples = [
25
+ '<%= config.bin %> <%= command.id %> zzzv-123 --ttl 48',
26
+ '<%= config.bin %> <%= command.id %> zzzv-123 --ttl 0',
27
+ '<%= config.bin %> <%= command.id %> zzzv-123 --auto-scheduled',
28
+ '<%= config.bin %> <%= command.id %> zzzv-123 --no-auto-scheduled',
29
+ '<%= config.bin %> <%= command.id %> zzzv-123 --tags tag1,tag2',
30
+ '<%= config.bin %> <%= command.id %> zzzv-123 --emails user@example.com,dev@example.com',
31
+ '<%= config.bin %> <%= command.id %> zzzv-123 --ttl 48 --tags ci,nightly --json',
32
+ ];
33
+ static flags = {
34
+ ttl: Flags.integer({
35
+ description: 'Number of hours to add to sandbox lifetime (0 or less for infinite)',
36
+ }),
37
+ 'auto-scheduled': Flags.boolean({
38
+ description: 'Enable or disable automatic start/stop scheduling',
39
+ allowNo: true,
40
+ }),
41
+ tags: Flags.string({
42
+ description: 'Comma-separated list of tags',
43
+ }),
44
+ emails: Flags.string({
45
+ description: 'Comma-separated list of notification email addresses',
46
+ }),
47
+ };
48
+ async run() {
49
+ const sandboxId = await this.resolveSandboxId(this.args.sandboxId);
50
+ const { ttl, 'auto-scheduled': autoScheduled, tags, emails } = this.flags;
51
+ // Require at least one update flag
52
+ if (ttl === undefined && autoScheduled === undefined && tags === undefined && emails === undefined) {
53
+ this.error('At least one update flag is required. Use --ttl, --auto-scheduled, --tags, or --emails.');
54
+ }
55
+ const body = {};
56
+ if (ttl !== undefined) {
57
+ body.ttl = ttl;
58
+ }
59
+ if (autoScheduled !== undefined) {
60
+ body.autoScheduled = autoScheduled;
61
+ }
62
+ if (tags !== undefined) {
63
+ body.tags = tags.split(',').map((tag) => tag.trim());
64
+ }
65
+ if (emails !== undefined) {
66
+ body.emails = emails.split(',').map((email) => email.trim());
67
+ }
68
+ this.log(t('commands.sandbox.update.updating', 'Updating sandbox {{sandboxId}}...', { sandboxId }));
69
+ const result = await this.odsClient.PATCH('/sandboxes/{sandboxId}', {
70
+ params: {
71
+ path: { sandboxId },
72
+ },
73
+ body,
74
+ });
75
+ if (!result.data?.data) {
76
+ const message = getApiErrorMessage(result.error, result.response);
77
+ this.error(`Failed to update sandbox: ${message}`);
78
+ }
79
+ const sandbox = result.data.data;
80
+ this.log(t('commands.sandbox.update.success', 'Sandbox updated successfully'));
81
+ if (this.jsonEnabled()) {
82
+ return sandbox;
83
+ }
84
+ this.printSandboxSummary(sandbox);
85
+ return sandbox;
86
+ }
87
+ printSandboxSummary(sandbox) {
88
+ const ui = cliui({ width: process.stdout.columns || 80 });
89
+ const fields = [
90
+ ['ID', sandbox.id],
91
+ ['Realm', sandbox.realm],
92
+ ['Instance', sandbox.instance],
93
+ ['State', sandbox.state],
94
+ ['Auto Scheduled', sandbox.autoScheduled?.toString()],
95
+ ['EOL', sandbox.eol ? new Date(sandbox.eol).toLocaleString() : undefined],
96
+ ];
97
+ if (sandbox.tags && sandbox.tags.length > 0) {
98
+ fields.push(['Tags', sandbox.tags.join(', ')]);
99
+ }
100
+ if (sandbox.emails && sandbox.emails.length > 0) {
101
+ fields.push(['Emails', sandbox.emails.join(', ')]);
102
+ }
103
+ for (const [label, value] of fields) {
104
+ if (value !== undefined) {
105
+ ui.div({ text: `${label}:`, width: 20, padding: [0, 2, 0, 0] }, { text: value, padding: [0, 0, 0, 0] });
106
+ }
107
+ }
108
+ ux.stdout(ui.toString());
109
+ }
110
+ }
111
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/sandbox/update.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,IAAI,EAAE,K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