@weapp-tailwindcss/cli 4.0.0-alpha.8 → 5.3.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.
@@ -0,0 +1,1067 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ let node_process = require("node:process");
24
+ node_process = __toESM(node_process, 1);
25
+ let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
26
+ let semver = require("semver");
27
+ semver = __toESM(semver, 1);
28
+ let node_buffer = require("node:buffer");
29
+ let node_fs_promises = require("node:fs/promises");
30
+ node_fs_promises = __toESM(node_fs_promises, 1);
31
+ let node_path = require("node:path");
32
+ node_path = __toESM(node_path, 1);
33
+ let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
34
+ let lightningcss = require("lightningcss");
35
+ let weapp_tailwindcss_generator = require("weapp-tailwindcss/generator");
36
+ let node_fs = require("node:fs");
37
+ node_fs = __toESM(node_fs, 1);
38
+ let node_crypto = require("node:crypto");
39
+ let _parcel_watcher = require("@parcel/watcher");
40
+ _parcel_watcher = __toESM(_parcel_watcher, 1);
41
+ let fast_glob = require("fast-glob");
42
+ fast_glob = __toESM(fast_glob, 1);
43
+ let node_readline = require("node:readline");
44
+ let node_module = require("node:module");
45
+ //#region src/build/args.ts
46
+ function value(argv, index, flag) {
47
+ const item = argv[index];
48
+ return (item?.startsWith(`${flag}=`) ? item.slice(flag.length + 1) : void 0) ?? argv[index + 1];
49
+ }
50
+ function parseBuildArgs(argv) {
51
+ let cwd = node_process.default.cwd();
52
+ let input;
53
+ let output;
54
+ let watch = false;
55
+ let watchMode = "native";
56
+ let pollInterval = 250;
57
+ let minify = false;
58
+ let optimize = false;
59
+ let map = false;
60
+ let silent = false;
61
+ let target = "web";
62
+ for (let index = 0; index < argv.length; index++) {
63
+ const arg = argv[index];
64
+ const consumesNext = !arg.includes("=");
65
+ if (arg === "--cwd" || arg.startsWith("--cwd=")) {
66
+ cwd = node_path.default.resolve(value(argv, index, "--cwd"));
67
+ if (consumesNext) index++;
68
+ } else if (arg === "-i" || arg === "--input" || arg.startsWith("--input=")) {
69
+ input = value(argv, index, arg === "-i" ? "-i" : "--input");
70
+ if (consumesNext) index++;
71
+ } else if (arg === "-o" || arg === "--output" || arg.startsWith("--output=")) {
72
+ output = value(argv, index, arg === "-o" ? "-o" : "--output");
73
+ if (consumesNext) index++;
74
+ } else if (arg === "-w" || arg === "--watch") watch = true;
75
+ else if (arg.startsWith("--watch=")) {
76
+ if (value(argv, index, "--watch") !== "always") throw new Error("Option \"--watch\" only accepts \"always\".");
77
+ watch = "always";
78
+ } else if (arg === "--poll") {
79
+ watchMode = "poll";
80
+ pollInterval = 250;
81
+ } else if (arg.startsWith("--poll=")) {
82
+ watchMode = "poll";
83
+ pollInterval = Number(value(argv, index, "--poll"));
84
+ if (!Number.isFinite(pollInterval) || pollInterval <= 0) throw new Error("Specified polling interval must be a positive number.");
85
+ } else if (arg === "-m" || arg === "--minify") minify = true;
86
+ else if (arg === "--optimize") optimize = true;
87
+ else if (arg === "--silent") silent = true;
88
+ else if (arg === "--map") {
89
+ const next = argv[index + 1];
90
+ if (next && !next.startsWith("-")) {
91
+ if (next === "-") throw new Error("Use --map without a value to inline the source map.");
92
+ map = next;
93
+ index++;
94
+ } else map = true;
95
+ } else if (arg.startsWith("--map=")) {
96
+ const next = value(argv, index, "--map");
97
+ if (next === "-") throw new Error("Use --map without a value to inline the source map.");
98
+ map = next;
99
+ } else if (arg === "--target" || arg.startsWith("--target=")) {
100
+ const next = value(argv, index, "--target");
101
+ if (next !== "web" && next !== "weapp") throw new Error("Option \"--target\" must be \"web\" or \"weapp\".");
102
+ target = next;
103
+ if (consumesNext) index++;
104
+ } else throw new Error(`Unknown option: ${arg}`);
105
+ }
106
+ const resolvePath = (file) => file && file !== "-" ? node_path.default.resolve(cwd, file) : file;
107
+ input = resolvePath(input);
108
+ output = resolvePath(output);
109
+ if (typeof map === "string") map = node_path.default.resolve(cwd, map);
110
+ if (input && input !== "-" && !node_fs.default.existsSync(input)) throw new Error(`Specified input file ${input} does not exist.`);
111
+ if (input && input !== "-" && input === output) throw new Error("Specified input and output files are identical.");
112
+ if (target === "weapp" && map) throw new Error("Option \"--map\" is only supported when \"--target web\" is used.");
113
+ return {
114
+ cwd,
115
+ input,
116
+ output,
117
+ watch,
118
+ watchMode,
119
+ pollInterval,
120
+ minify,
121
+ optimize,
122
+ map,
123
+ silent,
124
+ target
125
+ };
126
+ }
127
+ //#endregion
128
+ //#region src/build/watch.ts
129
+ async function snapshot(cwd, dependencies, output) {
130
+ const files = /* @__PURE__ */ new Set([...dependencies, ...await (0, fast_glob.default)("**/*", {
131
+ cwd,
132
+ absolute: true,
133
+ dot: true,
134
+ onlyFiles: true,
135
+ ignore: ["node_modules/**", ".git/**"]
136
+ })]);
137
+ if (output && output !== "-") files.delete(node_path.default.resolve(output));
138
+ const state = /* @__PURE__ */ new Map();
139
+ await Promise.all([...files].map(async (file) => {
140
+ try {
141
+ const [stat, content] = await Promise.all([node_fs_promises.default.stat(file), node_fs_promises.default.readFile(file)]);
142
+ const digest = (0, node_crypto.createHash)("sha256").update(content).digest("hex");
143
+ state.set(node_path.default.resolve(file), `${stat.mtimeMs}:${stat.size}:${digest}`);
144
+ } catch {}
145
+ }));
146
+ return state;
147
+ }
148
+ function changed(previous, next) {
149
+ if (previous.size !== next.size) return true;
150
+ for (const [file, value] of next) if (previous.get(file) !== value) return true;
151
+ return false;
152
+ }
153
+ async function watchBuildInputs(options) {
154
+ if (options.mode === "native") try {
155
+ return await watchWithNativeWatcher(options);
156
+ } catch (error) {
157
+ node_process.default.stderr.write(`Native watcher unavailable, falling back to polling: ${error instanceof Error ? error.message : String(error)}\n`);
158
+ return watchWithPolling(options);
159
+ }
160
+ return watchWithPolling(options);
161
+ }
162
+ async function watchWithPolling(options) {
163
+ let dependencies = /* @__PURE__ */ new Set();
164
+ const previous = await snapshot(options.cwd, dependencies, options.output);
165
+ dependencies = await options.rebuild();
166
+ const initialized = await snapshot(options.cwd, dependencies, options.output);
167
+ for (const [file, value] of initialized) if (!previous.has(file)) previous.set(file, value);
168
+ await new Promise((resolve) => {
169
+ let running = false;
170
+ const timer = setInterval(async () => {
171
+ if (running) return;
172
+ running = true;
173
+ try {
174
+ const next = await snapshot(options.cwd, dependencies, options.output);
175
+ if (changed(previous, next)) {
176
+ previous.clear();
177
+ for (const [file, value] of next) previous.set(file, value);
178
+ dependencies = await options.rebuild();
179
+ }
180
+ } catch (error) {
181
+ node_process.default.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
182
+ } finally {
183
+ running = false;
184
+ }
185
+ }, options.interval);
186
+ const stop = () => {
187
+ clearInterval(timer);
188
+ resolve();
189
+ };
190
+ node_process.default.once("SIGINT", stop);
191
+ node_process.default.once("SIGTERM", stop);
192
+ });
193
+ }
194
+ function parentDirectories(files, cwd) {
195
+ const directories = /* @__PURE__ */ new Set([node_path.default.resolve(cwd)]);
196
+ for (const file of files) {
197
+ const absolute = node_path.default.resolve(file);
198
+ if (!absolute.startsWith(`${node_path.default.resolve(cwd)}${node_path.default.sep}`)) directories.add(node_path.default.dirname(absolute));
199
+ }
200
+ return directories;
201
+ }
202
+ async function watchWithNativeWatcher(options) {
203
+ let dependencies = /* @__PURE__ */ new Set();
204
+ const subscriptions = /* @__PURE__ */ new Map();
205
+ let running = false;
206
+ let pending = false;
207
+ let resolvePending;
208
+ const output = options.output && options.output !== "-" ? node_path.default.resolve(options.output) : void 0;
209
+ const requestRebuild = () => {
210
+ pending = true;
211
+ resolvePending?.();
212
+ };
213
+ const syncSubscriptions = async () => {
214
+ const directories = parentDirectories(dependencies, options.cwd);
215
+ for (const directory of directories) {
216
+ if (subscriptions.has(directory)) continue;
217
+ const subscription = await _parcel_watcher.subscribe(directory, (error, events) => {
218
+ if (error) {
219
+ node_process.default.stderr.write(`${error.message}\n`);
220
+ return;
221
+ }
222
+ if (events.some((event) => !output || node_path.default.resolve(event.path) !== output)) requestRebuild();
223
+ }, { ignore: ["**/node_modules/**", "**/.git/**"] });
224
+ subscriptions.set(directory, subscription);
225
+ }
226
+ for (const [directory, subscription] of subscriptions) if (!directories.has(directory)) {
227
+ await subscription.unsubscribe();
228
+ subscriptions.delete(directory);
229
+ }
230
+ };
231
+ await syncSubscriptions();
232
+ dependencies = await options.rebuild();
233
+ await syncSubscriptions();
234
+ await new Promise((resolve) => {
235
+ const stop = () => {
236
+ Promise.all([...subscriptions.values()].map((subscription) => subscription.unsubscribe())).finally(resolve);
237
+ };
238
+ node_process.default.once("SIGINT", stop);
239
+ node_process.default.once("SIGTERM", stop);
240
+ const loop = async () => {
241
+ while (true) {
242
+ if (pending) break;
243
+ await new Promise((wake) => {
244
+ resolvePending = wake;
245
+ });
246
+ resolvePending = void 0;
247
+ }
248
+ if (running) return;
249
+ running = true;
250
+ pending = false;
251
+ try {
252
+ dependencies = await options.rebuild();
253
+ await syncSubscriptions();
254
+ } catch (error) {
255
+ node_process.default.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
256
+ } finally {
257
+ running = false;
258
+ if (pending) loop();
259
+ }
260
+ };
261
+ loop();
262
+ });
263
+ }
264
+ //#endregion
265
+ //#region src/canonicalize.ts
266
+ function splitCandidates(input) {
267
+ const result = [];
268
+ let token = "";
269
+ let depth = 0;
270
+ let quote = "";
271
+ for (const char of input.trim()) {
272
+ if (quote) {
273
+ token += char;
274
+ if (char === quote) quote = "";
275
+ continue;
276
+ }
277
+ if (char === "\"" || char === "'") {
278
+ quote = char;
279
+ token += char;
280
+ continue;
281
+ }
282
+ if (char === "[" || char === "(") depth++;
283
+ if (char === "]" || char === ")") depth--;
284
+ if (/\s/.test(char) && depth === 0) {
285
+ if (token) result.push(token);
286
+ token = "";
287
+ continue;
288
+ }
289
+ token += char;
290
+ }
291
+ if (token) result.push(token);
292
+ return result;
293
+ }
294
+ function canonicalize(designSystem, input) {
295
+ const candidates = designSystem.canonicalizeCandidates(splitCandidates(input), {
296
+ collapse: true,
297
+ logicalToPhysical: true
298
+ });
299
+ return designSystem.getClassOrder(candidates).sort(([, a], [, b]) => a === b ? 0 : a === null ? -1 : b === null ? 1 : a < b ? -1 : 1).map(([candidate]) => candidate).join(" ");
300
+ }
301
+ function record(designSystem, input) {
302
+ const output = canonicalize(designSystem, input);
303
+ return {
304
+ input,
305
+ output,
306
+ changed: input !== output
307
+ };
308
+ }
309
+ async function load(cssFile, cwd) {
310
+ const file = cssFile ? node_path.default.resolve(cwd, cssFile) : void 0;
311
+ const css = file ? await node_fs_promises.default.readFile(file, "utf8") : "@import \"tailwindcss\";";
312
+ const source = await (0, weapp_tailwindcss_generator.resolveTailwindV4Source)({
313
+ css,
314
+ base: file ? node_path.default.dirname(file) : cwd,
315
+ cwd,
316
+ projectRoot: cwd,
317
+ packageName: "tailwindcss"
318
+ });
319
+ return (0, weapp_tailwindcss_generator.loadTailwindV4DesignSystem)(source);
320
+ }
321
+ async function runCanonicalize(argv) {
322
+ let cssFile;
323
+ let format = "text";
324
+ let stream = false;
325
+ const inputs = [];
326
+ for (let index = 0; index < argv.length; index++) {
327
+ const arg = argv[index];
328
+ if (arg === "--css") cssFile = argv[++index];
329
+ else if (arg.startsWith("--css=")) cssFile = arg.slice(6);
330
+ else if (arg === "--format") format = argv[++index];
331
+ else if (arg.startsWith("--format=")) format = arg.slice(9);
332
+ else if (arg === "--stream") stream = true;
333
+ else inputs.push(arg);
334
+ }
335
+ if (![
336
+ "text",
337
+ "json",
338
+ "jsonl"
339
+ ].includes(format)) throw new Error(`Invalid value for --format: ${format}`);
340
+ const designSystem = await load(cssFile, node_process.default.cwd());
341
+ if (stream) {
342
+ const records = [];
343
+ for await (const line of (0, node_readline.createInterface)({ input: node_process.default.stdin })) {
344
+ const item = record(designSystem, line);
345
+ if (format === "text") node_process.default.stdout.write(`${item.output}\n`);
346
+ else if (format === "jsonl") node_process.default.stdout.write(`${JSON.stringify(item)}\n`);
347
+ else records.push(item);
348
+ }
349
+ if (format === "json") node_process.default.stdout.write(JSON.stringify(records, null, 2));
350
+ return 0;
351
+ }
352
+ if (inputs.length === 0) {
353
+ for await (const line of (0, node_readline.createInterface)({ input: node_process.default.stdin })) if (line.trim()) inputs.push(line.trim());
354
+ }
355
+ if (inputs.length === 0) throw new Error("No candidate groups provided");
356
+ const records = inputs.map((input) => record(designSystem, input));
357
+ const output = format === "json" ? JSON.stringify(records, null, 2) : format === "jsonl" ? records.map(JSON.stringify).join("\n") : records.map((item) => item.output).join("\n");
358
+ node_process.default.stdout.write(`${output}\n`);
359
+ return 0;
360
+ }
361
+ //#endregion
362
+ //#region src/build.ts
363
+ const DEFAULT_INPUT = "@import \"tailwindcss\";";
364
+ async function drainStdin() {
365
+ const chunks = [];
366
+ for await (const chunk of node_process.default.stdin) chunks.push(node_buffer.Buffer.from(chunk));
367
+ return node_buffer.Buffer.concat(chunks).toString();
368
+ }
369
+ async function writeFile$1(file, content) {
370
+ await node_fs_promises.default.mkdir(node_path.default.dirname(file), { recursive: true });
371
+ await node_fs_promises.default.writeFile(file, content);
372
+ }
373
+ function sourceMapComment(value) {
374
+ return `/*# sourceMappingURL=${value} */`;
375
+ }
376
+ async function buildOnce(options, stdinCss) {
377
+ const inputCss = options.input === "-" ? stdinCss ?? await drainStdin() : options.input ? await node_fs_promises.default.readFile(options.input, "utf8") : DEFAULT_INPUT;
378
+ const sourceOptions = {
379
+ base: options.input && options.input !== "-" ? node_path.default.dirname(options.input) : options.cwd,
380
+ projectRoot: options.cwd,
381
+ cwd: options.cwd,
382
+ packageName: "tailwindcss"
383
+ };
384
+ const source = await (0, weapp_tailwindcss_generator.resolveTailwindV4Source)({
385
+ ...sourceOptions,
386
+ css: inputCss
387
+ });
388
+ const generator = (0, weapp_tailwindcss_generator.createWeappTailwindcssGenerator)(source);
389
+ try {
390
+ const { compiled, dependencies: compilerDependencies } = await (0, _tailwindcss_mangle_engine.compileTailwindV4Source)(source);
391
+ const scanPatterns = (0, _tailwindcss_mangle_engine.createTailwindV4CompiledSourceEntries)(compiled.root, compiled.sources, source.projectRoot);
392
+ const scanSources = (0, _tailwindcss_mangle_engine.normalizeTailwindV4ScannerSources)(scanPatterns, source.projectRoot);
393
+ const outputPath = options.output && options.output !== "-" ? node_path.default.resolve(options.output) : void 0;
394
+ const sourceFiles = await (0, _tailwindcss_mangle_engine.resolveProjectSourceFiles)({
395
+ cwd: source.projectRoot,
396
+ sources: scanSources,
397
+ filter: (file) => node_path.default.resolve(file) !== outputPath
398
+ });
399
+ const candidateGroups = await Promise.all(sourceFiles.map(async (file) => {
400
+ const content = await node_fs_promises.default.readFile(file, "utf8");
401
+ const extension = node_path.default.extname(file).slice(1) || "html";
402
+ return (0, _tailwindcss_mangle_engine.extractRawCandidatesWithPositions)(content, extension);
403
+ }));
404
+ const candidates = new Set(candidateGroups.flat().map((candidate) => candidate.rawCandidate));
405
+ const result = await generator.generate({
406
+ candidates,
407
+ target: options.target,
408
+ scanSources: false,
409
+ incrementalCache: false
410
+ });
411
+ let css = result.css;
412
+ let map;
413
+ if (options.minify || options.optimize || options.map) {
414
+ const transformed = (0, lightningcss.transform)({
415
+ filename: options.input && options.input !== "-" ? node_path.default.basename(options.input) : "input.css",
416
+ code: node_buffer.Buffer.from(css),
417
+ minify: options.minify,
418
+ sourceMap: Boolean(options.map)
419
+ });
420
+ css = node_buffer.Buffer.from(transformed.code).toString();
421
+ map = transformed.map;
422
+ }
423
+ if (options.map && map) {
424
+ if (options.map === true) css += `\n${sourceMapComment(`data:application/json;base64,${node_buffer.Buffer.from(map).toString("base64")}`)}`;
425
+ else {
426
+ await writeFile$1(options.map, map);
427
+ const mapBase = options.output && options.output !== "-" ? node_path.default.dirname(options.output) : options.cwd;
428
+ css += `\n${sourceMapComment(node_path.default.relative(mapBase, options.map))}`;
429
+ }
430
+ }
431
+ return {
432
+ css,
433
+ dependencies: /* @__PURE__ */ new Set([
434
+ ...options.input && options.input !== "-" ? [options.input] : [],
435
+ ...source.dependencies,
436
+ ...compilerDependencies,
437
+ ...result.dependencies,
438
+ ...sourceFiles
439
+ ])
440
+ };
441
+ } finally {
442
+ generator.dispose?.();
443
+ }
444
+ }
445
+ async function runBuild(argv) {
446
+ const options = parseBuildArgs(argv);
447
+ if (!options.silent) node_process.default.stderr.write(`tailwindcss v${node_process.default.env.npm_package_version ?? ""}\n\n`);
448
+ const stdinCss = options.input === "-" ? await drainStdin() : void 0;
449
+ let previous = "";
450
+ const rebuild = async () => {
451
+ const result = await buildOnce(options, stdinCss);
452
+ if (result.css !== previous) {
453
+ if (options.output && options.output !== "-") await writeFile$1(options.output, result.css);
454
+ else node_process.default.stdout.write(`${result.css}\n`);
455
+ previous = result.css;
456
+ }
457
+ return result.dependencies;
458
+ };
459
+ if (!options.watch || options.input === "-" && options.watch !== "always") {
460
+ await rebuild();
461
+ return 0;
462
+ }
463
+ await watchBuildInputs({
464
+ cwd: options.cwd,
465
+ interval: options.pollInterval,
466
+ mode: options.watchMode,
467
+ output: options.output,
468
+ rebuild
469
+ });
470
+ return 0;
471
+ }
472
+ async function runTailwindCli(rawArgv) {
473
+ if (rawArgv[0] === "canonicalize") return runCanonicalize(rawArgv.slice(1));
474
+ return runBuild(rawArgv[0] === "build" ? rawArgv.slice(1) : rawArgv);
475
+ }
476
+ //#endregion
477
+ //#region package.json
478
+ var version = "5.3.0";
479
+ //#endregion
480
+ //#region src/constants.ts
481
+ const WEAPP_TW_REQUIRED_NODE_VERSION_RANGE = "^22.18.0 || >=24.11.0";
482
+ const WEAPP_TW_VERSION = version;
483
+ //#endregion
484
+ //#region src/context.ts
485
+ function formatOutputPath(target, baseDir) {
486
+ const root = baseDir ?? node_process.default.cwd();
487
+ const relative = node_path.default.relative(root, target);
488
+ if (!relative) return ".";
489
+ if (relative.startsWith("..")) return node_path.default.normalize(target);
490
+ return relative.startsWith(".") ? relative : `.${node_path.default.sep}${relative}`;
491
+ }
492
+ //#endregion
493
+ //#region src/doctor/constants.ts
494
+ const CONFIG_FILES = {
495
+ tailwind: [
496
+ "tailwind.config.js",
497
+ "tailwind.config.cjs",
498
+ "tailwind.config.mjs",
499
+ "tailwind.config.ts"
500
+ ],
501
+ postcss: [
502
+ "postcss.config.js",
503
+ "postcss.config.cjs",
504
+ "postcss.config.mjs",
505
+ "postcss.config.ts"
506
+ ],
507
+ vite: [
508
+ "vite.config.js",
509
+ "vite.config.mjs",
510
+ "vite.config.ts"
511
+ ],
512
+ webpack: [
513
+ "webpack.config.js",
514
+ "webpack.config.cjs",
515
+ "webpack.config.ts"
516
+ ]
517
+ };
518
+ const FRAMEWORK_DEPS = [
519
+ ["@tarojs/taro", "Taro"],
520
+ ["@dcloudio/uni-app", "uni-app"],
521
+ ["@mpxjs/core", "MPX"],
522
+ ["remax", "Remax"]
523
+ ];
524
+ //#endregion
525
+ //#region src/doctor.ts
526
+ function tryReadJson(file) {
527
+ try {
528
+ return JSON.parse((0, node_fs.readFileSync)(file, "utf8"));
529
+ } catch {
530
+ return;
531
+ }
532
+ }
533
+ function findFirstExisting(cwd, files) {
534
+ return files.find((file) => (0, node_fs.existsSync)(node_path.default.join(cwd, file)));
535
+ }
536
+ function readProjectPackageJson(cwd) {
537
+ return tryReadJson(node_path.default.join(cwd, "package.json"));
538
+ }
539
+ function readDependencyVersion(cwd, packageName) {
540
+ try {
541
+ return tryReadJson((0, node_module.createRequire)(node_path.default.join(cwd, "package.json")).resolve(`${packageName}/package.json`))?.version;
542
+ } catch {
543
+ return;
544
+ }
545
+ }
546
+ function collectDependencySpecs(pkg) {
547
+ return {
548
+ ...pkg?.dependencies ?? {},
549
+ ...pkg?.devDependencies ?? {},
550
+ ...pkg?.optionalDependencies ?? {},
551
+ ...pkg?.peerDependencies ?? {}
552
+ };
553
+ }
554
+ function detectPackageManager(cwd, pkg) {
555
+ if (pkg?.packageManager) return pkg.packageManager;
556
+ if ((0, node_fs.existsSync)(node_path.default.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
557
+ if ((0, node_fs.existsSync)(node_path.default.join(cwd, "package-lock.json"))) return "npm";
558
+ if ((0, node_fs.existsSync)(node_path.default.join(cwd, "yarn.lock"))) return "yarn";
559
+ }
560
+ function detectFrameworks(deps) {
561
+ return FRAMEWORK_DEPS.filter(([dependency]) => dependency in deps).map(([, label]) => label);
562
+ }
563
+ function addCheck(checks, check) {
564
+ checks.push(check);
565
+ }
566
+ function summarizeChecks(checks) {
567
+ return checks.reduce((summary, check) => {
568
+ summary[check.status] += 1;
569
+ return summary;
570
+ }, {
571
+ ok: 0,
572
+ warn: 0,
573
+ error: 0,
574
+ info: 0
575
+ });
576
+ }
577
+ function hasDependency(deps, packageName) {
578
+ return packageName in deps;
579
+ }
580
+ function getMajorVersion(version) {
581
+ if (!version) return;
582
+ return semver.default.parse(version)?.major;
583
+ }
584
+ function getDependencyMajor(deps, packageName) {
585
+ const spec = deps[packageName];
586
+ return spec ? semver.default.minVersion(spec)?.major : void 0;
587
+ }
588
+ function createDoctorReport(options = {}) {
589
+ const cwd = node_path.default.resolve(options.cwd ?? node_process.default.cwd());
590
+ const nodeVersion = options.nodeVersion ?? node_process.default.versions.node;
591
+ const pkg = readProjectPackageJson(cwd);
592
+ const deps = collectDependencySpecs(pkg);
593
+ const checks = [];
594
+ const packageManager = detectPackageManager(cwd, pkg);
595
+ const frameworks = detectFrameworks(deps);
596
+ const tailwindcssVersion = readDependencyVersion(cwd, "tailwindcss");
597
+ const weappTailwindcssVersion = readDependencyVersion(cwd, "weapp-tailwindcss");
598
+ const tailwindMajor = getMajorVersion(tailwindcssVersion) ?? getDependencyMajor(deps, "tailwindcss");
599
+ const tailwindConfig = findFirstExisting(cwd, CONFIG_FILES.tailwind);
600
+ const postcssConfig = findFirstExisting(cwd, CONFIG_FILES.postcss);
601
+ const viteConfig = findFirstExisting(cwd, CONFIG_FILES.vite);
602
+ const webpackConfig = findFirstExisting(cwd, CONFIG_FILES.webpack);
603
+ addCheck(checks, pkg ? {
604
+ id: "package-json",
605
+ title: "package.json",
606
+ status: "ok",
607
+ message: "已找到项目 package.json。"
608
+ } : {
609
+ id: "package-json",
610
+ title: "package.json",
611
+ status: "error",
612
+ message: "当前目录没有 package.json。",
613
+ suggestion: "请在项目根目录运行 doctor,或通过 --cwd 指向项目根目录。"
614
+ });
615
+ addCheck(checks, semver.default.satisfies(nodeVersion, "^22.18.0 || >=24.11.0") ? {
616
+ id: "node-version",
617
+ title: "Node.js",
618
+ status: "ok",
619
+ message: `当前 Node.js ${nodeVersion} 满足版本要求 ${WEAPP_TW_REQUIRED_NODE_VERSION_RANGE}。`
620
+ } : {
621
+ id: "node-version",
622
+ title: "Node.js",
623
+ status: "error",
624
+ message: `当前 Node.js ${nodeVersion} 不满足版本要求 ${WEAPP_TW_REQUIRED_NODE_VERSION_RANGE}。`,
625
+ suggestion: "请升级 Node.js 后再安装或构建 weapp-tailwindcss 项目。"
626
+ });
627
+ addCheck(checks, packageManager ? {
628
+ id: "package-manager",
629
+ title: "包管理器",
630
+ status: packageManager.startsWith("pnpm") ? "ok" : "info",
631
+ message: `检测到 ${packageManager}。`
632
+ } : {
633
+ id: "package-manager",
634
+ title: "包管理器",
635
+ status: "info",
636
+ message: "未检测到 lockfile 或 packageManager 字段。"
637
+ });
638
+ addCheck(checks, hasDependency(deps, "weapp-tailwindcss") || Boolean(weappTailwindcssVersion) ? {
639
+ id: "weapp-tailwindcss",
640
+ title: "weapp-tailwindcss",
641
+ status: "ok",
642
+ message: `检测到 weapp-tailwindcss${weappTailwindcssVersion ? `@${weappTailwindcssVersion}` : ""}。`
643
+ } : {
644
+ id: "weapp-tailwindcss",
645
+ title: "weapp-tailwindcss",
646
+ status: "warn",
647
+ message: "未在当前项目依赖中检测到 weapp-tailwindcss。",
648
+ suggestion: "如果这是业务项目,请安装 weapp-tailwindcss 并确认命令运行在项目根目录。"
649
+ });
650
+ addCheck(checks, hasDependency(deps, "tailwindcss") || Boolean(tailwindcssVersion) ? {
651
+ id: "tailwindcss",
652
+ title: "Tailwind CSS",
653
+ status: "ok",
654
+ message: `检测到 tailwindcss${tailwindcssVersion ? `@${tailwindcssVersion}` : ""}。`
655
+ } : {
656
+ id: "tailwindcss",
657
+ title: "Tailwind CSS",
658
+ status: "error",
659
+ message: "未检测到 tailwindcss。",
660
+ suggestion: "请安装 tailwindcss,并确认依赖可以从当前项目解析。"
661
+ });
662
+ addCheck(checks, tailwindConfig ? {
663
+ id: "tailwind-config",
664
+ title: "Tailwind 配置",
665
+ status: "ok",
666
+ message: `检测到 ${tailwindConfig}。`
667
+ } : {
668
+ id: "tailwind-config",
669
+ title: "Tailwind 配置",
670
+ status: tailwindMajor === 4 ? "info" : "warn",
671
+ message: "未检测到 tailwind.config.*。",
672
+ suggestion: tailwindMajor === 4 ? "Tailwind CSS v4 可以采用 CSS-first 配置;复杂 content/source 场景请补充配置文件。" : "请确认 Tailwind content/source 配置能够覆盖小程序页面、组件和脚本文件。"
673
+ });
674
+ addCheck(checks, postcssConfig ? {
675
+ id: "postcss-config",
676
+ title: "PostCSS 配置",
677
+ status: "ok",
678
+ message: `检测到 ${postcssConfig}。`
679
+ } : {
680
+ id: "postcss-config",
681
+ title: "PostCSS 配置",
682
+ status: viteConfig ? "info" : "warn",
683
+ message: "未检测到 postcss.config.*。",
684
+ suggestion: "如果通过 PostCSS 接入,请补充 postcss.config.*;如果通过 Vite/Taro 插件接入,可忽略此项。"
685
+ });
686
+ if (tailwindMajor === 4 && postcssConfig && !hasDependency(deps, "@tailwindcss/postcss")) addCheck(checks, {
687
+ id: "tailwindcss-v4-postcss",
688
+ title: "Tailwind v4 PostCSS",
689
+ status: "warn",
690
+ message: "Tailwind CSS v4 项目存在 PostCSS 配置,但未检测到 @tailwindcss/postcss。",
691
+ suggestion: "如果 PostCSS 配置中仍直接使用 tailwindcss,请迁移到 @tailwindcss/postcss。"
692
+ });
693
+ addCheck(checks, frameworks.length > 0 ? {
694
+ id: "framework",
695
+ title: "框架识别",
696
+ status: "ok",
697
+ message: `检测到 ${frameworks.join(", ")}。`
698
+ } : {
699
+ id: "framework",
700
+ title: "框架识别",
701
+ status: "info",
702
+ message: "未从依赖中识别出 Taro、uni-app、MPX 或 Remax。"
703
+ });
704
+ addCheck(checks, viteConfig || webpackConfig ? {
705
+ id: "bundler-config",
706
+ title: "构建器配置",
707
+ status: "ok",
708
+ message: `检测到 ${[viteConfig, webpackConfig].filter(Boolean).join(", ")}。`
709
+ } : {
710
+ id: "bundler-config",
711
+ title: "构建器配置",
712
+ status: "info",
713
+ message: "未检测到 vite.config.* 或 webpack.config.*。"
714
+ });
715
+ return {
716
+ cwd,
717
+ nodeVersion,
718
+ detected: {
719
+ packageManager,
720
+ frameworks,
721
+ tailwindcssVersion,
722
+ weappTailwindcssVersion
723
+ },
724
+ summary: summarizeChecks(checks),
725
+ checks
726
+ };
727
+ }
728
+ function hasDoctorFailure(report, strict = false) {
729
+ return report.summary.error > 0 || strict && report.summary.warn > 0;
730
+ }
731
+ function formatDoctorReport(report) {
732
+ const lines = [
733
+ `weapp-tailwindcss doctor`,
734
+ `cwd: ${report.cwd}`,
735
+ `summary: ${report.summary.error} error, ${report.summary.warn} warn, ${report.summary.ok} ok, ${report.summary.info} info`,
736
+ ""
737
+ ];
738
+ for (const check of report.checks) {
739
+ lines.push(`[${check.status}] ${check.title}: ${check.message}`);
740
+ if (check.suggestion) lines.push(` -> ${check.suggestion}`);
741
+ }
742
+ return lines.join("\n");
743
+ }
744
+ //#endregion
745
+ //#region src/helpers/options/parse.ts
746
+ function readStringOption(flag, value) {
747
+ if (value == null) return;
748
+ if (typeof value !== "string") throw new TypeError(`Option "--${flag}" expects a string value.`);
749
+ const trimmed = value.trim();
750
+ if (trimmed.length === 0) throw new TypeError(`Option "--${flag}" expects a non-empty value.`);
751
+ return trimmed;
752
+ }
753
+ function readStringArrayOption(flag, value) {
754
+ if (value == null) return;
755
+ if (Array.isArray(value)) {
756
+ const normalized = value.filter((entry) => entry != null).map((entry) => {
757
+ if (typeof entry !== "string") throw new TypeError(`Option "--${flag}" expects string values.`);
758
+ const trimmed = entry.trim();
759
+ if (!trimmed) throw new TypeError(`Option "--${flag}" expects non-empty values.`);
760
+ return trimmed;
761
+ });
762
+ return normalized.length > 0 ? normalized : void 0;
763
+ }
764
+ const normalized = readStringOption(flag, value);
765
+ return normalized ? [normalized] : void 0;
766
+ }
767
+ function toBoolean(value, fallback) {
768
+ if (typeof value === "boolean") return value;
769
+ if (typeof value === "string") {
770
+ if (value === "true") return true;
771
+ if (value === "false") return false;
772
+ }
773
+ if (value == null) return fallback;
774
+ return Boolean(value);
775
+ }
776
+ //#endregion
777
+ //#region src/helpers/options/resolve.ts
778
+ function resolveCliCwd(value) {
779
+ const raw = readStringOption("cwd", value);
780
+ if (!raw) return;
781
+ return node_path.default.isAbsolute(raw) ? node_path.default.normalize(raw) : node_path.default.resolve(node_process.default.cwd(), raw);
782
+ }
783
+ //#endregion
784
+ //#region src/helpers.ts
785
+ async function ensureDir(dir) {
786
+ await (0, node_fs_promises.mkdir)(dir, { recursive: true });
787
+ }
788
+ function handleCliError(error) {
789
+ if (error instanceof Error) {
790
+ _weapp_tailwindcss_logger.logger.error(error.message);
791
+ if (error.stack && node_process.default.env["WEAPP_TW_DEBUG"] === "1") _weapp_tailwindcss_logger.logger.error(error.stack);
792
+ } else _weapp_tailwindcss_logger.logger.error(String(error));
793
+ }
794
+ function commandAction(handler) {
795
+ return async (...args) => {
796
+ try {
797
+ await handler(...args);
798
+ } catch (error) {
799
+ handleCliError(error);
800
+ node_process.default.exitCode = 1;
801
+ }
802
+ };
803
+ }
804
+ //#endregion
805
+ //#region src/mount-options.ts
806
+ const PATCH_COMMAND_OBSOLETE_NOTICE = "提示:weapp-tailwindcss@5 已由构建运行时接管 Tailwind CSS 处理,weapp-tw patch 已无需执行;请移除 package.json 中的 postinstall 钩子。";
807
+ const obsoletePatchCommands = [
808
+ "extract",
809
+ "tokens",
810
+ "init",
811
+ "migrate",
812
+ "restore",
813
+ "validate"
814
+ ];
815
+ function logPatchCommandObsoleteNotice() {
816
+ _weapp_tailwindcss_logger.logger.warn(PATCH_COMMAND_OBSOLETE_NOTICE);
817
+ }
818
+ function logObsoletePatchCommand(command) {
819
+ logPatchCommandObsoleteNotice();
820
+ _weapp_tailwindcss_logger.logger.warn(`命令 "${command}" 来自旧版 tailwindcss-patch 工作流,当前版本无需执行。`);
821
+ }
822
+ const DEFAULT_VSCODE_SOURCES = [
823
+ "not \"./dist\"",
824
+ "not \"./unpackage\"",
825
+ "./src/**/*.{wxml,axml,swan,qml,ttml,ux,uts}",
826
+ "./src/**/*.{js,jsx,ts,tsx,mjs,cjs,wxs,sjs}",
827
+ "./src/**/*.{vue,svelte,mpx,html,md,mdx}"
828
+ ];
829
+ const SINGLE_QUOTE = "'";
830
+ const DOUBLE_QUOTE = "\"";
831
+ const BACKSLASH_RE = /\\/g;
832
+ function toPosixPath(filepath) {
833
+ return filepath.replace(BACKSLASH_RE, "/");
834
+ }
835
+ async function assertFileExists(filepath) {
836
+ try {
837
+ await (0, node_fs_promises.access)(filepath, node_fs.constants.F_OK);
838
+ } catch (error) {
839
+ const err = error;
840
+ if (err?.code === "ENOENT") throw new Error(`CSS entry file not found: ${filepath}`);
841
+ throw err;
842
+ }
843
+ }
844
+ async function assertCanWrite(filepath, force) {
845
+ try {
846
+ await (0, node_fs_promises.access)(filepath, node_fs.constants.F_OK);
847
+ if (!force) throw new Error(`VS Code helper already exists at ${filepath}. Re-run with --force to overwrite it.`);
848
+ } catch (error) {
849
+ const err = error;
850
+ if (err?.code === "ENOENT") return;
851
+ throw err;
852
+ }
853
+ }
854
+ function toCssLiteral(value) {
855
+ const normalized = toPosixPath(value);
856
+ return JSON.stringify(normalized);
857
+ }
858
+ function formatSource(pattern) {
859
+ const trimmed = pattern.trim();
860
+ if (!trimmed) return null;
861
+ if (trimmed.startsWith("@source ")) return trimmed.endsWith(";") ? trimmed : `${trimmed};`;
862
+ let body = trimmed;
863
+ let keyword = "";
864
+ if (body.startsWith("not ")) {
865
+ keyword = "not ";
866
+ body = body.slice(4).trim();
867
+ } else if (body.startsWith("!")) {
868
+ keyword = "not ";
869
+ body = body.slice(1).trim();
870
+ }
871
+ if (!body) throw new Error("Invalid @source pattern: empty body.");
872
+ if (!body.startsWith(SINGLE_QUOTE) && !body.startsWith(DOUBLE_QUOTE)) body = toCssLiteral(body);
873
+ return `@source ${keyword}${body};`;
874
+ }
875
+ function resolveOutputPath(baseDir, output) {
876
+ const target = output ?? ".vscode/weapp-tailwindcss.intellisense.css";
877
+ return node_path.default.isAbsolute(target) ? node_path.default.normalize(target) : node_path.default.resolve(baseDir, target);
878
+ }
879
+ function resolveCssEntry(baseDir, entry) {
880
+ return node_path.default.isAbsolute(entry) ? node_path.default.normalize(entry) : node_path.default.resolve(baseDir, entry);
881
+ }
882
+ function toRelativeImport(fromFile, targetFile) {
883
+ const fromDir = node_path.default.dirname(fromFile);
884
+ let relative = node_path.default.relative(fromDir, targetFile);
885
+ if (!relative) relative = node_path.default.basename(targetFile);
886
+ if (!relative.startsWith(".")) relative = `./${relative}`;
887
+ return toPosixPath(relative);
888
+ }
889
+ async function generateVscodeIntellisenseEntry(options) {
890
+ const baseDir = options.baseDir;
891
+ const cssEntryPath = resolveCssEntry(baseDir, options.cssEntry);
892
+ await assertFileExists(cssEntryPath);
893
+ const outputPath = resolveOutputPath(baseDir, options.output);
894
+ await ensureDir(node_path.default.dirname(outputPath));
895
+ await assertCanWrite(outputPath, options.force);
896
+ const formattedSources = (options.sources && options.sources.length > 0 ? options.sources : DEFAULT_VSCODE_SOURCES).map(formatSource).filter((statement) => Boolean(statement));
897
+ const cssImport = toRelativeImport(outputPath, cssEntryPath);
898
+ const separator = formattedSources.length > 0 ? [""] : [];
899
+ const content = [
900
+ "/*",
901
+ " * Auto-generated by weapp-tailwindcss.",
902
+ " * This file exists solely to activate Tailwind CSS IntelliSense in VS Code.",
903
+ " * Do not import it in your actual mini-program bundles.",
904
+ " */",
905
+ "@import 'tailwindcss';",
906
+ "",
907
+ ...formattedSources,
908
+ ...separator,
909
+ `@import '${cssImport}';`,
910
+ ""
911
+ ].filter((line, idx, arr) => !(line === "" && arr[idx - 1] === "")).join("\n");
912
+ await (0, node_fs_promises.writeFile)(outputPath, `${content}\n`, "utf8");
913
+ return {
914
+ outputPath,
915
+ cssEntryPath
916
+ };
917
+ }
918
+ //#endregion
919
+ //#region src/index.ts
920
+ function parseLegacyArgs(argv) {
921
+ const options = {};
922
+ const positional = [];
923
+ for (let index = 0; index < argv.length; index++) {
924
+ const arg = argv[index];
925
+ if (arg === void 0) continue;
926
+ if (!arg.startsWith("--")) {
927
+ positional.push(arg);
928
+ continue;
929
+ }
930
+ const [rawKey, inlineValue] = arg.slice(2).split("=", 2);
931
+ if (!rawKey) continue;
932
+ const key = rawKey.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
933
+ const next = argv[index + 1];
934
+ let value = true;
935
+ if (inlineValue !== void 0) value = inlineValue;
936
+ else if (next !== void 0 && !next.startsWith("-")) {
937
+ index++;
938
+ value = next;
939
+ }
940
+ const current = options[key];
941
+ if (current === void 0) options[key] = value;
942
+ else if (Array.isArray(current)) current.push(String(value));
943
+ else options[key] = [String(current), String(value)];
944
+ }
945
+ return {
946
+ command: positional[0],
947
+ options
948
+ };
949
+ }
950
+ function printHelp() {
951
+ _weapp_tailwindcss_logger.logger.log(`weapp-tailwindcss
952
+
953
+ Usage:
954
+ weapp-tw [--input input.css] [--output output.css] [--watch] [options...]
955
+ weapp-tw build [--input input.css] [--output output.css] [--watch] [options...]
956
+ weapp-tw canonicalize [classes...]
957
+
958
+ Build options:
959
+ -i, --input <file> Input CSS file (use - for stdin)
960
+ -o, --output <file> Output CSS file (defaults to stdout)
961
+ -w, --watch[=always] Watch for changes and rebuild
962
+ --poll[=ms] Use polling instead of the native watcher (default 250ms)
963
+ -m, --minify Optimize and minify the output
964
+ --optimize Optimize without minifying
965
+ --cwd <dir> Set the working directory
966
+ --map[=<file>] Generate a source map
967
+ --silent Suppress non-error build output
968
+ --target <target> CSS target: web (default) or weapp
969
+
970
+ Additional commands:
971
+ canonicalize Canonicalize Tailwind candidate lists
972
+ patch Deprecated no-op: v5 runtime handles Tailwind CSS automatically
973
+ status Deprecated no-op: patch status is no longer required
974
+ vscode-entry Generate a VS Code helper CSS for Tailwind IntelliSense
975
+ doctor Check project setup for weapp-tailwindcss
976
+ `);
977
+ }
978
+ async function runPatch() {
979
+ logPatchCommandObsoleteNotice();
980
+ _weapp_tailwindcss_logger.logger.success("已跳过:当前版本不需要手动执行 Tailwind CSS patch。");
981
+ }
982
+ async function runStatus(options) {
983
+ const payload = {
984
+ required: false,
985
+ status: "unnecessary",
986
+ message: PATCH_COMMAND_OBSOLETE_NOTICE
987
+ };
988
+ if (toBoolean(options.json, false)) {
989
+ _weapp_tailwindcss_logger.logger.log(JSON.stringify(payload, null, 2));
990
+ return;
991
+ }
992
+ logPatchCommandObsoleteNotice();
993
+ _weapp_tailwindcss_logger.logger.success("无需检查 Tailwind CSS patch 状态。");
994
+ }
995
+ async function runVscodeEntry(options) {
996
+ const resolvedCwd = resolveCliCwd(options.cwd);
997
+ const baseDir = resolvedCwd ?? node_process.default.cwd();
998
+ const cssEntry = readStringOption("css", options.css);
999
+ if (!cssEntry) throw new Error("Option \"--css\" is required.");
1000
+ const result = await generateVscodeIntellisenseEntry({
1001
+ baseDir,
1002
+ cssEntry,
1003
+ output: readStringOption("output", options.output),
1004
+ sources: readStringArrayOption("source", options.source),
1005
+ force: toBoolean(options.force, false)
1006
+ });
1007
+ _weapp_tailwindcss_logger.logger.success(`VS Code helper generated -> ${formatOutputPath(result.outputPath, resolvedCwd)}`);
1008
+ }
1009
+ async function runDoctor(options) {
1010
+ const report = createDoctorReport({ cwd: resolveCliCwd(options.cwd) });
1011
+ _weapp_tailwindcss_logger.logger.log(toBoolean(options.json, false) ? JSON.stringify(report, null, 2) : formatDoctorReport(report));
1012
+ if (hasDoctorFailure(report, toBoolean(options.strict, false))) node_process.default.exitCode = 1;
1013
+ }
1014
+ async function runCli(argv = node_process.default.argv.slice(2)) {
1015
+ if (!semver.default.satisfies(node_process.default.versions.node, "^22.18.0 || >=24.11.0")) _weapp_tailwindcss_logger.logger.warn(`You are using Node.js ${node_process.default.versions.node}. For @weapp-tailwindcss/cli, Node.js version ${WEAPP_TW_REQUIRED_NODE_VERSION_RANGE} is required.`);
1016
+ const { command, options } = parseLegacyArgs(argv);
1017
+ await commandAction(async () => {
1018
+ switch (command) {
1019
+ case "patch":
1020
+ case "install":
1021
+ await runPatch();
1022
+ return;
1023
+ case "status":
1024
+ await runStatus(options);
1025
+ return;
1026
+ case "vscode-entry":
1027
+ await runVscodeEntry(options);
1028
+ return;
1029
+ case "doctor":
1030
+ await runDoctor(options);
1031
+ return;
1032
+ case "help":
1033
+ printHelp();
1034
+ return;
1035
+ case "version":
1036
+ node_process.default.stdout.write(`${WEAPP_TW_VERSION}\n`);
1037
+ return;
1038
+ default: if (obsoletePatchCommands.includes(command ?? "")) {
1039
+ logObsoletePatchCommand(command);
1040
+ return;
1041
+ }
1042
+ }
1043
+ if ((argv.includes("--help") || argv.includes("-h")) && command === void 0) {
1044
+ printHelp();
1045
+ return;
1046
+ }
1047
+ if (argv.includes("--version") || argv.includes("-v")) {
1048
+ node_process.default.stdout.write(`${WEAPP_TW_VERSION}\n`);
1049
+ return;
1050
+ }
1051
+ node_process.default.exitCode = await runTailwindCli(argv);
1052
+ })();
1053
+ return node_process.default.exitCode ?? 0;
1054
+ }
1055
+ //#endregion
1056
+ Object.defineProperty(exports, "__toESM", {
1057
+ enumerable: true,
1058
+ get: function() {
1059
+ return __toESM;
1060
+ }
1061
+ });
1062
+ Object.defineProperty(exports, "runCli", {
1063
+ enumerable: true,
1064
+ get: function() {
1065
+ return runCli;
1066
+ }
1067
+ });