@voidzero-dev/vite-plus-core 0.1.1 → 0.1.2

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.
Files changed (29) hide show
  1. package/dist/rolldown/cli.mjs +1 -1
  2. package/dist/rolldown/config.d.mts +0 -1
  3. package/dist/rolldown/filter-index.d.mts +0 -1
  4. package/dist/rolldown/index.mjs +1 -1
  5. package/dist/rolldown/parallel-plugin.d.mts +0 -1
  6. package/dist/rolldown/shared/{watch-Cn-znpX_.mjs → watch-CVufTfok.mjs} +1 -1
  7. package/dist/tsdown/{build-BjQ7Rt90-tMPZTflz.js → build-TmLngPCw-I7MHSf0I.js} +269 -188
  8. package/dist/tsdown/build-gOkJM1H9-BRI3DQle.js +6 -0
  9. package/dist/tsdown/{debug-BUVkFfEZ-D3UMJnif.js → debug-tOJ_PtrM-DITcI9An.js} +2 -2
  10. package/dist/tsdown/{detect-CCATtVj7-DhvBg5EF.js → detect-DK-FDZQ9-CALXiuJa.js} +1 -1
  11. package/dist/tsdown/{dist-CFTDWtv2.js → dist-DVPyDO-_.js} +5 -2
  12. package/dist/tsdown/{dist-DNcnO8LL.js → dist-uzMTIu3J.js} +488 -521
  13. package/dist/tsdown/{filename-CPj0AKvV.js → filename-C2azOotK.js} +2 -2
  14. package/dist/tsdown/{index-node-ShM0x2b6-Bt7Chc0I.js → index-node-Djp92Gzb-fgHTblzo.js} +1 -1
  15. package/dist/tsdown/index-types.d.ts +175 -25
  16. package/dist/tsdown/index.js +5 -5
  17. package/dist/tsdown/{main-B3qcLRNf.js → main-BWoReXjl.js} +72 -69
  18. package/dist/tsdown/npm_cjs_chunk_lt.cjs +31 -0
  19. package/dist/tsdown/npm_cjs_chunk_range.cjs +7 -22
  20. package/dist/tsdown/npm_cjs_chunk_semver.cjs +17 -17
  21. package/dist/tsdown/npm_entry_semver_functions_lt.cjs +7 -0
  22. package/dist/tsdown/npm_entry_semver_functions_satisfies.cjs +2 -1
  23. package/dist/tsdown/npm_entry_semver_ranges_min-version.cjs +2 -1
  24. package/dist/tsdown/{resolver-j7HY1N36-DHVsN9q6.js → resolver-CdD-yT15-OWjlgV0D.js} +1 -1
  25. package/dist/tsdown/run.js +209 -68
  26. package/dist/tsdown/{tsc-CBjlgM2A.js → tsc-D6YfZJBZ.js} +62 -67
  27. package/dist/tsdown/{tsc-context-D1h5oZB8.js → tsc-context-CGmk4Cps.js} +1 -1
  28. package/package.json +13 -9
  29. package/dist/tsdown/build-2oRq4mfQ-YC_gzK3u.js +0 -6
@@ -1,15 +1,9 @@
1
1
  const require_chunk = require('./npm_cjs_chunk_chunk.cjs');
2
2
 
3
- //#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js
4
- var require_parse_options = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
5
- const looseOption = Object.freeze({ loose: true });
6
- const emptyOpts = Object.freeze({});
7
- const parseOptions = (options) => {
8
- if (!options) return emptyOpts;
9
- if (typeof options !== "object") return looseOption;
10
- return options;
11
- };
12
- module.exports = parseOptions;
3
+ //#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js
4
+ var require_debug = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
5
+ const debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
6
+ module.exports = debug;
13
7
  }));
14
8
 
15
9
  //#endregion
@@ -41,13 +35,6 @@ var require_constants = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
41
35
  };
42
36
  }));
43
37
 
44
- //#endregion
45
- //#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js
46
- var require_debug = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
47
- const debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
48
- module.exports = debug;
49
- }));
50
-
51
38
  //#endregion
52
39
  //#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/re.js
53
40
  var require_re = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
@@ -128,6 +115,19 @@ var require_re = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module)
128
115
  createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
129
116
  }));
130
117
 
118
+ //#endregion
119
+ //#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js
120
+ var require_parse_options = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
121
+ const looseOption = Object.freeze({ loose: true });
122
+ const emptyOpts = Object.freeze({});
123
+ const parseOptions = (options) => {
124
+ if (!options) return emptyOpts;
125
+ if (typeof options !== "object") return looseOption;
126
+ return options;
127
+ };
128
+ module.exports = parseOptions;
129
+ }));
130
+
131
131
  //#endregion
132
132
  //#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/identifiers.js
133
133
  var require_identifiers = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
@@ -0,0 +1,7 @@
1
+ require('./npm_cjs_chunk_semver.cjs');
2
+ const require_lt$1 = require('./npm_cjs_chunk_lt.cjs');
3
+
4
+ //#region dist/tsdown/_npm_entry_semver_functions_lt.cjs
5
+ module.exports = require_lt$1.require_lt();
6
+
7
+ //#endregion
@@ -1,6 +1,7 @@
1
1
  const require_chunk = require('./npm_cjs_chunk_chunk.cjs');
2
- const require_range$1 = require('./npm_cjs_chunk_range.cjs');
3
2
  require('./npm_cjs_chunk_semver.cjs');
3
+ require('./npm_cjs_chunk_lt.cjs');
4
+ const require_range$1 = require('./npm_cjs_chunk_range.cjs');
4
5
 
5
6
  //#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/satisfies.js
6
7
  var require_satisfies = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
@@ -1,6 +1,7 @@
1
1
  const require_chunk = require('./npm_cjs_chunk_chunk.cjs');
2
- const require_range$1 = require('./npm_cjs_chunk_range.cjs');
3
2
  const require_semver$1 = require('./npm_cjs_chunk_semver.cjs');
3
+ require('./npm_cjs_chunk_lt.cjs');
4
+ const require_range$1 = require('./npm_cjs_chunk_range.cjs');
4
5
 
5
6
  //#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-version.js
6
7
  var require_min_version = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
@@ -1,6 +1,6 @@
1
1
  import { t as createDebug } from "./node-Ba_UB_xO.js";
2
2
 
3
- //#region ../../node_modules/.pnpm/rolldown-plugin-dts@0.22.1_@typescript+native-preview@7.0.0-dev.20260122.2_oxc-resolver_d2e4a246ecba2d40b4415d1b79df8dc9/node_modules/rolldown-plugin-dts/dist/resolver-j7HY1N36.mjs
3
+ //#region ../../node_modules/.pnpm/rolldown-plugin-dts@0.22.4_@typescript+native-preview@7.0.0-dev.20260122.2_oxc-resolver_e2c498b62da30912fd0b48bf4746dbba/node_modules/rolldown-plugin-dts/dist/resolver-CdD-yT15.mjs
4
4
  const __cjs_require = globalThis.process.getBuiltinModule("module").createRequire(import.meta.url);
5
5
  const path = globalThis.process.getBuiltinModule("node:path");
6
6
  const ts = __cjs_require("typescript");
@@ -1,13 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { S as dim, l as globalLogger, r as version, t as K } from "./main-B3qcLRNf.js";
2
+ import { c as globalLogger, f as dim, g as yellow, r as version, t as K } from "./main-BWoReXjl.js";
3
3
  import "./node-Ba_UB_xO.js";
4
- import { t as enableDebug } from "./debug-BUVkFfEZ-D3UMJnif.js";
5
- import module from "node:module";
4
+ import { t as enableDebug } from "./debug-tOJ_PtrM-DITcI9An.js";
5
+ import module, { createRequire } from "node:module";
6
6
  import process$1 from "node:process";
7
7
  import { VERSION } from "@voidzero-dev/vite-plus-core/rolldown";
8
- import { EventEmitter } from "events";
9
8
 
10
- //#region ../../node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
9
+ //#region ../../node_modules/.pnpm/cac@7.0.0/node_modules/cac/dist/index.js
11
10
  function toArr(any) {
12
11
  return any == null ? [] : Array.isArray(any) ? any : [any];
13
12
  }
@@ -15,7 +14,7 @@ function toVal(out, key, val, opts) {
15
14
  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;
16
15
  out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
17
16
  }
18
- function mri2(args, opts) {
17
+ function lib_default(args, opts) {
19
18
  args = args || [];
20
19
  opts = opts || {};
21
20
  var k, arr, arg, name, val, out = { _: [] };
@@ -80,8 +79,10 @@ function mri2(args, opts) {
80
79
  }
81
80
  return out;
82
81
  }
83
- const removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
84
- const findAllBrackets = (v) => {
82
+ function removeBrackets(v) {
83
+ return v.replace(/[<[].+/, "").trim();
84
+ }
85
+ function findAllBrackets(v) {
85
86
  const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
86
87
  const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
87
88
  const res = [];
@@ -103,8 +104,8 @@ const findAllBrackets = (v) => {
103
104
  let squareMatch;
104
105
  while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) res.push(parse(squareMatch));
105
106
  return res;
106
- };
107
- const getMriOptions = (options) => {
107
+ }
108
+ function getMriOptions(options) {
108
109
  const result = {
109
110
  alias: {},
110
111
  boolean: []
@@ -118,62 +119,76 @@ const getMriOptions = (options) => {
118
119
  } else result.boolean.push(option.names[0]);
119
120
  }
120
121
  return result;
121
- };
122
- const findLongest = (arr) => {
122
+ }
123
+ function findLongest(arr) {
123
124
  return arr.sort((a, b) => {
124
125
  return a.length > b.length ? -1 : 1;
125
126
  })[0];
126
- };
127
- const padRight = (str, length) => {
127
+ }
128
+ function padRight(str, length) {
128
129
  return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
129
- };
130
- const camelcase = (input) => {
131
- return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
130
+ }
131
+ function camelcase(input) {
132
+ return input.replaceAll(/([a-z])-([a-z])/g, (_, p1, p2) => {
132
133
  return p1 + p2.toUpperCase();
133
134
  });
134
- };
135
- const setDotProp = (obj, keys, val) => {
136
- let i = 0;
137
- let length = keys.length;
138
- let t = obj;
139
- let x;
140
- for (; i < length; ++i) {
141
- x = t[keys[i]];
142
- t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
135
+ }
136
+ function setDotProp(obj, keys, val) {
137
+ let current = obj;
138
+ for (let i = 0; i < keys.length; i++) {
139
+ const key = keys[i];
140
+ if (i === keys.length - 1) {
141
+ current[key] = val;
142
+ return;
143
+ }
144
+ if (current[key] == null) {
145
+ const nextKeyIsArrayIndex = +keys[i + 1] > -1;
146
+ current[key] = nextKeyIsArrayIndex ? [] : {};
147
+ }
148
+ current = current[key];
143
149
  }
144
- };
145
- const setByType = (obj, transforms) => {
150
+ }
151
+ function setByType(obj, transforms) {
146
152
  for (const key of Object.keys(transforms)) {
147
153
  const transform = transforms[key];
148
154
  if (transform.shouldTransform) {
149
- obj[key] = Array.prototype.concat.call([], obj[key]);
155
+ obj[key] = [obj[key]].flat();
150
156
  if (typeof transform.transformFunction === "function") obj[key] = obj[key].map(transform.transformFunction);
151
157
  }
152
158
  }
153
- };
154
- const getFileName = (input) => {
155
- const m = /([^\\\/]+)$/.exec(input);
159
+ }
160
+ function getFileName(input) {
161
+ const m = /([^\\/]+)$/.exec(input);
156
162
  return m ? m[1] : "";
157
- };
158
- const camelcaseOptionName = (name) => {
163
+ }
164
+ function camelcaseOptionName(name) {
159
165
  return name.split(".").map((v, i) => {
160
166
  return i === 0 ? camelcase(v) : v;
161
167
  }).join(".");
162
- };
168
+ }
163
169
  var CACError = class extends Error {
164
170
  constructor(message) {
165
171
  super(message);
166
- this.name = this.constructor.name;
167
- if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(this, this.constructor);
168
- else this.stack = new Error(message).stack;
172
+ this.name = "CACError";
173
+ if (typeof Error.captureStackTrace !== "function") this.stack = new Error(message).stack;
169
174
  }
170
175
  };
171
176
  var Option = class {
177
+ rawName;
178
+ description;
179
+ /** Option name */
180
+ name;
181
+ /** Option name and aliases */
182
+ names;
183
+ isBoolean;
184
+ required;
185
+ config;
186
+ negated;
172
187
  constructor(rawName, description, config) {
173
188
  this.rawName = rawName;
174
189
  this.description = description;
175
190
  this.config = Object.assign({}, config);
176
- rawName = rawName.replace(/\.\*/g, "");
191
+ rawName = rawName.replaceAll(".*", "");
177
192
  this.negated = false;
178
193
  this.names = removeBrackets(rawName).split(",").map((v) => {
179
194
  let name = v.trim().replace(/^-{1,2}/, "");
@@ -183,16 +198,39 @@ var Option = class {
183
198
  }
184
199
  return camelcaseOptionName(name);
185
200
  }).sort((a, b) => a.length > b.length ? 1 : -1);
186
- this.name = this.names[this.names.length - 1];
201
+ this.name = this.names.at(-1);
187
202
  if (this.negated && this.config.default == null) this.config.default = true;
188
203
  if (rawName.includes("<")) this.required = true;
189
204
  else if (rawName.includes("[")) this.required = false;
190
205
  else this.isBoolean = true;
191
206
  }
192
207
  };
193
- const processArgs = process.argv;
194
- const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
208
+ let runtimeProcessArgs;
209
+ let runtimeInfo;
210
+ if (typeof process !== "undefined") {
211
+ let runtimeName;
212
+ if (typeof Deno !== "undefined" && typeof Deno.version?.deno === "string") runtimeName = "deno";
213
+ else if (typeof Bun !== "undefined" && typeof Bun.version === "string") runtimeName = "bun";
214
+ else runtimeName = "node";
215
+ runtimeInfo = `${process.platform}-${process.arch} ${runtimeName}-${process.version}`;
216
+ runtimeProcessArgs = process.argv;
217
+ } else if (typeof navigator === "undefined") runtimeInfo = `unknown`;
218
+ else runtimeInfo = `${navigator.platform} ${navigator.userAgent}`;
195
219
  var Command = class {
220
+ rawName;
221
+ description;
222
+ config;
223
+ cli;
224
+ options;
225
+ aliasNames;
226
+ name;
227
+ args;
228
+ commandAction;
229
+ usageText;
230
+ versionNumber;
231
+ examples;
232
+ helpCallback;
233
+ globalCommand;
196
234
  constructor(rawName, description, config = {}, cli) {
197
235
  this.rawName = rawName;
198
236
  this.description = description;
@@ -225,6 +263,12 @@ var Command = class {
225
263
  this.examples.push(example);
226
264
  return this;
227
265
  }
266
+ /**
267
+ * Add a option for this command
268
+ * @param rawName Raw option name(s)
269
+ * @param description Option description
270
+ * @param config Option config
271
+ */
228
272
  option(rawName, description, config) {
229
273
  const option = new Option(rawName, description, config);
230
274
  this.options.push(option);
@@ -238,6 +282,10 @@ var Command = class {
238
282
  this.commandAction = callback;
239
283
  return this;
240
284
  }
285
+ /**
286
+ * Check if a command name is matched by this command
287
+ * @param name Command name
288
+ */
241
289
  isMatched(name) {
242
290
  return this.name === name || this.aliasNames.includes(name);
243
291
  }
@@ -247,6 +295,10 @@ var Command = class {
247
295
  get isGlobalCommand() {
248
296
  return this instanceof GlobalCommand;
249
297
  }
298
+ /**
299
+ * Check if an option is registered in this command
300
+ * @param name Option name
301
+ */
250
302
  hasOption(name) {
251
303
  name = name.split(".")[0];
252
304
  return this.options.find((option) => {
@@ -268,8 +320,7 @@ var Command = class {
268
320
  body: commands.map((command) => {
269
321
  return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
270
322
  }).join("\n")
271
- });
272
- sections.push({
323
+ }, {
273
324
  title: `For more info, run any command with the \`--help\` flag`,
274
325
  body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
275
326
  });
@@ -293,26 +344,33 @@ var Command = class {
293
344
  }).join("\n")
294
345
  });
295
346
  if (helpCallback) sections = helpCallback(sections) || sections;
296
- console.log(sections.map((section) => {
297
- return section.title ? `${section.title}:
298
- ${section.body}` : section.body;
347
+ console.info(sections.map((section) => {
348
+ return section.title ? `${section.title}:\n${section.body}` : section.body;
299
349
  }).join("\n\n"));
300
350
  }
301
351
  outputVersion() {
302
352
  const { name } = this.cli;
303
353
  const { versionNumber } = this.cli.globalCommand;
304
- if (versionNumber) console.log(`${name}/${versionNumber} ${platformInfo}`);
354
+ if (versionNumber) console.info(`${name}/${versionNumber} ${runtimeInfo}`);
305
355
  }
306
356
  checkRequiredArgs() {
307
357
  const minimalArgsCount = this.args.filter((arg) => arg.required).length;
308
358
  if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
309
359
  }
360
+ /**
361
+ * Check if the parsed options contain any unknown options
362
+ *
363
+ * Exit and output error when true
364
+ */
310
365
  checkUnknownOptions() {
311
366
  const { options, globalCommand } = this.cli;
312
367
  if (!this.config.allowUnknownOptions) {
313
368
  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}`}\``);
314
369
  }
315
370
  }
371
+ /**
372
+ * Check if the required string-type options exist
373
+ */
316
374
  checkOptionValue() {
317
375
  const { options: parsedOptions, globalCommand } = this.cli;
318
376
  const options = [...globalCommand.options, ...this.options];
@@ -324,14 +382,43 @@ ${section.body}` : section.body;
324
382
  }
325
383
  }
326
384
  }
385
+ /**
386
+ * Check if the number of args is more than expected
387
+ */
388
+ checkUnusedArgs() {
389
+ const maximumArgsCount = this.args.some((arg) => arg.variadic) ? Infinity : this.args.length;
390
+ if (maximumArgsCount < this.cli.args.length) throw new CACError(`Unused args: ${this.cli.args.slice(maximumArgsCount).map((arg) => `\`${arg}\``).join(", ")}`);
391
+ }
327
392
  };
328
393
  var GlobalCommand = class extends Command {
329
394
  constructor(cli) {
330
395
  super("@@global@@", "", {}, cli);
331
396
  }
332
397
  };
333
- var __assign = Object.assign;
334
- var CAC = class extends EventEmitter {
398
+ var CAC = class extends EventTarget {
399
+ /** The program name to display in help and version message */
400
+ name;
401
+ commands;
402
+ globalCommand;
403
+ matchedCommand;
404
+ matchedCommandName;
405
+ /**
406
+ * Raw CLI arguments
407
+ */
408
+ rawArgs;
409
+ /**
410
+ * Parsed CLI arguments
411
+ */
412
+ args;
413
+ /**
414
+ * Parsed CLI options, camelCased
415
+ */
416
+ options;
417
+ showHelpOnExit;
418
+ showVersionOnExit;
419
+ /**
420
+ * @param name The program name to display in help and version message
421
+ */
335
422
  constructor(name = "") {
336
423
  super();
337
424
  this.name = name;
@@ -342,39 +429,75 @@ var CAC = class extends EventEmitter {
342
429
  this.globalCommand = new GlobalCommand(this);
343
430
  this.globalCommand.usage("<command> [options]");
344
431
  }
432
+ /**
433
+ * Add a global usage text.
434
+ *
435
+ * This is not used by sub-commands.
436
+ */
345
437
  usage(text) {
346
438
  this.globalCommand.usage(text);
347
439
  return this;
348
440
  }
441
+ /**
442
+ * Add a sub-command
443
+ */
349
444
  command(rawName, description, config) {
350
445
  const command = new Command(rawName, description || "", config, this);
351
446
  command.globalCommand = this.globalCommand;
352
447
  this.commands.push(command);
353
448
  return command;
354
449
  }
450
+ /**
451
+ * Add a global CLI option.
452
+ *
453
+ * Which is also applied to sub-commands.
454
+ */
355
455
  option(rawName, description, config) {
356
456
  this.globalCommand.option(rawName, description, config);
357
457
  return this;
358
458
  }
459
+ /**
460
+ * Show help message when `-h, --help` flags appear.
461
+ *
462
+ */
359
463
  help(callback) {
360
464
  this.globalCommand.option("-h, --help", "Display this message");
361
465
  this.globalCommand.helpCallback = callback;
362
466
  this.showHelpOnExit = true;
363
467
  return this;
364
468
  }
469
+ /**
470
+ * Show version number when `-v, --version` flags appear.
471
+ *
472
+ */
365
473
  version(version, customFlags = "-v, --version") {
366
474
  this.globalCommand.version(version, customFlags);
367
475
  this.showVersionOnExit = true;
368
476
  return this;
369
477
  }
478
+ /**
479
+ * Add a global example.
480
+ *
481
+ * This example added here will not be used by sub-commands.
482
+ */
370
483
  example(example) {
371
484
  this.globalCommand.example(example);
372
485
  return this;
373
486
  }
487
+ /**
488
+ * Output the corresponding help message
489
+ * When a sub-command is matched, output the help message for the command
490
+ * Otherwise output the global one.
491
+ *
492
+ */
374
493
  outputHelp() {
375
494
  if (this.matchedCommand) this.matchedCommand.outputHelp();
376
495
  else this.globalCommand.outputHelp();
377
496
  }
497
+ /**
498
+ * Output the version number.
499
+ *
500
+ */
378
501
  outputVersion() {
379
502
  this.globalCommand.outputVersion();
380
503
  }
@@ -389,7 +512,14 @@ var CAC = class extends EventEmitter {
389
512
  this.matchedCommand = void 0;
390
513
  this.matchedCommandName = void 0;
391
514
  }
392
- parse(argv = processArgs, { run = true } = {}) {
515
+ /**
516
+ * Parse argv
517
+ */
518
+ parse(argv, { run = true } = {}) {
519
+ if (!argv) {
520
+ if (!runtimeProcessArgs) throw new Error("No argv provided and runtime process argv is not available.");
521
+ argv = runtimeProcessArgs;
522
+ }
393
523
  this.rawArgs = argv;
394
524
  if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
395
525
  let shouldParse = true;
@@ -398,17 +528,20 @@ var CAC = class extends EventEmitter {
398
528
  const commandName = parsed.args[0];
399
529
  if (command.isMatched(commandName)) {
400
530
  shouldParse = false;
401
- const parsedInfo = __assign(__assign({}, parsed), { args: parsed.args.slice(1) });
531
+ const parsedInfo = {
532
+ ...parsed,
533
+ args: parsed.args.slice(1)
534
+ };
402
535
  this.setParsedInfo(parsedInfo, command, commandName);
403
- this.emit(`command:${commandName}`, command);
536
+ this.dispatchEvent(new CustomEvent(`command:${commandName}`, { detail: command }));
404
537
  }
405
538
  }
406
539
  if (shouldParse) {
407
- for (const command of this.commands) if (command.name === "") {
540
+ for (const command of this.commands) if (command.isDefaultCommand) {
408
541
  shouldParse = false;
409
542
  const parsed = this.mri(argv.slice(2), command);
410
543
  this.setParsedInfo(parsed, command);
411
- this.emit(`command:!`, command);
544
+ this.dispatchEvent(new CustomEvent("command:!", { detail: command }));
412
545
  }
413
546
  }
414
547
  if (shouldParse) {
@@ -430,7 +563,7 @@ var CAC = class extends EventEmitter {
430
563
  options: this.options
431
564
  };
432
565
  if (run) this.runMatchedCommand();
433
- if (!this.matchedCommand && this.args[0]) this.emit("command:*");
566
+ if (!this.matchedCommand && this.args[0]) this.dispatchEvent(new CustomEvent("command:*", { detail: this.args[0] }));
434
567
  return parsedArgv;
435
568
  }
436
569
  mri(argv, command) {
@@ -438,26 +571,27 @@ var CAC = class extends EventEmitter {
438
571
  const mriOptions = getMriOptions(cliOptions);
439
572
  let argsAfterDoubleDashes = [];
440
573
  const doubleDashesIndex = argv.indexOf("--");
441
- if (doubleDashesIndex > -1) {
574
+ if (doubleDashesIndex !== -1) {
442
575
  argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
443
576
  argv = argv.slice(0, doubleDashesIndex);
444
577
  }
445
- let parsed = mri2(argv, mriOptions);
578
+ let parsed = lib_default(argv, mriOptions);
446
579
  parsed = Object.keys(parsed).reduce((res, name) => {
447
- return __assign(__assign({}, res), { [camelcaseOptionName(name)]: parsed[name] });
580
+ return {
581
+ ...res,
582
+ [camelcaseOptionName(name)]: parsed[name]
583
+ };
448
584
  }, { _: [] });
449
585
  const args = parsed._;
450
586
  const options = { "--": argsAfterDoubleDashes };
451
587
  const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
452
- let transforms = Object.create(null);
588
+ const transforms = Object.create(null);
453
589
  for (const cliOption of cliOptions) {
454
590
  if (!ignoreDefault && cliOption.config.default !== void 0) for (const name of cliOption.names) options[name] = cliOption.config.default;
455
- if (Array.isArray(cliOption.config.type)) {
456
- if (transforms[cliOption.name] === void 0) {
457
- transforms[cliOption.name] = Object.create(null);
458
- transforms[cliOption.name]["shouldTransform"] = true;
459
- transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
460
- }
591
+ if (Array.isArray(cliOption.config.type) && transforms[cliOption.name] === void 0) {
592
+ transforms[cliOption.name] = Object.create(null);
593
+ transforms[cliOption.name].shouldTransform = true;
594
+ transforms[cliOption.name].transformFunction = cliOption.config.type[0];
461
595
  }
462
596
  }
463
597
  for (const key of Object.keys(parsed)) if (key !== "_") {
@@ -475,6 +609,7 @@ var CAC = class extends EventEmitter {
475
609
  command.checkUnknownOptions();
476
610
  command.checkOptionValue();
477
611
  command.checkRequiredArgs();
612
+ command.checkUnusedArgs();
478
613
  const actionArgs = [];
479
614
  command.args.forEach((arg, index) => {
480
615
  if (arg.variadic) actionArgs.push(args.slice(index));
@@ -484,10 +619,15 @@ var CAC = class extends EventEmitter {
484
619
  return command.commandAction.apply(this, actionArgs);
485
620
  }
486
621
  };
622
+ /**
623
+ * @param name The program name to display in help and version message
624
+ */
487
625
  const cac = (name = "") => new CAC(name);
488
626
 
489
627
  //#endregion
490
- //#region ../../node_modules/.pnpm/tsdown@0.21.0-beta.2_@arethetypeswrong+core@0.18.2_@typescript+native-preview@7.0.0-dev_d0d0ed2124937ee9dd401a280008a3bf/node_modules/tsdown/dist/run.mjs
628
+ //#region ../../node_modules/.pnpm/tsdown@0.21.0_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.0_@tsdown+exe@0.21.0_@type_743816f26d68021f6369d2afb428dae9/node_modules/tsdown/dist/run.mjs
629
+ const __cjs_require = createRequire(import.meta.url);
630
+ const lt = __cjs_require("./npm_entry_semver_functions_lt.cjs");
491
631
  const cli = cac("tsdown");
492
632
  cli.help().version(version);
493
633
  cli.command("[...files]", "Bundle files", {
@@ -496,7 +636,7 @@ cli.command("[...files]", "Bundle files", {
496
636
  }).option("-c, --config <filename>", "Use a custom config file").option("--config-loader <loader>", "Config loader to use: auto, native, unrun", { default: "auto" }).option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--deps.never-bundle <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--devtools", "Enable devtools integration").option("--debug [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("-l, --logLevel <level>", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).option("--no-write", "Disable writing files to disk, incompatible with watch mode").option("-d, --out-dir <dir>", "Output directory", { default: "dist" }).option("--treeshake", "Tree-shake bundle", { default: true }).option("--sourcemap", "Generate source map", { default: false }).option("--shims", "Enable cjs and esm shims ", { default: false }).option("--platform <platform>", "Target platform", { default: "node" }).option("--dts", "Generate dts files").option("--publint", "Enable publint", { default: false }).option("--attw", "Enable Are the types wrong integration", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--ignore-watch <path>", "Ignore custom paths in watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* <value>", "Define compile-time env variables").option("--env-file <file>", "Load environment variables from a file, when used together with --env, variables in --env take precedence").option("--env-prefix <prefix>", "Prefix for env variables to inject into the bundle", { default: "TSDOWN_" }).option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--public-dir <dir>", "Alias for --copy, deprecated").option("--tsconfig <tsconfig>", "Set tsconfig path").option("--unbundle", "Unbundle mode").option("--exe", "Bundle as executable").option("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter <pattern>", "Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
497
637
  globalLogger.level = flags.logLevel || "info";
498
638
  globalLogger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
499
- const { build } = await import("./build-2oRq4mfQ-YC_gzK3u.js");
639
+ const { build } = await import("./build-gOkJM1H9-BRI3DQle.js");
500
640
  if (input.length > 0) flags.entry = input;
501
641
  await build(flags);
502
642
  });
@@ -528,6 +668,7 @@ async function runCLI() {
528
668
  process$1.exit(1);
529
669
  }
530
670
  }
671
+ if (lt(process$1.version, "22.18.0")) console.warn(yellow`[tsdown] Node.js ${process$1.version} is deprecated. Support will be removed in the next minor release. Please upgrade to Node.js 22.18.0 or later.`);
531
672
  try {
532
673
  module.enableCompileCache?.();
533
674
  } catch {}