@salesforce/b2c-cli 1.1.0 → 1.2.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,37 @@
1
+ import { InstanceCommand } from '@salesforce/b2c-tooling-sdk/cli';
2
+ export default class Debug extends InstanceCommand<typeof Debug> {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ 'cartridge-path': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ 'client-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ server: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'webdav-server': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'code-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ username: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ certificate: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ passphrase: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ selfsigned: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ verify: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
+ 'client-secret': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'auth-scope': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'short-code': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ 'tenant-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
+ 'auth-methods': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ 'user-auth': import("@oclif/core/interfaces").BooleanFlag<boolean>;
23
+ 'account-manager-host': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
24
+ 'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
+ debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
26
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
27
+ jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
28
+ lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
29
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
30
+ instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
31
+ 'project-directory': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
32
+ 'extra-query': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
33
+ 'extra-body': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
34
+ 'extra-headers': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
35
+ };
36
+ run(): Promise<void>;
37
+ }
@@ -0,0 +1,64 @@
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 { Flags } from '@oclif/core';
7
+ import { InstanceCommand } from '@salesforce/b2c-tooling-sdk/cli';
8
+ import { findCartridges } from '@salesforce/b2c-tooling-sdk/operations/code';
9
+ import { B2CScriptDebugAdapter } from '@salesforce/b2c-tooling-sdk/operations/debug';
10
+ export default class Debug extends InstanceCommand {
11
+ static description = 'Start a DAP debug adapter for B2C Commerce script debugging';
12
+ static examples = [
13
+ '<%= config.bin %> <%= command.id %>',
14
+ '<%= config.bin %> <%= command.id %> --cartridge-path ./cartridges',
15
+ '<%= config.bin %> <%= command.id %> --client-id my-debugger',
16
+ ];
17
+ static flags = {
18
+ ...InstanceCommand.baseFlags,
19
+ 'cartridge-path': Flags.string({
20
+ description: 'Path to cartridges directory',
21
+ default: '.',
22
+ }),
23
+ 'client-id': Flags.string({
24
+ description: 'Client ID for the debugger API',
25
+ default: 'b2c-cli',
26
+ }),
27
+ };
28
+ async run() {
29
+ this.requireServer();
30
+ const hostname = this.resolvedConfig.values.hostname;
31
+ const username = this.resolvedConfig.values.username;
32
+ const password = this.resolvedConfig.values.password;
33
+ if (!username || !password) {
34
+ this.error('Basic auth credentials (username/password) are required for the script debugger. ' +
35
+ 'Set via --username/--password flags, SFCC_USERNAME/SFCC_PASSWORD env vars, or dw.json.');
36
+ }
37
+ const cartridgePath = this.flags['cartridge-path'] ?? '.';
38
+ const cartridges = findCartridges(cartridgePath);
39
+ if (cartridges.length === 0) {
40
+ this.warn(`No cartridges found in ${cartridgePath}`);
41
+ }
42
+ this.logger.info(`Mapped ${cartridges.length} cartridge(s): ${cartridges.map((c) => c.name).join(', ') || '(none)'}`);
43
+ const callbacks = {
44
+ onConnected: (host) => this.logger.debug(`Connected to script debugger on ${host}`),
45
+ onDisconnected: () => this.logger.debug('Script debugger disconnected'),
46
+ onDebuggerDisabled: () => this.logger.debug('Script debugger was disabled externally'),
47
+ };
48
+ const adapter = new B2CScriptDebugAdapter({
49
+ hostname,
50
+ username,
51
+ password,
52
+ clientId: this.flags['client-id'],
53
+ cartridgeRoots: cartridges,
54
+ }, callbacks);
55
+ // Run the DAP adapter over stdio
56
+ adapter.start(process.stdin, process.stdout);
57
+ // Wait for the adapter to finish (stdin closes)
58
+ await new Promise((resolve) => {
59
+ process.stdin.on('end', resolve);
60
+ process.stdin.on('close', resolve);
61
+ });
62
+ }
63
+ }
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/debug/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAC;AAClC,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAC,cAAc,EAAC,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAC,qBAAqB,EAA6B,MAAM,8CAA8C,CAAC;AAE/G,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,eAA6B;IAC9D,MAAM,CAAC,WAAW,GAAG,6DAA6D,CAAC;IAEnF,MAAM,CAAC,QAAQ,GAAG;QAChB,qCAAqC;QACrC,mEAAmE;QACnE,6DAA6D;KAC9D,CAAC;IAEF,MAAM,CAAC,KAAK,GAAG;QACb,GAAG,eAAe,CAAC,SAAS;QAC5B,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC;YAC7B,WAAW,EAAE,8BAA8B;YAC3C,OAAO,EAAE,GAAG;SACb,CAAC;QACF,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;YACxB,WAAW,EAAE,gCAAgC;YAC7C,OAAO,EAAE,SAAS;SACnB,CAAC;KACH,CAAC;IAEF,KAAK,CAAC,GAAG;QACP,IAAI,CAAC,aAAa,EAAE,CAAC;QAErB,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,QAAS,CAAC;QACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC;QACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC;QAErD,IAAI,CAAC,QAAQ,IAAI,CAAC,QAA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