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