weapp-tailwindcss 4.9.2-alpha.2 → 4.9.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-W4XFWZB5.js → chunk-3UOPODB3.js} +44 -44
- package/dist/{chunk-JOLM54PI.mjs → chunk-4HESZS5A.mjs} +2 -2
- package/dist/{chunk-5O6237HX.js → chunk-4RUFPPI6.js} +400 -377
- package/dist/{chunk-ZE7JKKFT.mjs → chunk-7D27E7TU.mjs} +438 -415
- package/dist/{chunk-KA2JONAP.js → chunk-A2BRI46M.js} +5 -5
- package/dist/{chunk-3SKEY32E.mjs → chunk-F2CKKG6Q.mjs} +67 -67
- package/dist/{chunk-YBTRKOE2.js → chunk-I3IRT5VH.js} +7 -7
- package/dist/chunk-IMOEZLDR.js +441 -0
- package/dist/{chunk-OU2OBBPZ.mjs → chunk-IW3B6ZJD.mjs} +646 -565
- package/dist/{chunk-NGRAUBWU.js → chunk-KXZ4MP4L.js} +277 -236
- package/dist/chunk-PU5CC4ZI.mjs +444 -0
- package/dist/{chunk-FFGR5V3H.mjs → chunk-SPH6SCTM.mjs} +1 -1
- package/dist/{chunk-J7KULRTR.js → chunk-VOD2WUH6.js} +635 -554
- package/dist/{chunk-2WPTDMN3.js → chunk-VPHA77FH.js} +61 -61
- package/dist/{chunk-QA5NZSGN.mjs → chunk-WH65CIYG.mjs} +41 -41
- package/dist/{chunk-UAEME5HT.js → chunk-Y6F6NBA7.js} +1 -1
- package/dist/{chunk-6HBFEXOW.mjs → chunk-Z2D5NSG5.mjs} +265 -224
- package/dist/{chunk-XWGIWOHV.mjs → chunk-ZL22KEHH.mjs} +2 -2
- package/dist/cli.js +182 -136
- package/dist/cli.mjs +194 -148
- package/dist/core.js +10 -10
- package/dist/core.mjs +4 -4
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/gulp.js +6 -6
- package/dist/gulp.mjs +5 -5
- package/dist/index.js +10 -10
- package/dist/index.mjs +9 -9
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +5 -5
- package/dist/presets.mjs +2 -2
- package/dist/reset.d.mts +2 -1
- package/dist/reset.d.ts +2 -1
- package/dist/reset.js +25 -21
- package/dist/reset.mjs +25 -21
- package/dist/types.d.mts +503 -474
- package/dist/types.d.ts +503 -474
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +7 -7
- package/dist/vite.mjs +6 -6
- package/dist/weapp-tw-css-import-rewrite-loader.js +2 -4
- package/dist/webpack.js +8 -8
- package/dist/webpack.mjs +7 -7
- package/dist/webpack4.js +351 -307
- package/dist/webpack4.mjs +341 -297
- package/package.json +11 -11
- package/dist/chunk-CF7VDUIE.mjs +0 -397
- package/dist/chunk-OGG7WXHZ.js +0 -394
package/dist/cli.mjs
CHANGED
|
@@ -3,17 +3,17 @@ import {
|
|
|
3
3
|
clearTailwindcssPatcherCache,
|
|
4
4
|
createPatchTargetRecorder,
|
|
5
5
|
logTailwindcssTarget
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IW3B6ZJD.mjs";
|
|
7
7
|
import {
|
|
8
8
|
findWorkspaceRoot,
|
|
9
9
|
logger
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-7D27E7TU.mjs";
|
|
11
11
|
import "./chunk-HWF5U4CI.mjs";
|
|
12
12
|
import "./chunk-OOHJLO5M.mjs";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-SPH6SCTM.mjs";
|
|
14
14
|
|
|
15
15
|
// src/cli.ts
|
|
16
|
-
import
|
|
16
|
+
import process7 from "process";
|
|
17
17
|
import semver from "semver";
|
|
18
18
|
import { createTailwindcssPatchCli } from "tailwindcss-patch";
|
|
19
19
|
|
|
@@ -34,16 +34,9 @@ function formatOutputPath(target, baseDir) {
|
|
|
34
34
|
|
|
35
35
|
// src/cli/helpers.ts
|
|
36
36
|
import { mkdir } from "fs/promises";
|
|
37
|
-
import
|
|
38
|
-
import process2 from "process";
|
|
39
|
-
|
|
40
|
-
// src/tailwindcss/index.ts
|
|
41
|
-
import { getPackageInfoSync } from "local-pkg";
|
|
42
|
-
function getTailwindcssPackageInfo(options) {
|
|
43
|
-
return getPackageInfoSync("tailwindcss", options);
|
|
44
|
-
}
|
|
37
|
+
import process4 from "process";
|
|
45
38
|
|
|
46
|
-
// src/cli/helpers.ts
|
|
39
|
+
// src/cli/helpers/options/parse.ts
|
|
47
40
|
function readStringOption(flag, value) {
|
|
48
41
|
if (value == null) {
|
|
49
42
|
return void 0;
|
|
@@ -94,6 +87,10 @@ function toBoolean(value, fallback) {
|
|
|
94
87
|
}
|
|
95
88
|
return Boolean(value);
|
|
96
89
|
}
|
|
90
|
+
|
|
91
|
+
// src/cli/helpers/options/resolve.ts
|
|
92
|
+
import path2 from "path";
|
|
93
|
+
import process2 from "process";
|
|
97
94
|
function resolveCliCwd(value) {
|
|
98
95
|
const raw = readStringOption("cwd", value);
|
|
99
96
|
if (!raw) {
|
|
@@ -101,11 +98,23 @@ function resolveCliCwd(value) {
|
|
|
101
98
|
}
|
|
102
99
|
return path2.isAbsolute(raw) ? path2.normalize(raw) : path2.resolve(process2.cwd(), raw);
|
|
103
100
|
}
|
|
101
|
+
|
|
102
|
+
// src/cli/helpers/patch-cwd.ts
|
|
103
|
+
import path3 from "path";
|
|
104
|
+
import process3 from "process";
|
|
105
|
+
|
|
106
|
+
// src/tailwindcss/index.ts
|
|
107
|
+
import { getPackageInfoSync } from "local-pkg";
|
|
108
|
+
function getTailwindcssPackageInfo(options) {
|
|
109
|
+
return getPackageInfoSync("tailwindcss", options);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/cli/helpers/patch-cwd.ts
|
|
104
113
|
function normalizeCandidatePath(baseDir, candidate) {
|
|
105
114
|
if (!candidate) {
|
|
106
115
|
return void 0;
|
|
107
116
|
}
|
|
108
|
-
return
|
|
117
|
+
return path3.isAbsolute(candidate) ? path3.normalize(candidate) : path3.resolve(baseDir, candidate);
|
|
109
118
|
}
|
|
110
119
|
function detectTailwindWorkspace(paths) {
|
|
111
120
|
for (const candidate of paths) {
|
|
@@ -119,15 +128,15 @@ function detectTailwindWorkspace(paths) {
|
|
|
119
128
|
}
|
|
120
129
|
return void 0;
|
|
121
130
|
}
|
|
122
|
-
function resolvePatchDefaultCwd(currentCwd =
|
|
123
|
-
const baseDir =
|
|
124
|
-
const explicitCwd = normalizeCandidatePath(baseDir,
|
|
131
|
+
function resolvePatchDefaultCwd(currentCwd = process3.cwd()) {
|
|
132
|
+
const baseDir = path3.normalize(currentCwd);
|
|
133
|
+
const explicitCwd = normalizeCandidatePath(baseDir, process3.env.WEAPP_TW_PATCH_CWD);
|
|
125
134
|
if (explicitCwd) {
|
|
126
135
|
return explicitCwd;
|
|
127
136
|
}
|
|
128
137
|
const workspaceRoot = findWorkspaceRoot(baseDir);
|
|
129
|
-
const initCwd = normalizeCandidatePath(baseDir,
|
|
130
|
-
const localPrefix = normalizeCandidatePath(baseDir,
|
|
138
|
+
const initCwd = normalizeCandidatePath(baseDir, process3.env.INIT_CWD);
|
|
139
|
+
const localPrefix = normalizeCandidatePath(baseDir, process3.env.npm_config_local_prefix);
|
|
131
140
|
const candidates = [
|
|
132
141
|
baseDir,
|
|
133
142
|
workspaceRoot,
|
|
@@ -140,13 +149,15 @@ function resolvePatchDefaultCwd(currentCwd = process2.cwd()) {
|
|
|
140
149
|
}
|
|
141
150
|
return initCwd ?? localPrefix ?? workspaceRoot ?? baseDir;
|
|
142
151
|
}
|
|
152
|
+
|
|
153
|
+
// src/cli/helpers.ts
|
|
143
154
|
async function ensureDir(dir) {
|
|
144
155
|
await mkdir(dir, { recursive: true });
|
|
145
156
|
}
|
|
146
157
|
function handleCliError(error) {
|
|
147
158
|
if (error instanceof Error) {
|
|
148
159
|
logger.error(error.message);
|
|
149
|
-
if (error.stack &&
|
|
160
|
+
if (error.stack && process4.env.WEAPP_TW_DEBUG === "1") {
|
|
150
161
|
logger.error(error.stack);
|
|
151
162
|
}
|
|
152
163
|
} else {
|
|
@@ -159,13 +170,52 @@ function commandAction(handler) {
|
|
|
159
170
|
await handler(...args);
|
|
160
171
|
} catch (error) {
|
|
161
172
|
handleCliError(error);
|
|
162
|
-
|
|
173
|
+
process4.exitCode = 1;
|
|
163
174
|
}
|
|
164
175
|
};
|
|
165
176
|
}
|
|
166
177
|
|
|
167
178
|
// src/cli/mount-options.ts
|
|
168
|
-
import
|
|
179
|
+
import process6 from "process";
|
|
180
|
+
|
|
181
|
+
// src/cli/mount-options/patch-status.ts
|
|
182
|
+
function formatStatusFilesHint(files) {
|
|
183
|
+
if (!files?.length) {
|
|
184
|
+
return "";
|
|
185
|
+
}
|
|
186
|
+
return ` (${files.join(", ")})`;
|
|
187
|
+
}
|
|
188
|
+
function logPatchStatusReport(report) {
|
|
189
|
+
const applied = report.entries.filter((entry) => entry.status === "applied");
|
|
190
|
+
const pending = report.entries.filter((entry) => entry.status === "not-applied");
|
|
191
|
+
const skipped = report.entries.filter(
|
|
192
|
+
(entry) => entry.status === "skipped" || entry.status === "unsupported"
|
|
193
|
+
);
|
|
194
|
+
const packageLabel = `${report.package.name ?? "tailwindcss"}@${report.package.version ?? "unknown"}`;
|
|
195
|
+
logger.info(`Patch status for ${packageLabel} (v${report.majorVersion})`);
|
|
196
|
+
if (applied.length) {
|
|
197
|
+
logger.success("Applied:");
|
|
198
|
+
applied.forEach((entry) => {
|
|
199
|
+
logger.success(` - ${entry.name}${formatStatusFilesHint(entry.files)}`);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
if (pending.length) {
|
|
203
|
+
logger.warn("Needs attention:");
|
|
204
|
+
pending.forEach((entry) => {
|
|
205
|
+
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
206
|
+
logger.warn(` - ${entry.name}${formatStatusFilesHint(entry.files)}${details}`);
|
|
207
|
+
});
|
|
208
|
+
} else {
|
|
209
|
+
logger.success("All applicable patches are applied.");
|
|
210
|
+
}
|
|
211
|
+
if (skipped.length) {
|
|
212
|
+
logger.info("Skipped:");
|
|
213
|
+
skipped.forEach((entry) => {
|
|
214
|
+
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
215
|
+
logger.info(` - ${entry.name}${details}`);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
169
219
|
|
|
170
220
|
// src/cli/patch-options.ts
|
|
171
221
|
var DEFAULT_EXTEND_LENGTH_UNITS_FEATURE = {
|
|
@@ -201,12 +251,21 @@ function buildExtendLengthUnitsOverride(options) {
|
|
|
201
251
|
}
|
|
202
252
|
|
|
203
253
|
// src/cli/workspace.ts
|
|
204
|
-
import
|
|
205
|
-
import
|
|
206
|
-
|
|
254
|
+
import path8 from "path";
|
|
255
|
+
import process5 from "process";
|
|
256
|
+
|
|
257
|
+
// src/cli/workspace/package-dirs.ts
|
|
258
|
+
import { existsSync as existsSync3 } from "fs";
|
|
259
|
+
import path6 from "path";
|
|
207
260
|
import fg from "fast-glob";
|
|
208
|
-
|
|
261
|
+
|
|
262
|
+
// src/cli/workspace/workspace-globs.ts
|
|
263
|
+
import { existsSync, readFileSync as readFileSync2 } from "fs";
|
|
264
|
+
import path4 from "path";
|
|
209
265
|
import { parse as parseYaml } from "yaml";
|
|
266
|
+
|
|
267
|
+
// src/cli/workspace/workspace-io.ts
|
|
268
|
+
import { readFileSync } from "fs";
|
|
210
269
|
function tryReadJson(file) {
|
|
211
270
|
try {
|
|
212
271
|
const content = readFileSync(file, "utf8");
|
|
@@ -215,8 +274,10 @@ function tryReadJson(file) {
|
|
|
215
274
|
return void 0;
|
|
216
275
|
}
|
|
217
276
|
}
|
|
277
|
+
|
|
278
|
+
// src/cli/workspace/workspace-globs.ts
|
|
218
279
|
function parseWorkspaceGlobsFromPackageJson(workspaceRoot) {
|
|
219
|
-
const pkgJsonPath =
|
|
280
|
+
const pkgJsonPath = path4.join(workspaceRoot, "package.json");
|
|
220
281
|
const pkg = tryReadJson(pkgJsonPath);
|
|
221
282
|
if (!pkg?.workspaces) {
|
|
222
283
|
return [];
|
|
@@ -230,24 +291,29 @@ function parseWorkspaceGlobsFromPackageJson(workspaceRoot) {
|
|
|
230
291
|
return [];
|
|
231
292
|
}
|
|
232
293
|
function parseWorkspaceGlobsFromWorkspaceFile(workspaceRoot) {
|
|
233
|
-
const workspaceFile =
|
|
294
|
+
const workspaceFile = path4.join(workspaceRoot, "pnpm-workspace.yaml");
|
|
234
295
|
if (!existsSync(workspaceFile)) {
|
|
235
296
|
return [];
|
|
236
297
|
}
|
|
237
298
|
try {
|
|
238
|
-
const parsed = parseYaml(
|
|
299
|
+
const parsed = parseYaml(readFileSync2(workspaceFile, "utf8"));
|
|
239
300
|
return Array.isArray(parsed?.packages) ? parsed.packages.filter(Boolean) : [];
|
|
240
301
|
} catch {
|
|
241
302
|
return [];
|
|
242
303
|
}
|
|
243
304
|
}
|
|
305
|
+
|
|
306
|
+
// src/cli/workspace/workspace-lock.ts
|
|
307
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
|
|
308
|
+
import path5 from "path";
|
|
309
|
+
import { parse as parseYaml2 } from "yaml";
|
|
244
310
|
function parseImportersFromLock(workspaceRoot) {
|
|
245
|
-
const lockPath =
|
|
246
|
-
if (!
|
|
311
|
+
const lockPath = path5.join(workspaceRoot, "pnpm-lock.yaml");
|
|
312
|
+
if (!existsSync2(lockPath)) {
|
|
247
313
|
return [];
|
|
248
314
|
}
|
|
249
315
|
try {
|
|
250
|
-
const parsed =
|
|
316
|
+
const parsed = parseYaml2(readFileSync3(lockPath, "utf8"));
|
|
251
317
|
const importers = parsed?.importers;
|
|
252
318
|
if (!importers) {
|
|
253
319
|
return [];
|
|
@@ -256,16 +322,18 @@ function parseImportersFromLock(workspaceRoot) {
|
|
|
256
322
|
if (!key || key === ".") {
|
|
257
323
|
return workspaceRoot;
|
|
258
324
|
}
|
|
259
|
-
return
|
|
325
|
+
return path5.join(workspaceRoot, key);
|
|
260
326
|
});
|
|
261
327
|
} catch {
|
|
262
328
|
return [];
|
|
263
329
|
}
|
|
264
330
|
}
|
|
331
|
+
|
|
332
|
+
// src/cli/workspace/package-dirs.ts
|
|
265
333
|
async function resolveWorkspacePackageDirs(workspaceRoot) {
|
|
266
334
|
const dirs = /* @__PURE__ */ new Set();
|
|
267
335
|
for (const importerDir of parseImportersFromLock(workspaceRoot)) {
|
|
268
|
-
dirs.add(
|
|
336
|
+
dirs.add(path6.normalize(importerDir));
|
|
269
337
|
}
|
|
270
338
|
if (!dirs.size) {
|
|
271
339
|
let globs = parseWorkspaceGlobsFromWorkspaceFile(workspaceRoot);
|
|
@@ -285,16 +353,34 @@ async function resolveWorkspacePackageDirs(workspaceRoot) {
|
|
|
285
353
|
ignore: ["**/node_modules/**", "**/.git/**"]
|
|
286
354
|
});
|
|
287
355
|
for (const file of packageJsonFiles) {
|
|
288
|
-
dirs.add(
|
|
356
|
+
dirs.add(path6.normalize(path6.dirname(file)));
|
|
289
357
|
}
|
|
290
358
|
}
|
|
291
359
|
}
|
|
292
|
-
const rootPkg =
|
|
293
|
-
if (
|
|
294
|
-
dirs.add(
|
|
360
|
+
const rootPkg = path6.join(workspaceRoot, "package.json");
|
|
361
|
+
if (existsSync3(rootPkg)) {
|
|
362
|
+
dirs.add(path6.normalize(workspaceRoot));
|
|
295
363
|
}
|
|
296
364
|
return [...dirs];
|
|
297
365
|
}
|
|
366
|
+
|
|
367
|
+
// src/cli/workspace/patch-package.ts
|
|
368
|
+
import { normalizeOptions, TailwindcssPatcher } from "tailwindcss-patch";
|
|
369
|
+
|
|
370
|
+
// src/cli/workspace/patch-utils.ts
|
|
371
|
+
import path7 from "path";
|
|
372
|
+
function formatDisplayName(workspaceRoot, dir, name) {
|
|
373
|
+
const relative = path7.relative(workspaceRoot, dir) || ".";
|
|
374
|
+
return name ? `${name} (${relative})` : relative;
|
|
375
|
+
}
|
|
376
|
+
function summarizeWorkspaceResults(results) {
|
|
377
|
+
const patched = results.filter((result) => result.status === "patched").length;
|
|
378
|
+
const skipped = results.filter((result) => result.status === "skipped").length;
|
|
379
|
+
const failed = results.filter((result) => result.status === "failed").length;
|
|
380
|
+
logger.info("[workspace] \u6C47\u603B\uFF1A\u5DF2\u8865\u4E01 %d\uFF0C\u8DF3\u8FC7 %d\uFF0C\u5931\u8D25 %d", patched, skipped, failed);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// src/cli/workspace/patch-package.ts
|
|
298
384
|
function createWorkspacePatcher(cwd) {
|
|
299
385
|
const normalized = normalizeOptions(
|
|
300
386
|
withDefaultExtendLengthUnits({
|
|
@@ -303,12 +389,61 @@ function createWorkspacePatcher(cwd) {
|
|
|
303
389
|
);
|
|
304
390
|
return new TailwindcssPatcher(normalized);
|
|
305
391
|
}
|
|
306
|
-
function
|
|
307
|
-
const
|
|
308
|
-
|
|
392
|
+
async function patchWorkspacePackage(workspaceRoot, dir, pkgName, options) {
|
|
393
|
+
const displayName = formatDisplayName(workspaceRoot, dir, pkgName);
|
|
394
|
+
const tailwindInfo = getTailwindcssPackageInfo({ paths: [dir] });
|
|
395
|
+
if (!tailwindInfo?.rootPath) {
|
|
396
|
+
logger.info("[workspace] \u8DF3\u8FC7 %s\uFF08tailwindcss \u672A\u5B89\u88C5\uFF09\u3002", displayName);
|
|
397
|
+
return {
|
|
398
|
+
dir,
|
|
399
|
+
name: pkgName,
|
|
400
|
+
status: "skipped",
|
|
401
|
+
message: "tailwindcss \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
try {
|
|
405
|
+
const patcher = createWorkspacePatcher(dir);
|
|
406
|
+
if (options.clearCache) {
|
|
407
|
+
await clearTailwindcssPatcherCache(patcher, { removeDirectory: true });
|
|
408
|
+
}
|
|
409
|
+
const recorder = createPatchTargetRecorder(dir, patcher, {
|
|
410
|
+
source: "cli",
|
|
411
|
+
cwd: dir,
|
|
412
|
+
recordTarget: options.recordTarget !== false,
|
|
413
|
+
alwaysRecord: true
|
|
414
|
+
});
|
|
415
|
+
if (recorder?.message) {
|
|
416
|
+
logger.info("[workspace] %s %s", displayName, recorder.message);
|
|
417
|
+
}
|
|
418
|
+
logTailwindcssTarget("cli", patcher, dir);
|
|
419
|
+
await patcher.patch();
|
|
420
|
+
if (recorder?.onPatched) {
|
|
421
|
+
await recorder.onPatched();
|
|
422
|
+
}
|
|
423
|
+
logger.success("[workspace] \u5DF2\u8865\u4E01 %s", displayName);
|
|
424
|
+
return {
|
|
425
|
+
dir,
|
|
426
|
+
name: pkgName,
|
|
427
|
+
status: "patched",
|
|
428
|
+
message: "\u5DF2\u5B8C\u6210 patch\u3002"
|
|
429
|
+
};
|
|
430
|
+
} catch (error) {
|
|
431
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
432
|
+
const suggestion = `\u8BF7\u5728 ${dir} \u8FD0\u884C "weapp-tw patch --cwd ${dir}".`;
|
|
433
|
+
const message = `${reason}\uFF0C${suggestion}`;
|
|
434
|
+
logger.error("[workspace] \u8865\u4E01\u5931\u8D25 %s\uFF1A%s", displayName, message);
|
|
435
|
+
return {
|
|
436
|
+
dir,
|
|
437
|
+
name: pkgName,
|
|
438
|
+
status: "failed",
|
|
439
|
+
message
|
|
440
|
+
};
|
|
441
|
+
}
|
|
309
442
|
}
|
|
443
|
+
|
|
444
|
+
// src/cli/workspace.ts
|
|
310
445
|
async function patchWorkspace(options) {
|
|
311
|
-
const cwd = options.cwd ??
|
|
446
|
+
const cwd = options.cwd ?? process5.cwd();
|
|
312
447
|
const workspaceRoot = findWorkspaceRoot(cwd) ?? cwd;
|
|
313
448
|
const packageDirs = await resolveWorkspacePackageDirs(workspaceRoot);
|
|
314
449
|
if (packageDirs.length === 0) {
|
|
@@ -317,70 +452,18 @@ async function patchWorkspace(options) {
|
|
|
317
452
|
}
|
|
318
453
|
const results = [];
|
|
319
454
|
for (const dir of packageDirs) {
|
|
320
|
-
const pkgJsonPath =
|
|
455
|
+
const pkgJsonPath = path8.join(dir, "package.json");
|
|
321
456
|
const pkgJson = tryReadJson(pkgJsonPath);
|
|
322
|
-
|
|
323
|
-
const tailwindInfo = getTailwindcssPackageInfo({ paths: [dir] });
|
|
324
|
-
if (!tailwindInfo?.rootPath) {
|
|
325
|
-
results.push({
|
|
326
|
-
dir,
|
|
327
|
-
name: pkgJson?.name,
|
|
328
|
-
status: "skipped",
|
|
329
|
-
message: "tailwindcss \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
330
|
-
});
|
|
331
|
-
logger.info("[workspace] \u8DF3\u8FC7 %s\uFF08tailwindcss \u672A\u5B89\u88C5\uFF09\u3002", displayName);
|
|
332
|
-
continue;
|
|
333
|
-
}
|
|
334
|
-
try {
|
|
335
|
-
const patcher = createWorkspacePatcher(dir);
|
|
336
|
-
if (options.clearCache) {
|
|
337
|
-
await clearTailwindcssPatcherCache(patcher, { removeDirectory: true });
|
|
338
|
-
}
|
|
339
|
-
const recorder = createPatchTargetRecorder(dir, patcher, {
|
|
340
|
-
source: "cli",
|
|
341
|
-
cwd: dir,
|
|
342
|
-
recordTarget: options.recordTarget !== false,
|
|
343
|
-
alwaysRecord: true
|
|
344
|
-
});
|
|
345
|
-
if (recorder?.message) {
|
|
346
|
-
logger.info("[workspace] %s %s", displayName, recorder.message);
|
|
347
|
-
}
|
|
348
|
-
logTailwindcssTarget("cli", patcher, dir);
|
|
349
|
-
await patcher.patch();
|
|
350
|
-
if (recorder?.onPatched) {
|
|
351
|
-
await recorder.onPatched();
|
|
352
|
-
}
|
|
353
|
-
results.push({
|
|
354
|
-
dir,
|
|
355
|
-
name: pkgJson?.name,
|
|
356
|
-
status: "patched",
|
|
357
|
-
message: "\u5DF2\u5B8C\u6210 patch\u3002"
|
|
358
|
-
});
|
|
359
|
-
logger.success("[workspace] \u5DF2\u8865\u4E01 %s", displayName);
|
|
360
|
-
} catch (error) {
|
|
361
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
362
|
-
const suggestion = `\u8BF7\u5728 ${dir} \u8FD0\u884C "weapp-tw patch --cwd ${dir}".`;
|
|
363
|
-
const message = `${reason}\uFF0C${suggestion}`;
|
|
364
|
-
results.push({
|
|
365
|
-
dir,
|
|
366
|
-
name: pkgJson?.name,
|
|
367
|
-
status: "failed",
|
|
368
|
-
message
|
|
369
|
-
});
|
|
370
|
-
logger.error("[workspace] \u8865\u4E01\u5931\u8D25 %s\uFF1A%s", displayName, message);
|
|
371
|
-
}
|
|
457
|
+
results.push(await patchWorkspacePackage(workspaceRoot, dir, pkgJson?.name, options));
|
|
372
458
|
}
|
|
373
|
-
|
|
374
|
-
const skipped = results.filter((result) => result.status === "skipped").length;
|
|
375
|
-
const failed = results.filter((result) => result.status === "failed").length;
|
|
376
|
-
logger.info("[workspace] \u6C47\u603B\uFF1A\u5DF2\u8865\u4E01 %d\uFF0C\u8DF3\u8FC7 %d\uFF0C\u5931\u8D25 %d", patched, skipped, failed);
|
|
459
|
+
summarizeWorkspaceResults(results);
|
|
377
460
|
}
|
|
378
461
|
|
|
379
462
|
// src/cli/mount-options.ts
|
|
380
463
|
function handleCliError2(error) {
|
|
381
464
|
if (error instanceof Error) {
|
|
382
465
|
logger.error(error.message);
|
|
383
|
-
if (error.stack &&
|
|
466
|
+
if (error.stack && process6.env.WEAPP_TW_DEBUG === "1") {
|
|
384
467
|
logger.error(error.stack);
|
|
385
468
|
}
|
|
386
469
|
} else {
|
|
@@ -393,7 +476,7 @@ function withCommandErrorHandling(handler) {
|
|
|
393
476
|
return await handler(ctx, next);
|
|
394
477
|
} catch (error) {
|
|
395
478
|
handleCliError2(error);
|
|
396
|
-
|
|
479
|
+
process6.exitCode = 1;
|
|
397
480
|
return void 0;
|
|
398
481
|
}
|
|
399
482
|
});
|
|
@@ -406,43 +489,6 @@ async function createPatcherWithDefaultExtendLengthUnits(ctx) {
|
|
|
406
489
|
}
|
|
407
490
|
return ctx.createPatcher();
|
|
408
491
|
}
|
|
409
|
-
function formatStatusFilesHint(files) {
|
|
410
|
-
if (!files?.length) {
|
|
411
|
-
return "";
|
|
412
|
-
}
|
|
413
|
-
return ` (${files.join(", ")})`;
|
|
414
|
-
}
|
|
415
|
-
function logPatchStatusReport(report) {
|
|
416
|
-
const applied = report.entries.filter((entry) => entry.status === "applied");
|
|
417
|
-
const pending = report.entries.filter((entry) => entry.status === "not-applied");
|
|
418
|
-
const skipped = report.entries.filter(
|
|
419
|
-
(entry) => entry.status === "skipped" || entry.status === "unsupported"
|
|
420
|
-
);
|
|
421
|
-
const packageLabel = `${report.package.name ?? "tailwindcss"}@${report.package.version ?? "unknown"}`;
|
|
422
|
-
logger.info(`Patch status for ${packageLabel} (v${report.majorVersion})`);
|
|
423
|
-
if (applied.length) {
|
|
424
|
-
logger.success("Applied:");
|
|
425
|
-
applied.forEach((entry) => {
|
|
426
|
-
logger.success(` - ${entry.name}${formatStatusFilesHint(entry.files)}`);
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
if (pending.length) {
|
|
430
|
-
logger.warn("Needs attention:");
|
|
431
|
-
pending.forEach((entry) => {
|
|
432
|
-
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
433
|
-
logger.warn(` - ${entry.name}${formatStatusFilesHint(entry.files)}${details}`);
|
|
434
|
-
});
|
|
435
|
-
} else {
|
|
436
|
-
logger.success("All applicable patches are applied.");
|
|
437
|
-
}
|
|
438
|
-
if (skipped.length) {
|
|
439
|
-
logger.info("Skipped:");
|
|
440
|
-
skipped.forEach((entry) => {
|
|
441
|
-
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
442
|
-
logger.info(` - ${entry.name}${details}`);
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
492
|
var mountOptions = {
|
|
447
493
|
commandOptions: {
|
|
448
494
|
install: {
|
|
@@ -540,7 +586,7 @@ var mountOptions = {
|
|
|
540
586
|
// src/cli/vscode-entry.ts
|
|
541
587
|
import { constants } from "fs";
|
|
542
588
|
import { access, writeFile } from "fs/promises";
|
|
543
|
-
import
|
|
589
|
+
import path9 from "path";
|
|
544
590
|
var DEFAULT_VSCODE_ENTRY_OUTPUT = ".vscode/weapp-tailwindcss.intellisense.css";
|
|
545
591
|
var DEFAULT_VSCODE_SOURCES = [
|
|
546
592
|
'not "./dist"',
|
|
@@ -612,16 +658,16 @@ function formatSource(pattern) {
|
|
|
612
658
|
}
|
|
613
659
|
function resolveOutputPath(baseDir, output) {
|
|
614
660
|
const target = output ?? DEFAULT_VSCODE_ENTRY_OUTPUT;
|
|
615
|
-
return
|
|
661
|
+
return path9.isAbsolute(target) ? path9.normalize(target) : path9.resolve(baseDir, target);
|
|
616
662
|
}
|
|
617
663
|
function resolveCssEntry(baseDir, entry) {
|
|
618
|
-
return
|
|
664
|
+
return path9.isAbsolute(entry) ? path9.normalize(entry) : path9.resolve(baseDir, entry);
|
|
619
665
|
}
|
|
620
666
|
function toRelativeImport(fromFile, targetFile) {
|
|
621
|
-
const fromDir =
|
|
622
|
-
let relative =
|
|
667
|
+
const fromDir = path9.dirname(fromFile);
|
|
668
|
+
let relative = path9.relative(fromDir, targetFile);
|
|
623
669
|
if (!relative) {
|
|
624
|
-
relative =
|
|
670
|
+
relative = path9.basename(targetFile);
|
|
625
671
|
}
|
|
626
672
|
if (!relative.startsWith(".")) {
|
|
627
673
|
relative = `./${relative}`;
|
|
@@ -633,7 +679,7 @@ async function generateVscodeIntellisenseEntry(options) {
|
|
|
633
679
|
const cssEntryPath = resolveCssEntry(baseDir, options.cssEntry);
|
|
634
680
|
await assertFileExists(cssEntryPath);
|
|
635
681
|
const outputPath = resolveOutputPath(baseDir, options.output);
|
|
636
|
-
await ensureDir(
|
|
682
|
+
await ensureDir(path9.dirname(outputPath));
|
|
637
683
|
await assertCanWrite(outputPath, options.force);
|
|
638
684
|
const sources = options.sources && options.sources.length > 0 ? options.sources : DEFAULT_VSCODE_SOURCES;
|
|
639
685
|
const formattedSources = sources.map(formatSource).filter((statement) => Boolean(statement));
|
|
@@ -658,10 +704,10 @@ async function generateVscodeIntellisenseEntry(options) {
|
|
|
658
704
|
}
|
|
659
705
|
|
|
660
706
|
// src/cli.ts
|
|
661
|
-
|
|
662
|
-
if (semver.lt(
|
|
707
|
+
process7.title = "node (weapp-tailwindcss)";
|
|
708
|
+
if (semver.lt(process7.versions.node, WEAPP_TW_REQUIRED_NODE_VERSION)) {
|
|
663
709
|
logger.warn(
|
|
664
|
-
`You are using Node.js ${
|
|
710
|
+
`You are using Node.js ${process7.versions.node}. For weapp-tailwindcss, Node.js version >= v${WEAPP_TW_REQUIRED_NODE_VERSION} is required.`
|
|
665
711
|
);
|
|
666
712
|
}
|
|
667
713
|
var cli = createTailwindcssPatchCli({
|
|
@@ -671,7 +717,7 @@ var cli = createTailwindcssPatchCli({
|
|
|
671
717
|
cli.command("vscode-entry", "Generate a VS Code helper CSS for Tailwind IntelliSense").option("--cwd <dir>", "Working directory").option("--css <file>", "Path to the CSS file that imports weapp-tailwindcss (required)").option("--output <file>", `Helper output path. Defaults to ${DEFAULT_VSCODE_ENTRY_OUTPUT}`).option("--source <pattern>", "Additional @source glob (can be repeated)").option("--force", "Overwrite the helper file when it already exists").action(
|
|
672
718
|
commandAction(async (options) => {
|
|
673
719
|
const resolvedCwd = resolveCliCwd(options.cwd);
|
|
674
|
-
const baseDir = resolvedCwd ??
|
|
720
|
+
const baseDir = resolvedCwd ?? process7.cwd();
|
|
675
721
|
const cssEntry = readStringOption("css", options.css);
|
|
676
722
|
if (!cssEntry) {
|
|
677
723
|
throw new Error('Option "--css" is required.');
|
|
@@ -692,5 +738,5 @@ cli.command("vscode-entry", "Generate a VS Code helper CSS for Tailwind IntelliS
|
|
|
692
738
|
})
|
|
693
739
|
);
|
|
694
740
|
cli.help();
|
|
695
|
-
cli.version(
|
|
741
|
+
cli.version(process7.env.npm_package_version ?? "0.0.0");
|
|
696
742
|
cli.parse();
|
package/dist/core.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkA2BRI46Mjs = require('./chunk-A2BRI46M.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
require('./chunk-
|
|
8
|
+
var _chunkVOD2WUH6js = require('./chunk-VOD2WUH6.js');
|
|
9
|
+
require('./chunk-4RUFPPI6.js');
|
|
10
10
|
require('./chunk-FYYBY3VK.js');
|
|
11
11
|
require('./chunk-DYLQ6UOI.js');
|
|
12
|
-
require('./chunk-
|
|
12
|
+
require('./chunk-Y6F6NBA7.js');
|
|
13
13
|
|
|
14
14
|
// src/core.ts
|
|
15
15
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
16
16
|
var _shared = require('@weapp-tailwindcss/shared');
|
|
17
17
|
function createContext(options = {}) {
|
|
18
|
-
const opts =
|
|
18
|
+
const opts = _chunkVOD2WUH6js.getCompilerContext.call(void 0, options);
|
|
19
19
|
const { templateHandler, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
20
|
-
const patchRecorderState =
|
|
20
|
+
const patchRecorderState = _chunkA2BRI46Mjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
|
|
21
21
|
source: "runtime",
|
|
22
22
|
cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
23
23
|
});
|
|
@@ -29,7 +29,7 @@ function createContext(options = {}) {
|
|
|
29
29
|
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
30
30
|
};
|
|
31
31
|
async function refreshRuntimeState(force) {
|
|
32
|
-
await
|
|
32
|
+
await _chunkVOD2WUH6js.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
|
|
33
33
|
}
|
|
34
34
|
async function transformWxss(rawCss, options2) {
|
|
35
35
|
await runtimeState.patchPromise;
|
|
@@ -38,7 +38,7 @@ function createContext(options = {}) {
|
|
|
38
38
|
}));
|
|
39
39
|
await refreshRuntimeState(true);
|
|
40
40
|
await runtimeState.patchPromise;
|
|
41
|
-
runtimeSet = await
|
|
41
|
+
runtimeSet = await _chunkVOD2WUH6js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
42
42
|
return result;
|
|
43
43
|
}
|
|
44
44
|
async function transformJs(rawJs, options2 = {}) {
|
|
@@ -48,7 +48,7 @@ function createContext(options = {}) {
|
|
|
48
48
|
} else {
|
|
49
49
|
await refreshRuntimeState(true);
|
|
50
50
|
await runtimeState.patchPromise;
|
|
51
|
-
runtimeSet = await
|
|
51
|
+
runtimeSet = await _chunkVOD2WUH6js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
52
52
|
}
|
|
53
53
|
return await jsHandler(rawJs, runtimeSet, options2);
|
|
54
54
|
}
|
|
@@ -57,7 +57,7 @@ function createContext(options = {}) {
|
|
|
57
57
|
if (!_optionalChain([options2, 'optionalAccess', _2 => _2.runtimeSet]) && runtimeSet.size === 0) {
|
|
58
58
|
await refreshRuntimeState(true);
|
|
59
59
|
await runtimeState.patchPromise;
|
|
60
|
-
runtimeSet = await
|
|
60
|
+
runtimeSet = await _chunkVOD2WUH6js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
61
61
|
}
|
|
62
62
|
return templateHandler(rawWxml, _shared.defuOverrideArray.call(void 0, options2, {
|
|
63
63
|
runtimeSet
|
package/dist/core.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
setupPatchRecorder
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZL22KEHH.mjs";
|
|
4
4
|
import {
|
|
5
5
|
collectRuntimeClassSet,
|
|
6
6
|
getCompilerContext,
|
|
7
7
|
refreshTailwindRuntimeState
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-IW3B6ZJD.mjs";
|
|
9
|
+
import "./chunk-7D27E7TU.mjs";
|
|
10
10
|
import "./chunk-HWF5U4CI.mjs";
|
|
11
11
|
import "./chunk-OOHJLO5M.mjs";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-SPH6SCTM.mjs";
|
|
13
13
|
|
|
14
14
|
// src/core.ts
|
|
15
15
|
import process from "process";
|
package/dist/css-macro.js
CHANGED
|
@@ -5,7 +5,7 @@ var _chunkNS3NEDWDjs = require('./chunk-NS3NEDWD.js');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
|
|
8
|
-
require('./chunk-
|
|
8
|
+
require('./chunk-Y6F6NBA7.js');
|
|
9
9
|
|
|
10
10
|
// src/css-macro/index.ts
|
|
11
11
|
var _plugin = require('tailwindcss/plugin'); var _plugin2 = _interopRequireDefault(_plugin);
|