vite-plus 0.3.0 → 0.3.1

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 (80) hide show
  1. package/LICENSE +29 -29
  2. package/README.md +2 -2
  3. package/binding/index.cjs +60 -55
  4. package/binding/index.d.cts +125 -14
  5. package/dist/{agent-Wqx0MPk0.js → agent-C5jMYVfB.js} +3 -2
  6. package/dist/bin.js +89 -58
  7. package/dist/cli-parse-DHE8NrBU.js +13 -0
  8. package/dist/client/bundledDevClient.mjs +1 -1
  9. package/dist/client/client.mjs +1 -1
  10. package/dist/client/env.mjs +1 -1
  11. package/dist/client.d.ts +1 -1
  12. package/dist/config/bin.js +83 -55
  13. package/dist/{constants-Bn-U8o4v.js → constants-0IAVgpox.js} +3 -3
  14. package/dist/create/bin.d.ts +13 -5
  15. package/dist/create/bin.js +37 -190
  16. package/dist/{define-config-WiVlryJ2.cjs → define-config-DIE9de46.cjs} +1 -1
  17. package/dist/{define-config-DWoAkNdp.d.ts → define-config-DPNEJxPz.d.ts} +5 -9
  18. package/dist/{define-config-GXUdVT-0.js → define-config-U3_xg7i-.js} +2 -2
  19. package/dist/define-config.cjs +1 -1
  20. package/dist/define-config.d.ts +1 -1
  21. package/dist/define-config.js +1 -1
  22. package/dist/dist-DfmT__Aw.js +619 -0
  23. package/dist/{editor-CC4DqODz.js → editor-B5-lvRaU.js} +68 -40
  24. package/dist/hooks/bin.js +9 -114
  25. package/dist/{hooks-DFqViZqZ.js → hooks-C-4gykWR.js} +1 -1
  26. package/dist/index.cjs +2 -2
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.js +2 -2
  29. package/dist/internal.d.ts +1 -1
  30. package/dist/internal.js +1 -1
  31. package/dist/migration/bin.js +24 -143
  32. package/dist/migration/compat/worker.js +1 -1
  33. package/dist/module-runner.d.ts +1 -1
  34. package/dist/module-runner.js +1 -1
  35. package/dist/{oxlint-plugin-config-DX5ezKbB.js → oxlint-plugin-config-Drdl67Xp.js} +1 -1
  36. package/dist/oxlint-plugin.d.ts +2 -2
  37. package/dist/oxlint-plugin.js +1 -1
  38. package/dist/{pack-PvUg_xpv.d.ts → pack-BK38MLVZ.d.ts} +1 -1
  39. package/dist/pack-bin.d.ts +2 -3
  40. package/dist/pack-bin.js +5 -622
  41. package/dist/pack-client.d.ts +1 -1
  42. package/dist/pack.d.ts +2 -2
  43. package/dist/pack.js +1 -1
  44. package/dist/{package-CBe9EWPY.js → package-BZz2Ij68.js} +1 -1
  45. package/dist/{prompts-DF3yU-eU.js → prompts-CtzEgFY-.js} +3 -1400
  46. package/dist/{report-ZNR1Mk6h.js → report-CK5TnTsr.js} +1 -0
  47. package/dist/{resolve-vite-config-ipGb39Jo.js → resolve-vite-config-CGks1xR7.js} +3 -3
  48. package/dist/resolve-vite-config-Dnmc-lBc.js +2 -0
  49. package/dist/semver-CaDAb8vV.js +1400 -0
  50. package/dist/staged/bin.js +83 -218
  51. package/dist/sync-versions/bin.d.ts +1 -0
  52. package/dist/sync-versions/bin.js +3884 -0
  53. package/dist/sync-versions/bin.mjs +13323 -0
  54. package/dist/toolchain.js +9 -9
  55. package/dist/toolchain.json +9 -9
  56. package/dist/{tsconfig-LD2QhQ0O.js → tsconfig-CUggNuJR.js} +2 -2
  57. package/dist/{tsconfig-BVHG3DpR.js → tsconfig-VAbm4ZzJ.js} +1 -1
  58. package/dist/tsgolint-path.d.ts +3 -4
  59. package/dist/types/customEvent.d.ts +1 -1
  60. package/dist/types/hmrPayload.d.ts +1 -1
  61. package/dist/types/hot.d.ts +1 -1
  62. package/dist/types/import-meta.d.ts +1 -1
  63. package/dist/types/importGlob.d.ts +1 -1
  64. package/dist/types/importMeta.d.ts +1 -1
  65. package/dist/types/metadata.d.ts +1 -1
  66. package/dist/version.d.ts +2 -3
  67. package/dist/version.js +2 -2
  68. package/dist/versions.js +4 -4
  69. package/dist/vitest-ecosystem-BiRqcaRI.js +23 -0
  70. package/docs/guide/check.md +1 -0
  71. package/docs/guide/ci.md +42 -2
  72. package/docs/guide/env.md +124 -52
  73. package/docs/guide/ide-integration.md +14 -2
  74. package/docs/guide/index.md +1 -1
  75. package/docs/guide/install.md +3 -1
  76. package/docs/guide/installer-env-vars.md +10 -0
  77. package/docs/guide/migrate-rules.md +57 -2
  78. package/package.json +17 -19
  79. package/dist/lib-L3DWSRQp.js +0 -75
  80. package/dist/{log-update-DHZRyJ2m.js → log-update-CoW8Z4Dl.js} +1 -1
package/dist/pack-bin.js CHANGED
@@ -1,625 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { a as resolveViteConfig } from "./resolve-vite-config-ipGb39Jo.js";
2
+ import { t as cac } from "./dist-DfmT__Aw.js";
3
+ import { o as resolveViteConfig } from "./resolve-vite-config-CGks1xR7.js";
3
4
  import module from "node:module";
4
- import { buildWithConfigs, enableDebug, globalLogger, resolveUserConfig } from "@voidzero-dev/vite-plus-core/pack";
5
- //#region ../../node_modules/.pnpm/cac@7.0.0/node_modules/cac/dist/index.js
6
- function toArr(any) {
7
- return any == null ? [] : Array.isArray(any) ? any : [any];
8
- }
9
- function toVal(out, key, val, opts) {
10
- 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;
11
- out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
12
- }
13
- function lib_default(args, opts) {
14
- args = args || [];
15
- opts = opts || {};
16
- var k, arr, arg, name, val, out = { _: [] };
17
- var i = 0, j = 0, idx = 0, len = args.length;
18
- const alibi = opts.alias !== void 0;
19
- const strict = opts.unknown !== void 0;
20
- const defaults = opts.default !== void 0;
21
- opts.alias = opts.alias || {};
22
- opts.string = toArr(opts.string);
23
- opts.boolean = toArr(opts.boolean);
24
- if (alibi) for (k in opts.alias) {
25
- arr = opts.alias[k] = toArr(opts.alias[k]);
26
- for (i = 0; i < arr.length; i++) (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
27
- }
28
- for (i = opts.boolean.length; i-- > 0;) {
29
- arr = opts.alias[opts.boolean[i]] || [];
30
- for (j = arr.length; j-- > 0;) opts.boolean.push(arr[j]);
31
- }
32
- for (i = opts.string.length; i-- > 0;) {
33
- arr = opts.alias[opts.string[i]] || [];
34
- for (j = arr.length; j-- > 0;) opts.string.push(arr[j]);
35
- }
36
- if (defaults) for (k in opts.default) {
37
- name = typeof opts.default[k];
38
- arr = opts.alias[k] = opts.alias[k] || [];
39
- if (opts[name] !== void 0) {
40
- opts[name].push(k);
41
- for (i = 0; i < arr.length; i++) opts[name].push(arr[i]);
42
- }
43
- }
44
- const keys = strict ? Object.keys(opts.alias) : [];
45
- for (i = 0; i < len; i++) {
46
- arg = args[i];
47
- if (arg === "--") {
48
- out._ = out._.concat(args.slice(++i));
49
- break;
50
- }
51
- for (j = 0; j < arg.length; j++) if (arg.charCodeAt(j) !== 45) break;
52
- if (j === 0) out._.push(arg);
53
- else if (arg.substring(j, j + 3) === "no-") {
54
- name = arg.substring(j + 3);
55
- if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
56
- out[name] = false;
57
- } else {
58
- for (idx = j + 1; idx < arg.length; idx++) if (arg.charCodeAt(idx) === 61) break;
59
- name = arg.substring(j, idx);
60
- val = arg.substring(++idx) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
61
- arr = j === 2 ? [name] : name;
62
- for (idx = 0; idx < arr.length; idx++) {
63
- name = arr[idx];
64
- if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
65
- toVal(out, name, idx + 1 < arr.length || val, opts);
66
- }
67
- }
68
- }
69
- if (defaults) {
70
- for (k in opts.default) if (out[k] === void 0) out[k] = opts.default[k];
71
- }
72
- if (alibi) for (k in out) {
73
- arr = opts.alias[k] || [];
74
- while (arr.length > 0) out[arr.shift()] = out[k];
75
- }
76
- return out;
77
- }
78
- function removeBrackets(v) {
79
- return v.replace(/[<[].+/, "").trim();
80
- }
81
- function findAllBrackets(v) {
82
- const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
83
- const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
84
- const res = [];
85
- const parse = (match) => {
86
- let variadic = false;
87
- let value = match[1];
88
- if (value.startsWith("...")) {
89
- value = value.slice(3);
90
- variadic = true;
91
- }
92
- return {
93
- required: match[0].startsWith("<"),
94
- value,
95
- variadic
96
- };
97
- };
98
- let angledMatch;
99
- while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) res.push(parse(angledMatch));
100
- let squareMatch;
101
- while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) res.push(parse(squareMatch));
102
- return res;
103
- }
104
- function getMriOptions(options) {
105
- const result = {
106
- alias: {},
107
- boolean: []
108
- };
109
- for (const [index, option] of options.entries()) {
110
- if (option.names.length > 1) result.alias[option.names[0]] = option.names.slice(1);
111
- if (option.isBoolean) if (option.negated) {
112
- if (!options.some((o, i) => {
113
- return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
114
- })) result.boolean.push(option.names[0]);
115
- } else result.boolean.push(option.names[0]);
116
- }
117
- return result;
118
- }
119
- function findLongest(arr) {
120
- return arr.sort((a, b) => {
121
- return a.length > b.length ? -1 : 1;
122
- })[0];
123
- }
124
- function padRight(str, length) {
125
- return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
126
- }
127
- function camelcase(input) {
128
- return input.replaceAll(/([a-z])-([a-z])/g, (_, p1, p2) => {
129
- return p1 + p2.toUpperCase();
130
- });
131
- }
132
- function setDotProp(obj, keys, val) {
133
- let current = obj;
134
- for (let i = 0; i < keys.length; i++) {
135
- const key = keys[i];
136
- if (i === keys.length - 1) {
137
- current[key] = val;
138
- return;
139
- }
140
- if (current[key] == null) {
141
- const nextKeyIsArrayIndex = +keys[i + 1] > -1;
142
- current[key] = nextKeyIsArrayIndex ? [] : {};
143
- }
144
- current = current[key];
145
- }
146
- }
147
- function setByType(obj, transforms) {
148
- for (const key of Object.keys(transforms)) {
149
- const transform = transforms[key];
150
- if (transform.shouldTransform) {
151
- obj[key] = [obj[key]].flat();
152
- if (typeof transform.transformFunction === "function") obj[key] = obj[key].map(transform.transformFunction);
153
- }
154
- }
155
- }
156
- function getFileName(input) {
157
- const m = /([^\\/]+)$/.exec(input);
158
- return m ? m[1] : "";
159
- }
160
- function camelcaseOptionName(name) {
161
- return name.split(".").map((v, i) => {
162
- return i === 0 ? camelcase(v) : v;
163
- }).join(".");
164
- }
165
- var CACError = class extends Error {
166
- constructor(message) {
167
- super(message);
168
- this.name = "CACError";
169
- if (typeof Error.captureStackTrace !== "function") this.stack = new Error(message).stack;
170
- }
171
- };
172
- var Option = class {
173
- rawName;
174
- description;
175
- /** Option name */
176
- name;
177
- /** Option name and aliases */
178
- names;
179
- isBoolean;
180
- required;
181
- config;
182
- negated;
183
- constructor(rawName, description, config) {
184
- this.rawName = rawName;
185
- this.description = description;
186
- this.config = Object.assign({}, config);
187
- rawName = rawName.replaceAll(".*", "");
188
- this.negated = false;
189
- this.names = removeBrackets(rawName).split(",").map((v) => {
190
- let name = v.trim().replace(/^-{1,2}/, "");
191
- if (name.startsWith("no-")) {
192
- this.negated = true;
193
- name = name.replace(/^no-/, "");
194
- }
195
- return camelcaseOptionName(name);
196
- }).sort((a, b) => a.length > b.length ? 1 : -1);
197
- this.name = this.names.at(-1);
198
- if (this.negated && this.config.default == null) this.config.default = true;
199
- if (rawName.includes("<")) this.required = true;
200
- else if (rawName.includes("[")) this.required = false;
201
- else this.isBoolean = true;
202
- }
203
- };
204
- let runtimeProcessArgs;
205
- let runtimeInfo;
206
- if (typeof process !== "undefined") {
207
- let runtimeName;
208
- if (typeof Deno !== "undefined" && typeof Deno.version?.deno === "string") runtimeName = "deno";
209
- else if (typeof Bun !== "undefined" && typeof Bun.version === "string") runtimeName = "bun";
210
- else runtimeName = "node";
211
- runtimeInfo = `${process.platform}-${process.arch} ${runtimeName}-${process.version}`;
212
- runtimeProcessArgs = process.argv;
213
- } else if (typeof navigator === "undefined") runtimeInfo = `unknown`;
214
- else runtimeInfo = `${navigator.platform} ${navigator.userAgent}`;
215
- var Command = class {
216
- rawName;
217
- description;
218
- config;
219
- cli;
220
- options;
221
- aliasNames;
222
- name;
223
- args;
224
- commandAction;
225
- usageText;
226
- versionNumber;
227
- examples;
228
- helpCallback;
229
- globalCommand;
230
- constructor(rawName, description, config = {}, cli) {
231
- this.rawName = rawName;
232
- this.description = description;
233
- this.config = config;
234
- this.cli = cli;
235
- this.options = [];
236
- this.aliasNames = [];
237
- this.name = removeBrackets(rawName);
238
- this.args = findAllBrackets(rawName);
239
- this.examples = [];
240
- }
241
- usage(text) {
242
- this.usageText = text;
243
- return this;
244
- }
245
- allowUnknownOptions() {
246
- this.config.allowUnknownOptions = true;
247
- return this;
248
- }
249
- ignoreOptionDefaultValue() {
250
- this.config.ignoreOptionDefaultValue = true;
251
- return this;
252
- }
253
- version(version, customFlags = "-v, --version") {
254
- this.versionNumber = version;
255
- this.option(customFlags, "Display version number");
256
- return this;
257
- }
258
- example(example) {
259
- this.examples.push(example);
260
- return this;
261
- }
262
- /**
263
- * Add a option for this command
264
- * @param rawName Raw option name(s)
265
- * @param description Option description
266
- * @param config Option config
267
- */
268
- option(rawName, description, config) {
269
- const option = new Option(rawName, description, config);
270
- this.options.push(option);
271
- return this;
272
- }
273
- alias(name) {
274
- this.aliasNames.push(name);
275
- return this;
276
- }
277
- action(callback) {
278
- this.commandAction = callback;
279
- return this;
280
- }
281
- /**
282
- * Check if a command name is matched by this command
283
- * @param name Command name
284
- */
285
- isMatched(name) {
286
- return this.name === name || this.aliasNames.includes(name);
287
- }
288
- get isDefaultCommand() {
289
- return this.name === "" || this.aliasNames.includes("!");
290
- }
291
- get isGlobalCommand() {
292
- return this instanceof GlobalCommand;
293
- }
294
- /**
295
- * Check if an option is registered in this command
296
- * @param name Option name
297
- */
298
- hasOption(name) {
299
- name = name.split(".")[0];
300
- return this.options.find((option) => {
301
- return option.names.includes(name);
302
- });
303
- }
304
- outputHelp() {
305
- const { name, commands } = this.cli;
306
- const { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand;
307
- let sections = [{ body: `${name}${versionNumber ? `/${versionNumber}` : ""}` }];
308
- sections.push({
309
- title: "Usage",
310
- body: ` $ ${name} ${this.usageText || this.rawName}`
311
- });
312
- if ((this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0) {
313
- const longestCommandName = findLongest(commands.map((command) => command.rawName));
314
- sections.push({
315
- title: "Commands",
316
- body: commands.map((command) => {
317
- return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
318
- }).join("\n")
319
- }, {
320
- title: `For more info, run any command with the \`--help\` flag`,
321
- body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
322
- });
323
- }
324
- let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
325
- if (!this.isGlobalCommand && !this.isDefaultCommand) options = options.filter((option) => option.name !== "version");
326
- if (options.length > 0) {
327
- const longestOptionName = findLongest(options.map((option) => option.rawName));
328
- sections.push({
329
- title: "Options",
330
- body: options.map((option) => {
331
- return ` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${option.config.default === void 0 ? "" : `(default: ${option.config.default})`}`;
332
- }).join("\n")
333
- });
334
- }
335
- if (this.examples.length > 0) sections.push({
336
- title: "Examples",
337
- body: this.examples.map((example) => {
338
- if (typeof example === "function") return example(name);
339
- return example;
340
- }).join("\n")
341
- });
342
- if (helpCallback) sections = helpCallback(sections) || sections;
343
- console.info(sections.map((section) => {
344
- return section.title ? `${section.title}:\n${section.body}` : section.body;
345
- }).join("\n\n"));
346
- }
347
- outputVersion() {
348
- const { name } = this.cli;
349
- const { versionNumber } = this.cli.globalCommand;
350
- if (versionNumber) console.info(`${name}/${versionNumber} ${runtimeInfo}`);
351
- }
352
- checkRequiredArgs() {
353
- const minimalArgsCount = this.args.filter((arg) => arg.required).length;
354
- if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
355
- }
356
- /**
357
- * Check if the parsed options contain any unknown options
358
- *
359
- * Exit and output error when true
360
- */
361
- checkUnknownOptions() {
362
- const { options, globalCommand } = this.cli;
363
- if (!this.config.allowUnknownOptions) {
364
- 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}`}\``);
365
- }
366
- }
367
- /**
368
- * Check if the required string-type options exist
369
- */
370
- checkOptionValue() {
371
- const { options: parsedOptions, globalCommand } = this.cli;
372
- const options = [...globalCommand.options, ...this.options];
373
- for (const option of options) {
374
- const value = parsedOptions[option.name.split(".")[0]];
375
- if (option.required) {
376
- const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
377
- if (value === true || value === false && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
378
- }
379
- }
380
- }
381
- /**
382
- * Check if the number of args is more than expected
383
- */
384
- checkUnusedArgs() {
385
- const maximumArgsCount = this.args.some((arg) => arg.variadic) ? Infinity : this.args.length;
386
- if (maximumArgsCount < this.cli.args.length) throw new CACError(`Unused args: ${this.cli.args.slice(maximumArgsCount).map((arg) => `\`${arg}\``).join(", ")}`);
387
- }
388
- };
389
- var GlobalCommand = class extends Command {
390
- constructor(cli) {
391
- super("@@global@@", "", {}, cli);
392
- }
393
- };
394
- var CAC = class extends EventTarget {
395
- /** The program name to display in help and version message */
396
- name;
397
- commands;
398
- globalCommand;
399
- matchedCommand;
400
- matchedCommandName;
401
- /**
402
- * Raw CLI arguments
403
- */
404
- rawArgs;
405
- /**
406
- * Parsed CLI arguments
407
- */
408
- args;
409
- /**
410
- * Parsed CLI options, camelCased
411
- */
412
- options;
413
- showHelpOnExit;
414
- showVersionOnExit;
415
- /**
416
- * @param name The program name to display in help and version message
417
- */
418
- constructor(name = "") {
419
- super();
420
- this.name = name;
421
- this.commands = [];
422
- this.rawArgs = [];
423
- this.args = [];
424
- this.options = {};
425
- this.globalCommand = new GlobalCommand(this);
426
- this.globalCommand.usage("<command> [options]");
427
- }
428
- /**
429
- * Add a global usage text.
430
- *
431
- * This is not used by sub-commands.
432
- */
433
- usage(text) {
434
- this.globalCommand.usage(text);
435
- return this;
436
- }
437
- /**
438
- * Add a sub-command
439
- */
440
- command(rawName, description, config) {
441
- const command = new Command(rawName, description || "", config, this);
442
- command.globalCommand = this.globalCommand;
443
- this.commands.push(command);
444
- return command;
445
- }
446
- /**
447
- * Add a global CLI option.
448
- *
449
- * Which is also applied to sub-commands.
450
- */
451
- option(rawName, description, config) {
452
- this.globalCommand.option(rawName, description, config);
453
- return this;
454
- }
455
- /**
456
- * Show help message when `-h, --help` flags appear.
457
- *
458
- */
459
- help(callback) {
460
- this.globalCommand.option("-h, --help", "Display this message");
461
- this.globalCommand.helpCallback = callback;
462
- this.showHelpOnExit = true;
463
- return this;
464
- }
465
- /**
466
- * Show version number when `-v, --version` flags appear.
467
- *
468
- */
469
- version(version, customFlags = "-v, --version") {
470
- this.globalCommand.version(version, customFlags);
471
- this.showVersionOnExit = true;
472
- return this;
473
- }
474
- /**
475
- * Add a global example.
476
- *
477
- * This example added here will not be used by sub-commands.
478
- */
479
- example(example) {
480
- this.globalCommand.example(example);
481
- return this;
482
- }
483
- /**
484
- * Output the corresponding help message
485
- * When a sub-command is matched, output the help message for the command
486
- * Otherwise output the global one.
487
- *
488
- */
489
- outputHelp() {
490
- if (this.matchedCommand) this.matchedCommand.outputHelp();
491
- else this.globalCommand.outputHelp();
492
- }
493
- /**
494
- * Output the version number.
495
- *
496
- */
497
- outputVersion() {
498
- this.globalCommand.outputVersion();
499
- }
500
- setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
501
- this.args = args;
502
- this.options = options;
503
- if (matchedCommand) this.matchedCommand = matchedCommand;
504
- if (matchedCommandName) this.matchedCommandName = matchedCommandName;
505
- return this;
506
- }
507
- unsetMatchedCommand() {
508
- this.matchedCommand = void 0;
509
- this.matchedCommandName = void 0;
510
- }
511
- /**
512
- * Parse argv
513
- */
514
- parse(argv, { run = true } = {}) {
515
- if (!argv) {
516
- if (!runtimeProcessArgs) throw new Error("No argv provided and runtime process argv is not available.");
517
- argv = runtimeProcessArgs;
518
- }
519
- this.rawArgs = argv;
520
- if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
521
- let shouldParse = true;
522
- for (const command of this.commands) {
523
- const parsed = this.mri(argv.slice(2), command);
524
- const commandName = parsed.args[0];
525
- if (command.isMatched(commandName)) {
526
- shouldParse = false;
527
- const parsedInfo = {
528
- ...parsed,
529
- args: parsed.args.slice(1)
530
- };
531
- this.setParsedInfo(parsedInfo, command, commandName);
532
- this.dispatchEvent(new CustomEvent(`command:${commandName}`, { detail: command }));
533
- }
534
- }
535
- if (shouldParse) {
536
- for (const command of this.commands) if (command.isDefaultCommand) {
537
- shouldParse = false;
538
- const parsed = this.mri(argv.slice(2), command);
539
- this.setParsedInfo(parsed, command);
540
- this.dispatchEvent(new CustomEvent("command:!", { detail: command }));
541
- }
542
- }
543
- if (shouldParse) {
544
- const parsed = this.mri(argv.slice(2));
545
- this.setParsedInfo(parsed);
546
- }
547
- if (this.options.help && this.showHelpOnExit) {
548
- this.outputHelp();
549
- run = false;
550
- this.unsetMatchedCommand();
551
- }
552
- if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
553
- this.outputVersion();
554
- run = false;
555
- this.unsetMatchedCommand();
556
- }
557
- const parsedArgv = {
558
- args: this.args,
559
- options: this.options
560
- };
561
- if (run) this.runMatchedCommand();
562
- if (!this.matchedCommand && this.args[0]) this.dispatchEvent(new CustomEvent("command:*", { detail: this.args[0] }));
563
- return parsedArgv;
564
- }
565
- mri(argv, command) {
566
- const cliOptions = [...this.globalCommand.options, ...command ? command.options : []];
567
- const mriOptions = getMriOptions(cliOptions);
568
- let argsAfterDoubleDashes = [];
569
- const doubleDashesIndex = argv.indexOf("--");
570
- if (doubleDashesIndex !== -1) {
571
- argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
572
- argv = argv.slice(0, doubleDashesIndex);
573
- }
574
- let parsed = lib_default(argv, mriOptions);
575
- parsed = Object.keys(parsed).reduce((res, name) => {
576
- return {
577
- ...res,
578
- [camelcaseOptionName(name)]: parsed[name]
579
- };
580
- }, { _: [] });
581
- const args = parsed._;
582
- const options = { "--": argsAfterDoubleDashes };
583
- const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
584
- const transforms = Object.create(null);
585
- for (const cliOption of cliOptions) {
586
- if (!ignoreDefault && cliOption.config.default !== void 0) for (const name of cliOption.names) options[name] = cliOption.config.default;
587
- if (Array.isArray(cliOption.config.type) && transforms[cliOption.name] === void 0) {
588
- transforms[cliOption.name] = Object.create(null);
589
- transforms[cliOption.name].shouldTransform = true;
590
- transforms[cliOption.name].transformFunction = cliOption.config.type[0];
591
- }
592
- }
593
- for (const key of Object.keys(parsed)) if (key !== "_") {
594
- setDotProp(options, key.split("."), parsed[key]);
595
- setByType(options, transforms);
596
- }
597
- return {
598
- args,
599
- options
600
- };
601
- }
602
- runMatchedCommand() {
603
- const { args, options, matchedCommand: command } = this;
604
- if (!command || !command.commandAction) return;
605
- command.checkUnknownOptions();
606
- command.checkOptionValue();
607
- command.checkRequiredArgs();
608
- command.checkUnusedArgs();
609
- const actionArgs = [];
610
- command.args.forEach((arg, index) => {
611
- if (arg.variadic) actionArgs.push(args.slice(index));
612
- else actionArgs.push(args[index]);
613
- });
614
- actionArgs.push(options);
615
- return command.commandAction.apply(this, actionArgs);
616
- }
617
- };
618
- /**
619
- * @param name The program name to display in help and version message
620
- */
621
- const cac = (name = "") => new CAC(name);
622
- //#endregion
5
+ import { buildWithConfigs, enableDebug, globalLogger, resolveUserConfig } from "vite/pack";
623
6
  //#region src/pack-bin.ts
624
7
  const RE_DTS = /\.d\.[cm]?ts$/;
625
8
  const EXTERNAL_DTS_PKG_RE = /^(?:postcss|lightningcss|vitest|@vitest\/[^/]+|vite-plus)(?:\/|$)/;
@@ -680,7 +63,7 @@ const DEFAULT_ENV_PREFIXES = ["VITE_PACK_", "TSDOWN_"];
680
63
  cli.command("[...files]", "Bundle files", {
681
64
  ignoreOptionDefaultValue: true,
682
65
  allowUnknownOptions: true
683
- }).option("--config-loader <loader>", "Config loader to use: auto, native, tsx, 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: DEFAULT_ENV_PREFIXES }).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("--root <dir>", "Root directory of input files").option("--exe", "Bundle as executable").option("-W, --workspace [dir]", "Enable workspace mode").option("--concurrency <count>", "Maximum number of Rolldown builds to run in parallel").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) => {
66
+ }).option("--config-loader <loader>", "Config loader to use: auto, native, tsx, 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: DEFAULT_ENV_PREFIXES }).option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--tsconfig <tsconfig>", "Set tsconfig path").option("--unbundle", "Unbundle mode").option("--root <dir>", "Root directory of input files").option("--exe", "Bundle as executable").option("-W, --workspace [dir]", "Enable workspace mode").option("--concurrency <count>", "Maximum number of Rolldown builds to run in parallel").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) => {
684
67
  if (input.length > 0) flags.entry = input;
685
68
  if (flags.envPrefix === void 0) flags.envPrefix = DEFAULT_ENV_PREFIXES;
686
69
  async function runBuild() {
@@ -699,7 +82,7 @@ cli.command("[...files]", "Bundle files", {
699
82
  resolvedConfig.forEach((config) => config.configDeps.forEach((dep) => configDeps.add(dep)));
700
83
  configs.push(...resolvedConfig);
701
84
  }
702
- await buildWithConfigs(configs, configDeps, runBuild);
85
+ return buildWithConfigs(configs, configDeps, runBuild);
703
86
  }
704
87
  await runBuild();
705
88
  });
@@ -1 +1 @@
1
- /// <reference types="@voidzero-dev/vite-plus-core/pack/client" />
1
+ /// <reference types="vite/pack/client" />
package/dist/pack.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { t as PackUserConfig } from "./pack-PvUg_xpv.js";
2
- export * from "@voidzero-dev/vite-plus-core/pack";
1
+ import { t as PackUserConfig } from "./pack-BK38MLVZ.js";
2
+ export * from "vite/pack";
3
3
  export { PackUserConfig };
package/dist/pack.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "@voidzero-dev/vite-plus-core/pack";
1
+ export * from "vite/pack";
2
2
  export {};
@@ -1,4 +1,4 @@
1
- import "./constants-Bn-U8o4v.js";
1
+ import "./constants-0IAVgpox.js";
2
2
  import { i as readJsonFile } from "./json-cULBl7Pi.js";
3
3
  import { createRequire } from "node:module";
4
4
  import path from "node:path";