vite-doctor 0.0.0 → 0.0.1-alpha.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.
- package/dist/_format-B2HI7dfh.mjs +21 -0
- package/dist/chunk-Vs_PY4HZ.mjs +37 -0
- package/dist/cli.d.mts +4 -0
- package/dist/cli.mjs +147 -0
- package/dist/dist-8lLfIOP2.mjs +500 -0
- package/dist/doctor-_N6Ivxkm.mjs +37 -0
- package/dist/index.d.mts +25 -0
- package/dist/index.mjs +2 -0
- package/dist/jiti-CKNfQMe-.mjs +5460 -0
- package/dist/jiti-R7_DrxGt.mjs +3 -0
- package/dist/json5-6m_qGRPT.mjs +775 -0
- package/dist/jsonc-BE4T3qGL.mjs +399 -0
- package/dist/jsonc-CLHNv_ud.mjs +2 -0
- package/dist/main-DLCb8JN7.mjs +272 -0
- package/dist/nuxt.d.mts +457 -0
- package/dist/nuxt.mjs +8696 -0
- package/dist/nypm-B42YpMR7.mjs +671 -0
- package/dist/nypm-V_7qwBzU.mjs +2 -0
- package/dist/ohash-DJf_Wz36.mjs +183 -0
- package/dist/plugin.d.mts +20 -0
- package/dist/plugin.mjs +45 -0
- package/dist/prompt-BtRxIZzP.mjs +847 -0
- package/dist/rolldown-runtime-DRLVd5Gq.mjs +13 -0
- package/dist/rules-C0Oyy6lY-ClEeab_k.mjs +167037 -0
- package/dist/src-CuYgaMvh.mjs +1173 -0
- package/dist/src-DrZYBMKC.mjs +63 -0
- package/dist/tar-C2j71EuP.mjs +2933 -0
- package/dist/toml-DQFyLJNX.mjs +644 -0
- package/dist/yaml-BXFm6QiY.mjs +1065 -0
- package/package.json +72 -9
- package/index.js +0 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.mjs
|
|
2
|
+
const t = Symbol.for(`__confbox_fmt__`), n = /^(\s+)/, r = /(\s+)$/;
|
|
3
|
+
function i(e, t = {}) {
|
|
4
|
+
return {
|
|
5
|
+
sample: t.indent === void 0 && t.preserveIndentation !== !1 && e.slice(0, t?.sampleSize || 1024),
|
|
6
|
+
whiteSpace: t.preserveWhitespace === !1 ? void 0 : {
|
|
7
|
+
start: n.exec(e)?.[0] || ``,
|
|
8
|
+
end: r.exec(e)?.[0] || ``
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function a(e, n, r) {
|
|
13
|
+
!n || typeof n != `object` || Object.defineProperty(n, t, {
|
|
14
|
+
enumerable: !1,
|
|
15
|
+
configurable: !0,
|
|
16
|
+
writable: !0,
|
|
17
|
+
value: i(e, r)
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { a as t };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
10
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
11
|
+
var __exportAll = (all, no_symbols) => {
|
|
12
|
+
let target = {};
|
|
13
|
+
for (var name in all) __defProp(target, name, {
|
|
14
|
+
get: all[name],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
22
|
+
key = keys[i];
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
24
|
+
get: ((k) => from[k]).bind(null, key),
|
|
25
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return to;
|
|
29
|
+
};
|
|
30
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
31
|
+
value: mod,
|
|
32
|
+
enumerable: true
|
|
33
|
+
}) : target, mod));
|
|
34
|
+
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
36
|
+
//#endregion
|
|
37
|
+
export { __toCommonJS as a, __require as i, __esmMin as n, __toESM as o, __exportAll as r, __commonJSMin as t };
|
package/dist/cli.d.mts
ADDED
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { i as planCi } from "./src-DrZYBMKC.mjs";
|
|
3
|
+
import { _ as createReport, r as cleanCache, v as createRulesReport, y as explainRule } from "./rules-C0Oyy6lY-ClEeab_k.mjs";
|
|
4
|
+
import { n as shouldFailDoctorRun, r as viteDoctorRulePacks, t as runViteDoctor } from "./doctor-_N6Ivxkm.mjs";
|
|
5
|
+
import { statSync } from "node:fs";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { resolve } from "pathe";
|
|
9
|
+
//#region src/cli.ts
|
|
10
|
+
async function main(args = process.argv.slice(2), cwd = process.cwd()) {
|
|
11
|
+
const dryRun = args.includes("--dry-run");
|
|
12
|
+
const firstPositional = args.find((arg) => !arg.startsWith("-"));
|
|
13
|
+
const command = firstPositional ? isCommand(firstPositional) ? firstPositional : "scan" : "run";
|
|
14
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
15
|
+
printHelp();
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
if (command === "rules") {
|
|
19
|
+
const { options } = parseRunArgs(args.filter((arg) => arg !== command));
|
|
20
|
+
process.stdout.write(createRulesReport(viteDoctorRulePacks(), options.format));
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
if (command === "explain") {
|
|
24
|
+
const rest = args.filter((arg) => arg !== command);
|
|
25
|
+
const ruleId = rest.find((arg) => !arg.startsWith("-")) ?? "";
|
|
26
|
+
const { options } = parseRunArgs(rest.filter((arg) => arg !== ruleId));
|
|
27
|
+
process.stdout.write(explainRule(viteDoctorRulePacks(), ruleId, options.format));
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
if (command === "cache" && args.includes("clean")) {
|
|
31
|
+
cleanCache(cwd);
|
|
32
|
+
console.log("Doctor cache cleaned");
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
if (command === "scan" || command === "check") {
|
|
36
|
+
const { path, options } = parseRunArgs(args.filter((arg) => arg !== command));
|
|
37
|
+
const root = resolve(cwd, path);
|
|
38
|
+
if (!statSync(root, { throwIfNoEntry: false })?.isDirectory()) {
|
|
39
|
+
console.error(`No readable directory found at ${root}`);
|
|
40
|
+
return 1;
|
|
41
|
+
}
|
|
42
|
+
const result = await runViteDoctor({
|
|
43
|
+
...options,
|
|
44
|
+
root
|
|
45
|
+
});
|
|
46
|
+
process.stdout.write(createReport(result, options.format));
|
|
47
|
+
return shouldFailDoctorRun(result, options.maxWarnings) ? 1 : 0;
|
|
48
|
+
}
|
|
49
|
+
if (command !== "run" && command !== "ci") {
|
|
50
|
+
console.error(`Unknown command: ${command}`);
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
let plan;
|
|
54
|
+
try {
|
|
55
|
+
plan = planCi(cwd);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
console.log(`Package manager: ${plan.packageManager}`);
|
|
61
|
+
console.log("Commands:");
|
|
62
|
+
for (const item of plan.commands) console.log(`- ${item.display}`);
|
|
63
|
+
if (dryRun) return 0;
|
|
64
|
+
for (const item of plan.commands) {
|
|
65
|
+
const exitCode = await runCommand(item, cwd);
|
|
66
|
+
if (exitCode !== 0) return exitCode;
|
|
67
|
+
}
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
function printHelp() {
|
|
71
|
+
console.log(`vite-doctor
|
|
72
|
+
|
|
73
|
+
Usage:
|
|
74
|
+
vite-doctor [run] [--dry-run]
|
|
75
|
+
vite-doctor [path]
|
|
76
|
+
vite-doctor scan [path]
|
|
77
|
+
vite-doctor check [path]
|
|
78
|
+
vite-doctor rules [--format json]
|
|
79
|
+
|
|
80
|
+
Runs the project's existing scripts with the detected package manager by default.`);
|
|
81
|
+
}
|
|
82
|
+
function parseRunArgs(args) {
|
|
83
|
+
const options = {};
|
|
84
|
+
let path = ".";
|
|
85
|
+
for (let index = 0; index < args.length; index++) {
|
|
86
|
+
const arg = args[index];
|
|
87
|
+
if (arg === "--trusted-config" || arg === "--config") options.config = true;
|
|
88
|
+
else if (arg === "--changed") options.changed = true;
|
|
89
|
+
else if (arg === "--types") options.types = true;
|
|
90
|
+
else if (arg === "--threads") options.threads = Number(args[++index]);
|
|
91
|
+
else if (arg === "--analyses") options.analyses = args[++index];
|
|
92
|
+
else if (arg === "--profile") options.profile = true;
|
|
93
|
+
else if (arg === "--new-only") options.newOnly = true;
|
|
94
|
+
else if (arg === "--cache") options.cache = true;
|
|
95
|
+
else if (arg === "--no-cache") options.cache = false;
|
|
96
|
+
else if (arg === "--fix") options.fix = true;
|
|
97
|
+
else if (arg === "--unsafe-fix") options.unsafeFix = true;
|
|
98
|
+
else if (arg === "--max-warnings") options.maxWarnings = Number(args[++index]);
|
|
99
|
+
else if (arg === "--framework") options.framework = args[++index];
|
|
100
|
+
else if (arg === "--rules") options.rules = args[++index];
|
|
101
|
+
else if (arg === "--severity") options.severity = args[++index];
|
|
102
|
+
else if (arg === "--preset") options.preset = args[++index];
|
|
103
|
+
else if (arg === "--since") options.since = args[++index];
|
|
104
|
+
else if (arg === "--baseline") options.baseline = args[++index];
|
|
105
|
+
else if (arg === "--format") options.format = args[++index];
|
|
106
|
+
else if (!arg.startsWith("-")) path = arg;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
path,
|
|
110
|
+
options
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function isCommand(value) {
|
|
114
|
+
return [
|
|
115
|
+
"run",
|
|
116
|
+
"ci",
|
|
117
|
+
"rules",
|
|
118
|
+
"explain",
|
|
119
|
+
"cache",
|
|
120
|
+
"scan",
|
|
121
|
+
"check"
|
|
122
|
+
].includes(value);
|
|
123
|
+
}
|
|
124
|
+
function runCommand(item, cwd) {
|
|
125
|
+
return new Promise((resolve) => {
|
|
126
|
+
const child = spawn(item.command, item.args, {
|
|
127
|
+
cwd,
|
|
128
|
+
stdio: "inherit"
|
|
129
|
+
});
|
|
130
|
+
child.on("error", (error) => {
|
|
131
|
+
console.error(`Failed to run ${item.display}: ${error.message}`);
|
|
132
|
+
resolve(1);
|
|
133
|
+
});
|
|
134
|
+
child.on("close", (code, signal) => {
|
|
135
|
+
if (signal) {
|
|
136
|
+
console.error(`${item.display} exited from signal ${signal}`);
|
|
137
|
+
resolve(1);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
resolve(code ?? 1);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
145
|
+
if (process.argv[1] === currentFile) process.exitCode = await main();
|
|
146
|
+
//#endregion
|
|
147
|
+
export { main };
|