@blzsky/variant 0.2.0
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/LICENSE +20 -0
- package/README.md +177 -0
- package/dist/build-2LO7GD2S.js +63 -0
- package/dist/check-ZTKGGF4M.js +44 -0
- package/dist/chunk-3E5LBU3O.js +180 -0
- package/dist/chunk-4LLK2S4R.js +630 -0
- package/dist/chunk-6J4XDG44.js +14 -0
- package/dist/chunk-CXNXZLDG.js +13 -0
- package/dist/chunk-DRMASVYN.js +25 -0
- package/dist/chunk-GDSZFIHM.js +29 -0
- package/dist/chunk-ISRF5F3Q.js +68 -0
- package/dist/chunk-KSHWC2XN.js +78 -0
- package/dist/chunk-LJDDS4RR.js +91 -0
- package/dist/chunk-LXKLCLL6.js +91 -0
- package/dist/chunk-MZZOE7L4.js +26 -0
- package/dist/chunk-NSNZOH5P.js +31 -0
- package/dist/chunk-O4LZKXNZ.js +301 -0
- package/dist/chunk-RGD422OM.js +108 -0
- package/dist/chunk-RVXUCJYA.js +81 -0
- package/dist/chunk-SWPVR2DF.js +468 -0
- package/dist/chunk-V22IPJ7A.js +64 -0
- package/dist/chunk-V5CTGXMM.js +256 -0
- package/dist/chunk-VTJ67TT5.js +238 -0
- package/dist/chunk-XTYVVUWW.js +279 -0
- package/dist/chunk-XUBWCTJZ.js +100 -0
- package/dist/chunk-YYGCSKIQ.js +29 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +225 -0
- package/dist/diff-GFI6RAEA.js +60 -0
- package/dist/doctor-GH4RZVEH.js +127 -0
- package/dist/env-QORDD6FQ.js +24 -0
- package/dist/impact-AF453PLK.js +702 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +7 -0
- package/dist/init-KJIUNGAN.js +158 -0
- package/dist/insight-DZ5NQY6D.js +29 -0
- package/dist/pr-UFZRZX6S.js +152 -0
- package/dist/run-6PNH4QRA.js +40 -0
- package/dist/symbol-graph-YYUEMZGR.js +22 -0
- package/dist/tsconfig-paths-E3UEDGXZ.js +10 -0
- package/dist/workspace-X5FUBTY3.js +186 -0
- package/package.json +86 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findVariantConfigPath,
|
|
3
|
+
loadConfig
|
|
4
|
+
} from "./chunk-RGD422OM.js";
|
|
5
|
+
import {
|
|
6
|
+
getColors
|
|
7
|
+
} from "./chunk-YYGCSKIQ.js";
|
|
8
|
+
import "./chunk-RVXUCJYA.js";
|
|
9
|
+
import {
|
|
10
|
+
lines
|
|
11
|
+
} from "./chunk-6J4XDG44.js";
|
|
12
|
+
import {
|
|
13
|
+
getPrinter
|
|
14
|
+
} from "./chunk-V22IPJ7A.js";
|
|
15
|
+
|
|
16
|
+
// src/core/doctor/diagnostics.ts
|
|
17
|
+
import { readdir, stat } from "fs/promises";
|
|
18
|
+
import path from "path";
|
|
19
|
+
var MINIMUM_NODE_MAJOR = 20;
|
|
20
|
+
var CACHE_WARN_MB = 500;
|
|
21
|
+
function checkNodeVersion(version = process.version) {
|
|
22
|
+
const match = version.match(/^v(\d+)/);
|
|
23
|
+
const major = match ? Number(match[1]) : 0;
|
|
24
|
+
if (major >= MINIMUM_NODE_MAJOR) {
|
|
25
|
+
return {
|
|
26
|
+
level: "ok",
|
|
27
|
+
label: `Node ${version} meets requirement \u2265${MINIMUM_NODE_MAJOR}`
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
level: "error",
|
|
32
|
+
label: `Node ${version} is below requirement \u2265${MINIMUM_NODE_MAJOR}`,
|
|
33
|
+
detail: `Upgrade Node.js to v${MINIMUM_NODE_MAJOR} or later.`
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async function directorySizeBytes(dir) {
|
|
37
|
+
let entries;
|
|
38
|
+
try {
|
|
39
|
+
entries = await readdir(dir);
|
|
40
|
+
} catch {
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
const sizes = await Promise.all(
|
|
44
|
+
entries.map(async (entry) => {
|
|
45
|
+
const full = path.join(dir, entry);
|
|
46
|
+
try {
|
|
47
|
+
const stats = await stat(full);
|
|
48
|
+
return stats.isDirectory() ? await directorySizeBytes(full) : stats.size;
|
|
49
|
+
} catch {
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
return sizes.reduce((total, size) => total + size, 0);
|
|
55
|
+
}
|
|
56
|
+
async function checkCacheSize(cwd, cacheDir) {
|
|
57
|
+
const bytes = await directorySizeBytes(path.resolve(cwd, cacheDir));
|
|
58
|
+
const megabytes = bytes / (1024 * 1024);
|
|
59
|
+
const label = `Cache directory is ${megabytes.toFixed(0)} MB`;
|
|
60
|
+
if (megabytes > CACHE_WARN_MB) {
|
|
61
|
+
return {
|
|
62
|
+
level: "warn",
|
|
63
|
+
label,
|
|
64
|
+
detail: "Consider setting `cache.ttlDays` to evict old entries automatically."
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return { level: "ok", label };
|
|
68
|
+
}
|
|
69
|
+
async function checkConfig(cwd) {
|
|
70
|
+
const configPath = findVariantConfigPath(cwd);
|
|
71
|
+
if (!configPath) {
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
level: "error",
|
|
75
|
+
label: "No variant.config.ts found",
|
|
76
|
+
detail: "Run `variant init` to create one."
|
|
77
|
+
}
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
const diagnostics = [
|
|
81
|
+
{ level: "ok", label: `Config found: ${path.basename(configPath)}` }
|
|
82
|
+
];
|
|
83
|
+
let config;
|
|
84
|
+
try {
|
|
85
|
+
config = await loadConfig(cwd);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
diagnostics.push({
|
|
88
|
+
level: "error",
|
|
89
|
+
label: "Config validation failed",
|
|
90
|
+
detail: err instanceof Error ? err.message : String(err)
|
|
91
|
+
});
|
|
92
|
+
return diagnostics;
|
|
93
|
+
}
|
|
94
|
+
diagnostics.push({ level: "ok", label: "Config is valid" });
|
|
95
|
+
diagnostics.push(await checkCacheSize(cwd, config.cache.directory));
|
|
96
|
+
return diagnostics;
|
|
97
|
+
}
|
|
98
|
+
async function runDiagnostics(cwd) {
|
|
99
|
+
return [checkNodeVersion(), ...await checkConfig(cwd)];
|
|
100
|
+
}
|
|
101
|
+
function hasFailure(diagnostics) {
|
|
102
|
+
return diagnostics.some((diagnostic) => diagnostic.level === "error");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/cli/render/doctor.ts
|
|
106
|
+
var ICON = {
|
|
107
|
+
ok: (colors) => colors.green("[\u2713]"),
|
|
108
|
+
warn: (colors) => colors.yellow("[!]"),
|
|
109
|
+
error: (colors) => colors.red("[\u2717]")
|
|
110
|
+
};
|
|
111
|
+
function renderDiagnostics(diagnostics, printer = getPrinter()) {
|
|
112
|
+
const colors = getColors();
|
|
113
|
+
for (const diagnostic of diagnostics) {
|
|
114
|
+
lines(printer, `${ICON[diagnostic.level](colors)} ${diagnostic.label}`);
|
|
115
|
+
if (diagnostic.detail) lines(printer, ` \u2192 ${diagnostic.detail}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/cli/commands/doctor.ts
|
|
120
|
+
async function registerDoctorAction() {
|
|
121
|
+
const diagnostics = await runDiagnostics(process.cwd());
|
|
122
|
+
renderDiagnostics(diagnostics);
|
|
123
|
+
if (hasFailure(diagnostics)) process.exitCode = 1;
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
registerDoctorAction
|
|
127
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderEnv
|
|
3
|
+
} from "./chunk-ISRF5F3Q.js";
|
|
4
|
+
import {
|
|
5
|
+
createContext
|
|
6
|
+
} from "./chunk-SWPVR2DF.js";
|
|
7
|
+
import "./chunk-V5CTGXMM.js";
|
|
8
|
+
import "./chunk-RGD422OM.js";
|
|
9
|
+
import "./chunk-YYGCSKIQ.js";
|
|
10
|
+
import "./chunk-MZZOE7L4.js";
|
|
11
|
+
import "./chunk-3E5LBU3O.js";
|
|
12
|
+
import "./chunk-RVXUCJYA.js";
|
|
13
|
+
import "./chunk-XUBWCTJZ.js";
|
|
14
|
+
import "./chunk-6J4XDG44.js";
|
|
15
|
+
import "./chunk-V22IPJ7A.js";
|
|
16
|
+
|
|
17
|
+
// src/cli/commands/env.ts
|
|
18
|
+
async function registerEnvAction() {
|
|
19
|
+
const ctx = await createContext(process.cwd(), { scope: false });
|
|
20
|
+
renderEnv(ctx.pm, ctx.runtime, ctx.framework);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
registerEnvAction
|
|
24
|
+
};
|