@contentful/experience-design-system-cli 2.34.1 → 2.34.2-dev-build-cfb3467.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/cli.js +13 -5
- package/dist/package.json +1 -1
- package/dist/src/index.js +288 -201
- package/dist/src/lib/cli-errors.d.ts +10 -0
- package/package.json +6 -6
package/dist/src/index.js
CHANGED
|
@@ -21,8 +21,78 @@ var init_agent_names = __esm({
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
// packages/experience-design-system-generation/dist/src/
|
|
24
|
+
// packages/experience-design-system-generation/dist/src/lib/binary-launch.js
|
|
25
25
|
import { spawn } from "node:child_process";
|
|
26
|
+
import { accessSync, constants } from "node:fs";
|
|
27
|
+
import { delimiter, isAbsolute, join } from "node:path";
|
|
28
|
+
function executableExtensions(platform) {
|
|
29
|
+
return platform === "win32" ? [".exe", ".cmd", ".bat", ".com"] : [""];
|
|
30
|
+
}
|
|
31
|
+
function findBinary(binary, platform = process.platform) {
|
|
32
|
+
const extensions = executableExtensions(platform);
|
|
33
|
+
if (isAbsolute(binary)) {
|
|
34
|
+
for (const extension of ["", ...extensions]) {
|
|
35
|
+
try {
|
|
36
|
+
accessSync(binary + extension, constants.F_OK);
|
|
37
|
+
return binary + extension;
|
|
38
|
+
} catch {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
for (const directory of (process.env["PATH"] ?? "").split(delimiter)) {
|
|
45
|
+
if (!directory || !isAbsolute(directory))
|
|
46
|
+
continue;
|
|
47
|
+
for (const extension of extensions) {
|
|
48
|
+
const candidate = join(directory, binary + extension);
|
|
49
|
+
try {
|
|
50
|
+
accessSync(candidate, constants.X_OK);
|
|
51
|
+
return candidate;
|
|
52
|
+
} catch {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
function binaryExists(binary, platform = process.platform) {
|
|
60
|
+
return findBinary(binary, platform) !== null;
|
|
61
|
+
}
|
|
62
|
+
function spawnSpec(resolved, args, platform = process.platform) {
|
|
63
|
+
if (platform !== "win32" || /\.(exe|com)$/i.test(resolved)) {
|
|
64
|
+
return { command: resolved, args };
|
|
65
|
+
}
|
|
66
|
+
const shell = process.env["ComSpec"] || "cmd.exe";
|
|
67
|
+
const quote = (value) => `"${value.replace(/"/g, '""')}"`;
|
|
68
|
+
const commandLine = [resolved, ...args].map(quote).join(" ");
|
|
69
|
+
return {
|
|
70
|
+
command: shell,
|
|
71
|
+
// /d skips AutoRun scripts, /s keeps the outer quotes intact, /c runs and exits.
|
|
72
|
+
args: ["/d", "/s", "/c", `"${commandLine}"`],
|
|
73
|
+
windowsVerbatimArguments: true
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function resolveSpawn(binary, args, platform = process.platform) {
|
|
77
|
+
const resolved = findBinary(binary, platform);
|
|
78
|
+
if (!resolved)
|
|
79
|
+
return null;
|
|
80
|
+
return spawnSpec(resolved, args, platform);
|
|
81
|
+
}
|
|
82
|
+
function spawnBinary(command, args, options = {}) {
|
|
83
|
+
const launch = resolveSpawn(command, args) ?? { command, args };
|
|
84
|
+
return spawn(launch.command, launch.args, {
|
|
85
|
+
...options,
|
|
86
|
+
...launch.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
var init_binary_launch = __esm({
|
|
90
|
+
"packages/experience-design-system-generation/dist/src/lib/binary-launch.js"() {
|
|
91
|
+
"use strict";
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// packages/experience-design-system-generation/dist/src/agent-runner.js
|
|
26
96
|
function findJsonObjectEnd(line) {
|
|
27
97
|
let depth = 0;
|
|
28
98
|
let inString = false;
|
|
@@ -297,10 +367,22 @@ function codexBedrockConfigArgs() {
|
|
|
297
367
|
const region = process.env.AWS_REGION?.trim() || process.env.AWS_DEFAULT_REGION?.trim() || DEFAULT_CODEX_BEDROCK_REGION;
|
|
298
368
|
return ["-c", "model_provider=amazon-bedrock", "-c", `model_providers.amazon-bedrock.region=${region}`];
|
|
299
369
|
}
|
|
370
|
+
function agentSupportsStdinPrompt(agent) {
|
|
371
|
+
return STDIN_CAPABLE_AGENTS.has(agent);
|
|
372
|
+
}
|
|
373
|
+
function shouldUseStdinPrompt(agent, prompt2) {
|
|
374
|
+
return agentSupportsStdinPrompt(agent) && prompt2.length > ARGV_PROMPT_LIMIT;
|
|
375
|
+
}
|
|
376
|
+
function promptExceedsArgvLimit(agent, prompt2, platform = process.platform) {
|
|
377
|
+
if (agentSupportsStdinPrompt(agent))
|
|
378
|
+
return false;
|
|
379
|
+
return platform === "win32" && prompt2.length > 8191;
|
|
380
|
+
}
|
|
300
381
|
function buildArgs(agent, prompt2, model, promptViaStdin = false, bedrock = false) {
|
|
301
382
|
const resolvedModel = resolveAgentModel(agent, model, bedrock);
|
|
302
383
|
const modelArg = resolvedModel ? ["--model", resolvedModel] : [];
|
|
303
|
-
const
|
|
384
|
+
const useStdin2 = promptViaStdin && agentSupportsStdinPrompt(agent);
|
|
385
|
+
const promptArg = useStdin2 ? [] : [prompt2];
|
|
304
386
|
switch (agent) {
|
|
305
387
|
case "claude":
|
|
306
388
|
return ["--print", ...modelArg, ...promptArg];
|
|
@@ -323,7 +405,7 @@ async function runAgent(options) {
|
|
|
323
405
|
const { agent, prompt: prompt2, timeoutMs, model, onOutput, promptViaStdin, onDebugEvent } = options;
|
|
324
406
|
const bedrock = options.bedrock ?? process.env.EDS_BEDROCK === "1";
|
|
325
407
|
const binary = resolveBinary(agent);
|
|
326
|
-
const useStdin2 = !!promptViaStdin;
|
|
408
|
+
const useStdin2 = agentSupportsStdinPrompt(agent) && (!!promptViaStdin || shouldUseStdinPrompt(agent, prompt2));
|
|
327
409
|
const args = buildArgs(agent, prompt2, model, useStdin2, bedrock);
|
|
328
410
|
const startedAt = Date.now();
|
|
329
411
|
onDebugEvent?.("run.start", {
|
|
@@ -337,7 +419,7 @@ async function runAgent(options) {
|
|
|
337
419
|
});
|
|
338
420
|
return new Promise((resolve29) => {
|
|
339
421
|
const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
|
|
340
|
-
const child =
|
|
422
|
+
const child = spawnBinary(binary, args, {
|
|
341
423
|
stdio: ["pipe", "pipe", "pipe"],
|
|
342
424
|
...bedrockEnv ? { env: { ...process.env, ...bedrockEnv } } : {}
|
|
343
425
|
});
|
|
@@ -390,20 +472,13 @@ async function runAgent(options) {
|
|
|
390
472
|
}
|
|
391
473
|
async function checkAgentAuth(agent) {
|
|
392
474
|
const binary = resolveBinary(agent);
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
import("node:fs/promises").then((fs2) => fs2.access(binary).then(() => resolve29(true), () => resolve29(false)));
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
const child = spawn("which", [binary], { stdio: "ignore" });
|
|
399
|
-
child.on("close", (code) => resolve29(code === 0));
|
|
400
|
-
});
|
|
401
|
-
if (!binaryExists2)
|
|
475
|
+
const resolvedBinary = findBinary(binary);
|
|
476
|
+
if (!resolvedBinary)
|
|
402
477
|
return "not-found";
|
|
403
478
|
if (agent !== "claude")
|
|
404
479
|
return "ok";
|
|
405
480
|
return new Promise((resolve29) => {
|
|
406
|
-
const child =
|
|
481
|
+
const child = spawnBinary(resolvedBinary, ["auth", "status", "--json"], {
|
|
407
482
|
stdio: ["ignore", "pipe", "pipe"]
|
|
408
483
|
});
|
|
409
484
|
let stdout = "";
|
|
@@ -457,10 +532,11 @@ function extractSentinelOutput(stdout) {
|
|
|
457
532
|
return "multiple";
|
|
458
533
|
return stdout.slice(startIdx + START.length, endIdx).trim();
|
|
459
534
|
}
|
|
460
|
-
var VALID_SELECT_TOOL_NAMES, VALID_TOOL_NAMES, VALID_TOKEN_TOOL_NAMES, VALID_CDF_TYPES, VALID_CATEGORIES, AGENT_BINARIES, BEDROCK_ENV_BY_AGENT, BEDROCK_CAPABLE_AGENTS, DEFAULT_CODEX_BEDROCK_REGION, DEFAULT_OPENCODE_MODEL, DEFAULT_MODELS, DEFAULT_CODEX_BEDROCK_MODEL;
|
|
535
|
+
var VALID_SELECT_TOOL_NAMES, VALID_TOOL_NAMES, VALID_TOKEN_TOOL_NAMES, VALID_CDF_TYPES, VALID_CATEGORIES, AGENT_BINARIES, BEDROCK_ENV_BY_AGENT, BEDROCK_CAPABLE_AGENTS, DEFAULT_CODEX_BEDROCK_REGION, DEFAULT_OPENCODE_MODEL, DEFAULT_MODELS, DEFAULT_CODEX_BEDROCK_MODEL, STDIN_CAPABLE_AGENTS, ARGV_PROMPT_LIMIT;
|
|
461
536
|
var init_agent_runner = __esm({
|
|
462
537
|
"packages/experience-design-system-generation/dist/src/agent-runner.js"() {
|
|
463
538
|
"use strict";
|
|
539
|
+
init_binary_launch();
|
|
464
540
|
init_agent_names();
|
|
465
541
|
VALID_SELECT_TOOL_NAMES = /* @__PURE__ */ new Set(["select_component", "reject_component"]);
|
|
466
542
|
VALID_TOOL_NAMES = /* @__PURE__ */ new Set(["classify_prop", "exclude_prop", "classify_component", "classify_slot"]);
|
|
@@ -489,6 +565,8 @@ var init_agent_runner = __esm({
|
|
|
489
565
|
// the only model guaranteed on every Copilot plan (Free/Pro/Business/Enterprise); Pro+ users override via EDS_AGENT_MODEL_COPILOT
|
|
490
566
|
};
|
|
491
567
|
DEFAULT_CODEX_BEDROCK_MODEL = "openai.gpt-5.6-luna";
|
|
568
|
+
STDIN_CAPABLE_AGENTS = /* @__PURE__ */ new Set(["claude", "codex", "opencode", "cursor"]);
|
|
569
|
+
ARGV_PROMPT_LIMIT = 4096;
|
|
492
570
|
}
|
|
493
571
|
});
|
|
494
572
|
|
|
@@ -514,7 +592,7 @@ var init_agent_invoker = __esm({
|
|
|
514
592
|
// packages/experience-design-system-generation/dist/src/prompt-builder.js
|
|
515
593
|
import { existsSync } from "node:fs";
|
|
516
594
|
import { readFile } from "node:fs/promises";
|
|
517
|
-
import { dirname, join, resolve } from "node:path";
|
|
595
|
+
import { dirname, join as join2, resolve } from "node:path";
|
|
518
596
|
import { fileURLToPath } from "node:url";
|
|
519
597
|
import { flattenDTCG } from "@contentful/experience-design-system-types";
|
|
520
598
|
function formatCustomPromptBanner(skill, path) {
|
|
@@ -538,9 +616,9 @@ function resolveSkillPath(skill) {
|
|
|
538
616
|
const thisDir = dirname(fileURLToPath(import.meta.url));
|
|
539
617
|
let dir = thisDir;
|
|
540
618
|
for (; ; ) {
|
|
541
|
-
const candidate =
|
|
619
|
+
const candidate = join2(dir, "skills");
|
|
542
620
|
if (existsSync(candidate))
|
|
543
|
-
return
|
|
621
|
+
return join2(candidate, SKILL_FILES[skill]);
|
|
544
622
|
const parent = resolve(dir, "..");
|
|
545
623
|
if (parent === dir) {
|
|
546
624
|
throw new Error(`skill file missing from CLI installation (could not locate skills/ directory from: ${thisDir})`);
|
|
@@ -891,12 +969,15 @@ __export(src_exports, {
|
|
|
891
969
|
AGENT_NAMES: () => AGENT_NAMES,
|
|
892
970
|
DEFAULT_AGENT_NAME: () => DEFAULT_AGENT_NAME,
|
|
893
971
|
agentSupportsBedrock: () => agentSupportsBedrock,
|
|
972
|
+
agentSupportsStdinPrompt: () => agentSupportsStdinPrompt,
|
|
973
|
+
binaryExists: () => binaryExists,
|
|
894
974
|
buildArgs: () => buildArgs,
|
|
895
975
|
buildPrompt: () => buildPrompt,
|
|
896
976
|
checkAgentAuth: () => checkAgentAuth,
|
|
897
977
|
createLocalCliAgentInvoker: () => createLocalCliAgentInvoker,
|
|
898
978
|
describeAgentFailure: () => describeAgentFailure,
|
|
899
979
|
extractSentinelOutput: () => extractSentinelOutput,
|
|
980
|
+
findBinary: () => findBinary,
|
|
900
981
|
formatCustomPromptBanner: () => formatCustomPromptBanner,
|
|
901
982
|
formatGenerateProgressLine: () => formatGenerateProgressLine,
|
|
902
983
|
isAgentName: () => isAgentName,
|
|
@@ -904,10 +985,13 @@ __export(src_exports, {
|
|
|
904
985
|
parseSelectToolCallLines: () => parseSelectToolCallLines,
|
|
905
986
|
parseTokenToolCallLines: () => parseTokenToolCallLines,
|
|
906
987
|
parseToolCallLines: () => parseToolCallLines,
|
|
988
|
+
promptExceedsArgvLimit: () => promptExceedsArgvLimit,
|
|
907
989
|
resolveAgentModel: () => resolveAgentModel,
|
|
908
990
|
resolveBinary: () => resolveBinary,
|
|
909
991
|
resolveSkillPath: () => resolveSkillPath,
|
|
910
|
-
runAgent: () => runAgent
|
|
992
|
+
runAgent: () => runAgent,
|
|
993
|
+
shouldUseStdinPrompt: () => shouldUseStdinPrompt,
|
|
994
|
+
spawnBinary: () => spawnBinary
|
|
911
995
|
});
|
|
912
996
|
var init_src = __esm({
|
|
913
997
|
"packages/experience-design-system-generation/dist/src/index.js"() {
|
|
@@ -917,6 +1001,7 @@ var init_src = __esm({
|
|
|
917
1001
|
init_agent_invoker();
|
|
918
1002
|
init_prompt_builder();
|
|
919
1003
|
init_progress();
|
|
1004
|
+
init_binary_launch();
|
|
920
1005
|
}
|
|
921
1006
|
});
|
|
922
1007
|
|
|
@@ -932,7 +1017,7 @@ var init_types = __esm({
|
|
|
932
1017
|
|
|
933
1018
|
// packages/experience-design-system-extraction/dist/src/extract/tsx-shared.js
|
|
934
1019
|
import { existsSync as existsSync2, readFileSync } from "node:fs";
|
|
935
|
-
import { dirname as dirname2, join as
|
|
1020
|
+
import { dirname as dirname2, join as join3, resolve as resolve2 } from "node:path";
|
|
936
1021
|
import { Node, Project, SyntaxKind } from "ts-morph";
|
|
937
1022
|
import ts from "typescript";
|
|
938
1023
|
function createTsxProject(filePaths) {
|
|
@@ -1089,7 +1174,7 @@ function findNearestTsConfigPath(filePath) {
|
|
|
1089
1174
|
let currentDir = dirname2(filePath);
|
|
1090
1175
|
while (true) {
|
|
1091
1176
|
for (const candidateName of ["tsconfig.json", "jsconfig.json"]) {
|
|
1092
|
-
const candidatePath =
|
|
1177
|
+
const candidatePath = join3(currentDir, candidateName);
|
|
1093
1178
|
if (existsSync2(candidatePath)) {
|
|
1094
1179
|
nearestTsConfigPathCache.set(filePath, candidatePath);
|
|
1095
1180
|
return candidatePath;
|
|
@@ -1146,10 +1231,10 @@ function resolveImportSourcePath(basePath) {
|
|
|
1146
1231
|
`${basePath}.tsx`,
|
|
1147
1232
|
`${basePath}.js`,
|
|
1148
1233
|
`${basePath}.jsx`,
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1234
|
+
join3(basePath, "index.ts"),
|
|
1235
|
+
join3(basePath, "index.tsx"),
|
|
1236
|
+
join3(basePath, "index.js"),
|
|
1237
|
+
join3(basePath, "index.jsx")
|
|
1153
1238
|
];
|
|
1154
1239
|
return candidates.find((candidatePath) => existsSync2(candidatePath));
|
|
1155
1240
|
}
|
|
@@ -1160,10 +1245,10 @@ function findProjectSourceFileByImportPath(project, resolvedPath) {
|
|
|
1160
1245
|
`${resolvedPath}.tsx`,
|
|
1161
1246
|
`${resolvedPath}.js`,
|
|
1162
1247
|
`${resolvedPath}.jsx`,
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1248
|
+
join3(resolvedPath, "index.ts"),
|
|
1249
|
+
join3(resolvedPath, "index.tsx"),
|
|
1250
|
+
join3(resolvedPath, "index.js"),
|
|
1251
|
+
join3(resolvedPath, "index.jsx")
|
|
1167
1252
|
];
|
|
1168
1253
|
for (const candidatePath of candidatePaths) {
|
|
1169
1254
|
const sourceFile = project.getSourceFile(candidatePath);
|
|
@@ -1184,10 +1269,10 @@ function findWorkspacePackageEntrySourceFile(originSourceFile, moduleSpecifier)
|
|
|
1184
1269
|
if (!packageRootDir)
|
|
1185
1270
|
return void 0;
|
|
1186
1271
|
const preferredEntryPaths = [
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1272
|
+
join3(packageRootDir, "src/index.ts"),
|
|
1273
|
+
join3(packageRootDir, "src/index.tsx"),
|
|
1274
|
+
join3(packageRootDir, "index.ts"),
|
|
1275
|
+
join3(packageRootDir, "index.tsx")
|
|
1191
1276
|
];
|
|
1192
1277
|
for (const entryPath of preferredEntryPaths) {
|
|
1193
1278
|
const entrySourceFile = project.getSourceFile(entryPath);
|
|
@@ -1195,7 +1280,7 @@ function findWorkspacePackageEntrySourceFile(originSourceFile, moduleSpecifier)
|
|
|
1195
1280
|
return entrySourceFile;
|
|
1196
1281
|
}
|
|
1197
1282
|
}
|
|
1198
|
-
return candidateSourceFiles.find((sourceFile) => sourceFile.getDirectoryPath() ===
|
|
1283
|
+
return candidateSourceFiles.find((sourceFile) => sourceFile.getDirectoryPath() === join3(packageRootDir, "src"));
|
|
1199
1284
|
}
|
|
1200
1285
|
function getWorkspacePackageManifestForSourceFile(sourceFile) {
|
|
1201
1286
|
const packageRootDir = findNearestPackageRootDir(sourceFile.getFilePath());
|
|
@@ -1204,7 +1289,7 @@ function getWorkspacePackageManifestForSourceFile(sourceFile) {
|
|
|
1204
1289
|
if (workspacePackageManifestCache.has(packageRootDir)) {
|
|
1205
1290
|
return workspacePackageManifestCache.get(packageRootDir) ?? void 0;
|
|
1206
1291
|
}
|
|
1207
|
-
const packageJsonPath =
|
|
1292
|
+
const packageJsonPath = join3(packageRootDir, "package.json");
|
|
1208
1293
|
try {
|
|
1209
1294
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
1210
1295
|
const manifest = typeof packageJson.name === "string" ? { name: packageJson.name, rootDir: packageRootDir } : null;
|
|
@@ -1221,7 +1306,7 @@ function findNearestPackageRootDir(filePath) {
|
|
|
1221
1306
|
}
|
|
1222
1307
|
let currentDir = dirname2(filePath);
|
|
1223
1308
|
while (true) {
|
|
1224
|
-
if (existsSync2(
|
|
1309
|
+
if (existsSync2(join3(currentDir, "package.json"))) {
|
|
1225
1310
|
packageRootByFilePathCache.set(filePath, currentDir);
|
|
1226
1311
|
return currentDir;
|
|
1227
1312
|
}
|
|
@@ -4221,7 +4306,7 @@ var init_vue_tsx = __esm({
|
|
|
4221
4306
|
|
|
4222
4307
|
// packages/experience-design-system-extraction/dist/src/extract/resolve-local-module.js
|
|
4223
4308
|
import { existsSync as existsSync3, statSync } from "node:fs";
|
|
4224
|
-
import { dirname as dirname3, join as
|
|
4309
|
+
import { dirname as dirname3, join as join4, resolve as resolve3 } from "node:path";
|
|
4225
4310
|
function resolveLocalModule(importingFilePath, specifier, options = {}) {
|
|
4226
4311
|
const basePath = resolve3(dirname3(importingFilePath), specifier);
|
|
4227
4312
|
const candidates = [
|
|
@@ -4230,10 +4315,10 @@ function resolveLocalModule(importingFilePath, specifier, options = {}) {
|
|
|
4230
4315
|
`${basePath}.ts`,
|
|
4231
4316
|
`${basePath}.mjs`,
|
|
4232
4317
|
`${basePath}.cjs`,
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4318
|
+
join4(basePath, "index.js"),
|
|
4319
|
+
join4(basePath, "index.ts"),
|
|
4320
|
+
join4(basePath, "index.mjs"),
|
|
4321
|
+
join4(basePath, "index.cjs")
|
|
4237
4322
|
];
|
|
4238
4323
|
for (const candidate of candidates) {
|
|
4239
4324
|
if (existsSync3(candidate) && statSync(candidate).isFile())
|
|
@@ -4271,7 +4356,7 @@ var init_resolve_type_property = __esm({
|
|
|
4271
4356
|
});
|
|
4272
4357
|
|
|
4273
4358
|
// packages/experience-design-system-extraction/dist/src/extract/vue.js
|
|
4274
|
-
import { basename, dirname as dirname4, resolve as resolve4, join as
|
|
4359
|
+
import { basename, dirname as dirname4, resolve as resolve4, join as join5 } from "node:path";
|
|
4275
4360
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
4276
4361
|
import { existsSync as existsSync4, readFileSync as readFileSync2, readdirSync, statSync as statSync2 } from "node:fs";
|
|
4277
4362
|
import os from "node:os";
|
|
@@ -4487,11 +4572,11 @@ function findWorkspaceRoot(startDir) {
|
|
|
4487
4572
|
return workspaceRootCache.get(startDir);
|
|
4488
4573
|
let dir = startDir;
|
|
4489
4574
|
while (true) {
|
|
4490
|
-
const pkgJsonPath =
|
|
4575
|
+
const pkgJsonPath = join5(dir, "package.json");
|
|
4491
4576
|
if (existsSync4(pkgJsonPath)) {
|
|
4492
4577
|
try {
|
|
4493
4578
|
const pkg4 = JSON.parse(readFileSync2(pkgJsonPath, "utf8"));
|
|
4494
|
-
if (pkg4.workspaces || existsSync4(
|
|
4579
|
+
if (pkg4.workspaces || existsSync4(join5(dir, "pnpm-workspace.yaml"))) {
|
|
4495
4580
|
workspaceRootCache.set(startDir, dir);
|
|
4496
4581
|
return dir;
|
|
4497
4582
|
}
|
|
@@ -4511,7 +4596,7 @@ function getWorkspacePackageDirs(workspaceRoot) {
|
|
|
4511
4596
|
return workspacePackageDirsCache.get(workspaceRoot);
|
|
4512
4597
|
}
|
|
4513
4598
|
const packageMap = /* @__PURE__ */ new Map();
|
|
4514
|
-
const packagesDir =
|
|
4599
|
+
const packagesDir = join5(workspaceRoot, "packages");
|
|
4515
4600
|
if (!existsSync4(packagesDir)) {
|
|
4516
4601
|
workspacePackageDirsCache.set(workspaceRoot, packageMap);
|
|
4517
4602
|
return packageMap;
|
|
@@ -4525,7 +4610,7 @@ function getWorkspacePackageDirs(workspaceRoot) {
|
|
|
4525
4610
|
} catch {
|
|
4526
4611
|
return;
|
|
4527
4612
|
}
|
|
4528
|
-
const pkgJsonPath =
|
|
4613
|
+
const pkgJsonPath = join5(dir, "package.json");
|
|
4529
4614
|
if (existsSync4(pkgJsonPath)) {
|
|
4530
4615
|
try {
|
|
4531
4616
|
const pkg4 = JSON.parse(readFileSync2(pkgJsonPath, "utf8"));
|
|
@@ -4538,7 +4623,7 @@ function getWorkspacePackageDirs(workspaceRoot) {
|
|
|
4538
4623
|
for (const entry of entries) {
|
|
4539
4624
|
if (entry === "node_modules" || entry === ".git" || entry.startsWith("."))
|
|
4540
4625
|
continue;
|
|
4541
|
-
const entryPath =
|
|
4626
|
+
const entryPath = join5(dir, entry);
|
|
4542
4627
|
try {
|
|
4543
4628
|
const stat8 = statSync2(entryPath);
|
|
4544
4629
|
if (stat8.isDirectory()) {
|
|
@@ -4578,7 +4663,7 @@ function resolveWorkspaceVueImport(specifier, importingFilePath) {
|
|
|
4578
4663
|
const packageDir = packageDirs.get(packageName);
|
|
4579
4664
|
if (!packageDir)
|
|
4580
4665
|
return null;
|
|
4581
|
-
const pkgJsonPath =
|
|
4666
|
+
const pkgJsonPath = join5(packageDir, "package.json");
|
|
4582
4667
|
try {
|
|
4583
4668
|
const pkg4 = JSON.parse(readFileSync2(pkgJsonPath, "utf8"));
|
|
4584
4669
|
if (pkg4.exports && subpath !== ".") {
|
|
@@ -4591,8 +4676,8 @@ function resolveWorkspaceVueImport(specifier, importingFilePath) {
|
|
|
4591
4676
|
}
|
|
4592
4677
|
if (subpath !== ".") {
|
|
4593
4678
|
const subDir = resolve4(packageDir, subpath.replace(/^\.\//, ""));
|
|
4594
|
-
for (const base of [
|
|
4595
|
-
const subPkgPath =
|
|
4679
|
+
for (const base of [join5(packageDir, "src", subpath.replace(/^\.\//, "")), subDir]) {
|
|
4680
|
+
const subPkgPath = join5(base, "package.json");
|
|
4596
4681
|
if (existsSync4(subPkgPath)) {
|
|
4597
4682
|
try {
|
|
4598
4683
|
const subPkg = JSON.parse(readFileSync2(subPkgPath, "utf8"));
|
|
@@ -5056,7 +5141,7 @@ var init_astro = __esm({
|
|
|
5056
5141
|
});
|
|
5057
5142
|
|
|
5058
5143
|
// packages/experience-design-system-extraction/dist/src/extract/web-components.js
|
|
5059
|
-
import { basename as basename3, dirname as dirname5, join as
|
|
5144
|
+
import { basename as basename3, dirname as dirname5, join as join6, resolve as resolve5 } from "node:path";
|
|
5060
5145
|
import { Project as Project5, Node as Node8, SyntaxKind as SyntaxKind6 } from "ts-morph";
|
|
5061
5146
|
function normalizeComponentName(input) {
|
|
5062
5147
|
return input.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
|
|
@@ -5709,14 +5794,14 @@ function resolveImportSourcePath2(fromFilePath, specifier) {
|
|
|
5709
5794
|
if (!specifier.startsWith(spectrumPrefix)) {
|
|
5710
5795
|
return null;
|
|
5711
5796
|
}
|
|
5712
|
-
const packagesMarker = `${
|
|
5797
|
+
const packagesMarker = `${join6("2nd-gen", "packages")}${fromFilePath.includes("\\") ? "\\" : "/"}`;
|
|
5713
5798
|
const markerIndex = fromFilePath.lastIndexOf(packagesMarker);
|
|
5714
5799
|
if (markerIndex === -1) {
|
|
5715
5800
|
return null;
|
|
5716
5801
|
}
|
|
5717
5802
|
const packagesRoot = fromFilePath.slice(0, markerIndex + packagesMarker.length - 1);
|
|
5718
5803
|
const componentPath = specifier.slice(spectrumPrefix.length);
|
|
5719
|
-
return
|
|
5804
|
+
return join6(packagesRoot, "core", "components", componentPath, "index.ts");
|
|
5720
5805
|
}
|
|
5721
5806
|
function getImportedBaseClass(classDecl, project, visitedFiles) {
|
|
5722
5807
|
const extendsClause = classDecl.getHeritageClauses().find((clause) => clause.getToken() === SyntaxKind6.ExtendsKeyword);
|
|
@@ -5982,7 +6067,7 @@ var init_scoring = __esm({
|
|
|
5982
6067
|
});
|
|
5983
6068
|
|
|
5984
6069
|
// packages/experience-design-system-extraction/dist/src/extract/svelte.js
|
|
5985
|
-
import { basename as basename4, dirname as dirname6, resolve as resolve6, join as
|
|
6070
|
+
import { basename as basename4, dirname as dirname6, resolve as resolve6, join as join7 } from "node:path";
|
|
5986
6071
|
import { existsSync as existsSync5, readFileSync as readFileSync3 } from "node:fs";
|
|
5987
6072
|
import { createRequire } from "node:module";
|
|
5988
6073
|
import os3 from "node:os";
|
|
@@ -6117,7 +6202,7 @@ async function maybeRunResolveUnreachableRetry(components, warnings, retryContex
|
|
|
6117
6202
|
function findNearestTsconfig(startDir) {
|
|
6118
6203
|
let dir = startDir;
|
|
6119
6204
|
for (let i = 0; i < 16; i++) {
|
|
6120
|
-
const candidate =
|
|
6205
|
+
const candidate = join7(dir, "tsconfig.json");
|
|
6121
6206
|
if (existsSync5(candidate))
|
|
6122
6207
|
return candidate;
|
|
6123
6208
|
const parent = dirname6(dir);
|
|
@@ -6253,7 +6338,7 @@ function locateDtsForSpecifier(req, specifier, parentFile) {
|
|
|
6253
6338
|
const seedDir = resolvedJs ? dirname6(resolvedJs) : dirname6(parentFile);
|
|
6254
6339
|
const pkgRoot = findPackageRootForSpecifier(seedDir, specifier);
|
|
6255
6340
|
if (pkgRoot) {
|
|
6256
|
-
const pkgJsonPath =
|
|
6341
|
+
const pkgJsonPath = join7(pkgRoot, "package.json");
|
|
6257
6342
|
if (existsSync5(pkgJsonPath)) {
|
|
6258
6343
|
try {
|
|
6259
6344
|
const pkgRaw = readFileSync3(pkgJsonPath, "utf-8");
|
|
@@ -6274,7 +6359,7 @@ function locateDtsForSpecifier(req, specifier, parentFile) {
|
|
|
6274
6359
|
}
|
|
6275
6360
|
}
|
|
6276
6361
|
for (const entry of ["index.d.ts", "index.d.mts"]) {
|
|
6277
|
-
const candidate =
|
|
6362
|
+
const candidate = join7(pkgRoot, entry);
|
|
6278
6363
|
if (existsSync5(candidate))
|
|
6279
6364
|
return candidate;
|
|
6280
6365
|
}
|
|
@@ -6292,9 +6377,9 @@ function locateDtsForSpecifier(req, specifier, parentFile) {
|
|
|
6292
6377
|
function findPackageRootForSpecifier(seedDir, specifier) {
|
|
6293
6378
|
let dir = seedDir;
|
|
6294
6379
|
for (let i = 0; i < 32; i++) {
|
|
6295
|
-
if (existsSync5(
|
|
6380
|
+
if (existsSync5(join7(dir, "package.json"))) {
|
|
6296
6381
|
try {
|
|
6297
|
-
const pkgRaw = readFileSync3(
|
|
6382
|
+
const pkgRaw = readFileSync3(join7(dir, "package.json"), "utf-8");
|
|
6298
6383
|
const pkg4 = JSON.parse(pkgRaw);
|
|
6299
6384
|
if (pkg4.name === specifier)
|
|
6300
6385
|
return dir;
|
|
@@ -7269,11 +7354,11 @@ function getPathPreferenceScore(filePath) {
|
|
|
7269
7354
|
const normalized = filePath.replace(/\\/g, "/");
|
|
7270
7355
|
const segments = normalized.split("/").filter(Boolean);
|
|
7271
7356
|
const filename = segments.at(-1) ?? "";
|
|
7272
|
-
const
|
|
7357
|
+
const basename8 = filename.replace(/\.[^.]+$/, "");
|
|
7273
7358
|
let score = 0;
|
|
7274
7359
|
if (/^index\.[jt]sx?$/.test(filename))
|
|
7275
7360
|
score += 100;
|
|
7276
|
-
if (
|
|
7361
|
+
if (basename8 && segments.at(-2) === basename8)
|
|
7277
7362
|
score -= 10;
|
|
7278
7363
|
const componentsSegmentCount = segments.filter((segment) => segment === "components").length;
|
|
7279
7364
|
score -= componentsSegmentCount * 8;
|
|
@@ -8105,18 +8190,18 @@ var init_src2 = __esm({
|
|
|
8105
8190
|
|
|
8106
8191
|
// packages/experience-design-system-cli/src/lib/cli-path.ts
|
|
8107
8192
|
import { existsSync as existsSync6 } from "node:fs";
|
|
8108
|
-
import { dirname as dirname7, join as
|
|
8193
|
+
import { dirname as dirname7, join as join8 } from "node:path";
|
|
8109
8194
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8110
8195
|
function findCliPath() {
|
|
8111
8196
|
let dir = dirname7(fileURLToPath2(import.meta.url));
|
|
8112
8197
|
for (let i = 0; i < 8; i++) {
|
|
8113
|
-
const candidate =
|
|
8198
|
+
const candidate = join8(dir, "bin", "cli.js");
|
|
8114
8199
|
if (existsSync6(candidate)) return candidate;
|
|
8115
8200
|
const parent = dirname7(dir);
|
|
8116
8201
|
if (parent === dir) break;
|
|
8117
8202
|
dir = parent;
|
|
8118
8203
|
}
|
|
8119
|
-
return
|
|
8204
|
+
return join8(fileURLToPath2(import.meta.url), "..", "..", "..", "..", "bin", "cli.js");
|
|
8120
8205
|
}
|
|
8121
8206
|
function findPkgRoot() {
|
|
8122
8207
|
return dirname7(dirname7(findCliPath()));
|
|
@@ -8129,7 +8214,7 @@ var init_cli_path = __esm({
|
|
|
8129
8214
|
|
|
8130
8215
|
// packages/experience-design-system-cli/src/analyze/select/tui/components/TopBar.tsx
|
|
8131
8216
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
8132
|
-
import { join as
|
|
8217
|
+
import { join as join9 } from "node:path";
|
|
8133
8218
|
import { Box, Text } from "ink";
|
|
8134
8219
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8135
8220
|
function TopBar({ subcommand, hints }) {
|
|
@@ -8146,7 +8231,7 @@ var init_TopBar = __esm({
|
|
|
8146
8231
|
"packages/experience-design-system-cli/src/analyze/select/tui/components/TopBar.tsx"() {
|
|
8147
8232
|
"use strict";
|
|
8148
8233
|
init_cli_path();
|
|
8149
|
-
VERSION = JSON.parse(readFileSync4(
|
|
8234
|
+
VERSION = JSON.parse(readFileSync4(join9(findPkgRoot(), "package.json"), "utf8")).version;
|
|
8150
8235
|
}
|
|
8151
8236
|
});
|
|
8152
8237
|
|
|
@@ -10943,13 +11028,13 @@ var init_persistence = __esm({
|
|
|
10943
11028
|
// packages/experience-design-system-cli/src/analyze/select/parser.ts
|
|
10944
11029
|
import { createHash as createHash6 } from "node:crypto";
|
|
10945
11030
|
import { access as access2 } from "node:fs/promises";
|
|
10946
|
-
import { isAbsolute, relative, resolve as resolve10 } from "node:path";
|
|
11031
|
+
import { isAbsolute as isAbsolute2, relative, resolve as resolve10 } from "node:path";
|
|
10947
11032
|
function createComponentId(name, resolvedSourcePath) {
|
|
10948
11033
|
const sourceHash = createHash6("sha256").update(`${name}:${resolvedSourcePath}`).digest("hex").slice(0, 12);
|
|
10949
11034
|
return `${name}-${sourceHash}`;
|
|
10950
11035
|
}
|
|
10951
11036
|
async function resolveComponentSourcePath(source, reviewRoot) {
|
|
10952
|
-
if (
|
|
11037
|
+
if (isAbsolute2(source)) {
|
|
10953
11038
|
try {
|
|
10954
11039
|
await access2(source);
|
|
10955
11040
|
return source;
|
|
@@ -10959,7 +11044,7 @@ async function resolveComponentSourcePath(source, reviewRoot) {
|
|
|
10959
11044
|
}
|
|
10960
11045
|
const candidate = resolve10(reviewRoot, source);
|
|
10961
11046
|
const relativeToRoot = relative(reviewRoot, candidate);
|
|
10962
|
-
if (relativeToRoot.startsWith("..") || relativeToRoot === ".." ||
|
|
11047
|
+
if (relativeToRoot.startsWith("..") || relativeToRoot === ".." || isAbsolute2(relativeToRoot)) {
|
|
10963
11048
|
throw new Error(
|
|
10964
11049
|
`Resolved component source is outside the review root: ${source}. Pass --project-root <path> to set the correct base.`
|
|
10965
11050
|
);
|
|
@@ -12750,7 +12835,7 @@ var init_host_utils = __esm({
|
|
|
12750
12835
|
|
|
12751
12836
|
// packages/experience-design-system-cli/src/lib/debug-logger.ts
|
|
12752
12837
|
import { mkdirSync as mkdirSync2, appendFileSync } from "node:fs";
|
|
12753
|
-
import { join as
|
|
12838
|
+
import { join as join10, dirname as dirname9 } from "node:path";
|
|
12754
12839
|
import { homedir as homedir3 } from "node:os";
|
|
12755
12840
|
function redactValue(value, seen) {
|
|
12756
12841
|
if (value === null || value === void 0) return value;
|
|
@@ -12776,7 +12861,7 @@ function redactForDebug(payload) {
|
|
|
12776
12861
|
return redactValue(payload, /* @__PURE__ */ new WeakSet());
|
|
12777
12862
|
}
|
|
12778
12863
|
function defaultDebugRoot() {
|
|
12779
|
-
return process.env[DEBUG_ROOT_ENV] ??
|
|
12864
|
+
return process.env[DEBUG_ROOT_ENV] ?? join10(homedir3(), ".contentful", "experience-design-system-cli", "debug");
|
|
12780
12865
|
}
|
|
12781
12866
|
function makeSessionTimestamp() {
|
|
12782
12867
|
const override = process.env["EDSI_DEBUG_TS"];
|
|
@@ -12800,7 +12885,7 @@ function initDebugLogger(opts) {
|
|
|
12800
12885
|
const root = opts.root ?? defaultDebugRoot();
|
|
12801
12886
|
const ts3 = makeSessionTimestamp();
|
|
12802
12887
|
const suffix = opts.command ? `-${opts.command}` : "";
|
|
12803
|
-
const path =
|
|
12888
|
+
const path = join10(root, `${ts3}${suffix}.jsonl`);
|
|
12804
12889
|
singleton = new FileDebugLogger(path);
|
|
12805
12890
|
process.env[DEBUG_LOG_ENV] = path;
|
|
12806
12891
|
if (opts.command) singleton.event("config", "command.start", { command: opts.command });
|
|
@@ -12921,7 +13006,7 @@ var init_debug_logger = __esm({
|
|
|
12921
13006
|
|
|
12922
13007
|
// packages/experience-design-system-cli/src/lib/user-agent.ts
|
|
12923
13008
|
import { readFileSync as readFileSync6 } from "node:fs";
|
|
12924
|
-
import { join as
|
|
13009
|
+
import { join as join11 } from "node:path";
|
|
12925
13010
|
function buildUserAgent(version = pkg.version) {
|
|
12926
13011
|
const parts = [`app ${APP}/${version}`, `platform node.js/${process.version}`];
|
|
12927
13012
|
const os4 = OS_NAMES[process.platform];
|
|
@@ -12933,7 +13018,7 @@ var init_user_agent = __esm({
|
|
|
12933
13018
|
"packages/experience-design-system-cli/src/lib/user-agent.ts"() {
|
|
12934
13019
|
"use strict";
|
|
12935
13020
|
init_cli_path();
|
|
12936
|
-
pkg = JSON.parse(readFileSync6(
|
|
13021
|
+
pkg = JSON.parse(readFileSync6(join11(findPkgRoot(), "package.json"), "utf8"));
|
|
12937
13022
|
APP = "contentful.experience-design-system-cli";
|
|
12938
13023
|
OS_NAMES = {
|
|
12939
13024
|
android: "Android",
|
|
@@ -14379,7 +14464,7 @@ __export(credentials_store_exports, {
|
|
|
14379
14464
|
writeExperiencesCredentials: () => writeExperiencesCredentials
|
|
14380
14465
|
});
|
|
14381
14466
|
import { readFile as readFile8, writeFile as writeFile2, mkdir as mkdir2 } from "node:fs/promises";
|
|
14382
|
-
import { join as
|
|
14467
|
+
import { join as join12 } from "node:path";
|
|
14383
14468
|
import { homedir as homedir4 } from "node:os";
|
|
14384
14469
|
async function readExperiencesCredentials() {
|
|
14385
14470
|
try {
|
|
@@ -14455,14 +14540,14 @@ var init_credentials_store = __esm({
|
|
|
14455
14540
|
"use strict";
|
|
14456
14541
|
init_host_utils();
|
|
14457
14542
|
init_composition_mode();
|
|
14458
|
-
CREDENTIALS_DIR =
|
|
14459
|
-
CREDENTIALS_PATH =
|
|
14543
|
+
CREDENTIALS_DIR = join12(homedir4(), ".config", "experiences");
|
|
14544
|
+
CREDENTIALS_PATH = join12(CREDENTIALS_DIR, "credentials.json");
|
|
14460
14545
|
}
|
|
14461
14546
|
});
|
|
14462
14547
|
|
|
14463
14548
|
// packages/experience-design-system-cli/src/analytics/client.ts
|
|
14464
14549
|
import { readFileSync as readFileSync7 } from "node:fs";
|
|
14465
|
-
import { join as
|
|
14550
|
+
import { join as join13 } from "node:path";
|
|
14466
14551
|
import { Analytics } from "@segment/analytics-node";
|
|
14467
14552
|
function cliVersion() {
|
|
14468
14553
|
return pkg2.version;
|
|
@@ -14516,7 +14601,7 @@ var init_client2 = __esm({
|
|
|
14516
14601
|
"packages/experience-design-system-cli/src/analytics/client.ts"() {
|
|
14517
14602
|
"use strict";
|
|
14518
14603
|
init_cli_path();
|
|
14519
|
-
pkg2 = JSON.parse(readFileSync7(
|
|
14604
|
+
pkg2 = JSON.parse(readFileSync7(join13(findPkgRoot(), "package.json"), "utf8"));
|
|
14520
14605
|
DEFAULT_WRITE_KEY = "6DmxiEPN3SV1vbRTTMcNqDzCvkfwT06N";
|
|
14521
14606
|
analyticsClient = null;
|
|
14522
14607
|
persistedDisabled = false;
|
|
@@ -14813,7 +14898,7 @@ var init_path_exists = __esm({
|
|
|
14813
14898
|
import { createElement, useState as useState6 } from "react";
|
|
14814
14899
|
import { render, useInput as useInput2 } from "ink";
|
|
14815
14900
|
import { readFile as readFile9, readdir, stat } from "node:fs/promises";
|
|
14816
|
-
import { join as
|
|
14901
|
+
import { join as join14 } from "node:path";
|
|
14817
14902
|
import {
|
|
14818
14903
|
validateCDF,
|
|
14819
14904
|
flattenDTCG as flattenDTCG2,
|
|
@@ -14857,7 +14942,7 @@ async function collectJsonFiles(dir) {
|
|
|
14857
14942
|
await Promise.all(
|
|
14858
14943
|
entries.map(async (entry) => {
|
|
14859
14944
|
if (IGNORE_TOKEN_DIRS.has(entry)) return;
|
|
14860
|
-
const full =
|
|
14945
|
+
const full = join14(current, entry);
|
|
14861
14946
|
let s;
|
|
14862
14947
|
try {
|
|
14863
14948
|
s = await stat(full);
|
|
@@ -16678,7 +16763,7 @@ var init_fetch_existing_contentful_entities = __esm({
|
|
|
16678
16763
|
|
|
16679
16764
|
// packages/experience-design-system-cli/src/helpers/fetch-and-persist-existing-contentful-entities.ts
|
|
16680
16765
|
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
16681
|
-
import { join as
|
|
16766
|
+
import { join as join20 } from "node:path";
|
|
16682
16767
|
async function fetchAndPersistExistingContentfulEntities(params) {
|
|
16683
16768
|
const t0 = Date.now();
|
|
16684
16769
|
try {
|
|
@@ -16690,7 +16775,7 @@ async function fetchAndPersistExistingContentfulEntities(params) {
|
|
|
16690
16775
|
spaceId: params.spaceId,
|
|
16691
16776
|
environmentId: params.environmentId
|
|
16692
16777
|
});
|
|
16693
|
-
const path =
|
|
16778
|
+
const path = join20(params.outDir, ".existing-entities.json");
|
|
16694
16779
|
await writeFile5(path, JSON.stringify(entities, null, 2), "utf8");
|
|
16695
16780
|
return { ok: true, path, durationMs: Date.now() - t0, entities };
|
|
16696
16781
|
} catch (error) {
|
|
@@ -16711,7 +16796,7 @@ var init_fetch_and_persist_existing_contentful_entities = __esm({
|
|
|
16711
16796
|
|
|
16712
16797
|
// packages/experience-design-system-cli/src/runs/save-path-resolver.ts
|
|
16713
16798
|
import { access as access7 } from "node:fs/promises";
|
|
16714
|
-
import { join as
|
|
16799
|
+
import { join as join22 } from "node:path";
|
|
16715
16800
|
function isConflictMode(value) {
|
|
16716
16801
|
return CONFLICT_MODES.includes(value);
|
|
16717
16802
|
}
|
|
@@ -16719,7 +16804,7 @@ async function listConflictingFiles(path) {
|
|
|
16719
16804
|
const conflicts = [];
|
|
16720
16805
|
for (const name of SAVE_FILES) {
|
|
16721
16806
|
try {
|
|
16722
|
-
await access7(
|
|
16807
|
+
await access7(join22(path, name));
|
|
16723
16808
|
conflicts.push(name);
|
|
16724
16809
|
} catch {
|
|
16725
16810
|
}
|
|
@@ -16739,7 +16824,7 @@ function buildTimestampedSubdir(base, now = /* @__PURE__ */ new Date()) {
|
|
|
16739
16824
|
const hh = pad2(now.getHours());
|
|
16740
16825
|
const mm = pad2(now.getMinutes());
|
|
16741
16826
|
const ss = pad2(now.getSeconds());
|
|
16742
|
-
return
|
|
16827
|
+
return join22(base, `dsi-${y}${m}${d}-${hh}${mm}${ss}`);
|
|
16743
16828
|
}
|
|
16744
16829
|
async function resolveSavePath(path, options = {}) {
|
|
16745
16830
|
const conflicts = await listConflictingFiles(path);
|
|
@@ -16770,7 +16855,7 @@ var init_save_path_resolver = __esm({
|
|
|
16770
16855
|
|
|
16771
16856
|
// packages/experience-design-system-cli/src/runs/store.ts
|
|
16772
16857
|
import { readFile as readFile21, writeFile as writeFile6, mkdir as mkdir6, rename } from "node:fs/promises";
|
|
16773
|
-
import { join as
|
|
16858
|
+
import { join as join23 } from "node:path";
|
|
16774
16859
|
import { homedir as homedir7 } from "node:os";
|
|
16775
16860
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
16776
16861
|
function runsFilePath() {
|
|
@@ -16891,8 +16976,8 @@ var init_store = __esm({
|
|
|
16891
16976
|
RUNS_FILE_VERSION = 3;
|
|
16892
16977
|
RUNS_FILE_CAP = 200;
|
|
16893
16978
|
READABLE_VERSIONS = /* @__PURE__ */ new Set([1, 2, 3]);
|
|
16894
|
-
RUNS_DIR =
|
|
16895
|
-
RUNS_PATH =
|
|
16979
|
+
RUNS_DIR = join23(homedir7(), ".config", "experiences");
|
|
16980
|
+
RUNS_PATH = join23(RUNS_DIR, "runs.json");
|
|
16896
16981
|
CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
16897
16982
|
}
|
|
16898
16983
|
});
|
|
@@ -16927,11 +17012,12 @@ async function resolveRunTarget(arg) {
|
|
|
16927
17012
|
}
|
|
16928
17013
|
function looksLikePath2(arg) {
|
|
16929
17014
|
if (arg === "." || arg === "~") return true;
|
|
16930
|
-
|
|
17015
|
+
if (/^[A-Za-z]:[\\/]/.test(arg) || arg.startsWith("\\\\")) return true;
|
|
17016
|
+
return arg.startsWith("/") || arg.startsWith("./") || arg.startsWith("../") || arg.startsWith(".\\") || arg.startsWith("..\\") || arg.startsWith("~/") || arg.startsWith("~\\");
|
|
16931
17017
|
}
|
|
16932
17018
|
function expandHome(arg) {
|
|
16933
17019
|
if (arg === "~") return homedir8();
|
|
16934
|
-
if (arg.startsWith("~/")) return resolvePath(homedir8(), arg.slice(2));
|
|
17020
|
+
if (arg.startsWith("~/") || arg.startsWith("~\\")) return resolvePath(homedir8(), arg.slice(2));
|
|
16935
17021
|
return arg;
|
|
16936
17022
|
}
|
|
16937
17023
|
var init_resolve_run_target = __esm({
|
|
@@ -16972,13 +17058,13 @@ var init_use_blinking_cursor = __esm({
|
|
|
16972
17058
|
import { useState as useState10 } from "react";
|
|
16973
17059
|
import { Box as Box20, Text as Text21 } from "ink";
|
|
16974
17060
|
import { readdirSync as readdirSync3 } from "node:fs";
|
|
16975
|
-
import { dirname as dirname14, basename as
|
|
17061
|
+
import { dirname as dirname14, basename as basename7, join as join24 } from "node:path";
|
|
16976
17062
|
import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
16977
17063
|
function autocomplete(partial) {
|
|
16978
17064
|
if (!partial) return null;
|
|
16979
17065
|
const normalized = normalizePath(partial);
|
|
16980
17066
|
const dir = dirname14(normalized);
|
|
16981
|
-
const base =
|
|
17067
|
+
const base = basename7(normalized);
|
|
16982
17068
|
let entries;
|
|
16983
17069
|
try {
|
|
16984
17070
|
entries = readdirSync3(dir);
|
|
@@ -16987,13 +17073,13 @@ function autocomplete(partial) {
|
|
|
16987
17073
|
}
|
|
16988
17074
|
const matches = entries.filter((e) => e.startsWith(base));
|
|
16989
17075
|
if (matches.length === 0) return null;
|
|
16990
|
-
if (matches.length === 1) return
|
|
17076
|
+
if (matches.length === 1) return join24(dir, matches[0]);
|
|
16991
17077
|
let prefix = matches[0];
|
|
16992
17078
|
for (const m of matches) {
|
|
16993
17079
|
while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
|
|
16994
17080
|
if (!prefix) break;
|
|
16995
17081
|
}
|
|
16996
|
-
return prefix.length > base.length ?
|
|
17082
|
+
return prefix.length > base.length ? join24(dir, prefix) : null;
|
|
16997
17083
|
}
|
|
16998
17084
|
function PathPrompt({
|
|
16999
17085
|
defaultPath,
|
|
@@ -17585,7 +17671,7 @@ var init_WelcomeStep = __esm({
|
|
|
17585
17671
|
import { useState as useState14, useEffect as useEffect4 } from "react";
|
|
17586
17672
|
import { Box as Box25, Text as Text26 } from "ink";
|
|
17587
17673
|
import { promises as fs } from "node:fs";
|
|
17588
|
-
import { join as
|
|
17674
|
+
import { join as join25 } from "node:path";
|
|
17589
17675
|
import { jsx as jsx28, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
17590
17676
|
async function countFiles(dir) {
|
|
17591
17677
|
const counts = {
|
|
@@ -17609,7 +17695,7 @@ async function countFiles(dir) {
|
|
|
17609
17695
|
await Promise.all(
|
|
17610
17696
|
entries.map(async (entry) => {
|
|
17611
17697
|
if (IGNORE_DIRS.has(entry)) return;
|
|
17612
|
-
const full =
|
|
17698
|
+
const full = join25(current, entry);
|
|
17613
17699
|
let stat8;
|
|
17614
17700
|
try {
|
|
17615
17701
|
stat8 = await fs.stat(full);
|
|
@@ -27938,11 +28024,11 @@ __export(WizardApp_exports, {
|
|
|
27938
28024
|
});
|
|
27939
28025
|
import { useEffect as useEffect13, useRef as useRef10, useState as useState33 } from "react";
|
|
27940
28026
|
import { Box as Box57, Text as Text61, useStdout as useStdout7 } from "ink";
|
|
27941
|
-
import { join as
|
|
28027
|
+
import { join as join26, resolve as resolve25 } from "node:path";
|
|
27942
28028
|
import { appendFileSync as appendFileSync2, writeFileSync } from "node:fs";
|
|
27943
28029
|
import { access as access8, readFile as readFile23, stat as stat6 } from "node:fs/promises";
|
|
27944
28030
|
import { tmpdir } from "node:os";
|
|
27945
|
-
import { execFile as
|
|
28031
|
+
import { execFile as execFile3, spawn as spawn4 } from "node:child_process";
|
|
27946
28032
|
import { mkdir as mkdir7 } from "node:fs/promises";
|
|
27947
28033
|
import { buildManifest as buildManifest4 } from "@contentful/experience-design-system-types";
|
|
27948
28034
|
import { jsx as jsx65, jsxs as jsxs58 } from "react/jsx-runtime";
|
|
@@ -28010,14 +28096,14 @@ function formatAcceptanceSummary(opts) {
|
|
|
28010
28096
|
}
|
|
28011
28097
|
function runCli2(args) {
|
|
28012
28098
|
return new Promise((res) => {
|
|
28013
|
-
|
|
28099
|
+
execFile3(process.execPath, [findCliPath(), ...args], (error, stdout, stderr) => {
|
|
28014
28100
|
res({ exitCode: error?.code ? Number(error.code) : 0, stdout, stderr });
|
|
28015
28101
|
});
|
|
28016
28102
|
});
|
|
28017
28103
|
}
|
|
28018
28104
|
function runSpawnedCli(args, onStderr) {
|
|
28019
28105
|
return new Promise((res) => {
|
|
28020
|
-
const child = spawn4(
|
|
28106
|
+
const child = spawn4(process.execPath, args);
|
|
28021
28107
|
let stdout = "";
|
|
28022
28108
|
let stderr = "";
|
|
28023
28109
|
child.stdout.on("data", (d) => {
|
|
@@ -28116,8 +28202,8 @@ function WizardApp({
|
|
|
28116
28202
|
const rawTokensEntryReady = !modifyEntryReady && !pushFromPickerReady && !!initialRawTokensPath;
|
|
28117
28203
|
const effectiveNoCache = resolveNoCacheForGenerate({ cliNoCache: noCache });
|
|
28118
28204
|
const initialStepResolved = modifyEntryReady ? "final-review" : pushFromPickerReady ? "push-from-picker" : rawTokensEntryReady ? "generating-tokens" : initialProjectPath ? "token-input" : "welcome";
|
|
28119
|
-
const initialOutDir = initialProjectPath ?
|
|
28120
|
-
const initialTokensPath = (modifyEntryReady || pushFromPickerReady) && initialOutDir && seedTokenSessionId ?
|
|
28205
|
+
const initialOutDir = initialProjectPath ? join26(resolve25(initialProjectPath), ".contentful") : "";
|
|
28206
|
+
const initialTokensPath = (modifyEntryReady || pushFromPickerReady) && initialOutDir && seedTokenSessionId ? join26(initialOutDir, "tokens.json") : "";
|
|
28121
28207
|
const [state, setState] = useState33({
|
|
28122
28208
|
step: modifyEntryReady || rawTokensEntryReady || pushFromPickerReady ? initialStepResolved : initialRuns && initialRuns.length > 0 ? "run-picker" : initialStepResolved,
|
|
28123
28209
|
agent: initialAgent ?? "claude",
|
|
@@ -28274,7 +28360,7 @@ If you are using AWS Bedrock, run:
|
|
|
28274
28360
|
}
|
|
28275
28361
|
const sessionMatch = /^session=(.+)$/m.exec(result.stdout);
|
|
28276
28362
|
const tokenSessionId = sessionMatch ? sessionMatch[1].trim() : null;
|
|
28277
|
-
const tokensPath =
|
|
28363
|
+
const tokensPath = join26(outDir, "tokens.json");
|
|
28278
28364
|
const printArgs = ["print", "tokens", "--out", tokensPath];
|
|
28279
28365
|
if (tokenSessionId) printArgs.push("--session", tokenSessionId);
|
|
28280
28366
|
const r = await runCli2(printArgs);
|
|
@@ -28294,7 +28380,7 @@ If you are using AWS Bedrock, run:
|
|
|
28294
28380
|
tokenCount,
|
|
28295
28381
|
skipComponents: true,
|
|
28296
28382
|
acceptedCount: 0,
|
|
28297
|
-
outDir: state.outDir ||
|
|
28383
|
+
outDir: state.outDir || join26(process.cwd(), ".contentful")
|
|
28298
28384
|
});
|
|
28299
28385
|
if (noPush) {
|
|
28300
28386
|
void startSaveFlow();
|
|
@@ -28361,7 +28447,7 @@ If you are using AWS Bedrock, run:
|
|
|
28361
28447
|
return true;
|
|
28362
28448
|
};
|
|
28363
28449
|
const runExtract = async (projectPath) => {
|
|
28364
|
-
const outDir =
|
|
28450
|
+
const outDir = join26(resolve25(projectPath), ".contentful");
|
|
28365
28451
|
update({ step: "extracting", outDir, extractProgress: null, compositionPhase: null });
|
|
28366
28452
|
const extractArgs = [findCliPath(), "analyze", "extract", "--project", projectPath];
|
|
28367
28453
|
if (compositionMode === "composite") {
|
|
@@ -28460,7 +28546,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
28460
28546
|
noCache,
|
|
28461
28547
|
...state.existingEntitiesPath ? { existingEntitiesPath: state.existingEntitiesPath } : {}
|
|
28462
28548
|
});
|
|
28463
|
-
const child = spawn4(
|
|
28549
|
+
const child = spawn4(process.execPath, [findCliPath(), ...args]);
|
|
28464
28550
|
autoFilterChildRef.current = child;
|
|
28465
28551
|
let stderr = "";
|
|
28466
28552
|
child.stderr.on("data", (d) => {
|
|
@@ -28561,7 +28647,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
28561
28647
|
const args = buildGenerateArgs(extractSessionId, tokensPath);
|
|
28562
28648
|
let progressCursor = null;
|
|
28563
28649
|
const { child, donePromise } = spawnGenerateChild({
|
|
28564
|
-
command:
|
|
28650
|
+
command: process.execPath,
|
|
28565
28651
|
args,
|
|
28566
28652
|
onStderr: (chunk) => {
|
|
28567
28653
|
const nextProgress = parseGenerateStderrChunk(chunk, progressCursor);
|
|
@@ -28616,7 +28702,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
28616
28702
|
const args = buildGenerateArgs(extractSessionId, tokensPath, generatePromptPath);
|
|
28617
28703
|
let progressCursor = state.generateProgress;
|
|
28618
28704
|
const { donePromise } = spawnGenerateChild({
|
|
28619
|
-
command:
|
|
28705
|
+
command: process.execPath,
|
|
28620
28706
|
args,
|
|
28621
28707
|
onStderr: (chunk) => {
|
|
28622
28708
|
const nextProgress = parseGenerateStderrChunk(chunk, progressCursor);
|
|
@@ -28718,7 +28804,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
28718
28804
|
};
|
|
28719
28805
|
const advanceAfterCredentialsValidated = async () => {
|
|
28720
28806
|
if (!state.credentialsSkipped && state.spaceId && state.environmentId && state.cmaToken && state.projectPath) {
|
|
28721
|
-
const outDir =
|
|
28807
|
+
const outDir = join26(resolve25(state.projectPath), ".contentful");
|
|
28722
28808
|
await mkdir7(outDir, { recursive: true });
|
|
28723
28809
|
const result = await fetchAndPersistExistingContentfulEntities({
|
|
28724
28810
|
spaceId: state.spaceId,
|
|
@@ -29090,7 +29176,7 @@ If using a custom --host, make sure the space exists on that host.`
|
|
|
29090
29176
|
};
|
|
29091
29177
|
const runPrintFiles = async (extractSessionId, outDir, opts = {}) => {
|
|
29092
29178
|
update({ step: "printing" });
|
|
29093
|
-
const componentsPath =
|
|
29179
|
+
const componentsPath = join26(outDir, "components.json");
|
|
29094
29180
|
const printArgs = ["print", "components", "--out", componentsPath];
|
|
29095
29181
|
if (extractSessionId) printArgs.push("--session", extractSessionId);
|
|
29096
29182
|
if (opts.allowEmpty) printArgs.push("--allow-empty");
|
|
@@ -29106,7 +29192,7 @@ If using a custom --host, make sure the space exists on that host.`
|
|
|
29106
29192
|
let emittedTokensPath;
|
|
29107
29193
|
let emittedTokenCount;
|
|
29108
29194
|
if (opts.tokenSessionId) {
|
|
29109
|
-
const tokensOut =
|
|
29195
|
+
const tokensOut = join26(outDir, "tokens.json");
|
|
29110
29196
|
const tokenArgs = ["print", "tokens", "--out", tokensOut, "--session", opts.tokenSessionId];
|
|
29111
29197
|
const tr = await runCli2(tokenArgs);
|
|
29112
29198
|
if (tr.exitCode !== 0) {
|
|
@@ -29193,7 +29279,7 @@ If using a custom --host, make sure the space exists on that host.`
|
|
|
29193
29279
|
);
|
|
29194
29280
|
}
|
|
29195
29281
|
try {
|
|
29196
|
-
const componentsBuf = await readFile23(
|
|
29282
|
+
const componentsBuf = await readFile23(join26(path, "components.json")).catch(() => null);
|
|
29197
29283
|
const tokensBuf = recordedTokensPath ? await readFile23(recordedTokensPath).catch(() => null) : null;
|
|
29198
29284
|
savedFingerprint = buildSavedFingerprint({
|
|
29199
29285
|
componentsJson: componentsBuf,
|
|
@@ -29235,7 +29321,7 @@ If using a custom --host, make sure the space exists on that host.`
|
|
|
29235
29321
|
if (state.step === "generating-tokens") {
|
|
29236
29322
|
if (tokenReuseChecked.current) return;
|
|
29237
29323
|
tokenReuseChecked.current = true;
|
|
29238
|
-
const existingTokensPath =
|
|
29324
|
+
const existingTokensPath = join26(state.outDir, "tokens.json");
|
|
29239
29325
|
(async () => {
|
|
29240
29326
|
try {
|
|
29241
29327
|
await access8(existingTokensPath);
|
|
@@ -29311,7 +29397,7 @@ If using a custom --host, make sure the space exists on that host.`
|
|
|
29311
29397
|
{
|
|
29312
29398
|
onContinue: (path) => {
|
|
29313
29399
|
const projectPath = normalizePath(path);
|
|
29314
|
-
const outDir =
|
|
29400
|
+
const outDir = join26(projectPath, ".contentful");
|
|
29315
29401
|
update({ step: "token-input", projectPath, outDir });
|
|
29316
29402
|
},
|
|
29317
29403
|
onQuit: () => process.exit(0)
|
|
@@ -29935,7 +30021,7 @@ var init_WizardApp = __esm({
|
|
|
29935
30021
|
init_wizard_state_transitions();
|
|
29936
30022
|
init_cycle_auto_reject();
|
|
29937
30023
|
init_cli_path();
|
|
29938
|
-
WIZARD_LOG =
|
|
30024
|
+
WIZARD_LOG = join26(tmpdir(), "experiences-import-wizard.log");
|
|
29939
30025
|
}
|
|
29940
30026
|
});
|
|
29941
30027
|
|
|
@@ -29947,7 +30033,7 @@ __export(staleness_exports, {
|
|
|
29947
30033
|
shortStalenessSummary: () => shortStalenessSummary
|
|
29948
30034
|
});
|
|
29949
30035
|
import { readFile as readFile24, stat as stat7 } from "node:fs/promises";
|
|
29950
|
-
import { join as
|
|
30036
|
+
import { join as join27 } from "node:path";
|
|
29951
30037
|
async function checkRunStaleness(run) {
|
|
29952
30038
|
if (!run.sourceFingerprint) return { ...UNKNOWN };
|
|
29953
30039
|
const result = {
|
|
@@ -29989,7 +30075,7 @@ async function checkRunStaleness(run) {
|
|
|
29989
30075
|
}
|
|
29990
30076
|
if (run.savedFingerprint) {
|
|
29991
30077
|
if (run.savedFingerprint.componentsJsonHash !== null) {
|
|
29992
|
-
const compPath =
|
|
30078
|
+
const compPath = join27(run.savePath, "components.json");
|
|
29993
30079
|
try {
|
|
29994
30080
|
const buf = await readFile24(compPath);
|
|
29995
30081
|
if (sha256Hex(buf) !== run.savedFingerprint.componentsJsonHash) {
|
|
@@ -30002,7 +30088,7 @@ async function checkRunStaleness(run) {
|
|
|
30002
30088
|
}
|
|
30003
30089
|
}
|
|
30004
30090
|
if (run.savedFingerprint.tokensJsonHash !== null) {
|
|
30005
|
-
const tokensPath = run.tokensPath ??
|
|
30091
|
+
const tokensPath = run.tokensPath ?? join27(run.savePath, "tokens.json");
|
|
30006
30092
|
try {
|
|
30007
30093
|
const buf = await readFile24(tokensPath);
|
|
30008
30094
|
if (sha256Hex(buf) !== run.savedFingerprint.tokensJsonHash) {
|
|
@@ -30110,9 +30196,8 @@ var init_push_creds_prompt = __esm({
|
|
|
30110
30196
|
});
|
|
30111
30197
|
|
|
30112
30198
|
// packages/experience-design-system-cli/src/program.ts
|
|
30113
|
-
import { spawn as spawn6 } from "node:child_process";
|
|
30114
30199
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
30115
|
-
import { dirname as dirname15, join as
|
|
30200
|
+
import { dirname as dirname15, join as join30, resolve as resolve28 } from "node:path";
|
|
30116
30201
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
30117
30202
|
import { Command } from "commander";
|
|
30118
30203
|
|
|
@@ -30120,7 +30205,7 @@ import { Command } from "commander";
|
|
|
30120
30205
|
import { createElement as createElement3 } from "react";
|
|
30121
30206
|
import { render as render3 } from "ink";
|
|
30122
30207
|
import { mkdir as mkdir3, readdir as readdir2, readFile as readFile16, stat as stat2, writeFile as writeFile3 } from "node:fs/promises";
|
|
30123
|
-
import { isAbsolute as
|
|
30208
|
+
import { isAbsolute as isAbsolute5, join as join17, relative as relative3, resolve as resolve16 } from "node:path";
|
|
30124
30209
|
|
|
30125
30210
|
// packages/experience-design-system-cli/src/lib/agent-model-options.ts
|
|
30126
30211
|
init_src();
|
|
@@ -30468,7 +30553,7 @@ var OutputFormatter = class {
|
|
|
30468
30553
|
// packages/experience-design-system-cli/src/analyze/select-agent/context-builder.ts
|
|
30469
30554
|
init_src2();
|
|
30470
30555
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
30471
|
-
import { dirname as dirname11, isAbsolute as
|
|
30556
|
+
import { dirname as dirname11, isAbsolute as isAbsolute3, join as join15, relative as relative2, resolve as resolve12, sep } from "node:path";
|
|
30472
30557
|
var SCANNED_FILE_EXTENSIONS = /* @__PURE__ */ new Set([".astro", ".js", ".jsx", ".svelte", ".ts", ".tsx", ".vue"]);
|
|
30473
30558
|
var IMPORT_PATTERN2 = /import\s+(?:type\s+)?(.+?)\s+from\s+['"]([^'"]+)['"]/g;
|
|
30474
30559
|
var EXPORT_NAMED_PATTERN = /export\s+(?:const|function|class|type|interface|enum)\s+([A-Za-z0-9_]+)/g;
|
|
@@ -30486,7 +30571,7 @@ function truncateText(text, maxChars) {
|
|
|
30486
30571
|
}
|
|
30487
30572
|
function isWithinRoot(path, root) {
|
|
30488
30573
|
const relativePath = relative2(root, path);
|
|
30489
|
-
return relativePath !== ".." && !relativePath.startsWith(`..${sep}`) && !
|
|
30574
|
+
return relativePath !== ".." && !relativePath.startsWith(`..${sep}`) && !isAbsolute3(relativePath);
|
|
30490
30575
|
}
|
|
30491
30576
|
function toPosixPath(path) {
|
|
30492
30577
|
return sep === "/" ? path : path.split(sep).join("/");
|
|
@@ -30499,7 +30584,7 @@ function resolveLocalImportPath(source, componentDirectory, root, filePaths) {
|
|
|
30499
30584
|
const candidates = [
|
|
30500
30585
|
basePath,
|
|
30501
30586
|
...[...SCANNED_FILE_EXTENSIONS].map((extension) => `${basePath}${extension}`),
|
|
30502
|
-
...[...SCANNED_FILE_EXTENSIONS].map((extension) =>
|
|
30587
|
+
...[...SCANNED_FILE_EXTENSIONS].map((extension) => join15(basePath, `index${extension}`))
|
|
30503
30588
|
];
|
|
30504
30589
|
for (const candidate of candidates) {
|
|
30505
30590
|
if (filePaths.has(candidate) && isWithinRoot(candidate, root)) {
|
|
@@ -30600,7 +30685,7 @@ async function buildRepoContextIndex(root, filePaths) {
|
|
|
30600
30685
|
};
|
|
30601
30686
|
}
|
|
30602
30687
|
function buildSelectionContext(index, component) {
|
|
30603
|
-
const absolutePath =
|
|
30688
|
+
const absolutePath = isAbsolute3(component.source) ? component.source : resolve12(index.root, component.source);
|
|
30604
30689
|
if (!isWithinRoot(absolutePath, index.root)) return void 0;
|
|
30605
30690
|
const componentFile = index.files.find((file) => file.absolutePath === absolutePath);
|
|
30606
30691
|
if (!componentFile) return void 0;
|
|
@@ -30711,7 +30796,7 @@ function runShowRationale(opts) {
|
|
|
30711
30796
|
|
|
30712
30797
|
// packages/experience-design-system-cli/src/analyze/select-agent/command.ts
|
|
30713
30798
|
init_debug_logger();
|
|
30714
|
-
import { isAbsolute as
|
|
30799
|
+
import { isAbsolute as isAbsolute4, resolve as resolve13 } from "node:path";
|
|
30715
30800
|
|
|
30716
30801
|
// packages/experience-design-system-cli/src/lib/agent-output.ts
|
|
30717
30802
|
async function invokeAgentWithOutput(invoker3, options, verbose) {
|
|
@@ -31096,7 +31181,7 @@ function registerAnalyzeSelectAgentCommand(program) {
|
|
|
31096
31181
|
process.stderr.write(c.yellow(formatExclusionWarning(invalidComponents)));
|
|
31097
31182
|
}
|
|
31098
31183
|
if (selectionRoot && scannedFiles.length > 0) {
|
|
31099
|
-
scannedFiles = scannedFiles.map((f) =>
|
|
31184
|
+
scannedFiles = scannedFiles.map((f) => isAbsolute4(f) ? f : resolve13(selectionRoot, f));
|
|
31100
31185
|
}
|
|
31101
31186
|
if (selectionRoot && scannedFiles.length === 0 && rawComponents.length > 0) {
|
|
31102
31187
|
process.stderr.write(
|
|
@@ -31449,14 +31534,14 @@ function applyMapping(components, edges) {
|
|
|
31449
31534
|
|
|
31450
31535
|
// packages/experience-design-system-cli/src/analyze/composition/agent-parser/load-prompt.ts
|
|
31451
31536
|
import { existsSync as existsSync7, readFileSync as readFileSync8 } from "node:fs";
|
|
31452
|
-
import { dirname as dirname12, join as
|
|
31537
|
+
import { dirname as dirname12, join as join16, resolve as resolve14 } from "node:path";
|
|
31453
31538
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
31454
31539
|
function resolvePromptPath(fileName) {
|
|
31455
31540
|
const thisDir = dirname12(fileURLToPath3(import.meta.url));
|
|
31456
31541
|
let dir = thisDir;
|
|
31457
31542
|
for (; ; ) {
|
|
31458
|
-
const candidate =
|
|
31459
|
-
if (existsSync7(candidate)) return
|
|
31543
|
+
const candidate = join16(dir, "prompts");
|
|
31544
|
+
if (existsSync7(candidate)) return join16(candidate, fileName);
|
|
31460
31545
|
const parent = resolve14(dir, "..");
|
|
31461
31546
|
if (parent === dir) {
|
|
31462
31547
|
throw new Error(
|
|
@@ -32177,7 +32262,7 @@ function pluralize(count, singular, plural = `${singular}s`) {
|
|
|
32177
32262
|
return `${count} ${count === 1 ? singular : plural}`;
|
|
32178
32263
|
}
|
|
32179
32264
|
function resolveFromProjectRoot(projectRoot, inputPath) {
|
|
32180
|
-
return
|
|
32265
|
+
return isAbsolute5(inputPath) ? inputPath : resolve16(projectRoot, inputPath);
|
|
32181
32266
|
}
|
|
32182
32267
|
function wrapperConfidenceToIssueCount(confidence) {
|
|
32183
32268
|
if (confidence >= 4) return 2;
|
|
@@ -32193,7 +32278,7 @@ async function collectSourceFiles(directory, onProgress) {
|
|
|
32193
32278
|
const entries = await readdir2(currentDirectory, { withFileTypes: true });
|
|
32194
32279
|
const subdirs = [];
|
|
32195
32280
|
for (const entry of entries) {
|
|
32196
|
-
const fullPath =
|
|
32281
|
+
const fullPath = join17(currentDirectory, entry.name);
|
|
32197
32282
|
if (entry.isDirectory()) {
|
|
32198
32283
|
if (!IGNORED_DIRECTORY_NAMES.has(entry.name)) {
|
|
32199
32284
|
subdirs.push(fullPath);
|
|
@@ -32307,7 +32392,7 @@ function registerAnalyzeCommand(program) {
|
|
|
32307
32392
|
}
|
|
32308
32393
|
}
|
|
32309
32394
|
const projectRoot = resolve16(opts.project);
|
|
32310
|
-
const outDir =
|
|
32395
|
+
const outDir = join17(projectRoot, ".contentful");
|
|
32311
32396
|
let sourceDirectory;
|
|
32312
32397
|
if (opts.dir !== void 0) {
|
|
32313
32398
|
sourceDirectory = resolveFromProjectRoot(projectRoot, opts.dir);
|
|
@@ -32660,7 +32745,7 @@ init_src();
|
|
|
32660
32745
|
import { createElement as createElement4 } from "react";
|
|
32661
32746
|
import { render as render4 } from "ink";
|
|
32662
32747
|
import { readFile as readFile18, readdir as readdir3, stat as stat3 } from "node:fs/promises";
|
|
32663
|
-
import { join as
|
|
32748
|
+
import { basename as basename5, join as join18, resolve as resolve18 } from "node:path";
|
|
32664
32749
|
init_debug_logger();
|
|
32665
32750
|
|
|
32666
32751
|
// packages/experience-design-system-cli/src/generate/tui/GenerateView.tsx
|
|
@@ -32800,10 +32885,8 @@ init_credentials_store();
|
|
|
32800
32885
|
init_analytics();
|
|
32801
32886
|
|
|
32802
32887
|
// packages/experience-design-system-cli/src/lib/cli-errors.ts
|
|
32888
|
+
init_src();
|
|
32803
32889
|
init_analytics();
|
|
32804
|
-
import { execFile } from "node:child_process";
|
|
32805
|
-
import { promisify } from "node:util";
|
|
32806
|
-
var execFileAsync = promisify(execFile);
|
|
32807
32890
|
function die2(message) {
|
|
32808
32891
|
process.stderr.write(`${message}
|
|
32809
32892
|
`);
|
|
@@ -32811,12 +32894,18 @@ function die2(message) {
|
|
|
32811
32894
|
throw new Error("exit");
|
|
32812
32895
|
}
|
|
32813
32896
|
async function assertBinaryInPath(binary) {
|
|
32814
|
-
|
|
32815
|
-
|
|
32816
|
-
|
|
32817
|
-
|
|
32818
|
-
|
|
32819
|
-
|
|
32897
|
+
return binaryExists(binary);
|
|
32898
|
+
}
|
|
32899
|
+
function assertAgentCanReceivePrompt(agent) {
|
|
32900
|
+
if (process.platform !== "win32" || agentSupportsStdinPrompt(agent)) return;
|
|
32901
|
+
die2(
|
|
32902
|
+
`Error: --agent ${agent} does not work on Windows.
|
|
32903
|
+
Its CLI only accepts the prompt as a command-line argument, and Windows limits a command
|
|
32904
|
+
line to 8191 characters \u2014 shorter than the prompts this command sends.
|
|
32905
|
+
|
|
32906
|
+
Every other agent reads the prompt from standard input, so they are unaffected.
|
|
32907
|
+
Use --agent claude, codex, opencode, or cursor.`
|
|
32908
|
+
);
|
|
32820
32909
|
}
|
|
32821
32910
|
|
|
32822
32911
|
// packages/experience-design-system-cli/src/generate/command.ts
|
|
@@ -32849,7 +32938,7 @@ async function readFileInline(path) {
|
|
|
32849
32938
|
return;
|
|
32850
32939
|
}
|
|
32851
32940
|
for (const entry of entries.sort()) {
|
|
32852
|
-
const full =
|
|
32941
|
+
const full = join18(dir, entry);
|
|
32853
32942
|
let es;
|
|
32854
32943
|
try {
|
|
32855
32944
|
es = await stat3(full);
|
|
@@ -33201,7 +33290,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
33201
33290
|
mode: "autonomous",
|
|
33202
33291
|
rawComponentsInline: sampleInline ?? rawTokensInline,
|
|
33203
33292
|
rawTokensInline: skill === "tokens" ? rawTokensInline : void 0,
|
|
33204
|
-
rawTokensFilename: opts.rawTokens ? resolve18(opts.rawTokens)
|
|
33293
|
+
rawTokensFilename: opts.rawTokens ? basename5(resolve18(opts.rawTokens)) : void 0,
|
|
33205
33294
|
tokensInline,
|
|
33206
33295
|
tokenMapInline,
|
|
33207
33296
|
outDir: process.cwd(),
|
|
@@ -33222,6 +33311,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
33222
33311
|
});
|
|
33223
33312
|
await exitWithAnalytics(1);
|
|
33224
33313
|
}
|
|
33314
|
+
assertAgentCanReceivePrompt(agent);
|
|
33225
33315
|
if (skill === "components" && allComponents && sessionId2) {
|
|
33226
33316
|
const db = openPipelineDb();
|
|
33227
33317
|
let componentResults;
|
|
@@ -33344,7 +33434,7 @@ session=${sessionId2 ?? ""}
|
|
|
33344
33434
|
skill,
|
|
33345
33435
|
mode: "autonomous",
|
|
33346
33436
|
rawTokensInline,
|
|
33347
|
-
rawTokensFilename: opts.rawTokens ? resolve18(opts.rawTokens)
|
|
33437
|
+
rawTokensFilename: opts.rawTokens ? basename5(resolve18(opts.rawTokens)) : void 0,
|
|
33348
33438
|
tokensInline,
|
|
33349
33439
|
tokenMapInline,
|
|
33350
33440
|
outDir: process.cwd()
|
|
@@ -33536,7 +33626,7 @@ init_session_id();
|
|
|
33536
33626
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
33537
33627
|
import { readdirSync as readdirSync2, readFileSync as readFileSync9, renameSync, statSync as statSync4 } from "node:fs";
|
|
33538
33628
|
import { existsSync as existsSync8 } from "node:fs";
|
|
33539
|
-
import { join as
|
|
33629
|
+
import { join as join19, resolve as resolve19 } from "node:path";
|
|
33540
33630
|
import { homedir as homedir5 } from "node:os";
|
|
33541
33631
|
var MIGRATION_NAME = "v1_import_and_reviews";
|
|
33542
33632
|
function getReviewsDir() {
|
|
@@ -33580,13 +33670,13 @@ function migrateReviewSessions(db, _now) {
|
|
|
33580
33670
|
}
|
|
33581
33671
|
for (const entry of entries) {
|
|
33582
33672
|
if (entry.endsWith(".migrated")) continue;
|
|
33583
|
-
const sessionDir =
|
|
33673
|
+
const sessionDir = join19(reviewsDir, entry);
|
|
33584
33674
|
try {
|
|
33585
33675
|
if (!statSync4(sessionDir).isDirectory()) continue;
|
|
33586
33676
|
} catch {
|
|
33587
33677
|
continue;
|
|
33588
33678
|
}
|
|
33589
|
-
const stateFile =
|
|
33679
|
+
const stateFile = join19(sessionDir, "current-review-state.json");
|
|
33590
33680
|
let snapshot;
|
|
33591
33681
|
try {
|
|
33592
33682
|
snapshot = JSON.parse(readFileSync9(stateFile, "utf8"));
|
|
@@ -33908,7 +33998,7 @@ init_db();
|
|
|
33908
33998
|
import { createElement as createElement5 } from "react";
|
|
33909
33999
|
import { render as render5 } from "ink";
|
|
33910
34000
|
import { access as access6, mkdir as mkdir4, stat as stat4, writeFile as writeFile4 } from "node:fs/promises";
|
|
33911
|
-
import { basename as
|
|
34001
|
+
import { basename as basename6, resolve as resolve20 } from "node:path";
|
|
33912
34002
|
|
|
33913
34003
|
// packages/experience-design-system-cli/src/print/validate/validators/cdf-validator.ts
|
|
33914
34004
|
import { validateCDF as validateCDF2 } from "@contentful/experience-design-system-types";
|
|
@@ -34285,7 +34375,7 @@ function registerPrintCommand(program) {
|
|
|
34285
34375
|
await writeFile4(outPath, `${JSON.stringify(cdfObj, null, 2)}
|
|
34286
34376
|
`);
|
|
34287
34377
|
process.stdout.write(
|
|
34288
|
-
`wrote ${
|
|
34378
|
+
`wrote ${basename6(outPath)} (${components.length} component${components.length === 1 ? "" : "s"})
|
|
34289
34379
|
`
|
|
34290
34380
|
);
|
|
34291
34381
|
});
|
|
@@ -34309,7 +34399,7 @@ function registerPrintCommand(program) {
|
|
|
34309
34399
|
await writeFile4(outPath, `${JSON.stringify(tree, null, 2)}
|
|
34310
34400
|
`);
|
|
34311
34401
|
process.stdout.write(
|
|
34312
|
-
`wrote ${
|
|
34402
|
+
`wrote ${basename6(outPath)} (${result.tokens.length} token${result.tokens.length === 1 ? "" : "s"})
|
|
34313
34403
|
`
|
|
34314
34404
|
);
|
|
34315
34405
|
});
|
|
@@ -34751,6 +34841,7 @@ Install it, choose another agent with --agent, or use --print-prompt to run the
|
|
|
34751
34841
|
${resolveSkillPath("map-tokens")}`
|
|
34752
34842
|
);
|
|
34753
34843
|
}
|
|
34844
|
+
assertAgentCanReceivePrompt(agent);
|
|
34754
34845
|
const stepId = createStep(db, sessionId2, "map tokens", { agent, model: model ?? "" });
|
|
34755
34846
|
const prompt2 = await buildPrompt({
|
|
34756
34847
|
skill: "map-tokens",
|
|
@@ -34798,7 +34889,7 @@ function registerMapTokensCommand(program) {
|
|
|
34798
34889
|
// packages/experience-design-system-cli/src/import/command.ts
|
|
34799
34890
|
init_src();
|
|
34800
34891
|
init_path_utils();
|
|
34801
|
-
import { resolve as resolve27, join as
|
|
34892
|
+
import { resolve as resolve27, join as join28 } from "node:path";
|
|
34802
34893
|
|
|
34803
34894
|
// packages/experience-design-system-cli/src/import/orchestrator.ts
|
|
34804
34895
|
init_db();
|
|
@@ -34810,8 +34901,8 @@ init_contentful_urls();
|
|
|
34810
34901
|
init_debug_logger();
|
|
34811
34902
|
init_analytics();
|
|
34812
34903
|
import { mkdir as mkdir5 } from "node:fs/promises";
|
|
34813
|
-
import { join as
|
|
34814
|
-
import { execFile
|
|
34904
|
+
import { join as join21, resolve as resolve23 } from "node:path";
|
|
34905
|
+
import { execFile } from "node:child_process";
|
|
34815
34906
|
|
|
34816
34907
|
// packages/experience-design-system-cli/src/analytics/env.ts
|
|
34817
34908
|
init_debug_logger();
|
|
@@ -34834,7 +34925,7 @@ async function runStep(args, cliPath, analyticsSessionId, env = {}, streamStderr
|
|
|
34834
34925
|
const startedAt = Date.now();
|
|
34835
34926
|
debug.event("import", "subprocess.spawn", { cliPath, args });
|
|
34836
34927
|
return new Promise((res) => {
|
|
34837
|
-
const child =
|
|
34928
|
+
const child = execFile(process.execPath, [cliPath, ...args], {
|
|
34838
34929
|
env: pipelineSubprocessEnv({ ...process.env, ...env }, analyticsSessionId)
|
|
34839
34930
|
});
|
|
34840
34931
|
let stdout = "";
|
|
@@ -34915,7 +35006,7 @@ function buildPushStepResult(args) {
|
|
|
34915
35006
|
async function runPipeline(opts, progressWriter, cliPathOverride) {
|
|
34916
35007
|
const projectRoot = resolve23(opts.project);
|
|
34917
35008
|
const outDir = resolve23(opts.out);
|
|
34918
|
-
const componentsPath =
|
|
35009
|
+
const componentsPath = join21(outDir, "components.json");
|
|
34919
35010
|
const cliPath = cliPathOverride ?? findCliPath();
|
|
34920
35011
|
const db = openPipelineDb();
|
|
34921
35012
|
const { sessionId: sessionId2 } = getOrCreateSession(db, void 0, void 0, {
|
|
@@ -35537,7 +35628,7 @@ import { resolve as resolve26 } from "node:path";
|
|
|
35537
35628
|
|
|
35538
35629
|
// packages/experience-design-system-cli/src/runs/push-helpers.ts
|
|
35539
35630
|
init_cli_path();
|
|
35540
|
-
import { execFile as
|
|
35631
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
35541
35632
|
import { existsSync as existsSync9 } from "node:fs";
|
|
35542
35633
|
function runCli(args) {
|
|
35543
35634
|
const cliPath = findCliPath();
|
|
@@ -35549,7 +35640,7 @@ function runCli(args) {
|
|
|
35549
35640
|
});
|
|
35550
35641
|
}
|
|
35551
35642
|
return new Promise((res) => {
|
|
35552
|
-
|
|
35643
|
+
execFile2(process.execPath, [cliPath, ...args], (err, stdout, stderr) => {
|
|
35553
35644
|
res({
|
|
35554
35645
|
exitCode: err && "code" in err && typeof err.code === "number" ? err.code : err ? 1 : 0,
|
|
35555
35646
|
stdout,
|
|
@@ -36243,7 +36334,7 @@ function registerImportCommand(program) {
|
|
|
36243
36334
|
return;
|
|
36244
36335
|
}
|
|
36245
36336
|
const projectRoot = normalizePath(opts.project);
|
|
36246
|
-
const outDir = opts.out ? resolve27(opts.out) :
|
|
36337
|
+
const outDir = opts.out ? resolve27(opts.out) : join28(projectRoot, ".contentful");
|
|
36247
36338
|
const headlessCreds = await readExperiencesCredentials();
|
|
36248
36339
|
const headlessAgent = resolveAgent(opts.agent, headlessCreds.agent);
|
|
36249
36340
|
const headlessModel = resolveModel(opts.model, headlessCreds.agentModel);
|
|
@@ -36299,13 +36390,11 @@ function registerImportCommand(program) {
|
|
|
36299
36390
|
|
|
36300
36391
|
// packages/experience-design-system-cli/src/setup/command.ts
|
|
36301
36392
|
init_credentials_store();
|
|
36302
|
-
import { execFile as execFile5, spawn as spawn5 } from "node:child_process";
|
|
36303
36393
|
import { appendFile as appendFile2, readFile as readFile26, access as access9 } from "node:fs/promises";
|
|
36304
|
-
import { join as
|
|
36394
|
+
import { join as join29 } from "node:path";
|
|
36305
36395
|
import { homedir as homedir9 } from "node:os";
|
|
36306
36396
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
36307
36397
|
import { createInterface } from "node:readline";
|
|
36308
|
-
import { promisify as promisify2 } from "node:util";
|
|
36309
36398
|
|
|
36310
36399
|
// packages/experience-design-system-cli/src/setup/prompt-helpers.ts
|
|
36311
36400
|
async function promptBooleanPreference(ask, current, defaultValue, question) {
|
|
@@ -36336,7 +36425,7 @@ async function promptAnalyticsPreference(ask, current) {
|
|
|
36336
36425
|
// packages/experience-design-system-cli/src/setup/command.ts
|
|
36337
36426
|
init_host_utils();
|
|
36338
36427
|
init_cli_path();
|
|
36339
|
-
|
|
36428
|
+
init_src();
|
|
36340
36429
|
var REQUIRED_NODE_MAJOR = 24;
|
|
36341
36430
|
function ok(msg) {
|
|
36342
36431
|
process.stdout.write(` \x1B[32m\u2713\x1B[0m ${msg}
|
|
@@ -36423,17 +36512,12 @@ async function confirm(question, defaultYes = true) {
|
|
|
36423
36512
|
if (!answer) return defaultYes;
|
|
36424
36513
|
return answer.toLowerCase().startsWith("y");
|
|
36425
36514
|
}
|
|
36426
|
-
async function
|
|
36427
|
-
|
|
36428
|
-
await execFileAsync2("which", [name]);
|
|
36429
|
-
return true;
|
|
36430
|
-
} catch {
|
|
36431
|
-
return false;
|
|
36432
|
-
}
|
|
36515
|
+
async function binaryExists2(name) {
|
|
36516
|
+
return findBinary(name) !== null;
|
|
36433
36517
|
}
|
|
36434
36518
|
function runSpawn(cmd, args, opts = {}) {
|
|
36435
36519
|
return new Promise((resolve29) => {
|
|
36436
|
-
const child =
|
|
36520
|
+
const child = spawnBinary(cmd, args, {
|
|
36437
36521
|
cwd: opts.cwd,
|
|
36438
36522
|
env: opts.env ?? process.env,
|
|
36439
36523
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -36447,10 +36531,10 @@ function runSpawn(cmd, args, opts = {}) {
|
|
|
36447
36531
|
resolve29({ exitCode: 1, stdout: "", stderr: err.message });
|
|
36448
36532
|
}
|
|
36449
36533
|
});
|
|
36450
|
-
child.stdout
|
|
36534
|
+
child.stdout?.on("data", (d) => {
|
|
36451
36535
|
stdout += String(d);
|
|
36452
36536
|
});
|
|
36453
|
-
child.stderr
|
|
36537
|
+
child.stderr?.on("data", (d) => {
|
|
36454
36538
|
stderr += String(d);
|
|
36455
36539
|
});
|
|
36456
36540
|
child.on("exit", (code) => {
|
|
@@ -36465,17 +36549,17 @@ async function detectShellProfile() {
|
|
|
36465
36549
|
const shell = process.env["SHELL"] ?? "";
|
|
36466
36550
|
const home = homedir9();
|
|
36467
36551
|
if (shell.includes("zsh")) {
|
|
36468
|
-
return
|
|
36552
|
+
return join29(home, ".zshrc");
|
|
36469
36553
|
}
|
|
36470
36554
|
if (shell.includes("bash")) {
|
|
36471
|
-
const bashProfile =
|
|
36555
|
+
const bashProfile = join29(home, ".bash_profile");
|
|
36472
36556
|
const exists = await access9(bashProfile).then(() => true).catch(() => false);
|
|
36473
|
-
return exists ? bashProfile :
|
|
36557
|
+
return exists ? bashProfile : join29(home, ".bashrc");
|
|
36474
36558
|
}
|
|
36475
36559
|
if (shell.includes("fish")) {
|
|
36476
|
-
return
|
|
36560
|
+
return join29(home, ".config", "fish", "config.fish");
|
|
36477
36561
|
}
|
|
36478
|
-
return
|
|
36562
|
+
return join29(home, ".profile");
|
|
36479
36563
|
}
|
|
36480
36564
|
async function profileContains(profilePath, str) {
|
|
36481
36565
|
try {
|
|
@@ -36500,8 +36584,8 @@ async function setupNode() {
|
|
|
36500
36584
|
}
|
|
36501
36585
|
fail(`Node.js v${current} \u2014 need v${REQUIRED_NODE_MAJOR}+`);
|
|
36502
36586
|
info("");
|
|
36503
|
-
const hasNvm = await
|
|
36504
|
-
const hasFnm = await
|
|
36587
|
+
const hasNvm = await binaryExists2("nvm") || await access9(join29(homedir9(), ".nvm", "nvm.sh")).then(() => true).catch(() => false);
|
|
36588
|
+
const hasFnm = await binaryExists2("fnm");
|
|
36505
36589
|
if (hasNvm) {
|
|
36506
36590
|
info(`nvm detected. Will run: nvm install ${REQUIRED_NODE_MAJOR} && nvm use ${REQUIRED_NODE_MAJOR}`);
|
|
36507
36591
|
const go = await confirm(`Install and switch to Node ${REQUIRED_NODE_MAJOR} via nvm?`);
|
|
@@ -36509,7 +36593,7 @@ async function setupNode() {
|
|
|
36509
36593
|
warn(`Skipped. Re-run experiences setup after switching to Node ${REQUIRED_NODE_MAJOR}.`);
|
|
36510
36594
|
return false;
|
|
36511
36595
|
}
|
|
36512
|
-
const nvmScript =
|
|
36596
|
+
const nvmScript = join29(homedir9(), ".nvm", "nvm.sh");
|
|
36513
36597
|
const result = await runSpawn("bash", [
|
|
36514
36598
|
"-c",
|
|
36515
36599
|
`source "${nvmScript}" && nvm install ${REQUIRED_NODE_MAJOR} && nvm alias default ${REQUIRED_NODE_MAJOR}`
|
|
@@ -36571,14 +36655,14 @@ async function setupNode() {
|
|
|
36571
36655
|
}
|
|
36572
36656
|
async function setupPnpm() {
|
|
36573
36657
|
section("Step 2: pnpm", "[required]");
|
|
36574
|
-
if (await
|
|
36658
|
+
if (await binaryExists2("pnpm")) {
|
|
36575
36659
|
const v = await runSpawn("pnpm", ["--version"]);
|
|
36576
36660
|
ok(`pnpm v${v.stdout.trim()} \u2014 already installed`);
|
|
36577
36661
|
return true;
|
|
36578
36662
|
}
|
|
36579
36663
|
fail("pnpm not found");
|
|
36580
36664
|
info("");
|
|
36581
|
-
const hasCorecpack = await
|
|
36665
|
+
const hasCorecpack = await binaryExists2("corepack");
|
|
36582
36666
|
if (hasCorecpack) {
|
|
36583
36667
|
info("Will run: corepack enable && corepack prepare pnpm@latest --activate");
|
|
36584
36668
|
const go2 = await confirm("Install pnpm via corepack?");
|
|
@@ -36666,7 +36750,8 @@ async function setupAgent() {
|
|
|
36666
36750
|
section("Step 4: Coding agent (claude, codex, opencode, or copilot)", "[required]");
|
|
36667
36751
|
info("experiences import uses a coding agent to generate component definitions.");
|
|
36668
36752
|
info("");
|
|
36669
|
-
const
|
|
36753
|
+
const candidates = AGENT_DEFS.filter((a) => agentSupportsStdinPrompt(a.binary) || process.platform !== "win32");
|
|
36754
|
+
const found = (await Promise.all(candidates.map(async (a) => await binaryExists2(a.binary) ? a : null))).filter(
|
|
36670
36755
|
(a) => a !== null
|
|
36671
36756
|
);
|
|
36672
36757
|
if (found.length === 1) {
|
|
@@ -36708,7 +36793,7 @@ async function setupAgent() {
|
|
|
36708
36793
|
info(r.stderr.trim().split("\n").slice(0, 5).join("\n"));
|
|
36709
36794
|
return { agent: void 0, agentModel: void 0 };
|
|
36710
36795
|
}
|
|
36711
|
-
if (!await
|
|
36796
|
+
if (!await binaryExists2("claude")) {
|
|
36712
36797
|
fail("claude binary not found on PATH after install \u2014 check your npm global bin directory");
|
|
36713
36798
|
return { agent: void 0, agentModel: void 0 };
|
|
36714
36799
|
}
|
|
@@ -36724,7 +36809,7 @@ async function setupAgent() {
|
|
|
36724
36809
|
fail("Install failed");
|
|
36725
36810
|
return { agent: void 0, agentModel: void 0 };
|
|
36726
36811
|
}
|
|
36727
|
-
if (!await
|
|
36812
|
+
if (!await binaryExists2("codex")) {
|
|
36728
36813
|
fail("codex binary not found on PATH after install \u2014 check your npm global bin directory");
|
|
36729
36814
|
return { agent: void 0, agentModel: void 0 };
|
|
36730
36815
|
}
|
|
@@ -36738,7 +36823,7 @@ async function setupAgent() {
|
|
|
36738
36823
|
fail("Install failed");
|
|
36739
36824
|
return { agent: void 0, agentModel: void 0 };
|
|
36740
36825
|
}
|
|
36741
|
-
if (!await
|
|
36826
|
+
if (!await binaryExists2("opencode")) {
|
|
36742
36827
|
fail("opencode binary not found on PATH after install \u2014 check your npm global bin directory");
|
|
36743
36828
|
return { agent: void 0, agentModel: void 0 };
|
|
36744
36829
|
}
|
|
@@ -36933,11 +37018,11 @@ async function checkNode() {
|
|
|
36933
37018
|
fail(`Node.js v${current} \u2014 need v${REQUIRED_NODE_MAJOR}+`);
|
|
36934
37019
|
info("");
|
|
36935
37020
|
info("How to fix:");
|
|
36936
|
-
if (await
|
|
37021
|
+
if (await binaryExists2("nvm")) {
|
|
36937
37022
|
info(` nvm install ${REQUIRED_NODE_MAJOR}`);
|
|
36938
37023
|
info(` nvm use ${REQUIRED_NODE_MAJOR}`);
|
|
36939
37024
|
info(` nvm alias default ${REQUIRED_NODE_MAJOR} # make it permanent`);
|
|
36940
|
-
} else if (await
|
|
37025
|
+
} else if (await binaryExists2("fnm")) {
|
|
36941
37026
|
info(` fnm install ${REQUIRED_NODE_MAJOR}`);
|
|
36942
37027
|
info(` fnm use ${REQUIRED_NODE_MAJOR}`);
|
|
36943
37028
|
} else {
|
|
@@ -36950,7 +37035,7 @@ async function checkNode() {
|
|
|
36950
37035
|
}
|
|
36951
37036
|
async function checkPnpm(pkgRoot) {
|
|
36952
37037
|
section("Checking pnpm");
|
|
36953
|
-
if (!await
|
|
37038
|
+
if (!await binaryExists2("pnpm")) {
|
|
36954
37039
|
fail("pnpm not found");
|
|
36955
37040
|
info("How to fix:");
|
|
36956
37041
|
info(" npm install -g pnpm");
|
|
@@ -36976,13 +37061,13 @@ async function checkPnpm(pkgRoot) {
|
|
|
36976
37061
|
}
|
|
36977
37062
|
async function checkDependencies(pkgRoot) {
|
|
36978
37063
|
section("Checking dependencies (pnpm install)");
|
|
36979
|
-
const nodeModulesExists = await access9(
|
|
37064
|
+
const nodeModulesExists = await access9(join29(pkgRoot, "node_modules")).then(() => true).catch(() => false);
|
|
36980
37065
|
if (!nodeModulesExists) {
|
|
36981
37066
|
info("node_modules not found \u2014 running pnpm install...");
|
|
36982
37067
|
} else {
|
|
36983
37068
|
info("Running pnpm install to ensure dependencies are up to date...");
|
|
36984
37069
|
}
|
|
36985
|
-
const repoRoot =
|
|
37070
|
+
const repoRoot = join29(pkgRoot, "..", "..");
|
|
36986
37071
|
const result = await runSpawn("pnpm", ["install", "--frozen-lockfile"], { cwd: repoRoot });
|
|
36987
37072
|
if (result.exitCode !== 0) {
|
|
36988
37073
|
fail("pnpm install failed");
|
|
@@ -37001,7 +37086,7 @@ async function checkDependencies(pkgRoot) {
|
|
|
37001
37086
|
async function checkBuild(pkgRoot) {
|
|
37002
37087
|
section("Building CLI");
|
|
37003
37088
|
info("Running pnpm build...");
|
|
37004
|
-
const repoRoot =
|
|
37089
|
+
const repoRoot = join29(pkgRoot, "..", "..");
|
|
37005
37090
|
const result = await runSpawn("pnpm", ["--filter", "@contentful/experience-design-system-cli", "run", "build"], {
|
|
37006
37091
|
cwd: repoRoot
|
|
37007
37092
|
});
|
|
@@ -37021,12 +37106,12 @@ async function checkBuild(pkgRoot) {
|
|
|
37021
37106
|
}
|
|
37022
37107
|
async function checkAgent() {
|
|
37023
37108
|
section("Checking coding agent");
|
|
37024
|
-
const agents = AGENT_DEFS;
|
|
37109
|
+
const agents = AGENT_DEFS.filter((a) => agentSupportsStdinPrompt(a.binary) || process.platform !== "win32");
|
|
37025
37110
|
const creds = await readExperiencesCredentials();
|
|
37026
37111
|
const savedAgent = creds.agent;
|
|
37027
37112
|
const savedModel = creds.agentModel;
|
|
37028
37113
|
if (savedAgent) {
|
|
37029
|
-
const found = await
|
|
37114
|
+
const found = await binaryExists2(savedAgent);
|
|
37030
37115
|
if (found) {
|
|
37031
37116
|
const modelStr = savedModel ? ` \u2014 model: ${savedModel}` : "";
|
|
37032
37117
|
ok(`${savedAgent}${modelStr} (saved preference)`);
|
|
@@ -37038,7 +37123,7 @@ async function checkAgent() {
|
|
|
37038
37123
|
}
|
|
37039
37124
|
}
|
|
37040
37125
|
for (const agent of agents) {
|
|
37041
|
-
if (await
|
|
37126
|
+
if (await binaryExists2(agent.binary)) {
|
|
37042
37127
|
ok(`${agent.name} (${agent.binary}) found`);
|
|
37043
37128
|
info("Tip: run experiences setup to save a default agent and model.");
|
|
37044
37129
|
return true;
|
|
@@ -37117,7 +37202,7 @@ function registerSetupCommand(program) {
|
|
|
37117
37202
|
process.stdout.write("\n\x1B[1mexperiences setup\x1B[0m \u2014 interactive setup wizard\n");
|
|
37118
37203
|
process.stdout.write("Sets up everything you need to run \x1B[1mexperiences import\x1B[0m.\n");
|
|
37119
37204
|
const pkgRoot = findPkgRoot();
|
|
37120
|
-
const repoRoot =
|
|
37205
|
+
const repoRoot = join29(pkgRoot, "..", "..");
|
|
37121
37206
|
const profilePath = await detectShellProfile();
|
|
37122
37207
|
const results = [];
|
|
37123
37208
|
const nodeOk = await setupNode();
|
|
@@ -37357,7 +37442,8 @@ async function beginCommand(command, opts) {
|
|
|
37357
37442
|
init_analytics();
|
|
37358
37443
|
init_credentials_store();
|
|
37359
37444
|
init_cli_path();
|
|
37360
|
-
|
|
37445
|
+
init_src();
|
|
37446
|
+
var pkg3 = JSON.parse(readFileSync10(join30(findPkgRoot(), "package.json"), "utf8"));
|
|
37361
37447
|
async function runBuild(opts) {
|
|
37362
37448
|
return new Promise((resolvePromise) => {
|
|
37363
37449
|
const child = opts.spawnFn();
|
|
@@ -37397,7 +37483,8 @@ function registerBuildCommand(program) {
|
|
|
37397
37483
|
const pkgRoot = resolve28(dirname15(fileURLToPath5(import.meta.url)), "..", "..");
|
|
37398
37484
|
process.stderr.write("\u2699 Building from source...\n");
|
|
37399
37485
|
const { exitCode } = await runBuild({
|
|
37400
|
-
|
|
37486
|
+
// spawnBinary: pnpm is a `.cmd` shim on Windows.
|
|
37487
|
+
spawnFn: () => spawnBinary("pnpm", ["build"], { cwd: pkgRoot, stdio: "inherit" }),
|
|
37401
37488
|
stderrWrite: (s) => process.stderr.write(s)
|
|
37402
37489
|
});
|
|
37403
37490
|
process.exit(exitCode);
|