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