@contentful/experience-design-system-cli 2.37.1-dev-build-a0a57522.0 → 2.37.1-dev-build-350476b2.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/dist/app.js +755 -103
- package/dist/index.js +877 -117
- package/dist/package.json +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1500,7 +1500,7 @@ async function runAgent(options) {
|
|
|
1500
1500
|
promptLen: prompt.length,
|
|
1501
1501
|
promptHead: prompt.slice(0, 500)
|
|
1502
1502
|
});
|
|
1503
|
-
return new Promise((
|
|
1503
|
+
return new Promise((resolve29) => {
|
|
1504
1504
|
const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
|
|
1505
1505
|
const child = spawn(binary, args, {
|
|
1506
1506
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -1549,7 +1549,7 @@ async function runAgent(options) {
|
|
|
1549
1549
|
stderrLen: stderr.length,
|
|
1550
1550
|
stderrTail: stderr.slice(-1e3)
|
|
1551
1551
|
});
|
|
1552
|
-
|
|
1552
|
+
resolve29(result);
|
|
1553
1553
|
});
|
|
1554
1554
|
});
|
|
1555
1555
|
}
|
|
@@ -1571,7 +1571,7 @@ async function checkAgentAuth(agent) {
|
|
|
1571
1571
|
return "not-found";
|
|
1572
1572
|
if (agent !== "claude")
|
|
1573
1573
|
return "ok";
|
|
1574
|
-
return new Promise((
|
|
1574
|
+
return new Promise((resolve29) => {
|
|
1575
1575
|
const child = spawn2(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
|
|
1576
1576
|
let stdout = "";
|
|
1577
1577
|
let done = false;
|
|
@@ -1580,7 +1580,7 @@ async function checkAgentAuth(agent) {
|
|
|
1580
1580
|
return;
|
|
1581
1581
|
done = true;
|
|
1582
1582
|
child.kill("SIGTERM");
|
|
1583
|
-
|
|
1583
|
+
resolve29("unauthenticated");
|
|
1584
1584
|
}, 5e3);
|
|
1585
1585
|
child.stdout?.on("data", (chunk) => {
|
|
1586
1586
|
stdout += chunk.toString();
|
|
@@ -1591,14 +1591,14 @@ async function checkAgentAuth(agent) {
|
|
|
1591
1591
|
done = true;
|
|
1592
1592
|
clearTimeout(timer);
|
|
1593
1593
|
if (code !== 0) {
|
|
1594
|
-
|
|
1594
|
+
resolve29("unauthenticated");
|
|
1595
1595
|
return;
|
|
1596
1596
|
}
|
|
1597
1597
|
try {
|
|
1598
1598
|
const status = JSON.parse(stdout);
|
|
1599
|
-
|
|
1599
|
+
resolve29(status.loggedIn ? "ok" : "unauthenticated");
|
|
1600
1600
|
} catch {
|
|
1601
|
-
|
|
1601
|
+
resolve29("unauthenticated");
|
|
1602
1602
|
}
|
|
1603
1603
|
});
|
|
1604
1604
|
});
|
|
@@ -1608,9 +1608,9 @@ async function binaryIsOnPath(binary) {
|
|
|
1608
1608
|
const fs = await import("node:fs/promises");
|
|
1609
1609
|
return fs.access(binary).then(() => true, () => false);
|
|
1610
1610
|
}
|
|
1611
|
-
return new Promise((
|
|
1611
|
+
return new Promise((resolve29) => {
|
|
1612
1612
|
const child = spawn2(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
|
|
1613
|
-
child.on("close", (code) =>
|
|
1613
|
+
child.on("close", (code) => resolve29(code === 0));
|
|
1614
1614
|
});
|
|
1615
1615
|
}
|
|
1616
1616
|
var init_check_agent_auth = __esm({
|
|
@@ -2247,7 +2247,8 @@ var init_infer_fence_lang = __esm({
|
|
|
2247
2247
|
sass: "scss",
|
|
2248
2248
|
css: "css",
|
|
2249
2249
|
json: "json",
|
|
2250
|
-
json5: "json"
|
|
2250
|
+
json5: "json",
|
|
2251
|
+
html: "html"
|
|
2251
2252
|
};
|
|
2252
2253
|
}
|
|
2253
2254
|
});
|
|
@@ -10986,6 +10987,756 @@ var init_extract_svelte_components = __esm({
|
|
|
10986
10987
|
}
|
|
10987
10988
|
});
|
|
10988
10989
|
|
|
10990
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/find-component-decorator.js
|
|
10991
|
+
import { Node as Node10 } from "ts-morph";
|
|
10992
|
+
function findComponentDecorator(cls) {
|
|
10993
|
+
const decorator = cls.getDecorator("Component");
|
|
10994
|
+
if (!decorator)
|
|
10995
|
+
return null;
|
|
10996
|
+
const [arg] = decorator.getArguments();
|
|
10997
|
+
if (!arg || !Node10.isObjectLiteralExpression(arg))
|
|
10998
|
+
return null;
|
|
10999
|
+
return arg;
|
|
11000
|
+
}
|
|
11001
|
+
function hasComponentDecorator(cls) {
|
|
11002
|
+
return cls.getDecorator("Component") !== void 0;
|
|
11003
|
+
}
|
|
11004
|
+
var init_find_component_decorator = __esm({
|
|
11005
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/find-component-decorator.js"() {
|
|
11006
|
+
"use strict";
|
|
11007
|
+
}
|
|
11008
|
+
});
|
|
11009
|
+
|
|
11010
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/props/resolve-prop-type.js
|
|
11011
|
+
import { Node as Node11 } from "ts-morph";
|
|
11012
|
+
function resolvePropType(typeNode) {
|
|
11013
|
+
if (!typeNode) {
|
|
11014
|
+
return { text: "any", allowedValues: null, isTemplateRef: false };
|
|
11015
|
+
}
|
|
11016
|
+
const text = typeNode.getText();
|
|
11017
|
+
const members = extractStringLiteralUnion(typeNode);
|
|
11018
|
+
const isTemplateRef = containsTemplateRef(typeNode);
|
|
11019
|
+
return {
|
|
11020
|
+
text,
|
|
11021
|
+
allowedValues: members.length > 0 ? members : null,
|
|
11022
|
+
isTemplateRef
|
|
11023
|
+
};
|
|
11024
|
+
}
|
|
11025
|
+
function extractStringLiteralUnion(typeNode) {
|
|
11026
|
+
if (Node11.isLiteralTypeNode(typeNode)) {
|
|
11027
|
+
const lit = typeNode.getLiteral();
|
|
11028
|
+
if (Node11.isStringLiteral(lit) || Node11.isNoSubstitutionTemplateLiteral(lit)) {
|
|
11029
|
+
return [lit.getLiteralText()];
|
|
11030
|
+
}
|
|
11031
|
+
return [];
|
|
11032
|
+
}
|
|
11033
|
+
if (Node11.isUnionTypeNode(typeNode)) {
|
|
11034
|
+
const out = [];
|
|
11035
|
+
for (const member of typeNode.getTypeNodes()) {
|
|
11036
|
+
const sub = extractStringLiteralUnion(member);
|
|
11037
|
+
if (sub.length === 0 && !isNullOrUndefinedLiteral(member)) {
|
|
11038
|
+
return [];
|
|
11039
|
+
}
|
|
11040
|
+
out.push(...sub);
|
|
11041
|
+
}
|
|
11042
|
+
return out;
|
|
11043
|
+
}
|
|
11044
|
+
return [];
|
|
11045
|
+
}
|
|
11046
|
+
function isNullOrUndefinedLiteral(typeNode) {
|
|
11047
|
+
if (Node11.isLiteralTypeNode(typeNode)) {
|
|
11048
|
+
const lit = typeNode.getLiteral();
|
|
11049
|
+
if (Node11.isNullLiteral(lit))
|
|
11050
|
+
return true;
|
|
11051
|
+
}
|
|
11052
|
+
const t = typeNode.getText();
|
|
11053
|
+
return t === "null" || t === "undefined";
|
|
11054
|
+
}
|
|
11055
|
+
function containsTemplateRef(typeNode) {
|
|
11056
|
+
const text = typeNode.getText();
|
|
11057
|
+
return /\bTemplateRef\b/.test(text);
|
|
11058
|
+
}
|
|
11059
|
+
var init_resolve_prop_type = __esm({
|
|
11060
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/props/resolve-prop-type.js"() {
|
|
11061
|
+
"use strict";
|
|
11062
|
+
}
|
|
11063
|
+
});
|
|
11064
|
+
|
|
11065
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/props/extract-decorator-input.js
|
|
11066
|
+
import { Node as Node12 } from "ts-morph";
|
|
11067
|
+
function extractDecoratorInput(field) {
|
|
11068
|
+
const decorator = field.getDecorator("Input");
|
|
11069
|
+
if (!decorator)
|
|
11070
|
+
return null;
|
|
11071
|
+
const fieldName = field.getName();
|
|
11072
|
+
const args = decorator.getArguments();
|
|
11073
|
+
let alias = null;
|
|
11074
|
+
let required = false;
|
|
11075
|
+
let transformIsBoolean = false;
|
|
11076
|
+
let transformIsNumber = false;
|
|
11077
|
+
if (args.length === 1) {
|
|
11078
|
+
const arg = args[0];
|
|
11079
|
+
if (Node12.isStringLiteral(arg) || Node12.isNoSubstitutionTemplateLiteral(arg)) {
|
|
11080
|
+
alias = arg.getLiteralText();
|
|
11081
|
+
} else if (Node12.isObjectLiteralExpression(arg)) {
|
|
11082
|
+
const aliasProp = arg.getProperty("alias");
|
|
11083
|
+
if (aliasProp && Node12.isPropertyAssignment(aliasProp)) {
|
|
11084
|
+
const init = aliasProp.getInitializer();
|
|
11085
|
+
if (init && (Node12.isStringLiteral(init) || Node12.isNoSubstitutionTemplateLiteral(init))) {
|
|
11086
|
+
alias = init.getLiteralText();
|
|
11087
|
+
}
|
|
11088
|
+
}
|
|
11089
|
+
const requiredProp = arg.getProperty("required");
|
|
11090
|
+
if (requiredProp && Node12.isPropertyAssignment(requiredProp)) {
|
|
11091
|
+
const init = requiredProp.getInitializer();
|
|
11092
|
+
if (init?.getText() === "true")
|
|
11093
|
+
required = true;
|
|
11094
|
+
}
|
|
11095
|
+
const transformProp = arg.getProperty("transform");
|
|
11096
|
+
if (transformProp && Node12.isPropertyAssignment(transformProp)) {
|
|
11097
|
+
const transformText = transformProp.getInitializer()?.getText() ?? "";
|
|
11098
|
+
if (/\bbooleanAttribute\b/.test(transformText))
|
|
11099
|
+
transformIsBoolean = true;
|
|
11100
|
+
if (/\bnumberAttribute\b/.test(transformText))
|
|
11101
|
+
transformIsNumber = true;
|
|
11102
|
+
}
|
|
11103
|
+
}
|
|
11104
|
+
}
|
|
11105
|
+
let typeNode;
|
|
11106
|
+
let defaultValue;
|
|
11107
|
+
if (Node12.isSetAccessorDeclaration(field)) {
|
|
11108
|
+
const param = field.getParameters()[0];
|
|
11109
|
+
typeNode = param?.getTypeNode();
|
|
11110
|
+
} else if (Node12.isGetAccessorDeclaration(field)) {
|
|
11111
|
+
const parent = field.getParent();
|
|
11112
|
+
const companionSetter = parent && Node12.isClassDeclaration(parent) ? parent.getSetAccessor(fieldName) : void 0;
|
|
11113
|
+
if (companionSetter) {
|
|
11114
|
+
typeNode = companionSetter.getParameters()[0]?.getTypeNode();
|
|
11115
|
+
}
|
|
11116
|
+
if (!typeNode)
|
|
11117
|
+
typeNode = field.getReturnTypeNode();
|
|
11118
|
+
} else {
|
|
11119
|
+
typeNode = field.getTypeNode();
|
|
11120
|
+
const initializer = field.getInitializer();
|
|
11121
|
+
if (initializer)
|
|
11122
|
+
defaultValue = initializer.getText();
|
|
11123
|
+
}
|
|
11124
|
+
const resolved = resolvePropType(typeNode);
|
|
11125
|
+
const typeText = transformIsBoolean ? "boolean" : transformIsNumber ? "number" : resolved.text;
|
|
11126
|
+
const name = alias ?? fieldName;
|
|
11127
|
+
const prop = {
|
|
11128
|
+
name,
|
|
11129
|
+
type: typeText,
|
|
11130
|
+
required,
|
|
11131
|
+
sourceStartLine: field.getStartLineNumber(),
|
|
11132
|
+
sourceEndLine: field.getEndLineNumber()
|
|
11133
|
+
};
|
|
11134
|
+
if (defaultValue !== void 0)
|
|
11135
|
+
prop.defaultValue = defaultValue;
|
|
11136
|
+
if (resolved.allowedValues && !transformIsBoolean && !transformIsNumber) {
|
|
11137
|
+
prop.allowedValues = resolved.allowedValues;
|
|
11138
|
+
}
|
|
11139
|
+
return prop;
|
|
11140
|
+
}
|
|
11141
|
+
var init_extract_decorator_input = __esm({
|
|
11142
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/props/extract-decorator-input.js"() {
|
|
11143
|
+
"use strict";
|
|
11144
|
+
init_resolve_prop_type();
|
|
11145
|
+
}
|
|
11146
|
+
});
|
|
11147
|
+
|
|
11148
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/props/extract-signal-input.js
|
|
11149
|
+
import { Node as Node13 } from "ts-morph";
|
|
11150
|
+
function extractSignalInput(field) {
|
|
11151
|
+
const init = field.getInitializer();
|
|
11152
|
+
if (!init || !Node13.isCallExpression(init))
|
|
11153
|
+
return null;
|
|
11154
|
+
const callee = init.getExpression();
|
|
11155
|
+
let required = false;
|
|
11156
|
+
if (Node13.isIdentifier(callee)) {
|
|
11157
|
+
if (callee.getText() !== "input")
|
|
11158
|
+
return null;
|
|
11159
|
+
} else if (Node13.isPropertyAccessExpression(callee)) {
|
|
11160
|
+
const left = callee.getExpression();
|
|
11161
|
+
const right = callee.getName();
|
|
11162
|
+
if (!Node13.isIdentifier(left) || left.getText() !== "input" || right !== "required")
|
|
11163
|
+
return null;
|
|
11164
|
+
required = true;
|
|
11165
|
+
} else {
|
|
11166
|
+
return null;
|
|
11167
|
+
}
|
|
11168
|
+
const fieldName = field.getName();
|
|
11169
|
+
const args = init.getArguments();
|
|
11170
|
+
let defaultValue;
|
|
11171
|
+
let configArg;
|
|
11172
|
+
if (required) {
|
|
11173
|
+
configArg = args[0];
|
|
11174
|
+
} else {
|
|
11175
|
+
const first = args[0];
|
|
11176
|
+
if (first) {
|
|
11177
|
+
defaultValue = first.getText();
|
|
11178
|
+
configArg = args[1];
|
|
11179
|
+
}
|
|
11180
|
+
}
|
|
11181
|
+
let alias = null;
|
|
11182
|
+
let transformIsBoolean = false;
|
|
11183
|
+
let transformIsNumber = false;
|
|
11184
|
+
if (configArg && Node13.isObjectLiteralExpression(configArg)) {
|
|
11185
|
+
const aliasProp = configArg.getProperty("alias");
|
|
11186
|
+
if (aliasProp && Node13.isPropertyAssignment(aliasProp)) {
|
|
11187
|
+
const aliasInit = aliasProp.getInitializer();
|
|
11188
|
+
if (aliasInit && (Node13.isStringLiteral(aliasInit) || Node13.isNoSubstitutionTemplateLiteral(aliasInit))) {
|
|
11189
|
+
alias = aliasInit.getLiteralText();
|
|
11190
|
+
}
|
|
11191
|
+
}
|
|
11192
|
+
const transformProp = configArg.getProperty("transform");
|
|
11193
|
+
if (transformProp && Node13.isPropertyAssignment(transformProp)) {
|
|
11194
|
+
const transformText = transformProp.getInitializer()?.getText() ?? "";
|
|
11195
|
+
if (/\bbooleanAttribute\b/.test(transformText))
|
|
11196
|
+
transformIsBoolean = true;
|
|
11197
|
+
if (/\bnumberAttribute\b/.test(transformText))
|
|
11198
|
+
transformIsNumber = true;
|
|
11199
|
+
}
|
|
11200
|
+
}
|
|
11201
|
+
const typeArg = init.getTypeArguments()[0];
|
|
11202
|
+
const resolved = resolvePropType(typeArg);
|
|
11203
|
+
const typeText = transformIsBoolean ? "boolean" : transformIsNumber ? "number" : resolved.text;
|
|
11204
|
+
const name = alias ?? fieldName;
|
|
11205
|
+
const prop = {
|
|
11206
|
+
name,
|
|
11207
|
+
type: typeText,
|
|
11208
|
+
required,
|
|
11209
|
+
sourceStartLine: field.getStartLineNumber(),
|
|
11210
|
+
sourceEndLine: field.getEndLineNumber()
|
|
11211
|
+
};
|
|
11212
|
+
if (defaultValue !== void 0)
|
|
11213
|
+
prop.defaultValue = defaultValue;
|
|
11214
|
+
if (resolved.allowedValues && !transformIsBoolean && !transformIsNumber) {
|
|
11215
|
+
prop.allowedValues = resolved.allowedValues;
|
|
11216
|
+
}
|
|
11217
|
+
return prop;
|
|
11218
|
+
}
|
|
11219
|
+
var init_extract_signal_input = __esm({
|
|
11220
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/props/extract-signal-input.js"() {
|
|
11221
|
+
"use strict";
|
|
11222
|
+
init_resolve_prop_type();
|
|
11223
|
+
}
|
|
11224
|
+
});
|
|
11225
|
+
|
|
11226
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/props/parse-inputs-array-entry.js
|
|
11227
|
+
function parseInputsArrayEntry(entry) {
|
|
11228
|
+
const trimmed = entry.trim();
|
|
11229
|
+
if (!trimmed)
|
|
11230
|
+
return null;
|
|
11231
|
+
const parts = trimmed.split(":");
|
|
11232
|
+
if (parts.length === 1) {
|
|
11233
|
+
return { fieldName: parts[0].trim(), alias: null };
|
|
11234
|
+
}
|
|
11235
|
+
if (parts.length === 2) {
|
|
11236
|
+
const field = parts[0].trim();
|
|
11237
|
+
const alias = parts[1].trim();
|
|
11238
|
+
if (!field || !alias)
|
|
11239
|
+
return null;
|
|
11240
|
+
return { fieldName: field, alias };
|
|
11241
|
+
}
|
|
11242
|
+
return null;
|
|
11243
|
+
}
|
|
11244
|
+
var init_parse_inputs_array_entry = __esm({
|
|
11245
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/props/parse-inputs-array-entry.js"() {
|
|
11246
|
+
"use strict";
|
|
11247
|
+
}
|
|
11248
|
+
});
|
|
11249
|
+
|
|
11250
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/props/extract-props.js
|
|
11251
|
+
function extractProps2(cls, meta) {
|
|
11252
|
+
const byName = /* @__PURE__ */ new Map();
|
|
11253
|
+
for (const field of cls.getProperties()) {
|
|
11254
|
+
const prop = extractDecoratorInput(field);
|
|
11255
|
+
if (prop && !byName.has(prop.name))
|
|
11256
|
+
byName.set(prop.name, prop);
|
|
11257
|
+
}
|
|
11258
|
+
for (const setter of cls.getSetAccessors()) {
|
|
11259
|
+
const prop = extractDecoratorInput(setter);
|
|
11260
|
+
if (prop && !byName.has(prop.name))
|
|
11261
|
+
byName.set(prop.name, prop);
|
|
11262
|
+
}
|
|
11263
|
+
for (const getter of cls.getGetAccessors()) {
|
|
11264
|
+
const prop = extractDecoratorInput(getter);
|
|
11265
|
+
if (prop && !byName.has(prop.name))
|
|
11266
|
+
byName.set(prop.name, prop);
|
|
11267
|
+
}
|
|
11268
|
+
for (const field of cls.getProperties()) {
|
|
11269
|
+
const prop = extractSignalInput(field);
|
|
11270
|
+
if (prop && !byName.has(prop.name))
|
|
11271
|
+
byName.set(prop.name, prop);
|
|
11272
|
+
}
|
|
11273
|
+
for (const entry of meta.inputsArray) {
|
|
11274
|
+
const parsed = parseInputsArrayEntry(entry);
|
|
11275
|
+
if (!parsed)
|
|
11276
|
+
continue;
|
|
11277
|
+
const name = parsed.alias ?? parsed.fieldName;
|
|
11278
|
+
if (byName.has(name))
|
|
11279
|
+
continue;
|
|
11280
|
+
byName.set(name, { name, type: "any", required: false });
|
|
11281
|
+
}
|
|
11282
|
+
return [...byName.values()];
|
|
11283
|
+
}
|
|
11284
|
+
var init_extract_props = __esm({
|
|
11285
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/props/extract-props.js"() {
|
|
11286
|
+
"use strict";
|
|
11287
|
+
init_extract_decorator_input();
|
|
11288
|
+
init_extract_signal_input();
|
|
11289
|
+
init_parse_inputs_array_entry();
|
|
11290
|
+
}
|
|
11291
|
+
});
|
|
11292
|
+
|
|
11293
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/resolution/normalize-component-name.js
|
|
11294
|
+
function normalizeComponentName2(className) {
|
|
11295
|
+
for (const suffix of SUFFIXES) {
|
|
11296
|
+
if (className.endsWith(suffix) && className.length > suffix.length) {
|
|
11297
|
+
return className.slice(0, -suffix.length);
|
|
11298
|
+
}
|
|
11299
|
+
}
|
|
11300
|
+
return className;
|
|
11301
|
+
}
|
|
11302
|
+
var SUFFIXES;
|
|
11303
|
+
var init_normalize_component_name = __esm({
|
|
11304
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/resolution/normalize-component-name.js"() {
|
|
11305
|
+
"use strict";
|
|
11306
|
+
SUFFIXES = ["Component", "Directive"];
|
|
11307
|
+
}
|
|
11308
|
+
});
|
|
11309
|
+
|
|
11310
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/read-decorator-string.js
|
|
11311
|
+
import { Node as Node14 } from "ts-morph";
|
|
11312
|
+
function readDecoratorString(obj, propName) {
|
|
11313
|
+
const prop = obj.getProperty(propName);
|
|
11314
|
+
if (!prop || !Node14.isPropertyAssignment(prop))
|
|
11315
|
+
return null;
|
|
11316
|
+
const init = prop.getInitializer();
|
|
11317
|
+
if (!init)
|
|
11318
|
+
return null;
|
|
11319
|
+
if (Node14.isStringLiteral(init) || Node14.isNoSubstitutionTemplateLiteral(init)) {
|
|
11320
|
+
return init.getLiteralText();
|
|
11321
|
+
}
|
|
11322
|
+
return null;
|
|
11323
|
+
}
|
|
11324
|
+
function readDecoratorStringArray(obj, propName) {
|
|
11325
|
+
const prop = obj.getProperty(propName);
|
|
11326
|
+
if (!prop || !Node14.isPropertyAssignment(prop))
|
|
11327
|
+
return [];
|
|
11328
|
+
const init = prop.getInitializer();
|
|
11329
|
+
if (!init || !Node14.isArrayLiteralExpression(init))
|
|
11330
|
+
return [];
|
|
11331
|
+
const out = [];
|
|
11332
|
+
for (const el of init.getElements()) {
|
|
11333
|
+
if (Node14.isStringLiteral(el) || Node14.isNoSubstitutionTemplateLiteral(el)) {
|
|
11334
|
+
out.push(el.getLiteralText());
|
|
11335
|
+
}
|
|
11336
|
+
}
|
|
11337
|
+
return out;
|
|
11338
|
+
}
|
|
11339
|
+
var init_read_decorator_string = __esm({
|
|
11340
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/read-decorator-string.js"() {
|
|
11341
|
+
"use strict";
|
|
11342
|
+
}
|
|
11343
|
+
});
|
|
11344
|
+
|
|
11345
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/read-component-metadata.js
|
|
11346
|
+
import { dirname as dirname9, resolve as resolve11 } from "node:path";
|
|
11347
|
+
function readComponentMetadata(cls, sourceFilePath) {
|
|
11348
|
+
const obj = findComponentDecorator(cls);
|
|
11349
|
+
if (!obj)
|
|
11350
|
+
return null;
|
|
11351
|
+
const className = cls.getName();
|
|
11352
|
+
if (!className)
|
|
11353
|
+
return null;
|
|
11354
|
+
const rawSelector = readDecoratorString(obj, "selector");
|
|
11355
|
+
const inlineTemplate = readDecoratorString(obj, "template");
|
|
11356
|
+
const templateUrlRel = readDecoratorString(obj, "templateUrl");
|
|
11357
|
+
const inputsArray = readDecoratorStringArray(obj, "inputs");
|
|
11358
|
+
const templatePath = templateUrlRel ? resolve11(dirname9(sourceFilePath), templateUrlRel) : null;
|
|
11359
|
+
const decorator = cls.getDecorator("Component");
|
|
11360
|
+
const decoratorLine = decorator?.getStartLineNumber() ?? cls.getStartLineNumber();
|
|
11361
|
+
return {
|
|
11362
|
+
className,
|
|
11363
|
+
normalizedName: normalizeComponentName2(className),
|
|
11364
|
+
rawSelector,
|
|
11365
|
+
inlineTemplate,
|
|
11366
|
+
templatePath,
|
|
11367
|
+
inputsArray,
|
|
11368
|
+
decoratorLine
|
|
11369
|
+
};
|
|
11370
|
+
}
|
|
11371
|
+
var init_read_component_metadata = __esm({
|
|
11372
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/read-component-metadata.js"() {
|
|
11373
|
+
"use strict";
|
|
11374
|
+
init_find_component_decorator();
|
|
11375
|
+
init_normalize_component_name();
|
|
11376
|
+
init_read_decorator_string();
|
|
11377
|
+
}
|
|
11378
|
+
});
|
|
11379
|
+
|
|
11380
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/template/parse-ng-content-elements.js
|
|
11381
|
+
function parseNgContentElements(templateHtml) {
|
|
11382
|
+
const out = [];
|
|
11383
|
+
const tagRe = /<ng-content\b([^>]*?)\/?>/gi;
|
|
11384
|
+
for (const match2 of templateHtml.matchAll(tagRe)) {
|
|
11385
|
+
const attrs = match2[1] ?? "";
|
|
11386
|
+
const selectMatch = attrs.match(/\bselect\s*=\s*(?:"([^"]*)"|'([^']*)')/);
|
|
11387
|
+
const rawSelect = selectMatch ? selectMatch[1] ?? selectMatch[2] ?? null : null;
|
|
11388
|
+
const sourceLine = countLines(templateHtml, match2.index ?? 0);
|
|
11389
|
+
out.push({ rawSelect, sourceLine });
|
|
11390
|
+
}
|
|
11391
|
+
return out;
|
|
11392
|
+
}
|
|
11393
|
+
function countLines(text, offset) {
|
|
11394
|
+
let line = 1;
|
|
11395
|
+
for (let i = 0; i < offset && i < text.length; i++) {
|
|
11396
|
+
if (text.charCodeAt(i) === 10)
|
|
11397
|
+
line++;
|
|
11398
|
+
}
|
|
11399
|
+
return line;
|
|
11400
|
+
}
|
|
11401
|
+
var init_parse_ng_content_elements = __esm({
|
|
11402
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/template/parse-ng-content-elements.js"() {
|
|
11403
|
+
"use strict";
|
|
11404
|
+
}
|
|
11405
|
+
});
|
|
11406
|
+
|
|
11407
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/template/resolve-template-source.js
|
|
11408
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
11409
|
+
async function resolveTemplateSource(meta) {
|
|
11410
|
+
if (meta.inlineTemplate !== null)
|
|
11411
|
+
return meta.inlineTemplate;
|
|
11412
|
+
if (meta.templatePath === null)
|
|
11413
|
+
return null;
|
|
11414
|
+
try {
|
|
11415
|
+
return await readFile7(meta.templatePath, "utf8");
|
|
11416
|
+
} catch {
|
|
11417
|
+
return null;
|
|
11418
|
+
}
|
|
11419
|
+
}
|
|
11420
|
+
var init_resolve_template_source = __esm({
|
|
11421
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/template/resolve-template-source.js"() {
|
|
11422
|
+
"use strict";
|
|
11423
|
+
}
|
|
11424
|
+
});
|
|
11425
|
+
|
|
11426
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/resolution/strip-library-prefix.js
|
|
11427
|
+
function stripLibraryPrefix(name) {
|
|
11428
|
+
for (const prefix of KNOWN_PREFIXES) {
|
|
11429
|
+
if (name.startsWith(prefix) && name.length > prefix.length) {
|
|
11430
|
+
const rest = name.slice(prefix.length);
|
|
11431
|
+
if (rest[0] && rest[0] === rest[0].toUpperCase()) {
|
|
11432
|
+
return rest;
|
|
11433
|
+
}
|
|
11434
|
+
}
|
|
11435
|
+
}
|
|
11436
|
+
return name;
|
|
11437
|
+
}
|
|
11438
|
+
var KNOWN_PREFIXES;
|
|
11439
|
+
var init_strip_library_prefix = __esm({
|
|
11440
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/resolution/strip-library-prefix.js"() {
|
|
11441
|
+
"use strict";
|
|
11442
|
+
KNOWN_PREFIXES = ["Mat", "Cdk", "Nz", "Cds", "Ibm", "Clr", "Hlm", "Brn", "Tui", "Nb", "Fd", "P", "Ng"];
|
|
11443
|
+
}
|
|
11444
|
+
});
|
|
11445
|
+
|
|
11446
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/slots/derive-slot-name.js
|
|
11447
|
+
function deriveSlotName(rawSelect, parentNormalizedName) {
|
|
11448
|
+
if (!rawSelect || rawSelect.trim() === "")
|
|
11449
|
+
return "children";
|
|
11450
|
+
if (rawSelect.includes(",")) {
|
|
11451
|
+
const first = rawSelect.split(",")[0].trim();
|
|
11452
|
+
return deriveSingleSelectorName(first, parentNormalizedName);
|
|
11453
|
+
}
|
|
11454
|
+
return deriveSingleSelectorName(rawSelect.trim(), parentNormalizedName);
|
|
11455
|
+
}
|
|
11456
|
+
function deriveSingleSelectorName(sel, parentNormalizedName) {
|
|
11457
|
+
const slotAttrMatch = sel.match(/^\[\s*slot\s*=\s*['"]?([^'"\]]+)['"]?\s*\]$/);
|
|
11458
|
+
if (slotAttrMatch)
|
|
11459
|
+
return slotAttrMatch[1].trim();
|
|
11460
|
+
if (sel.startsWith(".")) {
|
|
11461
|
+
const last = sel.slice(1).split("-").pop() ?? sel.slice(1);
|
|
11462
|
+
return kebabToCamel2(last);
|
|
11463
|
+
}
|
|
11464
|
+
const attrMatch = sel.match(/^\[([^=\]]+)\]$/);
|
|
11465
|
+
if (attrMatch) {
|
|
11466
|
+
const attr = attrMatch[1].trim();
|
|
11467
|
+
const stripped = tryStripSubComponentOrLibraryPrefix(attr, parentNormalizedName);
|
|
11468
|
+
return stripped || kebabToCamel2(attr);
|
|
11469
|
+
}
|
|
11470
|
+
const elMatch = sel.match(/^([a-zA-Z][a-zA-Z0-9-]*)/);
|
|
11471
|
+
if (elMatch) {
|
|
11472
|
+
const tag = elMatch[1];
|
|
11473
|
+
const stripped = tryStripSubComponentOrLibraryPrefix(tag, parentNormalizedName);
|
|
11474
|
+
return stripped || kebabToCamel2(tag);
|
|
11475
|
+
}
|
|
11476
|
+
return sel.replace(/\s+/g, "");
|
|
11477
|
+
}
|
|
11478
|
+
function tryStripSubComponentOrLibraryPrefix(ident, parentNormalizedName) {
|
|
11479
|
+
const parentKebab = pascalToKebab(parentNormalizedName);
|
|
11480
|
+
if (parentKebab && ident.startsWith(`${parentKebab}-`)) {
|
|
11481
|
+
return kebabToCamel2(ident.slice(parentKebab.length + 1));
|
|
11482
|
+
}
|
|
11483
|
+
const asPascal = kebabToPascal2(ident);
|
|
11484
|
+
const stripped = stripLibraryPrefix(asPascal);
|
|
11485
|
+
if (stripped !== asPascal) {
|
|
11486
|
+
return stripped.charAt(0).toLowerCase() + stripped.slice(1);
|
|
11487
|
+
}
|
|
11488
|
+
return null;
|
|
11489
|
+
}
|
|
11490
|
+
function kebabToCamel2(s) {
|
|
11491
|
+
return s.replace(/-([a-z])/g, (_, c2) => c2.toUpperCase());
|
|
11492
|
+
}
|
|
11493
|
+
function kebabToPascal2(s) {
|
|
11494
|
+
const camel = kebabToCamel2(s);
|
|
11495
|
+
return camel.charAt(0).toUpperCase() + camel.slice(1);
|
|
11496
|
+
}
|
|
11497
|
+
function pascalToKebab(s) {
|
|
11498
|
+
return s.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
11499
|
+
}
|
|
11500
|
+
var init_derive_slot_name = __esm({
|
|
11501
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/slots/derive-slot-name.js"() {
|
|
11502
|
+
"use strict";
|
|
11503
|
+
init_strip_library_prefix();
|
|
11504
|
+
}
|
|
11505
|
+
});
|
|
11506
|
+
|
|
11507
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/slots/extract-content-child-queries.js
|
|
11508
|
+
import { Node as Node15 } from "ts-morph";
|
|
11509
|
+
function extractContentChildQueries(cls) {
|
|
11510
|
+
const out = [];
|
|
11511
|
+
for (const field of cls.getProperties()) {
|
|
11512
|
+
const fieldName = field.getName();
|
|
11513
|
+
const init = field.getInitializer();
|
|
11514
|
+
if (init && Node15.isCallExpression(init)) {
|
|
11515
|
+
const callee = init.getExpression();
|
|
11516
|
+
if (Node15.isIdentifier(callee)) {
|
|
11517
|
+
const name = callee.getText();
|
|
11518
|
+
if (name === "contentChild" || name === "contentChildren") {
|
|
11519
|
+
const first = init.getArguments()[0];
|
|
11520
|
+
const allowed = resolveClassIdentifierArg(first);
|
|
11521
|
+
out.push(buildSlot(fieldName, allowed));
|
|
11522
|
+
continue;
|
|
11523
|
+
}
|
|
11524
|
+
}
|
|
11525
|
+
}
|
|
11526
|
+
for (const decName of ["ContentChild", "ContentChildren"]) {
|
|
11527
|
+
const dec = field.getDecorator(decName);
|
|
11528
|
+
if (dec) {
|
|
11529
|
+
const first = dec.getArguments()[0];
|
|
11530
|
+
const allowed = resolveClassIdentifierArg(first);
|
|
11531
|
+
out.push(buildSlot(fieldName, allowed));
|
|
11532
|
+
break;
|
|
11533
|
+
}
|
|
11534
|
+
}
|
|
11535
|
+
}
|
|
11536
|
+
return out;
|
|
11537
|
+
}
|
|
11538
|
+
function resolveClassIdentifierArg(arg) {
|
|
11539
|
+
if (!arg)
|
|
11540
|
+
return [];
|
|
11541
|
+
if (Node15.isStringLiteral(arg) || Node15.isNoSubstitutionTemplateLiteral(arg))
|
|
11542
|
+
return [];
|
|
11543
|
+
if (Node15.isIdentifier(arg))
|
|
11544
|
+
return [arg.getText()];
|
|
11545
|
+
return [];
|
|
11546
|
+
}
|
|
11547
|
+
function buildSlot(name, allowed) {
|
|
11548
|
+
const slot = {
|
|
11549
|
+
name,
|
|
11550
|
+
isDefault: false
|
|
11551
|
+
};
|
|
11552
|
+
if (allowed.length > 0)
|
|
11553
|
+
slot.allowedComponents = allowed;
|
|
11554
|
+
return slot;
|
|
11555
|
+
}
|
|
11556
|
+
var init_extract_content_child_queries = __esm({
|
|
11557
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/slots/extract-content-child-queries.js"() {
|
|
11558
|
+
"use strict";
|
|
11559
|
+
}
|
|
11560
|
+
});
|
|
11561
|
+
|
|
11562
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/slots/extract-template-ref-slots.js
|
|
11563
|
+
function extractTemplateRefSlots(props) {
|
|
11564
|
+
const nextProps = [];
|
|
11565
|
+
const slots = [];
|
|
11566
|
+
for (const prop of props) {
|
|
11567
|
+
const type = prop.type;
|
|
11568
|
+
const hasTemplateRef = /\bTemplateRef\b/.test(type);
|
|
11569
|
+
if (!hasTemplateRef) {
|
|
11570
|
+
nextProps.push(prop);
|
|
11571
|
+
continue;
|
|
11572
|
+
}
|
|
11573
|
+
const isPureTemplateRef = /^\s*TemplateRef<[^>]*>\s*(\|\s*(null|undefined)\s*)*$/.test(type);
|
|
11574
|
+
if (!isPureTemplateRef) {
|
|
11575
|
+
nextProps.push(prop);
|
|
11576
|
+
}
|
|
11577
|
+
slots.push({ name: prop.name, isDefault: false });
|
|
11578
|
+
}
|
|
11579
|
+
return { props: nextProps, slots };
|
|
11580
|
+
}
|
|
11581
|
+
var init_extract_template_ref_slots = __esm({
|
|
11582
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/slots/extract-template-ref-slots.js"() {
|
|
11583
|
+
"use strict";
|
|
11584
|
+
}
|
|
11585
|
+
});
|
|
11586
|
+
|
|
11587
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/slots/extract-slots.js
|
|
11588
|
+
async function extractSlots3(cls, meta, props) {
|
|
11589
|
+
const byName = /* @__PURE__ */ new Map();
|
|
11590
|
+
const template = await resolveTemplateSource(meta);
|
|
11591
|
+
if (template) {
|
|
11592
|
+
for (const el of parseNgContentElements(template)) {
|
|
11593
|
+
const name = deriveSlotName(el.rawSelect, meta.normalizedName);
|
|
11594
|
+
if (byName.has(name))
|
|
11595
|
+
continue;
|
|
11596
|
+
byName.set(name, {
|
|
11597
|
+
name,
|
|
11598
|
+
isDefault: el.rawSelect === null
|
|
11599
|
+
});
|
|
11600
|
+
}
|
|
11601
|
+
}
|
|
11602
|
+
for (const slot of extractContentChildQueries(cls)) {
|
|
11603
|
+
if (!byName.has(slot.name))
|
|
11604
|
+
byName.set(slot.name, slot);
|
|
11605
|
+
}
|
|
11606
|
+
const split = extractTemplateRefSlots(props);
|
|
11607
|
+
for (const slot of split.slots) {
|
|
11608
|
+
if (!byName.has(slot.name))
|
|
11609
|
+
byName.set(slot.name, slot);
|
|
11610
|
+
}
|
|
11611
|
+
return { props: split.props, slots: [...byName.values()] };
|
|
11612
|
+
}
|
|
11613
|
+
var init_extract_slots = __esm({
|
|
11614
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/slots/extract-slots.js"() {
|
|
11615
|
+
"use strict";
|
|
11616
|
+
init_parse_ng_content_elements();
|
|
11617
|
+
init_resolve_template_source();
|
|
11618
|
+
init_derive_slot_name();
|
|
11619
|
+
init_extract_content_child_queries();
|
|
11620
|
+
init_extract_template_ref_slots();
|
|
11621
|
+
}
|
|
11622
|
+
});
|
|
11623
|
+
|
|
11624
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/extract-angular-components.js
|
|
11625
|
+
import { readFile as readFile8 } from "node:fs/promises";
|
|
11626
|
+
import { ModuleKind as ModuleKind2, Project as Project7, ScriptTarget as ScriptTarget2 } from "ts-morph";
|
|
11627
|
+
async function extractAngularComponents(filePaths, onProgress, _opts) {
|
|
11628
|
+
const components = [];
|
|
11629
|
+
const warnings = [];
|
|
11630
|
+
let filesProcessed = 0;
|
|
11631
|
+
const project = new Project7({
|
|
11632
|
+
useInMemoryFileSystem: false,
|
|
11633
|
+
skipAddingFilesFromTsConfig: true,
|
|
11634
|
+
compilerOptions: {
|
|
11635
|
+
target: ScriptTarget2.ES2022,
|
|
11636
|
+
module: ModuleKind2.ESNext,
|
|
11637
|
+
experimentalDecorators: true,
|
|
11638
|
+
emitDecoratorMetadata: false,
|
|
11639
|
+
allowJs: false
|
|
11640
|
+
}
|
|
11641
|
+
});
|
|
11642
|
+
for (const filePath of filePaths) {
|
|
11643
|
+
try {
|
|
11644
|
+
const source = await readFile8(filePath, "utf8");
|
|
11645
|
+
const sourceFile = project.createSourceFile(filePath, source, { overwrite: true });
|
|
11646
|
+
for (const cls of sourceFile.getClasses()) {
|
|
11647
|
+
if (!hasComponentDecorator(cls))
|
|
11648
|
+
continue;
|
|
11649
|
+
if (!findComponentDecorator(cls)) {
|
|
11650
|
+
warnings.push(`${filePath}: ${cls.getName() ?? "<anonymous>"} has @Component with a non-literal argument; skipped.`);
|
|
11651
|
+
continue;
|
|
11652
|
+
}
|
|
11653
|
+
const meta = readComponentMetadata(cls, filePath);
|
|
11654
|
+
if (!meta)
|
|
11655
|
+
continue;
|
|
11656
|
+
const propsOnly = extractProps2(cls, meta);
|
|
11657
|
+
const { props, slots } = await extractSlots3(cls, meta, propsOnly);
|
|
11658
|
+
const partial = {
|
|
11659
|
+
name: meta.className,
|
|
11660
|
+
source: filePath,
|
|
11661
|
+
framework: "angular",
|
|
11662
|
+
props,
|
|
11663
|
+
slots: normalizeSlots(slots),
|
|
11664
|
+
sourcePath: filePath
|
|
11665
|
+
};
|
|
11666
|
+
const score = computeExtractionScore(partial);
|
|
11667
|
+
partial.extractionConfidence = score.confidence;
|
|
11668
|
+
partial.reviewReasons = score.reasons;
|
|
11669
|
+
partial.needsReview = deriveNeedsReview(score.confidence);
|
|
11670
|
+
components.push(partial);
|
|
11671
|
+
}
|
|
11672
|
+
sourceFile.deleteImmediatelySync();
|
|
11673
|
+
} catch (err) {
|
|
11674
|
+
warnings.push(`${filePath}: Angular extractor failed \u2014 ${err instanceof Error ? err.message : String(err)}`);
|
|
11675
|
+
} finally {
|
|
11676
|
+
filesProcessed++;
|
|
11677
|
+
if (onProgress)
|
|
11678
|
+
onProgress({ filesProcessed, componentsFound: components.length });
|
|
11679
|
+
}
|
|
11680
|
+
}
|
|
11681
|
+
return {
|
|
11682
|
+
components: components.sort((a, b) => a.name.localeCompare(b.name)),
|
|
11683
|
+
warnings
|
|
11684
|
+
};
|
|
11685
|
+
}
|
|
11686
|
+
function normalizeSlots(slots) {
|
|
11687
|
+
let fallbackIndex = 0;
|
|
11688
|
+
return slots.map((slot) => {
|
|
11689
|
+
if (slot.name.trim())
|
|
11690
|
+
return slot;
|
|
11691
|
+
const name = fallbackIndex === 0 ? "children" : `slot_${fallbackIndex}`;
|
|
11692
|
+
fallbackIndex++;
|
|
11693
|
+
return { ...slot, name };
|
|
11694
|
+
});
|
|
11695
|
+
}
|
|
11696
|
+
var init_extract_angular_components = __esm({
|
|
11697
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/extract-angular-components.js"() {
|
|
11698
|
+
"use strict";
|
|
11699
|
+
init_scoring();
|
|
11700
|
+
init_find_component_decorator();
|
|
11701
|
+
init_extract_props();
|
|
11702
|
+
init_read_component_metadata();
|
|
11703
|
+
init_extract_slots();
|
|
11704
|
+
}
|
|
11705
|
+
});
|
|
11706
|
+
|
|
11707
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/is-angular-source-file.js
|
|
11708
|
+
import { openSync, readSync, closeSync, statSync as statSync3 } from "node:fs";
|
|
11709
|
+
function isAngularSourceFile(filePath) {
|
|
11710
|
+
if (!/\.[cm]?ts$/.test(filePath))
|
|
11711
|
+
return false;
|
|
11712
|
+
if (filePath.endsWith(".d.ts"))
|
|
11713
|
+
return false;
|
|
11714
|
+
try {
|
|
11715
|
+
const stats = statSync3(filePath);
|
|
11716
|
+
const toRead = Math.min(HEAD_BYTES, stats.size);
|
|
11717
|
+
if (toRead === 0)
|
|
11718
|
+
return false;
|
|
11719
|
+
const fd = openSync(filePath, "r");
|
|
11720
|
+
try {
|
|
11721
|
+
const bytesRead = readSync(fd, buffer, 0, toRead, 0);
|
|
11722
|
+
const head = buffer.subarray(0, bytesRead).toString("utf8");
|
|
11723
|
+
return head.includes("@angular/core");
|
|
11724
|
+
} finally {
|
|
11725
|
+
closeSync(fd);
|
|
11726
|
+
}
|
|
11727
|
+
} catch {
|
|
11728
|
+
return false;
|
|
11729
|
+
}
|
|
11730
|
+
}
|
|
11731
|
+
var HEAD_BYTES, buffer;
|
|
11732
|
+
var init_is_angular_source_file = __esm({
|
|
11733
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/angular/helpers/is-angular-source-file.js"() {
|
|
11734
|
+
"use strict";
|
|
11735
|
+
HEAD_BYTES = 4 * 1024;
|
|
11736
|
+
buffer = Buffer.alloc(HEAD_BYTES);
|
|
11737
|
+
}
|
|
11738
|
+
});
|
|
11739
|
+
|
|
10989
11740
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/services/run-extraction-service.js
|
|
10990
11741
|
function getPathPreferenceScore(filePath) {
|
|
10991
11742
|
const normalized = filePath.replace(/\\/g, "/");
|
|
@@ -11278,6 +12029,8 @@ var init_run_extraction_service = __esm({
|
|
|
11278
12029
|
init_extract_astro_components();
|
|
11279
12030
|
init_extract_web_components();
|
|
11280
12031
|
init_extract_svelte_components();
|
|
12032
|
+
init_extract_angular_components();
|
|
12033
|
+
init_is_angular_source_file();
|
|
11281
12034
|
extractors = [
|
|
11282
12035
|
{
|
|
11283
12036
|
name: "stencil",
|
|
@@ -11304,6 +12057,13 @@ var init_run_extraction_service = __esm({
|
|
|
11304
12057
|
fileFilter: (f) => f.endsWith(".astro"),
|
|
11305
12058
|
extract: extractAstroComponents
|
|
11306
12059
|
},
|
|
12060
|
+
{
|
|
12061
|
+
// Must run BEFORE web-components (both claim bare .ts). The sniff reads
|
|
12062
|
+
// the file head looking for `@angular/core` so we only claim real Angular files.
|
|
12063
|
+
name: "angular",
|
|
12064
|
+
fileFilter: (f) => isAngularSourceFile(f),
|
|
12065
|
+
extract: extractAngularComponents
|
|
12066
|
+
},
|
|
11307
12067
|
{
|
|
11308
12068
|
name: "web-components",
|
|
11309
12069
|
fileFilter: (f) => /\.[jt]s$/.test(f) && !/\.[jt]sx$/.test(f) && !f.endsWith(".d.ts"),
|
|
@@ -11532,16 +12292,16 @@ var init_apply_mapping = __esm({
|
|
|
11532
12292
|
|
|
11533
12293
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/composition/src/helpers/prompt/prompt-loader.js
|
|
11534
12294
|
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
|
|
11535
|
-
import { dirname as
|
|
12295
|
+
import { dirname as dirname10, join as join8, resolve as resolve12 } from "node:path";
|
|
11536
12296
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
11537
12297
|
function resolvePromptPath(fileName) {
|
|
11538
|
-
const thisDir =
|
|
12298
|
+
const thisDir = dirname10(fileURLToPath2(import.meta.url));
|
|
11539
12299
|
let dir = thisDir;
|
|
11540
12300
|
for (; ; ) {
|
|
11541
12301
|
const candidate = join8(dir, "prompts");
|
|
11542
12302
|
if (existsSync6(candidate))
|
|
11543
12303
|
return join8(candidate, fileName);
|
|
11544
|
-
const parent =
|
|
12304
|
+
const parent = resolve12(dir, "..");
|
|
11545
12305
|
if (parent === dir) {
|
|
11546
12306
|
throw new Error(`prompt file missing from package installation (could not locate prompts/ directory from: ${thisDir})`);
|
|
11547
12307
|
}
|
|
@@ -11729,8 +12489,8 @@ var init_composition_cache_key = __esm({
|
|
|
11729
12489
|
});
|
|
11730
12490
|
|
|
11731
12491
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/composition/src/helpers/edges/manifest-doc-evidence.js
|
|
11732
|
-
import { dirname as
|
|
11733
|
-
function
|
|
12492
|
+
import { dirname as dirname11 } from "node:path";
|
|
12493
|
+
function kebabToPascal3(name) {
|
|
11734
12494
|
return name.split("-").filter(Boolean).map((seg) => seg.charAt(0).toUpperCase() + seg.slice(1)).join("");
|
|
11735
12495
|
}
|
|
11736
12496
|
function collectManifestEdges(files, componentNames) {
|
|
@@ -11752,7 +12512,7 @@ function collectManifestEdges(files, componentNames) {
|
|
|
11752
12512
|
const rawParentName = typeof component === "object" && component !== null && typeof component.name === "string" ? component.name : void 0;
|
|
11753
12513
|
if (!rawParentName)
|
|
11754
12514
|
continue;
|
|
11755
|
-
const parent =
|
|
12515
|
+
const parent = kebabToPascal3(rawParentName);
|
|
11756
12516
|
if (!componentNames.has(parent))
|
|
11757
12517
|
continue;
|
|
11758
12518
|
const variantsMeta = root.variantsMeta;
|
|
@@ -11772,7 +12532,7 @@ function collectManifestEdges(files, componentNames) {
|
|
|
11772
12532
|
const rawChildName = value.name;
|
|
11773
12533
|
if (typeof rawChildName !== "string")
|
|
11774
12534
|
continue;
|
|
11775
|
-
const child =
|
|
12535
|
+
const child = kebabToPascal3(rawChildName);
|
|
11776
12536
|
if (!componentNames.has(child) || child === parent)
|
|
11777
12537
|
continue;
|
|
11778
12538
|
const key = `${parent}::${child}`;
|
|
@@ -11791,8 +12551,8 @@ function collectAgentsDocEdges(files, components, componentNames) {
|
|
|
11791
12551
|
for (const file of files) {
|
|
11792
12552
|
if (!file.path.endsWith("AGENTS.md"))
|
|
11793
12553
|
continue;
|
|
11794
|
-
const docDir =
|
|
11795
|
-
const parent = components.find((c2) => c2.sourcePath &&
|
|
12554
|
+
const docDir = dirname11(file.path);
|
|
12555
|
+
const parent = components.find((c2) => c2.sourcePath && dirname11(c2.sourcePath) === docDir)?.name;
|
|
11796
12556
|
if (!parent || !componentNames.has(parent))
|
|
11797
12557
|
continue;
|
|
11798
12558
|
for (const line of file.content.split("\n")) {
|
|
@@ -11801,7 +12561,7 @@ function collectAgentsDocEdges(files, components, componentNames) {
|
|
|
11801
12561
|
continue;
|
|
11802
12562
|
for (const match2 of line.matchAll(BOLD_BACKTICK)) {
|
|
11803
12563
|
const raw = match2[1];
|
|
11804
|
-
const candidate = componentNames.has(raw) ? raw :
|
|
12564
|
+
const candidate = componentNames.has(raw) ? raw : kebabToPascal3(raw);
|
|
11805
12565
|
if (!componentNames.has(candidate) || candidate === parent)
|
|
11806
12566
|
continue;
|
|
11807
12567
|
const key = `${parent}::${candidate}`;
|
|
@@ -12439,7 +13199,7 @@ var init_create_component_id = __esm({
|
|
|
12439
13199
|
|
|
12440
13200
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/helpers/resolve-component-source-path.js
|
|
12441
13201
|
import { access } from "node:fs/promises";
|
|
12442
|
-
import { isAbsolute, relative, resolve as
|
|
13202
|
+
import { isAbsolute, relative, resolve as resolve13 } from "node:path";
|
|
12443
13203
|
async function resolveComponentSourcePath(source, reviewRoot) {
|
|
12444
13204
|
if (isAbsolute(source)) {
|
|
12445
13205
|
try {
|
|
@@ -12449,7 +13209,7 @@ async function resolveComponentSourcePath(source, reviewRoot) {
|
|
|
12449
13209
|
throw new Error(`Unable to access component source at ${source}`);
|
|
12450
13210
|
}
|
|
12451
13211
|
}
|
|
12452
|
-
const candidate =
|
|
13212
|
+
const candidate = resolve13(reviewRoot, source);
|
|
12453
13213
|
const relativeToRoot = relative(reviewRoot, candidate);
|
|
12454
13214
|
if (relativeToRoot.startsWith("..") || relativeToRoot === ".." || isAbsolute(relativeToRoot)) {
|
|
12455
13215
|
throw new Error(`Resolved component source is outside the review root: ${source}. Pass --project-root <path> to set the correct base.`);
|
|
@@ -12468,9 +13228,9 @@ var init_resolve_component_source_path = __esm({
|
|
|
12468
13228
|
});
|
|
12469
13229
|
|
|
12470
13230
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/helpers/load-review-input.js
|
|
12471
|
-
import { resolve as
|
|
13231
|
+
import { resolve as resolve14 } from "node:path";
|
|
12472
13232
|
async function loadReviewInput(components, options = {}) {
|
|
12473
|
-
const reviewRoot =
|
|
13233
|
+
const reviewRoot = resolve14(options.reviewRoot ?? process.cwd());
|
|
12474
13234
|
const records = await Promise.all(components.map(async (component) => {
|
|
12475
13235
|
let resolvedSourcePath;
|
|
12476
13236
|
try {
|
|
@@ -12521,13 +13281,13 @@ var init_load_and_validate_for_review = __esm({
|
|
|
12521
13281
|
});
|
|
12522
13282
|
|
|
12523
13283
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-session-paths.js
|
|
12524
|
-
import { resolve as
|
|
13284
|
+
import { resolve as resolve15 } from "node:path";
|
|
12525
13285
|
async function getRefineSessionPaths(sessionId, artifactsRoot) {
|
|
12526
|
-
const sessionDir2 =
|
|
13286
|
+
const sessionDir2 = resolve15(artifactsRoot, sessionId);
|
|
12527
13287
|
return {
|
|
12528
13288
|
sessionDir: sessionDir2,
|
|
12529
|
-
eventsPath:
|
|
12530
|
-
statePath:
|
|
13289
|
+
eventsPath: resolve15(sessionDir2, "events.jsonl"),
|
|
13290
|
+
statePath: resolve15(sessionDir2, "current-review-state.json")
|
|
12531
13291
|
};
|
|
12532
13292
|
}
|
|
12533
13293
|
var init_review_session_paths = __esm({
|
|
@@ -12537,13 +13297,13 @@ var init_review_session_paths = __esm({
|
|
|
12537
13297
|
});
|
|
12538
13298
|
|
|
12539
13299
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/ensure-review-session.js
|
|
12540
|
-
import { access as access2, mkdir, readFile as
|
|
13300
|
+
import { access as access2, mkdir, readFile as readFile9, writeFile } from "node:fs/promises";
|
|
12541
13301
|
async function ensureRefineSession(sessionId, artifactsRoot, initialSnapshot) {
|
|
12542
13302
|
const paths = await getRefineSessionPaths(sessionId, artifactsRoot);
|
|
12543
13303
|
await mkdir(paths.sessionDir, { recursive: true });
|
|
12544
13304
|
try {
|
|
12545
13305
|
await access2(paths.statePath);
|
|
12546
|
-
const savedState = await
|
|
13306
|
+
const savedState = await readFile9(paths.statePath, "utf8");
|
|
12547
13307
|
return JSON.parse(savedState);
|
|
12548
13308
|
} catch {
|
|
12549
13309
|
await writeFile(paths.statePath, JSON.stringify(initialSnapshot, null, 2), "utf8");
|
|
@@ -12559,12 +13319,12 @@ var init_ensure_review_session = __esm({
|
|
|
12559
13319
|
});
|
|
12560
13320
|
|
|
12561
13321
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-artifacts-root.js
|
|
12562
|
-
import { resolve as
|
|
13322
|
+
import { resolve as resolve16 } from "node:path";
|
|
12563
13323
|
function getRefineArtifactsRoot() {
|
|
12564
13324
|
if (process.env["EDS_REVIEW_ARTIFACTS_DIR"]) {
|
|
12565
|
-
return
|
|
13325
|
+
return resolve16(process.env["EDS_REVIEW_ARTIFACTS_DIR"]);
|
|
12566
13326
|
}
|
|
12567
|
-
return
|
|
13327
|
+
return resolve16(configRoot(), "reviews");
|
|
12568
13328
|
}
|
|
12569
13329
|
var init_review_artifacts_root = __esm({
|
|
12570
13330
|
"packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-artifacts-root.js"() {
|
|
@@ -12585,14 +13345,14 @@ var init_save_review_state = __esm({
|
|
|
12585
13345
|
});
|
|
12586
13346
|
|
|
12587
13347
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/selection/src/controller/review/merge-preview-validation-errors-into-review-session.js
|
|
12588
|
-
import { access as access3, readFile as
|
|
13348
|
+
import { access as access3, readFile as readFile10 } from "node:fs/promises";
|
|
12589
13349
|
async function mergePreviewValidationErrorsIntoReviewSession(sessionId, errors, opts = {}) {
|
|
12590
13350
|
const artifactsRoot = opts.artifactsRoot ?? getRefineArtifactsRoot();
|
|
12591
13351
|
const paths = await getRefineSessionPaths(sessionId, artifactsRoot);
|
|
12592
13352
|
let snapshot;
|
|
12593
13353
|
try {
|
|
12594
13354
|
await access3(paths.statePath);
|
|
12595
|
-
snapshot = JSON.parse(await
|
|
13355
|
+
snapshot = JSON.parse(await readFile10(paths.statePath, "utf8"));
|
|
12596
13356
|
} catch {
|
|
12597
13357
|
snapshot = await loadAndValidateForReview(sessionId, void 0);
|
|
12598
13358
|
snapshot = await ensureRefineSession(sessionId, artifactsRoot, snapshot);
|
|
@@ -12640,7 +13400,7 @@ var init_merge_preview_validation_errors_into_review_session = __esm({
|
|
|
12640
13400
|
});
|
|
12641
13401
|
|
|
12642
13402
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/selection/src/controller/review/reject-components-by-name.js
|
|
12643
|
-
import { readFile as
|
|
13403
|
+
import { readFile as readFile11 } from "node:fs/promises";
|
|
12644
13404
|
async function rejectComponentsByName(sessionId, names, opts = {}) {
|
|
12645
13405
|
if (names.length === 0)
|
|
12646
13406
|
return;
|
|
@@ -12656,7 +13416,7 @@ async function rejectComponentsByName(sessionId, names, opts = {}) {
|
|
|
12656
13416
|
const nameSet = new Set(names);
|
|
12657
13417
|
let snapshot;
|
|
12658
13418
|
try {
|
|
12659
|
-
snapshot = JSON.parse(await
|
|
13419
|
+
snapshot = JSON.parse(await readFile11(paths.statePath, "utf8"));
|
|
12660
13420
|
} catch {
|
|
12661
13421
|
return;
|
|
12662
13422
|
}
|
|
@@ -12907,13 +13667,13 @@ var init_walk_project_tree = __esm({
|
|
|
12907
13667
|
});
|
|
12908
13668
|
|
|
12909
13669
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/collect-files.js
|
|
12910
|
-
import { statSync as
|
|
13670
|
+
import { statSync as statSync4 } from "node:fs";
|
|
12911
13671
|
import path4 from "node:path";
|
|
12912
13672
|
function collectFiles(root, options = {}) {
|
|
12913
13673
|
const resolved = path4.resolve(root);
|
|
12914
13674
|
let stat6;
|
|
12915
13675
|
try {
|
|
12916
|
-
stat6 =
|
|
13676
|
+
stat6 = statSync4(resolved);
|
|
12917
13677
|
} catch (err) {
|
|
12918
13678
|
return { ok: false, failure: classifyStatError(err.code), rootPath: resolved };
|
|
12919
13679
|
}
|
|
@@ -13017,10 +13777,10 @@ var init_run_record = __esm({
|
|
|
13017
13777
|
});
|
|
13018
13778
|
|
|
13019
13779
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/runs/repositories/read-runs-file.js
|
|
13020
|
-
import { readFile as
|
|
13780
|
+
import { readFile as readFile12 } from "node:fs/promises";
|
|
13021
13781
|
async function readRunsFileMaybe() {
|
|
13022
13782
|
try {
|
|
13023
|
-
const raw = await
|
|
13783
|
+
const raw = await readFile12(runsFilePath(), "utf8");
|
|
13024
13784
|
const parsed = JSON.parse(raw);
|
|
13025
13785
|
if (!READABLE_VERSIONS.has(parsed.version)) {
|
|
13026
13786
|
throw new Error(`runs.json version mismatch: file is v${parsed.version}, this CLI expects v${RUNS_FILE_VERSION} (also reads: ${[...READABLE_VERSIONS].join(", ")}). Back up and remove the file to start fresh.`);
|
|
@@ -13045,9 +13805,9 @@ var init_read_runs_file = __esm({
|
|
|
13045
13805
|
|
|
13046
13806
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/runs/repositories/write-runs-file.js
|
|
13047
13807
|
import { mkdir as mkdir2, rename, writeFile as writeFile3 } from "node:fs/promises";
|
|
13048
|
-
import { dirname as
|
|
13808
|
+
import { dirname as dirname12 } from "node:path";
|
|
13049
13809
|
async function writeRunsFileAtomic(file) {
|
|
13050
|
-
await mkdir2(
|
|
13810
|
+
await mkdir2(dirname12(runsFilePath()), { recursive: true });
|
|
13051
13811
|
const body = JSON.stringify(file, null, 2) + "\n";
|
|
13052
13812
|
const tmp = `${runsFilePath()}.${process.pid}.${Date.now()}.tmp`;
|
|
13053
13813
|
await writeFile3(tmp, body, { mode: 384 });
|
|
@@ -13140,8 +13900,8 @@ var init_sha256_hex = __esm({
|
|
|
13140
13900
|
});
|
|
13141
13901
|
|
|
13142
13902
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/runs/services/build-source-fingerprint.js
|
|
13143
|
-
import { readFile as
|
|
13144
|
-
import { resolve as
|
|
13903
|
+
import { readFile as readFile13, stat } from "node:fs/promises";
|
|
13904
|
+
import { resolve as resolve17 } from "node:path";
|
|
13145
13905
|
function rowField(row, key) {
|
|
13146
13906
|
const v = row[key];
|
|
13147
13907
|
return typeof v === "string" ? v : null;
|
|
@@ -13155,7 +13915,7 @@ async function buildSourceFingerprint(opts) {
|
|
|
13155
13915
|
const name = rowField(row, "name");
|
|
13156
13916
|
if (!sourcePath)
|
|
13157
13917
|
continue;
|
|
13158
|
-
const abs =
|
|
13918
|
+
const abs = resolve17(sourcePath);
|
|
13159
13919
|
if (seen.has(abs))
|
|
13160
13920
|
continue;
|
|
13161
13921
|
seen.add(abs);
|
|
@@ -13172,10 +13932,10 @@ async function buildSourceFingerprint(opts) {
|
|
|
13172
13932
|
let rawTokensMtime = null;
|
|
13173
13933
|
let rawTokensContentHash = null;
|
|
13174
13934
|
if (opts.rawTokensPath) {
|
|
13175
|
-
const abs =
|
|
13935
|
+
const abs = resolve17(opts.rawTokensPath);
|
|
13176
13936
|
rawTokensPath = abs;
|
|
13177
13937
|
try {
|
|
13178
|
-
const [st, buf] = await Promise.all([stat(abs),
|
|
13938
|
+
const [st, buf] = await Promise.all([stat(abs), readFile13(abs)]);
|
|
13179
13939
|
rawTokensMtime = st.mtime.toISOString();
|
|
13180
13940
|
rawTokensContentHash = sha256Hex(buf);
|
|
13181
13941
|
} catch {
|
|
@@ -13340,12 +14100,12 @@ var init_write_scope_decisions_snapshot = __esm({
|
|
|
13340
14100
|
});
|
|
13341
14101
|
|
|
13342
14102
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/load-accepted-names.js
|
|
13343
|
-
import { readFile as
|
|
14103
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
13344
14104
|
async function loadAcceptedNames(sessionId) {
|
|
13345
14105
|
try {
|
|
13346
14106
|
const artifactsRoot = getRefineArtifactsRoot();
|
|
13347
14107
|
const paths = await getRefineSessionPaths(sessionId, artifactsRoot);
|
|
13348
|
-
const raw = await
|
|
14108
|
+
const raw = await readFile14(paths.statePath, "utf8");
|
|
13349
14109
|
const snapshot = JSON.parse(raw);
|
|
13350
14110
|
const accepted = snapshot.components.filter((c2) => c2.status === "accepted").map((c2) => c2.name);
|
|
13351
14111
|
if (accepted.length === 0)
|
|
@@ -14333,7 +15093,7 @@ function errorMessage(error) {
|
|
|
14333
15093
|
return error instanceof Error && error.message ? error.message : String(error);
|
|
14334
15094
|
}
|
|
14335
15095
|
function defaultSleep(delayMs) {
|
|
14336
|
-
return new Promise((
|
|
15096
|
+
return new Promise((resolve29) => setTimeout(resolve29, delayMs));
|
|
14337
15097
|
}
|
|
14338
15098
|
var MAX_RETRY_AFTER_MS;
|
|
14339
15099
|
var init_http_utils = __esm({
|
|
@@ -14609,7 +15369,7 @@ var init_api_client = __esm({
|
|
|
14609
15369
|
const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
|
|
14610
15370
|
const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
|
|
14611
15371
|
const jitter = Math.random() * baseDelay * 0.15;
|
|
14612
|
-
await new Promise((
|
|
15372
|
+
await new Promise((resolve29) => setTimeout(resolve29, baseDelay + jitter));
|
|
14613
15373
|
}
|
|
14614
15374
|
}
|
|
14615
15375
|
throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
|
|
@@ -15296,7 +16056,7 @@ var init_collect_json_files = __esm({
|
|
|
15296
16056
|
});
|
|
15297
16057
|
|
|
15298
16058
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/tokens/read-tokens-from-path.js
|
|
15299
|
-
import { readFile as
|
|
16059
|
+
import { readFile as readFile15, stat as stat3 } from "node:fs/promises";
|
|
15300
16060
|
async function readTokensFromPath(flag, p) {
|
|
15301
16061
|
let s;
|
|
15302
16062
|
try {
|
|
@@ -15319,7 +16079,7 @@ async function readMergedFromDir(flag, dir) {
|
|
|
15319
16079
|
const merged = {};
|
|
15320
16080
|
for (const file of files.sort()) {
|
|
15321
16081
|
try {
|
|
15322
|
-
const text = await
|
|
16082
|
+
const text = await readFile15(file, "utf8");
|
|
15323
16083
|
const parsed = JSON.parse(text);
|
|
15324
16084
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
15325
16085
|
Object.assign(merged, parsed);
|
|
@@ -15333,7 +16093,7 @@ async function readMergedFromDir(flag, dir) {
|
|
|
15333
16093
|
async function readSingleFile(flag, p) {
|
|
15334
16094
|
let text;
|
|
15335
16095
|
try {
|
|
15336
|
-
text = await
|
|
16096
|
+
text = await readFile15(p, "utf8");
|
|
15337
16097
|
} catch {
|
|
15338
16098
|
throw new Error(`file not found: ${p} (from ${flag})`);
|
|
15339
16099
|
}
|
|
@@ -15439,12 +16199,12 @@ var init_fetch_and_persist = __esm({
|
|
|
15439
16199
|
});
|
|
15440
16200
|
|
|
15441
16201
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/existing-entities/read-from-session.js
|
|
15442
|
-
import { readFile as
|
|
16202
|
+
import { readFile as readFile16 } from "node:fs/promises";
|
|
15443
16203
|
async function readExistingContentfulEntitiesFromSession(request) {
|
|
15444
16204
|
if (!request.path)
|
|
15445
16205
|
return void 0;
|
|
15446
16206
|
try {
|
|
15447
|
-
const raw = await
|
|
16207
|
+
const raw = await readFile16(request.path, "utf8");
|
|
15448
16208
|
const parsed = JSON.parse(raw);
|
|
15449
16209
|
if (!Array.isArray(parsed.components) || !Array.isArray(parsed.tokens))
|
|
15450
16210
|
return void 0;
|
|
@@ -16317,7 +17077,7 @@ var init_analytics = __esm({
|
|
|
16317
17077
|
});
|
|
16318
17078
|
|
|
16319
17079
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/map-tokens/run-map-tokens.js
|
|
16320
|
-
import { resolve as
|
|
17080
|
+
import { resolve as resolve18 } from "node:path";
|
|
16321
17081
|
async function runMapTokens(request) {
|
|
16322
17082
|
const timeoutMs = request.agentTimeoutMs ?? DEFAULT_TIMEOUT_MS2;
|
|
16323
17083
|
const db = openPipelineDb();
|
|
@@ -16368,7 +17128,7 @@ async function runMapTokens(request) {
|
|
|
16368
17128
|
outDir: process.cwd(),
|
|
16369
17129
|
existingTokensInline: request.existingEntitiesInline,
|
|
16370
17130
|
...request.skillContentOverride !== void 0 ? { skillContentOverride: request.skillContentOverride } : {},
|
|
16371
|
-
...request.skillContentOverride === void 0 && request.skillPathOverride ? { skillPathOverride:
|
|
17131
|
+
...request.skillContentOverride === void 0 && request.skillPathOverride ? { skillPathOverride: resolve18(request.skillPathOverride) } : {}
|
|
16372
17132
|
});
|
|
16373
17133
|
if (request.printPrompt) {
|
|
16374
17134
|
const prompt2 = await buildMapPrompt();
|
|
@@ -16584,7 +17344,7 @@ var init_parse_imported_names = __esm({
|
|
|
16584
17344
|
});
|
|
16585
17345
|
|
|
16586
17346
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/helpers/evidence/source-inspection.js
|
|
16587
|
-
import { readFile as
|
|
17347
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
16588
17348
|
function escapeRegExp(value) {
|
|
16589
17349
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
16590
17350
|
}
|
|
@@ -16640,7 +17400,7 @@ function dedupeReasons(reasons) {
|
|
|
16640
17400
|
async function inspectComponentSource(component) {
|
|
16641
17401
|
let sourceText = "";
|
|
16642
17402
|
try {
|
|
16643
|
-
sourceText = await
|
|
17403
|
+
sourceText = await readFile17(component.source, "utf8");
|
|
16644
17404
|
} catch {
|
|
16645
17405
|
return {
|
|
16646
17406
|
wrapperConfidence: 0,
|
|
@@ -17096,7 +17856,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
|
|
|
17096
17856
|
const message = error instanceof Error ? error.message : String(error);
|
|
17097
17857
|
if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
|
|
17098
17858
|
throw error;
|
|
17099
|
-
await new Promise((
|
|
17859
|
+
await new Promise((resolve29) => setTimeout(resolve29, Math.min(250 * attempt, 2e3)));
|
|
17100
17860
|
}
|
|
17101
17861
|
}
|
|
17102
17862
|
}
|
|
@@ -17144,7 +17904,7 @@ var init_resolve_composition_agent_name = __esm({
|
|
|
17144
17904
|
});
|
|
17145
17905
|
|
|
17146
17906
|
// packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-extract-and-compose-session/helpers/read-candidate-files.js
|
|
17147
|
-
import { readFile as
|
|
17907
|
+
import { readFile as readFile18 } from "node:fs/promises";
|
|
17148
17908
|
async function readCandidateFiles(components, extraFiles = []) {
|
|
17149
17909
|
const paths = new Set(extraFiles);
|
|
17150
17910
|
for (const c2 of components) {
|
|
@@ -17154,7 +17914,7 @@ async function readCandidateFiles(components, extraFiles = []) {
|
|
|
17154
17914
|
const out = [];
|
|
17155
17915
|
await Promise.all([...paths].map(async (p) => {
|
|
17156
17916
|
try {
|
|
17157
|
-
const content = await
|
|
17917
|
+
const content = await readFile18(p, "utf8");
|
|
17158
17918
|
out.push({ path: p, content });
|
|
17159
17919
|
} catch {
|
|
17160
17920
|
}
|
|
@@ -17393,7 +18153,7 @@ var init_write_tokens_file = __esm({
|
|
|
17393
18153
|
});
|
|
17394
18154
|
|
|
17395
18155
|
// packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-tokens-session/run-generate-tokens-session.js
|
|
17396
|
-
import { readFile as
|
|
18156
|
+
import { readFile as readFile19 } from "node:fs/promises";
|
|
17397
18157
|
import { basename as basename5, resolve as pathResolve } from "node:path";
|
|
17398
18158
|
async function runGenerateTokensSession(request) {
|
|
17399
18159
|
const { rawTokensPath, outDir, agent, agentModel, promptOverrides, skillPath, noCache, bedrock = false, onProgress, onSessionCreated } = request;
|
|
@@ -17402,7 +18162,7 @@ async function runGenerateTokensSession(request) {
|
|
|
17402
18162
|
throw new Error(`Prompt override error(s): ${promptErrors.join("; ")}`);
|
|
17403
18163
|
const tokensOverride = overridesMap.get("tokens");
|
|
17404
18164
|
const skillContentOverride = tokensOverride ? await resolvePromptOverride(tokensOverride) : void 0;
|
|
17405
|
-
const rawTokensInline = await
|
|
18165
|
+
const rawTokensInline = await readFile19(pathResolve(rawTokensPath), "utf8");
|
|
17406
18166
|
const tokenInputHash = hashTokenContent(rawTokensInline);
|
|
17407
18167
|
const db = openPipelineDb();
|
|
17408
18168
|
try {
|
|
@@ -17553,7 +18313,7 @@ var init_read_existing_entities = __esm({
|
|
|
17553
18313
|
});
|
|
17554
18314
|
|
|
17555
18315
|
// packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/resolve-generate-prompt.js
|
|
17556
|
-
import { resolve as
|
|
18316
|
+
import { resolve as resolve19 } from "node:path";
|
|
17557
18317
|
async function resolveGeneratePrompt(overrides) {
|
|
17558
18318
|
const { overrides: parsed, errors } = parsePromptOverrides(overrides);
|
|
17559
18319
|
if (errors.length > 0)
|
|
@@ -17564,7 +18324,7 @@ async function resolveGeneratePrompt(overrides) {
|
|
|
17564
18324
|
const text = await resolvePromptOverride(entry);
|
|
17565
18325
|
if (entry.kind === "text")
|
|
17566
18326
|
return { text };
|
|
17567
|
-
return { path:
|
|
18327
|
+
return { path: resolve19(entry.value), text };
|
|
17568
18328
|
}
|
|
17569
18329
|
var init_resolve_generate_prompt = __esm({
|
|
17570
18330
|
"packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/resolve-generate-prompt.js"() {
|
|
@@ -18067,10 +18827,10 @@ var init_src3 = __esm({
|
|
|
18067
18827
|
|
|
18068
18828
|
// packages/experience-design-system-cli/src/tui/package-root.ts
|
|
18069
18829
|
import { existsSync as existsSync7, readFileSync as readFileSync7 } from "node:fs";
|
|
18070
|
-
import { dirname as
|
|
18830
|
+
import { dirname as dirname13, join as join14 } from "node:path";
|
|
18071
18831
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
18072
18832
|
function findPackageRoot(startUrl, packageName) {
|
|
18073
|
-
let dir =
|
|
18833
|
+
let dir = dirname13(fileURLToPath3(startUrl));
|
|
18074
18834
|
let found;
|
|
18075
18835
|
while (true) {
|
|
18076
18836
|
const manifestPath = join14(dir, "package.json");
|
|
@@ -18078,7 +18838,7 @@ function findPackageRoot(startUrl, packageName) {
|
|
|
18078
18838
|
const pkg2 = JSON.parse(readFileSync7(manifestPath, "utf8"));
|
|
18079
18839
|
if (pkg2.name === packageName) found = dir;
|
|
18080
18840
|
}
|
|
18081
|
-
const parent =
|
|
18841
|
+
const parent = dirname13(dir);
|
|
18082
18842
|
if (parent === dir) return found ?? dir;
|
|
18083
18843
|
dir = parent;
|
|
18084
18844
|
}
|
|
@@ -18091,22 +18851,22 @@ var init_package_root = __esm({
|
|
|
18091
18851
|
|
|
18092
18852
|
// packages/experience-design-system-types/dist/src/config/index.js
|
|
18093
18853
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
18094
|
-
import { mkdir as mkdir6, readFile as
|
|
18854
|
+
import { mkdir as mkdir6, readFile as readFile20, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
|
|
18095
18855
|
import { homedir as homedir2 } from "node:os";
|
|
18096
|
-
import { dirname as
|
|
18856
|
+
import { dirname as dirname14, join as join16 } from "node:path";
|
|
18097
18857
|
function configRoot2() {
|
|
18098
18858
|
return process.env["EDS_HOME"] || join16(homedir2(), ".contentful", "experience-design-system-cli");
|
|
18099
18859
|
}
|
|
18100
18860
|
async function readSettings2() {
|
|
18101
18861
|
try {
|
|
18102
|
-
return JSON.parse(await
|
|
18862
|
+
return JSON.parse(await readFile20(configFilePath2(), "utf8"));
|
|
18103
18863
|
} catch {
|
|
18104
18864
|
return {};
|
|
18105
18865
|
}
|
|
18106
18866
|
}
|
|
18107
18867
|
async function writeSettings2(settings) {
|
|
18108
18868
|
const path5 = configFilePath2();
|
|
18109
|
-
await mkdir6(
|
|
18869
|
+
await mkdir6(dirname14(path5), { recursive: true });
|
|
18110
18870
|
const tmp = `${path5}.${process.pid}.${randomBytes4(4).toString("hex")}.tmp`;
|
|
18111
18871
|
await writeFile6(tmp, `${JSON.stringify(settings, null, 2)}
|
|
18112
18872
|
`, { mode: 384 });
|
|
@@ -18705,7 +19465,7 @@ var init_controls2 = __esm({
|
|
|
18705
19465
|
|
|
18706
19466
|
// packages/experience-design-system-cli/src/tui/import/resolve-user-path.ts
|
|
18707
19467
|
import { homedir as homedir3 } from "node:os";
|
|
18708
|
-
import { resolve as
|
|
19468
|
+
import { resolve as resolve20 } from "node:path";
|
|
18709
19469
|
function stripQuotes(value) {
|
|
18710
19470
|
const quoted = value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'");
|
|
18711
19471
|
return value.length >= 2 && quoted ? value.slice(1, -1) : value;
|
|
@@ -18714,7 +19474,7 @@ function expandHome(value) {
|
|
|
18714
19474
|
return value === "~" || value.startsWith("~/") || value.startsWith("~\\") ? homedir3() + value.slice(1) : value;
|
|
18715
19475
|
}
|
|
18716
19476
|
function resolveUserPath(raw) {
|
|
18717
|
-
return
|
|
19477
|
+
return resolve20(expandHome(stripQuotes(raw.trim())));
|
|
18718
19478
|
}
|
|
18719
19479
|
var init_resolve_user_path = __esm({
|
|
18720
19480
|
"packages/experience-design-system-cli/src/tui/import/resolve-user-path.ts"() {
|
|
@@ -18723,12 +19483,12 @@ var init_resolve_user_path = __esm({
|
|
|
18723
19483
|
});
|
|
18724
19484
|
|
|
18725
19485
|
// packages/experience-design-system-cli/src/tui/import/steps/02-token-input/validate-path.ts
|
|
18726
|
-
import { statSync as
|
|
19486
|
+
import { statSync as statSync5 } from "node:fs";
|
|
18727
19487
|
function validateTokenPath(rawPath) {
|
|
18728
19488
|
const path5 = resolveUserPath(rawPath);
|
|
18729
19489
|
let stats;
|
|
18730
19490
|
try {
|
|
18731
|
-
stats =
|
|
19491
|
+
stats = statSync5(path5);
|
|
18732
19492
|
} catch {
|
|
18733
19493
|
return { ok: false, error: `Path not found: ${path5}`, resolvedPath: path5 };
|
|
18734
19494
|
}
|
|
@@ -19749,15 +20509,15 @@ var init_steps = __esm({
|
|
|
19749
20509
|
|
|
19750
20510
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/find-skill-path.ts
|
|
19751
20511
|
import { existsSync as existsSync9 } from "node:fs";
|
|
19752
|
-
import { dirname as
|
|
20512
|
+
import { dirname as dirname15, join as join19, resolve as resolve21 } from "node:path";
|
|
19753
20513
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
19754
20514
|
function findSkillPath(fileName) {
|
|
19755
|
-
const thisDir =
|
|
20515
|
+
const thisDir = dirname15(fileURLToPath4(import.meta.url));
|
|
19756
20516
|
let dir = thisDir;
|
|
19757
20517
|
for (; ; ) {
|
|
19758
20518
|
const candidate = join19(dir, "skills", fileName);
|
|
19759
20519
|
if (existsSync9(candidate)) return candidate;
|
|
19760
|
-
const parent =
|
|
20520
|
+
const parent = resolve21(dir, "..");
|
|
19761
20521
|
if (parent === dir) {
|
|
19762
20522
|
throw new Error(`skill file not found (looked for skills/${fileName} from ${thisDir})`);
|
|
19763
20523
|
}
|
|
@@ -19771,9 +20531,9 @@ var init_find_skill_path = __esm({
|
|
|
19771
20531
|
});
|
|
19772
20532
|
|
|
19773
20533
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/selection.ts
|
|
19774
|
-
import { resolve as
|
|
20534
|
+
import { resolve as resolve22 } from "node:path";
|
|
19775
20535
|
async function hashSelectPrompt(options) {
|
|
19776
|
-
const promptHash = options.promptText ? hashContent(options.promptText) : options.promptPath ? await hashFile(
|
|
20536
|
+
const promptHash = options.promptText ? hashContent(options.promptText) : options.promptPath ? await hashFile(resolve22(options.promptPath)) : await hashFile(SELECT_SKILL_PATH);
|
|
19777
20537
|
return hashContent(`${promptHash}|${options.agent}|${options.model ?? ""}`);
|
|
19778
20538
|
}
|
|
19779
20539
|
async function runSelection(options) {
|
|
@@ -19868,9 +20628,9 @@ var init_selection2 = __esm({
|
|
|
19868
20628
|
|
|
19869
20629
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts
|
|
19870
20630
|
import { mkdir as mkdir7 } from "node:fs/promises";
|
|
19871
|
-
import { join as join20, resolve as
|
|
20631
|
+
import { join as join20, resolve as resolve23 } from "node:path";
|
|
19872
20632
|
async function runExtraction(input, onProgress, deps = realDeps) {
|
|
19873
|
-
const outDir = input.outDir ?? join20(
|
|
20633
|
+
const outDir = input.outDir ?? join20(resolve23(input.projectPath), ".contentful");
|
|
19874
20634
|
let progress = initialProgress({
|
|
19875
20635
|
hasCredentials: input.credentials !== null,
|
|
19876
20636
|
hasRawTokens: input.rawTokensPath !== "",
|
|
@@ -19996,7 +20756,7 @@ async function resolveSelectionPrompt(overrides) {
|
|
|
19996
20756
|
if (select?.kind === "text") return { promptText: select.value };
|
|
19997
20757
|
if (select?.kind === "path") {
|
|
19998
20758
|
await resolvePromptOverride(select);
|
|
19999
|
-
return { promptPath:
|
|
20759
|
+
return { promptPath: resolve23(select.value) };
|
|
20000
20760
|
}
|
|
20001
20761
|
return {};
|
|
20002
20762
|
}
|
|
@@ -23275,7 +24035,7 @@ var init_save_decisions = __esm({
|
|
|
23275
24035
|
});
|
|
23276
24036
|
|
|
23277
24037
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
|
|
23278
|
-
import { resolve as
|
|
24038
|
+
import { resolve as resolve24 } from "node:path";
|
|
23279
24039
|
async function runGeneration(input, onProgress, deps = realDeps3) {
|
|
23280
24040
|
let progress = { components: null, mapTokens: "idle", mapTokensEligible: null };
|
|
23281
24041
|
const update = (change) => {
|
|
@@ -23361,7 +24121,7 @@ async function buildMapTokensOptions(input) {
|
|
|
23361
24121
|
if (mapOverride?.kind === "text") prompt.skillContentOverride = mapOverride.value;
|
|
23362
24122
|
if (mapOverride?.kind === "path") {
|
|
23363
24123
|
await resolvePromptOverride(mapOverride);
|
|
23364
|
-
prompt.skillPathOverride =
|
|
24124
|
+
prompt.skillPathOverride = resolve24(mapOverride.value);
|
|
23365
24125
|
}
|
|
23366
24126
|
if (input.existingEntitiesPath) {
|
|
23367
24127
|
const entities = await readExistingContentfulEntitiesFromSession({ path: input.existingEntitiesPath });
|
|
@@ -29613,7 +30373,7 @@ var init_DoneStep = __esm({
|
|
|
29613
30373
|
});
|
|
29614
30374
|
|
|
29615
30375
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts
|
|
29616
|
-
import { resolve as
|
|
30376
|
+
import { resolve as resolve25 } from "node:path";
|
|
29617
30377
|
import { homedir as homedir4 } from "node:os";
|
|
29618
30378
|
function expandTilde(input) {
|
|
29619
30379
|
if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
|
|
@@ -29627,7 +30387,7 @@ function normalizePath(input) {
|
|
|
29627
30387
|
p = p.slice(1, -1);
|
|
29628
30388
|
}
|
|
29629
30389
|
p = expandTilde(p);
|
|
29630
|
-
return
|
|
30390
|
+
return resolve25(p);
|
|
29631
30391
|
}
|
|
29632
30392
|
var init_path_utils = __esm({
|
|
29633
30393
|
"packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts"() {
|
|
@@ -29655,12 +30415,12 @@ var init_use_blinking_cursor = __esm({
|
|
|
29655
30415
|
import { useState as useState24 } from "react";
|
|
29656
30416
|
import { Box as Box37, Text as Text40 } from "ink";
|
|
29657
30417
|
import { readdirSync as readdirSync3 } from "node:fs";
|
|
29658
|
-
import { dirname as
|
|
30418
|
+
import { dirname as dirname16, basename as basename6, join as join22 } from "node:path";
|
|
29659
30419
|
import { jsx as jsx48, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
29660
30420
|
function autocomplete(partial) {
|
|
29661
30421
|
if (!partial) return null;
|
|
29662
30422
|
const normalized = normalizePath(partial);
|
|
29663
|
-
const dir =
|
|
30423
|
+
const dir = dirname16(normalized);
|
|
29664
30424
|
const base = basename6(normalized);
|
|
29665
30425
|
let entries;
|
|
29666
30426
|
try {
|
|
@@ -30974,7 +31734,7 @@ var init_save = __esm({
|
|
|
30974
31734
|
writeFile: (path5, contents) => writeFile7(path5, contents),
|
|
30975
31735
|
appendRun,
|
|
30976
31736
|
buildSourceFingerprint,
|
|
30977
|
-
sleep: (ms) => new Promise((
|
|
31737
|
+
sleep: (ms) => new Promise((resolve29) => setTimeout(resolve29, ms)),
|
|
30978
31738
|
warn: (message) => process.stderr.write(message)
|
|
30979
31739
|
});
|
|
30980
31740
|
}
|
|
@@ -30996,7 +31756,7 @@ var init_types9 = __esm({
|
|
|
30996
31756
|
import { appendFileSync, writeFileSync } from "node:fs";
|
|
30997
31757
|
import { mkdir as mkdir8 } from "node:fs/promises";
|
|
30998
31758
|
import { tmpdir } from "node:os";
|
|
30999
|
-
import { join as join24, resolve as
|
|
31759
|
+
import { join as join24, resolve as resolve26 } from "node:path";
|
|
31000
31760
|
function appendWizardLog(entry) {
|
|
31001
31761
|
appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
|
|
31002
31762
|
}
|
|
@@ -31244,7 +32004,7 @@ function createFlowController(start, deps) {
|
|
|
31244
32004
|
},
|
|
31245
32005
|
async submitPath(submitted) {
|
|
31246
32006
|
await deps.mkdir(submitted);
|
|
31247
|
-
if (
|
|
32007
|
+
if (resolve26(submitted) !== resolve26(state2.outDir) && await deps.detectSaveConflict(submitted)) {
|
|
31248
32008
|
const subdir = deps.buildTimestampedSubdir(submitted);
|
|
31249
32009
|
await deps.mkdir(subdir);
|
|
31250
32010
|
await proceedToWrite(subdir);
|
|
@@ -31339,7 +32099,7 @@ var init_debug_mode_store = __esm({
|
|
|
31339
32099
|
|
|
31340
32100
|
// packages/experience-design-system-cli/src/tui/debug-prune.ts
|
|
31341
32101
|
import { readdir as readdir3, rm, rmdir, stat as stat5 } from "node:fs/promises";
|
|
31342
|
-
import { dirname as
|
|
32102
|
+
import { dirname as dirname17, join as join25 } from "node:path";
|
|
31343
32103
|
async function logFilesIn(dir) {
|
|
31344
32104
|
const entries = await readdir3(dir, { withFileTypes: true });
|
|
31345
32105
|
const nested = await Promise.all(
|
|
@@ -31362,7 +32122,7 @@ async function removeEmptyFolders(from, stop) {
|
|
|
31362
32122
|
}
|
|
31363
32123
|
removed += 1;
|
|
31364
32124
|
if (dir === stop) return removed;
|
|
31365
|
-
dir =
|
|
32125
|
+
dir = dirname17(dir);
|
|
31366
32126
|
}
|
|
31367
32127
|
}
|
|
31368
32128
|
async function pruneExpiredLogs(base, retentionDays, now = Date.now()) {
|
|
@@ -31378,7 +32138,7 @@ async function pruneExpiredLogs(base, retentionDays, now = Date.now()) {
|
|
|
31378
32138
|
if ((await stat5(file)).mtimeMs >= cutoff) continue;
|
|
31379
32139
|
await rm(file);
|
|
31380
32140
|
result.logs += 1;
|
|
31381
|
-
result.folders += await removeEmptyFolders(
|
|
32141
|
+
result.folders += await removeEmptyFolders(dirname17(file), join25(contentfulDir, session));
|
|
31382
32142
|
} catch {
|
|
31383
32143
|
}
|
|
31384
32144
|
}
|
|
@@ -31408,7 +32168,7 @@ __export(debug_store_exports, {
|
|
|
31408
32168
|
});
|
|
31409
32169
|
import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
|
|
31410
32170
|
import { existsSync as existsSync10, readdirSync as readdirSync4 } from "node:fs";
|
|
31411
|
-
import { join as join26, resolve as
|
|
32171
|
+
import { join as join26, resolve as resolve27 } from "node:path";
|
|
31412
32172
|
function generateRunId() {
|
|
31413
32173
|
const now = /* @__PURE__ */ new Date();
|
|
31414
32174
|
const pad = (n) => String(n).padStart(2, "0");
|
|
@@ -31424,7 +32184,7 @@ function slugify(value) {
|
|
|
31424
32184
|
async function readBaseDir() {
|
|
31425
32185
|
try {
|
|
31426
32186
|
const dir = (await readSettings2())["contentfulBaseDir"];
|
|
31427
|
-
return typeof dir === "string" && dir !== "" ?
|
|
32187
|
+
return typeof dir === "string" && dir !== "" ? resolve27(dir) : void 0;
|
|
31428
32188
|
} catch {
|
|
31429
32189
|
return void 0;
|
|
31430
32190
|
}
|
|
@@ -31453,7 +32213,7 @@ function currentSessionDir() {
|
|
|
31453
32213
|
async function startDebugSessionIn(base, { replace = false } = {}) {
|
|
31454
32214
|
try {
|
|
31455
32215
|
if (!await isDebugModeEnabled()) return;
|
|
31456
|
-
await mkdir9(join26(startSession(
|
|
32216
|
+
await mkdir9(join26(startSession(resolve27(base), { replace }), "debug"), { recursive: true });
|
|
31457
32217
|
} catch {
|
|
31458
32218
|
}
|
|
31459
32219
|
}
|
|
@@ -31467,7 +32227,7 @@ function nextImportRunDir(session) {
|
|
|
31467
32227
|
}
|
|
31468
32228
|
async function startImportRun(projectPath) {
|
|
31469
32229
|
await startDebugSessionIn(projectPath);
|
|
31470
|
-
if (!sessionDir) return join26(
|
|
32230
|
+
if (!sessionDir) return join26(resolve27(projectPath), ".contentful");
|
|
31471
32231
|
const dir = nextImportRunDir(sessionDir);
|
|
31472
32232
|
await mkdir9(dir, { recursive: true });
|
|
31473
32233
|
return dir;
|
|
@@ -31609,7 +32369,7 @@ var init_debug_store = __esm({
|
|
|
31609
32369
|
});
|
|
31610
32370
|
|
|
31611
32371
|
// packages/experience-design-system-cli/src/tui/help/file-locations.ts
|
|
31612
|
-
import { join as join27, resolve as
|
|
32372
|
+
import { join as join27, resolve as resolve28 } from "node:path";
|
|
31613
32373
|
function describeFileLocations({
|
|
31614
32374
|
contentfulBaseDir,
|
|
31615
32375
|
debugModeEnabled,
|
|
@@ -31621,7 +32381,7 @@ function describeFileLocations({
|
|
|
31621
32381
|
importFiles: `${join27("<project>", ".contentful")}/ (tokens.json, components.json)`
|
|
31622
32382
|
};
|
|
31623
32383
|
}
|
|
31624
|
-
const base = contentfulBaseDir ?
|
|
32384
|
+
const base = contentfulBaseDir ? resolve28(contentfulBaseDir) : "<project>";
|
|
31625
32385
|
const session = currentSessionDir2 ?? join27(base, ".contentful", "<date>-session-<n>");
|
|
31626
32386
|
return {
|
|
31627
32387
|
debugLogs: join27(session, "debug"),
|
|
@@ -31853,20 +32613,20 @@ function resolveOnPath(binary) {
|
|
|
31853
32613
|
() => null
|
|
31854
32614
|
);
|
|
31855
32615
|
}
|
|
31856
|
-
return new Promise((
|
|
32616
|
+
return new Promise((resolve29) => {
|
|
31857
32617
|
execFile2(
|
|
31858
32618
|
process.platform === "win32" ? "where" : "which",
|
|
31859
32619
|
[binary],
|
|
31860
|
-
(error, stdout) =>
|
|
32620
|
+
(error, stdout) => resolve29(error ? null : stdout.split("\n")[0]?.trim() ?? null)
|
|
31861
32621
|
);
|
|
31862
32622
|
});
|
|
31863
32623
|
}
|
|
31864
32624
|
function readVersion(binary) {
|
|
31865
|
-
return new Promise((
|
|
32625
|
+
return new Promise((resolve29) => {
|
|
31866
32626
|
execFile2(binary, ["--version"], { timeout: VERSION_TIMEOUT_MS }, (error, stdout) => {
|
|
31867
32627
|
const line = stdout.split("\n")[0]?.trim() ?? "";
|
|
31868
|
-
if (!error && line)
|
|
31869
|
-
else
|
|
32628
|
+
if (!error && line) resolve29(pass("version", line));
|
|
32629
|
+
else resolve29(fail3("version", "runs, but did not report a version"));
|
|
31870
32630
|
});
|
|
31871
32631
|
});
|
|
31872
32632
|
}
|
|
@@ -33408,14 +34168,14 @@ function runDevWatch(args) {
|
|
|
33408
34168
|
process.stderr.write("--watch only works from a checkout of the repo (scripts/dev.mjs is not in the package).\n");
|
|
33409
34169
|
return Promise.resolve(1);
|
|
33410
34170
|
}
|
|
33411
|
-
return new Promise((
|
|
34171
|
+
return new Promise((resolve29) => {
|
|
33412
34172
|
const child = spawn3(process.execPath, [script, ...args], { stdio: "inherit" });
|
|
33413
34173
|
process.on("SIGINT", () => void 0);
|
|
33414
|
-
child.on("exit", (code) =>
|
|
34174
|
+
child.on("exit", (code) => resolve29(code ?? 0));
|
|
33415
34175
|
child.on("error", (err) => {
|
|
33416
34176
|
process.stderr.write(`${err.message}
|
|
33417
34177
|
`);
|
|
33418
|
-
|
|
34178
|
+
resolve29(1);
|
|
33419
34179
|
});
|
|
33420
34180
|
});
|
|
33421
34181
|
}
|
|
@@ -33486,12 +34246,12 @@ function createProgram() {
|
|
|
33486
34246
|
init_config();
|
|
33487
34247
|
init_package_root();
|
|
33488
34248
|
import { existsSync as existsSync12 } from "node:fs";
|
|
33489
|
-
import { mkdir as mkdir10, readFile as
|
|
33490
|
-
import { dirname as
|
|
34249
|
+
import { mkdir as mkdir10, readFile as readFile21, rename as rename3, rmdir as rmdir2, unlink } from "node:fs/promises";
|
|
34250
|
+
import { dirname as dirname18, join as join30 } from "node:path";
|
|
33491
34251
|
var PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
|
|
33492
34252
|
async function readJson(path5) {
|
|
33493
34253
|
try {
|
|
33494
|
-
return JSON.parse(await
|
|
34254
|
+
return JSON.parse(await readFile21(path5, "utf8"));
|
|
33495
34255
|
} catch {
|
|
33496
34256
|
return void 0;
|
|
33497
34257
|
}
|
|
@@ -33513,7 +34273,7 @@ async function migrateOldConfig() {
|
|
|
33513
34273
|
if (Object.keys(migrated).length > 0) await updateSettings2({ ...migrated, ...await readSettings2() });
|
|
33514
34274
|
if (existsSync12(oldRuns)) {
|
|
33515
34275
|
if (!existsSync12(runsFilePath2())) {
|
|
33516
|
-
await mkdir10(
|
|
34276
|
+
await mkdir10(dirname18(runsFilePath2()), { recursive: true });
|
|
33517
34277
|
await rename3(oldRuns, runsFilePath2());
|
|
33518
34278
|
} else {
|
|
33519
34279
|
await unlink(oldRuns);
|