tailwindcss-patch 9.4.0 → 9.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { a as ValidateFailureSummary, c as TailwindcssPatchCliMountOptions, d as TailwindcssPatchCommandContext, f as TailwindcssPatchCommandHandler, g as tailwindcssPatchCommands, h as TailwindcssPatchCommandOptions, i as ValidateFailureReason, l as TailwindcssPatchCliOptions, m as TailwindcssPatchCommandOptionDefinition, n as VALIDATE_FAILURE_REASONS, o as ValidateJsonFailurePayload, p as TailwindcssPatchCommandHandlerMap, r as ValidateCommandError, s as ValidateJsonSuccessPayload, t as VALIDATE_EXIT_CODES, u as TailwindcssPatchCommand } from "../validate-DFiRmBtJ.js";
1
+ import { a as ValidateFailureSummary, c as TailwindcssPatchCliMountOptions, d as TailwindcssPatchCommandContext, f as TailwindcssPatchCommandHandler, g as tailwindcssPatchCommands, h as TailwindcssPatchCommandOptions, i as ValidateFailureReason, l as TailwindcssPatchCliOptions, m as TailwindcssPatchCommandOptionDefinition, n as VALIDATE_FAILURE_REASONS, o as ValidateJsonFailurePayload, p as TailwindcssPatchCommandHandlerMap, r as ValidateCommandError, s as ValidateJsonSuccessPayload, t as VALIDATE_EXIT_CODES, u as TailwindcssPatchCommand } from "../validate-CaJv2g5K.js";
2
2
  import { CAC } from "cac";
3
3
 
4
4
  //#region src/commands/cli.d.ts
@@ -1,666 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_chunk = require("../chunk-8l464Juk.js");
3
- const require_validate = require("../validate-D9fDrE9I.js");
4
- let node_process = require("node:process");
5
- node_process = require_chunk.__toESM(node_process);
6
- let fs_extra = require("fs-extra");
7
- fs_extra = require_chunk.__toESM(fs_extra);
8
- let pathe = require("pathe");
9
- pathe = require_chunk.__toESM(pathe);
10
- let cac = require("cac");
11
- cac = require_chunk.__toESM(cac);
12
- //#region src/commands/token-output.ts
13
- const TOKEN_FORMATS = [
14
- "json",
15
- "lines",
16
- "grouped-json"
17
- ];
18
- const DEFAULT_TOKEN_REPORT = ".tw-patch/tw-token-report.json";
19
- function formatTokenLine(entry) {
20
- return `${entry.relativeFile}:${entry.line}:${entry.column} ${entry.rawCandidate} (${entry.start}-${entry.end})`;
21
- }
22
- function formatGroupedPreview(map, limit = 3) {
23
- const files = Object.keys(map);
24
- if (!files.length) return {
25
- preview: "",
26
- moreFiles: 0
27
- };
28
- return {
29
- preview: files.slice(0, limit).map((file) => {
30
- const tokens = map[file] ?? [];
31
- const sample = tokens.slice(0, 3).map((token) => token.rawCandidate).join(", ");
32
- const suffix = tokens.length > 3 ? ", …" : "";
33
- return `${file}: ${tokens.length} tokens (${sample}${suffix})`;
34
- }).join("\n"),
35
- moreFiles: Math.max(0, files.length - limit)
36
- };
37
- }
38
- //#endregion
39
- //#region src/commands/command-definitions.ts
40
- function createCwdOptionDefinition(description = "Working directory") {
41
- return {
42
- flags: "--cwd <dir>",
43
- description,
44
- config: { default: node_process.default.cwd() }
45
- };
46
- }
47
- function buildDefaultCommandDefinitions() {
48
- return {
49
- install: {
50
- description: "Apply Tailwind CSS runtime patches",
51
- optionDefs: [createCwdOptionDefinition()]
52
- },
53
- extract: {
54
- description: "Collect generated class names into a cache file",
55
- optionDefs: [
56
- createCwdOptionDefinition(),
57
- {
58
- flags: "--output <file>",
59
- description: "Override output file path"
60
- },
61
- {
62
- flags: "--format <format>",
63
- description: "Output format (json|lines)"
64
- },
65
- {
66
- flags: "--css <file>",
67
- description: "Tailwind CSS entry CSS when using v4"
68
- },
69
- {
70
- flags: "--no-write",
71
- description: "Skip writing to disk"
72
- }
73
- ]
74
- },
75
- tokens: {
76
- description: "Extract Tailwind tokens with file/position metadata",
77
- optionDefs: [
78
- createCwdOptionDefinition(),
79
- {
80
- flags: "--output <file>",
81
- description: "Override output file path",
82
- config: { default: DEFAULT_TOKEN_REPORT }
83
- },
84
- {
85
- flags: "--format <format>",
86
- description: "Output format (json|lines|grouped-json)",
87
- config: { default: "json" }
88
- },
89
- {
90
- flags: "--group-key <key>",
91
- description: "Grouping key for grouped-json output (relative|absolute)",
92
- config: { default: "relative" }
93
- },
94
- {
95
- flags: "--no-write",
96
- description: "Skip writing to disk"
97
- }
98
- ]
99
- },
100
- init: {
101
- description: "Generate a tailwindcss-patch config file",
102
- optionDefs: [createCwdOptionDefinition()]
103
- },
104
- migrate: {
105
- description: "Migrate deprecated config fields to modern options",
106
- optionDefs: [
107
- createCwdOptionDefinition(),
108
- {
109
- flags: "--config <file>",
110
- description: "Migrate a specific config file path"
111
- },
112
- {
113
- flags: "--workspace",
114
- description: "Scan workspace recursively for config files"
115
- },
116
- {
117
- flags: "--max-depth <n>",
118
- description: "Maximum recursion depth for --workspace",
119
- config: { default: 6 }
120
- },
121
- {
122
- flags: "--include <glob>",
123
- description: "Only migrate files that match this glob (repeatable)"
124
- },
125
- {
126
- flags: "--exclude <glob>",
127
- description: "Skip files that match this glob (repeatable)"
128
- },
129
- {
130
- flags: "--report-file <file>",
131
- description: "Write migration report JSON to a file"
132
- },
133
- {
134
- flags: "--backup-dir <dir>",
135
- description: "Write pre-migration backups into this directory"
136
- },
137
- {
138
- flags: "--check",
139
- description: "Exit with an error when migration changes are required"
140
- },
141
- {
142
- flags: "--json",
143
- description: "Print the migration report as JSON"
144
- },
145
- {
146
- flags: "--dry-run",
147
- description: "Preview changes without writing files"
148
- }
149
- ]
150
- },
151
- restore: {
152
- description: "Restore config files from a previous migration report backup snapshot",
153
- optionDefs: [
154
- createCwdOptionDefinition(),
155
- {
156
- flags: "--report-file <file>",
157
- description: "Migration report file generated by migrate"
158
- },
159
- {
160
- flags: "--dry-run",
161
- description: "Preview restore targets without writing files"
162
- },
163
- {
164
- flags: "--strict",
165
- description: "Fail when any backup file is missing"
166
- },
167
- {
168
- flags: "--json",
169
- description: "Print the restore result as JSON"
170
- }
171
- ]
172
- },
173
- validate: {
174
- description: "Validate migration report compatibility without modifying files",
175
- optionDefs: [
176
- createCwdOptionDefinition(),
177
- {
178
- flags: "--report-file <file>",
179
- description: "Migration report file to validate"
180
- },
181
- {
182
- flags: "--strict",
183
- description: "Fail when any backup file is missing"
184
- },
185
- {
186
- flags: "--json",
187
- description: "Print validation result as JSON"
188
- }
189
- ]
190
- },
191
- status: {
192
- description: "Check which Tailwind patches are applied",
193
- optionDefs: [createCwdOptionDefinition(), {
194
- flags: "--json",
195
- description: "Print a JSON report of patch status"
196
- }]
197
- }
198
- };
199
- }
200
- //#endregion
201
- //#region src/commands/command-metadata.ts
202
- function addPrefixIfMissing(value, prefix) {
203
- if (!prefix || value.startsWith(prefix)) return value;
204
- return `${prefix}${value}`;
205
- }
206
- function resolveCommandNames(command, mountOptions, prefix) {
207
- const override = mountOptions.commandOptions?.[command];
208
- return {
209
- name: addPrefixIfMissing(override?.name ?? command, prefix),
210
- aliases: (override?.aliases ?? []).map((alias) => addPrefixIfMissing(alias, prefix))
211
- };
212
- }
213
- function resolveOptionDefinitions(defaults, override) {
214
- if (!override) return defaults;
215
- const appendDefaults = override.appendDefaultOptions ?? true;
216
- const customDefs = override.optionDefs ?? [];
217
- if (!appendDefaults) return customDefs;
218
- if (customDefs.length === 0) return defaults;
219
- return [...defaults, ...customDefs];
220
- }
221
- function resolveCommandMetadata(command, mountOptions, prefix, defaults) {
222
- const names = resolveCommandNames(command, mountOptions, prefix);
223
- const definition = defaults[command];
224
- const override = mountOptions.commandOptions?.[command];
225
- const description = override?.description ?? definition.description;
226
- const optionDefs = resolveOptionDefinitions(definition.optionDefs, override);
227
- return {
228
- ...names,
229
- description,
230
- optionDefs
231
- };
232
- }
233
- function applyCommandOptions(command, optionDefs) {
234
- for (const option of optionDefs) command.option(option.flags, option.description ?? "", option.config);
235
- }
236
- //#endregion
237
- //#region src/commands/command-context.ts
238
- function resolveCommandCwd(rawCwd) {
239
- if (!rawCwd) return node_process.default.cwd();
240
- return pathe.default.resolve(rawCwd);
241
- }
242
- function createMemoizedPromiseRunner(factory) {
243
- let promise;
244
- return () => {
245
- if (!promise) promise = factory();
246
- return promise;
247
- };
248
- }
249
- function createTailwindcssPatchCommandContext(cli, command, commandName, args, cwd) {
250
- const loadCachedConfig = createMemoizedPromiseRunner(() => require_validate.loadWorkspaceConfigModule().then((mod) => mod.getConfig(cwd)));
251
- const loadCachedPatchOptions = createMemoizedPromiseRunner(() => require_validate.loadPatchOptionsForWorkspace(cwd));
252
- const createCachedPatcher = createMemoizedPromiseRunner(async () => {
253
- return new require_validate.TailwindcssPatcher(await loadCachedPatchOptions());
254
- });
255
- const loadPatchOptionsForContext = (overrides) => {
256
- if (overrides) return require_validate.loadPatchOptionsForWorkspace(cwd, overrides);
257
- return loadCachedPatchOptions();
258
- };
259
- const createPatcherForContext = async (overrides) => {
260
- if (overrides) return new require_validate.TailwindcssPatcher(await require_validate.loadPatchOptionsForWorkspace(cwd, overrides));
261
- return createCachedPatcher();
262
- };
263
- return {
264
- cli,
265
- command,
266
- commandName,
267
- args,
268
- cwd,
269
- logger: require_validate.logger,
270
- loadConfig: loadCachedConfig,
271
- loadPatchOptions: loadPatchOptionsForContext,
272
- createPatcher: createPatcherForContext
273
- };
274
- }
275
- //#endregion
276
- //#region src/commands/command-runtime.ts
277
- function runWithCommandHandler(cli, command, commandName, args, handler, defaultHandler) {
278
- const context = createTailwindcssPatchCommandContext(cli, command, commandName, args, resolveCommandCwd(args.cwd));
279
- const runDefault = createMemoizedPromiseRunner(() => defaultHandler(context));
280
- if (!handler) return runDefault();
281
- return handler(context, runDefault);
282
- }
283
- //#endregion
284
- //#region src/commands/basic-handlers.ts
285
- const DEFAULT_CONFIG_NAME = "tailwindcss-mangle";
286
- async function installCommandDefaultHandler(_ctx) {
287
- await (await _ctx.createPatcher()).patch();
288
- require_validate.logger.success("Tailwind CSS runtime patched successfully.");
289
- }
290
- async function extractCommandDefaultHandler(ctx) {
291
- const { args } = ctx;
292
- const overrides = {};
293
- let hasOverrides = false;
294
- if (args.output || args.format) {
295
- overrides.extract = {
296
- ...args.output === void 0 ? {} : { file: args.output },
297
- ...args.format === void 0 ? {} : { format: args.format }
298
- };
299
- hasOverrides = true;
300
- }
301
- if (args.css) {
302
- overrides.tailwindcss = { v4: { cssEntries: [args.css] } };
303
- hasOverrides = true;
304
- }
305
- const patcher = await ctx.createPatcher(hasOverrides ? overrides : void 0);
306
- const extractOptions = args.write === void 0 ? {} : { write: args.write };
307
- const result = await patcher.extract(extractOptions);
308
- if (result.filename) require_validate.logger.success(`Collected ${result.classList.length} classes → ${result.filename}`);
309
- else require_validate.logger.success(`Collected ${result.classList.length} classes.`);
310
- return result;
311
- }
312
- async function tokensCommandDefaultHandler(ctx) {
313
- const { args } = ctx;
314
- const report = await (await ctx.createPatcher()).collectContentTokens();
315
- const shouldWrite = args.write ?? true;
316
- let format = args.format ?? "json";
317
- if (!TOKEN_FORMATS.includes(format)) format = "json";
318
- const targetFile = args.output ?? ".tw-patch/tw-token-report.json";
319
- const groupKey = args.groupKey === "absolute" ? "absolute" : "relative";
320
- const buildGrouped = () => require_validate.groupTokensByFile(report, {
321
- key: groupKey,
322
- stripAbsolutePaths: groupKey !== "absolute"
323
- });
324
- const grouped = format === "grouped-json" ? buildGrouped() : null;
325
- const resolveGrouped = () => grouped ?? buildGrouped();
326
- if (shouldWrite) {
327
- const target = pathe.default.resolve(targetFile);
328
- await fs_extra.default.ensureDir(pathe.default.dirname(target));
329
- if (format === "json") await fs_extra.default.writeJSON(target, report, { spaces: 2 });
330
- else if (format === "grouped-json") await fs_extra.default.writeJSON(target, resolveGrouped(), { spaces: 2 });
331
- else {
332
- const lines = report.entries.map(formatTokenLine);
333
- await fs_extra.default.writeFile(target, `${lines.join("\n")}\n`, "utf8");
334
- }
335
- require_validate.logger.success(`Collected ${report.entries.length} tokens (${format}) → ${target.replace(node_process.default.cwd(), ".")}`);
336
- } else {
337
- require_validate.logger.success(`Collected ${report.entries.length} tokens from ${report.filesScanned} files.`);
338
- if (format === "lines") {
339
- const preview = report.entries.slice(0, 5).map(formatTokenLine).join("\n");
340
- if (preview) {
341
- require_validate.logger.log("");
342
- require_validate.logger.info(preview);
343
- if (report.entries.length > 5) require_validate.logger.info(`…and ${report.entries.length - 5} more.`);
344
- }
345
- } else if (format === "grouped-json") {
346
- const { preview, moreFiles } = formatGroupedPreview(resolveGrouped());
347
- if (preview) {
348
- require_validate.logger.log("");
349
- require_validate.logger.info(preview);
350
- if (moreFiles > 0) require_validate.logger.info(`…and ${moreFiles} more files.`);
351
- }
352
- } else {
353
- const previewEntries = report.entries.slice(0, 3);
354
- if (previewEntries.length) {
355
- require_validate.logger.log("");
356
- require_validate.logger.info(JSON.stringify(previewEntries, null, 2));
357
- }
358
- }
359
- }
360
- if (report.skippedFiles.length) {
361
- require_validate.logger.warn("Skipped files:");
362
- for (const skipped of report.skippedFiles) require_validate.logger.warn(` • ${skipped.file} (${skipped.reason})`);
363
- }
364
- return report;
365
- }
366
- async function initCommandDefaultHandler(ctx) {
367
- const configModule = await require_validate.loadWorkspaceConfigModule();
368
- await configModule.initConfig(ctx.cwd);
369
- const configName = configModule.CONFIG_NAME || DEFAULT_CONFIG_NAME;
370
- require_validate.logger.success(`✨ ${configName}.config.ts initialized!`);
371
- }
372
- //#endregion
373
- //#region src/commands/migration-args.ts
374
- function normalizePatternArgs(value) {
375
- if (!value) return;
376
- const values = (Array.isArray(value) ? value : [value]).flatMap((item) => item.split(",")).map((item) => item.trim()).filter(Boolean);
377
- return values.length > 0 ? values : void 0;
378
- }
379
- function parseMaxDepth(value) {
380
- if (value === void 0) return {
381
- maxDepth: void 0,
382
- hasInvalidMaxDepth: false
383
- };
384
- const parsed = Number(value);
385
- if (!Number.isFinite(parsed) || parsed < 0) return {
386
- maxDepth: void 0,
387
- hasInvalidMaxDepth: true
388
- };
389
- return {
390
- maxDepth: Math.floor(parsed),
391
- hasInvalidMaxDepth: false
392
- };
393
- }
394
- function resolveMigrateCommandArgs(args) {
395
- const include = normalizePatternArgs(args.include);
396
- const exclude = normalizePatternArgs(args.exclude);
397
- const { maxDepth, hasInvalidMaxDepth } = parseMaxDepth(args.maxDepth);
398
- const checkMode = args.check ?? false;
399
- return {
400
- include,
401
- exclude,
402
- maxDepth,
403
- checkMode,
404
- dryRun: args.dryRun ?? checkMode,
405
- hasInvalidMaxDepth
406
- };
407
- }
408
- function resolveRestoreCommandArgs(args) {
409
- return {
410
- reportFile: args.reportFile ?? ".tw-patch/migrate-report.json",
411
- dryRun: args.dryRun ?? false,
412
- strict: args.strict ?? false
413
- };
414
- }
415
- function resolveValidateCommandArgs(args) {
416
- return {
417
- reportFile: args.reportFile ?? ".tw-patch/migrate-report.json",
418
- strict: args.strict ?? false
419
- };
420
- }
421
- //#endregion
422
- //#region src/commands/migration-output.ts
423
- function formatPathForLog(file) {
424
- return file.replace(node_process.default.cwd(), ".");
425
- }
426
- function createMigrationCheckFailureError(changedFiles) {
427
- return /* @__PURE__ */ new Error(`Migration check failed: ${changedFiles} file(s) still need migration.`);
428
- }
429
- async function writeMigrationReportFile(cwd, reportFile, report) {
430
- const reportPath = pathe.default.resolve(cwd, reportFile);
431
- await fs_extra.default.ensureDir(pathe.default.dirname(reportPath));
432
- await fs_extra.default.writeJSON(reportPath, report, { spaces: 2 });
433
- require_validate.logger.info(`Migration report written: ${formatPathForLog(reportPath)}`);
434
- }
435
- function logMigrationReportAsJson(report) {
436
- require_validate.logger.log(JSON.stringify(report, null, 2));
437
- }
438
- function logNoMigrationConfigFilesWarning() {
439
- require_validate.logger.warn("No config files found for migration.");
440
- }
441
- function logMigrationEntries(report, dryRun) {
442
- for (const entry of report.entries) {
443
- const fileLabel = formatPathForLog(entry.file);
444
- if (!entry.changed) {
445
- require_validate.logger.info(`No changes: ${fileLabel}`);
446
- continue;
447
- }
448
- if (dryRun) require_validate.logger.info(`[dry-run] ${fileLabel}`);
449
- else require_validate.logger.success(`Migrated: ${fileLabel}`);
450
- for (const change of entry.changes) require_validate.logger.info(` - ${change}`);
451
- if (entry.backupFile) require_validate.logger.info(` - backup: ${formatPathForLog(entry.backupFile)}`);
452
- }
453
- }
454
- function logMigrationSummary(report) {
455
- require_validate.logger.info(`Migration summary: scanned=${report.scannedFiles}, changed=${report.changedFiles}, written=${report.writtenFiles}, backups=${report.backupsWritten}, missing=${report.missingFiles}, unchanged=${report.unchangedFiles}`);
456
- }
457
- function logRestoreResultAsJson(result) {
458
- require_validate.logger.log(JSON.stringify(result, null, 2));
459
- }
460
- function logRestoreSummary(result) {
461
- require_validate.logger.info(`Restore summary: scanned=${result.scannedEntries}, restorable=${result.restorableEntries}, restored=${result.restoredFiles}, missingBackups=${result.missingBackups}, skipped=${result.skippedEntries}`);
462
- if (result.restored.length > 0) {
463
- const preview = result.restored.slice(0, 5);
464
- for (const file of preview) require_validate.logger.info(` - ${formatPathForLog(file)}`);
465
- if (result.restored.length > preview.length) require_validate.logger.info(` ...and ${result.restored.length - preview.length} more`);
466
- }
467
- }
468
- function logValidateSuccessAsJson(result) {
469
- const payload = {
470
- ok: true,
471
- ...result
472
- };
473
- require_validate.logger.log(JSON.stringify(payload, null, 2));
474
- }
475
- function logValidateSuccessSummary(result) {
476
- require_validate.logger.success(`Migration report validated: scanned=${result.scannedEntries}, restorable=${result.restorableEntries}, missingBackups=${result.missingBackups}, skipped=${result.skippedEntries}`);
477
- if (result.reportKind || result.reportSchemaVersion !== void 0) {
478
- const kind = result.reportKind ?? "unknown";
479
- const schema = result.reportSchemaVersion === void 0 ? "unknown" : String(result.reportSchemaVersion);
480
- require_validate.logger.info(` metadata: kind=${kind}, schema=${schema}`);
481
- }
482
- }
483
- function logValidateFailureAsJson(summary) {
484
- const payload = {
485
- ok: false,
486
- reason: summary.reason,
487
- exitCode: summary.exitCode,
488
- message: summary.message
489
- };
490
- require_validate.logger.log(JSON.stringify(payload, null, 2));
491
- }
492
- function logValidateFailureSummary(summary) {
493
- require_validate.logger.error(`Validation failed [${summary.reason}] (exit ${summary.exitCode}): ${summary.message}`);
494
- }
495
- //#endregion
496
- //#region src/commands/migrate-handler.ts
497
- async function migrateCommandDefaultHandler(ctx) {
498
- const { args } = ctx;
499
- const { include, exclude, maxDepth, checkMode, dryRun, hasInvalidMaxDepth } = resolveMigrateCommandArgs(args);
500
- if (args.workspace && hasInvalidMaxDepth) require_validate.logger.warn(`Invalid --max-depth value "${String(args.maxDepth)}", fallback to default depth.`);
501
- const report = await require_validate.migrateConfigFiles({
502
- cwd: ctx.cwd,
503
- dryRun,
504
- ...args.config ? { files: [args.config] } : {},
505
- ...args.workspace ? { workspace: true } : {},
506
- ...args.workspace && maxDepth !== void 0 ? { maxDepth } : {},
507
- ...args.backupDir ? { backupDir: args.backupDir } : {},
508
- ...include ? { include } : {},
509
- ...exclude ? { exclude } : {}
510
- });
511
- if (args.reportFile) await writeMigrationReportFile(ctx.cwd, args.reportFile, report);
512
- if (args.json) {
513
- logMigrationReportAsJson(report);
514
- if (checkMode && report.changedFiles > 0) throw createMigrationCheckFailureError(report.changedFiles);
515
- if (report.scannedFiles === 0) logNoMigrationConfigFilesWarning();
516
- return report;
517
- }
518
- if (report.scannedFiles === 0) {
519
- logNoMigrationConfigFilesWarning();
520
- return report;
521
- }
522
- logMigrationEntries(report, dryRun);
523
- logMigrationSummary(report);
524
- if (checkMode && report.changedFiles > 0) throw createMigrationCheckFailureError(report.changedFiles);
525
- return report;
526
- }
527
- //#endregion
528
- //#region src/commands/restore-handler.ts
529
- async function restoreCommandDefaultHandler(ctx) {
530
- const { args } = ctx;
531
- const restoreArgs = resolveRestoreCommandArgs(args);
532
- const result = await require_validate.restoreConfigFiles({
533
- cwd: ctx.cwd,
534
- reportFile: restoreArgs.reportFile,
535
- dryRun: restoreArgs.dryRun,
536
- strict: restoreArgs.strict
537
- });
538
- if (args.json) {
539
- logRestoreResultAsJson(result);
540
- return result;
541
- }
542
- logRestoreSummary(result);
543
- return result;
544
- }
545
- //#endregion
546
- //#region src/commands/status-output.ts
547
- function formatFilesHint(entry) {
548
- if (!entry.files.length) return "";
549
- return ` (${entry.files.join(", ")})`;
550
- }
551
- function formatPackageLabel(report) {
552
- return `${report.package.name ?? "tailwindcss"}@${report.package.version ?? "unknown"}`;
553
- }
554
- function partitionStatusEntries(report) {
555
- return {
556
- applied: report.entries.filter((entry) => entry.status === "applied"),
557
- pending: report.entries.filter((entry) => entry.status === "not-applied"),
558
- skipped: report.entries.filter((entry) => entry.status === "skipped" || entry.status === "unsupported")
559
- };
560
- }
561
- function logStatusReportAsJson(report) {
562
- require_validate.logger.log(JSON.stringify(report, null, 2));
563
- }
564
- function logStatusReportSummary(report) {
565
- const { applied, pending, skipped } = partitionStatusEntries(report);
566
- require_validate.logger.info(`Patch status for ${formatPackageLabel(report)} (v${report.majorVersion})`);
567
- if (applied.length) {
568
- require_validate.logger.success("Applied:");
569
- applied.forEach((entry) => require_validate.logger.success(` • ${entry.name}${formatFilesHint(entry)}`));
570
- }
571
- if (pending.length) {
572
- require_validate.logger.warn("Needs attention:");
573
- pending.forEach((entry) => {
574
- const details = entry.reason ? ` - ${entry.reason}` : "";
575
- require_validate.logger.warn(` • ${entry.name}${formatFilesHint(entry)}${details}`);
576
- });
577
- } else require_validate.logger.success("All applicable patches are applied.");
578
- if (skipped.length) {
579
- require_validate.logger.info("Skipped:");
580
- skipped.forEach((entry) => {
581
- const details = entry.reason ? ` - ${entry.reason}` : "";
582
- require_validate.logger.info(` • ${entry.name}${details}`);
583
- });
584
- }
585
- }
586
- //#endregion
587
- //#region src/commands/status-handler.ts
588
- async function statusCommandDefaultHandler(ctx) {
589
- const report = await (await ctx.createPatcher()).getPatchStatus();
590
- if (ctx.args.json) {
591
- logStatusReportAsJson(report);
592
- return report;
593
- }
594
- logStatusReportSummary(report);
595
- return report;
596
- }
597
- //#endregion
598
- //#region src/commands/validate-handler.ts
599
- async function validateCommandDefaultHandler(ctx) {
600
- const { args } = ctx;
601
- const validateArgs = resolveValidateCommandArgs(args);
602
- try {
603
- const result = await require_validate.restoreConfigFiles({
604
- cwd: ctx.cwd,
605
- reportFile: validateArgs.reportFile,
606
- dryRun: true,
607
- strict: validateArgs.strict
608
- });
609
- if (args.json) {
610
- logValidateSuccessAsJson(result);
611
- return result;
612
- }
613
- logValidateSuccessSummary(result);
614
- return result;
615
- } catch (error) {
616
- const summary = require_validate.classifyValidateError(error);
617
- if (args.json) logValidateFailureAsJson(summary);
618
- else logValidateFailureSummary(summary);
619
- throw new require_validate.ValidateCommandError(summary, { cause: error });
620
- }
621
- }
622
- //#endregion
623
- //#region src/commands/default-handler-map.ts
624
- const defaultCommandHandlers = {
625
- install: installCommandDefaultHandler,
626
- extract: extractCommandDefaultHandler,
627
- tokens: tokensCommandDefaultHandler,
628
- init: initCommandDefaultHandler,
629
- migrate: migrateCommandDefaultHandler,
630
- restore: restoreCommandDefaultHandler,
631
- validate: validateCommandDefaultHandler,
632
- status: statusCommandDefaultHandler
633
- };
634
- //#endregion
635
- //#region src/commands/command-registrar.ts
636
- function registerTailwindcssPatchCommand(cli, commandName, options, prefix, defaultDefinitions) {
637
- const metadata = resolveCommandMetadata(commandName, options, prefix, defaultDefinitions);
638
- const command = cli.command(metadata.name, metadata.description);
639
- applyCommandOptions(command, metadata.optionDefs);
640
- command.action(async (args) => {
641
- const defaultHandler = defaultCommandHandlers[commandName];
642
- return runWithCommandHandler(cli, command, commandName, args, options.commandHandlers?.[commandName], defaultHandler);
643
- });
644
- metadata.aliases.forEach((alias) => command.alias(alias));
645
- }
646
- //#endregion
647
- //#region src/commands/cli.ts
648
- function mountTailwindcssPatchCommands(cli, options = {}) {
649
- const prefix = options.commandPrefix ?? "";
650
- const selectedCommands = options.commands ?? require_validate.tailwindcssPatchCommands;
651
- const defaultDefinitions = buildDefaultCommandDefinitions();
652
- for (const name of selectedCommands) registerTailwindcssPatchCommand(cli, name, options, prefix, defaultDefinitions);
653
- return cli;
654
- }
655
- function createTailwindcssPatchCli(options = {}) {
656
- const cli = (0, cac.default)(options.name ?? "tw-patch");
657
- mountTailwindcssPatchCommands(cli, options.mountOptions);
658
- return cli;
659
- }
660
- //#endregion
661
- exports.VALIDATE_EXIT_CODES = require_validate.VALIDATE_EXIT_CODES;
662
- exports.VALIDATE_FAILURE_REASONS = require_validate.VALIDATE_FAILURE_REASONS;
663
- exports.ValidateCommandError = require_validate.ValidateCommandError;
664
- exports.createTailwindcssPatchCli = createTailwindcssPatchCli;
665
- exports.mountTailwindcssPatchCommands = mountTailwindcssPatchCommands;
666
- exports.tailwindcssPatchCommands = require_validate.tailwindcssPatchCommands;
2
+ const require_migrate_config = require("../migrate-config-Dn9OTXpO.js");
3
+ const require_cli = require("../cli-CBVPia5Z.js");
4
+ exports.VALIDATE_EXIT_CODES = require_migrate_config.VALIDATE_EXIT_CODES;
5
+ exports.VALIDATE_FAILURE_REASONS = require_migrate_config.VALIDATE_FAILURE_REASONS;
6
+ exports.ValidateCommandError = require_migrate_config.ValidateCommandError;
7
+ exports.createTailwindcssPatchCli = require_cli.createTailwindcssPatchCli;
8
+ exports.mountTailwindcssPatchCommands = require_cli.mountTailwindcssPatchCommands;
9
+ exports.tailwindcssPatchCommands = require_migrate_config.tailwindcssPatchCommands;