tailwindcss-patch 9.0.0-alpha.3 → 9.0.0-alpha.5
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-D6ICWMM4.mjs → chunk-4BA7N3QJ.mjs} +17 -10
- package/dist/{chunk-77GHKSKG.js → chunk-A7IKQTXK.js} +19 -12
- package/dist/{chunk-A67ABH3M.mjs → chunk-OSH52QWA.mjs} +1 -1
- package/dist/{chunk-PMN7HS4Y.js → chunk-QQXAOMUH.js} +2 -2
- package/dist/{chunk-5CWNAWKP.js → chunk-ZPLR2UEW.js} +1 -1
- package/dist/cli.js +6 -6
- package/dist/cli.mjs +2 -2
- package/dist/commands/cli-runtime.js +307 -337
- package/dist/commands/cli-runtime.mjs +241 -271
- package/dist/{dist-7O2232CU.js → dist-22YCNIJW.js} +1 -1
- package/dist/{dist-7UDSGIWH.mjs → dist-7W73GIRD.mjs} +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +2 -2
- package/package.json +7 -7
- package/src/runtime/class-collector.ts +10 -1
|
@@ -11,10 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
require('../chunk-
|
|
14
|
+
var _chunkA7IKQTXKjs = require('../chunk-A7IKQTXK.js');
|
|
15
|
+
require('../chunk-ZPLR2UEW.js');
|
|
16
16
|
|
|
17
|
-
// ../../node_modules/.pnpm/cac@7.
|
|
17
|
+
// ../../node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
|
|
18
|
+
var _events = require('events');
|
|
18
19
|
function toArr(any) {
|
|
19
20
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
20
21
|
}
|
|
@@ -22,7 +23,7 @@ function toVal(out, key, val, opts) {
|
|
|
22
23
|
var x, old = out[key], nxt = !!~opts.string.indexOf(key) ? val == null || val === true ? "" : String(val) : typeof val === "boolean" ? val : !!~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
|
|
23
24
|
out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function mri2(args, opts) {
|
|
26
27
|
args = args || [];
|
|
27
28
|
opts = opts || {};
|
|
28
29
|
var k, arr, arg, name, val, out = { _: [] };
|
|
@@ -33,9 +34,13 @@ function lib_default(args, opts) {
|
|
|
33
34
|
opts.alias = opts.alias || {};
|
|
34
35
|
opts.string = toArr(opts.string);
|
|
35
36
|
opts.boolean = toArr(opts.boolean);
|
|
36
|
-
if (alibi)
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
if (alibi) {
|
|
38
|
+
for (k in opts.alias) {
|
|
39
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
40
|
+
for (i = 0; i < arr.length; i++) {
|
|
41
|
+
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
for (i = opts.boolean.length; i-- > 0; ) {
|
|
41
46
|
arr = opts.alias[opts.boolean[i]] || [];
|
|
@@ -45,12 +50,16 @@ function lib_default(args, opts) {
|
|
|
45
50
|
arr = opts.alias[opts.string[i]] || [];
|
|
46
51
|
for (j = arr.length; j-- > 0; ) opts.string.push(arr[j]);
|
|
47
52
|
}
|
|
48
|
-
if (defaults)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
opts[name]
|
|
53
|
-
|
|
53
|
+
if (defaults) {
|
|
54
|
+
for (k in opts.default) {
|
|
55
|
+
name = typeof opts.default[k];
|
|
56
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
57
|
+
if (opts[name] !== void 0) {
|
|
58
|
+
opts[name].push(k);
|
|
59
|
+
for (i = 0; i < arr.length; i++) {
|
|
60
|
+
opts[name].push(arr[i]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
54
63
|
}
|
|
55
64
|
}
|
|
56
65
|
const keys = strict ? Object.keys(opts.alias) : [];
|
|
@@ -60,16 +69,23 @@ function lib_default(args, opts) {
|
|
|
60
69
|
out._ = out._.concat(args.slice(++i));
|
|
61
70
|
break;
|
|
62
71
|
}
|
|
63
|
-
for (j = 0; j < arg.length; j++)
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
for (j = 0; j < arg.length; j++) {
|
|
73
|
+
if (arg.charCodeAt(j) !== 45) break;
|
|
74
|
+
}
|
|
75
|
+
if (j === 0) {
|
|
76
|
+
out._.push(arg);
|
|
77
|
+
} else if (arg.substring(j, j + 3) === "no-") {
|
|
66
78
|
name = arg.substring(j + 3);
|
|
67
|
-
if (strict && !~keys.indexOf(name))
|
|
79
|
+
if (strict && !~keys.indexOf(name)) {
|
|
80
|
+
return opts.unknown(arg);
|
|
81
|
+
}
|
|
68
82
|
out[name] = false;
|
|
69
83
|
} else {
|
|
70
|
-
for (idx = j + 1; idx < arg.length; idx++)
|
|
84
|
+
for (idx = j + 1; idx < arg.length; idx++) {
|
|
85
|
+
if (arg.charCodeAt(idx) === 61) break;
|
|
86
|
+
}
|
|
71
87
|
name = arg.substring(j, idx);
|
|
72
|
-
val = arg.substring(++idx) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
|
|
88
|
+
val = arg.substring(++idx) || (i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i]);
|
|
73
89
|
arr = j === 2 ? [name] : name;
|
|
74
90
|
for (idx = 0; idx < arr.length; idx++) {
|
|
75
91
|
name = arr[idx];
|
|
@@ -79,18 +95,24 @@ function lib_default(args, opts) {
|
|
|
79
95
|
}
|
|
80
96
|
}
|
|
81
97
|
if (defaults) {
|
|
82
|
-
for (k in opts.default)
|
|
98
|
+
for (k in opts.default) {
|
|
99
|
+
if (out[k] === void 0) {
|
|
100
|
+
out[k] = opts.default[k];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
83
103
|
}
|
|
84
|
-
if (alibi)
|
|
85
|
-
|
|
86
|
-
|
|
104
|
+
if (alibi) {
|
|
105
|
+
for (k in out) {
|
|
106
|
+
arr = opts.alias[k] || [];
|
|
107
|
+
while (arr.length > 0) {
|
|
108
|
+
out[arr.shift()] = out[k];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
87
111
|
}
|
|
88
112
|
return out;
|
|
89
113
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
function findAllBrackets(v) {
|
|
114
|
+
var removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
|
|
115
|
+
var findAllBrackets = (v) => {
|
|
94
116
|
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
95
117
|
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
96
118
|
const res = [];
|
|
@@ -108,95 +130,96 @@ function findAllBrackets(v) {
|
|
|
108
130
|
};
|
|
109
131
|
};
|
|
110
132
|
let angledMatch;
|
|
111
|
-
while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v))
|
|
133
|
+
while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) {
|
|
134
|
+
res.push(parse(angledMatch));
|
|
135
|
+
}
|
|
112
136
|
let squareMatch;
|
|
113
|
-
while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v))
|
|
137
|
+
while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) {
|
|
138
|
+
res.push(parse(squareMatch));
|
|
139
|
+
}
|
|
114
140
|
return res;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const result = {
|
|
118
|
-
alias: {},
|
|
119
|
-
boolean: []
|
|
120
|
-
};
|
|
141
|
+
};
|
|
142
|
+
var getMriOptions = (options) => {
|
|
143
|
+
const result = { alias: {}, boolean: [] };
|
|
121
144
|
for (const [index, option] of options.entries()) {
|
|
122
|
-
if (option.names.length > 1)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
145
|
+
if (option.names.length > 1) {
|
|
146
|
+
result.alias[option.names[0]] = option.names.slice(1);
|
|
147
|
+
}
|
|
148
|
+
if (option.isBoolean) {
|
|
149
|
+
if (option.negated) {
|
|
150
|
+
const hasStringTypeOption = options.some((o, i) => {
|
|
151
|
+
return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
|
|
152
|
+
});
|
|
153
|
+
if (!hasStringTypeOption) {
|
|
154
|
+
result.boolean.push(option.names[0]);
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
result.boolean.push(option.names[0]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
128
160
|
}
|
|
129
161
|
return result;
|
|
130
|
-
}
|
|
131
|
-
|
|
162
|
+
};
|
|
163
|
+
var findLongest = (arr) => {
|
|
132
164
|
return arr.sort((a, b) => {
|
|
133
165
|
return a.length > b.length ? -1 : 1;
|
|
134
166
|
})[0];
|
|
135
|
-
}
|
|
136
|
-
|
|
167
|
+
};
|
|
168
|
+
var padRight = (str, length) => {
|
|
137
169
|
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return input.
|
|
170
|
+
};
|
|
171
|
+
var camelcase = (input) => {
|
|
172
|
+
return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
|
|
141
173
|
return p1 + p2.toUpperCase();
|
|
142
174
|
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
let
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
if (current[key] == null) {
|
|
153
|
-
const nextKeyIsArrayIndex = +keys[i + 1] > -1;
|
|
154
|
-
current[key] = nextKeyIsArrayIndex ? [] : {};
|
|
155
|
-
}
|
|
156
|
-
current = current[key];
|
|
175
|
+
};
|
|
176
|
+
var setDotProp = (obj, keys, val) => {
|
|
177
|
+
let i = 0;
|
|
178
|
+
let length = keys.length;
|
|
179
|
+
let t = obj;
|
|
180
|
+
let x;
|
|
181
|
+
for (; i < length; ++i) {
|
|
182
|
+
x = t[keys[i]];
|
|
183
|
+
t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
|
|
157
184
|
}
|
|
158
|
-
}
|
|
159
|
-
|
|
185
|
+
};
|
|
186
|
+
var setByType = (obj, transforms) => {
|
|
160
187
|
for (const key of Object.keys(transforms)) {
|
|
161
188
|
const transform = transforms[key];
|
|
162
189
|
if (transform.shouldTransform) {
|
|
163
|
-
obj[key] = [obj[key]
|
|
164
|
-
if (typeof transform.transformFunction === "function")
|
|
190
|
+
obj[key] = Array.prototype.concat.call([], obj[key]);
|
|
191
|
+
if (typeof transform.transformFunction === "function") {
|
|
192
|
+
obj[key] = obj[key].map(transform.transformFunction);
|
|
193
|
+
}
|
|
165
194
|
}
|
|
166
195
|
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const m = /([
|
|
196
|
+
};
|
|
197
|
+
var getFileName = (input) => {
|
|
198
|
+
const m = /([^\\\/]+)$/.exec(input);
|
|
170
199
|
return m ? m[1] : "";
|
|
171
|
-
}
|
|
172
|
-
|
|
200
|
+
};
|
|
201
|
+
var camelcaseOptionName = (name) => {
|
|
173
202
|
return name.split(".").map((v, i) => {
|
|
174
203
|
return i === 0 ? camelcase(v) : v;
|
|
175
204
|
}).join(".");
|
|
176
|
-
}
|
|
205
|
+
};
|
|
177
206
|
var CACError = class extends Error {
|
|
178
207
|
constructor(message) {
|
|
179
208
|
super(message);
|
|
180
|
-
this.name =
|
|
181
|
-
if (typeof Error.captureStackTrace
|
|
209
|
+
this.name = this.constructor.name;
|
|
210
|
+
if (typeof Error.captureStackTrace === "function") {
|
|
211
|
+
Error.captureStackTrace(this, this.constructor);
|
|
212
|
+
} else {
|
|
213
|
+
this.stack = new Error(message).stack;
|
|
214
|
+
}
|
|
182
215
|
}
|
|
183
216
|
};
|
|
184
217
|
var Option = class {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
/** Option name */
|
|
188
|
-
|
|
189
|
-
/** Option name and aliases */
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
218
|
constructor(rawName, description, config) {
|
|
196
219
|
this.rawName = rawName;
|
|
197
220
|
this.description = description;
|
|
198
221
|
this.config = Object.assign({}, config);
|
|
199
|
-
rawName = rawName.
|
|
222
|
+
rawName = rawName.replace(/\.\*/g, "");
|
|
200
223
|
this.negated = false;
|
|
201
224
|
this.names = removeBrackets(rawName).split(",").map((v) => {
|
|
202
225
|
let name = v.trim().replace(/^-{1,2}/, "");
|
|
@@ -206,39 +229,22 @@ var Option = class {
|
|
|
206
229
|
}
|
|
207
230
|
return camelcaseOptionName(name);
|
|
208
231
|
}).sort((a, b) => a.length > b.length ? 1 : -1);
|
|
209
|
-
this.name = this.names.
|
|
210
|
-
if (this.negated && this.config.default == null)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
232
|
+
this.name = this.names[this.names.length - 1];
|
|
233
|
+
if (this.negated && this.config.default == null) {
|
|
234
|
+
this.config.default = true;
|
|
235
|
+
}
|
|
236
|
+
if (rawName.includes("<")) {
|
|
237
|
+
this.required = true;
|
|
238
|
+
} else if (rawName.includes("[")) {
|
|
239
|
+
this.required = false;
|
|
240
|
+
} else {
|
|
241
|
+
this.isBoolean = true;
|
|
242
|
+
}
|
|
214
243
|
}
|
|
215
244
|
};
|
|
216
|
-
var
|
|
217
|
-
var
|
|
218
|
-
if (typeof process !== "undefined") {
|
|
219
|
-
let runtimeName;
|
|
220
|
-
if (typeof Deno !== "undefined" && typeof _optionalChain([Deno, 'access', _2 => _2.version, 'optionalAccess', _3 => _3.deno]) === "string") runtimeName = "deno";
|
|
221
|
-
else if (typeof Bun !== "undefined" && typeof Bun.version === "string") runtimeName = "bun";
|
|
222
|
-
else runtimeName = "node";
|
|
223
|
-
runtimeInfo = `${process.platform}-${process.arch} ${runtimeName}-${process.version}`;
|
|
224
|
-
runtimeProcessArgs = process.argv;
|
|
225
|
-
} else if (typeof navigator === "undefined") runtimeInfo = `unknown`;
|
|
226
|
-
else runtimeInfo = `${navigator.platform} ${navigator.userAgent}`;
|
|
245
|
+
var processArgs = process.argv;
|
|
246
|
+
var platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
227
247
|
var Command = class {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
248
|
constructor(rawName, description, config = {}, cli) {
|
|
243
249
|
this.rawName = rawName;
|
|
244
250
|
this.description = description;
|
|
@@ -271,12 +277,6 @@ var Command = class {
|
|
|
271
277
|
this.examples.push(example);
|
|
272
278
|
return this;
|
|
273
279
|
}
|
|
274
|
-
/**
|
|
275
|
-
* Add a option for this command
|
|
276
|
-
* @param rawName Raw option name(s)
|
|
277
|
-
* @param description Option description
|
|
278
|
-
* @param config Option config
|
|
279
|
-
*/
|
|
280
280
|
option(rawName, description, config) {
|
|
281
281
|
const option = new Option(rawName, description, config);
|
|
282
282
|
this.options.push(option);
|
|
@@ -290,10 +290,6 @@ var Command = class {
|
|
|
290
290
|
this.commandAction = callback;
|
|
291
291
|
return this;
|
|
292
292
|
}
|
|
293
|
-
/**
|
|
294
|
-
* Check if a command name is matched by this command
|
|
295
|
-
* @param name Command name
|
|
296
|
-
*/
|
|
297
293
|
isMatched(name) {
|
|
298
294
|
return this.name === name || this.aliasNames.includes(name);
|
|
299
295
|
}
|
|
@@ -303,10 +299,6 @@ var Command = class {
|
|
|
303
299
|
get isGlobalCommand() {
|
|
304
300
|
return this instanceof GlobalCommand;
|
|
305
301
|
}
|
|
306
|
-
/**
|
|
307
|
-
* Check if an option is registered in this command
|
|
308
|
-
* @param name Option name
|
|
309
|
-
*/
|
|
310
302
|
hasOption(name) {
|
|
311
303
|
name = name.split(".")[0];
|
|
312
304
|
return this.options.find((option) => {
|
|
@@ -315,26 +307,38 @@ var Command = class {
|
|
|
315
307
|
}
|
|
316
308
|
outputHelp() {
|
|
317
309
|
const { name, commands } = this.cli;
|
|
318
|
-
const {
|
|
319
|
-
|
|
310
|
+
const {
|
|
311
|
+
versionNumber,
|
|
312
|
+
options: globalOptions,
|
|
313
|
+
helpCallback
|
|
314
|
+
} = this.cli.globalCommand;
|
|
315
|
+
let sections = [
|
|
316
|
+
{
|
|
317
|
+
body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
|
|
318
|
+
}
|
|
319
|
+
];
|
|
320
320
|
sections.push({
|
|
321
321
|
title: "Usage",
|
|
322
322
|
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
323
323
|
});
|
|
324
|
-
|
|
324
|
+
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
325
|
+
if (showCommands) {
|
|
325
326
|
const longestCommandName = findLongest(commands.map((command) => command.rawName));
|
|
326
327
|
sections.push({
|
|
327
328
|
title: "Commands",
|
|
328
329
|
body: commands.map((command) => {
|
|
329
330
|
return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
|
|
330
331
|
}).join("\n")
|
|
331
|
-
}
|
|
332
|
+
});
|
|
333
|
+
sections.push({
|
|
332
334
|
title: `For more info, run any command with the \`--help\` flag`,
|
|
333
335
|
body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
|
|
334
336
|
});
|
|
335
337
|
}
|
|
336
338
|
let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
|
|
337
|
-
if (!this.isGlobalCommand && !this.isDefaultCommand)
|
|
339
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand) {
|
|
340
|
+
options = options.filter((option) => option.name !== "version");
|
|
341
|
+
}
|
|
338
342
|
if (options.length > 0) {
|
|
339
343
|
const longestOptionName = findLongest(options.map((option) => option.rawName));
|
|
340
344
|
sections.push({
|
|
@@ -344,15 +348,21 @@ var Command = class {
|
|
|
344
348
|
}).join("\n")
|
|
345
349
|
});
|
|
346
350
|
}
|
|
347
|
-
if (this.examples.length > 0)
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
351
|
+
if (this.examples.length > 0) {
|
|
352
|
+
sections.push({
|
|
353
|
+
title: "Examples",
|
|
354
|
+
body: this.examples.map((example) => {
|
|
355
|
+
if (typeof example === "function") {
|
|
356
|
+
return example(name);
|
|
357
|
+
}
|
|
358
|
+
return example;
|
|
359
|
+
}).join("\n")
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
if (helpCallback) {
|
|
363
|
+
sections = helpCallback(sections) || sections;
|
|
364
|
+
}
|
|
365
|
+
console.log(sections.map((section) => {
|
|
356
366
|
return section.title ? `${section.title}:
|
|
357
367
|
${section.body}` : section.body;
|
|
358
368
|
}).join("\n\n"));
|
|
@@ -360,26 +370,26 @@ ${section.body}` : section.body;
|
|
|
360
370
|
outputVersion() {
|
|
361
371
|
const { name } = this.cli;
|
|
362
372
|
const { versionNumber } = this.cli.globalCommand;
|
|
363
|
-
if (versionNumber)
|
|
373
|
+
if (versionNumber) {
|
|
374
|
+
console.log(`${name}/${versionNumber} ${platformInfo}`);
|
|
375
|
+
}
|
|
364
376
|
}
|
|
365
377
|
checkRequiredArgs() {
|
|
366
378
|
const minimalArgsCount = this.args.filter((arg) => arg.required).length;
|
|
367
|
-
if (this.cli.args.length < minimalArgsCount)
|
|
379
|
+
if (this.cli.args.length < minimalArgsCount) {
|
|
380
|
+
throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
381
|
+
}
|
|
368
382
|
}
|
|
369
|
-
/**
|
|
370
|
-
* Check if the parsed options contain any unknown options
|
|
371
|
-
*
|
|
372
|
-
* Exit and output error when true
|
|
373
|
-
*/
|
|
374
383
|
checkUnknownOptions() {
|
|
375
384
|
const { options, globalCommand } = this.cli;
|
|
376
385
|
if (!this.config.allowUnknownOptions) {
|
|
377
|
-
for (const name of Object.keys(options))
|
|
386
|
+
for (const name of Object.keys(options)) {
|
|
387
|
+
if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) {
|
|
388
|
+
throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
378
391
|
}
|
|
379
392
|
}
|
|
380
|
-
/**
|
|
381
|
-
* Check if the required string-type options exist
|
|
382
|
-
*/
|
|
383
393
|
checkOptionValue() {
|
|
384
394
|
const { options: parsedOptions, globalCommand } = this.cli;
|
|
385
395
|
const options = [...globalCommand.options, ...this.options];
|
|
@@ -387,47 +397,20 @@ ${section.body}` : section.body;
|
|
|
387
397
|
const value = parsedOptions[option.name.split(".")[0]];
|
|
388
398
|
if (option.required) {
|
|
389
399
|
const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
|
|
390
|
-
if (value === true || value === false && !hasNegated)
|
|
400
|
+
if (value === true || value === false && !hasNegated) {
|
|
401
|
+
throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
402
|
+
}
|
|
391
403
|
}
|
|
392
404
|
}
|
|
393
405
|
}
|
|
394
|
-
/**
|
|
395
|
-
* Check if the number of args is more than expected
|
|
396
|
-
*/
|
|
397
|
-
checkUnusedArgs() {
|
|
398
|
-
const maximumArgsCount = this.args.some((arg) => arg.variadic) ? Infinity : this.args.length;
|
|
399
|
-
if (maximumArgsCount < this.cli.args.length) throw new CACError(`Unused args: ${this.cli.args.slice(maximumArgsCount).map((arg) => `\`${arg}\``).join(", ")}`);
|
|
400
|
-
}
|
|
401
406
|
};
|
|
402
407
|
var GlobalCommand = class extends Command {
|
|
403
408
|
constructor(cli) {
|
|
404
409
|
super("@@global@@", "", {}, cli);
|
|
405
410
|
}
|
|
406
411
|
};
|
|
407
|
-
var
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Raw CLI arguments
|
|
416
|
-
*/
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Parsed CLI arguments
|
|
420
|
-
*/
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* Parsed CLI options, camelCased
|
|
424
|
-
*/
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* @param name The program name to display in help and version message
|
|
430
|
-
*/
|
|
412
|
+
var __assign = Object.assign;
|
|
413
|
+
var CAC = class extends _events.EventEmitter {
|
|
431
414
|
constructor(name = "") {
|
|
432
415
|
super();
|
|
433
416
|
this.name = name;
|
|
@@ -438,119 +421,88 @@ var CAC = class extends EventTarget {
|
|
|
438
421
|
this.globalCommand = new GlobalCommand(this);
|
|
439
422
|
this.globalCommand.usage("<command> [options]");
|
|
440
423
|
}
|
|
441
|
-
/**
|
|
442
|
-
* Add a global usage text.
|
|
443
|
-
*
|
|
444
|
-
* This is not used by sub-commands.
|
|
445
|
-
*/
|
|
446
424
|
usage(text) {
|
|
447
425
|
this.globalCommand.usage(text);
|
|
448
426
|
return this;
|
|
449
427
|
}
|
|
450
|
-
/**
|
|
451
|
-
* Add a sub-command
|
|
452
|
-
*/
|
|
453
428
|
command(rawName, description, config) {
|
|
454
429
|
const command = new Command(rawName, description || "", config, this);
|
|
455
430
|
command.globalCommand = this.globalCommand;
|
|
456
431
|
this.commands.push(command);
|
|
457
432
|
return command;
|
|
458
433
|
}
|
|
459
|
-
/**
|
|
460
|
-
* Add a global CLI option.
|
|
461
|
-
*
|
|
462
|
-
* Which is also applied to sub-commands.
|
|
463
|
-
*/
|
|
464
434
|
option(rawName, description, config) {
|
|
465
435
|
this.globalCommand.option(rawName, description, config);
|
|
466
436
|
return this;
|
|
467
437
|
}
|
|
468
|
-
/**
|
|
469
|
-
* Show help message when `-h, --help` flags appear.
|
|
470
|
-
*
|
|
471
|
-
*/
|
|
472
438
|
help(callback) {
|
|
473
439
|
this.globalCommand.option("-h, --help", "Display this message");
|
|
474
440
|
this.globalCommand.helpCallback = callback;
|
|
475
441
|
this.showHelpOnExit = true;
|
|
476
442
|
return this;
|
|
477
443
|
}
|
|
478
|
-
/**
|
|
479
|
-
* Show version number when `-v, --version` flags appear.
|
|
480
|
-
*
|
|
481
|
-
*/
|
|
482
444
|
version(version, customFlags = "-v, --version") {
|
|
483
445
|
this.globalCommand.version(version, customFlags);
|
|
484
446
|
this.showVersionOnExit = true;
|
|
485
447
|
return this;
|
|
486
448
|
}
|
|
487
|
-
/**
|
|
488
|
-
* Add a global example.
|
|
489
|
-
*
|
|
490
|
-
* This example added here will not be used by sub-commands.
|
|
491
|
-
*/
|
|
492
449
|
example(example) {
|
|
493
450
|
this.globalCommand.example(example);
|
|
494
451
|
return this;
|
|
495
452
|
}
|
|
496
|
-
/**
|
|
497
|
-
* Output the corresponding help message
|
|
498
|
-
* When a sub-command is matched, output the help message for the command
|
|
499
|
-
* Otherwise output the global one.
|
|
500
|
-
*
|
|
501
|
-
*/
|
|
502
453
|
outputHelp() {
|
|
503
|
-
if (this.matchedCommand)
|
|
504
|
-
|
|
454
|
+
if (this.matchedCommand) {
|
|
455
|
+
this.matchedCommand.outputHelp();
|
|
456
|
+
} else {
|
|
457
|
+
this.globalCommand.outputHelp();
|
|
458
|
+
}
|
|
505
459
|
}
|
|
506
|
-
/**
|
|
507
|
-
* Output the version number.
|
|
508
|
-
*
|
|
509
|
-
*/
|
|
510
460
|
outputVersion() {
|
|
511
461
|
this.globalCommand.outputVersion();
|
|
512
462
|
}
|
|
513
463
|
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
514
464
|
this.args = args;
|
|
515
465
|
this.options = options;
|
|
516
|
-
if (matchedCommand)
|
|
517
|
-
|
|
466
|
+
if (matchedCommand) {
|
|
467
|
+
this.matchedCommand = matchedCommand;
|
|
468
|
+
}
|
|
469
|
+
if (matchedCommandName) {
|
|
470
|
+
this.matchedCommandName = matchedCommandName;
|
|
471
|
+
}
|
|
518
472
|
return this;
|
|
519
473
|
}
|
|
520
474
|
unsetMatchedCommand() {
|
|
521
475
|
this.matchedCommand = void 0;
|
|
522
476
|
this.matchedCommandName = void 0;
|
|
523
477
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
parse(argv, { run = true } = {}) {
|
|
528
|
-
if (!argv) {
|
|
529
|
-
if (!runtimeProcessArgs) throw new Error("No argv provided and runtime process argv is not available.");
|
|
530
|
-
argv = runtimeProcessArgs;
|
|
531
|
-
}
|
|
478
|
+
parse(argv = processArgs, {
|
|
479
|
+
run = true
|
|
480
|
+
} = {}) {
|
|
532
481
|
this.rawArgs = argv;
|
|
533
|
-
if (!this.name)
|
|
482
|
+
if (!this.name) {
|
|
483
|
+
this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
484
|
+
}
|
|
534
485
|
let shouldParse = true;
|
|
535
486
|
for (const command of this.commands) {
|
|
536
487
|
const parsed = this.mri(argv.slice(2), command);
|
|
537
488
|
const commandName = parsed.args[0];
|
|
538
489
|
if (command.isMatched(commandName)) {
|
|
539
490
|
shouldParse = false;
|
|
540
|
-
const parsedInfo = {
|
|
541
|
-
...parsed,
|
|
491
|
+
const parsedInfo = __assign(__assign({}, parsed), {
|
|
542
492
|
args: parsed.args.slice(1)
|
|
543
|
-
};
|
|
493
|
+
});
|
|
544
494
|
this.setParsedInfo(parsedInfo, command, commandName);
|
|
545
|
-
this.
|
|
495
|
+
this.emit(`command:${commandName}`, command);
|
|
546
496
|
}
|
|
547
497
|
}
|
|
548
498
|
if (shouldParse) {
|
|
549
|
-
for (const command of this.commands)
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
499
|
+
for (const command of this.commands) {
|
|
500
|
+
if (command.name === "") {
|
|
501
|
+
shouldParse = false;
|
|
502
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
503
|
+
this.setParsedInfo(parsed, command);
|
|
504
|
+
this.emit(`command:!`, command);
|
|
505
|
+
}
|
|
554
506
|
}
|
|
555
507
|
}
|
|
556
508
|
if (shouldParse) {
|
|
@@ -567,45 +519,59 @@ var CAC = class extends EventTarget {
|
|
|
567
519
|
run = false;
|
|
568
520
|
this.unsetMatchedCommand();
|
|
569
521
|
}
|
|
570
|
-
const parsedArgv = {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}
|
|
574
|
-
if (
|
|
575
|
-
|
|
522
|
+
const parsedArgv = { args: this.args, options: this.options };
|
|
523
|
+
if (run) {
|
|
524
|
+
this.runMatchedCommand();
|
|
525
|
+
}
|
|
526
|
+
if (!this.matchedCommand && this.args[0]) {
|
|
527
|
+
this.emit("command:*");
|
|
528
|
+
}
|
|
576
529
|
return parsedArgv;
|
|
577
530
|
}
|
|
578
531
|
mri(argv, command) {
|
|
579
|
-
const cliOptions = [
|
|
532
|
+
const cliOptions = [
|
|
533
|
+
...this.globalCommand.options,
|
|
534
|
+
...command ? command.options : []
|
|
535
|
+
];
|
|
580
536
|
const mriOptions = getMriOptions(cliOptions);
|
|
581
537
|
let argsAfterDoubleDashes = [];
|
|
582
538
|
const doubleDashesIndex = argv.indexOf("--");
|
|
583
|
-
if (doubleDashesIndex
|
|
539
|
+
if (doubleDashesIndex > -1) {
|
|
584
540
|
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
585
541
|
argv = argv.slice(0, doubleDashesIndex);
|
|
586
542
|
}
|
|
587
|
-
let parsed =
|
|
543
|
+
let parsed = mri2(argv, mriOptions);
|
|
588
544
|
parsed = Object.keys(parsed).reduce((res, name) => {
|
|
589
|
-
return {
|
|
590
|
-
...res,
|
|
545
|
+
return __assign(__assign({}, res), {
|
|
591
546
|
[camelcaseOptionName(name)]: parsed[name]
|
|
592
|
-
};
|
|
547
|
+
});
|
|
593
548
|
}, { _: [] });
|
|
594
549
|
const args = parsed._;
|
|
595
|
-
const options = {
|
|
550
|
+
const options = {
|
|
551
|
+
"--": argsAfterDoubleDashes
|
|
552
|
+
};
|
|
596
553
|
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
597
|
-
|
|
554
|
+
let transforms = /* @__PURE__ */ Object.create(null);
|
|
598
555
|
for (const cliOption of cliOptions) {
|
|
599
|
-
if (!ignoreDefault && cliOption.config.default !== void 0)
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
556
|
+
if (!ignoreDefault && cliOption.config.default !== void 0) {
|
|
557
|
+
for (const name of cliOption.names) {
|
|
558
|
+
options[name] = cliOption.config.default;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
if (Array.isArray(cliOption.config.type)) {
|
|
562
|
+
if (transforms[cliOption.name] === void 0) {
|
|
563
|
+
transforms[cliOption.name] = /* @__PURE__ */ Object.create(null);
|
|
564
|
+
transforms[cliOption.name]["shouldTransform"] = true;
|
|
565
|
+
transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
|
|
566
|
+
}
|
|
604
567
|
}
|
|
605
568
|
}
|
|
606
|
-
for (const key of Object.keys(parsed))
|
|
607
|
-
|
|
608
|
-
|
|
569
|
+
for (const key of Object.keys(parsed)) {
|
|
570
|
+
if (key !== "_") {
|
|
571
|
+
const keys = key.split(".");
|
|
572
|
+
setDotProp(options, keys, parsed[key]);
|
|
573
|
+
setByType(options, transforms);
|
|
574
|
+
}
|
|
609
575
|
}
|
|
610
576
|
return {
|
|
611
577
|
args,
|
|
@@ -614,21 +580,25 @@ var CAC = class extends EventTarget {
|
|
|
614
580
|
}
|
|
615
581
|
runMatchedCommand() {
|
|
616
582
|
const { args, options, matchedCommand: command } = this;
|
|
617
|
-
if (!command || !command.commandAction)
|
|
583
|
+
if (!command || !command.commandAction)
|
|
584
|
+
return;
|
|
618
585
|
command.checkUnknownOptions();
|
|
619
586
|
command.checkOptionValue();
|
|
620
587
|
command.checkRequiredArgs();
|
|
621
|
-
command.checkUnusedArgs();
|
|
622
588
|
const actionArgs = [];
|
|
623
589
|
command.args.forEach((arg, index) => {
|
|
624
|
-
if (arg.variadic)
|
|
625
|
-
|
|
590
|
+
if (arg.variadic) {
|
|
591
|
+
actionArgs.push(args.slice(index));
|
|
592
|
+
} else {
|
|
593
|
+
actionArgs.push(args[index]);
|
|
594
|
+
}
|
|
626
595
|
});
|
|
627
596
|
actionArgs.push(options);
|
|
628
597
|
return command.commandAction.apply(this, actionArgs);
|
|
629
598
|
}
|
|
630
599
|
};
|
|
631
600
|
var cac = (name = "") => new CAC(name);
|
|
601
|
+
var dist_default = cac;
|
|
632
602
|
|
|
633
603
|
// src/commands/command-definitions.ts
|
|
634
604
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
@@ -755,10 +725,10 @@ function addPrefixIfMissing(value, prefix) {
|
|
|
755
725
|
return `${prefix}${value}`;
|
|
756
726
|
}
|
|
757
727
|
function resolveCommandNames(command, mountOptions, prefix) {
|
|
758
|
-
const override = _optionalChain([mountOptions, 'access',
|
|
759
|
-
const baseName = _nullishCoalesce(_optionalChain([override, 'optionalAccess',
|
|
728
|
+
const override = _optionalChain([mountOptions, 'access', _2 => _2.commandOptions, 'optionalAccess', _3 => _3[command]]);
|
|
729
|
+
const baseName = _nullishCoalesce(_optionalChain([override, 'optionalAccess', _4 => _4.name]), () => ( command));
|
|
760
730
|
const name = addPrefixIfMissing(baseName, prefix);
|
|
761
|
-
const aliases = (_nullishCoalesce(_optionalChain([override, 'optionalAccess',
|
|
731
|
+
const aliases = (_nullishCoalesce(_optionalChain([override, 'optionalAccess', _5 => _5.aliases]), () => ( []))).map((alias) => addPrefixIfMissing(alias, prefix));
|
|
762
732
|
return { name, aliases };
|
|
763
733
|
}
|
|
764
734
|
function resolveOptionDefinitions(defaults, override) {
|
|
@@ -778,8 +748,8 @@ function resolveOptionDefinitions(defaults, override) {
|
|
|
778
748
|
function resolveCommandMetadata(command, mountOptions, prefix, defaults) {
|
|
779
749
|
const names = resolveCommandNames(command, mountOptions, prefix);
|
|
780
750
|
const definition = defaults[command];
|
|
781
|
-
const override = _optionalChain([mountOptions, 'access',
|
|
782
|
-
const description = _nullishCoalesce(_optionalChain([override, 'optionalAccess',
|
|
751
|
+
const override = _optionalChain([mountOptions, 'access', _6 => _6.commandOptions, 'optionalAccess', _7 => _7[command]]);
|
|
752
|
+
const description = _nullishCoalesce(_optionalChain([override, 'optionalAccess', _8 => _8.description]), () => ( definition.description));
|
|
783
753
|
const optionDefs = resolveOptionDefinitions(definition.optionDefs, override);
|
|
784
754
|
return { ...names, description, optionDefs };
|
|
785
755
|
}
|
|
@@ -809,25 +779,25 @@ function createMemoizedPromiseRunner(factory) {
|
|
|
809
779
|
}
|
|
810
780
|
function createTailwindcssPatchCommandContext(cli, command, commandName, args, cwd) {
|
|
811
781
|
const loadCachedConfig = createMemoizedPromiseRunner(
|
|
812
|
-
() =>
|
|
782
|
+
() => _chunkA7IKQTXKjs.loadWorkspaceConfigModule.call(void 0, ).then((mod) => mod.getConfig(cwd))
|
|
813
783
|
);
|
|
814
784
|
const loadCachedPatchOptions = createMemoizedPromiseRunner(
|
|
815
|
-
() =>
|
|
785
|
+
() => _chunkA7IKQTXKjs.loadPatchOptionsForWorkspace.call(void 0, cwd)
|
|
816
786
|
);
|
|
817
787
|
const createCachedPatcher = createMemoizedPromiseRunner(async () => {
|
|
818
788
|
const patchOptions = await loadCachedPatchOptions();
|
|
819
|
-
return new (0,
|
|
789
|
+
return new (0, _chunkA7IKQTXKjs.TailwindcssPatcher)(patchOptions);
|
|
820
790
|
});
|
|
821
791
|
const loadPatchOptionsForContext = (overrides) => {
|
|
822
792
|
if (overrides) {
|
|
823
|
-
return
|
|
793
|
+
return _chunkA7IKQTXKjs.loadPatchOptionsForWorkspace.call(void 0, cwd, overrides);
|
|
824
794
|
}
|
|
825
795
|
return loadCachedPatchOptions();
|
|
826
796
|
};
|
|
827
797
|
const createPatcherForContext = async (overrides) => {
|
|
828
798
|
if (overrides) {
|
|
829
|
-
const patchOptions = await
|
|
830
|
-
return new (0,
|
|
799
|
+
const patchOptions = await _chunkA7IKQTXKjs.loadPatchOptionsForWorkspace.call(void 0, cwd, overrides);
|
|
800
|
+
return new (0, _chunkA7IKQTXKjs.TailwindcssPatcher)(patchOptions);
|
|
831
801
|
}
|
|
832
802
|
return createCachedPatcher();
|
|
833
803
|
};
|
|
@@ -837,7 +807,7 @@ function createTailwindcssPatchCommandContext(cli, command, commandName, args, c
|
|
|
837
807
|
commandName,
|
|
838
808
|
args,
|
|
839
809
|
cwd,
|
|
840
|
-
logger:
|
|
810
|
+
logger: _chunkA7IKQTXKjs.logger_default,
|
|
841
811
|
loadConfig: loadCachedConfig,
|
|
842
812
|
loadPatchOptions: loadPatchOptionsForContext,
|
|
843
813
|
createPatcher: createPatcherForContext
|
|
@@ -863,7 +833,7 @@ var DEFAULT_CONFIG_NAME = "tailwindcss-mangle";
|
|
|
863
833
|
async function installCommandDefaultHandler(_ctx) {
|
|
864
834
|
const patcher = await _ctx.createPatcher();
|
|
865
835
|
await patcher.patch();
|
|
866
|
-
|
|
836
|
+
_chunkA7IKQTXKjs.logger_default.success("Tailwind CSS runtime patched successfully.");
|
|
867
837
|
}
|
|
868
838
|
async function extractCommandDefaultHandler(ctx) {
|
|
869
839
|
const { args } = ctx;
|
|
@@ -888,9 +858,9 @@ async function extractCommandDefaultHandler(ctx) {
|
|
|
888
858
|
const extractOptions = args.write === void 0 ? {} : { write: args.write };
|
|
889
859
|
const result = await patcher.extract(extractOptions);
|
|
890
860
|
if (result.filename) {
|
|
891
|
-
|
|
861
|
+
_chunkA7IKQTXKjs.logger_default.success(`Collected ${result.classList.length} classes \u2192 ${result.filename}`);
|
|
892
862
|
} else {
|
|
893
|
-
|
|
863
|
+
_chunkA7IKQTXKjs.logger_default.success(`Collected ${result.classList.length} classes.`);
|
|
894
864
|
}
|
|
895
865
|
return result;
|
|
896
866
|
}
|
|
@@ -905,7 +875,7 @@ async function tokensCommandDefaultHandler(ctx) {
|
|
|
905
875
|
}
|
|
906
876
|
const targetFile = _nullishCoalesce(args.output, () => ( DEFAULT_TOKEN_REPORT));
|
|
907
877
|
const groupKey = args.groupKey === "absolute" ? "absolute" : "relative";
|
|
908
|
-
const buildGrouped = () =>
|
|
878
|
+
const buildGrouped = () => _chunkA7IKQTXKjs.groupTokensByFile.call(void 0, report, {
|
|
909
879
|
key: groupKey,
|
|
910
880
|
stripAbsolutePaths: groupKey !== "absolute"
|
|
911
881
|
});
|
|
@@ -923,49 +893,49 @@ async function tokensCommandDefaultHandler(ctx) {
|
|
|
923
893
|
await _fsextra2.default.writeFile(target, `${lines.join("\n")}
|
|
924
894
|
`, "utf8");
|
|
925
895
|
}
|
|
926
|
-
|
|
896
|
+
_chunkA7IKQTXKjs.logger_default.success(`Collected ${report.entries.length} tokens (${format}) \u2192 ${target.replace(_process2.default.cwd(), ".")}`);
|
|
927
897
|
} else {
|
|
928
|
-
|
|
898
|
+
_chunkA7IKQTXKjs.logger_default.success(`Collected ${report.entries.length} tokens from ${report.filesScanned} files.`);
|
|
929
899
|
if (format === "lines") {
|
|
930
900
|
const preview = report.entries.slice(0, 5).map(formatTokenLine).join("\n");
|
|
931
901
|
if (preview) {
|
|
932
|
-
|
|
933
|
-
|
|
902
|
+
_chunkA7IKQTXKjs.logger_default.log("");
|
|
903
|
+
_chunkA7IKQTXKjs.logger_default.info(preview);
|
|
934
904
|
if (report.entries.length > 5) {
|
|
935
|
-
|
|
905
|
+
_chunkA7IKQTXKjs.logger_default.info(`\u2026and ${report.entries.length - 5} more.`);
|
|
936
906
|
}
|
|
937
907
|
}
|
|
938
908
|
} else if (format === "grouped-json") {
|
|
939
909
|
const map = resolveGrouped();
|
|
940
910
|
const { preview, moreFiles } = formatGroupedPreview(map);
|
|
941
911
|
if (preview) {
|
|
942
|
-
|
|
943
|
-
|
|
912
|
+
_chunkA7IKQTXKjs.logger_default.log("");
|
|
913
|
+
_chunkA7IKQTXKjs.logger_default.info(preview);
|
|
944
914
|
if (moreFiles > 0) {
|
|
945
|
-
|
|
915
|
+
_chunkA7IKQTXKjs.logger_default.info(`\u2026and ${moreFiles} more files.`);
|
|
946
916
|
}
|
|
947
917
|
}
|
|
948
918
|
} else {
|
|
949
919
|
const previewEntries = report.entries.slice(0, 3);
|
|
950
920
|
if (previewEntries.length) {
|
|
951
|
-
|
|
952
|
-
|
|
921
|
+
_chunkA7IKQTXKjs.logger_default.log("");
|
|
922
|
+
_chunkA7IKQTXKjs.logger_default.info(JSON.stringify(previewEntries, null, 2));
|
|
953
923
|
}
|
|
954
924
|
}
|
|
955
925
|
}
|
|
956
926
|
if (report.skippedFiles.length) {
|
|
957
|
-
|
|
927
|
+
_chunkA7IKQTXKjs.logger_default.warn("Skipped files:");
|
|
958
928
|
for (const skipped of report.skippedFiles) {
|
|
959
|
-
|
|
929
|
+
_chunkA7IKQTXKjs.logger_default.warn(` \u2022 ${skipped.file} (${skipped.reason})`);
|
|
960
930
|
}
|
|
961
931
|
}
|
|
962
932
|
return report;
|
|
963
933
|
}
|
|
964
934
|
async function initCommandDefaultHandler(ctx) {
|
|
965
|
-
const configModule = await
|
|
935
|
+
const configModule = await _chunkA7IKQTXKjs.loadWorkspaceConfigModule.call(void 0, );
|
|
966
936
|
await configModule.initConfig(ctx.cwd);
|
|
967
937
|
const configName = configModule.CONFIG_NAME || DEFAULT_CONFIG_NAME;
|
|
968
|
-
|
|
938
|
+
_chunkA7IKQTXKjs.logger_default.success(`\u2728 ${configName}.config.ts initialized!`);
|
|
969
939
|
}
|
|
970
940
|
|
|
971
941
|
// src/commands/migration-args.ts
|
|
@@ -1039,53 +1009,53 @@ async function writeMigrationReportFile(cwd, reportFile, report) {
|
|
|
1039
1009
|
const reportPath = _pathe2.default.resolve(cwd, reportFile);
|
|
1040
1010
|
await _fsextra2.default.ensureDir(_pathe2.default.dirname(reportPath));
|
|
1041
1011
|
await _fsextra2.default.writeJSON(reportPath, report, { spaces: 2 });
|
|
1042
|
-
|
|
1012
|
+
_chunkA7IKQTXKjs.logger_default.info(`Migration report written: ${formatPathForLog(reportPath)}`);
|
|
1043
1013
|
}
|
|
1044
1014
|
function logMigrationReportAsJson(report) {
|
|
1045
|
-
|
|
1015
|
+
_chunkA7IKQTXKjs.logger_default.log(JSON.stringify(report, null, 2));
|
|
1046
1016
|
}
|
|
1047
1017
|
function logNoMigrationConfigFilesWarning() {
|
|
1048
|
-
|
|
1018
|
+
_chunkA7IKQTXKjs.logger_default.warn("No config files found for migration.");
|
|
1049
1019
|
}
|
|
1050
1020
|
function logMigrationEntries(report, dryRun) {
|
|
1051
1021
|
for (const entry of report.entries) {
|
|
1052
1022
|
const fileLabel = formatPathForLog(entry.file);
|
|
1053
1023
|
if (!entry.changed) {
|
|
1054
|
-
|
|
1024
|
+
_chunkA7IKQTXKjs.logger_default.info(`No changes: ${fileLabel}`);
|
|
1055
1025
|
continue;
|
|
1056
1026
|
}
|
|
1057
1027
|
if (dryRun) {
|
|
1058
|
-
|
|
1028
|
+
_chunkA7IKQTXKjs.logger_default.info(`[dry-run] ${fileLabel}`);
|
|
1059
1029
|
} else {
|
|
1060
|
-
|
|
1030
|
+
_chunkA7IKQTXKjs.logger_default.success(`Migrated: ${fileLabel}`);
|
|
1061
1031
|
}
|
|
1062
1032
|
for (const change of entry.changes) {
|
|
1063
|
-
|
|
1033
|
+
_chunkA7IKQTXKjs.logger_default.info(` - ${change}`);
|
|
1064
1034
|
}
|
|
1065
1035
|
if (entry.backupFile) {
|
|
1066
|
-
|
|
1036
|
+
_chunkA7IKQTXKjs.logger_default.info(` - backup: ${formatPathForLog(entry.backupFile)}`);
|
|
1067
1037
|
}
|
|
1068
1038
|
}
|
|
1069
1039
|
}
|
|
1070
1040
|
function logMigrationSummary(report) {
|
|
1071
|
-
|
|
1041
|
+
_chunkA7IKQTXKjs.logger_default.info(
|
|
1072
1042
|
`Migration summary: scanned=${report.scannedFiles}, changed=${report.changedFiles}, written=${report.writtenFiles}, backups=${report.backupsWritten}, missing=${report.missingFiles}, unchanged=${report.unchangedFiles}`
|
|
1073
1043
|
);
|
|
1074
1044
|
}
|
|
1075
1045
|
function logRestoreResultAsJson(result) {
|
|
1076
|
-
|
|
1046
|
+
_chunkA7IKQTXKjs.logger_default.log(JSON.stringify(result, null, 2));
|
|
1077
1047
|
}
|
|
1078
1048
|
function logRestoreSummary(result) {
|
|
1079
|
-
|
|
1049
|
+
_chunkA7IKQTXKjs.logger_default.info(
|
|
1080
1050
|
`Restore summary: scanned=${result.scannedEntries}, restorable=${result.restorableEntries}, restored=${result.restoredFiles}, missingBackups=${result.missingBackups}, skipped=${result.skippedEntries}`
|
|
1081
1051
|
);
|
|
1082
1052
|
if (result.restored.length > 0) {
|
|
1083
1053
|
const preview = result.restored.slice(0, 5);
|
|
1084
1054
|
for (const file of preview) {
|
|
1085
|
-
|
|
1055
|
+
_chunkA7IKQTXKjs.logger_default.info(` - ${formatPathForLog(file)}`);
|
|
1086
1056
|
}
|
|
1087
1057
|
if (result.restored.length > preview.length) {
|
|
1088
|
-
|
|
1058
|
+
_chunkA7IKQTXKjs.logger_default.info(` ...and ${result.restored.length - preview.length} more`);
|
|
1089
1059
|
}
|
|
1090
1060
|
}
|
|
1091
1061
|
}
|
|
@@ -1094,16 +1064,16 @@ function logValidateSuccessAsJson(result) {
|
|
|
1094
1064
|
ok: true,
|
|
1095
1065
|
...result
|
|
1096
1066
|
};
|
|
1097
|
-
|
|
1067
|
+
_chunkA7IKQTXKjs.logger_default.log(JSON.stringify(payload, null, 2));
|
|
1098
1068
|
}
|
|
1099
1069
|
function logValidateSuccessSummary(result) {
|
|
1100
|
-
|
|
1070
|
+
_chunkA7IKQTXKjs.logger_default.success(
|
|
1101
1071
|
`Migration report validated: scanned=${result.scannedEntries}, restorable=${result.restorableEntries}, missingBackups=${result.missingBackups}, skipped=${result.skippedEntries}`
|
|
1102
1072
|
);
|
|
1103
1073
|
if (result.reportKind || result.reportSchemaVersion !== void 0) {
|
|
1104
1074
|
const kind = _nullishCoalesce(result.reportKind, () => ( "unknown"));
|
|
1105
1075
|
const schema = result.reportSchemaVersion === void 0 ? "unknown" : String(result.reportSchemaVersion);
|
|
1106
|
-
|
|
1076
|
+
_chunkA7IKQTXKjs.logger_default.info(` metadata: kind=${kind}, schema=${schema}`);
|
|
1107
1077
|
}
|
|
1108
1078
|
}
|
|
1109
1079
|
function logValidateFailureAsJson(summary) {
|
|
@@ -1113,10 +1083,10 @@ function logValidateFailureAsJson(summary) {
|
|
|
1113
1083
|
exitCode: summary.exitCode,
|
|
1114
1084
|
message: summary.message
|
|
1115
1085
|
};
|
|
1116
|
-
|
|
1086
|
+
_chunkA7IKQTXKjs.logger_default.log(JSON.stringify(payload, null, 2));
|
|
1117
1087
|
}
|
|
1118
1088
|
function logValidateFailureSummary(summary) {
|
|
1119
|
-
|
|
1089
|
+
_chunkA7IKQTXKjs.logger_default.error(`Validation failed [${summary.reason}] (exit ${summary.exitCode}): ${summary.message}`);
|
|
1120
1090
|
}
|
|
1121
1091
|
|
|
1122
1092
|
// src/commands/migrate-handler.ts
|
|
@@ -1131,9 +1101,9 @@ async function migrateCommandDefaultHandler(ctx) {
|
|
|
1131
1101
|
hasInvalidMaxDepth
|
|
1132
1102
|
} = resolveMigrateCommandArgs(args);
|
|
1133
1103
|
if (args.workspace && hasInvalidMaxDepth) {
|
|
1134
|
-
|
|
1104
|
+
_chunkA7IKQTXKjs.logger_default.warn(`Invalid --max-depth value "${String(args.maxDepth)}", fallback to default depth.`);
|
|
1135
1105
|
}
|
|
1136
|
-
const report = await
|
|
1106
|
+
const report = await _chunkA7IKQTXKjs.migrateConfigFiles.call(void 0, {
|
|
1137
1107
|
cwd: ctx.cwd,
|
|
1138
1108
|
dryRun,
|
|
1139
1109
|
...args.config ? { files: [args.config] } : {},
|
|
@@ -1172,7 +1142,7 @@ async function migrateCommandDefaultHandler(ctx) {
|
|
|
1172
1142
|
async function restoreCommandDefaultHandler(ctx) {
|
|
1173
1143
|
const { args } = ctx;
|
|
1174
1144
|
const restoreArgs = resolveRestoreCommandArgs(args);
|
|
1175
|
-
const result = await
|
|
1145
|
+
const result = await _chunkA7IKQTXKjs.restoreConfigFiles.call(void 0, {
|
|
1176
1146
|
cwd: ctx.cwd,
|
|
1177
1147
|
reportFile: restoreArgs.reportFile,
|
|
1178
1148
|
dryRun: restoreArgs.dryRun,
|
|
@@ -1204,7 +1174,7 @@ function partitionStatusEntries(report) {
|
|
|
1204
1174
|
};
|
|
1205
1175
|
}
|
|
1206
1176
|
function logStatusReportAsJson(report) {
|
|
1207
|
-
|
|
1177
|
+
_chunkA7IKQTXKjs.logger_default.log(JSON.stringify(report, null, 2));
|
|
1208
1178
|
}
|
|
1209
1179
|
function logStatusReportSummary(report) {
|
|
1210
1180
|
const {
|
|
@@ -1212,25 +1182,25 @@ function logStatusReportSummary(report) {
|
|
|
1212
1182
|
pending,
|
|
1213
1183
|
skipped
|
|
1214
1184
|
} = partitionStatusEntries(report);
|
|
1215
|
-
|
|
1185
|
+
_chunkA7IKQTXKjs.logger_default.info(`Patch status for ${formatPackageLabel(report)} (v${report.majorVersion})`);
|
|
1216
1186
|
if (applied.length) {
|
|
1217
|
-
|
|
1218
|
-
applied.forEach((entry) =>
|
|
1187
|
+
_chunkA7IKQTXKjs.logger_default.success("Applied:");
|
|
1188
|
+
applied.forEach((entry) => _chunkA7IKQTXKjs.logger_default.success(` \u2022 ${entry.name}${formatFilesHint(entry)}`));
|
|
1219
1189
|
}
|
|
1220
1190
|
if (pending.length) {
|
|
1221
|
-
|
|
1191
|
+
_chunkA7IKQTXKjs.logger_default.warn("Needs attention:");
|
|
1222
1192
|
pending.forEach((entry) => {
|
|
1223
1193
|
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
1224
|
-
|
|
1194
|
+
_chunkA7IKQTXKjs.logger_default.warn(` \u2022 ${entry.name}${formatFilesHint(entry)}${details}`);
|
|
1225
1195
|
});
|
|
1226
1196
|
} else {
|
|
1227
|
-
|
|
1197
|
+
_chunkA7IKQTXKjs.logger_default.success("All applicable patches are applied.");
|
|
1228
1198
|
}
|
|
1229
1199
|
if (skipped.length) {
|
|
1230
|
-
|
|
1200
|
+
_chunkA7IKQTXKjs.logger_default.info("Skipped:");
|
|
1231
1201
|
skipped.forEach((entry) => {
|
|
1232
1202
|
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
1233
|
-
|
|
1203
|
+
_chunkA7IKQTXKjs.logger_default.info(` \u2022 ${entry.name}${details}`);
|
|
1234
1204
|
});
|
|
1235
1205
|
}
|
|
1236
1206
|
}
|
|
@@ -1252,7 +1222,7 @@ async function validateCommandDefaultHandler(ctx) {
|
|
|
1252
1222
|
const { args } = ctx;
|
|
1253
1223
|
const validateArgs = resolveValidateCommandArgs(args);
|
|
1254
1224
|
try {
|
|
1255
|
-
const result = await
|
|
1225
|
+
const result = await _chunkA7IKQTXKjs.restoreConfigFiles.call(void 0, {
|
|
1256
1226
|
cwd: ctx.cwd,
|
|
1257
1227
|
reportFile: validateArgs.reportFile,
|
|
1258
1228
|
dryRun: true,
|
|
@@ -1265,13 +1235,13 @@ async function validateCommandDefaultHandler(ctx) {
|
|
|
1265
1235
|
logValidateSuccessSummary(result);
|
|
1266
1236
|
return result;
|
|
1267
1237
|
} catch (error) {
|
|
1268
|
-
const summary =
|
|
1238
|
+
const summary = _chunkA7IKQTXKjs.classifyValidateError.call(void 0, error);
|
|
1269
1239
|
if (args.json) {
|
|
1270
1240
|
logValidateFailureAsJson(summary);
|
|
1271
1241
|
} else {
|
|
1272
1242
|
logValidateFailureSummary(summary);
|
|
1273
1243
|
}
|
|
1274
|
-
throw new (0,
|
|
1244
|
+
throw new (0, _chunkA7IKQTXKjs.ValidateCommandError)(summary, { cause: error });
|
|
1275
1245
|
}
|
|
1276
1246
|
}
|
|
1277
1247
|
|
|
@@ -1299,7 +1269,7 @@ function registerTailwindcssPatchCommand(cli, commandName, options, prefix, defa
|
|
|
1299
1269
|
command,
|
|
1300
1270
|
commandName,
|
|
1301
1271
|
args,
|
|
1302
|
-
_optionalChain([options, 'access',
|
|
1272
|
+
_optionalChain([options, 'access', _9 => _9.commandHandlers, 'optionalAccess', _10 => _10[commandName]]),
|
|
1303
1273
|
defaultHandler
|
|
1304
1274
|
);
|
|
1305
1275
|
});
|
|
@@ -1309,7 +1279,7 @@ function registerTailwindcssPatchCommand(cli, commandName, options, prefix, defa
|
|
|
1309
1279
|
// src/commands/cli.ts
|
|
1310
1280
|
function mountTailwindcssPatchCommands(cli, options = {}) {
|
|
1311
1281
|
const prefix = _nullishCoalesce(options.commandPrefix, () => ( ""));
|
|
1312
|
-
const selectedCommands = _nullishCoalesce(options.commands, () => (
|
|
1282
|
+
const selectedCommands = _nullishCoalesce(options.commands, () => ( _chunkA7IKQTXKjs.tailwindcssPatchCommands));
|
|
1313
1283
|
const defaultDefinitions = buildDefaultCommandDefinitions();
|
|
1314
1284
|
for (const name of selectedCommands) {
|
|
1315
1285
|
registerTailwindcssPatchCommand(cli, name, options, prefix, defaultDefinitions);
|
|
@@ -1317,7 +1287,7 @@ function mountTailwindcssPatchCommands(cli, options = {}) {
|
|
|
1317
1287
|
return cli;
|
|
1318
1288
|
}
|
|
1319
1289
|
function createTailwindcssPatchCli(options = {}) {
|
|
1320
|
-
const cli =
|
|
1290
|
+
const cli = dist_default(_nullishCoalesce(options.name, () => ( "tw-patch")));
|
|
1321
1291
|
mountTailwindcssPatchCommands(cli, options.mountOptions);
|
|
1322
1292
|
return cli;
|
|
1323
1293
|
}
|
|
@@ -1328,4 +1298,4 @@ function createTailwindcssPatchCli(options = {}) {
|
|
|
1328
1298
|
|
|
1329
1299
|
|
|
1330
1300
|
|
|
1331
|
-
exports.VALIDATE_EXIT_CODES =
|
|
1301
|
+
exports.VALIDATE_EXIT_CODES = _chunkA7IKQTXKjs.VALIDATE_EXIT_CODES; exports.VALIDATE_FAILURE_REASONS = _chunkA7IKQTXKjs.VALIDATE_FAILURE_REASONS; exports.ValidateCommandError = _chunkA7IKQTXKjs.ValidateCommandError; exports.createTailwindcssPatchCli = createTailwindcssPatchCli; exports.mountTailwindcssPatchCommands = mountTailwindcssPatchCommands; exports.tailwindcssPatchCommands = _chunkA7IKQTXKjs.tailwindcssPatchCommands;
|