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.
@@ -11,10 +11,11 @@ import {
11
11
  migrateConfigFiles,
12
12
  restoreConfigFiles,
13
13
  tailwindcssPatchCommands
14
- } from "../chunk-D6ICWMM4.mjs";
15
- import "../chunk-A67ABH3M.mjs";
14
+ } from "../chunk-4BA7N3QJ.mjs";
15
+ import "../chunk-OSH52QWA.mjs";
16
16
 
17
- // ../../node_modules/.pnpm/cac@7.0.0/node_modules/cac/dist/index.js
17
+ // ../../node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
18
+ import { EventEmitter } from "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 lib_default(args, opts) {
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) for (k in opts.alias) {
37
- arr = opts.alias[k] = toArr(opts.alias[k]);
38
- for (i = 0; i < arr.length; i++) (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
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) for (k in opts.default) {
49
- name = typeof opts.default[k];
50
- arr = opts.alias[k] = opts.alias[k] || [];
51
- if (opts[name] !== void 0) {
52
- opts[name].push(k);
53
- for (i = 0; i < arr.length; i++) opts[name].push(arr[i]);
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++) if (arg.charCodeAt(j) !== 45) break;
64
- if (j === 0) out._.push(arg);
65
- else if (arg.substring(j, j + 3) === "no-") {
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)) return opts.unknown(arg);
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++) if (arg.charCodeAt(idx) === 61) break;
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) if (out[k] === void 0) out[k] = opts.default[k];
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) for (k in out) {
85
- arr = opts.alias[k] || [];
86
- while (arr.length > 0) out[arr.shift()] = out[k];
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
- function removeBrackets(v) {
91
- return v.replace(/[<[].+/, "").trim();
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)) res.push(parse(angledMatch));
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)) res.push(parse(squareMatch));
137
+ while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) {
138
+ res.push(parse(squareMatch));
139
+ }
114
140
  return res;
115
- }
116
- function getMriOptions(options) {
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) result.alias[option.names[0]] = option.names.slice(1);
123
- if (option.isBoolean) if (option.negated) {
124
- if (!options.some((o, i) => {
125
- return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
126
- })) result.boolean.push(option.names[0]);
127
- } else result.boolean.push(option.names[0]);
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
- function findLongest(arr) {
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
- function padRight(str, length) {
167
+ };
168
+ var padRight = (str, length) => {
137
169
  return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
138
- }
139
- function camelcase(input) {
140
- return input.replaceAll(/([a-z])-([a-z])/g, (_, p1, p2) => {
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
- function setDotProp(obj, keys, val) {
145
- let current = obj;
146
- for (let i = 0; i < keys.length; i++) {
147
- const key = keys[i];
148
- if (i === keys.length - 1) {
149
- current[key] = val;
150
- return;
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
- function setByType(obj, transforms) {
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]].flat();
164
- if (typeof transform.transformFunction === "function") obj[key] = obj[key].map(transform.transformFunction);
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
- function getFileName(input) {
169
- const m = /([^\\/]+)$/.exec(input);
196
+ };
197
+ var getFileName = (input) => {
198
+ const m = /([^\\\/]+)$/.exec(input);
170
199
  return m ? m[1] : "";
171
- }
172
- function camelcaseOptionName(name) {
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 = "CACError";
181
- if (typeof Error.captureStackTrace !== "function") this.stack = new Error(message).stack;
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
- rawName;
186
- description;
187
- /** Option name */
188
- name;
189
- /** Option name and aliases */
190
- names;
191
- isBoolean;
192
- required;
193
- config;
194
- negated;
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.replaceAll(".*", "");
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.at(-1);
210
- if (this.negated && this.config.default == null) this.config.default = true;
211
- if (rawName.includes("<")) this.required = true;
212
- else if (rawName.includes("[")) this.required = false;
213
- else this.isBoolean = true;
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 runtimeProcessArgs;
217
- var runtimeInfo;
218
- if (typeof process !== "undefined") {
219
- let runtimeName;
220
- if (typeof Deno !== "undefined" && typeof Deno.version?.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
- rawName;
229
- description;
230
- config;
231
- cli;
232
- options;
233
- aliasNames;
234
- name;
235
- args;
236
- commandAction;
237
- usageText;
238
- versionNumber;
239
- examples;
240
- helpCallback;
241
- globalCommand;
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 { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand;
319
- let sections = [{ body: `${name}${versionNumber ? `/${versionNumber}` : ""}` }];
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
- if ((this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0) {
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) options = options.filter((option) => option.name !== "version");
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) sections.push({
348
- title: "Examples",
349
- body: this.examples.map((example) => {
350
- if (typeof example === "function") return example(name);
351
- return example;
352
- }).join("\n")
353
- });
354
- if (helpCallback) sections = helpCallback(sections) || sections;
355
- console.info(sections.map((section) => {
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) console.info(`${name}/${versionNumber} ${runtimeInfo}`);
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) throw new CACError(`missing required args for command \`${this.rawName}\``);
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)) if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
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) throw new CACError(`option \`${option.rawName}\` value is missing`);
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 CAC = class extends EventTarget {
408
- /** The program name to display in help and version message */
409
- name;
410
- commands;
411
- globalCommand;
412
- matchedCommand;
413
- matchedCommandName;
414
- /**
415
- * Raw CLI arguments
416
- */
417
- rawArgs;
418
- /**
419
- * Parsed CLI arguments
420
- */
421
- args;
422
- /**
423
- * Parsed CLI options, camelCased
424
- */
425
- options;
426
- showHelpOnExit;
427
- showVersionOnExit;
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 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) this.matchedCommand.outputHelp();
504
- else this.globalCommand.outputHelp();
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) this.matchedCommand = matchedCommand;
517
- if (matchedCommandName) this.matchedCommandName = matchedCommandName;
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
- * Parse argv
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) this.name = argv[1] ? getFileName(argv[1]) : "cli";
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.dispatchEvent(new CustomEvent(`command:${commandName}`, { detail: command }));
495
+ this.emit(`command:${commandName}`, command);
546
496
  }
547
497
  }
548
498
  if (shouldParse) {
549
- for (const command of this.commands) if (command.isDefaultCommand) {
550
- shouldParse = false;
551
- const parsed = this.mri(argv.slice(2), command);
552
- this.setParsedInfo(parsed, command);
553
- this.dispatchEvent(new CustomEvent("command:!", { detail: command }));
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
- args: this.args,
572
- options: this.options
573
- };
574
- if (run) this.runMatchedCommand();
575
- if (!this.matchedCommand && this.args[0]) this.dispatchEvent(new CustomEvent("command:*", { detail: this.args[0] }));
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 = [...this.globalCommand.options, ...command ? command.options : []];
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 !== -1) {
539
+ if (doubleDashesIndex > -1) {
584
540
  argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
585
541
  argv = argv.slice(0, doubleDashesIndex);
586
542
  }
587
- let parsed = lib_default(argv, mriOptions);
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 = { "--": argsAfterDoubleDashes };
550
+ const options = {
551
+ "--": argsAfterDoubleDashes
552
+ };
596
553
  const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
597
- const transforms = /* @__PURE__ */ Object.create(null);
554
+ let transforms = /* @__PURE__ */ Object.create(null);
598
555
  for (const cliOption of cliOptions) {
599
- if (!ignoreDefault && cliOption.config.default !== void 0) for (const name of cliOption.names) options[name] = cliOption.config.default;
600
- if (Array.isArray(cliOption.config.type) && transforms[cliOption.name] === void 0) {
601
- transforms[cliOption.name] = /* @__PURE__ */ Object.create(null);
602
- transforms[cliOption.name].shouldTransform = true;
603
- transforms[cliOption.name].transformFunction = cliOption.config.type[0];
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)) if (key !== "_") {
607
- setDotProp(options, key.split("."), parsed[key]);
608
- setByType(options, transforms);
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) return;
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) actionArgs.push(args.slice(index));
625
- else actionArgs.push(args[index]);
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
  import process2 from "process";
@@ -1317,7 +1287,7 @@ function mountTailwindcssPatchCommands(cli, options = {}) {
1317
1287
  return cli;
1318
1288
  }
1319
1289
  function createTailwindcssPatchCli(options = {}) {
1320
- const cli = cac(options.name ?? "tw-patch");
1290
+ const cli = dist_default(options.name ?? "tw-patch");
1321
1291
  mountTailwindcssPatchCommands(cli, options.mountOptions);
1322
1292
  return cli;
1323
1293
  }