@visulima/vis 1.0.0-alpha.10 → 1.0.0-alpha.11
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/CHANGELOG.md +95 -42
- package/LICENSE.md +213 -0
- package/README.md +8 -4
- package/dist/bin.js +9 -1
- package/dist/config/index.d.ts +1818 -0
- package/dist/config/index.js +2 -0
- package/dist/generate/index.d.ts +1 -1
- package/dist/generate/index.js +3 -1
- package/dist/packem_chunks/applyDefaults.js +336 -0
- package/dist/packem_chunks/bin.js +9554 -64
- package/dist/packem_chunks/doctor-probe.js +112 -0
- package/dist/packem_chunks/fix.js +229 -48
- package/dist/packem_chunks/handler.js +99 -1
- package/dist/packem_chunks/handler10.js +53 -1
- package/dist/packem_chunks/handler11.js +32 -1
- package/dist/packem_chunks/handler12.js +100 -2
- package/dist/packem_chunks/handler13.js +25 -1
- package/dist/packem_chunks/handler14.js +916 -5
- package/dist/packem_chunks/handler15.js +206 -1
- package/dist/packem_chunks/handler16.js +122 -18
- package/dist/packem_chunks/handler17.js +13 -1
- package/dist/packem_chunks/handler18.js +106 -1
- package/dist/packem_chunks/handler19.js +19 -1
- package/dist/packem_chunks/handler2.js +75 -1
- package/dist/packem_chunks/handler20.js +29 -1
- package/dist/packem_chunks/handler21.js +222 -1
- package/dist/packem_chunks/handler22.js +237 -5
- package/dist/packem_chunks/handler23.js +101 -1
- package/dist/packem_chunks/handler24.js +110 -1
- package/dist/packem_chunks/handler25.js +402 -5
- package/dist/packem_chunks/handler26.js +13 -1
- package/dist/packem_chunks/handler27.js +63 -3
- package/dist/packem_chunks/handler28.js +34 -1
- package/dist/packem_chunks/handler29.js +458 -7
- package/dist/packem_chunks/handler3.js +95 -2
- package/dist/packem_chunks/handler30.js +168 -21
- package/dist/packem_chunks/handler31.js +530 -3
- package/dist/packem_chunks/handler32.js +214 -2
- package/dist/packem_chunks/handler33.js +119 -24
- package/dist/packem_chunks/handler34.js +630 -2
- package/dist/packem_chunks/handler35.js +283 -19
- package/dist/packem_chunks/handler36.js +521 -407
- package/dist/packem_chunks/handler37.js +762 -22
- package/dist/packem_chunks/handler38.js +989 -22
- package/dist/packem_chunks/handler39.js +574 -22
- package/dist/packem_chunks/handler4.js +90 -4
- package/dist/packem_chunks/handler40.js +1685 -3
- package/dist/packem_chunks/handler41.js +1088 -10
- package/dist/packem_chunks/handler42.js +785 -141
- package/dist/packem_chunks/handler43.js +2658 -42
- package/dist/packem_chunks/handler44.js +3886 -3
- package/dist/packem_chunks/handler45.js +2568 -21
- package/dist/packem_chunks/handler46.js +3769 -0
- package/dist/packem_chunks/handler47.js +1491 -0
- package/dist/packem_chunks/handler5.js +174 -2
- package/dist/packem_chunks/handler6.js +95 -13
- package/dist/packem_chunks/handler7.js +115 -8
- package/dist/packem_chunks/handler8.js +12 -1
- package/dist/packem_chunks/handler9.js +29 -1
- package/dist/packem_chunks/heal-accept.js +522 -0
- package/dist/packem_chunks/heal.js +673 -0
- package/dist/packem_chunks/index.js +873 -7
- package/dist/packem_chunks/loader.js +23 -1
- package/dist/packem_shared/VisUpdateApp-D-Yz_wvg.js +1316 -0
- package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +5 -0
- package/dist/packem_shared/ai-analysis-CHeB1joD.js +367 -0
- package/dist/packem_shared/ai-cache-Be_jexe4.js +142 -0
- package/dist/packem_shared/ai-fix-B9iQVcD2.js +379 -0
- package/dist/packem_shared/cache-directory-2qvs4goY.js +98 -0
- package/dist/packem_shared/catalog-BJTtyi-O.js +1371 -0
- package/dist/packem_shared/dependency-scan-A0KSklpG.js +188 -0
- package/dist/packem_shared/docker-2iZzc280.js +181 -0
- package/dist/packem_shared/failure-log-Cz3Z4SKL.js +100 -0
- package/dist/packem_shared/flakiness-goTxXuCX.js +180 -0
- package/dist/packem_shared/otel-DCvqCTz_.js +158 -0
- package/dist/packem_shared/otelPlugin-DFaLDvJf.js +3 -0
- package/dist/packem_shared/registry-CbqXI0rc.js +272 -0
- package/dist/packem_shared/run-summary-utils-PVMl4aIh.js +130 -0
- package/dist/packem_shared/runtime-check-Cobi3p6l.js +127 -0
- package/dist/packem_shared/selectors-SM69TfqC.js +194 -0
- package/dist/packem_shared/symbols-Ta7g2nU-.js +14 -0
- package/dist/packem_shared/toolchain-BdZd9eBi.js +975 -0
- package/dist/packem_shared/typosquats-C-bCh3PX.js +1210 -0
- package/dist/packem_shared/use-measured-height-CNP0vT4M.js +20 -0
- package/dist/packem_shared/utils-CthVdBPS.js +40 -0
- package/dist/packem_shared/xxh3-Ck8mXNg1.js +239 -0
- package/index.js +727 -555
- package/package.json +35 -17
- package/schemas/project.schema.json +8 -10
- package/schemas/vis-config.schema.json +132 -8
- package/skills/vis/SKILL.md +96 -0
- package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
- package/templates/buildkite-ci/template.yml +20 -0
- package/dist/errors/index.d.ts +0 -26
- package/dist/errors/index.js +0 -1
- package/dist/packem_chunks/config.js +0 -2
- package/dist/packem_shared/VisConfigCycleError-CAYNC7d-.js +0 -1
- package/dist/packem_shared/VisConfigError-B5LP1zRf.js +0 -1
- package/dist/packem_shared/VisConfigLoadError-CeqBSd2Z.js +0 -2
- package/dist/packem_shared/VisConfigNotFoundError-DZ9KC527.js +0 -5
- package/dist/packem_shared/VisUpdateApp-D-L4_-Iu.js +0 -1
- package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +0 -1
- package/dist/packem_shared/ai-analysis-CGuy7dfE.js +0 -67
- package/dist/packem_shared/ai-cache-Bynt6Y9x.js +0 -1
- package/dist/packem_shared/cache-directory-D72ZEag2.js +0 -1
- package/dist/packem_shared/catalog-BVPerCwG.js +0 -12
- package/dist/packem_shared/dependency-scan-Du0tBu64.js +0 -2
- package/dist/packem_shared/docker-BcfqH4Av.js +0 -2
- package/dist/packem_shared/failure-log-DqYen0LC.js +0 -2
- package/dist/packem_shared/flakiness-DSIHZGBT.js +0 -1
- package/dist/packem_shared/run-summary-utils-C24Aaf9E.js +0 -1
- package/dist/packem_shared/runtime-check-CGHal8SO.js +0 -1
- package/dist/packem_shared/selectors-CfH9ZY08.js +0 -3
- package/dist/packem_shared/symbols-CQmER5MT.js +0 -1
- package/dist/packem_shared/target-merge-DNa-6eWu.js +0 -1
- package/dist/packem_shared/toolchain-DQfTQY8E.js +0 -5
- package/dist/packem_shared/typosquats-DOR8izpX.js +0 -1
- package/dist/packem_shared/use-measured-height-DjYgUOKk.js +0 -1
- package/dist/packem_shared/utils-DrNg0XTR.js +0 -1
- package/dist/packem_shared/xxh3-DrAUNq4n.js +0 -1
|
@@ -1,2 +1,174 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { findPackageManagerSync } from '@visulima/package';
|
|
2
|
+
import { render, renderToString, Text } from '@visulima/tui';
|
|
3
|
+
import { c as detectPm, g as printSecurityReport, h as previewPnpmSync, p as pail, i as isInCi, j as scoreColor, a as buildSocketOptions } from './bin.js';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { v as validateAnalysisType, r as runAiAnalysis, f as formatAiAnalysis } from '../packem_shared/ai-analysis-CHeB1joD.js';
|
|
6
|
+
import { U as UpdateStore, V as VisUpdateApp, C as CheckProgressApp } from '../packem_shared/VisUpdateApp-D-Yz_wvg.js';
|
|
7
|
+
import { l as loadNpmrc, r as readCatalogs, c as checkOutdated, b as formatSummary, d as formatOutdatedMinimal, h as formatOutdatedTable, t as toFilterArray } from '../packem_shared/catalog-BJTtyi-O.js';
|
|
8
|
+
|
|
9
|
+
const execute = async ({ argument, logger, options, visConfig, workspaceRoot: wsRoot }) => {
|
|
10
|
+
if (!wsRoot) {
|
|
11
|
+
throw new Error("Could not determine workspace root. Run this command inside a monorepo.");
|
|
12
|
+
}
|
|
13
|
+
const workspaceRoot = wsRoot;
|
|
14
|
+
if (options.securityConfig) {
|
|
15
|
+
const pm = detectPm(workspaceRoot);
|
|
16
|
+
printSecurityReport(visConfig ?? {}, pm.name);
|
|
17
|
+
if (options.sync && pm.name === "pnpm") {
|
|
18
|
+
const synced = previewPnpmSync(visConfig ?? {});
|
|
19
|
+
if (synced.length > 0) {
|
|
20
|
+
pail.info("\nSettings that would sync to pnpm-workspace.yaml:");
|
|
21
|
+
for (const s of synced) {
|
|
22
|
+
pail.success(` ${s}`);
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
pail.info("No security settings to sync.");
|
|
26
|
+
}
|
|
27
|
+
} else if (options.sync && pm.name !== "pnpm") {
|
|
28
|
+
pail.info(`--sync is only available for pnpm projects. Your project uses ${pm.name}.`);
|
|
29
|
+
pail.info("vis enforces security settings at the vis layer for non-pnpm projects.");
|
|
30
|
+
}
|
|
31
|
+
if (!options.security && !argument?.length) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const { packageManager } = findPackageManagerSync(workspaceRoot);
|
|
36
|
+
const npmrcConfig = loadNpmrc(workspaceRoot);
|
|
37
|
+
const configDefaults = visConfig?.update ?? {};
|
|
38
|
+
const catalogs = readCatalogs(workspaceRoot, packageManager, {
|
|
39
|
+
dev: options.dev,
|
|
40
|
+
prod: options.prod
|
|
41
|
+
});
|
|
42
|
+
if (catalogs.size === 0) {
|
|
43
|
+
logger.info("No catalogs found.");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const target = options.target ?? configDefaults.target ?? "latest";
|
|
47
|
+
if (!["latest", "minor", "patch"].includes(target)) {
|
|
48
|
+
throw new Error(`Invalid target "${target}". Use: latest, minor, or patch.`);
|
|
49
|
+
}
|
|
50
|
+
const checkOptions = {
|
|
51
|
+
exclude: [...toFilterArray(options.exclude), ...toFilterArray(configDefaults.exclude)],
|
|
52
|
+
ignore: toFilterArray(configDefaults.ignore),
|
|
53
|
+
include: [...toFilterArray(options.include), ...toFilterArray(configDefaults.include), ...argument],
|
|
54
|
+
includeLocked: Boolean(options.includeLocked),
|
|
55
|
+
includePrerelease: options.prerelease || configDefaults.prerelease || false,
|
|
56
|
+
security: !options.noSecurity,
|
|
57
|
+
target
|
|
58
|
+
};
|
|
59
|
+
let totalDeps = 0;
|
|
60
|
+
for (const deps of catalogs.values()) {
|
|
61
|
+
totalDeps += deps.size;
|
|
62
|
+
}
|
|
63
|
+
const isTTY = Boolean(process.stdout.isTTY) && !isInCi;
|
|
64
|
+
let progressInstance;
|
|
65
|
+
const onProgress = isTTY ? (current, total) => {
|
|
66
|
+
if (progressInstance) {
|
|
67
|
+
progressInstance.rerender(React.createElement(CheckProgressApp, { current, total }));
|
|
68
|
+
} else {
|
|
69
|
+
progressInstance = render(React.createElement(CheckProgressApp, { current, total }), {
|
|
70
|
+
interactive: true,
|
|
71
|
+
patchConsole: false
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
} : (current, total) => {
|
|
75
|
+
logger.info(`Checking ${String(current)}/${String(total)} dependencies...`);
|
|
76
|
+
};
|
|
77
|
+
if (!isTTY) {
|
|
78
|
+
logger.info(`Checking ${String(totalDeps)} catalog dependencies against npm registry...
|
|
79
|
+
`);
|
|
80
|
+
}
|
|
81
|
+
const socketOptions = buildSocketOptions(visConfig?.security?.socket);
|
|
82
|
+
const { failed, outdated } = await checkOutdated(
|
|
83
|
+
catalogs,
|
|
84
|
+
checkOptions,
|
|
85
|
+
npmrcConfig,
|
|
86
|
+
onProgress,
|
|
87
|
+
workspaceRoot,
|
|
88
|
+
socketOptions,
|
|
89
|
+
visConfig?.security?.socket?.acceptedRisks
|
|
90
|
+
);
|
|
91
|
+
if (progressInstance) {
|
|
92
|
+
progressInstance.clear();
|
|
93
|
+
progressInstance.unmount();
|
|
94
|
+
}
|
|
95
|
+
if (failed.length > 0) {
|
|
96
|
+
logger.warn(`Failed to fetch: ${failed.join(", ")}`);
|
|
97
|
+
}
|
|
98
|
+
if (outdated.length === 0) {
|
|
99
|
+
logger.info("All catalog dependencies are up to date.");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const format = options.format ?? configDefaults.format ?? "table";
|
|
103
|
+
const analysisType = validateAnalysisType(options.aiType ?? "impact");
|
|
104
|
+
const aiResult = options.ai ? await runAiAnalysis(outdated, logger, visConfig?.ai, analysisType) : void 0;
|
|
105
|
+
if (isTTY && format === "table") {
|
|
106
|
+
const store = new UpdateStore(outdated, aiResult ?? null);
|
|
107
|
+
const autoExitConfig = visConfig?.tui?.autoExit ?? false;
|
|
108
|
+
const autoExitSeconds = autoExitConfig === true ? 3 : typeof autoExitConfig === "number" ? autoExitConfig : 0;
|
|
109
|
+
const instance = render(
|
|
110
|
+
React.createElement(VisUpdateApp, {
|
|
111
|
+
autoExitSeconds,
|
|
112
|
+
isDryRun: true,
|
|
113
|
+
store
|
|
114
|
+
}),
|
|
115
|
+
{
|
|
116
|
+
alternateScreen: true,
|
|
117
|
+
exitOnCtrlC: false,
|
|
118
|
+
interactive: true,
|
|
119
|
+
patchConsole: true
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
await instance.waitUntilExit();
|
|
123
|
+
const columns = process.stdout.columns || 80;
|
|
124
|
+
process.stdout.write("\n");
|
|
125
|
+
for (const entry of outdated) {
|
|
126
|
+
const hasSecurityIssue = entry.vulnerabilities?.length || entry.socketReport && entry.socketReport.alerts.length > 0;
|
|
127
|
+
const isAck = Boolean(entry.acceptedRisk);
|
|
128
|
+
const icon = hasSecurityIssue ? isAck ? "✓" : "⚠" : "✓";
|
|
129
|
+
const iconColor = isAck ? "gray" : entry.updateType === "major" ? "red" : entry.updateType === "minor" ? "yellow" : "green";
|
|
130
|
+
const socketOverall = entry.socketReport?.score.overall;
|
|
131
|
+
const scoreSuffix = socketOverall === void 0 ? "" : ` [${String(Math.round(socketOverall * 100))}%]`;
|
|
132
|
+
const socketColorName = socketOverall === void 0 ? void 0 : scoreColor(socketOverall);
|
|
133
|
+
process.stdout.write(
|
|
134
|
+
`${renderToString(
|
|
135
|
+
React.createElement(
|
|
136
|
+
Text,
|
|
137
|
+
null,
|
|
138
|
+
" ",
|
|
139
|
+
React.createElement(Text, { color: iconColor }, icon),
|
|
140
|
+
` ${entry.packageName} ${entry.currentRange} → ${entry.newRange}`,
|
|
141
|
+
React.createElement(Text, { dimColor: true }, ` ${entry.updateType}`),
|
|
142
|
+
socketColorName ? React.createElement(Text, { color: socketColorName }, scoreSuffix) : null
|
|
143
|
+
),
|
|
144
|
+
{ columns }
|
|
145
|
+
)}
|
|
146
|
+
`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
process.stdout.write("\n");
|
|
150
|
+
logger.info(formatSummary(outdated));
|
|
151
|
+
} else if (format === "json") {
|
|
152
|
+
const output = { failed, outdated };
|
|
153
|
+
if (aiResult) {
|
|
154
|
+
output.aiAnalysis = aiResult;
|
|
155
|
+
}
|
|
156
|
+
process.stdout.write(`${JSON.stringify(output, void 0, 2)}
|
|
157
|
+
`);
|
|
158
|
+
} else if (format === "minimal") {
|
|
159
|
+
process.stdout.write(`${formatOutdatedMinimal(outdated)}
|
|
160
|
+
`);
|
|
161
|
+
} else {
|
|
162
|
+
formatOutdatedTable(outdated, logger);
|
|
163
|
+
logger.info(formatSummary(outdated));
|
|
164
|
+
if (aiResult) {
|
|
165
|
+
logger.info("");
|
|
166
|
+
logger.info(formatAiAnalysis(aiResult));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (options.exitCode && outdated.length > 0) {
|
|
170
|
+
process.exitCode = 1;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export { execute as default };
|
|
@@ -1,13 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { r as runToolchainPreflight } from '../packem_shared/toolchain-BdZd9eBi.js';
|
|
2
|
+
|
|
3
|
+
const detectCiRefs = () => {
|
|
4
|
+
if (process.env["GITHUB_BASE_REF"]) {
|
|
5
|
+
return {
|
|
6
|
+
base: `origin/${process.env["GITHUB_BASE_REF"]}`,
|
|
7
|
+
head: process.env["GITHUB_SHA"] ?? "HEAD"
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
if (process.env["CI_MERGE_REQUEST_TARGET_BRANCH_NAME"]) {
|
|
11
|
+
return {
|
|
12
|
+
base: `origin/${process.env["CI_MERGE_REQUEST_TARGET_BRANCH_NAME"]}`,
|
|
13
|
+
head: process.env["CI_COMMIT_SHA"] ?? "HEAD"
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (process.env["BUILDKITE_PULL_REQUEST_BASE_BRANCH"]) {
|
|
17
|
+
return {
|
|
18
|
+
base: `origin/${process.env["BUILDKITE_PULL_REQUEST_BASE_BRANCH"]}`,
|
|
19
|
+
head: process.env["BUILDKITE_COMMIT"] ?? "HEAD"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (process.env["CIRCLE_BRANCH"] && process.env["CIRCLE_SHA1"]) {
|
|
23
|
+
return {
|
|
24
|
+
base: "origin/main",
|
|
25
|
+
head: process.env["CIRCLE_SHA1"]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return { base: "origin/main", head: "HEAD" };
|
|
29
|
+
};
|
|
30
|
+
const execute = async ({ argument, logger, options, runtime, visConfig, workspaceRoot: wsRoot }) => {
|
|
31
|
+
const rawTargets = argument[0];
|
|
32
|
+
if (!rawTargets) {
|
|
33
|
+
throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");
|
|
34
|
+
}
|
|
35
|
+
const targets = rawTargets.split(",").map((t) => t.trim()).filter(Boolean);
|
|
36
|
+
if (targets.length === 0) {
|
|
37
|
+
throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");
|
|
38
|
+
}
|
|
39
|
+
if (!wsRoot) {
|
|
40
|
+
throw new Error("Could not determine workspace root. Run this command inside a monorepo.");
|
|
41
|
+
}
|
|
42
|
+
const { base: defaultBase, head: defaultHead } = detectCiRefs();
|
|
43
|
+
const base = options.base ?? defaultBase;
|
|
44
|
+
const head = options.head ?? defaultHead;
|
|
45
|
+
if (!options.skipToolchain) {
|
|
46
|
+
logger.info("▸ Toolchain pre-flight");
|
|
47
|
+
}
|
|
48
|
+
await runToolchainPreflight(
|
|
49
|
+
wsRoot,
|
|
50
|
+
visConfig?.toolchain,
|
|
51
|
+
{
|
|
52
|
+
error: (message) => {
|
|
53
|
+
logger.error(message);
|
|
54
|
+
},
|
|
55
|
+
info: (message) => {
|
|
56
|
+
logger.info(message);
|
|
57
|
+
},
|
|
58
|
+
warn: (message) => {
|
|
59
|
+
logger.warn(message);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
Boolean(options.skipToolchain)
|
|
63
|
+
);
|
|
64
|
+
if (options.install === false) {
|
|
65
|
+
logger.info("▸ Skipping install (--no-install)");
|
|
66
|
+
} else {
|
|
67
|
+
logger.info("▸ Installing dependencies");
|
|
68
|
+
await runtime.runCommand("install", {
|
|
69
|
+
argv: ["--frozen-lockfile"]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
for (const target of targets) {
|
|
73
|
+
logger.info(`▸ Running affected ${target} (base=${base}, head=${head})`);
|
|
74
|
+
const argv = [
|
|
75
|
+
target,
|
|
76
|
+
`--base=${base}`,
|
|
77
|
+
`--head=${head}`,
|
|
78
|
+
`--upstream=${String(options.upstream ?? "none")}`,
|
|
79
|
+
`--downstream=${String(options.downstream ?? "deep")}`
|
|
80
|
+
];
|
|
81
|
+
if (options.parallel !== void 0) {
|
|
82
|
+
argv.push(`--parallel=${String(options.parallel)}`);
|
|
83
|
+
}
|
|
84
|
+
if (options.partition) {
|
|
85
|
+
argv.push(`--partition=${String(options.partition)}`);
|
|
86
|
+
}
|
|
87
|
+
if (options.query) {
|
|
88
|
+
argv.push(`--query=${String(options.query)}`);
|
|
89
|
+
}
|
|
90
|
+
await runtime.runCommand("affected", { argv });
|
|
91
|
+
}
|
|
92
|
+
logger.info("▸ CI pipeline complete");
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export { execute as default };
|
|
@@ -1,8 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
+
|
|
7
|
+
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
+
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
+
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
+
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
+
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
+
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
+
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// Fallback to createRequire
|
|
17
|
+
return __cjs_require(module);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
readdirSync,
|
|
22
|
+
lstatSync
|
|
23
|
+
} = __cjs_getBuiltinModule("node:fs");
|
|
24
|
+
import { isAccessibleSync } from '@visulima/fs';
|
|
25
|
+
import { join } from '@visulima/path';
|
|
26
|
+
import { cleanWorkspace } from '#native';
|
|
27
|
+
import { p as pail } from './bin.js';
|
|
28
|
+
|
|
29
|
+
const findNodeModulesDirectories = (root) => {
|
|
30
|
+
const results = [];
|
|
31
|
+
const stack = [root];
|
|
32
|
+
while (stack.length > 0) {
|
|
33
|
+
const dir = stack.pop();
|
|
34
|
+
let entries;
|
|
35
|
+
try {
|
|
36
|
+
entries = readdirSync(dir);
|
|
37
|
+
} catch {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
for (const entry of entries) {
|
|
41
|
+
const fullPath = join(dir, entry);
|
|
42
|
+
try {
|
|
43
|
+
const stat = lstatSync(fullPath);
|
|
44
|
+
if (stat.isSymbolicLink() || !stat.isDirectory()) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
} catch {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (entry === "node_modules") {
|
|
51
|
+
results.push(fullPath);
|
|
52
|
+
} else if (entry !== ".git" && entry !== ".hg") {
|
|
53
|
+
stack.push(fullPath);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return results;
|
|
58
|
+
};
|
|
59
|
+
const LOCKFILE_NAMES = ["pnpm-lock.yaml", "package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "bun.lock", "bun.lockb"];
|
|
60
|
+
const removeLockfiles = (cwd, dryRun, logger) => {
|
|
61
|
+
let removed = 0;
|
|
62
|
+
let hadError = false;
|
|
63
|
+
for (const name of LOCKFILE_NAMES) {
|
|
64
|
+
const lockfile = join(cwd, name);
|
|
65
|
+
if (!isAccessibleSync(lockfile)) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
{
|
|
69
|
+
logger.info(` ${lockfile}`);
|
|
70
|
+
removed++;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { hadError, removed };
|
|
75
|
+
};
|
|
76
|
+
const execute = async ({ logger, options, workspaceRoot: wsRoot }) => {
|
|
77
|
+
const cwd = wsRoot ?? process.cwd();
|
|
78
|
+
const shouldRemoveLockfile = options.lockfile || false;
|
|
79
|
+
const dryRun = options.dryRun || false;
|
|
80
|
+
if (dryRun) {
|
|
81
|
+
const directories = findNodeModulesDirectories(cwd);
|
|
82
|
+
if (directories.length > 0) {
|
|
83
|
+
pail.info("Would remove:");
|
|
84
|
+
for (const dir of directories) {
|
|
85
|
+
logger.info(` ${dir}`);
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
pail.info("No node_modules directories found.");
|
|
89
|
+
}
|
|
90
|
+
if (shouldRemoveLockfile) {
|
|
91
|
+
removeLockfiles(cwd, true, logger);
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const result = cleanWorkspace(cwd, shouldRemoveLockfile);
|
|
96
|
+
for (const dir of result.removed) {
|
|
97
|
+
pail.success(`Removed ${dir}`);
|
|
98
|
+
}
|
|
99
|
+
for (const file of result.lockfilesRemoved) {
|
|
100
|
+
pail.success(`Removed ${file}`);
|
|
101
|
+
}
|
|
102
|
+
for (const error of result.errors) {
|
|
103
|
+
pail.error(error);
|
|
104
|
+
}
|
|
105
|
+
if (result.removed.length === 0 && result.lockfilesRemoved.length === 0) {
|
|
106
|
+
pail.info("No node_modules directories found.");
|
|
107
|
+
} else {
|
|
108
|
+
pail.info(`Cleaned ${result.removed.length} node_modules director${result.removed.length === 1 ? "y" : "ies"}`);
|
|
109
|
+
}
|
|
110
|
+
if (result.errors.length > 0) {
|
|
111
|
+
process.exitCode = 1;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export { execute as default };
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { r as resolveInstaller, k as runDedupe } from './bin.js';
|
|
2
|
+
|
|
3
|
+
const execute = async ({ logger, options, visConfig, workspaceRoot: wsRoot }) => {
|
|
4
|
+
const cwd = wsRoot ?? process.cwd();
|
|
5
|
+
const pm = resolveInstaller(cwd, { configBackend: visConfig?.install?.backend });
|
|
6
|
+
const code = runDedupe(pm, options.check || false, cwd, logger);
|
|
7
|
+
if (code !== 0) {
|
|
8
|
+
process.exitCode = code;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { execute as default };
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import { r as resolveInstaller, l as runDlx } from './bin.js';
|
|
2
|
+
|
|
3
|
+
const execute = async ({ argument, logger, options, visConfig, workspaceRoot: wsRoot }) => {
|
|
4
|
+
const args = argument;
|
|
5
|
+
if (!args || args.length === 0) {
|
|
6
|
+
throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");
|
|
7
|
+
}
|
|
8
|
+
const [pkg, ...rest] = args;
|
|
9
|
+
const cwd = wsRoot ?? process.cwd();
|
|
10
|
+
const pm = resolveInstaller(cwd, { configBackend: visConfig?.install?.backend });
|
|
11
|
+
const additionalPackages = options.package ? Array.isArray(options.package) ? options.package : [options.package] : [];
|
|
12
|
+
const code = runDlx(
|
|
13
|
+
pm,
|
|
14
|
+
{
|
|
15
|
+
additionalPackages,
|
|
16
|
+
args: rest,
|
|
17
|
+
package: pkg,
|
|
18
|
+
shellMode: options.shellMode || false,
|
|
19
|
+
silent: options.silent || false
|
|
20
|
+
},
|
|
21
|
+
cwd,
|
|
22
|
+
logger
|
|
23
|
+
);
|
|
24
|
+
if (code !== 0) {
|
|
25
|
+
process.exitCode = code;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { execute as default };
|