@salesforce/b2c-cli 0.4.1 → 0.5.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/dist/commands/cip/describe.d.ts +48 -0
- package/dist/commands/cip/describe.js +70 -0
- package/dist/commands/cip/describe.js.map +1 -0
- package/dist/commands/cip/query.d.ts +46 -0
- package/dist/commands/cip/query.js +81 -0
- package/dist/commands/cip/query.js.map +1 -0
- package/dist/commands/cip/report/customer-registration-trends.d.ts +37 -0
- package/dist/commands/cip/report/customer-registration-trends.js +22 -0
- package/dist/commands/cip/report/customer-registration-trends.js.map +1 -0
- package/dist/commands/cip/report/ocapi-requests.d.ts +37 -0
- package/dist/commands/cip/report/ocapi-requests.js +22 -0
- package/dist/commands/cip/report/ocapi-requests.js.map +1 -0
- package/dist/commands/cip/report/payment-method-performance.d.ts +37 -0
- package/dist/commands/cip/report/payment-method-performance.js +22 -0
- package/dist/commands/cip/report/payment-method-performance.js.map +1 -0
- package/dist/commands/cip/report/product-co-purchase-analysis.d.ts +37 -0
- package/dist/commands/cip/report/product-co-purchase-analysis.js +22 -0
- package/dist/commands/cip/report/product-co-purchase-analysis.js.map +1 -0
- package/dist/commands/cip/report/promotion-discount-analysis.d.ts +36 -0
- package/dist/commands/cip/report/promotion-discount-analysis.js +20 -0
- package/dist/commands/cip/report/promotion-discount-analysis.js.map +1 -0
- package/dist/commands/cip/report/sales-analytics.d.ts +37 -0
- package/dist/commands/cip/report/sales-analytics.js +22 -0
- package/dist/commands/cip/report/sales-analytics.js.map +1 -0
- package/dist/commands/cip/report/sales-summary.d.ts +37 -0
- package/dist/commands/cip/report/sales-summary.js +22 -0
- package/dist/commands/cip/report/sales-summary.js.map +1 -0
- package/dist/commands/cip/report/search-query-performance.d.ts +38 -0
- package/dist/commands/cip/report/search-query-performance.js +35 -0
- package/dist/commands/cip/report/search-query-performance.js.map +1 -0
- package/dist/commands/cip/report/top-referrers.d.ts +38 -0
- package/dist/commands/cip/report/top-referrers.js +23 -0
- package/dist/commands/cip/report/top-referrers.js.map +1 -0
- package/dist/commands/cip/report/top-selling-products.d.ts +37 -0
- package/dist/commands/cip/report/top-selling-products.js +22 -0
- package/dist/commands/cip/report/top-selling-products.js.map +1 -0
- package/dist/commands/cip/report.d.ts +9 -0
- package/dist/commands/cip/report.js +22 -0
- package/dist/commands/cip/report.js.map +1 -0
- package/dist/commands/cip/tables.d.ts +45 -0
- package/dist/commands/cip/tables.js +70 -0
- package/dist/commands/cip/tables.js.map +1 -0
- package/dist/commands/code/activate.d.ts +1 -0
- package/dist/commands/code/delete.d.ts +1 -0
- package/dist/commands/code/deploy.d.ts +1 -0
- package/dist/commands/code/watch.d.ts +1 -0
- package/dist/commands/content/export.d.ts +1 -0
- package/dist/commands/content/list.d.ts +1 -0
- package/dist/commands/docs/download.d.ts +1 -0
- package/dist/commands/docs/read.d.ts +1 -0
- package/dist/commands/docs/schema.d.ts +1 -0
- package/dist/commands/docs/search.d.ts +1 -0
- package/dist/commands/ecdn/cache/purge.d.ts +1 -0
- package/dist/commands/ecdn/certificates/add.d.ts +1 -0
- package/dist/commands/ecdn/certificates/delete.d.ts +1 -0
- package/dist/commands/ecdn/certificates/list.d.ts +1 -0
- package/dist/commands/ecdn/certificates/update.d.ts +1 -0
- package/dist/commands/ecdn/certificates/validate.d.ts +1 -0
- package/dist/commands/ecdn/cipher-suites/get.d.ts +1 -0
- package/dist/commands/ecdn/cipher-suites/update.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/create.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/delete.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/get.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/list.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/update.d.ts +1 -0
- package/dist/commands/ecdn/logpush/ownership.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/create.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/delete.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/get.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/rules/delete.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/rules/update.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/update.d.ts +1 -0
- package/dist/commands/ecdn/mtls/create.d.ts +1 -0
- package/dist/commands/ecdn/mtls/delete.d.ts +1 -0
- package/dist/commands/ecdn/mtls/get.d.ts +1 -0
- package/dist/commands/ecdn/mtls/list.d.ts +1 -0
- package/dist/commands/ecdn/origin-headers/delete.d.ts +1 -0
- package/dist/commands/ecdn/origin-headers/get.d.ts +1 -0
- package/dist/commands/ecdn/origin-headers/set.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/notifications/create.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/notifications/delete.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/notifications/list.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/create.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/delete.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/get.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/list.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/update.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/scripts/get.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/scripts/list.d.ts +1 -0
- package/dist/commands/ecdn/security/get.d.ts +1 -0
- package/dist/commands/ecdn/security/update.d.ts +1 -0
- package/dist/commands/ecdn/speed/get.d.ts +1 -0
- package/dist/commands/ecdn/speed/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/groups/list.d.ts +1 -0
- package/dist/commands/ecdn/waf/groups/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/managed-rules/list.d.ts +1 -0
- package/dist/commands/ecdn/waf/managed-rules/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/migrate.d.ts +1 -0
- package/dist/commands/ecdn/waf/owasp/get.d.ts +1 -0
- package/dist/commands/ecdn/waf/owasp/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/rules/get.d.ts +1 -0
- package/dist/commands/ecdn/waf/rules/list.d.ts +1 -0
- package/dist/commands/ecdn/waf/rules/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/rulesets/list.d.ts +1 -0
- package/dist/commands/ecdn/waf/rulesets/update.d.ts +1 -0
- package/dist/commands/ecdn/zones/create.d.ts +1 -0
- package/dist/commands/ecdn/zones/list.d.ts +1 -0
- package/dist/commands/job/export.d.ts +4 -1
- package/dist/commands/job/export.js +22 -19
- package/dist/commands/job/export.js.map +1 -1
- package/dist/commands/job/import.d.ts +1 -0
- package/dist/commands/job/run.d.ts +1 -0
- package/dist/commands/job/search.d.ts +1 -0
- package/dist/commands/job/wait.d.ts +1 -0
- package/dist/commands/logs/get.d.ts +1 -0
- package/dist/commands/logs/list.d.ts +1 -0
- package/dist/commands/logs/tail.d.ts +1 -0
- package/dist/commands/mrt/bundle/deploy.d.ts +1 -0
- package/dist/commands/mrt/bundle/download.d.ts +1 -0
- package/dist/commands/mrt/bundle/history.d.ts +1 -0
- package/dist/commands/mrt/bundle/list.d.ts +1 -0
- package/dist/commands/mrt/env/access-control/list.d.ts +1 -0
- package/dist/commands/mrt/env/b2c.d.ts +1 -0
- package/dist/commands/mrt/env/create.d.ts +1 -0
- package/dist/commands/mrt/env/delete.d.ts +1 -0
- package/dist/commands/mrt/env/get.d.ts +1 -0
- package/dist/commands/mrt/env/invalidate.d.ts +1 -0
- package/dist/commands/mrt/env/list.d.ts +1 -0
- package/dist/commands/mrt/env/redirect/clone.d.ts +1 -0
- package/dist/commands/mrt/env/redirect/create.d.ts +1 -0
- package/dist/commands/mrt/env/redirect/delete.d.ts +1 -0
- package/dist/commands/mrt/env/redirect/list.d.ts +1 -0
- package/dist/commands/mrt/env/update.d.ts +1 -0
- package/dist/commands/mrt/env/var/delete.d.ts +1 -0
- package/dist/commands/mrt/env/var/list.d.ts +1 -0
- package/dist/commands/mrt/env/var/set.d.ts +1 -0
- package/dist/commands/mrt/org/b2c.d.ts +1 -0
- package/dist/commands/mrt/org/list.d.ts +1 -0
- package/dist/commands/mrt/project/create.d.ts +1 -0
- package/dist/commands/mrt/project/delete.d.ts +1 -0
- package/dist/commands/mrt/project/get.d.ts +1 -0
- package/dist/commands/mrt/project/list.d.ts +1 -0
- package/dist/commands/mrt/project/member/add.d.ts +1 -0
- package/dist/commands/mrt/project/member/get.d.ts +1 -0
- package/dist/commands/mrt/project/member/list.d.ts +1 -0
- package/dist/commands/mrt/project/member/remove.d.ts +1 -0
- package/dist/commands/mrt/project/member/update.d.ts +1 -0
- package/dist/commands/mrt/project/notification/create.d.ts +1 -0
- package/dist/commands/mrt/project/notification/delete.d.ts +1 -0
- package/dist/commands/mrt/project/notification/get.d.ts +1 -0
- package/dist/commands/mrt/project/notification/list.d.ts +1 -0
- package/dist/commands/mrt/project/notification/update.d.ts +1 -0
- package/dist/commands/mrt/project/update.d.ts +1 -0
- package/dist/commands/mrt/tail-logs.d.ts +1 -0
- package/dist/commands/mrt/user/api-key.d.ts +1 -0
- package/dist/commands/mrt/user/email-prefs.d.ts +1 -0
- package/dist/commands/mrt/user/profile.d.ts +1 -0
- package/dist/commands/sandbox/alias/create.d.ts +23 -0
- package/dist/commands/sandbox/alias/create.js +98 -0
- package/dist/commands/sandbox/alias/create.js.map +1 -0
- package/dist/commands/sandbox/alias/delete.d.ts +21 -0
- package/dist/commands/sandbox/alias/delete.js +75 -0
- package/dist/commands/sandbox/alias/delete.js.map +1 -0
- package/dist/commands/sandbox/alias/list.d.ts +22 -0
- package/dist/commands/sandbox/alias/list.js +132 -0
- package/dist/commands/sandbox/alias/list.js.map +1 -0
- package/dist/commands/sandbox/ips.d.ts +19 -0
- package/dist/commands/sandbox/ips.js +74 -0
- package/dist/commands/sandbox/ips.js.map +1 -0
- package/dist/commands/sandbox/list.d.ts +2 -1
- package/dist/commands/sandbox/list.js +14 -2
- package/dist/commands/sandbox/list.js.map +1 -1
- package/dist/commands/sandbox/realm/get.d.ts +24 -0
- package/dist/commands/sandbox/realm/get.js +126 -0
- package/dist/commands/sandbox/realm/get.js.map +1 -0
- package/dist/commands/sandbox/realm/list.d.ts +24 -0
- package/dist/commands/sandbox/realm/list.js +85 -0
- package/dist/commands/sandbox/realm/list.js.map +1 -0
- package/dist/commands/sandbox/realm/update.d.ts +23 -0
- package/dist/commands/sandbox/realm/update.js +114 -0
- package/dist/commands/sandbox/realm/update.js.map +1 -0
- package/dist/commands/sandbox/realm/usage.d.ts +24 -0
- package/dist/commands/sandbox/realm/usage.js +122 -0
- package/dist/commands/sandbox/realm/usage.js.map +1 -0
- package/dist/commands/sandbox/reset.d.ts +23 -0
- package/dist/commands/sandbox/reset.js +106 -0
- package/dist/commands/sandbox/reset.js.map +1 -0
- package/dist/commands/sandbox/usage.d.ts +22 -0
- package/dist/commands/sandbox/usage.js +109 -0
- package/dist/commands/sandbox/usage.js.map +1 -0
- package/dist/commands/scapi/custom/status.d.ts +1 -0
- package/dist/commands/scapi/custom/status.js +1 -16
- package/dist/commands/scapi/custom/status.js.map +1 -1
- package/dist/commands/scapi/schemas/get.d.ts +1 -0
- package/dist/commands/scapi/schemas/list.d.ts +1 -0
- package/dist/commands/setup/ide/index.d.ts +9 -0
- package/dist/commands/setup/ide/index.js +18 -0
- package/dist/commands/setup/ide/index.js.map +1 -0
- package/dist/commands/setup/ide/prophet.d.ts +38 -0
- package/dist/commands/setup/ide/prophet.js +316 -0
- package/dist/commands/setup/ide/prophet.js.map +1 -0
- package/dist/commands/setup/index.js +6 -2
- package/dist/commands/setup/index.js.map +1 -1
- package/dist/commands/setup/inspect.d.ts +1 -0
- package/dist/commands/setup/instance/create.d.ts +1 -0
- package/dist/commands/setup/instance/list.d.ts +1 -0
- package/dist/commands/setup/instance/remove.d.ts +1 -0
- package/dist/commands/setup/instance/set-active.d.ts +1 -0
- package/dist/commands/setup/skills.d.ts +1 -0
- package/dist/commands/slas/client/create.d.ts +1 -0
- package/dist/commands/slas/client/delete.d.ts +1 -0
- package/dist/commands/slas/client/get.d.ts +1 -0
- package/dist/commands/slas/client/list.d.ts +1 -0
- package/dist/commands/slas/client/open.d.ts +1 -0
- package/dist/commands/slas/client/update.d.ts +1 -0
- package/dist/commands/webdav/get.d.ts +1 -0
- package/dist/commands/webdav/rm.d.ts +1 -0
- package/dist/utils/cip/command.d.ts +40 -0
- package/dist/utils/cip/command.js +110 -0
- package/dist/utils/cip/command.js.map +1 -0
- package/dist/utils/cip/format.d.ts +3 -0
- package/dist/utils/cip/format.js +54 -0
- package/dist/utils/cip/format.js.map +1 -0
- package/dist/utils/cip/report-command.d.ts +34 -0
- package/dist/utils/cip/report-command.js +131 -0
- package/dist/utils/cip/report-command.js.map +1 -0
- package/dist/utils/cip/report-flags.d.ts +10 -0
- package/dist/utils/cip/report-flags.js +23 -0
- package/dist/utils/cip/report-flags.js.map +1 -0
- package/dist/utils/ecdn/zone-command.d.ts +1 -0
- package/oclif.manifest.json +15118 -6011
- package/package.json +13 -5
|
@@ -0,0 +1,316 @@
|
|
|
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 * as fs from 'node:fs/promises';
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { Flags, ux } from '@oclif/core';
|
|
10
|
+
import { BaseCommand } from '@salesforce/b2c-tooling-sdk/cli';
|
|
11
|
+
import { withDocs } from '../../../i18n/index.js';
|
|
12
|
+
/**
|
|
13
|
+
* Build the dw.js script for Prophet integration.
|
|
14
|
+
*/
|
|
15
|
+
function buildDwJsScript(inspectArgs) {
|
|
16
|
+
return `/**
|
|
17
|
+
* Auto-generated by "b2c setup ide prophet".
|
|
18
|
+
* Purpose: Provide Prophet VS Code extension with dw.json-compatible configuration
|
|
19
|
+
* by exporting the resolved B2C CLI config as module.exports.
|
|
20
|
+
* support dwJson multi-config in prophet and other tools that support dw.js loading
|
|
21
|
+
* when this is present prophet will ignore dw.json and instead load the configuration exported
|
|
22
|
+
* This script shells out to: b2c setup inspect --json --unmask
|
|
23
|
+
*/
|
|
24
|
+
var childProcess = require('node:child_process');
|
|
25
|
+
var path = require('node:path');
|
|
26
|
+
var INSPECT_ARGS = ${JSON.stringify(inspectArgs)};
|
|
27
|
+
var dwJson = {};
|
|
28
|
+
|
|
29
|
+
function logProphetDw(message, error) {
|
|
30
|
+
var suffix = error && error.message ? ': ' + String(error.message) : '';
|
|
31
|
+
var line = '[b2c setup ide prophet] ' + message + suffix;
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
console.error(line);
|
|
35
|
+
} catch (logError) {}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
console.log(line);
|
|
39
|
+
} catch (logError) {}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function loadDotEnv() {
|
|
43
|
+
try {
|
|
44
|
+
require('dotenv').config({override: true});
|
|
45
|
+
} catch (error) {
|
|
46
|
+
// optional dependency
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function getWorkspaceRoot() {
|
|
51
|
+
if (process.env.SFCC_WORKING_DIRECTORY && process.env.SFCC_WORKING_DIRECTORY.trim()) {
|
|
52
|
+
return process.env.SFCC_WORKING_DIRECTORY.trim();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (process.env.SFCC_CONFIG && process.env.SFCC_CONFIG.trim()) {
|
|
56
|
+
return path.dirname(process.env.SFCC_CONFIG.trim());
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (typeof __dirname === 'string' && __dirname) {
|
|
60
|
+
return __dirname;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (typeof module !== 'undefined' && module && module.filename) {
|
|
64
|
+
return path.dirname(module.filename);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (typeof workspace !== 'undefined' && workspace && Array.isArray(workspace.workspaceFolders)) {
|
|
68
|
+
for (var i = 0; i < workspace.workspaceFolders.length; i += 1) {
|
|
69
|
+
var folder = workspace.workspaceFolders[i];
|
|
70
|
+
if (folder && folder.uri && typeof folder.uri.fsPath === 'string' && folder.uri.fsPath) {
|
|
71
|
+
return folder.uri.fsPath;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return process.cwd();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function withWorkingDirectory(args, workingDirectory) {
|
|
80
|
+
if (!workingDirectory || args.indexOf('--working-directory') !== -1) {
|
|
81
|
+
return args.slice();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return args.concat(['--working-directory', workingDirectory]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function pickInspectConfig(parsed) {
|
|
88
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
89
|
+
return {};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
var root = parsed.result && typeof parsed.result === 'object' ? parsed.result : parsed;
|
|
93
|
+
|
|
94
|
+
if (root.config && typeof root.config === 'object') {
|
|
95
|
+
return root.config;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (root.result && root.result.config && typeof root.result.config === 'object') {
|
|
99
|
+
return root.result.config;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return root;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function runSetupInspect(workingDirectory) {
|
|
106
|
+
var inspectArgs = withWorkingDirectory(INSPECT_ARGS, workingDirectory);
|
|
107
|
+
var candidates = [];
|
|
108
|
+
|
|
109
|
+
if (process.env.B2C_CLI_BIN && process.env.B2C_CLI_BIN.trim()) {
|
|
110
|
+
candidates.push({cmd: process.env.B2C_CLI_BIN.trim(), args: inspectArgs});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
candidates.push({cmd: 'b2c', args: inspectArgs});
|
|
114
|
+
candidates.push({cmd: 'npx', args: ['--yes', '@salesforce/b2c-cli'].concat(inspectArgs)});
|
|
115
|
+
|
|
116
|
+
var lastError;
|
|
117
|
+
|
|
118
|
+
for (var i = 0; i < candidates.length; i += 1) {
|
|
119
|
+
var candidate = candidates[i];
|
|
120
|
+
try {
|
|
121
|
+
var execOptions = {
|
|
122
|
+
encoding: 'utf8',
|
|
123
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
124
|
+
};
|
|
125
|
+
if (workingDirectory) {
|
|
126
|
+
execOptions.cwd = workingDirectory;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
var stdout = childProcess.execFileSync(candidate.cmd, candidate.args, execOptions);
|
|
130
|
+
return pickInspectConfig(JSON.parse(stdout));
|
|
131
|
+
} catch (error) {
|
|
132
|
+
logProphetDw('setup inspect candidate failed (' + candidate.cmd + ')', error);
|
|
133
|
+
lastError = error;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
throw lastError || new Error('No setup inspect candidate succeeded');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function resolveDwJsonConfig(raw) {
|
|
141
|
+
if (!raw || typeof raw !== 'object') {
|
|
142
|
+
return {};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
var instanceName = process.env.SFCC_INSTANCE;
|
|
146
|
+
|
|
147
|
+
if (!instanceName || raw.name !== instanceName) {
|
|
148
|
+
if (instanceName && Array.isArray(raw.configs)) {
|
|
149
|
+
return raw.configs.find(function (item) {
|
|
150
|
+
return item && item.name === instanceName;
|
|
151
|
+
}) || raw;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (Array.isArray(raw.configs) && raw.active !== true) {
|
|
155
|
+
return raw.configs.find(function (item) {
|
|
156
|
+
return item && item.active === true;
|
|
157
|
+
}) || raw;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return raw;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function loadDwJsonFallback(workingDirectory) {
|
|
165
|
+
try {
|
|
166
|
+
var dwJsonPath = process.env.SFCC_CONFIG ? process.env.SFCC_CONFIG : path.join(workingDirectory, 'dw.json');
|
|
167
|
+
if (!path.isAbsolute(dwJsonPath)) {
|
|
168
|
+
dwJsonPath = path.resolve(workingDirectory || process.cwd(), dwJsonPath);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return resolveDwJsonConfig(require(dwJsonPath));
|
|
172
|
+
} catch (error) {
|
|
173
|
+
logProphetDw('dw.json fallback failed', error);
|
|
174
|
+
return {};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function toProphetConfig(config) {
|
|
179
|
+
if (!config || typeof config !== 'object') {
|
|
180
|
+
return {};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
var result = {};
|
|
184
|
+
var codeVersion = config['code-version'] || config.codeVersion || config.version;
|
|
185
|
+
|
|
186
|
+
if (config.hostname || config.server) {
|
|
187
|
+
result.hostname = config.hostname || config.server;
|
|
188
|
+
}
|
|
189
|
+
if (config.username) {
|
|
190
|
+
result.username = config.username;
|
|
191
|
+
}
|
|
192
|
+
if (config.password) {
|
|
193
|
+
result.password = config.password;
|
|
194
|
+
}
|
|
195
|
+
if (codeVersion) {
|
|
196
|
+
result['code-version'] = codeVersion;
|
|
197
|
+
result.version = codeVersion;
|
|
198
|
+
}
|
|
199
|
+
if (config.cartridgesPath !== undefined) {
|
|
200
|
+
result.cartridgesPath = config.cartridgesPath;
|
|
201
|
+
}
|
|
202
|
+
if (config.siteID !== undefined || config.siteId !== undefined) {
|
|
203
|
+
result.siteID = config.siteID || config.siteId;
|
|
204
|
+
}
|
|
205
|
+
if (config.storefrontPassword !== undefined) {
|
|
206
|
+
result.storefrontPassword = config.storefrontPassword;
|
|
207
|
+
}
|
|
208
|
+
if (config.cartridge !== undefined) {
|
|
209
|
+
result.cartridge = config.cartridge;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function loadDwConfig() {
|
|
216
|
+
loadDotEnv();
|
|
217
|
+
var workingDirectory = getWorkspaceRoot();
|
|
218
|
+
|
|
219
|
+
try {
|
|
220
|
+
var inspectConfig = runSetupInspect(workingDirectory);
|
|
221
|
+
var inspectMapped = toProphetConfig(inspectConfig);
|
|
222
|
+
if (inspectMapped.hostname) {
|
|
223
|
+
return inspectMapped;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
logProphetDw('setup inspect returned no hostname; falling back to dw.json');
|
|
227
|
+
} catch (error) {
|
|
228
|
+
logProphetDw('setup inspect failed; falling back to dw.json', error);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
try {
|
|
232
|
+
var fallbackMapped = toProphetConfig(loadDwJsonFallback(workingDirectory));
|
|
233
|
+
if (!fallbackMapped.hostname) {
|
|
234
|
+
logProphetDw('dw.json fallback returned no hostname');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return fallbackMapped;
|
|
238
|
+
} catch (error) {
|
|
239
|
+
logProphetDw('dw.json mapping failed; returning empty config', error);
|
|
240
|
+
return {};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
try {
|
|
245
|
+
dwJson = loadDwConfig();
|
|
246
|
+
} catch (error) {
|
|
247
|
+
logProphetDw('unexpected dw.js error; returning empty config', error);
|
|
248
|
+
dwJson = {};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
module.exports = dwJson;
|
|
252
|
+
`;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Create dw.js integration script for Prophet VS Code extension.
|
|
256
|
+
*/
|
|
257
|
+
export default class SetupIdeProphet extends BaseCommand {
|
|
258
|
+
static description = withDocs('Generate a dw.js script that exposes B2C CLI config for Prophet VS Code', '/cli/setup.html#b2c-setup-ide-prophet');
|
|
259
|
+
static enableJsonFlag = true;
|
|
260
|
+
static examples = [
|
|
261
|
+
'<%= config.bin %> <%= command.id %>',
|
|
262
|
+
'<%= config.bin %> <%= command.id %> --force',
|
|
263
|
+
'<%= config.bin %> <%= command.id %> --output .vscode/dw.js',
|
|
264
|
+
'<%= config.bin %> <%= command.id %> --instance staging',
|
|
265
|
+
];
|
|
266
|
+
static flags = {
|
|
267
|
+
...BaseCommand.baseFlags,
|
|
268
|
+
output: Flags.string({
|
|
269
|
+
char: 'o',
|
|
270
|
+
description: 'Path for generated script file',
|
|
271
|
+
default: 'dw.js',
|
|
272
|
+
}),
|
|
273
|
+
force: Flags.boolean({
|
|
274
|
+
char: 'f',
|
|
275
|
+
description: 'Overwrite output file if it already exists',
|
|
276
|
+
default: false,
|
|
277
|
+
}),
|
|
278
|
+
};
|
|
279
|
+
async run() {
|
|
280
|
+
const outputPath = path.resolve(this.flags.output);
|
|
281
|
+
const alreadyExists = existsSync(outputPath);
|
|
282
|
+
if (alreadyExists && !this.flags.force) {
|
|
283
|
+
this.error(`File already exists at ${outputPath}. Use --force to overwrite.`);
|
|
284
|
+
}
|
|
285
|
+
const inspectArgs = this.buildInspectArgs();
|
|
286
|
+
const script = buildDwJsScript(inspectArgs);
|
|
287
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
288
|
+
await fs.writeFile(outputPath, script, 'utf8');
|
|
289
|
+
const result = {
|
|
290
|
+
path: outputPath,
|
|
291
|
+
overwritten: alreadyExists,
|
|
292
|
+
};
|
|
293
|
+
if (!this.jsonEnabled()) {
|
|
294
|
+
ux.stdout(`Created ${outputPath}`);
|
|
295
|
+
}
|
|
296
|
+
return result;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Build setup inspect arguments for the generated script.
|
|
300
|
+
* Includes setup context flags so runtime resolution matches command intent.
|
|
301
|
+
*/
|
|
302
|
+
buildInspectArgs() {
|
|
303
|
+
const args = ['setup', 'inspect', '--json', '--unmask'];
|
|
304
|
+
if (this.flags.instance) {
|
|
305
|
+
args.push('--instance', this.flags.instance);
|
|
306
|
+
}
|
|
307
|
+
if (this.flags.config) {
|
|
308
|
+
args.push('--config', this.flags.config);
|
|
309
|
+
}
|
|
310
|
+
if (this.flags['working-directory']) {
|
|
311
|
+
args.push('--working-directory', this.flags['working-directory']);
|
|
312
|
+
}
|
|
313
|
+
return args;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=prophet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prophet.js","sourceRoot":"","sources":["../../../../src/commands/setup/ide/prophet.ts"],"names":[],"mappings":"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"}
|
|
@@ -13,8 +13,12 @@ import { withDocs } from '../../i18n/index.js';
|
|
|
13
13
|
* - `b2c setup` with instance configured or non-TTY: shows topic help
|
|
14
14
|
*/
|
|
15
15
|
export default class SetupIndex extends BaseCommand {
|
|
16
|
-
static description = withDocs('Manage instances,
|
|
17
|
-
static examples = [
|
|
16
|
+
static description = withDocs('Manage instances, inspect configuration, install skills, and configure IDE integrations', '/cli/setup.html');
|
|
17
|
+
static examples = [
|
|
18
|
+
'<%= config.bin %> setup --help',
|
|
19
|
+
'<%= config.bin %> setup instance create',
|
|
20
|
+
'<%= config.bin %> setup ide prophet',
|
|
21
|
+
];
|
|
18
22
|
async run() {
|
|
19
23
|
const hasInstance = this.resolvedConfig.hasB2CInstanceConfig();
|
|
20
24
|
const isTTY = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/setup/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAA8B;IACpE,MAAM,CAAC,WAAW,GAAG,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/setup/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAA8B;IACpE,MAAM,CAAC,WAAW,GAAG,QAAQ,CAC3B,yFAAyF,EACzF,iBAAiB,CAClB,CAAC;IAEF,MAAM,CAAC,QAAQ,GAAG;QAChB,gCAAgC;QAChC,yCAAyC;QACzC,qCAAqC;KACtC,CAAC;IAEF,KAAK,CAAC,GAAG;QACP,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;QAC/D,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAEnE,IAAI,CAAC,WAAW,IAAI,KAAK,EAAE,CAAC;YAC1B,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC;gBACjC,OAAO,EAAE,uDAAuD;gBAChE,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;YAEH,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;gBACtD,OAAO;YACT,CAAC;QACH,CAAC;QAED,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAClD,CAAC"}
|
|
@@ -21,6 +21,7 @@ export default class SetupInspect extends BaseCommand<typeof SetupInspect> {
|
|
|
21
21
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
22
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
23
23
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
24
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
24
25
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
26
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
27
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -30,6 +30,7 @@ export default class SetupInstanceCreate extends BaseCommand<typeof SetupInstanc
|
|
|
30
30
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
31
31
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
32
32
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
33
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
33
34
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
34
35
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
35
36
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -18,6 +18,7 @@ export default class SetupInstanceList extends BaseCommand<typeof SetupInstanceL
|
|
|
18
18
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
19
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
20
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
21
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
21
22
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
23
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
24
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -21,6 +21,7 @@ export default class SetupInstanceRemove extends BaseCommand<typeof SetupInstanc
|
|
|
21
21
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
22
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
23
23
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
24
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
24
25
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
26
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
27
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -20,6 +20,7 @@ export default class SetupInstanceSetActive extends BaseCommand<typeof SetupInst
|
|
|
20
20
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
21
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
22
22
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
23
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
23
24
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
25
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
26
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -27,6 +27,7 @@ export default class SetupSkills extends BaseCommand<typeof SetupSkills> {
|
|
|
27
27
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
28
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
29
29
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
30
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
30
31
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
31
32
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
32
33
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -27,6 +27,7 @@ export default class SlasClientCreate extends SlasClientCommand<typeof SlasClien
|
|
|
27
27
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
28
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
29
29
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
30
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
30
31
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
31
32
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
32
33
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -22,6 +22,7 @@ export default class SlasClientDelete extends SlasClientCommand<typeof SlasClien
|
|
|
22
22
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
23
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
24
24
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
25
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
25
26
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
27
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
28
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -18,6 +18,7 @@ export default class SlasClientGet extends SlasClientCommand<typeof SlasClientGe
|
|
|
18
18
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
19
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
20
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
21
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
21
22
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
23
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
24
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -18,6 +18,7 @@ export default class SlasClientList extends SlasClientCommand<typeof SlasClientL
|
|
|
18
18
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
19
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
20
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
21
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
21
22
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
23
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
24
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -11,6 +11,7 @@ export default class SlasClientOpen extends BaseCommand<typeof SlasClientOpen> {
|
|
|
11
11
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
13
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
15
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
16
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
17
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -25,6 +25,7 @@ export default class SlasClientUpdate extends SlasClientCommand<typeof SlasClien
|
|
|
25
25
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
26
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
27
27
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
28
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
28
29
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
29
30
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
30
31
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -34,6 +34,7 @@ export default class WebDavGet extends WebDavCommand<typeof WebDavGet> {
|
|
|
34
34
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
35
35
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
36
36
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
37
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
37
38
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
38
39
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
39
40
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -33,6 +33,7 @@ export default class WebDavRm extends WebDavCommand<typeof WebDavRm> {
|
|
|
33
33
|
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
34
34
|
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
35
35
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
36
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
36
37
|
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
37
38
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
38
39
|
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import type { AuthMethod } from '@salesforce/b2c-tooling-sdk/auth';
|
|
3
|
+
import { type CipClient } from '@salesforce/b2c-tooling-sdk/clients';
|
|
4
|
+
import { OAuthCommand } from '@salesforce/b2c-tooling-sdk/cli';
|
|
5
|
+
import type { ResolvedB2CConfig } from '@salesforce/b2c-tooling-sdk/config';
|
|
6
|
+
export declare abstract class CipCommand<T extends typeof Command> extends OAuthCommand<T> {
|
|
7
|
+
static baseFlags: {
|
|
8
|
+
'cip-host': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
staging: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
from: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
to: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'fetch-size': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'client-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'client-secret': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'auth-scope': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'short-code': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'tenant-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'auth-methods': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
'user-auth': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
21
|
+
'account-manager-host': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
24
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
25
|
+
jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
26
|
+
lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
+
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
|
+
instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
29
|
+
'working-directory': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
30
|
+
'extra-query': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
31
|
+
'extra-body': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
32
|
+
'extra-headers': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
33
|
+
};
|
|
34
|
+
protected getCipClient(): CipClient;
|
|
35
|
+
protected getDefaultAuthMethods(): AuthMethod[];
|
|
36
|
+
protected loadConfiguration(): ResolvedB2CConfig;
|
|
37
|
+
protected requireCipCredentials(): void;
|
|
38
|
+
protected resolveCipHost(cipInstance: string): string;
|
|
39
|
+
protected validateCipAuthMethods(): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
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 { Command, Flags } from '@oclif/core';
|
|
7
|
+
import { createCipClient, DEFAULT_CIP_HOST, DEFAULT_CIP_STAGING_HOST, } from '@salesforce/b2c-tooling-sdk/clients';
|
|
8
|
+
import { extractOAuthFlags, loadConfig, OAuthCommand } from '@salesforce/b2c-tooling-sdk/cli';
|
|
9
|
+
import { t } from '../../i18n/index.js';
|
|
10
|
+
const CIP_AUTH_METHODS = ['client-credentials'];
|
|
11
|
+
function toIsoDate(value) {
|
|
12
|
+
const year = value.getFullYear();
|
|
13
|
+
const month = String(value.getMonth() + 1).padStart(2, '0');
|
|
14
|
+
const day = String(value.getDate()).padStart(2, '0');
|
|
15
|
+
return `${year}-${month}-${day}`;
|
|
16
|
+
}
|
|
17
|
+
function getDefaultFromDate() {
|
|
18
|
+
const now = new Date();
|
|
19
|
+
return toIsoDate(new Date(now.getFullYear(), now.getMonth(), 1));
|
|
20
|
+
}
|
|
21
|
+
function getDefaultToDate() {
|
|
22
|
+
return toIsoDate(new Date());
|
|
23
|
+
}
|
|
24
|
+
function isLikelyProductionTenantId(tenantId) {
|
|
25
|
+
return tenantId.toLowerCase().endsWith('_prd');
|
|
26
|
+
}
|
|
27
|
+
export class CipCommand extends OAuthCommand {
|
|
28
|
+
static baseFlags = {
|
|
29
|
+
...OAuthCommand.baseFlags,
|
|
30
|
+
'cip-host': Flags.string({
|
|
31
|
+
description: `CIP host override (default: ${DEFAULT_CIP_HOST})`,
|
|
32
|
+
env: 'SFCC_CIP_HOST',
|
|
33
|
+
helpGroup: 'QUERY',
|
|
34
|
+
}),
|
|
35
|
+
staging: Flags.boolean({
|
|
36
|
+
description: `Use staging analytics host (${DEFAULT_CIP_STAGING_HOST})`,
|
|
37
|
+
env: 'SFCC_CIP_STAGING',
|
|
38
|
+
default: false,
|
|
39
|
+
helpGroup: 'QUERY',
|
|
40
|
+
}),
|
|
41
|
+
from: Flags.string({
|
|
42
|
+
description: 'Inclusive start date (YYYY-MM-DD)',
|
|
43
|
+
default: getDefaultFromDate(),
|
|
44
|
+
helpGroup: 'QUERY',
|
|
45
|
+
}),
|
|
46
|
+
to: Flags.string({
|
|
47
|
+
description: 'Inclusive end date (YYYY-MM-DD)',
|
|
48
|
+
default: getDefaultToDate(),
|
|
49
|
+
helpGroup: 'QUERY',
|
|
50
|
+
}),
|
|
51
|
+
format: Flags.string({
|
|
52
|
+
description: 'Output format',
|
|
53
|
+
options: ['table', 'json', 'csv'],
|
|
54
|
+
default: 'table',
|
|
55
|
+
helpGroup: 'QUERY',
|
|
56
|
+
}),
|
|
57
|
+
'fetch-size': Flags.integer({
|
|
58
|
+
description: 'Frame fetch size for CIP paging',
|
|
59
|
+
default: 1000,
|
|
60
|
+
min: 1,
|
|
61
|
+
helpGroup: 'QUERY',
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
64
|
+
getCipClient() {
|
|
65
|
+
this.validateCipAuthMethods();
|
|
66
|
+
const cipInstance = this.requireTenantId();
|
|
67
|
+
const cipHost = this.resolveCipHost(cipInstance);
|
|
68
|
+
return createCipClient({
|
|
69
|
+
instance: cipInstance,
|
|
70
|
+
host: cipHost,
|
|
71
|
+
}, this.getOAuthStrategy());
|
|
72
|
+
}
|
|
73
|
+
getDefaultAuthMethods() {
|
|
74
|
+
return CIP_AUTH_METHODS;
|
|
75
|
+
}
|
|
76
|
+
loadConfiguration() {
|
|
77
|
+
const flags = this.flags;
|
|
78
|
+
return loadConfig({
|
|
79
|
+
...extractOAuthFlags(flags),
|
|
80
|
+
cipHost: flags['cip-host'],
|
|
81
|
+
}, this.getBaseConfigOptions(), this.getPluginSources());
|
|
82
|
+
}
|
|
83
|
+
requireCipCredentials() {
|
|
84
|
+
this.validateCipAuthMethods();
|
|
85
|
+
if (!this.hasFullOAuthCredentials()) {
|
|
86
|
+
this.error(t('error.oauthClientSecretRequired', 'CIP requires OAuth client credentials. Provide --client-id and --client-secret, or set SFCC_CLIENT_ID and SFCC_CLIENT_SECRET.'));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
resolveCipHost(cipInstance) {
|
|
90
|
+
const configuredHost = this.flags['cip-host'] ?? this.resolvedConfig.values.cipHost;
|
|
91
|
+
if (configuredHost) {
|
|
92
|
+
return configuredHost;
|
|
93
|
+
}
|
|
94
|
+
if (this.flags.staging || !isLikelyProductionTenantId(cipInstance)) {
|
|
95
|
+
return DEFAULT_CIP_STAGING_HOST;
|
|
96
|
+
}
|
|
97
|
+
return DEFAULT_CIP_HOST;
|
|
98
|
+
}
|
|
99
|
+
validateCipAuthMethods() {
|
|
100
|
+
const methods = this.resolvedConfig.values.authMethods;
|
|
101
|
+
if (!methods || methods.length === 0) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const invalidMethods = methods.filter((method) => method !== 'client-credentials');
|
|
105
|
+
if (invalidMethods.length > 0) {
|
|
106
|
+
this.error(t('error.cipAuthMethodNotSupported', 'CIP only supports client-credentials auth. Remove --user-auth/--auth-methods overrides and provide --client-id and --client-secret.'));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=command.js.map
|