tailwindcss-patch 9.0.0-alpha.2 → 9.0.0-alpha.3
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/{chunk-TOAZIPHJ.js → chunk-77GHKSKG.js} +33 -724
- package/dist/{chunk-VDWTCQ74.mjs → chunk-D6ICWMM4.mjs} +37 -728
- package/dist/chunk-PMN7HS4Y.js +25 -0
- package/dist/chunk-YYBY7EM5.mjs +21 -0
- package/dist/cli.js +7 -5
- package/dist/cli.mjs +5 -3
- package/dist/commands/cli-runtime.d.mts +13 -0
- package/dist/commands/cli-runtime.d.ts +13 -0
- package/dist/commands/cli-runtime.js +1331 -0
- package/dist/commands/cli-runtime.mjs +1331 -0
- package/dist/index.d.mts +11 -679
- package/dist/index.d.ts +11 -679
- package/dist/index.js +5 -7
- package/dist/index.mjs +6 -8
- package/dist/validate-nbmOI2w8.d.mts +677 -0
- package/dist/validate-nbmOI2w8.d.ts +677 -0
- package/package.json +4 -1
- package/src/cli.bundle.ts +20 -0
- package/src/index.bundle.ts +105 -0
|
@@ -20,10 +20,13 @@ import path from "pathe";
|
|
|
20
20
|
// package.json
|
|
21
21
|
var package_default = {
|
|
22
22
|
name: "tailwindcss-patch",
|
|
23
|
-
version: "9.0.0-alpha.
|
|
23
|
+
version: "9.0.0-alpha.3",
|
|
24
24
|
description: "patch tailwindcss for exposing context and extract classes",
|
|
25
25
|
author: "ice breaker <1324318532@qq.com>",
|
|
26
26
|
license: "MIT",
|
|
27
|
+
engines: {
|
|
28
|
+
node: ">=18.0.0"
|
|
29
|
+
},
|
|
27
30
|
homepage: "https://mangle.icebreaker.top/",
|
|
28
31
|
repository: {
|
|
29
32
|
type: "git",
|
|
@@ -2405,8 +2408,8 @@ function transformProcessTailwindFeaturesReturnContextV2(content) {
|
|
|
2405
2408
|
});
|
|
2406
2409
|
let hasPatched = false;
|
|
2407
2410
|
traverse(ast, {
|
|
2408
|
-
FunctionDeclaration(
|
|
2409
|
-
const node =
|
|
2411
|
+
FunctionDeclaration(path15) {
|
|
2412
|
+
const node = path15.node;
|
|
2410
2413
|
if (node.id?.name !== "processTailwindFeatures" || node.body.body.length !== 1 || !t.isReturnStatement(node.body.body[0])) {
|
|
2411
2414
|
return;
|
|
2412
2415
|
}
|
|
@@ -2437,8 +2440,8 @@ function transformPostcssPluginV2(content, options) {
|
|
|
2437
2440
|
const ast = parse(content);
|
|
2438
2441
|
let hasPatched = false;
|
|
2439
2442
|
traverse(ast, {
|
|
2440
|
-
Program(
|
|
2441
|
-
const program =
|
|
2443
|
+
Program(path15) {
|
|
2444
|
+
const program = path15.node;
|
|
2442
2445
|
const index = program.body.findIndex((statement) => {
|
|
2443
2446
|
return t.isFunctionDeclaration(statement) && statement.id?.name === "_default";
|
|
2444
2447
|
});
|
|
@@ -2477,11 +2480,11 @@ function transformPostcssPluginV2(content, options) {
|
|
|
2477
2480
|
);
|
|
2478
2481
|
}
|
|
2479
2482
|
},
|
|
2480
|
-
FunctionDeclaration(
|
|
2483
|
+
FunctionDeclaration(path15) {
|
|
2481
2484
|
if (hasPatched) {
|
|
2482
2485
|
return;
|
|
2483
2486
|
}
|
|
2484
|
-
const fn =
|
|
2487
|
+
const fn = path15.node;
|
|
2485
2488
|
if (fn.id?.name !== "_default") {
|
|
2486
2489
|
return;
|
|
2487
2490
|
}
|
|
@@ -2570,8 +2573,8 @@ function transformProcessTailwindFeaturesReturnContext(content) {
|
|
|
2570
2573
|
const ast = parse(content);
|
|
2571
2574
|
let hasPatched = false;
|
|
2572
2575
|
traverse(ast, {
|
|
2573
|
-
FunctionDeclaration(
|
|
2574
|
-
const node =
|
|
2576
|
+
FunctionDeclaration(path15) {
|
|
2577
|
+
const node = path15.node;
|
|
2575
2578
|
if (node.id?.name !== "processTailwindFeatures" || node.body.body.length !== 1) {
|
|
2576
2579
|
return;
|
|
2577
2580
|
}
|
|
@@ -2603,8 +2606,8 @@ function transformPostcssPlugin(content, { refProperty }) {
|
|
|
2603
2606
|
const valueMember = t2.memberExpression(refIdentifier, t2.identifier("value"));
|
|
2604
2607
|
let hasPatched = false;
|
|
2605
2608
|
traverse(ast, {
|
|
2606
|
-
Program(
|
|
2607
|
-
const program =
|
|
2609
|
+
Program(path15) {
|
|
2610
|
+
const program = path15.node;
|
|
2608
2611
|
const index = program.body.findIndex((statement) => {
|
|
2609
2612
|
return t2.isExpressionStatement(statement) && t2.isAssignmentExpression(statement.expression) && t2.isMemberExpression(statement.expression.left) && t2.isFunctionExpression(statement.expression.right) && statement.expression.right.id?.name === "tailwindcss";
|
|
2610
2613
|
});
|
|
@@ -2647,11 +2650,11 @@ function transformPostcssPlugin(content, { refProperty }) {
|
|
|
2647
2650
|
);
|
|
2648
2651
|
}
|
|
2649
2652
|
},
|
|
2650
|
-
FunctionExpression(
|
|
2653
|
+
FunctionExpression(path15) {
|
|
2651
2654
|
if (hasPatched) {
|
|
2652
2655
|
return;
|
|
2653
2656
|
}
|
|
2654
|
-
const fn =
|
|
2657
|
+
const fn = path15.node;
|
|
2655
2658
|
if (fn.id?.name !== "tailwindcss" || fn.body.body.length !== 1) {
|
|
2656
2659
|
return;
|
|
2657
2660
|
}
|
|
@@ -2730,21 +2733,21 @@ function updateLengthUnitsArray(content, options) {
|
|
|
2730
2733
|
let arrayRef;
|
|
2731
2734
|
let changed = false;
|
|
2732
2735
|
traverse(ast, {
|
|
2733
|
-
Identifier(
|
|
2734
|
-
if (
|
|
2735
|
-
arrayRef =
|
|
2736
|
+
Identifier(path15) {
|
|
2737
|
+
if (path15.node.name === variableName && t3.isVariableDeclarator(path15.parent) && t3.isArrayExpression(path15.parent.init)) {
|
|
2738
|
+
arrayRef = path15.parent.init;
|
|
2736
2739
|
const existing = new Set(
|
|
2737
|
-
|
|
2740
|
+
path15.parent.init.elements.map((element) => t3.isStringLiteral(element) ? element.value : void 0).filter(Boolean)
|
|
2738
2741
|
);
|
|
2739
2742
|
for (const unit of units) {
|
|
2740
2743
|
if (!existing.has(unit)) {
|
|
2741
|
-
|
|
2744
|
+
path15.parent.init.elements = path15.parent.init.elements.map((element) => {
|
|
2742
2745
|
if (t3.isStringLiteral(element)) {
|
|
2743
2746
|
return t3.stringLiteral(element.value);
|
|
2744
2747
|
}
|
|
2745
2748
|
return element;
|
|
2746
2749
|
});
|
|
2747
|
-
|
|
2750
|
+
path15.parent.init.elements.push(t3.stringLiteral(unit));
|
|
2748
2751
|
changed = true;
|
|
2749
2752
|
}
|
|
2750
2753
|
}
|
|
@@ -2825,13 +2828,13 @@ function applyExtendLengthUnitsPatchV4(rootDir, options) {
|
|
|
2825
2828
|
const { code, file, match } = item;
|
|
2826
2829
|
const ast = parse(match[0], { sourceType: "unambiguous" });
|
|
2827
2830
|
traverse(ast, {
|
|
2828
|
-
ArrayExpression(
|
|
2831
|
+
ArrayExpression(path15) {
|
|
2829
2832
|
for (const unit of opts.units) {
|
|
2830
|
-
if (
|
|
2833
|
+
if (path15.node.elements.some((element) => t3.isStringLiteral(element) && element.value === unit)) {
|
|
2831
2834
|
item.hasPatched = true;
|
|
2832
2835
|
return;
|
|
2833
2836
|
}
|
|
2834
|
-
|
|
2837
|
+
path15.node.elements.push(t3.stringLiteral(unit));
|
|
2835
2838
|
}
|
|
2836
2839
|
}
|
|
2837
2840
|
});
|
|
@@ -2867,14 +2870,14 @@ function inspectLengthUnitsArray(content, variableName, units) {
|
|
|
2867
2870
|
let found = false;
|
|
2868
2871
|
let missingUnits = [];
|
|
2869
2872
|
traverse(ast, {
|
|
2870
|
-
Identifier(
|
|
2871
|
-
if (
|
|
2873
|
+
Identifier(path15) {
|
|
2874
|
+
if (path15.node.name === variableName && t4.isVariableDeclarator(path15.parent) && t4.isArrayExpression(path15.parent.init)) {
|
|
2872
2875
|
found = true;
|
|
2873
2876
|
const existing = new Set(
|
|
2874
|
-
|
|
2877
|
+
path15.parent.init.elements.map((element) => t4.isStringLiteral(element) ? element.value : void 0).filter(Boolean)
|
|
2875
2878
|
);
|
|
2876
2879
|
missingUnits = units.filter((unit) => !existing.has(unit));
|
|
2877
|
-
|
|
2880
|
+
path15.stop();
|
|
2878
2881
|
}
|
|
2879
2882
|
}
|
|
2880
2883
|
});
|
|
@@ -4278,6 +4281,9 @@ async function restoreConfigFiles(options) {
|
|
|
4278
4281
|
};
|
|
4279
4282
|
}
|
|
4280
4283
|
|
|
4284
|
+
// src/commands/types.ts
|
|
4285
|
+
var tailwindcssPatchCommands = ["install", "extract", "tokens", "init", "migrate", "restore", "validate", "status"];
|
|
4286
|
+
|
|
4281
4287
|
// src/commands/validate.ts
|
|
4282
4288
|
var VALIDATE_EXIT_CODES = {
|
|
4283
4289
|
OK: 0,
|
|
@@ -4336,708 +4342,12 @@ var ValidateCommandError = class extends Error {
|
|
|
4336
4342
|
}
|
|
4337
4343
|
};
|
|
4338
4344
|
|
|
4339
|
-
// src/commands/types.ts
|
|
4340
|
-
var tailwindcssPatchCommands = ["install", "extract", "tokens", "init", "migrate", "restore", "validate", "status"];
|
|
4341
|
-
|
|
4342
|
-
// src/commands/cli.ts
|
|
4343
|
-
import cac from "cac";
|
|
4344
|
-
|
|
4345
|
-
// src/commands/command-definitions.ts
|
|
4346
|
-
import process7 from "process";
|
|
4347
|
-
|
|
4348
|
-
// src/commands/token-output.ts
|
|
4349
|
-
var TOKEN_FORMATS = ["json", "lines", "grouped-json"];
|
|
4350
|
-
var DEFAULT_TOKEN_REPORT = ".tw-patch/tw-token-report.json";
|
|
4351
|
-
function formatTokenLine(entry) {
|
|
4352
|
-
return `${entry.relativeFile}:${entry.line}:${entry.column} ${entry.rawCandidate} (${entry.start}-${entry.end})`;
|
|
4353
|
-
}
|
|
4354
|
-
function formatGroupedPreview(map, limit = 3) {
|
|
4355
|
-
const files = Object.keys(map);
|
|
4356
|
-
if (!files.length) {
|
|
4357
|
-
return { preview: "", moreFiles: 0 };
|
|
4358
|
-
}
|
|
4359
|
-
const lines = files.slice(0, limit).map((file) => {
|
|
4360
|
-
const tokens = map[file] ?? [];
|
|
4361
|
-
const sample = tokens.slice(0, 3).map((token) => token.rawCandidate).join(", ");
|
|
4362
|
-
const suffix = tokens.length > 3 ? ", \u2026" : "";
|
|
4363
|
-
return `${file}: ${tokens.length} tokens (${sample}${suffix})`;
|
|
4364
|
-
});
|
|
4365
|
-
return {
|
|
4366
|
-
preview: lines.join("\n"),
|
|
4367
|
-
moreFiles: Math.max(0, files.length - limit)
|
|
4368
|
-
};
|
|
4369
|
-
}
|
|
4370
|
-
|
|
4371
|
-
// src/commands/command-definitions.ts
|
|
4372
|
-
function createCwdOptionDefinition(description = "Working directory") {
|
|
4373
|
-
return {
|
|
4374
|
-
flags: "--cwd <dir>",
|
|
4375
|
-
description,
|
|
4376
|
-
config: { default: process7.cwd() }
|
|
4377
|
-
};
|
|
4378
|
-
}
|
|
4379
|
-
function buildDefaultCommandDefinitions() {
|
|
4380
|
-
return {
|
|
4381
|
-
install: {
|
|
4382
|
-
description: "Apply Tailwind CSS runtime patches",
|
|
4383
|
-
optionDefs: [createCwdOptionDefinition()]
|
|
4384
|
-
},
|
|
4385
|
-
extract: {
|
|
4386
|
-
description: "Collect generated class names into a cache file",
|
|
4387
|
-
optionDefs: [
|
|
4388
|
-
createCwdOptionDefinition(),
|
|
4389
|
-
{ flags: "--output <file>", description: "Override output file path" },
|
|
4390
|
-
{ flags: "--format <format>", description: "Output format (json|lines)" },
|
|
4391
|
-
{ flags: "--css <file>", description: "Tailwind CSS entry CSS when using v4" },
|
|
4392
|
-
{ flags: "--no-write", description: "Skip writing to disk" }
|
|
4393
|
-
]
|
|
4394
|
-
},
|
|
4395
|
-
tokens: {
|
|
4396
|
-
description: "Extract Tailwind tokens with file/position metadata",
|
|
4397
|
-
optionDefs: [
|
|
4398
|
-
createCwdOptionDefinition(),
|
|
4399
|
-
{ flags: "--output <file>", description: "Override output file path", config: { default: DEFAULT_TOKEN_REPORT } },
|
|
4400
|
-
{
|
|
4401
|
-
flags: "--format <format>",
|
|
4402
|
-
description: "Output format (json|lines|grouped-json)",
|
|
4403
|
-
config: { default: "json" }
|
|
4404
|
-
},
|
|
4405
|
-
{
|
|
4406
|
-
flags: "--group-key <key>",
|
|
4407
|
-
description: "Grouping key for grouped-json output (relative|absolute)",
|
|
4408
|
-
config: { default: "relative" }
|
|
4409
|
-
},
|
|
4410
|
-
{ flags: "--no-write", description: "Skip writing to disk" }
|
|
4411
|
-
]
|
|
4412
|
-
},
|
|
4413
|
-
init: {
|
|
4414
|
-
description: "Generate a tailwindcss-patch config file",
|
|
4415
|
-
optionDefs: [createCwdOptionDefinition()]
|
|
4416
|
-
},
|
|
4417
|
-
migrate: {
|
|
4418
|
-
description: "Migrate deprecated config fields to modern options",
|
|
4419
|
-
optionDefs: [
|
|
4420
|
-
createCwdOptionDefinition(),
|
|
4421
|
-
{ flags: "--config <file>", description: "Migrate a specific config file path" },
|
|
4422
|
-
{ flags: "--workspace", description: "Scan workspace recursively for config files" },
|
|
4423
|
-
{ flags: "--max-depth <n>", description: "Maximum recursion depth for --workspace", config: { default: 6 } },
|
|
4424
|
-
{ flags: "--include <glob>", description: "Only migrate files that match this glob (repeatable)" },
|
|
4425
|
-
{ flags: "--exclude <glob>", description: "Skip files that match this glob (repeatable)" },
|
|
4426
|
-
{ flags: "--report-file <file>", description: "Write migration report JSON to a file" },
|
|
4427
|
-
{ flags: "--backup-dir <dir>", description: "Write pre-migration backups into this directory" },
|
|
4428
|
-
{ flags: "--check", description: "Exit with an error when migration changes are required" },
|
|
4429
|
-
{ flags: "--json", description: "Print the migration report as JSON" },
|
|
4430
|
-
{ flags: "--dry-run", description: "Preview changes without writing files" }
|
|
4431
|
-
]
|
|
4432
|
-
},
|
|
4433
|
-
restore: {
|
|
4434
|
-
description: "Restore config files from a previous migration report backup snapshot",
|
|
4435
|
-
optionDefs: [
|
|
4436
|
-
createCwdOptionDefinition(),
|
|
4437
|
-
{ flags: "--report-file <file>", description: "Migration report file generated by migrate" },
|
|
4438
|
-
{ flags: "--dry-run", description: "Preview restore targets without writing files" },
|
|
4439
|
-
{ flags: "--strict", description: "Fail when any backup file is missing" },
|
|
4440
|
-
{ flags: "--json", description: "Print the restore result as JSON" }
|
|
4441
|
-
]
|
|
4442
|
-
},
|
|
4443
|
-
validate: {
|
|
4444
|
-
description: "Validate migration report compatibility without modifying files",
|
|
4445
|
-
optionDefs: [
|
|
4446
|
-
createCwdOptionDefinition(),
|
|
4447
|
-
{ flags: "--report-file <file>", description: "Migration report file to validate" },
|
|
4448
|
-
{ flags: "--strict", description: "Fail when any backup file is missing" },
|
|
4449
|
-
{ flags: "--json", description: "Print validation result as JSON" }
|
|
4450
|
-
]
|
|
4451
|
-
},
|
|
4452
|
-
status: {
|
|
4453
|
-
description: "Check which Tailwind patches are applied",
|
|
4454
|
-
optionDefs: [
|
|
4455
|
-
createCwdOptionDefinition(),
|
|
4456
|
-
{ flags: "--json", description: "Print a JSON report of patch status" }
|
|
4457
|
-
]
|
|
4458
|
-
}
|
|
4459
|
-
};
|
|
4460
|
-
}
|
|
4461
|
-
|
|
4462
|
-
// src/commands/command-metadata.ts
|
|
4463
|
-
function addPrefixIfMissing(value, prefix) {
|
|
4464
|
-
if (!prefix || value.startsWith(prefix)) {
|
|
4465
|
-
return value;
|
|
4466
|
-
}
|
|
4467
|
-
return `${prefix}${value}`;
|
|
4468
|
-
}
|
|
4469
|
-
function resolveCommandNames(command, mountOptions, prefix) {
|
|
4470
|
-
const override = mountOptions.commandOptions?.[command];
|
|
4471
|
-
const baseName = override?.name ?? command;
|
|
4472
|
-
const name = addPrefixIfMissing(baseName, prefix);
|
|
4473
|
-
const aliases = (override?.aliases ?? []).map((alias) => addPrefixIfMissing(alias, prefix));
|
|
4474
|
-
return { name, aliases };
|
|
4475
|
-
}
|
|
4476
|
-
function resolveOptionDefinitions(defaults, override) {
|
|
4477
|
-
if (!override) {
|
|
4478
|
-
return defaults;
|
|
4479
|
-
}
|
|
4480
|
-
const appendDefaults = override.appendDefaultOptions ?? true;
|
|
4481
|
-
const customDefs = override.optionDefs ?? [];
|
|
4482
|
-
if (!appendDefaults) {
|
|
4483
|
-
return customDefs;
|
|
4484
|
-
}
|
|
4485
|
-
if (customDefs.length === 0) {
|
|
4486
|
-
return defaults;
|
|
4487
|
-
}
|
|
4488
|
-
return [...defaults, ...customDefs];
|
|
4489
|
-
}
|
|
4490
|
-
function resolveCommandMetadata(command, mountOptions, prefix, defaults) {
|
|
4491
|
-
const names = resolveCommandNames(command, mountOptions, prefix);
|
|
4492
|
-
const definition = defaults[command];
|
|
4493
|
-
const override = mountOptions.commandOptions?.[command];
|
|
4494
|
-
const description = override?.description ?? definition.description;
|
|
4495
|
-
const optionDefs = resolveOptionDefinitions(definition.optionDefs, override);
|
|
4496
|
-
return { ...names, description, optionDefs };
|
|
4497
|
-
}
|
|
4498
|
-
function applyCommandOptions(command, optionDefs) {
|
|
4499
|
-
for (const option of optionDefs) {
|
|
4500
|
-
command.option(option.flags, option.description ?? "", option.config);
|
|
4501
|
-
}
|
|
4502
|
-
}
|
|
4503
|
-
|
|
4504
|
-
// src/commands/command-context.ts
|
|
4505
|
-
import process8 from "process";
|
|
4506
|
-
import path15 from "pathe";
|
|
4507
|
-
function resolveCommandCwd(rawCwd) {
|
|
4508
|
-
if (!rawCwd) {
|
|
4509
|
-
return process8.cwd();
|
|
4510
|
-
}
|
|
4511
|
-
return path15.resolve(rawCwd);
|
|
4512
|
-
}
|
|
4513
|
-
function createMemoizedPromiseRunner(factory) {
|
|
4514
|
-
let promise;
|
|
4515
|
-
return () => {
|
|
4516
|
-
if (!promise) {
|
|
4517
|
-
promise = factory();
|
|
4518
|
-
}
|
|
4519
|
-
return promise;
|
|
4520
|
-
};
|
|
4521
|
-
}
|
|
4522
|
-
function createTailwindcssPatchCommandContext(cli, command, commandName, args, cwd) {
|
|
4523
|
-
const loadCachedConfig = createMemoizedPromiseRunner(
|
|
4524
|
-
() => loadWorkspaceConfigModule().then((mod) => mod.getConfig(cwd))
|
|
4525
|
-
);
|
|
4526
|
-
const loadCachedPatchOptions = createMemoizedPromiseRunner(
|
|
4527
|
-
() => loadPatchOptionsForWorkspace(cwd)
|
|
4528
|
-
);
|
|
4529
|
-
const createCachedPatcher = createMemoizedPromiseRunner(async () => {
|
|
4530
|
-
const patchOptions = await loadCachedPatchOptions();
|
|
4531
|
-
return new TailwindcssPatcher(patchOptions);
|
|
4532
|
-
});
|
|
4533
|
-
const loadPatchOptionsForContext = (overrides) => {
|
|
4534
|
-
if (overrides) {
|
|
4535
|
-
return loadPatchOptionsForWorkspace(cwd, overrides);
|
|
4536
|
-
}
|
|
4537
|
-
return loadCachedPatchOptions();
|
|
4538
|
-
};
|
|
4539
|
-
const createPatcherForContext = async (overrides) => {
|
|
4540
|
-
if (overrides) {
|
|
4541
|
-
const patchOptions = await loadPatchOptionsForWorkspace(cwd, overrides);
|
|
4542
|
-
return new TailwindcssPatcher(patchOptions);
|
|
4543
|
-
}
|
|
4544
|
-
return createCachedPatcher();
|
|
4545
|
-
};
|
|
4546
|
-
return {
|
|
4547
|
-
cli,
|
|
4548
|
-
command,
|
|
4549
|
-
commandName,
|
|
4550
|
-
args,
|
|
4551
|
-
cwd,
|
|
4552
|
-
logger: logger_default,
|
|
4553
|
-
loadConfig: loadCachedConfig,
|
|
4554
|
-
loadPatchOptions: loadPatchOptionsForContext,
|
|
4555
|
-
createPatcher: createPatcherForContext
|
|
4556
|
-
};
|
|
4557
|
-
}
|
|
4558
|
-
|
|
4559
|
-
// src/commands/command-runtime.ts
|
|
4560
|
-
function runWithCommandHandler(cli, command, commandName, args, handler, defaultHandler) {
|
|
4561
|
-
const cwd = resolveCommandCwd(args.cwd);
|
|
4562
|
-
const context = createTailwindcssPatchCommandContext(cli, command, commandName, args, cwd);
|
|
4563
|
-
const runDefault = createMemoizedPromiseRunner(() => defaultHandler(context));
|
|
4564
|
-
if (!handler) {
|
|
4565
|
-
return runDefault();
|
|
4566
|
-
}
|
|
4567
|
-
return handler(context, runDefault);
|
|
4568
|
-
}
|
|
4569
|
-
|
|
4570
|
-
// src/commands/basic-handlers.ts
|
|
4571
|
-
import process9 from "process";
|
|
4572
|
-
import fs15 from "fs-extra";
|
|
4573
|
-
import path16 from "pathe";
|
|
4574
|
-
var DEFAULT_CONFIG_NAME = "tailwindcss-mangle";
|
|
4575
|
-
async function installCommandDefaultHandler(_ctx) {
|
|
4576
|
-
const patcher = await _ctx.createPatcher();
|
|
4577
|
-
await patcher.patch();
|
|
4578
|
-
logger_default.success("Tailwind CSS runtime patched successfully.");
|
|
4579
|
-
}
|
|
4580
|
-
async function extractCommandDefaultHandler(ctx) {
|
|
4581
|
-
const { args } = ctx;
|
|
4582
|
-
const overrides = {};
|
|
4583
|
-
let hasOverrides = false;
|
|
4584
|
-
if (args.output || args.format) {
|
|
4585
|
-
overrides.extract = {
|
|
4586
|
-
...args.output === void 0 ? {} : { file: args.output },
|
|
4587
|
-
...args.format === void 0 ? {} : { format: args.format }
|
|
4588
|
-
};
|
|
4589
|
-
hasOverrides = true;
|
|
4590
|
-
}
|
|
4591
|
-
if (args.css) {
|
|
4592
|
-
overrides.tailwindcss = {
|
|
4593
|
-
v4: {
|
|
4594
|
-
cssEntries: [args.css]
|
|
4595
|
-
}
|
|
4596
|
-
};
|
|
4597
|
-
hasOverrides = true;
|
|
4598
|
-
}
|
|
4599
|
-
const patcher = await ctx.createPatcher(hasOverrides ? overrides : void 0);
|
|
4600
|
-
const extractOptions = args.write === void 0 ? {} : { write: args.write };
|
|
4601
|
-
const result = await patcher.extract(extractOptions);
|
|
4602
|
-
if (result.filename) {
|
|
4603
|
-
logger_default.success(`Collected ${result.classList.length} classes \u2192 ${result.filename}`);
|
|
4604
|
-
} else {
|
|
4605
|
-
logger_default.success(`Collected ${result.classList.length} classes.`);
|
|
4606
|
-
}
|
|
4607
|
-
return result;
|
|
4608
|
-
}
|
|
4609
|
-
async function tokensCommandDefaultHandler(ctx) {
|
|
4610
|
-
const { args } = ctx;
|
|
4611
|
-
const patcher = await ctx.createPatcher();
|
|
4612
|
-
const report = await patcher.collectContentTokens();
|
|
4613
|
-
const shouldWrite = args.write ?? true;
|
|
4614
|
-
let format = args.format ?? "json";
|
|
4615
|
-
if (!TOKEN_FORMATS.includes(format)) {
|
|
4616
|
-
format = "json";
|
|
4617
|
-
}
|
|
4618
|
-
const targetFile = args.output ?? DEFAULT_TOKEN_REPORT;
|
|
4619
|
-
const groupKey = args.groupKey === "absolute" ? "absolute" : "relative";
|
|
4620
|
-
const buildGrouped = () => groupTokensByFile(report, {
|
|
4621
|
-
key: groupKey,
|
|
4622
|
-
stripAbsolutePaths: groupKey !== "absolute"
|
|
4623
|
-
});
|
|
4624
|
-
const grouped = format === "grouped-json" ? buildGrouped() : null;
|
|
4625
|
-
const resolveGrouped = () => grouped ?? buildGrouped();
|
|
4626
|
-
if (shouldWrite) {
|
|
4627
|
-
const target = path16.resolve(targetFile);
|
|
4628
|
-
await fs15.ensureDir(path16.dirname(target));
|
|
4629
|
-
if (format === "json") {
|
|
4630
|
-
await fs15.writeJSON(target, report, { spaces: 2 });
|
|
4631
|
-
} else if (format === "grouped-json") {
|
|
4632
|
-
await fs15.writeJSON(target, resolveGrouped(), { spaces: 2 });
|
|
4633
|
-
} else {
|
|
4634
|
-
const lines = report.entries.map(formatTokenLine);
|
|
4635
|
-
await fs15.writeFile(target, `${lines.join("\n")}
|
|
4636
|
-
`, "utf8");
|
|
4637
|
-
}
|
|
4638
|
-
logger_default.success(`Collected ${report.entries.length} tokens (${format}) \u2192 ${target.replace(process9.cwd(), ".")}`);
|
|
4639
|
-
} else {
|
|
4640
|
-
logger_default.success(`Collected ${report.entries.length} tokens from ${report.filesScanned} files.`);
|
|
4641
|
-
if (format === "lines") {
|
|
4642
|
-
const preview = report.entries.slice(0, 5).map(formatTokenLine).join("\n");
|
|
4643
|
-
if (preview) {
|
|
4644
|
-
logger_default.log("");
|
|
4645
|
-
logger_default.info(preview);
|
|
4646
|
-
if (report.entries.length > 5) {
|
|
4647
|
-
logger_default.info(`\u2026and ${report.entries.length - 5} more.`);
|
|
4648
|
-
}
|
|
4649
|
-
}
|
|
4650
|
-
} else if (format === "grouped-json") {
|
|
4651
|
-
const map = resolveGrouped();
|
|
4652
|
-
const { preview, moreFiles } = formatGroupedPreview(map);
|
|
4653
|
-
if (preview) {
|
|
4654
|
-
logger_default.log("");
|
|
4655
|
-
logger_default.info(preview);
|
|
4656
|
-
if (moreFiles > 0) {
|
|
4657
|
-
logger_default.info(`\u2026and ${moreFiles} more files.`);
|
|
4658
|
-
}
|
|
4659
|
-
}
|
|
4660
|
-
} else {
|
|
4661
|
-
const previewEntries = report.entries.slice(0, 3);
|
|
4662
|
-
if (previewEntries.length) {
|
|
4663
|
-
logger_default.log("");
|
|
4664
|
-
logger_default.info(JSON.stringify(previewEntries, null, 2));
|
|
4665
|
-
}
|
|
4666
|
-
}
|
|
4667
|
-
}
|
|
4668
|
-
if (report.skippedFiles.length) {
|
|
4669
|
-
logger_default.warn("Skipped files:");
|
|
4670
|
-
for (const skipped of report.skippedFiles) {
|
|
4671
|
-
logger_default.warn(` \u2022 ${skipped.file} (${skipped.reason})`);
|
|
4672
|
-
}
|
|
4673
|
-
}
|
|
4674
|
-
return report;
|
|
4675
|
-
}
|
|
4676
|
-
async function initCommandDefaultHandler(ctx) {
|
|
4677
|
-
const configModule = await loadWorkspaceConfigModule();
|
|
4678
|
-
await configModule.initConfig(ctx.cwd);
|
|
4679
|
-
const configName = configModule.CONFIG_NAME || DEFAULT_CONFIG_NAME;
|
|
4680
|
-
logger_default.success(`\u2728 ${configName}.config.ts initialized!`);
|
|
4681
|
-
}
|
|
4682
|
-
|
|
4683
|
-
// src/commands/migration-args.ts
|
|
4684
|
-
function normalizePatternArgs(value) {
|
|
4685
|
-
if (!value) {
|
|
4686
|
-
return void 0;
|
|
4687
|
-
}
|
|
4688
|
-
const raw = Array.isArray(value) ? value : [value];
|
|
4689
|
-
const values = raw.flatMap((item) => item.split(",")).map((item) => item.trim()).filter(Boolean);
|
|
4690
|
-
return values.length > 0 ? values : void 0;
|
|
4691
|
-
}
|
|
4692
|
-
function parseMaxDepth(value) {
|
|
4693
|
-
if (value === void 0) {
|
|
4694
|
-
return {
|
|
4695
|
-
maxDepth: void 0,
|
|
4696
|
-
hasInvalidMaxDepth: false
|
|
4697
|
-
};
|
|
4698
|
-
}
|
|
4699
|
-
const parsed = Number(value);
|
|
4700
|
-
if (!Number.isFinite(parsed) || parsed < 0) {
|
|
4701
|
-
return {
|
|
4702
|
-
maxDepth: void 0,
|
|
4703
|
-
hasInvalidMaxDepth: true
|
|
4704
|
-
};
|
|
4705
|
-
}
|
|
4706
|
-
return {
|
|
4707
|
-
maxDepth: Math.floor(parsed),
|
|
4708
|
-
hasInvalidMaxDepth: false
|
|
4709
|
-
};
|
|
4710
|
-
}
|
|
4711
|
-
function resolveMigrateCommandArgs(args) {
|
|
4712
|
-
const include = normalizePatternArgs(args.include);
|
|
4713
|
-
const exclude = normalizePatternArgs(args.exclude);
|
|
4714
|
-
const { maxDepth, hasInvalidMaxDepth } = parseMaxDepth(args.maxDepth);
|
|
4715
|
-
const checkMode = args.check ?? false;
|
|
4716
|
-
const dryRun = args.dryRun ?? checkMode;
|
|
4717
|
-
return {
|
|
4718
|
-
include,
|
|
4719
|
-
exclude,
|
|
4720
|
-
maxDepth,
|
|
4721
|
-
checkMode,
|
|
4722
|
-
dryRun,
|
|
4723
|
-
hasInvalidMaxDepth
|
|
4724
|
-
};
|
|
4725
|
-
}
|
|
4726
|
-
function resolveRestoreCommandArgs(args) {
|
|
4727
|
-
return {
|
|
4728
|
-
reportFile: args.reportFile ?? ".tw-patch/migrate-report.json",
|
|
4729
|
-
dryRun: args.dryRun ?? false,
|
|
4730
|
-
strict: args.strict ?? false
|
|
4731
|
-
};
|
|
4732
|
-
}
|
|
4733
|
-
function resolveValidateCommandArgs(args) {
|
|
4734
|
-
return {
|
|
4735
|
-
reportFile: args.reportFile ?? ".tw-patch/migrate-report.json",
|
|
4736
|
-
strict: args.strict ?? false
|
|
4737
|
-
};
|
|
4738
|
-
}
|
|
4739
|
-
|
|
4740
|
-
// src/commands/migration-output.ts
|
|
4741
|
-
import process10 from "process";
|
|
4742
|
-
import fs16 from "fs-extra";
|
|
4743
|
-
import path17 from "pathe";
|
|
4744
|
-
function formatPathForLog(file) {
|
|
4745
|
-
return file.replace(process10.cwd(), ".");
|
|
4746
|
-
}
|
|
4747
|
-
function createMigrationCheckFailureError(changedFiles) {
|
|
4748
|
-
return new Error(`Migration check failed: ${changedFiles} file(s) still need migration.`);
|
|
4749
|
-
}
|
|
4750
|
-
async function writeMigrationReportFile(cwd, reportFile, report) {
|
|
4751
|
-
const reportPath = path17.resolve(cwd, reportFile);
|
|
4752
|
-
await fs16.ensureDir(path17.dirname(reportPath));
|
|
4753
|
-
await fs16.writeJSON(reportPath, report, { spaces: 2 });
|
|
4754
|
-
logger_default.info(`Migration report written: ${formatPathForLog(reportPath)}`);
|
|
4755
|
-
}
|
|
4756
|
-
function logMigrationReportAsJson(report) {
|
|
4757
|
-
logger_default.log(JSON.stringify(report, null, 2));
|
|
4758
|
-
}
|
|
4759
|
-
function logNoMigrationConfigFilesWarning() {
|
|
4760
|
-
logger_default.warn("No config files found for migration.");
|
|
4761
|
-
}
|
|
4762
|
-
function logMigrationEntries(report, dryRun) {
|
|
4763
|
-
for (const entry of report.entries) {
|
|
4764
|
-
const fileLabel = formatPathForLog(entry.file);
|
|
4765
|
-
if (!entry.changed) {
|
|
4766
|
-
logger_default.info(`No changes: ${fileLabel}`);
|
|
4767
|
-
continue;
|
|
4768
|
-
}
|
|
4769
|
-
if (dryRun) {
|
|
4770
|
-
logger_default.info(`[dry-run] ${fileLabel}`);
|
|
4771
|
-
} else {
|
|
4772
|
-
logger_default.success(`Migrated: ${fileLabel}`);
|
|
4773
|
-
}
|
|
4774
|
-
for (const change of entry.changes) {
|
|
4775
|
-
logger_default.info(` - ${change}`);
|
|
4776
|
-
}
|
|
4777
|
-
if (entry.backupFile) {
|
|
4778
|
-
logger_default.info(` - backup: ${formatPathForLog(entry.backupFile)}`);
|
|
4779
|
-
}
|
|
4780
|
-
}
|
|
4781
|
-
}
|
|
4782
|
-
function logMigrationSummary(report) {
|
|
4783
|
-
logger_default.info(
|
|
4784
|
-
`Migration summary: scanned=${report.scannedFiles}, changed=${report.changedFiles}, written=${report.writtenFiles}, backups=${report.backupsWritten}, missing=${report.missingFiles}, unchanged=${report.unchangedFiles}`
|
|
4785
|
-
);
|
|
4786
|
-
}
|
|
4787
|
-
function logRestoreResultAsJson(result) {
|
|
4788
|
-
logger_default.log(JSON.stringify(result, null, 2));
|
|
4789
|
-
}
|
|
4790
|
-
function logRestoreSummary(result) {
|
|
4791
|
-
logger_default.info(
|
|
4792
|
-
`Restore summary: scanned=${result.scannedEntries}, restorable=${result.restorableEntries}, restored=${result.restoredFiles}, missingBackups=${result.missingBackups}, skipped=${result.skippedEntries}`
|
|
4793
|
-
);
|
|
4794
|
-
if (result.restored.length > 0) {
|
|
4795
|
-
const preview = result.restored.slice(0, 5);
|
|
4796
|
-
for (const file of preview) {
|
|
4797
|
-
logger_default.info(` - ${formatPathForLog(file)}`);
|
|
4798
|
-
}
|
|
4799
|
-
if (result.restored.length > preview.length) {
|
|
4800
|
-
logger_default.info(` ...and ${result.restored.length - preview.length} more`);
|
|
4801
|
-
}
|
|
4802
|
-
}
|
|
4803
|
-
}
|
|
4804
|
-
function logValidateSuccessAsJson(result) {
|
|
4805
|
-
const payload = {
|
|
4806
|
-
ok: true,
|
|
4807
|
-
...result
|
|
4808
|
-
};
|
|
4809
|
-
logger_default.log(JSON.stringify(payload, null, 2));
|
|
4810
|
-
}
|
|
4811
|
-
function logValidateSuccessSummary(result) {
|
|
4812
|
-
logger_default.success(
|
|
4813
|
-
`Migration report validated: scanned=${result.scannedEntries}, restorable=${result.restorableEntries}, missingBackups=${result.missingBackups}, skipped=${result.skippedEntries}`
|
|
4814
|
-
);
|
|
4815
|
-
if (result.reportKind || result.reportSchemaVersion !== void 0) {
|
|
4816
|
-
const kind = result.reportKind ?? "unknown";
|
|
4817
|
-
const schema = result.reportSchemaVersion === void 0 ? "unknown" : String(result.reportSchemaVersion);
|
|
4818
|
-
logger_default.info(` metadata: kind=${kind}, schema=${schema}`);
|
|
4819
|
-
}
|
|
4820
|
-
}
|
|
4821
|
-
function logValidateFailureAsJson(summary) {
|
|
4822
|
-
const payload = {
|
|
4823
|
-
ok: false,
|
|
4824
|
-
reason: summary.reason,
|
|
4825
|
-
exitCode: summary.exitCode,
|
|
4826
|
-
message: summary.message
|
|
4827
|
-
};
|
|
4828
|
-
logger_default.log(JSON.stringify(payload, null, 2));
|
|
4829
|
-
}
|
|
4830
|
-
function logValidateFailureSummary(summary) {
|
|
4831
|
-
logger_default.error(`Validation failed [${summary.reason}] (exit ${summary.exitCode}): ${summary.message}`);
|
|
4832
|
-
}
|
|
4833
|
-
|
|
4834
|
-
// src/commands/migrate-handler.ts
|
|
4835
|
-
async function migrateCommandDefaultHandler(ctx) {
|
|
4836
|
-
const { args } = ctx;
|
|
4837
|
-
const {
|
|
4838
|
-
include,
|
|
4839
|
-
exclude,
|
|
4840
|
-
maxDepth,
|
|
4841
|
-
checkMode,
|
|
4842
|
-
dryRun,
|
|
4843
|
-
hasInvalidMaxDepth
|
|
4844
|
-
} = resolveMigrateCommandArgs(args);
|
|
4845
|
-
if (args.workspace && hasInvalidMaxDepth) {
|
|
4846
|
-
logger_default.warn(`Invalid --max-depth value "${String(args.maxDepth)}", fallback to default depth.`);
|
|
4847
|
-
}
|
|
4848
|
-
const report = await migrateConfigFiles({
|
|
4849
|
-
cwd: ctx.cwd,
|
|
4850
|
-
dryRun,
|
|
4851
|
-
...args.config ? { files: [args.config] } : {},
|
|
4852
|
-
...args.workspace ? { workspace: true } : {},
|
|
4853
|
-
...args.workspace && maxDepth !== void 0 ? { maxDepth } : {},
|
|
4854
|
-
...args.backupDir ? { backupDir: args.backupDir } : {},
|
|
4855
|
-
...include ? { include } : {},
|
|
4856
|
-
...exclude ? { exclude } : {}
|
|
4857
|
-
});
|
|
4858
|
-
if (args.reportFile) {
|
|
4859
|
-
await writeMigrationReportFile(ctx.cwd, args.reportFile, report);
|
|
4860
|
-
}
|
|
4861
|
-
if (args.json) {
|
|
4862
|
-
logMigrationReportAsJson(report);
|
|
4863
|
-
if (checkMode && report.changedFiles > 0) {
|
|
4864
|
-
throw createMigrationCheckFailureError(report.changedFiles);
|
|
4865
|
-
}
|
|
4866
|
-
if (report.scannedFiles === 0) {
|
|
4867
|
-
logNoMigrationConfigFilesWarning();
|
|
4868
|
-
}
|
|
4869
|
-
return report;
|
|
4870
|
-
}
|
|
4871
|
-
if (report.scannedFiles === 0) {
|
|
4872
|
-
logNoMigrationConfigFilesWarning();
|
|
4873
|
-
return report;
|
|
4874
|
-
}
|
|
4875
|
-
logMigrationEntries(report, dryRun);
|
|
4876
|
-
logMigrationSummary(report);
|
|
4877
|
-
if (checkMode && report.changedFiles > 0) {
|
|
4878
|
-
throw createMigrationCheckFailureError(report.changedFiles);
|
|
4879
|
-
}
|
|
4880
|
-
return report;
|
|
4881
|
-
}
|
|
4882
|
-
|
|
4883
|
-
// src/commands/restore-handler.ts
|
|
4884
|
-
async function restoreCommandDefaultHandler(ctx) {
|
|
4885
|
-
const { args } = ctx;
|
|
4886
|
-
const restoreArgs = resolveRestoreCommandArgs(args);
|
|
4887
|
-
const result = await restoreConfigFiles({
|
|
4888
|
-
cwd: ctx.cwd,
|
|
4889
|
-
reportFile: restoreArgs.reportFile,
|
|
4890
|
-
dryRun: restoreArgs.dryRun,
|
|
4891
|
-
strict: restoreArgs.strict
|
|
4892
|
-
});
|
|
4893
|
-
if (args.json) {
|
|
4894
|
-
logRestoreResultAsJson(result);
|
|
4895
|
-
return result;
|
|
4896
|
-
}
|
|
4897
|
-
logRestoreSummary(result);
|
|
4898
|
-
return result;
|
|
4899
|
-
}
|
|
4900
|
-
|
|
4901
|
-
// src/commands/status-output.ts
|
|
4902
|
-
function formatFilesHint(entry) {
|
|
4903
|
-
if (!entry.files.length) {
|
|
4904
|
-
return "";
|
|
4905
|
-
}
|
|
4906
|
-
return ` (${entry.files.join(", ")})`;
|
|
4907
|
-
}
|
|
4908
|
-
function formatPackageLabel(report) {
|
|
4909
|
-
return `${report.package.name ?? "tailwindcss"}@${report.package.version ?? "unknown"}`;
|
|
4910
|
-
}
|
|
4911
|
-
function partitionStatusEntries(report) {
|
|
4912
|
-
return {
|
|
4913
|
-
applied: report.entries.filter((entry) => entry.status === "applied"),
|
|
4914
|
-
pending: report.entries.filter((entry) => entry.status === "not-applied"),
|
|
4915
|
-
skipped: report.entries.filter((entry) => entry.status === "skipped" || entry.status === "unsupported")
|
|
4916
|
-
};
|
|
4917
|
-
}
|
|
4918
|
-
function logStatusReportAsJson(report) {
|
|
4919
|
-
logger_default.log(JSON.stringify(report, null, 2));
|
|
4920
|
-
}
|
|
4921
|
-
function logStatusReportSummary(report) {
|
|
4922
|
-
const {
|
|
4923
|
-
applied,
|
|
4924
|
-
pending,
|
|
4925
|
-
skipped
|
|
4926
|
-
} = partitionStatusEntries(report);
|
|
4927
|
-
logger_default.info(`Patch status for ${formatPackageLabel(report)} (v${report.majorVersion})`);
|
|
4928
|
-
if (applied.length) {
|
|
4929
|
-
logger_default.success("Applied:");
|
|
4930
|
-
applied.forEach((entry) => logger_default.success(` \u2022 ${entry.name}${formatFilesHint(entry)}`));
|
|
4931
|
-
}
|
|
4932
|
-
if (pending.length) {
|
|
4933
|
-
logger_default.warn("Needs attention:");
|
|
4934
|
-
pending.forEach((entry) => {
|
|
4935
|
-
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
4936
|
-
logger_default.warn(` \u2022 ${entry.name}${formatFilesHint(entry)}${details}`);
|
|
4937
|
-
});
|
|
4938
|
-
} else {
|
|
4939
|
-
logger_default.success("All applicable patches are applied.");
|
|
4940
|
-
}
|
|
4941
|
-
if (skipped.length) {
|
|
4942
|
-
logger_default.info("Skipped:");
|
|
4943
|
-
skipped.forEach((entry) => {
|
|
4944
|
-
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
4945
|
-
logger_default.info(` \u2022 ${entry.name}${details}`);
|
|
4946
|
-
});
|
|
4947
|
-
}
|
|
4948
|
-
}
|
|
4949
|
-
|
|
4950
|
-
// src/commands/status-handler.ts
|
|
4951
|
-
async function statusCommandDefaultHandler(ctx) {
|
|
4952
|
-
const patcher = await ctx.createPatcher();
|
|
4953
|
-
const report = await patcher.getPatchStatus();
|
|
4954
|
-
if (ctx.args.json) {
|
|
4955
|
-
logStatusReportAsJson(report);
|
|
4956
|
-
return report;
|
|
4957
|
-
}
|
|
4958
|
-
logStatusReportSummary(report);
|
|
4959
|
-
return report;
|
|
4960
|
-
}
|
|
4961
|
-
|
|
4962
|
-
// src/commands/validate-handler.ts
|
|
4963
|
-
async function validateCommandDefaultHandler(ctx) {
|
|
4964
|
-
const { args } = ctx;
|
|
4965
|
-
const validateArgs = resolveValidateCommandArgs(args);
|
|
4966
|
-
try {
|
|
4967
|
-
const result = await restoreConfigFiles({
|
|
4968
|
-
cwd: ctx.cwd,
|
|
4969
|
-
reportFile: validateArgs.reportFile,
|
|
4970
|
-
dryRun: true,
|
|
4971
|
-
strict: validateArgs.strict
|
|
4972
|
-
});
|
|
4973
|
-
if (args.json) {
|
|
4974
|
-
logValidateSuccessAsJson(result);
|
|
4975
|
-
return result;
|
|
4976
|
-
}
|
|
4977
|
-
logValidateSuccessSummary(result);
|
|
4978
|
-
return result;
|
|
4979
|
-
} catch (error) {
|
|
4980
|
-
const summary = classifyValidateError(error);
|
|
4981
|
-
if (args.json) {
|
|
4982
|
-
logValidateFailureAsJson(summary);
|
|
4983
|
-
} else {
|
|
4984
|
-
logValidateFailureSummary(summary);
|
|
4985
|
-
}
|
|
4986
|
-
throw new ValidateCommandError(summary, { cause: error });
|
|
4987
|
-
}
|
|
4988
|
-
}
|
|
4989
|
-
|
|
4990
|
-
// src/commands/default-handler-map.ts
|
|
4991
|
-
var defaultCommandHandlers = {
|
|
4992
|
-
install: installCommandDefaultHandler,
|
|
4993
|
-
extract: extractCommandDefaultHandler,
|
|
4994
|
-
tokens: tokensCommandDefaultHandler,
|
|
4995
|
-
init: initCommandDefaultHandler,
|
|
4996
|
-
migrate: migrateCommandDefaultHandler,
|
|
4997
|
-
restore: restoreCommandDefaultHandler,
|
|
4998
|
-
validate: validateCommandDefaultHandler,
|
|
4999
|
-
status: statusCommandDefaultHandler
|
|
5000
|
-
};
|
|
5001
|
-
|
|
5002
|
-
// src/commands/command-registrar.ts
|
|
5003
|
-
function registerTailwindcssPatchCommand(cli, commandName, options, prefix, defaultDefinitions) {
|
|
5004
|
-
const metadata = resolveCommandMetadata(commandName, options, prefix, defaultDefinitions);
|
|
5005
|
-
const command = cli.command(metadata.name, metadata.description);
|
|
5006
|
-
applyCommandOptions(command, metadata.optionDefs);
|
|
5007
|
-
command.action(async (args) => {
|
|
5008
|
-
const defaultHandler = defaultCommandHandlers[commandName];
|
|
5009
|
-
return runWithCommandHandler(
|
|
5010
|
-
cli,
|
|
5011
|
-
command,
|
|
5012
|
-
commandName,
|
|
5013
|
-
args,
|
|
5014
|
-
options.commandHandlers?.[commandName],
|
|
5015
|
-
defaultHandler
|
|
5016
|
-
);
|
|
5017
|
-
});
|
|
5018
|
-
metadata.aliases.forEach((alias) => command.alias(alias));
|
|
5019
|
-
}
|
|
5020
|
-
|
|
5021
|
-
// src/commands/cli.ts
|
|
5022
|
-
function mountTailwindcssPatchCommands(cli, options = {}) {
|
|
5023
|
-
const prefix = options.commandPrefix ?? "";
|
|
5024
|
-
const selectedCommands = options.commands ?? tailwindcssPatchCommands;
|
|
5025
|
-
const defaultDefinitions = buildDefaultCommandDefinitions();
|
|
5026
|
-
for (const name of selectedCommands) {
|
|
5027
|
-
registerTailwindcssPatchCommand(cli, name, options, prefix, defaultDefinitions);
|
|
5028
|
-
}
|
|
5029
|
-
return cli;
|
|
5030
|
-
}
|
|
5031
|
-
function createTailwindcssPatchCli(options = {}) {
|
|
5032
|
-
const cli = cac(options.name ?? "tw-patch");
|
|
5033
|
-
mountTailwindcssPatchCommands(cli, options.mountOptions);
|
|
5034
|
-
return cli;
|
|
5035
|
-
}
|
|
5036
|
-
|
|
5037
4345
|
export {
|
|
5038
4346
|
logger_default,
|
|
5039
4347
|
CacheStore,
|
|
5040
4348
|
normalizeOptions,
|
|
4349
|
+
loadWorkspaceConfigModule,
|
|
4350
|
+
loadPatchOptionsForWorkspace,
|
|
5041
4351
|
extractRawCandidatesWithPositions,
|
|
5042
4352
|
extractRawCandidates,
|
|
5043
4353
|
extractValidCandidates,
|
|
@@ -5053,10 +4363,9 @@ export {
|
|
|
5053
4363
|
MIGRATION_REPORT_SCHEMA_VERSION,
|
|
5054
4364
|
migrateConfigFiles,
|
|
5055
4365
|
restoreConfigFiles,
|
|
4366
|
+
tailwindcssPatchCommands,
|
|
5056
4367
|
VALIDATE_EXIT_CODES,
|
|
5057
4368
|
VALIDATE_FAILURE_REASONS,
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
mountTailwindcssPatchCommands,
|
|
5061
|
-
createTailwindcssPatchCli
|
|
4369
|
+
classifyValidateError,
|
|
4370
|
+
ValidateCommandError
|
|
5062
4371
|
};
|