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