@bigcommerce/create-catalyst 0.20.0 → 0.22.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/bin/index.cjs +13 -3
- package/dist/index.js +443 -114
- package/dist/index.js.map +1 -1
- package/package.json +29 -23
package/dist/index.js
CHANGED
|
@@ -53,12 +53,12 @@ var __async = (__this, __arguments, generator) => {
|
|
|
53
53
|
|
|
54
54
|
// src/index.ts
|
|
55
55
|
import { program } from "@commander-js/extra-typings";
|
|
56
|
-
import
|
|
56
|
+
import chalk7 from "chalk";
|
|
57
57
|
|
|
58
58
|
// package.json
|
|
59
59
|
var package_default = {
|
|
60
60
|
name: "@bigcommerce/create-catalyst",
|
|
61
|
-
version: "0.
|
|
61
|
+
version: "0.21.0",
|
|
62
62
|
type: "module",
|
|
63
63
|
bin: "bin/index.cjs",
|
|
64
64
|
files: [
|
|
@@ -73,57 +73,279 @@ var package_default = {
|
|
|
73
73
|
build: "tsup"
|
|
74
74
|
},
|
|
75
75
|
engines: {
|
|
76
|
-
node: "
|
|
76
|
+
node: "^20.0.0 || ^22.0.0"
|
|
77
77
|
},
|
|
78
78
|
dependencies: {
|
|
79
|
-
"@commander-js/extra-typings": "^
|
|
79
|
+
"@commander-js/extra-typings": "^13.1.0",
|
|
80
80
|
"@iarna/toml": "^2.2.5",
|
|
81
|
-
"@inquirer/
|
|
82
|
-
"@
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
"@inquirer/core": "^10.1.10",
|
|
82
|
+
"@inquirer/figures": "^1.0.11",
|
|
83
|
+
"@inquirer/prompts": "^7.4.1",
|
|
84
|
+
"@inquirer/type": "^3.0.6",
|
|
85
|
+
"@segment/analytics-node": "^2.2.1",
|
|
86
|
+
"ansi-escapes": "^7.0.0",
|
|
87
|
+
chalk: "^5.4.1",
|
|
88
|
+
commander: "^13.1.0",
|
|
85
89
|
conf: "^13.1.0",
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
"cross-spawn": "^7.0.6",
|
|
91
|
+
dotenv: "^16.5.0",
|
|
92
|
+
"fs-extra": "^11.3.0",
|
|
93
|
+
giget: "^1.2.5",
|
|
89
94
|
"lodash.kebabcase": "^4.1.1",
|
|
90
|
-
nypm: "^0.4
|
|
95
|
+
nypm: "^0.5.4",
|
|
91
96
|
open: "^10.1.0",
|
|
92
|
-
ora: "^8.
|
|
93
|
-
semver: "^7.
|
|
94
|
-
"std-env": "^3.
|
|
95
|
-
zod: "^3.24.
|
|
97
|
+
ora: "^8.2.0",
|
|
98
|
+
semver: "^7.7.1",
|
|
99
|
+
"std-env": "^3.9.0",
|
|
100
|
+
zod: "^3.24.2",
|
|
96
101
|
"zod-validation-error": "^3.4.0"
|
|
97
102
|
},
|
|
98
103
|
devDependencies: {
|
|
99
|
-
"@bigcommerce/eslint-config": "^2.
|
|
104
|
+
"@bigcommerce/eslint-config": "^2.11.0",
|
|
100
105
|
"@bigcommerce/eslint-config-catalyst": "workspace:^",
|
|
101
|
-
"@swc/core": "^1.
|
|
106
|
+
"@swc/core": "^1.11.21",
|
|
102
107
|
"@swc/jest": "^0.2.37",
|
|
108
|
+
"@types/cross-spawn": "^6.0.6",
|
|
103
109
|
"@types/fs-extra": "^11.0.4",
|
|
104
110
|
"@types/jest": "^29.5.14",
|
|
105
111
|
"@types/lodash.kebabcase": "^4.1.9",
|
|
106
|
-
"@types/node": "^
|
|
112
|
+
"@types/node": "^22.14.1",
|
|
107
113
|
"@types/prompts": "^2.4.9",
|
|
108
|
-
"@types/semver": "^7.
|
|
114
|
+
"@types/semver": "^7.7.0",
|
|
109
115
|
eslint: "^8.57.1",
|
|
110
116
|
jest: "^29.7.0",
|
|
111
|
-
msw: "^2.
|
|
112
|
-
prettier: "^3.
|
|
113
|
-
tsup: "^8.
|
|
114
|
-
typescript: "^5.
|
|
117
|
+
msw: "^2.7.4",
|
|
118
|
+
prettier: "^3.5.3",
|
|
119
|
+
tsup: "^8.4.0",
|
|
120
|
+
typescript: "^5.8.3"
|
|
115
121
|
}
|
|
116
122
|
};
|
|
117
123
|
|
|
118
124
|
// src/commands/create.ts
|
|
119
125
|
import { Command, Option } from "@commander-js/extra-typings";
|
|
120
126
|
import { input, select } from "@inquirer/prompts";
|
|
121
|
-
import
|
|
122
|
-
import { execSync as
|
|
127
|
+
import chalk4 from "chalk";
|
|
128
|
+
import { execSync as execSync3 } from "child_process";
|
|
123
129
|
import { pathExistsSync } from "fs-extra/esm";
|
|
124
130
|
import kebabCase from "lodash.kebabcase";
|
|
125
131
|
import { join as join3 } from "path";
|
|
126
132
|
|
|
133
|
+
// src/prompts/multi-select/multi-select.ts
|
|
134
|
+
import {
|
|
135
|
+
createPrompt,
|
|
136
|
+
isBackspaceKey,
|
|
137
|
+
isDownKey,
|
|
138
|
+
isEnterKey,
|
|
139
|
+
isNumberKey,
|
|
140
|
+
isSpaceKey,
|
|
141
|
+
isUpKey,
|
|
142
|
+
makeTheme,
|
|
143
|
+
Separator as Separator2,
|
|
144
|
+
useEffect,
|
|
145
|
+
useKeypress,
|
|
146
|
+
useMemo,
|
|
147
|
+
usePagination,
|
|
148
|
+
usePrefix,
|
|
149
|
+
useRef,
|
|
150
|
+
useState,
|
|
151
|
+
ValidationError
|
|
152
|
+
} from "@inquirer/core";
|
|
153
|
+
import ansiEscapes from "ansi-escapes";
|
|
154
|
+
|
|
155
|
+
// src/prompts/multi-select/helpers.ts
|
|
156
|
+
import { Separator } from "@inquirer/core";
|
|
157
|
+
import figures from "@inquirer/figures";
|
|
158
|
+
import chalk from "chalk";
|
|
159
|
+
var selectTheme = {
|
|
160
|
+
helpMode: "auto",
|
|
161
|
+
icon: {
|
|
162
|
+
checked: chalk.green(figures.circleFilled),
|
|
163
|
+
unchecked: figures.circle,
|
|
164
|
+
cursor: figures.pointer
|
|
165
|
+
},
|
|
166
|
+
style: {
|
|
167
|
+
description: (text) => chalk.cyan(text),
|
|
168
|
+
disabledChoice: (text) => chalk.dim(`- ${text}`),
|
|
169
|
+
renderSelectedChoices: (selectedChoices) => selectedChoices.map((choice) => choice.short).join(", ")
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
var isSelectable = (item) => !Separator.isSeparator(item) && !item.disabled;
|
|
173
|
+
var isChecked = (item) => isSelectable(item) && Boolean(item.checked);
|
|
174
|
+
var toggle = (item) => isSelectable(item) ? __spreadProps(__spreadValues({}, item), { checked: !item.checked }) : item;
|
|
175
|
+
var normalizeChoices = (choices) => choices.map((choice) => {
|
|
176
|
+
var _a, _b, _c, _d;
|
|
177
|
+
if (Separator.isSeparator(choice)) {
|
|
178
|
+
return choice;
|
|
179
|
+
}
|
|
180
|
+
if (typeof choice === "string") {
|
|
181
|
+
return {
|
|
182
|
+
checked: false,
|
|
183
|
+
disabled: false,
|
|
184
|
+
name: choice,
|
|
185
|
+
short: choice,
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
187
|
+
value: choice
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
const name2 = (_a = choice.name) != null ? _a : String(choice.value);
|
|
191
|
+
return {
|
|
192
|
+
checked: (_b = choice.checked) != null ? _b : false,
|
|
193
|
+
description: choice.description,
|
|
194
|
+
disabled: (_c = choice.disabled) != null ? _c : false,
|
|
195
|
+
name: name2,
|
|
196
|
+
short: (_d = choice.short) != null ? _d : name2,
|
|
197
|
+
value: choice.value
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// src/prompts/multi-select/multi-select.ts
|
|
202
|
+
import { Separator as Separator3 } from "@inquirer/core";
|
|
203
|
+
var multiSelect = createPrompt(
|
|
204
|
+
(config, done) => {
|
|
205
|
+
const theme = makeTheme(selectTheme, config.theme);
|
|
206
|
+
const searchTimeoutRef = useRef();
|
|
207
|
+
const firstRender = useRef(true);
|
|
208
|
+
const [items, setItems] = useState(
|
|
209
|
+
normalizeChoices(config.choices)
|
|
210
|
+
);
|
|
211
|
+
const [status, setStatus] = useState("idle");
|
|
212
|
+
const [errorMsg, setError] = useState();
|
|
213
|
+
const prefix = usePrefix({ status, theme });
|
|
214
|
+
const { instructions, loop = true, pageSize = 7, required, validate = () => true } = config;
|
|
215
|
+
const bounds = useMemo(() => {
|
|
216
|
+
const first = items.findIndex(isSelectable);
|
|
217
|
+
const last = items.findLastIndex(isSelectable);
|
|
218
|
+
if (first === -1) {
|
|
219
|
+
throw new ValidationError(
|
|
220
|
+
"[multi select prompt] No selectable choices. All choices are disabled."
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
return { first, last };
|
|
224
|
+
}, [items]);
|
|
225
|
+
const [showHelpTip, setShowHelpTip] = useState(true);
|
|
226
|
+
const [active, setActive] = useState(bounds.first);
|
|
227
|
+
useEffect(
|
|
228
|
+
() => () => {
|
|
229
|
+
clearTimeout(searchTimeoutRef.current);
|
|
230
|
+
},
|
|
231
|
+
[]
|
|
232
|
+
);
|
|
233
|
+
useKeypress((key, rl) => __async(void 0, null, function* () {
|
|
234
|
+
clearTimeout(searchTimeoutRef.current);
|
|
235
|
+
if (isEnterKey(key)) {
|
|
236
|
+
const selection = items.filter(isChecked);
|
|
237
|
+
const isValid = yield validate([...selection]);
|
|
238
|
+
if (required && !items.some(isChecked)) {
|
|
239
|
+
setError("At least one choice must be selected");
|
|
240
|
+
} else if (isValid === true) {
|
|
241
|
+
setStatus("done");
|
|
242
|
+
done(selection.map((choice) => choice.value));
|
|
243
|
+
} else {
|
|
244
|
+
setError(isValid || "You must select a valid value");
|
|
245
|
+
}
|
|
246
|
+
} else if (isUpKey(key) || isDownKey(key)) {
|
|
247
|
+
rl.clearLine(0);
|
|
248
|
+
if (loop || isUpKey(key) && active !== bounds.first || isDownKey(key) && active !== bounds.last) {
|
|
249
|
+
const offset = isUpKey(key) ? -1 : 1;
|
|
250
|
+
let next = active;
|
|
251
|
+
do {
|
|
252
|
+
next = (next + offset + items.length) % items.length;
|
|
253
|
+
} while (!isSelectable(items[next]));
|
|
254
|
+
setActive(next);
|
|
255
|
+
}
|
|
256
|
+
} else if (isNumberKey(key)) {
|
|
257
|
+
rl.clearLine(0);
|
|
258
|
+
const position = Number(key.name) - 1;
|
|
259
|
+
if (isSelectable(items[position])) {
|
|
260
|
+
setActive(position);
|
|
261
|
+
}
|
|
262
|
+
} else if (isBackspaceKey(key)) {
|
|
263
|
+
rl.clearLine(0);
|
|
264
|
+
} else if (isSpaceKey(key)) {
|
|
265
|
+
rl.clearLine(0);
|
|
266
|
+
setShowHelpTip(false);
|
|
267
|
+
const nextItems = items.map((choice, i) => i === active ? toggle(choice) : choice);
|
|
268
|
+
const selection = nextItems.filter(isChecked);
|
|
269
|
+
const isValid = yield validate([...selection]);
|
|
270
|
+
if (isValid === true) {
|
|
271
|
+
setError(void 0);
|
|
272
|
+
setItems(nextItems);
|
|
273
|
+
} else {
|
|
274
|
+
setError(isValid || "You must select a valid value");
|
|
275
|
+
}
|
|
276
|
+
} else {
|
|
277
|
+
const searchTerm = rl.line.toLowerCase();
|
|
278
|
+
const matchIndex = items.findIndex(
|
|
279
|
+
(item) => Separator2.isSeparator(item) || !isSelectable(item) ? false : item.name.toLowerCase().startsWith(searchTerm)
|
|
280
|
+
);
|
|
281
|
+
if (matchIndex !== -1) {
|
|
282
|
+
setActive(matchIndex);
|
|
283
|
+
}
|
|
284
|
+
searchTimeoutRef.current = setTimeout(() => {
|
|
285
|
+
rl.clearLine(0);
|
|
286
|
+
}, 700);
|
|
287
|
+
}
|
|
288
|
+
}));
|
|
289
|
+
const message = theme.style.message(config.message, status);
|
|
290
|
+
let helpTipTop = "";
|
|
291
|
+
let helpTipBottom = "";
|
|
292
|
+
let description;
|
|
293
|
+
if (theme.helpMode === "always" || theme.helpMode === "auto" && showHelpTip && (instructions === void 0 || instructions)) {
|
|
294
|
+
if (typeof instructions === "string") {
|
|
295
|
+
helpTipTop = instructions;
|
|
296
|
+
} else {
|
|
297
|
+
const keys = [
|
|
298
|
+
`${theme.style.key("space")} to select`,
|
|
299
|
+
`${theme.style.key("enter")} to proceed`
|
|
300
|
+
];
|
|
301
|
+
helpTipTop = ` (Press ${keys.filter((key) => key !== "").join(", ")})`;
|
|
302
|
+
}
|
|
303
|
+
if (items.length > pageSize && (theme.helpMode === "always" || // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
304
|
+
theme.helpMode === "auto" && firstRender.current)) {
|
|
305
|
+
helpTipBottom = `
|
|
306
|
+
${theme.style.help("(Use arrow keys to reveal more choices)")}`;
|
|
307
|
+
firstRender.current = false;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const page = usePagination({
|
|
311
|
+
items,
|
|
312
|
+
active,
|
|
313
|
+
renderItem({ item, isActive }) {
|
|
314
|
+
if (Separator2.isSeparator(item)) {
|
|
315
|
+
return ` ${item.separator}`;
|
|
316
|
+
}
|
|
317
|
+
if (item.disabled) {
|
|
318
|
+
return theme.style.disabledChoice(
|
|
319
|
+
`${item.name} ${typeof item.disabled === "string" ? item.disabled : "(disabled)"}`
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
if (isActive) {
|
|
323
|
+
description = item.description;
|
|
324
|
+
}
|
|
325
|
+
const checkbox = item.checked ? theme.icon.checked : theme.icon.unchecked;
|
|
326
|
+
const color = isActive ? theme.style.highlight : (x) => x;
|
|
327
|
+
const cursor = isActive ? theme.icon.cursor : ` `;
|
|
328
|
+
return color(`${cursor}${checkbox} ${item.name}`);
|
|
329
|
+
},
|
|
330
|
+
pageSize,
|
|
331
|
+
loop
|
|
332
|
+
});
|
|
333
|
+
if (status === "done") {
|
|
334
|
+
return `${prefix} ${message} ${theme.style.answer(theme.style.renderSelectedChoices(items.filter(isChecked), items))}`;
|
|
335
|
+
}
|
|
336
|
+
const selectedChoices = items.filter(isChecked).length > 0 ? ` (${theme.style.answer(theme.style.renderSelectedChoices(items.filter(isChecked), items))})` : "";
|
|
337
|
+
const choiceDescription = description ? `
|
|
338
|
+
${theme.style.description(description)}` : ``;
|
|
339
|
+
let error = "";
|
|
340
|
+
if (errorMsg) {
|
|
341
|
+
error = `
|
|
342
|
+
${theme.style.error(errorMsg)}`;
|
|
343
|
+
}
|
|
344
|
+
return `${prefix} ${message}${selectedChoices}${helpTipTop}
|
|
345
|
+
${page}${helpTipBottom}${choiceDescription}${error}${ansiEscapes.cursorHide}`;
|
|
346
|
+
}
|
|
347
|
+
);
|
|
348
|
+
|
|
127
349
|
// src/utils/user-agent.ts
|
|
128
350
|
import {
|
|
129
351
|
isDevelopment,
|
|
@@ -184,7 +406,7 @@ var Https = class {
|
|
|
184
406
|
return __async(this, arguments, function* (path, opts = {}) {
|
|
185
407
|
const _a = opts, { headers = {} } = _a, rest = __objRest(_a, ["headers"]);
|
|
186
408
|
const options = __spreadValues({
|
|
187
|
-
headers: __spreadValues(__spreadProps(__spreadValues({}, headers), {
|
|
409
|
+
headers: __spreadValues(__spreadProps(__spreadValues({}, Object.fromEntries(new Headers(headers))), {
|
|
188
410
|
Accept: "application/json",
|
|
189
411
|
"User-Agent": this.userAgent
|
|
190
412
|
}), this.accessToken && { "X-Auth-Token": this.accessToken })
|
|
@@ -216,7 +438,7 @@ var CliApi = class {
|
|
|
216
438
|
});
|
|
217
439
|
});
|
|
218
440
|
}
|
|
219
|
-
createChannel(name2, installSampleData = false) {
|
|
441
|
+
createChannel(name2, storefrontLocale, additionalLocales, installSampleData = false) {
|
|
220
442
|
return __async(this, null, function* () {
|
|
221
443
|
return this.client.fetch("/channels/catalyst", {
|
|
222
444
|
method: "POST",
|
|
@@ -227,7 +449,9 @@ var CliApi = class {
|
|
|
227
449
|
type: installSampleData ? "sample" : "none"
|
|
228
450
|
},
|
|
229
451
|
deployStorefront: true,
|
|
230
|
-
devOrigin: "http://localhost:3000"
|
|
452
|
+
devOrigin: "http://localhost:3000",
|
|
453
|
+
storefrontLanguage: storefrontLocale,
|
|
454
|
+
additionalLocales
|
|
231
455
|
})
|
|
232
456
|
});
|
|
233
457
|
});
|
|
@@ -235,10 +459,10 @@ var CliApi = class {
|
|
|
235
459
|
};
|
|
236
460
|
|
|
237
461
|
// src/utils/clone-catalyst.ts
|
|
238
|
-
import { execSync as
|
|
462
|
+
import { execSync as execSync2 } from "child_process";
|
|
239
463
|
|
|
240
464
|
// src/utils/checkout-ref.ts
|
|
241
|
-
import {
|
|
465
|
+
import { sync as spawnSync } from "cross-spawn";
|
|
242
466
|
|
|
243
467
|
// src/utils/is-exec-exception.ts
|
|
244
468
|
function isExecException(error) {
|
|
@@ -248,11 +472,17 @@ function isExecException(error) {
|
|
|
248
472
|
// src/utils/checkout-ref.ts
|
|
249
473
|
function checkoutRef(repoDir, ref) {
|
|
250
474
|
try {
|
|
251
|
-
|
|
475
|
+
const spawn = spawnSync("git", ["checkout", ref, "--"], {
|
|
252
476
|
cwd: repoDir,
|
|
253
|
-
|
|
254
|
-
|
|
477
|
+
encoding: "utf8",
|
|
478
|
+
// Explicitly set shell to false to avoid shell injection
|
|
479
|
+
// Don't use shell: true as it's a security risk
|
|
480
|
+
shell: false
|
|
255
481
|
});
|
|
482
|
+
const stderr = spawn.stderr.trim();
|
|
483
|
+
if (spawn.status !== 0 && stderr) {
|
|
484
|
+
throw new Error(stderr);
|
|
485
|
+
}
|
|
256
486
|
console.log(`Checked out ref ${ref} successfully.`);
|
|
257
487
|
} catch (error) {
|
|
258
488
|
if (isExecException(error)) {
|
|
@@ -262,19 +492,20 @@ function checkoutRef(repoDir, ref) {
|
|
|
262
492
|
} else {
|
|
263
493
|
console.error(`Error checking out ref '${ref}':`, stderr.trim());
|
|
264
494
|
}
|
|
265
|
-
}
|
|
266
|
-
if (error instanceof Error) {
|
|
495
|
+
} else if (error instanceof Error) {
|
|
267
496
|
console.error(`Error checking out ref '${ref}':`, error.message);
|
|
497
|
+
} else {
|
|
498
|
+
console.error(`Unknown error occurred while checking out ref '${ref}'.`);
|
|
268
499
|
}
|
|
269
|
-
console.
|
|
500
|
+
console.warn(`Falling back to the default branch.`);
|
|
270
501
|
}
|
|
271
502
|
}
|
|
272
503
|
|
|
273
504
|
// src/utils/has-github-ssh.ts
|
|
274
|
-
import { execSync
|
|
505
|
+
import { execSync } from "child_process";
|
|
275
506
|
function hasGitHubSSH() {
|
|
276
507
|
try {
|
|
277
|
-
const output =
|
|
508
|
+
const output = execSync("ssh -T git@github.com", {
|
|
278
509
|
encoding: "utf8",
|
|
279
510
|
stdio: "pipe"
|
|
280
511
|
}).toString();
|
|
@@ -293,13 +524,19 @@ function hasGitHubSSH() {
|
|
|
293
524
|
}
|
|
294
525
|
|
|
295
526
|
// src/utils/reset-branch-to-ref.ts
|
|
296
|
-
import {
|
|
527
|
+
import { sync as spawnSync2 } from "cross-spawn";
|
|
297
528
|
function resetBranchToRef(projectDir, ghRef) {
|
|
298
|
-
|
|
529
|
+
const spawn = spawnSync2("git", ["reset", "--hard", ghRef, "--"], {
|
|
299
530
|
cwd: projectDir,
|
|
300
|
-
|
|
301
|
-
|
|
531
|
+
encoding: "utf8",
|
|
532
|
+
// Explicitly set shell to false to avoid shell injection
|
|
533
|
+
// Don't use shell: true as it's a security risk
|
|
534
|
+
shell: false
|
|
302
535
|
});
|
|
536
|
+
const stderr = spawn.stderr.trim();
|
|
537
|
+
if (spawn.status !== 0 && stderr) {
|
|
538
|
+
throw new Error(stderr);
|
|
539
|
+
}
|
|
303
540
|
}
|
|
304
541
|
|
|
305
542
|
// src/utils/clone-catalyst.ts
|
|
@@ -314,16 +551,16 @@ var cloneCatalyst = ({
|
|
|
314
551
|
console.log(`Cloning ${repository} using ${useSSH ? "SSH" : "HTTPS"}...
|
|
315
552
|
`);
|
|
316
553
|
const cloneCommand = `git clone ${useSSH ? `git@github.com:${repository}` : `https://github.com/${repository}`}.git${projectName ? ` ${projectName}` : ""}`;
|
|
317
|
-
|
|
554
|
+
execSync2(cloneCommand, { stdio: "inherit" });
|
|
318
555
|
console.log();
|
|
319
|
-
|
|
556
|
+
execSync2("git remote rename origin upstream", { cwd: projectDir, stdio: "inherit" });
|
|
320
557
|
console.log();
|
|
321
558
|
if (ghRef) {
|
|
322
559
|
if (resetMain) {
|
|
323
|
-
|
|
560
|
+
execSync2("git checkout -b main", { cwd: projectDir, stdio: "inherit" });
|
|
324
561
|
resetBranchToRef(projectDir, ghRef);
|
|
325
|
-
console.log(`Reset main to ${ghRef} successfully
|
|
326
|
-
|
|
562
|
+
console.log(`Reset main to ${ghRef} successfully.
|
|
563
|
+
`);
|
|
327
564
|
return;
|
|
328
565
|
}
|
|
329
566
|
checkoutRef(projectDir, ghRef);
|
|
@@ -332,7 +569,7 @@ var cloneCatalyst = ({
|
|
|
332
569
|
};
|
|
333
570
|
|
|
334
571
|
// src/utils/install-dependencies.ts
|
|
335
|
-
import
|
|
572
|
+
import chalk2 from "chalk";
|
|
336
573
|
import { installDependencies as installDeps } from "nypm";
|
|
337
574
|
|
|
338
575
|
// src/utils/spinner.ts
|
|
@@ -351,26 +588,69 @@ var installDependencies = (projectDir) => __async(void 0, null, function* () {
|
|
|
351
588
|
return spinner(installAllDeps(projectDir), {
|
|
352
589
|
text: `Installing dependencies. This could take a minute...`,
|
|
353
590
|
successText: `Dependencies installed successfully`,
|
|
354
|
-
failText: (err) =>
|
|
591
|
+
failText: (err) => chalk2.red(`Failed to install dependencies: ${err.message}`)
|
|
355
592
|
});
|
|
356
593
|
});
|
|
357
594
|
|
|
595
|
+
// src/utils/localization.ts
|
|
596
|
+
import { z } from "zod";
|
|
597
|
+
var allowedLocales = [
|
|
598
|
+
"en",
|
|
599
|
+
"da",
|
|
600
|
+
"es-AR",
|
|
601
|
+
"es-CL",
|
|
602
|
+
"es-CO",
|
|
603
|
+
"es-MX",
|
|
604
|
+
"es-PE",
|
|
605
|
+
"es-419",
|
|
606
|
+
"es",
|
|
607
|
+
"it",
|
|
608
|
+
"nl",
|
|
609
|
+
"pl",
|
|
610
|
+
"pt",
|
|
611
|
+
"de",
|
|
612
|
+
"fr",
|
|
613
|
+
"ja",
|
|
614
|
+
"no",
|
|
615
|
+
"pt-BR",
|
|
616
|
+
"sv"
|
|
617
|
+
];
|
|
618
|
+
var AvailableLocalesSuccessSchema = z.object({
|
|
619
|
+
data: z.array(
|
|
620
|
+
z.object({
|
|
621
|
+
id: z.string(),
|
|
622
|
+
name: z.string(),
|
|
623
|
+
fallback: z.string().nullable(),
|
|
624
|
+
is_supported: z.boolean()
|
|
625
|
+
})
|
|
626
|
+
)
|
|
627
|
+
});
|
|
628
|
+
var getAvailableLocales = (bc) => __async(void 0, null, function* () {
|
|
629
|
+
const response = yield bc.fetch("/v3/settings/store/available-locales");
|
|
630
|
+
if (!response.ok) {
|
|
631
|
+
throw new Error(
|
|
632
|
+
`GET /v3/settings/store/available-locales failed: ${response.status} ${response.statusText}`
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
return AvailableLocalesSuccessSchema.parse(yield response.json()).data.filter(({ id }) => allowedLocales.includes(id)).map(({ name: name2, id }) => ({ name: `${name2} (${id})`, value: id }));
|
|
636
|
+
});
|
|
637
|
+
|
|
358
638
|
// src/utils/login.ts
|
|
359
|
-
import
|
|
639
|
+
import chalk3 from "chalk";
|
|
360
640
|
import open from "open";
|
|
361
641
|
import { createInterface } from "readline";
|
|
362
642
|
|
|
363
643
|
// src/utils/auth.ts
|
|
364
|
-
import { z as
|
|
644
|
+
import { z as z3 } from "zod";
|
|
365
645
|
|
|
366
646
|
// src/utils/parse.ts
|
|
367
|
-
import * as
|
|
647
|
+
import * as z2 from "zod";
|
|
368
648
|
import { fromZodError } from "zod-validation-error";
|
|
369
649
|
var parse = (data, schema) => {
|
|
370
650
|
try {
|
|
371
651
|
return schema.parse(data);
|
|
372
652
|
} catch (error) {
|
|
373
|
-
if (error instanceof
|
|
653
|
+
if (error instanceof z2.ZodError) {
|
|
374
654
|
console.error(fromZodError(error).toString());
|
|
375
655
|
}
|
|
376
656
|
process.exit(1);
|
|
@@ -401,12 +681,12 @@ var Auth = class {
|
|
|
401
681
|
client_id: this.DEVICE_OAUTH_CLIENT_ID
|
|
402
682
|
})
|
|
403
683
|
});
|
|
404
|
-
const DeviceCodeSchema =
|
|
405
|
-
device_code:
|
|
406
|
-
user_code:
|
|
407
|
-
verification_uri:
|
|
408
|
-
expires_in:
|
|
409
|
-
interval:
|
|
684
|
+
const DeviceCodeSchema = z3.object({
|
|
685
|
+
device_code: z3.string(),
|
|
686
|
+
user_code: z3.string(),
|
|
687
|
+
verification_uri: z3.string(),
|
|
688
|
+
expires_in: z3.number(),
|
|
689
|
+
interval: z3.number()
|
|
410
690
|
});
|
|
411
691
|
return parse(yield response.json(), DeviceCodeSchema);
|
|
412
692
|
});
|
|
@@ -424,11 +704,11 @@ var Auth = class {
|
|
|
424
704
|
if (response.status !== 200) {
|
|
425
705
|
throw new Error("Device code not yet verified");
|
|
426
706
|
}
|
|
427
|
-
const DeviceCodeSuccessSchema =
|
|
428
|
-
access_token:
|
|
429
|
-
store_hash:
|
|
430
|
-
context:
|
|
431
|
-
api_uri:
|
|
707
|
+
const DeviceCodeSuccessSchema = z3.object({
|
|
708
|
+
access_token: z3.string(),
|
|
709
|
+
store_hash: z3.string(),
|
|
710
|
+
context: z3.string(),
|
|
711
|
+
api_uri: z3.string().url()
|
|
432
712
|
});
|
|
433
713
|
return parse(yield response.json(), DeviceCodeSuccessSchema);
|
|
434
714
|
});
|
|
@@ -555,7 +835,7 @@ function login(baseUrl) {
|
|
|
555
835
|
const auth = new Auth({ baseUrl });
|
|
556
836
|
const deviceCode = yield auth.getDeviceCode();
|
|
557
837
|
console.log(
|
|
558
|
-
|
|
838
|
+
chalk3.yellow("\n! First copy your one-time code: ") + chalk3.bold(deviceCode.user_code)
|
|
559
839
|
);
|
|
560
840
|
console.log(`Press Enter to open ${deviceCode.verification_uri} in your browser...`);
|
|
561
841
|
const shouldOpenUrl = yield waitForKeyPress("");
|
|
@@ -679,11 +959,55 @@ function getPlatformCheckCommand(command) {
|
|
|
679
959
|
return isWindows2 ? `where.exe ${command}` : `which ${command}`;
|
|
680
960
|
}
|
|
681
961
|
var telemetry = new Telemetry();
|
|
682
|
-
function handleChannelCreation(cliApi) {
|
|
962
|
+
function handleChannelCreation(bc, cliApi) {
|
|
683
963
|
return __async(this, null, function* () {
|
|
684
964
|
const newChannelName = yield input({
|
|
685
965
|
message: "What would you like to name your new channel?"
|
|
686
966
|
});
|
|
967
|
+
let availableLocales = [];
|
|
968
|
+
try {
|
|
969
|
+
availableLocales = yield getAvailableLocales(bc);
|
|
970
|
+
} catch (error) {
|
|
971
|
+
if (error instanceof Error) {
|
|
972
|
+
console.error(chalk4.red(error.message));
|
|
973
|
+
}
|
|
974
|
+
process.exit(1);
|
|
975
|
+
}
|
|
976
|
+
const storefrontLocale = yield select({
|
|
977
|
+
message: "Which default language would you like to set for your channel?",
|
|
978
|
+
default: "en",
|
|
979
|
+
choices: availableLocales,
|
|
980
|
+
theme: {
|
|
981
|
+
style: {
|
|
982
|
+
help: () => chalk4.dim("(Select locale from the list or start typing the name)")
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
const shouldAddAdditionalLocales = yield select({
|
|
987
|
+
message: "Would you like to add additional languages?",
|
|
988
|
+
choices: [
|
|
989
|
+
{ name: "Yes", value: true },
|
|
990
|
+
{ name: "No", value: false }
|
|
991
|
+
]
|
|
992
|
+
});
|
|
993
|
+
let additionalLocales = [];
|
|
994
|
+
if (shouldAddAdditionalLocales) {
|
|
995
|
+
additionalLocales = yield multiSelect({
|
|
996
|
+
choices: availableLocales.filter(({ value }) => value !== storefrontLocale),
|
|
997
|
+
message: "Which additional languages would you like to add to your channel?",
|
|
998
|
+
theme: {
|
|
999
|
+
style: {
|
|
1000
|
+
help: () => chalk4.dim("(Select locale from the list or start typing the name)")
|
|
1001
|
+
}
|
|
1002
|
+
},
|
|
1003
|
+
validate: (selections) => {
|
|
1004
|
+
if (selections.length > 4) {
|
|
1005
|
+
return "You can only select up to 4 additional languages";
|
|
1006
|
+
}
|
|
1007
|
+
return true;
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
687
1011
|
const shouldInstallSampleData = yield select({
|
|
688
1012
|
message: "Would you like to install sample data?",
|
|
689
1013
|
choices: [
|
|
@@ -691,10 +1015,15 @@ function handleChannelCreation(cliApi) {
|
|
|
691
1015
|
{ name: "No", value: false }
|
|
692
1016
|
]
|
|
693
1017
|
});
|
|
694
|
-
const response = yield cliApi.createChannel(
|
|
1018
|
+
const response = yield cliApi.createChannel(
|
|
1019
|
+
newChannelName,
|
|
1020
|
+
storefrontLocale,
|
|
1021
|
+
additionalLocales,
|
|
1022
|
+
shouldInstallSampleData
|
|
1023
|
+
);
|
|
695
1024
|
if (!response.ok) {
|
|
696
1025
|
console.error(
|
|
697
|
-
|
|
1026
|
+
chalk4.red(`
|
|
698
1027
|
POST /channels/catalyst failed: ${response.status} ${response.statusText}
|
|
699
1028
|
`)
|
|
700
1029
|
);
|
|
@@ -702,7 +1031,7 @@ POST /channels/catalyst failed: ${response.status} ${response.statusText}
|
|
|
702
1031
|
}
|
|
703
1032
|
const channelData = yield response.json();
|
|
704
1033
|
if (!isCreateChannelResponse(channelData)) {
|
|
705
|
-
console.error(
|
|
1034
|
+
console.error(chalk4.red("\nUnexpected response format from create channel endpoint\n"));
|
|
706
1035
|
process.exit(1);
|
|
707
1036
|
}
|
|
708
1037
|
return {
|
|
@@ -718,7 +1047,7 @@ function handleChannelSelection(bc) {
|
|
|
718
1047
|
const channelsResponse = yield bc.fetch("/v3/channels?available=true&type=storefront");
|
|
719
1048
|
if (!channelsResponse.ok) {
|
|
720
1049
|
console.error(
|
|
721
|
-
|
|
1050
|
+
chalk4.red(
|
|
722
1051
|
`
|
|
723
1052
|
GET /v3/channels failed: ${channelsResponse.status} ${channelsResponse.statusText}
|
|
724
1053
|
`
|
|
@@ -728,7 +1057,7 @@ GET /v3/channels failed: ${channelsResponse.status} ${channelsResponse.statusTex
|
|
|
728
1057
|
}
|
|
729
1058
|
const availableChannels = yield channelsResponse.json();
|
|
730
1059
|
if (!isChannelsResponse(availableChannels)) {
|
|
731
|
-
console.error(
|
|
1060
|
+
console.error(chalk4.red("\nUnexpected response format from channels endpoint\n"));
|
|
732
1061
|
process.exit(1);
|
|
733
1062
|
}
|
|
734
1063
|
const existingChannel = yield select({
|
|
@@ -756,7 +1085,7 @@ function getChannelInit(cliApi, channelId) {
|
|
|
756
1085
|
const initResponse = yield cliApi.getChannelInit(channelId);
|
|
757
1086
|
if (!initResponse.ok) {
|
|
758
1087
|
console.error(
|
|
759
|
-
|
|
1088
|
+
chalk4.red(
|
|
760
1089
|
`
|
|
761
1090
|
GET /channels/${channelId}/init failed: ${initResponse.status} ${initResponse.statusText}
|
|
762
1091
|
`
|
|
@@ -766,7 +1095,7 @@ GET /channels/${channelId}/init failed: ${initResponse.status} ${initResponse.st
|
|
|
766
1095
|
}
|
|
767
1096
|
const initData = yield initResponse.json();
|
|
768
1097
|
if (!isInitResponse(initData)) {
|
|
769
|
-
console.error(
|
|
1098
|
+
console.error(chalk4.red("\nUnexpected response format from init endpoint\n"));
|
|
770
1099
|
process.exit(1);
|
|
771
1100
|
}
|
|
772
1101
|
return {
|
|
@@ -779,7 +1108,7 @@ function setupProject(options) {
|
|
|
779
1108
|
return __async(this, null, function* () {
|
|
780
1109
|
let { projectName, projectDir } = options;
|
|
781
1110
|
if (!pathExistsSync(projectDir)) {
|
|
782
|
-
console.error(
|
|
1111
|
+
console.error(chalk4.red(`Error: --projectDir ${projectDir} is not a valid path
|
|
783
1112
|
`));
|
|
784
1113
|
process.exit(1);
|
|
785
1114
|
}
|
|
@@ -787,7 +1116,7 @@ function setupProject(options) {
|
|
|
787
1116
|
projectName = kebabCase(projectName);
|
|
788
1117
|
projectDir = join3(options.projectDir, projectName);
|
|
789
1118
|
if (pathExistsSync(projectDir)) {
|
|
790
|
-
console.error(
|
|
1119
|
+
console.error(chalk4.red(`Error: ${projectDir} already exists
|
|
791
1120
|
`));
|
|
792
1121
|
process.exit(1);
|
|
793
1122
|
}
|
|
@@ -815,16 +1144,16 @@ function setupProject(options) {
|
|
|
815
1144
|
}
|
|
816
1145
|
function checkRequiredTools() {
|
|
817
1146
|
try {
|
|
818
|
-
|
|
1147
|
+
execSync3(getPlatformCheckCommand("git"), { stdio: "ignore" });
|
|
819
1148
|
} catch (e) {
|
|
820
|
-
console.error(
|
|
1149
|
+
console.error(chalk4.red("Error: git is required to create a Catalyst project\n"));
|
|
821
1150
|
process.exit(1);
|
|
822
1151
|
}
|
|
823
1152
|
try {
|
|
824
|
-
|
|
1153
|
+
execSync3(getPlatformCheckCommand("pnpm"), { stdio: "ignore" });
|
|
825
1154
|
} catch (e) {
|
|
826
|
-
console.error(
|
|
827
|
-
console.error(
|
|
1155
|
+
console.error(chalk4.red("Error: pnpm is required to create a Catalyst project\n"));
|
|
1156
|
+
console.error(chalk4.yellow("Tip: Enable it by running `corepack enable pnpm`\n"));
|
|
828
1157
|
process.exit(1);
|
|
829
1158
|
}
|
|
830
1159
|
}
|
|
@@ -882,15 +1211,15 @@ Creating '${projectName}' at '${projectDir}'
|
|
|
882
1211
|
console.log(
|
|
883
1212
|
[
|
|
884
1213
|
`
|
|
885
|
-
${
|
|
1214
|
+
${chalk4.green("Success!")} Created '${projectName}' at '${projectDir}'
|
|
886
1215
|
`,
|
|
887
1216
|
`Next steps:`,
|
|
888
|
-
Object.keys(envVars).length > 0 ?
|
|
1217
|
+
Object.keys(envVars).length > 0 ? chalk4.yellow(`
|
|
889
1218
|
- cd ${projectName} && pnpm run dev
|
|
890
1219
|
`) : [
|
|
891
|
-
|
|
1220
|
+
chalk4.yellow(`
|
|
892
1221
|
- cd ${projectName} && cp .env.example .env.local`),
|
|
893
|
-
|
|
1222
|
+
chalk4.yellow(`
|
|
894
1223
|
- Populate .env.local with your BigCommerce API credentials
|
|
895
1224
|
`)
|
|
896
1225
|
].join("")
|
|
@@ -917,7 +1246,7 @@ ${chalk3.green("Success!")} Created '${projectName}' at '${projectDir}'
|
|
|
917
1246
|
const eligibilityResponse = yield cliApi.checkEligibility();
|
|
918
1247
|
if (!eligibilityResponse.ok) {
|
|
919
1248
|
console.error(
|
|
920
|
-
|
|
1249
|
+
chalk4.red(
|
|
921
1250
|
`
|
|
922
1251
|
GET /channels/catalyst/eligibility failed: ${eligibilityResponse.status} ${eligibilityResponse.statusText}
|
|
923
1252
|
`
|
|
@@ -927,11 +1256,11 @@ GET /channels/catalyst/eligibility failed: ${eligibilityResponse.status} ${eligi
|
|
|
927
1256
|
}
|
|
928
1257
|
const eligibilityData = yield eligibilityResponse.json();
|
|
929
1258
|
if (!isEligibilityResponse(eligibilityData)) {
|
|
930
|
-
console.error(
|
|
1259
|
+
console.error(chalk4.red("\nUnexpected response format from eligibility endpoint\n"));
|
|
931
1260
|
process.exit(1);
|
|
932
1261
|
}
|
|
933
1262
|
if (!eligibilityData.data.eligible) {
|
|
934
|
-
console.warn(
|
|
1263
|
+
console.warn(chalk4.yellow(eligibilityData.data.message));
|
|
935
1264
|
}
|
|
936
1265
|
let shouldCreateChannel;
|
|
937
1266
|
if (eligibilityData.data.eligible) {
|
|
@@ -944,13 +1273,13 @@ GET /channels/catalyst/eligibility failed: ${eligibilityResponse.status} ${eligi
|
|
|
944
1273
|
});
|
|
945
1274
|
}
|
|
946
1275
|
if (shouldCreateChannel) {
|
|
947
|
-
const channelData = yield handleChannelCreation(cliApi);
|
|
1276
|
+
const channelData = yield handleChannelCreation(bc, cliApi);
|
|
948
1277
|
channelId = channelData.channelId;
|
|
949
1278
|
storefrontToken = channelData.storefrontToken;
|
|
950
1279
|
envVars = __spreadValues({}, channelData.envVars);
|
|
951
|
-
console.log(
|
|
1280
|
+
console.log(chalk4.green(`Channel created successfully`));
|
|
952
1281
|
console.warn(
|
|
953
|
-
|
|
1282
|
+
chalk4.yellow(
|
|
954
1283
|
"\nNote: A preview storefront has been deployed in your BigCommerce control panel. This preview may look different from your local environment as it may be running different code."
|
|
955
1284
|
)
|
|
956
1285
|
);
|
|
@@ -996,10 +1325,10 @@ Creating '${projectName}' at '${projectDir}'
|
|
|
996
1325
|
}
|
|
997
1326
|
console.log(
|
|
998
1327
|
`
|
|
999
|
-
${
|
|
1328
|
+
${chalk4.green("Success!")} Created '${projectName}' at '${projectDir}'
|
|
1000
1329
|
`,
|
|
1001
1330
|
"\nNext steps:\n",
|
|
1002
|
-
|
|
1331
|
+
chalk4.yellow(`
|
|
1003
1332
|
cd ${projectName} && pnpm run dev
|
|
1004
1333
|
`)
|
|
1005
1334
|
);
|
|
@@ -1022,7 +1351,7 @@ function isChannelsResponse(response) {
|
|
|
1022
1351
|
// src/commands/init.ts
|
|
1023
1352
|
import { Command as Command2, Option as Option2 } from "@commander-js/extra-typings";
|
|
1024
1353
|
import { select as select2 } from "@inquirer/prompts";
|
|
1025
|
-
import
|
|
1354
|
+
import chalk5 from "chalk";
|
|
1026
1355
|
function isChannelsResponse2(response) {
|
|
1027
1356
|
return typeof response === "object" && response !== null && "data" in response && Array.isArray(response.data) && response.data.every(
|
|
1028
1357
|
(item) => typeof item === "object" && item !== null && "id" in item && "name" in item && "platform" in item
|
|
@@ -1066,7 +1395,7 @@ var init = new Command2("init").description("Connect a BigCommerce store with an
|
|
|
1066
1395
|
const channelsResponse = yield bc.fetch("/v3/channels?available=true&type=storefront");
|
|
1067
1396
|
if (!channelsResponse.ok) {
|
|
1068
1397
|
console.error(
|
|
1069
|
-
|
|
1398
|
+
chalk5.red(
|
|
1070
1399
|
`
|
|
1071
1400
|
GET /v3/channels failed: ${channelsResponse.status} ${channelsResponse.statusText}
|
|
1072
1401
|
`
|
|
@@ -1076,7 +1405,7 @@ GET /v3/channels failed: ${channelsResponse.status} ${channelsResponse.statusTex
|
|
|
1076
1405
|
}
|
|
1077
1406
|
const availableChannels = yield channelsResponse.json();
|
|
1078
1407
|
if (!isChannelsResponse2(availableChannels)) {
|
|
1079
|
-
console.error(
|
|
1408
|
+
console.error(chalk5.red("\nUnexpected response format from channels endpoint\n"));
|
|
1080
1409
|
process.exit(1);
|
|
1081
1410
|
}
|
|
1082
1411
|
const existingChannel = yield select2({
|
|
@@ -1093,7 +1422,7 @@ GET /v3/channels failed: ${channelsResponse.status} ${channelsResponse.statusTex
|
|
|
1093
1422
|
const initResponse = yield cliApi.getChannelInit(channelId);
|
|
1094
1423
|
if (!initResponse.ok) {
|
|
1095
1424
|
console.error(
|
|
1096
|
-
|
|
1425
|
+
chalk5.red(
|
|
1097
1426
|
`
|
|
1098
1427
|
GET /channels/${channelId}/init failed: ${initResponse.status} ${initResponse.statusText}
|
|
1099
1428
|
`
|
|
@@ -1103,7 +1432,7 @@ GET /channels/${channelId}/init failed: ${initResponse.status} ${initResponse.st
|
|
|
1103
1432
|
}
|
|
1104
1433
|
const initData = yield initResponse.json();
|
|
1105
1434
|
if (!isInitResponse2(initData)) {
|
|
1106
|
-
console.error(
|
|
1435
|
+
console.error(chalk5.red("\nUnexpected response format from init endpoint\n"));
|
|
1107
1436
|
process.exit(1);
|
|
1108
1437
|
}
|
|
1109
1438
|
const envVars = __spreadValues({}, initData.data.envVars);
|
|
@@ -1118,13 +1447,13 @@ GET /channels/${channelId}/init failed: ${initResponse.status} ${initResponse.st
|
|
|
1118
1447
|
Object.assign(envVars, cliEnvVars);
|
|
1119
1448
|
}
|
|
1120
1449
|
writeEnv(projectDir, envVars);
|
|
1121
|
-
console.log(
|
|
1450
|
+
console.log(chalk5.green(`
|
|
1122
1451
|
.env.local file created for channel ${existingChannel.name}!
|
|
1123
1452
|
`));
|
|
1124
|
-
console.log(
|
|
1453
|
+
console.log(chalk5.green(`
|
|
1125
1454
|
Next steps:
|
|
1126
1455
|
`));
|
|
1127
|
-
console.log(
|
|
1456
|
+
console.log(chalk5.yellow(`
|
|
1128
1457
|
pnpm run dev
|
|
1129
1458
|
`));
|
|
1130
1459
|
}));
|
|
@@ -1137,16 +1466,16 @@ import { outputFileSync as outputFileSync2, writeJsonSync } from "fs-extra/esm";
|
|
|
1137
1466
|
import kebabCase2 from "lodash.kebabcase";
|
|
1138
1467
|
import { coerce, compare } from "semver";
|
|
1139
1468
|
import { promisify } from "util";
|
|
1140
|
-
import { z as
|
|
1469
|
+
import { z as z4 } from "zod";
|
|
1141
1470
|
var exec = promisify(execCb);
|
|
1142
|
-
var ManifestSchema =
|
|
1143
|
-
name:
|
|
1144
|
-
dependencies:
|
|
1145
|
-
devDependencies:
|
|
1146
|
-
environmentVariables:
|
|
1471
|
+
var ManifestSchema = z4.object({
|
|
1472
|
+
name: z4.string(),
|
|
1473
|
+
dependencies: z4.object({ add: z4.array(z4.string()) }),
|
|
1474
|
+
devDependencies: z4.object({ add: z4.array(z4.string()) }),
|
|
1475
|
+
environmentVariables: z4.array(z4.string())
|
|
1147
1476
|
});
|
|
1148
1477
|
var integration = new Command3("integration").argument("<integration-name>", "Formatted name of the integration").option("--commit-hash <hash>", "Override integration source branch with a specific commit hash").action((integrationNameRaw, options) => __async(void 0, null, function* () {
|
|
1149
|
-
const integrationName =
|
|
1478
|
+
const integrationName = z4.string().transform(kebabCase2).parse(integrationNameRaw);
|
|
1150
1479
|
const manifest = {
|
|
1151
1480
|
name: integrationName,
|
|
1152
1481
|
dependencies: { add: [] },
|
|
@@ -1168,9 +1497,9 @@ var integration = new Command3("integration").argument("<integration-name>", "Fo
|
|
|
1168
1497
|
}
|
|
1169
1498
|
return 0;
|
|
1170
1499
|
}).reverse();
|
|
1171
|
-
const PackageDependenciesSchema =
|
|
1172
|
-
dependencies:
|
|
1173
|
-
devDependencies:
|
|
1500
|
+
const PackageDependenciesSchema = z4.object({
|
|
1501
|
+
dependencies: z4.object({}).passthrough(),
|
|
1502
|
+
devDependencies: z4.object({}).passthrough()
|
|
1174
1503
|
});
|
|
1175
1504
|
const getPackageDeps = (ref) => __async(void 0, null, function* () {
|
|
1176
1505
|
const { stdout } = yield exec(`git show ${ref}:core/package.json`);
|
|
@@ -1206,7 +1535,7 @@ var integration = new Command3("integration").argument("<integration-name>", "Fo
|
|
|
1206
1535
|
import { Argument, Command as Command4, Option as Option3 } from "@commander-js/extra-typings";
|
|
1207
1536
|
|
|
1208
1537
|
// src/utils/telemetry/index.ts
|
|
1209
|
-
import
|
|
1538
|
+
import chalk6 from "chalk";
|
|
1210
1539
|
var telemetry3 = new Telemetry();
|
|
1211
1540
|
var isEnabled = telemetry3.isEnabled();
|
|
1212
1541
|
var catalystTelemetry = (options, arg) => {
|
|
@@ -1227,7 +1556,7 @@ var catalystTelemetry = (options, arg) => {
|
|
|
1227
1556
|
}
|
|
1228
1557
|
console.log(
|
|
1229
1558
|
`
|
|
1230
|
-
Status: ${
|
|
1559
|
+
Status: ${chalk6.bold(isEnabled ? chalk6.green("Enabled") : chalk6.red("Disabled"))}`
|
|
1231
1560
|
);
|
|
1232
1561
|
if (!isEnabled) {
|
|
1233
1562
|
console.log(
|
|
@@ -1280,7 +1609,7 @@ var telemetryPostHook = () => __async(void 0, null, function* () {
|
|
|
1280
1609
|
});
|
|
1281
1610
|
|
|
1282
1611
|
// src/index.ts
|
|
1283
|
-
console.log(
|
|
1612
|
+
console.log(chalk7.cyanBright(`
|
|
1284
1613
|
\u25E2 ${package_default.name} v${package_default.version}
|
|
1285
1614
|
`));
|
|
1286
1615
|
program.name(package_default.name).version(package_default.version).description("A command line tool to create a new Catalyst project.").addCommand(create, { isDefault: true }).addCommand(init).addCommand(integration).addCommand(telemetry4).hook("preAction", telemetryPreHook).hook("postAction", telemetryPostHook);
|