@agent-scope/cli 1.15.0 → 1.16.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/cli.js +185 -51
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +145 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +145 -15
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/program.ts
|
|
4
|
-
import { readFileSync as
|
|
4
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
5
5
|
import { generateTest, loadTrace } from "@agent-scope/playwright";
|
|
6
6
|
import { Command as Command9 } from "commander";
|
|
7
7
|
|
|
@@ -1174,9 +1174,9 @@ function createRL() {
|
|
|
1174
1174
|
});
|
|
1175
1175
|
}
|
|
1176
1176
|
async function ask(rl, question) {
|
|
1177
|
-
return new Promise((
|
|
1177
|
+
return new Promise((resolve16) => {
|
|
1178
1178
|
rl.question(question, (answer) => {
|
|
1179
|
-
|
|
1179
|
+
resolve16(answer.trim());
|
|
1180
1180
|
});
|
|
1181
1181
|
});
|
|
1182
1182
|
}
|
|
@@ -2485,8 +2485,8 @@ Available: ${available}`
|
|
|
2485
2485
|
wastedRenders: opts.wastedRenders
|
|
2486
2486
|
});
|
|
2487
2487
|
await shutdownPool2();
|
|
2488
|
-
const
|
|
2489
|
-
if (
|
|
2488
|
+
const fmt2 = resolveFormat2(opts.format);
|
|
2489
|
+
if (fmt2 === "json") {
|
|
2490
2490
|
process.stdout.write(`${JSON.stringify(instrumentRoot, null, 2)}
|
|
2491
2491
|
`);
|
|
2492
2492
|
} else {
|
|
@@ -3182,12 +3182,12 @@ Available: ${available}`
|
|
|
3182
3182
|
);
|
|
3183
3183
|
return;
|
|
3184
3184
|
}
|
|
3185
|
-
const
|
|
3186
|
-
if (
|
|
3185
|
+
const fmt2 = resolveSingleFormat(opts.format);
|
|
3186
|
+
if (fmt2 === "json") {
|
|
3187
3187
|
const json = formatRenderJson(componentName, props, result);
|
|
3188
3188
|
process.stdout.write(`${JSON.stringify(json, null, 2)}
|
|
3189
3189
|
`);
|
|
3190
|
-
} else if (
|
|
3190
|
+
} else if (fmt2 === "file") {
|
|
3191
3191
|
const dir = resolve8(process.cwd(), DEFAULT_OUTPUT_DIR);
|
|
3192
3192
|
mkdirSync3(dir, { recursive: true });
|
|
3193
3193
|
const outPath = resolve8(dir, `${componentName}.png`);
|
|
@@ -3308,8 +3308,8 @@ Available: ${available}`
|
|
|
3308
3308
|
process.stderr.write(`Sprite sheet saved to ${spritePath}
|
|
3309
3309
|
`);
|
|
3310
3310
|
}
|
|
3311
|
-
const
|
|
3312
|
-
if (
|
|
3311
|
+
const fmt2 = resolveMatrixFormat(opts.format, opts.sprite !== void 0);
|
|
3312
|
+
if (fmt2 === "file") {
|
|
3313
3313
|
const { SpriteSheetGenerator: SpriteSheetGenerator2 } = await import("@agent-scope/render");
|
|
3314
3314
|
const gen = new SpriteSheetGenerator2();
|
|
3315
3315
|
const sheet = await gen.generate(result);
|
|
@@ -3322,10 +3322,10 @@ Available: ${available}`
|
|
|
3322
3322
|
`\u2713 ${componentName} matrix (${result.stats.totalCells} cells) \u2192 ${relPath} (${result.stats.wallClockTimeMs.toFixed(0)}ms total)
|
|
3323
3323
|
`
|
|
3324
3324
|
);
|
|
3325
|
-
} else if (
|
|
3325
|
+
} else if (fmt2 === "json") {
|
|
3326
3326
|
process.stdout.write(`${JSON.stringify(formatMatrixJson(result), null, 2)}
|
|
3327
3327
|
`);
|
|
3328
|
-
} else if (
|
|
3328
|
+
} else if (fmt2 === "png") {
|
|
3329
3329
|
if (opts.sprite !== void 0) {
|
|
3330
3330
|
} else {
|
|
3331
3331
|
const { SpriteSheetGenerator: SpriteSheetGenerator2 } = await import("@agent-scope/render");
|
|
@@ -3333,9 +3333,9 @@ Available: ${available}`
|
|
|
3333
3333
|
const sheet = await gen.generate(result);
|
|
3334
3334
|
process.stdout.write(sheet.png);
|
|
3335
3335
|
}
|
|
3336
|
-
} else if (
|
|
3336
|
+
} else if (fmt2 === "html") {
|
|
3337
3337
|
process.stdout.write(formatMatrixHtml(componentName, result));
|
|
3338
|
-
} else if (
|
|
3338
|
+
} else if (fmt2 === "csv") {
|
|
3339
3339
|
process.stdout.write(formatMatrixCsv(componentName, result));
|
|
3340
3340
|
}
|
|
3341
3341
|
} catch (err) {
|
|
@@ -3643,12 +3643,12 @@ async function runBaseline(options = {}) {
|
|
|
3643
3643
|
mkdirSync4(rendersDir, { recursive: true });
|
|
3644
3644
|
let manifest;
|
|
3645
3645
|
if (manifestPath !== void 0) {
|
|
3646
|
-
const { readFileSync:
|
|
3646
|
+
const { readFileSync: readFileSync12 } = await import("fs");
|
|
3647
3647
|
const absPath = resolve9(rootDir, manifestPath);
|
|
3648
3648
|
if (!existsSync6(absPath)) {
|
|
3649
3649
|
throw new Error(`Manifest not found at ${absPath}.`);
|
|
3650
3650
|
}
|
|
3651
|
-
manifest = JSON.parse(
|
|
3651
|
+
manifest = JSON.parse(readFileSync12(absPath, "utf-8"));
|
|
3652
3652
|
process.stderr.write(`Loaded manifest from ${manifestPath}
|
|
3653
3653
|
`);
|
|
3654
3654
|
} else {
|
|
@@ -4290,6 +4290,139 @@ function registerDiffSubCommand(reportCmd) {
|
|
|
4290
4290
|
);
|
|
4291
4291
|
}
|
|
4292
4292
|
|
|
4293
|
+
// src/report/pr-comment.ts
|
|
4294
|
+
import { existsSync as existsSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync8 } from "fs";
|
|
4295
|
+
import { resolve as resolve11 } from "path";
|
|
4296
|
+
var STATUS_BADGE = {
|
|
4297
|
+
added: "\u2705 added",
|
|
4298
|
+
removed: "\u{1F5D1}\uFE0F removed",
|
|
4299
|
+
unchanged: "\u2014 unchanged",
|
|
4300
|
+
compliance_regressed: "\u274C regressed",
|
|
4301
|
+
compliance_improved: "\u{1F4C8} improved",
|
|
4302
|
+
size_changed: "\u{1F4D0} resized"
|
|
4303
|
+
};
|
|
4304
|
+
function fmt(n) {
|
|
4305
|
+
return `${(n * 100).toFixed(1)}%`;
|
|
4306
|
+
}
|
|
4307
|
+
function fmtDelta(delta) {
|
|
4308
|
+
if (delta === null) return "\u2014";
|
|
4309
|
+
const sign = delta >= 0 ? "+" : "";
|
|
4310
|
+
return `${sign}${(delta * 100).toFixed(1)}%`;
|
|
4311
|
+
}
|
|
4312
|
+
function fmtDimensions(d) {
|
|
4313
|
+
if (d === null) return "\u2014";
|
|
4314
|
+
return `${d.width} \xD7 ${d.height}`;
|
|
4315
|
+
}
|
|
4316
|
+
function complianceDeltaArrow(diff) {
|
|
4317
|
+
const delta = diff.currentAggregateCompliance - diff.baselineAggregateCompliance;
|
|
4318
|
+
if (Math.abs(delta) < 5e-4) return `\u2192 ${fmt(diff.currentAggregateCompliance)} (no change)`;
|
|
4319
|
+
const arrow = delta > 0 ? "\u2191" : "\u2193";
|
|
4320
|
+
return `${arrow} ${fmtDelta(delta)}`;
|
|
4321
|
+
}
|
|
4322
|
+
function formatPrComment(diff) {
|
|
4323
|
+
const { summary, components } = diff;
|
|
4324
|
+
const lines = [];
|
|
4325
|
+
const hasRegressions = diff.hasRegressions;
|
|
4326
|
+
const headerEmoji = hasRegressions ? "\u26A0\uFE0F" : "\u2705";
|
|
4327
|
+
lines.push(`## ${headerEmoji} Scope Report`);
|
|
4328
|
+
lines.push("");
|
|
4329
|
+
lines.push("| Metric | Value |");
|
|
4330
|
+
lines.push("|---|---|");
|
|
4331
|
+
lines.push(`| Baseline compliance | ${fmt(diff.baselineAggregateCompliance)} |`);
|
|
4332
|
+
lines.push(`| Current compliance | ${fmt(diff.currentAggregateCompliance)} |`);
|
|
4333
|
+
lines.push(`| Delta | ${complianceDeltaArrow(diff)} |`);
|
|
4334
|
+
lines.push(
|
|
4335
|
+
`| Components | ${summary.total} total \xB7 ${summary.added} added \xB7 ${summary.removed} removed \xB7 ${summary.complianceRegressed} regressed |`
|
|
4336
|
+
);
|
|
4337
|
+
if (summary.renderFailed > 0) {
|
|
4338
|
+
lines.push(`| Render failures | ${summary.renderFailed} |`);
|
|
4339
|
+
}
|
|
4340
|
+
lines.push("");
|
|
4341
|
+
const changed = components.filter((c) => c.status !== "unchanged");
|
|
4342
|
+
const unchanged = components.filter((c) => c.status === "unchanged");
|
|
4343
|
+
if (changed.length > 0) {
|
|
4344
|
+
lines.push("### Changes");
|
|
4345
|
+
lines.push("");
|
|
4346
|
+
lines.push("| Component | Status | Compliance \u0394 | Dimensions |");
|
|
4347
|
+
lines.push("|---|---|---|---|");
|
|
4348
|
+
for (const c of changed) {
|
|
4349
|
+
const badge = STATUS_BADGE[c.status];
|
|
4350
|
+
const delta = fmtDelta(c.complianceDelta);
|
|
4351
|
+
const dims = fmtDimensions(c.currentDimensions ?? c.baselineDimensions);
|
|
4352
|
+
lines.push(`| \`${c.name}\` | ${badge} | ${delta} | ${dims} |`);
|
|
4353
|
+
}
|
|
4354
|
+
lines.push("");
|
|
4355
|
+
}
|
|
4356
|
+
if (unchanged.length > 0) {
|
|
4357
|
+
lines.push(
|
|
4358
|
+
`<details><summary>${unchanged.length} unchanged component${unchanged.length === 1 ? "" : "s"}</summary>`
|
|
4359
|
+
);
|
|
4360
|
+
lines.push("");
|
|
4361
|
+
lines.push("| Component | Compliance |");
|
|
4362
|
+
lines.push("|---|---|");
|
|
4363
|
+
for (const c of unchanged) {
|
|
4364
|
+
lines.push(
|
|
4365
|
+
`| \`${c.name}\` | ${c.currentCompliance !== null ? fmt(c.currentCompliance) : "\u2014"} |`
|
|
4366
|
+
);
|
|
4367
|
+
}
|
|
4368
|
+
lines.push("");
|
|
4369
|
+
lines.push("</details>");
|
|
4370
|
+
lines.push("");
|
|
4371
|
+
}
|
|
4372
|
+
lines.push(
|
|
4373
|
+
`> Generated by [Scope](https://github.com/FlatFilers/Scope) \xB7 diffed at ${diff.diffedAt}`
|
|
4374
|
+
);
|
|
4375
|
+
return lines.join("\n");
|
|
4376
|
+
}
|
|
4377
|
+
function loadDiffResult(filePath) {
|
|
4378
|
+
const abs = resolve11(filePath);
|
|
4379
|
+
if (!existsSync8(abs)) {
|
|
4380
|
+
throw new Error(`DiffResult file not found: ${abs}`);
|
|
4381
|
+
}
|
|
4382
|
+
let raw;
|
|
4383
|
+
try {
|
|
4384
|
+
raw = readFileSync7(abs, "utf-8");
|
|
4385
|
+
} catch (err) {
|
|
4386
|
+
throw new Error(
|
|
4387
|
+
`Failed to read DiffResult file: ${err instanceof Error ? err.message : String(err)}`
|
|
4388
|
+
);
|
|
4389
|
+
}
|
|
4390
|
+
let parsed;
|
|
4391
|
+
try {
|
|
4392
|
+
parsed = JSON.parse(raw);
|
|
4393
|
+
} catch {
|
|
4394
|
+
throw new Error(`DiffResult file is not valid JSON: ${abs}`);
|
|
4395
|
+
}
|
|
4396
|
+
if (typeof parsed !== "object" || parsed === null || !("diffedAt" in parsed) || !("components" in parsed) || !("summary" in parsed)) {
|
|
4397
|
+
throw new Error(
|
|
4398
|
+
`DiffResult file does not match expected shape (missing diffedAt/components/summary): ${abs}`
|
|
4399
|
+
);
|
|
4400
|
+
}
|
|
4401
|
+
return parsed;
|
|
4402
|
+
}
|
|
4403
|
+
function registerPrCommentSubCommand(reportCmd) {
|
|
4404
|
+
reportCmd.command("pr-comment").description(
|
|
4405
|
+
"Format a DiffResult JSON file as a GitHub PR comment (Markdown, written to stdout)"
|
|
4406
|
+
).requiredOption("-i, --input <path>", "Path to DiffResult JSON (from scope report diff --json)").option("-o, --output <path>", "Write comment to file instead of stdout").action(async (opts) => {
|
|
4407
|
+
try {
|
|
4408
|
+
const diff = loadDiffResult(opts.input);
|
|
4409
|
+
const comment = formatPrComment(diff);
|
|
4410
|
+
if (opts.output !== void 0) {
|
|
4411
|
+
writeFileSync8(resolve11(opts.output), comment, "utf-8");
|
|
4412
|
+
process.stderr.write(`PR comment written to ${opts.output}
|
|
4413
|
+
`);
|
|
4414
|
+
} else {
|
|
4415
|
+
process.stdout.write(`${comment}
|
|
4416
|
+
`);
|
|
4417
|
+
}
|
|
4418
|
+
} catch (err) {
|
|
4419
|
+
process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
|
|
4420
|
+
`);
|
|
4421
|
+
process.exit(1);
|
|
4422
|
+
}
|
|
4423
|
+
});
|
|
4424
|
+
}
|
|
4425
|
+
|
|
4293
4426
|
// src/tree-formatter.ts
|
|
4294
4427
|
var BRANCH2 = "\u251C\u2500\u2500 ";
|
|
4295
4428
|
var LAST_BRANCH2 = "\u2514\u2500\u2500 ";
|
|
@@ -4570,8 +4703,8 @@ function buildStructuredReport(report) {
|
|
|
4570
4703
|
}
|
|
4571
4704
|
|
|
4572
4705
|
// src/tokens/commands.ts
|
|
4573
|
-
import { existsSync as
|
|
4574
|
-
import { resolve as
|
|
4706
|
+
import { existsSync as existsSync11, readFileSync as readFileSync10 } from "fs";
|
|
4707
|
+
import { resolve as resolve15 } from "path";
|
|
4575
4708
|
import {
|
|
4576
4709
|
parseTokenFileSync as parseTokenFileSync2,
|
|
4577
4710
|
TokenParseError,
|
|
@@ -4582,23 +4715,23 @@ import {
|
|
|
4582
4715
|
import { Command as Command8 } from "commander";
|
|
4583
4716
|
|
|
4584
4717
|
// src/tokens/compliance.ts
|
|
4585
|
-
import { existsSync as
|
|
4586
|
-
import { resolve as
|
|
4718
|
+
import { existsSync as existsSync9, readFileSync as readFileSync8 } from "fs";
|
|
4719
|
+
import { resolve as resolve12 } from "path";
|
|
4587
4720
|
import {
|
|
4588
4721
|
ComplianceEngine as ComplianceEngine4,
|
|
4589
4722
|
TokenResolver as TokenResolver4
|
|
4590
4723
|
} from "@agent-scope/tokens";
|
|
4591
4724
|
var DEFAULT_STYLES_PATH = ".reactscope/compliance-styles.json";
|
|
4592
4725
|
function loadStylesFile(stylesPath) {
|
|
4593
|
-
const absPath =
|
|
4594
|
-
if (!
|
|
4726
|
+
const absPath = resolve12(process.cwd(), stylesPath);
|
|
4727
|
+
if (!existsSync9(absPath)) {
|
|
4595
4728
|
throw new Error(
|
|
4596
4729
|
`Compliance styles file not found at ${absPath}.
|
|
4597
4730
|
Run \`scope render all\` first to generate component styles, or use --styles to specify a path.
|
|
4598
4731
|
Expected format: { "ComponentName": { colors: {}, spacing: {}, typography: {}, borders: {}, shadows: {} } }`
|
|
4599
4732
|
);
|
|
4600
4733
|
}
|
|
4601
|
-
const raw =
|
|
4734
|
+
const raw = readFileSync8(absPath, "utf-8");
|
|
4602
4735
|
let parsed;
|
|
4603
4736
|
try {
|
|
4604
4737
|
parsed = JSON.parse(raw);
|
|
@@ -4758,8 +4891,8 @@ function registerCompliance(tokensCmd) {
|
|
|
4758
4891
|
}
|
|
4759
4892
|
|
|
4760
4893
|
// src/tokens/export.ts
|
|
4761
|
-
import { existsSync as
|
|
4762
|
-
import { resolve as
|
|
4894
|
+
import { existsSync as existsSync10, readFileSync as readFileSync9, writeFileSync as writeFileSync9 } from "fs";
|
|
4895
|
+
import { resolve as resolve13 } from "path";
|
|
4763
4896
|
import {
|
|
4764
4897
|
exportTokens,
|
|
4765
4898
|
parseTokenFileSync,
|
|
@@ -4772,21 +4905,21 @@ var CONFIG_FILE = "reactscope.config.json";
|
|
|
4772
4905
|
var SUPPORTED_FORMATS = ["css", "ts", "scss", "tailwind", "flat-json", "figma"];
|
|
4773
4906
|
function resolveTokenFilePath2(fileFlag) {
|
|
4774
4907
|
if (fileFlag !== void 0) {
|
|
4775
|
-
return
|
|
4908
|
+
return resolve13(process.cwd(), fileFlag);
|
|
4776
4909
|
}
|
|
4777
|
-
const configPath =
|
|
4778
|
-
if (
|
|
4910
|
+
const configPath = resolve13(process.cwd(), CONFIG_FILE);
|
|
4911
|
+
if (existsSync10(configPath)) {
|
|
4779
4912
|
try {
|
|
4780
|
-
const raw =
|
|
4913
|
+
const raw = readFileSync9(configPath, "utf-8");
|
|
4781
4914
|
const config = JSON.parse(raw);
|
|
4782
4915
|
if (typeof config === "object" && config !== null && "tokens" in config && typeof config.tokens === "object" && config.tokens !== null && typeof config.tokens?.file === "string") {
|
|
4783
4916
|
const file = config.tokens.file;
|
|
4784
|
-
return
|
|
4917
|
+
return resolve13(process.cwd(), file);
|
|
4785
4918
|
}
|
|
4786
4919
|
} catch {
|
|
4787
4920
|
}
|
|
4788
4921
|
}
|
|
4789
|
-
return
|
|
4922
|
+
return resolve13(process.cwd(), DEFAULT_TOKEN_FILE);
|
|
4790
4923
|
}
|
|
4791
4924
|
function createTokensExportCommand() {
|
|
4792
4925
|
return new Command7("export").description("Export design tokens to a downstream format").requiredOption("--format <fmt>", `Output format: ${SUPPORTED_FORMATS.join(", ")}`).option("--file <path>", "Path to token file (overrides config)").option("--out <path>", "Write output to file instead of stdout").option("--prefix <prefix>", "CSS/SCSS: prefix for variable names (e.g. 'scope')").option("--selector <selector>", "CSS: custom root selector (default: ':root')").option(
|
|
@@ -4805,13 +4938,13 @@ Supported formats: ${SUPPORTED_FORMATS.join(", ")}
|
|
|
4805
4938
|
const format = opts.format;
|
|
4806
4939
|
try {
|
|
4807
4940
|
const filePath = resolveTokenFilePath2(opts.file);
|
|
4808
|
-
if (!
|
|
4941
|
+
if (!existsSync10(filePath)) {
|
|
4809
4942
|
throw new Error(
|
|
4810
4943
|
`Token file not found at ${filePath}.
|
|
4811
4944
|
Create a reactscope.tokens.json file or use --file to specify a path.`
|
|
4812
4945
|
);
|
|
4813
4946
|
}
|
|
4814
|
-
const raw =
|
|
4947
|
+
const raw = readFileSync9(filePath, "utf-8");
|
|
4815
4948
|
const { tokens, rawFile } = parseTokenFileSync(raw);
|
|
4816
4949
|
let themesMap;
|
|
4817
4950
|
if (opts.theme !== void 0) {
|
|
@@ -4850,8 +4983,8 @@ Available themes: ${themeNames.join(", ")}`
|
|
|
4850
4983
|
themes: themesMap
|
|
4851
4984
|
});
|
|
4852
4985
|
if (opts.out !== void 0) {
|
|
4853
|
-
const outPath =
|
|
4854
|
-
|
|
4986
|
+
const outPath = resolve13(process.cwd(), opts.out);
|
|
4987
|
+
writeFileSync9(outPath, output, "utf-8");
|
|
4855
4988
|
process.stderr.write(`Exported ${tokens.length} tokens to ${outPath}
|
|
4856
4989
|
`);
|
|
4857
4990
|
} else {
|
|
@@ -4965,8 +5098,8 @@ ${formatImpactSummary(report)}
|
|
|
4965
5098
|
}
|
|
4966
5099
|
|
|
4967
5100
|
// src/tokens/preview.ts
|
|
4968
|
-
import { mkdirSync as mkdirSync5, writeFileSync as
|
|
4969
|
-
import { resolve as
|
|
5101
|
+
import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync10 } from "fs";
|
|
5102
|
+
import { resolve as resolve14 } from "path";
|
|
4970
5103
|
import { BrowserPool as BrowserPool7, SpriteSheetGenerator } from "@agent-scope/render";
|
|
4971
5104
|
import { ComplianceEngine as ComplianceEngine6, ImpactAnalyzer as ImpactAnalyzer2, TokenResolver as TokenResolver7 } from "@agent-scope/tokens";
|
|
4972
5105
|
var DEFAULT_STYLES_PATH3 = ".reactscope/compliance-styles.json";
|
|
@@ -5147,10 +5280,10 @@ function registerPreview(tokensCmd) {
|
|
|
5147
5280
|
});
|
|
5148
5281
|
const spriteResult = await generator.generate(matrixResult);
|
|
5149
5282
|
const tokenLabel = tokenPath.replace(/\./g, "-");
|
|
5150
|
-
const outputPath = opts.output ??
|
|
5151
|
-
const outputDir =
|
|
5283
|
+
const outputPath = opts.output ?? resolve14(process.cwd(), DEFAULT_OUTPUT_DIR2, `preview-${tokenLabel}.png`);
|
|
5284
|
+
const outputDir = resolve14(outputPath, "..");
|
|
5152
5285
|
mkdirSync5(outputDir, { recursive: true });
|
|
5153
|
-
|
|
5286
|
+
writeFileSync10(outputPath, spriteResult.png);
|
|
5154
5287
|
const useJson = opts.format === "json" || opts.format !== "text" && !isTTY();
|
|
5155
5288
|
if (useJson) {
|
|
5156
5289
|
process.stdout.write(
|
|
@@ -5209,30 +5342,30 @@ function buildTable2(headers, rows) {
|
|
|
5209
5342
|
}
|
|
5210
5343
|
function resolveTokenFilePath(fileFlag) {
|
|
5211
5344
|
if (fileFlag !== void 0) {
|
|
5212
|
-
return
|
|
5345
|
+
return resolve15(process.cwd(), fileFlag);
|
|
5213
5346
|
}
|
|
5214
|
-
const configPath =
|
|
5215
|
-
if (
|
|
5347
|
+
const configPath = resolve15(process.cwd(), CONFIG_FILE2);
|
|
5348
|
+
if (existsSync11(configPath)) {
|
|
5216
5349
|
try {
|
|
5217
|
-
const raw =
|
|
5350
|
+
const raw = readFileSync10(configPath, "utf-8");
|
|
5218
5351
|
const config = JSON.parse(raw);
|
|
5219
5352
|
if (typeof config === "object" && config !== null && "tokens" in config && typeof config.tokens === "object" && config.tokens !== null && typeof config.tokens?.file === "string") {
|
|
5220
5353
|
const file = config.tokens.file;
|
|
5221
|
-
return
|
|
5354
|
+
return resolve15(process.cwd(), file);
|
|
5222
5355
|
}
|
|
5223
5356
|
} catch {
|
|
5224
5357
|
}
|
|
5225
5358
|
}
|
|
5226
|
-
return
|
|
5359
|
+
return resolve15(process.cwd(), DEFAULT_TOKEN_FILE2);
|
|
5227
5360
|
}
|
|
5228
5361
|
function loadTokens(absPath) {
|
|
5229
|
-
if (!
|
|
5362
|
+
if (!existsSync11(absPath)) {
|
|
5230
5363
|
throw new Error(
|
|
5231
5364
|
`Token file not found at ${absPath}.
|
|
5232
5365
|
Create a reactscope.tokens.json file or use --file to specify a path.`
|
|
5233
5366
|
);
|
|
5234
5367
|
}
|
|
5235
|
-
const raw =
|
|
5368
|
+
const raw = readFileSync10(absPath, "utf-8");
|
|
5236
5369
|
return parseTokenFileSync2(raw);
|
|
5237
5370
|
}
|
|
5238
5371
|
function getRawValue(node, segments) {
|
|
@@ -5446,13 +5579,13 @@ function registerValidate(tokensCmd) {
|
|
|
5446
5579
|
).option("--file <path>", "Path to token file (overrides config)").option("--format <fmt>", "Output format: json or text (default: auto-detect)").action((opts) => {
|
|
5447
5580
|
try {
|
|
5448
5581
|
const filePath = resolveTokenFilePath(opts.file);
|
|
5449
|
-
if (!
|
|
5582
|
+
if (!existsSync11(filePath)) {
|
|
5450
5583
|
throw new Error(
|
|
5451
5584
|
`Token file not found at ${filePath}.
|
|
5452
5585
|
Create a reactscope.tokens.json file or use --file to specify a path.`
|
|
5453
5586
|
);
|
|
5454
5587
|
}
|
|
5455
|
-
const raw =
|
|
5588
|
+
const raw = readFileSync10(filePath, "utf-8");
|
|
5456
5589
|
const useJson = opts.format === "json" || opts.format !== "text" && !isTTY2();
|
|
5457
5590
|
const errors = [];
|
|
5458
5591
|
let parsed;
|
|
@@ -5610,7 +5743,7 @@ function createProgram(options = {}) {
|
|
|
5610
5743
|
}
|
|
5611
5744
|
);
|
|
5612
5745
|
program2.command("generate").description("Generate a Playwright test from a Scope trace file").argument("<trace>", "Path to a serialized Scope trace (.json)").option("-o, --output <path>", "Output file path", "scope.spec.ts").option("-d, --description <text>", "Test description").action((tracePath, opts) => {
|
|
5613
|
-
const raw =
|
|
5746
|
+
const raw = readFileSync11(tracePath, "utf-8");
|
|
5614
5747
|
const trace = loadTrace(raw);
|
|
5615
5748
|
const source = generateTest(trace, {
|
|
5616
5749
|
description: opts.description,
|
|
@@ -5629,6 +5762,7 @@ function createProgram(options = {}) {
|
|
|
5629
5762
|
if (existingReportCmd !== void 0) {
|
|
5630
5763
|
registerBaselineSubCommand(existingReportCmd);
|
|
5631
5764
|
registerDiffSubCommand(existingReportCmd);
|
|
5765
|
+
registerPrCommentSubCommand(existingReportCmd);
|
|
5632
5766
|
}
|
|
5633
5767
|
return program2;
|
|
5634
5768
|
}
|