@contentful/experience-design-system-cli 2.34.4 → 2.34.5-dev-build-a88e62a.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 +267 -200
- 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,17 @@ 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
|
+
}
|
|
300
376
|
function buildArgs(agent, prompt2, model, promptViaStdin = false, bedrock = false) {
|
|
301
377
|
const resolvedModel = resolveAgentModel(agent, model, bedrock);
|
|
302
378
|
const modelArg = resolvedModel ? ["--model", resolvedModel] : [];
|
|
303
|
-
const
|
|
379
|
+
const useStdin2 = promptViaStdin && agentSupportsStdinPrompt(agent);
|
|
380
|
+
const promptArg = useStdin2 ? [] : [prompt2];
|
|
304
381
|
switch (agent) {
|
|
305
382
|
case "claude":
|
|
306
383
|
return ["--print", ...modelArg, ...promptArg];
|
|
@@ -323,7 +400,7 @@ async function runAgent(options) {
|
|
|
323
400
|
const { agent, prompt: prompt2, timeoutMs, model, onOutput, promptViaStdin, onDebugEvent } = options;
|
|
324
401
|
const bedrock = options.bedrock ?? process.env.EDS_BEDROCK === "1";
|
|
325
402
|
const binary = resolveBinary(agent);
|
|
326
|
-
const useStdin2 = !!promptViaStdin;
|
|
403
|
+
const useStdin2 = agentSupportsStdinPrompt(agent) && (!!promptViaStdin || shouldUseStdinPrompt(agent, prompt2));
|
|
327
404
|
const args = buildArgs(agent, prompt2, model, useStdin2, bedrock);
|
|
328
405
|
const startedAt = Date.now();
|
|
329
406
|
onDebugEvent?.("run.start", {
|
|
@@ -337,7 +414,7 @@ async function runAgent(options) {
|
|
|
337
414
|
});
|
|
338
415
|
return new Promise((resolve29) => {
|
|
339
416
|
const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
|
|
340
|
-
const child =
|
|
417
|
+
const child = spawnBinary(binary, args, {
|
|
341
418
|
stdio: ["pipe", "pipe", "pipe"],
|
|
342
419
|
...bedrockEnv ? { env: { ...process.env, ...bedrockEnv } } : {}
|
|
343
420
|
});
|
|
@@ -390,20 +467,13 @@ async function runAgent(options) {
|
|
|
390
467
|
}
|
|
391
468
|
async function checkAgentAuth(agent) {
|
|
392
469
|
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)
|
|
470
|
+
const resolvedBinary = findBinary(binary);
|
|
471
|
+
if (!resolvedBinary)
|
|
402
472
|
return "not-found";
|
|
403
473
|
if (agent !== "claude")
|
|
404
474
|
return "ok";
|
|
405
475
|
return new Promise((resolve29) => {
|
|
406
|
-
const child =
|
|
476
|
+
const child = spawnBinary(resolvedBinary, ["auth", "status", "--json"], {
|
|
407
477
|
stdio: ["ignore", "pipe", "pipe"]
|
|
408
478
|
});
|
|
409
479
|
let stdout = "";
|
|
@@ -457,10 +527,11 @@ function extractSentinelOutput(stdout) {
|
|
|
457
527
|
return "multiple";
|
|
458
528
|
return stdout.slice(startIdx + START.length, endIdx).trim();
|
|
459
529
|
}
|
|
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;
|
|
530
|
+
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
531
|
var init_agent_runner = __esm({
|
|
462
532
|
"packages/experience-design-system-generation/dist/src/agent-runner.js"() {
|
|
463
533
|
"use strict";
|
|
534
|
+
init_binary_launch();
|
|
464
535
|
init_agent_names();
|
|
465
536
|
VALID_SELECT_TOOL_NAMES = /* @__PURE__ */ new Set(["select_component", "reject_component"]);
|
|
466
537
|
VALID_TOOL_NAMES = /* @__PURE__ */ new Set(["classify_prop", "exclude_prop", "classify_component", "classify_slot"]);
|
|
@@ -489,6 +560,8 @@ var init_agent_runner = __esm({
|
|
|
489
560
|
// the only model guaranteed on every Copilot plan (Free/Pro/Business/Enterprise); Pro+ users override via EDS_AGENT_MODEL_COPILOT
|
|
490
561
|
};
|
|
491
562
|
DEFAULT_CODEX_BEDROCK_MODEL = "openai.gpt-5.6-luna";
|
|
563
|
+
STDIN_CAPABLE_AGENTS = /* @__PURE__ */ new Set(["claude", "codex", "opencode", "cursor"]);
|
|
564
|
+
ARGV_PROMPT_LIMIT = 4096;
|
|
492
565
|
}
|
|
493
566
|
});
|
|
494
567
|
|
|
@@ -514,7 +587,7 @@ var init_agent_invoker = __esm({
|
|
|
514
587
|
// packages/experience-design-system-generation/dist/src/prompt-builder.js
|
|
515
588
|
import { existsSync } from "node:fs";
|
|
516
589
|
import { readFile } from "node:fs/promises";
|
|
517
|
-
import { dirname, join, resolve } from "node:path";
|
|
590
|
+
import { dirname, join as join2, resolve } from "node:path";
|
|
518
591
|
import { fileURLToPath } from "node:url";
|
|
519
592
|
import { flattenDTCG } from "@contentful/experience-design-system-types";
|
|
520
593
|
function formatCustomPromptBanner(skill, path) {
|
|
@@ -538,9 +611,9 @@ function resolveSkillPath(skill) {
|
|
|
538
611
|
const thisDir = dirname(fileURLToPath(import.meta.url));
|
|
539
612
|
let dir = thisDir;
|
|
540
613
|
for (; ; ) {
|
|
541
|
-
const candidate =
|
|
614
|
+
const candidate = join2(dir, "skills");
|
|
542
615
|
if (existsSync(candidate))
|
|
543
|
-
return
|
|
616
|
+
return join2(candidate, SKILL_FILES[skill]);
|
|
544
617
|
const parent = resolve(dir, "..");
|
|
545
618
|
if (parent === dir) {
|
|
546
619
|
throw new Error(`skill file missing from CLI installation (could not locate skills/ directory from: ${thisDir})`);
|
|
@@ -891,12 +964,15 @@ __export(src_exports, {
|
|
|
891
964
|
AGENT_NAMES: () => AGENT_NAMES,
|
|
892
965
|
DEFAULT_AGENT_NAME: () => DEFAULT_AGENT_NAME,
|
|
893
966
|
agentSupportsBedrock: () => agentSupportsBedrock,
|
|
967
|
+
agentSupportsStdinPrompt: () => agentSupportsStdinPrompt,
|
|
968
|
+
binaryExists: () => binaryExists,
|
|
894
969
|
buildArgs: () => buildArgs,
|
|
895
970
|
buildPrompt: () => buildPrompt,
|
|
896
971
|
checkAgentAuth: () => checkAgentAuth,
|
|
897
972
|
createLocalCliAgentInvoker: () => createLocalCliAgentInvoker,
|
|
898
973
|
describeAgentFailure: () => describeAgentFailure,
|
|
899
974
|
extractSentinelOutput: () => extractSentinelOutput,
|
|
975
|
+
findBinary: () => findBinary,
|
|
900
976
|
formatCustomPromptBanner: () => formatCustomPromptBanner,
|
|
901
977
|
formatGenerateProgressLine: () => formatGenerateProgressLine,
|
|
902
978
|
isAgentName: () => isAgentName,
|
|
@@ -907,7 +983,9 @@ __export(src_exports, {
|
|
|
907
983
|
resolveAgentModel: () => resolveAgentModel,
|
|
908
984
|
resolveBinary: () => resolveBinary,
|
|
909
985
|
resolveSkillPath: () => resolveSkillPath,
|
|
910
|
-
runAgent: () => runAgent
|
|
986
|
+
runAgent: () => runAgent,
|
|
987
|
+
shouldUseStdinPrompt: () => shouldUseStdinPrompt,
|
|
988
|
+
spawnBinary: () => spawnBinary
|
|
911
989
|
});
|
|
912
990
|
var init_src = __esm({
|
|
913
991
|
"packages/experience-design-system-generation/dist/src/index.js"() {
|
|
@@ -917,6 +995,7 @@ var init_src = __esm({
|
|
|
917
995
|
init_agent_invoker();
|
|
918
996
|
init_prompt_builder();
|
|
919
997
|
init_progress();
|
|
998
|
+
init_binary_launch();
|
|
920
999
|
}
|
|
921
1000
|
});
|
|
922
1001
|
|
|
@@ -932,7 +1011,7 @@ var init_types = __esm({
|
|
|
932
1011
|
|
|
933
1012
|
// packages/experience-design-system-extraction/dist/src/extract/tsx-shared.js
|
|
934
1013
|
import { existsSync as existsSync2, readFileSync } from "node:fs";
|
|
935
|
-
import { dirname as dirname2, join as
|
|
1014
|
+
import { dirname as dirname2, join as join3, resolve as resolve2 } from "node:path";
|
|
936
1015
|
import { Node, Project, SyntaxKind } from "ts-morph";
|
|
937
1016
|
import ts from "typescript";
|
|
938
1017
|
function createTsxProject(filePaths) {
|
|
@@ -1089,7 +1168,7 @@ function findNearestTsConfigPath(filePath) {
|
|
|
1089
1168
|
let currentDir = dirname2(filePath);
|
|
1090
1169
|
while (true) {
|
|
1091
1170
|
for (const candidateName of ["tsconfig.json", "jsconfig.json"]) {
|
|
1092
|
-
const candidatePath =
|
|
1171
|
+
const candidatePath = join3(currentDir, candidateName);
|
|
1093
1172
|
if (existsSync2(candidatePath)) {
|
|
1094
1173
|
nearestTsConfigPathCache.set(filePath, candidatePath);
|
|
1095
1174
|
return candidatePath;
|
|
@@ -1146,10 +1225,10 @@ function resolveImportSourcePath(basePath) {
|
|
|
1146
1225
|
`${basePath}.tsx`,
|
|
1147
1226
|
`${basePath}.js`,
|
|
1148
1227
|
`${basePath}.jsx`,
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1228
|
+
join3(basePath, "index.ts"),
|
|
1229
|
+
join3(basePath, "index.tsx"),
|
|
1230
|
+
join3(basePath, "index.js"),
|
|
1231
|
+
join3(basePath, "index.jsx")
|
|
1153
1232
|
];
|
|
1154
1233
|
return candidates.find((candidatePath) => existsSync2(candidatePath));
|
|
1155
1234
|
}
|
|
@@ -1160,10 +1239,10 @@ function findProjectSourceFileByImportPath(project, resolvedPath) {
|
|
|
1160
1239
|
`${resolvedPath}.tsx`,
|
|
1161
1240
|
`${resolvedPath}.js`,
|
|
1162
1241
|
`${resolvedPath}.jsx`,
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1242
|
+
join3(resolvedPath, "index.ts"),
|
|
1243
|
+
join3(resolvedPath, "index.tsx"),
|
|
1244
|
+
join3(resolvedPath, "index.js"),
|
|
1245
|
+
join3(resolvedPath, "index.jsx")
|
|
1167
1246
|
];
|
|
1168
1247
|
for (const candidatePath of candidatePaths) {
|
|
1169
1248
|
const sourceFile = project.getSourceFile(candidatePath);
|
|
@@ -1184,10 +1263,10 @@ function findWorkspacePackageEntrySourceFile(originSourceFile, moduleSpecifier)
|
|
|
1184
1263
|
if (!packageRootDir)
|
|
1185
1264
|
return void 0;
|
|
1186
1265
|
const preferredEntryPaths = [
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1266
|
+
join3(packageRootDir, "src/index.ts"),
|
|
1267
|
+
join3(packageRootDir, "src/index.tsx"),
|
|
1268
|
+
join3(packageRootDir, "index.ts"),
|
|
1269
|
+
join3(packageRootDir, "index.tsx")
|
|
1191
1270
|
];
|
|
1192
1271
|
for (const entryPath of preferredEntryPaths) {
|
|
1193
1272
|
const entrySourceFile = project.getSourceFile(entryPath);
|
|
@@ -1195,7 +1274,7 @@ function findWorkspacePackageEntrySourceFile(originSourceFile, moduleSpecifier)
|
|
|
1195
1274
|
return entrySourceFile;
|
|
1196
1275
|
}
|
|
1197
1276
|
}
|
|
1198
|
-
return candidateSourceFiles.find((sourceFile) => sourceFile.getDirectoryPath() ===
|
|
1277
|
+
return candidateSourceFiles.find((sourceFile) => sourceFile.getDirectoryPath() === join3(packageRootDir, "src"));
|
|
1199
1278
|
}
|
|
1200
1279
|
function getWorkspacePackageManifestForSourceFile(sourceFile) {
|
|
1201
1280
|
const packageRootDir = findNearestPackageRootDir(sourceFile.getFilePath());
|
|
@@ -1204,7 +1283,7 @@ function getWorkspacePackageManifestForSourceFile(sourceFile) {
|
|
|
1204
1283
|
if (workspacePackageManifestCache.has(packageRootDir)) {
|
|
1205
1284
|
return workspacePackageManifestCache.get(packageRootDir) ?? void 0;
|
|
1206
1285
|
}
|
|
1207
|
-
const packageJsonPath =
|
|
1286
|
+
const packageJsonPath = join3(packageRootDir, "package.json");
|
|
1208
1287
|
try {
|
|
1209
1288
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
1210
1289
|
const manifest = typeof packageJson.name === "string" ? { name: packageJson.name, rootDir: packageRootDir } : null;
|
|
@@ -1221,7 +1300,7 @@ function findNearestPackageRootDir(filePath) {
|
|
|
1221
1300
|
}
|
|
1222
1301
|
let currentDir = dirname2(filePath);
|
|
1223
1302
|
while (true) {
|
|
1224
|
-
if (existsSync2(
|
|
1303
|
+
if (existsSync2(join3(currentDir, "package.json"))) {
|
|
1225
1304
|
packageRootByFilePathCache.set(filePath, currentDir);
|
|
1226
1305
|
return currentDir;
|
|
1227
1306
|
}
|
|
@@ -4221,7 +4300,7 @@ var init_vue_tsx = __esm({
|
|
|
4221
4300
|
|
|
4222
4301
|
// packages/experience-design-system-extraction/dist/src/extract/resolve-local-module.js
|
|
4223
4302
|
import { existsSync as existsSync3, statSync } from "node:fs";
|
|
4224
|
-
import { dirname as dirname3, join as
|
|
4303
|
+
import { dirname as dirname3, join as join4, resolve as resolve3 } from "node:path";
|
|
4225
4304
|
function resolveLocalModule(importingFilePath, specifier, options = {}) {
|
|
4226
4305
|
const basePath = resolve3(dirname3(importingFilePath), specifier);
|
|
4227
4306
|
const candidates = [
|
|
@@ -4230,10 +4309,10 @@ function resolveLocalModule(importingFilePath, specifier, options = {}) {
|
|
|
4230
4309
|
`${basePath}.ts`,
|
|
4231
4310
|
`${basePath}.mjs`,
|
|
4232
4311
|
`${basePath}.cjs`,
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4312
|
+
join4(basePath, "index.js"),
|
|
4313
|
+
join4(basePath, "index.ts"),
|
|
4314
|
+
join4(basePath, "index.mjs"),
|
|
4315
|
+
join4(basePath, "index.cjs")
|
|
4237
4316
|
];
|
|
4238
4317
|
for (const candidate of candidates) {
|
|
4239
4318
|
if (existsSync3(candidate) && statSync(candidate).isFile())
|
|
@@ -4271,7 +4350,7 @@ var init_resolve_type_property = __esm({
|
|
|
4271
4350
|
});
|
|
4272
4351
|
|
|
4273
4352
|
// packages/experience-design-system-extraction/dist/src/extract/vue.js
|
|
4274
|
-
import { basename, dirname as dirname4, resolve as resolve4, join as
|
|
4353
|
+
import { basename, dirname as dirname4, resolve as resolve4, join as join5 } from "node:path";
|
|
4275
4354
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
4276
4355
|
import { existsSync as existsSync4, readFileSync as readFileSync2, readdirSync, statSync as statSync2 } from "node:fs";
|
|
4277
4356
|
import os from "node:os";
|
|
@@ -4487,11 +4566,11 @@ function findWorkspaceRoot(startDir) {
|
|
|
4487
4566
|
return workspaceRootCache.get(startDir);
|
|
4488
4567
|
let dir = startDir;
|
|
4489
4568
|
while (true) {
|
|
4490
|
-
const pkgJsonPath =
|
|
4569
|
+
const pkgJsonPath = join5(dir, "package.json");
|
|
4491
4570
|
if (existsSync4(pkgJsonPath)) {
|
|
4492
4571
|
try {
|
|
4493
4572
|
const pkg4 = JSON.parse(readFileSync2(pkgJsonPath, "utf8"));
|
|
4494
|
-
if (pkg4.workspaces || existsSync4(
|
|
4573
|
+
if (pkg4.workspaces || existsSync4(join5(dir, "pnpm-workspace.yaml"))) {
|
|
4495
4574
|
workspaceRootCache.set(startDir, dir);
|
|
4496
4575
|
return dir;
|
|
4497
4576
|
}
|
|
@@ -4511,7 +4590,7 @@ function getWorkspacePackageDirs(workspaceRoot) {
|
|
|
4511
4590
|
return workspacePackageDirsCache.get(workspaceRoot);
|
|
4512
4591
|
}
|
|
4513
4592
|
const packageMap = /* @__PURE__ */ new Map();
|
|
4514
|
-
const packagesDir =
|
|
4593
|
+
const packagesDir = join5(workspaceRoot, "packages");
|
|
4515
4594
|
if (!existsSync4(packagesDir)) {
|
|
4516
4595
|
workspacePackageDirsCache.set(workspaceRoot, packageMap);
|
|
4517
4596
|
return packageMap;
|
|
@@ -4525,7 +4604,7 @@ function getWorkspacePackageDirs(workspaceRoot) {
|
|
|
4525
4604
|
} catch {
|
|
4526
4605
|
return;
|
|
4527
4606
|
}
|
|
4528
|
-
const pkgJsonPath =
|
|
4607
|
+
const pkgJsonPath = join5(dir, "package.json");
|
|
4529
4608
|
if (existsSync4(pkgJsonPath)) {
|
|
4530
4609
|
try {
|
|
4531
4610
|
const pkg4 = JSON.parse(readFileSync2(pkgJsonPath, "utf8"));
|
|
@@ -4538,7 +4617,7 @@ function getWorkspacePackageDirs(workspaceRoot) {
|
|
|
4538
4617
|
for (const entry of entries) {
|
|
4539
4618
|
if (entry === "node_modules" || entry === ".git" || entry.startsWith("."))
|
|
4540
4619
|
continue;
|
|
4541
|
-
const entryPath =
|
|
4620
|
+
const entryPath = join5(dir, entry);
|
|
4542
4621
|
try {
|
|
4543
4622
|
const stat8 = statSync2(entryPath);
|
|
4544
4623
|
if (stat8.isDirectory()) {
|
|
@@ -4578,7 +4657,7 @@ function resolveWorkspaceVueImport(specifier, importingFilePath) {
|
|
|
4578
4657
|
const packageDir = packageDirs.get(packageName);
|
|
4579
4658
|
if (!packageDir)
|
|
4580
4659
|
return null;
|
|
4581
|
-
const pkgJsonPath =
|
|
4660
|
+
const pkgJsonPath = join5(packageDir, "package.json");
|
|
4582
4661
|
try {
|
|
4583
4662
|
const pkg4 = JSON.parse(readFileSync2(pkgJsonPath, "utf8"));
|
|
4584
4663
|
if (pkg4.exports && subpath !== ".") {
|
|
@@ -4591,8 +4670,8 @@ function resolveWorkspaceVueImport(specifier, importingFilePath) {
|
|
|
4591
4670
|
}
|
|
4592
4671
|
if (subpath !== ".") {
|
|
4593
4672
|
const subDir = resolve4(packageDir, subpath.replace(/^\.\//, ""));
|
|
4594
|
-
for (const base of [
|
|
4595
|
-
const subPkgPath =
|
|
4673
|
+
for (const base of [join5(packageDir, "src", subpath.replace(/^\.\//, "")), subDir]) {
|
|
4674
|
+
const subPkgPath = join5(base, "package.json");
|
|
4596
4675
|
if (existsSync4(subPkgPath)) {
|
|
4597
4676
|
try {
|
|
4598
4677
|
const subPkg = JSON.parse(readFileSync2(subPkgPath, "utf8"));
|
|
@@ -5056,7 +5135,7 @@ var init_astro = __esm({
|
|
|
5056
5135
|
});
|
|
5057
5136
|
|
|
5058
5137
|
// packages/experience-design-system-extraction/dist/src/extract/web-components.js
|
|
5059
|
-
import { basename as basename3, dirname as dirname5, join as
|
|
5138
|
+
import { basename as basename3, dirname as dirname5, join as join6, resolve as resolve5 } from "node:path";
|
|
5060
5139
|
import { Project as Project5, Node as Node8, SyntaxKind as SyntaxKind6 } from "ts-morph";
|
|
5061
5140
|
function normalizeComponentName(input) {
|
|
5062
5141
|
return input.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
|
|
@@ -5709,14 +5788,14 @@ function resolveImportSourcePath2(fromFilePath, specifier) {
|
|
|
5709
5788
|
if (!specifier.startsWith(spectrumPrefix)) {
|
|
5710
5789
|
return null;
|
|
5711
5790
|
}
|
|
5712
|
-
const packagesMarker = `${
|
|
5791
|
+
const packagesMarker = `${join6("2nd-gen", "packages")}${fromFilePath.includes("\\") ? "\\" : "/"}`;
|
|
5713
5792
|
const markerIndex = fromFilePath.lastIndexOf(packagesMarker);
|
|
5714
5793
|
if (markerIndex === -1) {
|
|
5715
5794
|
return null;
|
|
5716
5795
|
}
|
|
5717
5796
|
const packagesRoot = fromFilePath.slice(0, markerIndex + packagesMarker.length - 1);
|
|
5718
5797
|
const componentPath = specifier.slice(spectrumPrefix.length);
|
|
5719
|
-
return
|
|
5798
|
+
return join6(packagesRoot, "core", "components", componentPath, "index.ts");
|
|
5720
5799
|
}
|
|
5721
5800
|
function getImportedBaseClass(classDecl, project, visitedFiles) {
|
|
5722
5801
|
const extendsClause = classDecl.getHeritageClauses().find((clause) => clause.getToken() === SyntaxKind6.ExtendsKeyword);
|
|
@@ -5982,7 +6061,7 @@ var init_scoring = __esm({
|
|
|
5982
6061
|
});
|
|
5983
6062
|
|
|
5984
6063
|
// packages/experience-design-system-extraction/dist/src/extract/svelte.js
|
|
5985
|
-
import { basename as basename4, dirname as dirname6, resolve as resolve6, join as
|
|
6064
|
+
import { basename as basename4, dirname as dirname6, resolve as resolve6, join as join7 } from "node:path";
|
|
5986
6065
|
import { existsSync as existsSync5, readFileSync as readFileSync3 } from "node:fs";
|
|
5987
6066
|
import { createRequire } from "node:module";
|
|
5988
6067
|
import os3 from "node:os";
|
|
@@ -6117,7 +6196,7 @@ async function maybeRunResolveUnreachableRetry(components, warnings, retryContex
|
|
|
6117
6196
|
function findNearestTsconfig(startDir) {
|
|
6118
6197
|
let dir = startDir;
|
|
6119
6198
|
for (let i = 0; i < 16; i++) {
|
|
6120
|
-
const candidate =
|
|
6199
|
+
const candidate = join7(dir, "tsconfig.json");
|
|
6121
6200
|
if (existsSync5(candidate))
|
|
6122
6201
|
return candidate;
|
|
6123
6202
|
const parent = dirname6(dir);
|
|
@@ -6253,7 +6332,7 @@ function locateDtsForSpecifier(req, specifier, parentFile) {
|
|
|
6253
6332
|
const seedDir = resolvedJs ? dirname6(resolvedJs) : dirname6(parentFile);
|
|
6254
6333
|
const pkgRoot = findPackageRootForSpecifier(seedDir, specifier);
|
|
6255
6334
|
if (pkgRoot) {
|
|
6256
|
-
const pkgJsonPath =
|
|
6335
|
+
const pkgJsonPath = join7(pkgRoot, "package.json");
|
|
6257
6336
|
if (existsSync5(pkgJsonPath)) {
|
|
6258
6337
|
try {
|
|
6259
6338
|
const pkgRaw = readFileSync3(pkgJsonPath, "utf-8");
|
|
@@ -6274,7 +6353,7 @@ function locateDtsForSpecifier(req, specifier, parentFile) {
|
|
|
6274
6353
|
}
|
|
6275
6354
|
}
|
|
6276
6355
|
for (const entry of ["index.d.ts", "index.d.mts"]) {
|
|
6277
|
-
const candidate =
|
|
6356
|
+
const candidate = join7(pkgRoot, entry);
|
|
6278
6357
|
if (existsSync5(candidate))
|
|
6279
6358
|
return candidate;
|
|
6280
6359
|
}
|
|
@@ -6292,9 +6371,9 @@ function locateDtsForSpecifier(req, specifier, parentFile) {
|
|
|
6292
6371
|
function findPackageRootForSpecifier(seedDir, specifier) {
|
|
6293
6372
|
let dir = seedDir;
|
|
6294
6373
|
for (let i = 0; i < 32; i++) {
|
|
6295
|
-
if (existsSync5(
|
|
6374
|
+
if (existsSync5(join7(dir, "package.json"))) {
|
|
6296
6375
|
try {
|
|
6297
|
-
const pkgRaw = readFileSync3(
|
|
6376
|
+
const pkgRaw = readFileSync3(join7(dir, "package.json"), "utf-8");
|
|
6298
6377
|
const pkg4 = JSON.parse(pkgRaw);
|
|
6299
6378
|
if (pkg4.name === specifier)
|
|
6300
6379
|
return dir;
|
|
@@ -7269,11 +7348,11 @@ function getPathPreferenceScore(filePath) {
|
|
|
7269
7348
|
const normalized = filePath.replace(/\\/g, "/");
|
|
7270
7349
|
const segments = normalized.split("/").filter(Boolean);
|
|
7271
7350
|
const filename = segments.at(-1) ?? "";
|
|
7272
|
-
const
|
|
7351
|
+
const basename8 = filename.replace(/\.[^.]+$/, "");
|
|
7273
7352
|
let score = 0;
|
|
7274
7353
|
if (/^index\.[jt]sx?$/.test(filename))
|
|
7275
7354
|
score += 100;
|
|
7276
|
-
if (
|
|
7355
|
+
if (basename8 && segments.at(-2) === basename8)
|
|
7277
7356
|
score -= 10;
|
|
7278
7357
|
const componentsSegmentCount = segments.filter((segment) => segment === "components").length;
|
|
7279
7358
|
score -= componentsSegmentCount * 8;
|
|
@@ -8105,18 +8184,18 @@ var init_src2 = __esm({
|
|
|
8105
8184
|
|
|
8106
8185
|
// packages/experience-design-system-cli/src/lib/cli-path.ts
|
|
8107
8186
|
import { existsSync as existsSync6 } from "node:fs";
|
|
8108
|
-
import { dirname as dirname7, join as
|
|
8187
|
+
import { dirname as dirname7, join as join8 } from "node:path";
|
|
8109
8188
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8110
8189
|
function findCliPath() {
|
|
8111
8190
|
let dir = dirname7(fileURLToPath2(import.meta.url));
|
|
8112
8191
|
for (let i = 0; i < 8; i++) {
|
|
8113
|
-
const candidate =
|
|
8192
|
+
const candidate = join8(dir, "bin", "cli.js");
|
|
8114
8193
|
if (existsSync6(candidate)) return candidate;
|
|
8115
8194
|
const parent = dirname7(dir);
|
|
8116
8195
|
if (parent === dir) break;
|
|
8117
8196
|
dir = parent;
|
|
8118
8197
|
}
|
|
8119
|
-
return
|
|
8198
|
+
return join8(fileURLToPath2(import.meta.url), "..", "..", "..", "..", "bin", "cli.js");
|
|
8120
8199
|
}
|
|
8121
8200
|
function findPkgRoot() {
|
|
8122
8201
|
return dirname7(dirname7(findCliPath()));
|
|
@@ -8129,7 +8208,7 @@ var init_cli_path = __esm({
|
|
|
8129
8208
|
|
|
8130
8209
|
// packages/experience-design-system-cli/src/analyze/select/tui/components/TopBar.tsx
|
|
8131
8210
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
8132
|
-
import { join as
|
|
8211
|
+
import { join as join9 } from "node:path";
|
|
8133
8212
|
import { Box, Text } from "ink";
|
|
8134
8213
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8135
8214
|
function TopBar({ subcommand, hints }) {
|
|
@@ -8146,7 +8225,7 @@ var init_TopBar = __esm({
|
|
|
8146
8225
|
"packages/experience-design-system-cli/src/analyze/select/tui/components/TopBar.tsx"() {
|
|
8147
8226
|
"use strict";
|
|
8148
8227
|
init_cli_path();
|
|
8149
|
-
VERSION = JSON.parse(readFileSync4(
|
|
8228
|
+
VERSION = JSON.parse(readFileSync4(join9(findPkgRoot(), "package.json"), "utf8")).version;
|
|
8150
8229
|
}
|
|
8151
8230
|
});
|
|
8152
8231
|
|
|
@@ -10943,13 +11022,13 @@ var init_persistence = __esm({
|
|
|
10943
11022
|
// packages/experience-design-system-cli/src/analyze/select/parser.ts
|
|
10944
11023
|
import { createHash as createHash6 } from "node:crypto";
|
|
10945
11024
|
import { access as access2 } from "node:fs/promises";
|
|
10946
|
-
import { isAbsolute, relative, resolve as resolve10 } from "node:path";
|
|
11025
|
+
import { isAbsolute as isAbsolute2, relative, resolve as resolve10 } from "node:path";
|
|
10947
11026
|
function createComponentId(name, resolvedSourcePath) {
|
|
10948
11027
|
const sourceHash = createHash6("sha256").update(`${name}:${resolvedSourcePath}`).digest("hex").slice(0, 12);
|
|
10949
11028
|
return `${name}-${sourceHash}`;
|
|
10950
11029
|
}
|
|
10951
11030
|
async function resolveComponentSourcePath(source, reviewRoot) {
|
|
10952
|
-
if (
|
|
11031
|
+
if (isAbsolute2(source)) {
|
|
10953
11032
|
try {
|
|
10954
11033
|
await access2(source);
|
|
10955
11034
|
return source;
|
|
@@ -10959,7 +11038,7 @@ async function resolveComponentSourcePath(source, reviewRoot) {
|
|
|
10959
11038
|
}
|
|
10960
11039
|
const candidate = resolve10(reviewRoot, source);
|
|
10961
11040
|
const relativeToRoot = relative(reviewRoot, candidate);
|
|
10962
|
-
if (relativeToRoot.startsWith("..") || relativeToRoot === ".." ||
|
|
11041
|
+
if (relativeToRoot.startsWith("..") || relativeToRoot === ".." || isAbsolute2(relativeToRoot)) {
|
|
10963
11042
|
throw new Error(
|
|
10964
11043
|
`Resolved component source is outside the review root: ${source}. Pass --project-root <path> to set the correct base.`
|
|
10965
11044
|
);
|
|
@@ -12750,7 +12829,7 @@ var init_host_utils = __esm({
|
|
|
12750
12829
|
|
|
12751
12830
|
// packages/experience-design-system-cli/src/lib/debug-logger.ts
|
|
12752
12831
|
import { mkdirSync as mkdirSync2, appendFileSync } from "node:fs";
|
|
12753
|
-
import { join as
|
|
12832
|
+
import { join as join10, dirname as dirname9 } from "node:path";
|
|
12754
12833
|
import { homedir as homedir3 } from "node:os";
|
|
12755
12834
|
function redactValue(value, seen) {
|
|
12756
12835
|
if (value === null || value === void 0) return value;
|
|
@@ -12776,7 +12855,7 @@ function redactForDebug(payload) {
|
|
|
12776
12855
|
return redactValue(payload, /* @__PURE__ */ new WeakSet());
|
|
12777
12856
|
}
|
|
12778
12857
|
function defaultDebugRoot() {
|
|
12779
|
-
return process.env[DEBUG_ROOT_ENV] ??
|
|
12858
|
+
return process.env[DEBUG_ROOT_ENV] ?? join10(homedir3(), ".contentful", "experience-design-system-cli", "debug");
|
|
12780
12859
|
}
|
|
12781
12860
|
function makeSessionTimestamp() {
|
|
12782
12861
|
const override = process.env["EDSI_DEBUG_TS"];
|
|
@@ -12800,7 +12879,7 @@ function initDebugLogger(opts) {
|
|
|
12800
12879
|
const root = opts.root ?? defaultDebugRoot();
|
|
12801
12880
|
const ts3 = makeSessionTimestamp();
|
|
12802
12881
|
const suffix = opts.command ? `-${opts.command}` : "";
|
|
12803
|
-
const path =
|
|
12882
|
+
const path = join10(root, `${ts3}${suffix}.jsonl`);
|
|
12804
12883
|
singleton = new FileDebugLogger(path);
|
|
12805
12884
|
process.env[DEBUG_LOG_ENV] = path;
|
|
12806
12885
|
if (opts.command) singleton.event("config", "command.start", { command: opts.command });
|
|
@@ -12921,7 +13000,7 @@ var init_debug_logger = __esm({
|
|
|
12921
13000
|
|
|
12922
13001
|
// packages/experience-design-system-cli/src/lib/user-agent.ts
|
|
12923
13002
|
import { readFileSync as readFileSync6 } from "node:fs";
|
|
12924
|
-
import { join as
|
|
13003
|
+
import { join as join11 } from "node:path";
|
|
12925
13004
|
function buildUserAgent(version = pkg.version) {
|
|
12926
13005
|
const parts = [`app ${APP}/${version}`, `platform node.js/${process.version}`];
|
|
12927
13006
|
const os4 = OS_NAMES[process.platform];
|
|
@@ -12933,7 +13012,7 @@ var init_user_agent = __esm({
|
|
|
12933
13012
|
"packages/experience-design-system-cli/src/lib/user-agent.ts"() {
|
|
12934
13013
|
"use strict";
|
|
12935
13014
|
init_cli_path();
|
|
12936
|
-
pkg = JSON.parse(readFileSync6(
|
|
13015
|
+
pkg = JSON.parse(readFileSync6(join11(findPkgRoot(), "package.json"), "utf8"));
|
|
12937
13016
|
APP = "contentful.experience-design-system-cli";
|
|
12938
13017
|
OS_NAMES = {
|
|
12939
13018
|
android: "Android",
|
|
@@ -14379,7 +14458,7 @@ __export(credentials_store_exports, {
|
|
|
14379
14458
|
writeExperiencesCredentials: () => writeExperiencesCredentials
|
|
14380
14459
|
});
|
|
14381
14460
|
import { readFile as readFile8, writeFile as writeFile2, mkdir as mkdir2 } from "node:fs/promises";
|
|
14382
|
-
import { join as
|
|
14461
|
+
import { join as join12 } from "node:path";
|
|
14383
14462
|
import { homedir as homedir4 } from "node:os";
|
|
14384
14463
|
async function readExperiencesCredentials() {
|
|
14385
14464
|
try {
|
|
@@ -14455,14 +14534,14 @@ var init_credentials_store = __esm({
|
|
|
14455
14534
|
"use strict";
|
|
14456
14535
|
init_host_utils();
|
|
14457
14536
|
init_composition_mode();
|
|
14458
|
-
CREDENTIALS_DIR =
|
|
14459
|
-
CREDENTIALS_PATH =
|
|
14537
|
+
CREDENTIALS_DIR = join12(homedir4(), ".config", "experiences");
|
|
14538
|
+
CREDENTIALS_PATH = join12(CREDENTIALS_DIR, "credentials.json");
|
|
14460
14539
|
}
|
|
14461
14540
|
});
|
|
14462
14541
|
|
|
14463
14542
|
// packages/experience-design-system-cli/src/analytics/client.ts
|
|
14464
14543
|
import { readFileSync as readFileSync7 } from "node:fs";
|
|
14465
|
-
import { join as
|
|
14544
|
+
import { join as join13 } from "node:path";
|
|
14466
14545
|
import { Analytics } from "@segment/analytics-node";
|
|
14467
14546
|
function cliVersion() {
|
|
14468
14547
|
return pkg2.version;
|
|
@@ -14516,7 +14595,7 @@ var init_client2 = __esm({
|
|
|
14516
14595
|
"packages/experience-design-system-cli/src/analytics/client.ts"() {
|
|
14517
14596
|
"use strict";
|
|
14518
14597
|
init_cli_path();
|
|
14519
|
-
pkg2 = JSON.parse(readFileSync7(
|
|
14598
|
+
pkg2 = JSON.parse(readFileSync7(join13(findPkgRoot(), "package.json"), "utf8"));
|
|
14520
14599
|
DEFAULT_WRITE_KEY = "6DmxiEPN3SV1vbRTTMcNqDzCvkfwT06N";
|
|
14521
14600
|
analyticsClient = null;
|
|
14522
14601
|
persistedDisabled = false;
|
|
@@ -14813,7 +14892,7 @@ var init_path_exists = __esm({
|
|
|
14813
14892
|
import { createElement, useState as useState6 } from "react";
|
|
14814
14893
|
import { render, useInput as useInput2 } from "ink";
|
|
14815
14894
|
import { readFile as readFile9, readdir, stat } from "node:fs/promises";
|
|
14816
|
-
import { join as
|
|
14895
|
+
import { join as join14 } from "node:path";
|
|
14817
14896
|
import {
|
|
14818
14897
|
validateCDF,
|
|
14819
14898
|
flattenDTCG as flattenDTCG2,
|
|
@@ -14857,7 +14936,7 @@ async function collectJsonFiles(dir) {
|
|
|
14857
14936
|
await Promise.all(
|
|
14858
14937
|
entries.map(async (entry) => {
|
|
14859
14938
|
if (IGNORE_TOKEN_DIRS.has(entry)) return;
|
|
14860
|
-
const full =
|
|
14939
|
+
const full = join14(current, entry);
|
|
14861
14940
|
let s;
|
|
14862
14941
|
try {
|
|
14863
14942
|
s = await stat(full);
|
|
@@ -16678,7 +16757,7 @@ var init_fetch_existing_contentful_entities = __esm({
|
|
|
16678
16757
|
|
|
16679
16758
|
// packages/experience-design-system-cli/src/helpers/fetch-and-persist-existing-contentful-entities.ts
|
|
16680
16759
|
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
16681
|
-
import { join as
|
|
16760
|
+
import { join as join20 } from "node:path";
|
|
16682
16761
|
async function fetchAndPersistExistingContentfulEntities(params) {
|
|
16683
16762
|
const t0 = Date.now();
|
|
16684
16763
|
try {
|
|
@@ -16690,7 +16769,7 @@ async function fetchAndPersistExistingContentfulEntities(params) {
|
|
|
16690
16769
|
spaceId: params.spaceId,
|
|
16691
16770
|
environmentId: params.environmentId
|
|
16692
16771
|
});
|
|
16693
|
-
const path =
|
|
16772
|
+
const path = join20(params.outDir, ".existing-entities.json");
|
|
16694
16773
|
await writeFile5(path, JSON.stringify(entities, null, 2), "utf8");
|
|
16695
16774
|
return { ok: true, path, durationMs: Date.now() - t0, entities };
|
|
16696
16775
|
} catch (error) {
|
|
@@ -16711,7 +16790,7 @@ var init_fetch_and_persist_existing_contentful_entities = __esm({
|
|
|
16711
16790
|
|
|
16712
16791
|
// packages/experience-design-system-cli/src/runs/save-path-resolver.ts
|
|
16713
16792
|
import { access as access7 } from "node:fs/promises";
|
|
16714
|
-
import { join as
|
|
16793
|
+
import { join as join22 } from "node:path";
|
|
16715
16794
|
function isConflictMode(value) {
|
|
16716
16795
|
return CONFLICT_MODES.includes(value);
|
|
16717
16796
|
}
|
|
@@ -16719,7 +16798,7 @@ async function listConflictingFiles(path) {
|
|
|
16719
16798
|
const conflicts = [];
|
|
16720
16799
|
for (const name of SAVE_FILES) {
|
|
16721
16800
|
try {
|
|
16722
|
-
await access7(
|
|
16801
|
+
await access7(join22(path, name));
|
|
16723
16802
|
conflicts.push(name);
|
|
16724
16803
|
} catch {
|
|
16725
16804
|
}
|
|
@@ -16739,7 +16818,7 @@ function buildTimestampedSubdir(base, now = /* @__PURE__ */ new Date()) {
|
|
|
16739
16818
|
const hh = pad2(now.getHours());
|
|
16740
16819
|
const mm = pad2(now.getMinutes());
|
|
16741
16820
|
const ss = pad2(now.getSeconds());
|
|
16742
|
-
return
|
|
16821
|
+
return join22(base, `dsi-${y}${m}${d}-${hh}${mm}${ss}`);
|
|
16743
16822
|
}
|
|
16744
16823
|
async function resolveSavePath(path, options = {}) {
|
|
16745
16824
|
const conflicts = await listConflictingFiles(path);
|
|
@@ -16770,7 +16849,7 @@ var init_save_path_resolver = __esm({
|
|
|
16770
16849
|
|
|
16771
16850
|
// packages/experience-design-system-cli/src/runs/store.ts
|
|
16772
16851
|
import { readFile as readFile21, writeFile as writeFile6, mkdir as mkdir6, rename } from "node:fs/promises";
|
|
16773
|
-
import { join as
|
|
16852
|
+
import { join as join23 } from "node:path";
|
|
16774
16853
|
import { homedir as homedir7 } from "node:os";
|
|
16775
16854
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
16776
16855
|
function runsFilePath() {
|
|
@@ -16891,8 +16970,8 @@ var init_store = __esm({
|
|
|
16891
16970
|
RUNS_FILE_VERSION = 3;
|
|
16892
16971
|
RUNS_FILE_CAP = 200;
|
|
16893
16972
|
READABLE_VERSIONS = /* @__PURE__ */ new Set([1, 2, 3]);
|
|
16894
|
-
RUNS_DIR =
|
|
16895
|
-
RUNS_PATH =
|
|
16973
|
+
RUNS_DIR = join23(homedir7(), ".config", "experiences");
|
|
16974
|
+
RUNS_PATH = join23(RUNS_DIR, "runs.json");
|
|
16896
16975
|
CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
16897
16976
|
}
|
|
16898
16977
|
});
|
|
@@ -16927,11 +17006,12 @@ async function resolveRunTarget(arg) {
|
|
|
16927
17006
|
}
|
|
16928
17007
|
function looksLikePath2(arg) {
|
|
16929
17008
|
if (arg === "." || arg === "~") return true;
|
|
16930
|
-
|
|
17009
|
+
if (/^[A-Za-z]:[\\/]/.test(arg) || arg.startsWith("\\\\")) return true;
|
|
17010
|
+
return arg.startsWith("/") || arg.startsWith("./") || arg.startsWith("../") || arg.startsWith(".\\") || arg.startsWith("..\\") || arg.startsWith("~/") || arg.startsWith("~\\");
|
|
16931
17011
|
}
|
|
16932
17012
|
function expandHome(arg) {
|
|
16933
17013
|
if (arg === "~") return homedir8();
|
|
16934
|
-
if (arg.startsWith("~/")) return resolvePath(homedir8(), arg.slice(2));
|
|
17014
|
+
if (arg.startsWith("~/") || arg.startsWith("~\\")) return resolvePath(homedir8(), arg.slice(2));
|
|
16935
17015
|
return arg;
|
|
16936
17016
|
}
|
|
16937
17017
|
var init_resolve_run_target = __esm({
|
|
@@ -16972,13 +17052,13 @@ var init_use_blinking_cursor = __esm({
|
|
|
16972
17052
|
import { useState as useState10 } from "react";
|
|
16973
17053
|
import { Box as Box20, Text as Text21 } from "ink";
|
|
16974
17054
|
import { readdirSync as readdirSync3 } from "node:fs";
|
|
16975
|
-
import { dirname as dirname14, basename as
|
|
17055
|
+
import { dirname as dirname14, basename as basename7, join as join24 } from "node:path";
|
|
16976
17056
|
import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
16977
17057
|
function autocomplete(partial) {
|
|
16978
17058
|
if (!partial) return null;
|
|
16979
17059
|
const normalized = normalizePath(partial);
|
|
16980
17060
|
const dir = dirname14(normalized);
|
|
16981
|
-
const base =
|
|
17061
|
+
const base = basename7(normalized);
|
|
16982
17062
|
let entries;
|
|
16983
17063
|
try {
|
|
16984
17064
|
entries = readdirSync3(dir);
|
|
@@ -16987,13 +17067,13 @@ function autocomplete(partial) {
|
|
|
16987
17067
|
}
|
|
16988
17068
|
const matches = entries.filter((e) => e.startsWith(base));
|
|
16989
17069
|
if (matches.length === 0) return null;
|
|
16990
|
-
if (matches.length === 1) return
|
|
17070
|
+
if (matches.length === 1) return join24(dir, matches[0]);
|
|
16991
17071
|
let prefix = matches[0];
|
|
16992
17072
|
for (const m of matches) {
|
|
16993
17073
|
while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
|
|
16994
17074
|
if (!prefix) break;
|
|
16995
17075
|
}
|
|
16996
|
-
return prefix.length > base.length ?
|
|
17076
|
+
return prefix.length > base.length ? join24(dir, prefix) : null;
|
|
16997
17077
|
}
|
|
16998
17078
|
function PathPrompt({
|
|
16999
17079
|
defaultPath,
|
|
@@ -17585,7 +17665,7 @@ var init_WelcomeStep = __esm({
|
|
|
17585
17665
|
import { useState as useState14, useEffect as useEffect4 } from "react";
|
|
17586
17666
|
import { Box as Box25, Text as Text26 } from "ink";
|
|
17587
17667
|
import { promises as fs } from "node:fs";
|
|
17588
|
-
import { join as
|
|
17668
|
+
import { join as join25 } from "node:path";
|
|
17589
17669
|
import { jsx as jsx28, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
17590
17670
|
async function countFiles(dir) {
|
|
17591
17671
|
const counts = {
|
|
@@ -17609,7 +17689,7 @@ async function countFiles(dir) {
|
|
|
17609
17689
|
await Promise.all(
|
|
17610
17690
|
entries.map(async (entry) => {
|
|
17611
17691
|
if (IGNORE_DIRS.has(entry)) return;
|
|
17612
|
-
const full =
|
|
17692
|
+
const full = join25(current, entry);
|
|
17613
17693
|
let stat8;
|
|
17614
17694
|
try {
|
|
17615
17695
|
stat8 = await fs.stat(full);
|
|
@@ -27938,11 +28018,11 @@ __export(WizardApp_exports, {
|
|
|
27938
28018
|
});
|
|
27939
28019
|
import { useEffect as useEffect13, useRef as useRef10, useState as useState33 } from "react";
|
|
27940
28020
|
import { Box as Box57, Text as Text61, useStdout as useStdout7 } from "ink";
|
|
27941
|
-
import { join as
|
|
28021
|
+
import { join as join26, resolve as resolve25 } from "node:path";
|
|
27942
28022
|
import { appendFileSync as appendFileSync2, writeFileSync } from "node:fs";
|
|
27943
28023
|
import { access as access8, readFile as readFile23, stat as stat6 } from "node:fs/promises";
|
|
27944
28024
|
import { tmpdir } from "node:os";
|
|
27945
|
-
import { execFile as
|
|
28025
|
+
import { execFile as execFile3, spawn as spawn4 } from "node:child_process";
|
|
27946
28026
|
import { mkdir as mkdir7 } from "node:fs/promises";
|
|
27947
28027
|
import { buildManifest as buildManifest4 } from "@contentful/experience-design-system-types";
|
|
27948
28028
|
import { jsx as jsx65, jsxs as jsxs58 } from "react/jsx-runtime";
|
|
@@ -28010,14 +28090,14 @@ function formatAcceptanceSummary(opts) {
|
|
|
28010
28090
|
}
|
|
28011
28091
|
function runCli2(args) {
|
|
28012
28092
|
return new Promise((res) => {
|
|
28013
|
-
|
|
28093
|
+
execFile3(process.execPath, [findCliPath(), ...args], (error, stdout, stderr) => {
|
|
28014
28094
|
res({ exitCode: error?.code ? Number(error.code) : 0, stdout, stderr });
|
|
28015
28095
|
});
|
|
28016
28096
|
});
|
|
28017
28097
|
}
|
|
28018
28098
|
function runSpawnedCli(args, onStderr) {
|
|
28019
28099
|
return new Promise((res) => {
|
|
28020
|
-
const child = spawn4(
|
|
28100
|
+
const child = spawn4(process.execPath, args);
|
|
28021
28101
|
let stdout = "";
|
|
28022
28102
|
let stderr = "";
|
|
28023
28103
|
child.stdout.on("data", (d) => {
|
|
@@ -28116,8 +28196,8 @@ function WizardApp({
|
|
|
28116
28196
|
const rawTokensEntryReady = !modifyEntryReady && !pushFromPickerReady && !!initialRawTokensPath;
|
|
28117
28197
|
const effectiveNoCache = resolveNoCacheForGenerate({ cliNoCache: noCache });
|
|
28118
28198
|
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 ?
|
|
28199
|
+
const initialOutDir = initialProjectPath ? join26(resolve25(initialProjectPath), ".contentful") : "";
|
|
28200
|
+
const initialTokensPath = (modifyEntryReady || pushFromPickerReady) && initialOutDir && seedTokenSessionId ? join26(initialOutDir, "tokens.json") : "";
|
|
28121
28201
|
const [state, setState] = useState33({
|
|
28122
28202
|
step: modifyEntryReady || rawTokensEntryReady || pushFromPickerReady ? initialStepResolved : initialRuns && initialRuns.length > 0 ? "run-picker" : initialStepResolved,
|
|
28123
28203
|
agent: initialAgent ?? "claude",
|
|
@@ -28274,7 +28354,7 @@ If you are using AWS Bedrock, run:
|
|
|
28274
28354
|
}
|
|
28275
28355
|
const sessionMatch = /^session=(.+)$/m.exec(result.stdout);
|
|
28276
28356
|
const tokenSessionId = sessionMatch ? sessionMatch[1].trim() : null;
|
|
28277
|
-
const tokensPath =
|
|
28357
|
+
const tokensPath = join26(outDir, "tokens.json");
|
|
28278
28358
|
const printArgs = ["print", "tokens", "--out", tokensPath];
|
|
28279
28359
|
if (tokenSessionId) printArgs.push("--session", tokenSessionId);
|
|
28280
28360
|
const r = await runCli2(printArgs);
|
|
@@ -28294,7 +28374,7 @@ If you are using AWS Bedrock, run:
|
|
|
28294
28374
|
tokenCount,
|
|
28295
28375
|
skipComponents: true,
|
|
28296
28376
|
acceptedCount: 0,
|
|
28297
|
-
outDir: state.outDir ||
|
|
28377
|
+
outDir: state.outDir || join26(process.cwd(), ".contentful")
|
|
28298
28378
|
});
|
|
28299
28379
|
if (noPush) {
|
|
28300
28380
|
void startSaveFlow();
|
|
@@ -28361,7 +28441,7 @@ If you are using AWS Bedrock, run:
|
|
|
28361
28441
|
return true;
|
|
28362
28442
|
};
|
|
28363
28443
|
const runExtract = async (projectPath) => {
|
|
28364
|
-
const outDir =
|
|
28444
|
+
const outDir = join26(resolve25(projectPath), ".contentful");
|
|
28365
28445
|
update({ step: "extracting", outDir, extractProgress: null, compositionPhase: null });
|
|
28366
28446
|
const extractArgs = [findCliPath(), "analyze", "extract", "--project", projectPath];
|
|
28367
28447
|
if (compositionMode === "composite") {
|
|
@@ -28460,7 +28540,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
28460
28540
|
noCache,
|
|
28461
28541
|
...state.existingEntitiesPath ? { existingEntitiesPath: state.existingEntitiesPath } : {}
|
|
28462
28542
|
});
|
|
28463
|
-
const child = spawn4(
|
|
28543
|
+
const child = spawn4(process.execPath, [findCliPath(), ...args]);
|
|
28464
28544
|
autoFilterChildRef.current = child;
|
|
28465
28545
|
let stderr = "";
|
|
28466
28546
|
child.stderr.on("data", (d) => {
|
|
@@ -28561,7 +28641,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
28561
28641
|
const args = buildGenerateArgs(extractSessionId, tokensPath);
|
|
28562
28642
|
let progressCursor = null;
|
|
28563
28643
|
const { child, donePromise } = spawnGenerateChild({
|
|
28564
|
-
command:
|
|
28644
|
+
command: process.execPath,
|
|
28565
28645
|
args,
|
|
28566
28646
|
onStderr: (chunk) => {
|
|
28567
28647
|
const nextProgress = parseGenerateStderrChunk(chunk, progressCursor);
|
|
@@ -28616,7 +28696,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
28616
28696
|
const args = buildGenerateArgs(extractSessionId, tokensPath, generatePromptPath);
|
|
28617
28697
|
let progressCursor = state.generateProgress;
|
|
28618
28698
|
const { donePromise } = spawnGenerateChild({
|
|
28619
|
-
command:
|
|
28699
|
+
command: process.execPath,
|
|
28620
28700
|
args,
|
|
28621
28701
|
onStderr: (chunk) => {
|
|
28622
28702
|
const nextProgress = parseGenerateStderrChunk(chunk, progressCursor);
|
|
@@ -28718,7 +28798,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
28718
28798
|
};
|
|
28719
28799
|
const advanceAfterCredentialsValidated = async () => {
|
|
28720
28800
|
if (!state.credentialsSkipped && state.spaceId && state.environmentId && state.cmaToken && state.projectPath) {
|
|
28721
|
-
const outDir =
|
|
28801
|
+
const outDir = join26(resolve25(state.projectPath), ".contentful");
|
|
28722
28802
|
await mkdir7(outDir, { recursive: true });
|
|
28723
28803
|
const result = await fetchAndPersistExistingContentfulEntities({
|
|
28724
28804
|
spaceId: state.spaceId,
|
|
@@ -29090,7 +29170,7 @@ If using a custom --host, make sure the space exists on that host.`
|
|
|
29090
29170
|
};
|
|
29091
29171
|
const runPrintFiles = async (extractSessionId, outDir, opts = {}) => {
|
|
29092
29172
|
update({ step: "printing" });
|
|
29093
|
-
const componentsPath =
|
|
29173
|
+
const componentsPath = join26(outDir, "components.json");
|
|
29094
29174
|
const printArgs = ["print", "components", "--out", componentsPath];
|
|
29095
29175
|
if (extractSessionId) printArgs.push("--session", extractSessionId);
|
|
29096
29176
|
if (opts.allowEmpty) printArgs.push("--allow-empty");
|
|
@@ -29106,7 +29186,7 @@ If using a custom --host, make sure the space exists on that host.`
|
|
|
29106
29186
|
let emittedTokensPath;
|
|
29107
29187
|
let emittedTokenCount;
|
|
29108
29188
|
if (opts.tokenSessionId) {
|
|
29109
|
-
const tokensOut =
|
|
29189
|
+
const tokensOut = join26(outDir, "tokens.json");
|
|
29110
29190
|
const tokenArgs = ["print", "tokens", "--out", tokensOut, "--session", opts.tokenSessionId];
|
|
29111
29191
|
const tr = await runCli2(tokenArgs);
|
|
29112
29192
|
if (tr.exitCode !== 0) {
|
|
@@ -29193,7 +29273,7 @@ If using a custom --host, make sure the space exists on that host.`
|
|
|
29193
29273
|
);
|
|
29194
29274
|
}
|
|
29195
29275
|
try {
|
|
29196
|
-
const componentsBuf = await readFile23(
|
|
29276
|
+
const componentsBuf = await readFile23(join26(path, "components.json")).catch(() => null);
|
|
29197
29277
|
const tokensBuf = recordedTokensPath ? await readFile23(recordedTokensPath).catch(() => null) : null;
|
|
29198
29278
|
savedFingerprint = buildSavedFingerprint({
|
|
29199
29279
|
componentsJson: componentsBuf,
|
|
@@ -29235,7 +29315,7 @@ If using a custom --host, make sure the space exists on that host.`
|
|
|
29235
29315
|
if (state.step === "generating-tokens") {
|
|
29236
29316
|
if (tokenReuseChecked.current) return;
|
|
29237
29317
|
tokenReuseChecked.current = true;
|
|
29238
|
-
const existingTokensPath =
|
|
29318
|
+
const existingTokensPath = join26(state.outDir, "tokens.json");
|
|
29239
29319
|
(async () => {
|
|
29240
29320
|
try {
|
|
29241
29321
|
await access8(existingTokensPath);
|
|
@@ -29311,7 +29391,7 @@ If using a custom --host, make sure the space exists on that host.`
|
|
|
29311
29391
|
{
|
|
29312
29392
|
onContinue: (path) => {
|
|
29313
29393
|
const projectPath = normalizePath(path);
|
|
29314
|
-
const outDir =
|
|
29394
|
+
const outDir = join26(projectPath, ".contentful");
|
|
29315
29395
|
update({ step: "token-input", projectPath, outDir });
|
|
29316
29396
|
},
|
|
29317
29397
|
onQuit: () => process.exit(0)
|
|
@@ -29935,7 +30015,7 @@ var init_WizardApp = __esm({
|
|
|
29935
30015
|
init_wizard_state_transitions();
|
|
29936
30016
|
init_cycle_auto_reject();
|
|
29937
30017
|
init_cli_path();
|
|
29938
|
-
WIZARD_LOG =
|
|
30018
|
+
WIZARD_LOG = join26(tmpdir(), "experiences-import-wizard.log");
|
|
29939
30019
|
}
|
|
29940
30020
|
});
|
|
29941
30021
|
|
|
@@ -29947,7 +30027,7 @@ __export(staleness_exports, {
|
|
|
29947
30027
|
shortStalenessSummary: () => shortStalenessSummary
|
|
29948
30028
|
});
|
|
29949
30029
|
import { readFile as readFile24, stat as stat7 } from "node:fs/promises";
|
|
29950
|
-
import { join as
|
|
30030
|
+
import { join as join27 } from "node:path";
|
|
29951
30031
|
async function checkRunStaleness(run) {
|
|
29952
30032
|
if (!run.sourceFingerprint) return { ...UNKNOWN };
|
|
29953
30033
|
const result = {
|
|
@@ -29989,7 +30069,7 @@ async function checkRunStaleness(run) {
|
|
|
29989
30069
|
}
|
|
29990
30070
|
if (run.savedFingerprint) {
|
|
29991
30071
|
if (run.savedFingerprint.componentsJsonHash !== null) {
|
|
29992
|
-
const compPath =
|
|
30072
|
+
const compPath = join27(run.savePath, "components.json");
|
|
29993
30073
|
try {
|
|
29994
30074
|
const buf = await readFile24(compPath);
|
|
29995
30075
|
if (sha256Hex(buf) !== run.savedFingerprint.componentsJsonHash) {
|
|
@@ -30002,7 +30082,7 @@ async function checkRunStaleness(run) {
|
|
|
30002
30082
|
}
|
|
30003
30083
|
}
|
|
30004
30084
|
if (run.savedFingerprint.tokensJsonHash !== null) {
|
|
30005
|
-
const tokensPath = run.tokensPath ??
|
|
30085
|
+
const tokensPath = run.tokensPath ?? join27(run.savePath, "tokens.json");
|
|
30006
30086
|
try {
|
|
30007
30087
|
const buf = await readFile24(tokensPath);
|
|
30008
30088
|
if (sha256Hex(buf) !== run.savedFingerprint.tokensJsonHash) {
|
|
@@ -30110,9 +30190,8 @@ var init_push_creds_prompt = __esm({
|
|
|
30110
30190
|
});
|
|
30111
30191
|
|
|
30112
30192
|
// packages/experience-design-system-cli/src/program.ts
|
|
30113
|
-
import { spawn as spawn6 } from "node:child_process";
|
|
30114
30193
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
30115
|
-
import { dirname as dirname15, join as
|
|
30194
|
+
import { dirname as dirname15, join as join30, resolve as resolve28 } from "node:path";
|
|
30116
30195
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
30117
30196
|
import { Command } from "commander";
|
|
30118
30197
|
|
|
@@ -30120,7 +30199,7 @@ import { Command } from "commander";
|
|
|
30120
30199
|
import { createElement as createElement3 } from "react";
|
|
30121
30200
|
import { render as render3 } from "ink";
|
|
30122
30201
|
import { mkdir as mkdir3, readdir as readdir2, readFile as readFile16, stat as stat2, writeFile as writeFile3 } from "node:fs/promises";
|
|
30123
|
-
import { isAbsolute as
|
|
30202
|
+
import { isAbsolute as isAbsolute5, join as join17, relative as relative3, resolve as resolve16 } from "node:path";
|
|
30124
30203
|
|
|
30125
30204
|
// packages/experience-design-system-cli/src/lib/agent-model-options.ts
|
|
30126
30205
|
init_src();
|
|
@@ -30468,7 +30547,7 @@ var OutputFormatter = class {
|
|
|
30468
30547
|
// packages/experience-design-system-cli/src/analyze/select-agent/context-builder.ts
|
|
30469
30548
|
init_src2();
|
|
30470
30549
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
30471
|
-
import { dirname as dirname11, isAbsolute as
|
|
30550
|
+
import { dirname as dirname11, isAbsolute as isAbsolute3, join as join15, relative as relative2, resolve as resolve12, sep } from "node:path";
|
|
30472
30551
|
var SCANNED_FILE_EXTENSIONS = /* @__PURE__ */ new Set([".astro", ".js", ".jsx", ".svelte", ".ts", ".tsx", ".vue"]);
|
|
30473
30552
|
var IMPORT_PATTERN2 = /import\s+(?:type\s+)?(.+?)\s+from\s+['"]([^'"]+)['"]/g;
|
|
30474
30553
|
var EXPORT_NAMED_PATTERN = /export\s+(?:const|function|class|type|interface|enum)\s+([A-Za-z0-9_]+)/g;
|
|
@@ -30486,7 +30565,7 @@ function truncateText(text, maxChars) {
|
|
|
30486
30565
|
}
|
|
30487
30566
|
function isWithinRoot(path, root) {
|
|
30488
30567
|
const relativePath = relative2(root, path);
|
|
30489
|
-
return relativePath !== ".." && !relativePath.startsWith(`..${sep}`) && !
|
|
30568
|
+
return relativePath !== ".." && !relativePath.startsWith(`..${sep}`) && !isAbsolute3(relativePath);
|
|
30490
30569
|
}
|
|
30491
30570
|
function toPosixPath(path) {
|
|
30492
30571
|
return sep === "/" ? path : path.split(sep).join("/");
|
|
@@ -30499,7 +30578,7 @@ function resolveLocalImportPath(source, componentDirectory, root, filePaths) {
|
|
|
30499
30578
|
const candidates = [
|
|
30500
30579
|
basePath,
|
|
30501
30580
|
...[...SCANNED_FILE_EXTENSIONS].map((extension) => `${basePath}${extension}`),
|
|
30502
|
-
...[...SCANNED_FILE_EXTENSIONS].map((extension) =>
|
|
30581
|
+
...[...SCANNED_FILE_EXTENSIONS].map((extension) => join15(basePath, `index${extension}`))
|
|
30503
30582
|
];
|
|
30504
30583
|
for (const candidate of candidates) {
|
|
30505
30584
|
if (filePaths.has(candidate) && isWithinRoot(candidate, root)) {
|
|
@@ -30600,7 +30679,7 @@ async function buildRepoContextIndex(root, filePaths) {
|
|
|
30600
30679
|
};
|
|
30601
30680
|
}
|
|
30602
30681
|
function buildSelectionContext(index, component) {
|
|
30603
|
-
const absolutePath =
|
|
30682
|
+
const absolutePath = isAbsolute3(component.source) ? component.source : resolve12(index.root, component.source);
|
|
30604
30683
|
if (!isWithinRoot(absolutePath, index.root)) return void 0;
|
|
30605
30684
|
const componentFile = index.files.find((file) => file.absolutePath === absolutePath);
|
|
30606
30685
|
if (!componentFile) return void 0;
|
|
@@ -30711,7 +30790,7 @@ function runShowRationale(opts) {
|
|
|
30711
30790
|
|
|
30712
30791
|
// packages/experience-design-system-cli/src/analyze/select-agent/command.ts
|
|
30713
30792
|
init_debug_logger();
|
|
30714
|
-
import { isAbsolute as
|
|
30793
|
+
import { isAbsolute as isAbsolute4, resolve as resolve13 } from "node:path";
|
|
30715
30794
|
|
|
30716
30795
|
// packages/experience-design-system-cli/src/lib/agent-output.ts
|
|
30717
30796
|
async function invokeAgentWithOutput(invoker3, options, verbose) {
|
|
@@ -31096,7 +31175,7 @@ function registerAnalyzeSelectAgentCommand(program) {
|
|
|
31096
31175
|
process.stderr.write(c.yellow(formatExclusionWarning(invalidComponents)));
|
|
31097
31176
|
}
|
|
31098
31177
|
if (selectionRoot && scannedFiles.length > 0) {
|
|
31099
|
-
scannedFiles = scannedFiles.map((f) =>
|
|
31178
|
+
scannedFiles = scannedFiles.map((f) => isAbsolute4(f) ? f : resolve13(selectionRoot, f));
|
|
31100
31179
|
}
|
|
31101
31180
|
if (selectionRoot && scannedFiles.length === 0 && rawComponents.length > 0) {
|
|
31102
31181
|
process.stderr.write(
|
|
@@ -31449,14 +31528,14 @@ function applyMapping(components, edges) {
|
|
|
31449
31528
|
|
|
31450
31529
|
// packages/experience-design-system-cli/src/analyze/composition/agent-parser/load-prompt.ts
|
|
31451
31530
|
import { existsSync as existsSync7, readFileSync as readFileSync8 } from "node:fs";
|
|
31452
|
-
import { dirname as dirname12, join as
|
|
31531
|
+
import { dirname as dirname12, join as join16, resolve as resolve14 } from "node:path";
|
|
31453
31532
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
31454
31533
|
function resolvePromptPath(fileName) {
|
|
31455
31534
|
const thisDir = dirname12(fileURLToPath3(import.meta.url));
|
|
31456
31535
|
let dir = thisDir;
|
|
31457
31536
|
for (; ; ) {
|
|
31458
|
-
const candidate =
|
|
31459
|
-
if (existsSync7(candidate)) return
|
|
31537
|
+
const candidate = join16(dir, "prompts");
|
|
31538
|
+
if (existsSync7(candidate)) return join16(candidate, fileName);
|
|
31460
31539
|
const parent = resolve14(dir, "..");
|
|
31461
31540
|
if (parent === dir) {
|
|
31462
31541
|
throw new Error(
|
|
@@ -32177,7 +32256,7 @@ function pluralize(count, singular, plural = `${singular}s`) {
|
|
|
32177
32256
|
return `${count} ${count === 1 ? singular : plural}`;
|
|
32178
32257
|
}
|
|
32179
32258
|
function resolveFromProjectRoot(projectRoot, inputPath) {
|
|
32180
|
-
return
|
|
32259
|
+
return isAbsolute5(inputPath) ? inputPath : resolve16(projectRoot, inputPath);
|
|
32181
32260
|
}
|
|
32182
32261
|
function wrapperConfidenceToIssueCount(confidence) {
|
|
32183
32262
|
if (confidence >= 4) return 2;
|
|
@@ -32193,7 +32272,7 @@ async function collectSourceFiles(directory, onProgress) {
|
|
|
32193
32272
|
const entries = await readdir2(currentDirectory, { withFileTypes: true });
|
|
32194
32273
|
const subdirs = [];
|
|
32195
32274
|
for (const entry of entries) {
|
|
32196
|
-
const fullPath =
|
|
32275
|
+
const fullPath = join17(currentDirectory, entry.name);
|
|
32197
32276
|
if (entry.isDirectory()) {
|
|
32198
32277
|
if (!IGNORED_DIRECTORY_NAMES.has(entry.name)) {
|
|
32199
32278
|
subdirs.push(fullPath);
|
|
@@ -32307,7 +32386,7 @@ function registerAnalyzeCommand(program) {
|
|
|
32307
32386
|
}
|
|
32308
32387
|
}
|
|
32309
32388
|
const projectRoot = resolve16(opts.project);
|
|
32310
|
-
const outDir =
|
|
32389
|
+
const outDir = join17(projectRoot, ".contentful");
|
|
32311
32390
|
let sourceDirectory;
|
|
32312
32391
|
if (opts.dir !== void 0) {
|
|
32313
32392
|
sourceDirectory = resolveFromProjectRoot(projectRoot, opts.dir);
|
|
@@ -32660,7 +32739,7 @@ init_src();
|
|
|
32660
32739
|
import { createElement as createElement4 } from "react";
|
|
32661
32740
|
import { render as render4 } from "ink";
|
|
32662
32741
|
import { readFile as readFile18, readdir as readdir3, stat as stat3 } from "node:fs/promises";
|
|
32663
|
-
import { join as
|
|
32742
|
+
import { basename as basename5, join as join18, resolve as resolve18 } from "node:path";
|
|
32664
32743
|
init_debug_logger();
|
|
32665
32744
|
|
|
32666
32745
|
// packages/experience-design-system-cli/src/generate/tui/GenerateView.tsx
|
|
@@ -32800,10 +32879,8 @@ init_credentials_store();
|
|
|
32800
32879
|
init_analytics();
|
|
32801
32880
|
|
|
32802
32881
|
// packages/experience-design-system-cli/src/lib/cli-errors.ts
|
|
32882
|
+
init_src();
|
|
32803
32883
|
init_analytics();
|
|
32804
|
-
import { execFile } from "node:child_process";
|
|
32805
|
-
import { promisify } from "node:util";
|
|
32806
|
-
var execFileAsync = promisify(execFile);
|
|
32807
32884
|
function die2(message) {
|
|
32808
32885
|
process.stderr.write(`${message}
|
|
32809
32886
|
`);
|
|
@@ -32811,12 +32888,7 @@ function die2(message) {
|
|
|
32811
32888
|
throw new Error("exit");
|
|
32812
32889
|
}
|
|
32813
32890
|
async function assertBinaryInPath(binary) {
|
|
32814
|
-
|
|
32815
|
-
await execFileAsync("which", [binary]);
|
|
32816
|
-
return true;
|
|
32817
|
-
} catch {
|
|
32818
|
-
return false;
|
|
32819
|
-
}
|
|
32891
|
+
return binaryExists(binary);
|
|
32820
32892
|
}
|
|
32821
32893
|
|
|
32822
32894
|
// packages/experience-design-system-cli/src/generate/command.ts
|
|
@@ -32849,7 +32921,7 @@ async function readFileInline(path) {
|
|
|
32849
32921
|
return;
|
|
32850
32922
|
}
|
|
32851
32923
|
for (const entry of entries.sort()) {
|
|
32852
|
-
const full =
|
|
32924
|
+
const full = join18(dir, entry);
|
|
32853
32925
|
let es;
|
|
32854
32926
|
try {
|
|
32855
32927
|
es = await stat3(full);
|
|
@@ -33201,7 +33273,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
33201
33273
|
mode: "autonomous",
|
|
33202
33274
|
rawComponentsInline: sampleInline ?? rawTokensInline,
|
|
33203
33275
|
rawTokensInline: skill === "tokens" ? rawTokensInline : void 0,
|
|
33204
|
-
rawTokensFilename: opts.rawTokens ? resolve18(opts.rawTokens)
|
|
33276
|
+
rawTokensFilename: opts.rawTokens ? basename5(resolve18(opts.rawTokens)) : void 0,
|
|
33205
33277
|
tokensInline,
|
|
33206
33278
|
tokenMapInline,
|
|
33207
33279
|
outDir: process.cwd(),
|
|
@@ -33344,7 +33416,7 @@ session=${sessionId2 ?? ""}
|
|
|
33344
33416
|
skill,
|
|
33345
33417
|
mode: "autonomous",
|
|
33346
33418
|
rawTokensInline,
|
|
33347
|
-
rawTokensFilename: opts.rawTokens ? resolve18(opts.rawTokens)
|
|
33419
|
+
rawTokensFilename: opts.rawTokens ? basename5(resolve18(opts.rawTokens)) : void 0,
|
|
33348
33420
|
tokensInline,
|
|
33349
33421
|
tokenMapInline,
|
|
33350
33422
|
outDir: process.cwd()
|
|
@@ -33536,7 +33608,7 @@ init_session_id();
|
|
|
33536
33608
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
33537
33609
|
import { readdirSync as readdirSync2, readFileSync as readFileSync9, renameSync, statSync as statSync4 } from "node:fs";
|
|
33538
33610
|
import { existsSync as existsSync8 } from "node:fs";
|
|
33539
|
-
import { join as
|
|
33611
|
+
import { join as join19, resolve as resolve19 } from "node:path";
|
|
33540
33612
|
import { homedir as homedir5 } from "node:os";
|
|
33541
33613
|
var MIGRATION_NAME = "v1_import_and_reviews";
|
|
33542
33614
|
function getReviewsDir() {
|
|
@@ -33580,13 +33652,13 @@ function migrateReviewSessions(db, _now) {
|
|
|
33580
33652
|
}
|
|
33581
33653
|
for (const entry of entries) {
|
|
33582
33654
|
if (entry.endsWith(".migrated")) continue;
|
|
33583
|
-
const sessionDir =
|
|
33655
|
+
const sessionDir = join19(reviewsDir, entry);
|
|
33584
33656
|
try {
|
|
33585
33657
|
if (!statSync4(sessionDir).isDirectory()) continue;
|
|
33586
33658
|
} catch {
|
|
33587
33659
|
continue;
|
|
33588
33660
|
}
|
|
33589
|
-
const stateFile =
|
|
33661
|
+
const stateFile = join19(sessionDir, "current-review-state.json");
|
|
33590
33662
|
let snapshot;
|
|
33591
33663
|
try {
|
|
33592
33664
|
snapshot = JSON.parse(readFileSync9(stateFile, "utf8"));
|
|
@@ -33908,7 +33980,7 @@ init_db();
|
|
|
33908
33980
|
import { createElement as createElement5 } from "react";
|
|
33909
33981
|
import { render as render5 } from "ink";
|
|
33910
33982
|
import { access as access6, mkdir as mkdir4, stat as stat4, writeFile as writeFile4 } from "node:fs/promises";
|
|
33911
|
-
import { basename as
|
|
33983
|
+
import { basename as basename6, resolve as resolve20 } from "node:path";
|
|
33912
33984
|
|
|
33913
33985
|
// packages/experience-design-system-cli/src/print/validate/validators/cdf-validator.ts
|
|
33914
33986
|
import { validateCDF as validateCDF2 } from "@contentful/experience-design-system-types";
|
|
@@ -34285,7 +34357,7 @@ function registerPrintCommand(program) {
|
|
|
34285
34357
|
await writeFile4(outPath, `${JSON.stringify(cdfObj, null, 2)}
|
|
34286
34358
|
`);
|
|
34287
34359
|
process.stdout.write(
|
|
34288
|
-
`wrote ${
|
|
34360
|
+
`wrote ${basename6(outPath)} (${components.length} component${components.length === 1 ? "" : "s"})
|
|
34289
34361
|
`
|
|
34290
34362
|
);
|
|
34291
34363
|
});
|
|
@@ -34309,7 +34381,7 @@ function registerPrintCommand(program) {
|
|
|
34309
34381
|
await writeFile4(outPath, `${JSON.stringify(tree, null, 2)}
|
|
34310
34382
|
`);
|
|
34311
34383
|
process.stdout.write(
|
|
34312
|
-
`wrote ${
|
|
34384
|
+
`wrote ${basename6(outPath)} (${result.tokens.length} token${result.tokens.length === 1 ? "" : "s"})
|
|
34313
34385
|
`
|
|
34314
34386
|
);
|
|
34315
34387
|
});
|
|
@@ -34798,7 +34870,7 @@ function registerMapTokensCommand(program) {
|
|
|
34798
34870
|
// packages/experience-design-system-cli/src/import/command.ts
|
|
34799
34871
|
init_src();
|
|
34800
34872
|
init_path_utils();
|
|
34801
|
-
import { resolve as resolve27, join as
|
|
34873
|
+
import { resolve as resolve27, join as join28 } from "node:path";
|
|
34802
34874
|
|
|
34803
34875
|
// packages/experience-design-system-cli/src/import/orchestrator.ts
|
|
34804
34876
|
init_db();
|
|
@@ -34810,8 +34882,8 @@ init_contentful_urls();
|
|
|
34810
34882
|
init_debug_logger();
|
|
34811
34883
|
init_analytics();
|
|
34812
34884
|
import { mkdir as mkdir5 } from "node:fs/promises";
|
|
34813
|
-
import { join as
|
|
34814
|
-
import { execFile
|
|
34885
|
+
import { join as join21, resolve as resolve23 } from "node:path";
|
|
34886
|
+
import { execFile } from "node:child_process";
|
|
34815
34887
|
|
|
34816
34888
|
// packages/experience-design-system-cli/src/analytics/env.ts
|
|
34817
34889
|
init_debug_logger();
|
|
@@ -34834,7 +34906,7 @@ async function runStep(args, cliPath, analyticsSessionId, env = {}, streamStderr
|
|
|
34834
34906
|
const startedAt = Date.now();
|
|
34835
34907
|
debug.event("import", "subprocess.spawn", { cliPath, args });
|
|
34836
34908
|
return new Promise((res) => {
|
|
34837
|
-
const child =
|
|
34909
|
+
const child = execFile(process.execPath, [cliPath, ...args], {
|
|
34838
34910
|
env: pipelineSubprocessEnv({ ...process.env, ...env }, analyticsSessionId)
|
|
34839
34911
|
});
|
|
34840
34912
|
let stdout = "";
|
|
@@ -34915,7 +34987,7 @@ function buildPushStepResult(args) {
|
|
|
34915
34987
|
async function runPipeline(opts, progressWriter, cliPathOverride) {
|
|
34916
34988
|
const projectRoot = resolve23(opts.project);
|
|
34917
34989
|
const outDir = resolve23(opts.out);
|
|
34918
|
-
const componentsPath =
|
|
34990
|
+
const componentsPath = join21(outDir, "components.json");
|
|
34919
34991
|
const cliPath = cliPathOverride ?? findCliPath();
|
|
34920
34992
|
const db = openPipelineDb();
|
|
34921
34993
|
const { sessionId: sessionId2 } = getOrCreateSession(db, void 0, void 0, {
|
|
@@ -35537,7 +35609,7 @@ import { resolve as resolve26 } from "node:path";
|
|
|
35537
35609
|
|
|
35538
35610
|
// packages/experience-design-system-cli/src/runs/push-helpers.ts
|
|
35539
35611
|
init_cli_path();
|
|
35540
|
-
import { execFile as
|
|
35612
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
35541
35613
|
import { existsSync as existsSync9 } from "node:fs";
|
|
35542
35614
|
function runCli(args) {
|
|
35543
35615
|
const cliPath = findCliPath();
|
|
@@ -35549,7 +35621,7 @@ function runCli(args) {
|
|
|
35549
35621
|
});
|
|
35550
35622
|
}
|
|
35551
35623
|
return new Promise((res) => {
|
|
35552
|
-
|
|
35624
|
+
execFile2(process.execPath, [cliPath, ...args], (err, stdout, stderr) => {
|
|
35553
35625
|
res({
|
|
35554
35626
|
exitCode: err && "code" in err && typeof err.code === "number" ? err.code : err ? 1 : 0,
|
|
35555
35627
|
stdout,
|
|
@@ -36243,7 +36315,7 @@ function registerImportCommand(program) {
|
|
|
36243
36315
|
return;
|
|
36244
36316
|
}
|
|
36245
36317
|
const projectRoot = normalizePath(opts.project);
|
|
36246
|
-
const outDir = opts.out ? resolve27(opts.out) :
|
|
36318
|
+
const outDir = opts.out ? resolve27(opts.out) : join28(projectRoot, ".contentful");
|
|
36247
36319
|
const headlessCreds = await readExperiencesCredentials();
|
|
36248
36320
|
const headlessAgent = resolveAgent(opts.agent, headlessCreds.agent);
|
|
36249
36321
|
const headlessModel = resolveModel(opts.model, headlessCreds.agentModel);
|
|
@@ -36299,13 +36371,11 @@ function registerImportCommand(program) {
|
|
|
36299
36371
|
|
|
36300
36372
|
// packages/experience-design-system-cli/src/setup/command.ts
|
|
36301
36373
|
init_credentials_store();
|
|
36302
|
-
import { execFile as execFile5, spawn as spawn5 } from "node:child_process";
|
|
36303
36374
|
import { appendFile as appendFile2, readFile as readFile26, access as access9 } from "node:fs/promises";
|
|
36304
|
-
import { join as
|
|
36375
|
+
import { join as join29 } from "node:path";
|
|
36305
36376
|
import { homedir as homedir9 } from "node:os";
|
|
36306
36377
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
36307
36378
|
import { createInterface } from "node:readline";
|
|
36308
|
-
import { promisify as promisify2 } from "node:util";
|
|
36309
36379
|
|
|
36310
36380
|
// packages/experience-design-system-cli/src/setup/prompt-helpers.ts
|
|
36311
36381
|
async function promptBooleanPreference(ask, current, defaultValue, question) {
|
|
@@ -36336,7 +36406,7 @@ async function promptAnalyticsPreference(ask, current) {
|
|
|
36336
36406
|
// packages/experience-design-system-cli/src/setup/command.ts
|
|
36337
36407
|
init_host_utils();
|
|
36338
36408
|
init_cli_path();
|
|
36339
|
-
|
|
36409
|
+
init_src();
|
|
36340
36410
|
var REQUIRED_NODE_MAJOR = 24;
|
|
36341
36411
|
function ok(msg) {
|
|
36342
36412
|
process.stdout.write(` \x1B[32m\u2713\x1B[0m ${msg}
|
|
@@ -36423,17 +36493,12 @@ async function confirm(question, defaultYes = true) {
|
|
|
36423
36493
|
if (!answer) return defaultYes;
|
|
36424
36494
|
return answer.toLowerCase().startsWith("y");
|
|
36425
36495
|
}
|
|
36426
|
-
async function
|
|
36427
|
-
|
|
36428
|
-
await execFileAsync2("which", [name]);
|
|
36429
|
-
return true;
|
|
36430
|
-
} catch {
|
|
36431
|
-
return false;
|
|
36432
|
-
}
|
|
36496
|
+
async function binaryExists2(name) {
|
|
36497
|
+
return findBinary(name) !== null;
|
|
36433
36498
|
}
|
|
36434
36499
|
function runSpawn(cmd, args, opts = {}) {
|
|
36435
36500
|
return new Promise((resolve29) => {
|
|
36436
|
-
const child =
|
|
36501
|
+
const child = spawnBinary(cmd, args, {
|
|
36437
36502
|
cwd: opts.cwd,
|
|
36438
36503
|
env: opts.env ?? process.env,
|
|
36439
36504
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -36447,10 +36512,10 @@ function runSpawn(cmd, args, opts = {}) {
|
|
|
36447
36512
|
resolve29({ exitCode: 1, stdout: "", stderr: err.message });
|
|
36448
36513
|
}
|
|
36449
36514
|
});
|
|
36450
|
-
child.stdout
|
|
36515
|
+
child.stdout?.on("data", (d) => {
|
|
36451
36516
|
stdout += String(d);
|
|
36452
36517
|
});
|
|
36453
|
-
child.stderr
|
|
36518
|
+
child.stderr?.on("data", (d) => {
|
|
36454
36519
|
stderr += String(d);
|
|
36455
36520
|
});
|
|
36456
36521
|
child.on("exit", (code) => {
|
|
@@ -36465,17 +36530,17 @@ async function detectShellProfile() {
|
|
|
36465
36530
|
const shell = process.env["SHELL"] ?? "";
|
|
36466
36531
|
const home = homedir9();
|
|
36467
36532
|
if (shell.includes("zsh")) {
|
|
36468
|
-
return
|
|
36533
|
+
return join29(home, ".zshrc");
|
|
36469
36534
|
}
|
|
36470
36535
|
if (shell.includes("bash")) {
|
|
36471
|
-
const bashProfile =
|
|
36536
|
+
const bashProfile = join29(home, ".bash_profile");
|
|
36472
36537
|
const exists = await access9(bashProfile).then(() => true).catch(() => false);
|
|
36473
|
-
return exists ? bashProfile :
|
|
36538
|
+
return exists ? bashProfile : join29(home, ".bashrc");
|
|
36474
36539
|
}
|
|
36475
36540
|
if (shell.includes("fish")) {
|
|
36476
|
-
return
|
|
36541
|
+
return join29(home, ".config", "fish", "config.fish");
|
|
36477
36542
|
}
|
|
36478
|
-
return
|
|
36543
|
+
return join29(home, ".profile");
|
|
36479
36544
|
}
|
|
36480
36545
|
async function profileContains(profilePath, str) {
|
|
36481
36546
|
try {
|
|
@@ -36500,8 +36565,8 @@ async function setupNode() {
|
|
|
36500
36565
|
}
|
|
36501
36566
|
fail(`Node.js v${current} \u2014 need v${REQUIRED_NODE_MAJOR}+`);
|
|
36502
36567
|
info("");
|
|
36503
|
-
const hasNvm = await
|
|
36504
|
-
const hasFnm = await
|
|
36568
|
+
const hasNvm = await binaryExists2("nvm") || await access9(join29(homedir9(), ".nvm", "nvm.sh")).then(() => true).catch(() => false);
|
|
36569
|
+
const hasFnm = await binaryExists2("fnm");
|
|
36505
36570
|
if (hasNvm) {
|
|
36506
36571
|
info(`nvm detected. Will run: nvm install ${REQUIRED_NODE_MAJOR} && nvm use ${REQUIRED_NODE_MAJOR}`);
|
|
36507
36572
|
const go = await confirm(`Install and switch to Node ${REQUIRED_NODE_MAJOR} via nvm?`);
|
|
@@ -36509,7 +36574,7 @@ async function setupNode() {
|
|
|
36509
36574
|
warn(`Skipped. Re-run experiences setup after switching to Node ${REQUIRED_NODE_MAJOR}.`);
|
|
36510
36575
|
return false;
|
|
36511
36576
|
}
|
|
36512
|
-
const nvmScript =
|
|
36577
|
+
const nvmScript = join29(homedir9(), ".nvm", "nvm.sh");
|
|
36513
36578
|
const result = await runSpawn("bash", [
|
|
36514
36579
|
"-c",
|
|
36515
36580
|
`source "${nvmScript}" && nvm install ${REQUIRED_NODE_MAJOR} && nvm alias default ${REQUIRED_NODE_MAJOR}`
|
|
@@ -36571,14 +36636,14 @@ async function setupNode() {
|
|
|
36571
36636
|
}
|
|
36572
36637
|
async function setupPnpm() {
|
|
36573
36638
|
section("Step 2: pnpm", "[required]");
|
|
36574
|
-
if (await
|
|
36639
|
+
if (await binaryExists2("pnpm")) {
|
|
36575
36640
|
const v = await runSpawn("pnpm", ["--version"]);
|
|
36576
36641
|
ok(`pnpm v${v.stdout.trim()} \u2014 already installed`);
|
|
36577
36642
|
return true;
|
|
36578
36643
|
}
|
|
36579
36644
|
fail("pnpm not found");
|
|
36580
36645
|
info("");
|
|
36581
|
-
const hasCorecpack = await
|
|
36646
|
+
const hasCorecpack = await binaryExists2("corepack");
|
|
36582
36647
|
if (hasCorecpack) {
|
|
36583
36648
|
info("Will run: corepack enable && corepack prepare pnpm@latest --activate");
|
|
36584
36649
|
const go2 = await confirm("Install pnpm via corepack?");
|
|
@@ -36666,7 +36731,7 @@ async function setupAgent() {
|
|
|
36666
36731
|
section("Step 4: Coding agent (claude, codex, opencode, or copilot)", "[required]");
|
|
36667
36732
|
info("experiences import uses a coding agent to generate component definitions.");
|
|
36668
36733
|
info("");
|
|
36669
|
-
const found = (await Promise.all(AGENT_DEFS.map(async (a) => await
|
|
36734
|
+
const found = (await Promise.all(AGENT_DEFS.map(async (a) => await binaryExists2(a.binary) ? a : null))).filter(
|
|
36670
36735
|
(a) => a !== null
|
|
36671
36736
|
);
|
|
36672
36737
|
if (found.length === 1) {
|
|
@@ -36708,7 +36773,7 @@ async function setupAgent() {
|
|
|
36708
36773
|
info(r.stderr.trim().split("\n").slice(0, 5).join("\n"));
|
|
36709
36774
|
return { agent: void 0, agentModel: void 0 };
|
|
36710
36775
|
}
|
|
36711
|
-
if (!await
|
|
36776
|
+
if (!await binaryExists2("claude")) {
|
|
36712
36777
|
fail("claude binary not found on PATH after install \u2014 check your npm global bin directory");
|
|
36713
36778
|
return { agent: void 0, agentModel: void 0 };
|
|
36714
36779
|
}
|
|
@@ -36724,7 +36789,7 @@ async function setupAgent() {
|
|
|
36724
36789
|
fail("Install failed");
|
|
36725
36790
|
return { agent: void 0, agentModel: void 0 };
|
|
36726
36791
|
}
|
|
36727
|
-
if (!await
|
|
36792
|
+
if (!await binaryExists2("codex")) {
|
|
36728
36793
|
fail("codex binary not found on PATH after install \u2014 check your npm global bin directory");
|
|
36729
36794
|
return { agent: void 0, agentModel: void 0 };
|
|
36730
36795
|
}
|
|
@@ -36738,7 +36803,7 @@ async function setupAgent() {
|
|
|
36738
36803
|
fail("Install failed");
|
|
36739
36804
|
return { agent: void 0, agentModel: void 0 };
|
|
36740
36805
|
}
|
|
36741
|
-
if (!await
|
|
36806
|
+
if (!await binaryExists2("opencode")) {
|
|
36742
36807
|
fail("opencode binary not found on PATH after install \u2014 check your npm global bin directory");
|
|
36743
36808
|
return { agent: void 0, agentModel: void 0 };
|
|
36744
36809
|
}
|
|
@@ -36933,11 +36998,11 @@ async function checkNode() {
|
|
|
36933
36998
|
fail(`Node.js v${current} \u2014 need v${REQUIRED_NODE_MAJOR}+`);
|
|
36934
36999
|
info("");
|
|
36935
37000
|
info("How to fix:");
|
|
36936
|
-
if (await
|
|
37001
|
+
if (await binaryExists2("nvm")) {
|
|
36937
37002
|
info(` nvm install ${REQUIRED_NODE_MAJOR}`);
|
|
36938
37003
|
info(` nvm use ${REQUIRED_NODE_MAJOR}`);
|
|
36939
37004
|
info(` nvm alias default ${REQUIRED_NODE_MAJOR} # make it permanent`);
|
|
36940
|
-
} else if (await
|
|
37005
|
+
} else if (await binaryExists2("fnm")) {
|
|
36941
37006
|
info(` fnm install ${REQUIRED_NODE_MAJOR}`);
|
|
36942
37007
|
info(` fnm use ${REQUIRED_NODE_MAJOR}`);
|
|
36943
37008
|
} else {
|
|
@@ -36950,7 +37015,7 @@ async function checkNode() {
|
|
|
36950
37015
|
}
|
|
36951
37016
|
async function checkPnpm(pkgRoot) {
|
|
36952
37017
|
section("Checking pnpm");
|
|
36953
|
-
if (!await
|
|
37018
|
+
if (!await binaryExists2("pnpm")) {
|
|
36954
37019
|
fail("pnpm not found");
|
|
36955
37020
|
info("How to fix:");
|
|
36956
37021
|
info(" npm install -g pnpm");
|
|
@@ -36976,13 +37041,13 @@ async function checkPnpm(pkgRoot) {
|
|
|
36976
37041
|
}
|
|
36977
37042
|
async function checkDependencies(pkgRoot) {
|
|
36978
37043
|
section("Checking dependencies (pnpm install)");
|
|
36979
|
-
const nodeModulesExists = await access9(
|
|
37044
|
+
const nodeModulesExists = await access9(join29(pkgRoot, "node_modules")).then(() => true).catch(() => false);
|
|
36980
37045
|
if (!nodeModulesExists) {
|
|
36981
37046
|
info("node_modules not found \u2014 running pnpm install...");
|
|
36982
37047
|
} else {
|
|
36983
37048
|
info("Running pnpm install to ensure dependencies are up to date...");
|
|
36984
37049
|
}
|
|
36985
|
-
const repoRoot =
|
|
37050
|
+
const repoRoot = join29(pkgRoot, "..", "..");
|
|
36986
37051
|
const result = await runSpawn("pnpm", ["install", "--frozen-lockfile"], { cwd: repoRoot });
|
|
36987
37052
|
if (result.exitCode !== 0) {
|
|
36988
37053
|
fail("pnpm install failed");
|
|
@@ -37001,7 +37066,7 @@ async function checkDependencies(pkgRoot) {
|
|
|
37001
37066
|
async function checkBuild(pkgRoot) {
|
|
37002
37067
|
section("Building CLI");
|
|
37003
37068
|
info("Running pnpm build...");
|
|
37004
|
-
const repoRoot =
|
|
37069
|
+
const repoRoot = join29(pkgRoot, "..", "..");
|
|
37005
37070
|
const result = await runSpawn("pnpm", ["--filter", "@contentful/experience-design-system-cli", "run", "build"], {
|
|
37006
37071
|
cwd: repoRoot
|
|
37007
37072
|
});
|
|
@@ -37026,7 +37091,7 @@ async function checkAgent() {
|
|
|
37026
37091
|
const savedAgent = creds.agent;
|
|
37027
37092
|
const savedModel = creds.agentModel;
|
|
37028
37093
|
if (savedAgent) {
|
|
37029
|
-
const found = await
|
|
37094
|
+
const found = await binaryExists2(savedAgent);
|
|
37030
37095
|
if (found) {
|
|
37031
37096
|
const modelStr = savedModel ? ` \u2014 model: ${savedModel}` : "";
|
|
37032
37097
|
ok(`${savedAgent}${modelStr} (saved preference)`);
|
|
@@ -37038,7 +37103,7 @@ async function checkAgent() {
|
|
|
37038
37103
|
}
|
|
37039
37104
|
}
|
|
37040
37105
|
for (const agent of agents) {
|
|
37041
|
-
if (await
|
|
37106
|
+
if (await binaryExists2(agent.binary)) {
|
|
37042
37107
|
ok(`${agent.name} (${agent.binary}) found`);
|
|
37043
37108
|
info("Tip: run experiences setup to save a default agent and model.");
|
|
37044
37109
|
return true;
|
|
@@ -37117,7 +37182,7 @@ function registerSetupCommand(program) {
|
|
|
37117
37182
|
process.stdout.write("\n\x1B[1mexperiences setup\x1B[0m \u2014 interactive setup wizard\n");
|
|
37118
37183
|
process.stdout.write("Sets up everything you need to run \x1B[1mexperiences import\x1B[0m.\n");
|
|
37119
37184
|
const pkgRoot = findPkgRoot();
|
|
37120
|
-
const repoRoot =
|
|
37185
|
+
const repoRoot = join29(pkgRoot, "..", "..");
|
|
37121
37186
|
const profilePath = await detectShellProfile();
|
|
37122
37187
|
const results = [];
|
|
37123
37188
|
const nodeOk = await setupNode();
|
|
@@ -37357,7 +37422,8 @@ async function beginCommand(command, opts) {
|
|
|
37357
37422
|
init_analytics();
|
|
37358
37423
|
init_credentials_store();
|
|
37359
37424
|
init_cli_path();
|
|
37360
|
-
|
|
37425
|
+
init_src();
|
|
37426
|
+
var pkg3 = JSON.parse(readFileSync10(join30(findPkgRoot(), "package.json"), "utf8"));
|
|
37361
37427
|
async function runBuild(opts) {
|
|
37362
37428
|
return new Promise((resolvePromise) => {
|
|
37363
37429
|
const child = opts.spawnFn();
|
|
@@ -37397,7 +37463,8 @@ function registerBuildCommand(program) {
|
|
|
37397
37463
|
const pkgRoot = resolve28(dirname15(fileURLToPath5(import.meta.url)), "..", "..");
|
|
37398
37464
|
process.stderr.write("\u2699 Building from source...\n");
|
|
37399
37465
|
const { exitCode } = await runBuild({
|
|
37400
|
-
|
|
37466
|
+
// spawnBinary: pnpm is a `.cmd` shim on Windows.
|
|
37467
|
+
spawnFn: () => spawnBinary("pnpm", ["build"], { cwd: pkgRoot, stdio: "inherit" }),
|
|
37401
37468
|
stderrWrite: (s) => process.stderr.write(s)
|
|
37402
37469
|
});
|
|
37403
37470
|
process.exit(exitCode);
|