@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.
Files changed (120) hide show
  1. package/CHANGELOG.md +95 -42
  2. package/LICENSE.md +213 -0
  3. package/README.md +8 -4
  4. package/dist/bin.js +9 -1
  5. package/dist/config/index.d.ts +1818 -0
  6. package/dist/config/index.js +2 -0
  7. package/dist/generate/index.d.ts +1 -1
  8. package/dist/generate/index.js +3 -1
  9. package/dist/packem_chunks/applyDefaults.js +336 -0
  10. package/dist/packem_chunks/bin.js +9554 -64
  11. package/dist/packem_chunks/doctor-probe.js +112 -0
  12. package/dist/packem_chunks/fix.js +229 -48
  13. package/dist/packem_chunks/handler.js +99 -1
  14. package/dist/packem_chunks/handler10.js +53 -1
  15. package/dist/packem_chunks/handler11.js +32 -1
  16. package/dist/packem_chunks/handler12.js +100 -2
  17. package/dist/packem_chunks/handler13.js +25 -1
  18. package/dist/packem_chunks/handler14.js +916 -5
  19. package/dist/packem_chunks/handler15.js +206 -1
  20. package/dist/packem_chunks/handler16.js +122 -18
  21. package/dist/packem_chunks/handler17.js +13 -1
  22. package/dist/packem_chunks/handler18.js +106 -1
  23. package/dist/packem_chunks/handler19.js +19 -1
  24. package/dist/packem_chunks/handler2.js +75 -1
  25. package/dist/packem_chunks/handler20.js +29 -1
  26. package/dist/packem_chunks/handler21.js +222 -1
  27. package/dist/packem_chunks/handler22.js +237 -5
  28. package/dist/packem_chunks/handler23.js +101 -1
  29. package/dist/packem_chunks/handler24.js +110 -1
  30. package/dist/packem_chunks/handler25.js +402 -5
  31. package/dist/packem_chunks/handler26.js +13 -1
  32. package/dist/packem_chunks/handler27.js +63 -3
  33. package/dist/packem_chunks/handler28.js +34 -1
  34. package/dist/packem_chunks/handler29.js +458 -7
  35. package/dist/packem_chunks/handler3.js +95 -2
  36. package/dist/packem_chunks/handler30.js +168 -21
  37. package/dist/packem_chunks/handler31.js +530 -3
  38. package/dist/packem_chunks/handler32.js +214 -2
  39. package/dist/packem_chunks/handler33.js +119 -24
  40. package/dist/packem_chunks/handler34.js +630 -2
  41. package/dist/packem_chunks/handler35.js +283 -19
  42. package/dist/packem_chunks/handler36.js +521 -407
  43. package/dist/packem_chunks/handler37.js +762 -22
  44. package/dist/packem_chunks/handler38.js +989 -22
  45. package/dist/packem_chunks/handler39.js +574 -22
  46. package/dist/packem_chunks/handler4.js +90 -4
  47. package/dist/packem_chunks/handler40.js +1685 -3
  48. package/dist/packem_chunks/handler41.js +1088 -10
  49. package/dist/packem_chunks/handler42.js +785 -141
  50. package/dist/packem_chunks/handler43.js +2658 -42
  51. package/dist/packem_chunks/handler44.js +3886 -3
  52. package/dist/packem_chunks/handler45.js +2568 -21
  53. package/dist/packem_chunks/handler46.js +3769 -0
  54. package/dist/packem_chunks/handler47.js +1491 -0
  55. package/dist/packem_chunks/handler5.js +174 -2
  56. package/dist/packem_chunks/handler6.js +95 -13
  57. package/dist/packem_chunks/handler7.js +115 -8
  58. package/dist/packem_chunks/handler8.js +12 -1
  59. package/dist/packem_chunks/handler9.js +29 -1
  60. package/dist/packem_chunks/heal-accept.js +522 -0
  61. package/dist/packem_chunks/heal.js +673 -0
  62. package/dist/packem_chunks/index.js +873 -7
  63. package/dist/packem_chunks/loader.js +23 -1
  64. package/dist/packem_shared/VisUpdateApp-D-Yz_wvg.js +1316 -0
  65. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +5 -0
  66. package/dist/packem_shared/ai-analysis-CHeB1joD.js +367 -0
  67. package/dist/packem_shared/ai-cache-Be_jexe4.js +142 -0
  68. package/dist/packem_shared/ai-fix-B9iQVcD2.js +379 -0
  69. package/dist/packem_shared/cache-directory-2qvs4goY.js +98 -0
  70. package/dist/packem_shared/catalog-BJTtyi-O.js +1371 -0
  71. package/dist/packem_shared/dependency-scan-A0KSklpG.js +188 -0
  72. package/dist/packem_shared/docker-2iZzc280.js +181 -0
  73. package/dist/packem_shared/failure-log-Cz3Z4SKL.js +100 -0
  74. package/dist/packem_shared/flakiness-goTxXuCX.js +180 -0
  75. package/dist/packem_shared/otel-DCvqCTz_.js +158 -0
  76. package/dist/packem_shared/otelPlugin-DFaLDvJf.js +3 -0
  77. package/dist/packem_shared/registry-CbqXI0rc.js +272 -0
  78. package/dist/packem_shared/run-summary-utils-PVMl4aIh.js +130 -0
  79. package/dist/packem_shared/runtime-check-Cobi3p6l.js +127 -0
  80. package/dist/packem_shared/selectors-SM69TfqC.js +194 -0
  81. package/dist/packem_shared/symbols-Ta7g2nU-.js +14 -0
  82. package/dist/packem_shared/toolchain-BdZd9eBi.js +975 -0
  83. package/dist/packem_shared/typosquats-C-bCh3PX.js +1210 -0
  84. package/dist/packem_shared/use-measured-height-CNP0vT4M.js +20 -0
  85. package/dist/packem_shared/utils-CthVdBPS.js +40 -0
  86. package/dist/packem_shared/xxh3-Ck8mXNg1.js +239 -0
  87. package/index.js +727 -555
  88. package/package.json +35 -17
  89. package/schemas/project.schema.json +8 -10
  90. package/schemas/vis-config.schema.json +132 -8
  91. package/skills/vis/SKILL.md +96 -0
  92. package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
  93. package/templates/buildkite-ci/template.yml +20 -0
  94. package/dist/errors/index.d.ts +0 -26
  95. package/dist/errors/index.js +0 -1
  96. package/dist/packem_chunks/config.js +0 -2
  97. package/dist/packem_shared/VisConfigCycleError-CAYNC7d-.js +0 -1
  98. package/dist/packem_shared/VisConfigError-B5LP1zRf.js +0 -1
  99. package/dist/packem_shared/VisConfigLoadError-CeqBSd2Z.js +0 -2
  100. package/dist/packem_shared/VisConfigNotFoundError-DZ9KC527.js +0 -5
  101. package/dist/packem_shared/VisUpdateApp-D-L4_-Iu.js +0 -1
  102. package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +0 -1
  103. package/dist/packem_shared/ai-analysis-CGuy7dfE.js +0 -67
  104. package/dist/packem_shared/ai-cache-Bynt6Y9x.js +0 -1
  105. package/dist/packem_shared/cache-directory-D72ZEag2.js +0 -1
  106. package/dist/packem_shared/catalog-BVPerCwG.js +0 -12
  107. package/dist/packem_shared/dependency-scan-Du0tBu64.js +0 -2
  108. package/dist/packem_shared/docker-BcfqH4Av.js +0 -2
  109. package/dist/packem_shared/failure-log-DqYen0LC.js +0 -2
  110. package/dist/packem_shared/flakiness-DSIHZGBT.js +0 -1
  111. package/dist/packem_shared/run-summary-utils-C24Aaf9E.js +0 -1
  112. package/dist/packem_shared/runtime-check-CGHal8SO.js +0 -1
  113. package/dist/packem_shared/selectors-CfH9ZY08.js +0 -3
  114. package/dist/packem_shared/symbols-CQmER5MT.js +0 -1
  115. package/dist/packem_shared/target-merge-DNa-6eWu.js +0 -1
  116. package/dist/packem_shared/toolchain-DQfTQY8E.js +0 -5
  117. package/dist/packem_shared/typosquats-DOR8izpX.js +0 -1
  118. package/dist/packem_shared/use-measured-height-DjYgUOKk.js +0 -1
  119. package/dist/packem_shared/utils-DrNg0XTR.js +0 -1
  120. package/dist/packem_shared/xxh3-DrAUNq4n.js +0 -1
@@ -1,2 +1,174 @@
1
- var d=Object.defineProperty;var l=(s,t)=>d(s,"name",{value:t,configurable:!0});import{createRequire as f}from"node:module";import{c as y,p as e,I as w,T as h}from"./bin.js";const m=f(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=l(s=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[t,r]=c.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return c.getBuiltinModule(s)}return m(s)},"__cjs_getBuiltinModule"),{spawnSync:v}=g("node:child_process");var b=Object.defineProperty,_=l((s,t)=>b(s,"name",{value:t,configurable:!0}),"p");const $=_(async({options:s,visConfig:t,workspaceRoot:r})=>{const p=r??process.cwd(),a=y(p);if(a.name==="pnpm"&&!s.scan){e.info("Delegating to pnpm approve-builds...");const i=["approve-builds"];s.all&&i.push("--all");const o=v("pnpm",i,{cwd:p,stdio:"inherit"});if(o.error)throw new Error(`Failed to run pnpm approve-builds: ${o.error.message}`);if(o.status!==0&&o.status!==null&&(e.error(`pnpm approve-builds exited with code ${o.status}`),process.exitCode=o.status),!s.syncNative){e.notice(""),e.notice("Tip: vis.config.ts security.allowBuilds may now be out of sync with pnpm-workspace.yaml."),e.notice("Run 'vis check --security-config' to compare, or copy the new entries into vis.config.ts.");return}}else{const i=t?.security?.allowBuilds??{},o=w(p,i);if(o.length===0)e.success("No unapproved build scripts found.");else{e.warn(`Found ${o.length} package${o.length===1?"":"s"} with unapproved build scripts:
2
- `);for(const n of o)e.info(` ${n}`);e.notice(""),e.notice("To approve these packages, add them to vis.config.ts:"),e.notice(""),e.notice(" security: {"),e.notice(" allowBuilds: {");for(const n of o){const u=n.split(" (")[0];e.notice(` "${u}": true,`)}e.notice(" },"),e.notice(" },"),a.name==="pnpm"&&(e.notice(""),e.notice("Or run 'pnpm approve-builds' to update pnpm-workspace.yaml directly."))}}if(s.syncNative){const i=t?.security?.allowBuilds??{};if(Object.keys(i).length===0)e.warn("No security.allowBuilds configured in vis.config.ts. Nothing to sync.");else{const o=h(a.name,p,i);e.info("");for(const n of o)e.success(n)}}},"execute");export{$ as default};
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
- var F=Object.defineProperty;var C=(e,r)=>F(e,"name",{value:r,configurable:!0});import{createRequire as q}from"node:module";import{isAccessibleSync as v}from"@visulima/fs";import{formatBytes as g}from"@visulima/humanizer";import{join as L}from"@visulima/path";import{Cache as M,parseCacheSize as K,readLastRunSummary as T,getLastRunSummaryPath as Q}from"@visulima/task-runner";import{B as G,J as D}from"../packem_shared/ai-cache-Bynt6Y9x.js";import{_ as V,E as N}from"../packem_shared/cache-directory-D72ZEag2.js";import{p as n,H as X,a as E}from"./bin.js";import{r as J,f as I,a as Z,d as ee}from"../packem_shared/run-summary-utils-C24Aaf9E.js";const U=q(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=C(e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[r,t]=k.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return k.getBuiltinModule(e)}return U(e)},"__cjs_getBuiltinModule"),{readdir:j,stat:A,realpath:z,rm:O}=b("node:fs/promises"),{createInterface:Y}=b("node:readline");var te=Object.defineProperty,h=C((e,r)=>te(e,"name",{value:r,configurable:!0}),"f");const W=h(async e=>{let r=0;try{const t=await j(e,{withFileTypes:!0});for(const o of t){const s=L(e,o.name);if(o.isDirectory())r+=await W(s);else if(o.isFile()){const a=await A(s);r+=a.size}}}catch{}return r},"sumDirectorySize"),w=h(async e=>{const r=[];let t;try{t=await j(e)}catch{return[]}for(const o of t){if(o.startsWith("."))continue;const s=L(e,o);try{const a=await A(s);if(!a.isDirectory())continue;const c=await W(s);r.push({hash:o,mtimeMs:a.mtimeMs,path:s,sizeBytes:c})}catch{}}return r.sort((o,s)=>s.mtimeMs-o.mtimeMs),r},"collectCacheEntries"),se=h((e,r=Date.now())=>{const t=Math.floor((r-e)/1e3);return t<60?`${String(t)}s`:t<3600?`${String(Math.floor(t/60))}m`:t<86400?`${String(Math.floor(t/3600))}h`:`${String(Math.floor(t/86400))}d`},"formatAge"),re=h(e=>new Promise(r=>{const t=Y({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,o=>{t.close();const s=o.trim().toLowerCase();r(s==="y"||s==="yes")})}),"confirmPrompt"),oe=h(async(e,r,t)=>{if(!v(e)){if(r==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
2
- `);return}n.info(`No cache directory found at ${e}`);return}const o=await w(e);if(o.length===0){if(r==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
3
- `);return}n.info(`Cache directory is empty: ${e}`);return}const s=o.reduce((i,d)=>i+d.sizeBytes,0);if(r==="json"){const i=Date.now();process.stdout.write(`${JSON.stringify({directory:e,entries:o.map(d=>({ageMs:i-d.mtimeMs,hash:d.hash,mtimeIso:new Date(d.mtimeMs).toISOString(),sizeBytes:d.sizeBytes})),totalBytes:s,totalCount:o.length},void 0,2)}
4
- `);return}n.info(`Cache directory: ${e}`),n.info(`Entries: ${String(o.length)} (${g(s,{decimals:1,space:!1})})`),t.info("");const a=Date.now(),c=o.map(i=>({age:se(i.mtimeMs,a),hash:i.hash.slice(0,12),size:g(i.sizeBytes,{decimals:1,space:!1})})),u=Math.max(4,...c.map(i=>i.hash.length)),f=Math.max(4,...c.map(i=>i.size.length)),l=Math.max(3,...c.map(i=>i.age.length));t.info(` ${"hash".padEnd(u)} ${"size".padEnd(f)} ${"age".padEnd(l)}`),t.info(` ${"-".repeat(u)} ${"-".repeat(f)} ${"-".repeat(l)}`);for(const i of c)t.info(` ${i.hash.padEnd(u)} ${i.size.padEnd(f)} ${i.age.padEnd(l)}`)},"runList"),ae=h(()=>{try{const e=G();e>0&&n.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){n.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},"clearAiCacheSafe"),ne=h(()=>{try{const e=X();e>0&&n.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){n.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},"clearSocketCacheSafe"),ie=h(async(e,r,t)=>{if(!v(e)){n.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const s=await w(e),a=s.reduce((c,u)=>c+u.sizeBytes,0);n.info(`Would remove ${String(s.length)} cache entr${s.length===1?"y":"ies"} (${g(a,{decimals:1,space:!1})}) from ${e}`);return}const o=V(e,r);try{const s=await z(e),a=await z(r);if(s===a){n.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!o&&!t.force){if(n.warn(`Cache directory is outside the workspace root: ${e}`),n.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){n.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await re(" Continue?")){n.info("Aborted.");return}}o?await new M({cacheDirectory:e,workspaceRoot:r}).clear():await O(e,{force:!0,recursive:!0}),n.success(`Cleared cache: ${e}`)},"runClean"),ce=h(async(e,r,t)=>{if(!v(e)){n.info(`No cache directory to prune at ${e}`);return}if(t.maxCacheAgeDays!==void 0&&(!Number.isFinite(t.maxCacheAgeDays)||t.maxCacheAgeDays<0)){n.error(`Invalid --max-age-days value: expected a finite number >= 0, got ${String(t.maxCacheAgeDays)}`),process.exitCode=1;return}if(t.keepLast!==void 0&&(!Number.isFinite(t.keepLast)||t.keepLast<0||!Number.isInteger(t.keepLast))){n.error(`Invalid --keep-last value: expected a non-negative integer, got ${String(t.keepLast)}`),process.exitCode=1;return}if(t.maxCacheSize!==void 0){let i;try{i=K(t.maxCacheSize)}catch(d){n.error(`Invalid --max-size value: ${d instanceof Error?d.message:String(d)}`),process.exitCode=1;return}if(!Number.isFinite(i)||i<=0){n.error(`Invalid --max-size value: expected a positive size, got "${t.maxCacheSize}" (${String(i)} bytes)`),process.exitCode=1;return}}const o=t.maxCacheAgeDays===void 0?void 0:t.maxCacheAgeDays*24*60*60*1e3,s=await w(e),a=s.reduce((i,d)=>i+d.sizeBytes,0);if(t.keepLast!==void 0&&s.length>t.keepLast){const i=s.slice(t.keepLast);await Promise.all(i.map(d=>O(d.path,{force:!0,recursive:!0})))}await new M({cacheDirectory:e,maxCacheAge:o,maxCacheSize:t.maxCacheSize,workspaceRoot:r}).removeOldEntries();const c=await w(e),u=c.reduce((i,d)=>i+d.sizeBytes,0),f=s.length-c.length,l=a-u;if(f<=0){n.info("Nothing to prune — all entries are within the configured limits.");return}n.success(`Pruned ${String(f)} entr${f===1?"y":"ies"}, freed ${g(l,{decimals:1,space:!1})}.`)},"runPrune"),R=16,P=h(e=>e.length>R?`${e.slice(0,R)}…`:e,"truncateHash"),x=h((e,r,t)=>{const o=Object.entries(r??{});if(o.length!==0){t.info(` ${e}:`),o.sort(([s],[a])=>s.localeCompare(a));for(const[s,a]of o)t.info(` ${s.padEnd(40)} ${P(a)}`)}},"renderHashDetailsBucket"),ue=h(async(e,r,t)=>{const{format:o,runId:s,workspaceRoot:a}=r,c=s===void 0?await T(a):await J(a,s);if(!c){if(o==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:s??null,taskId:e},void 0,2)}
5
- `),process.exitCode=1;return}s===void 0?n.error("No previous run summary found. Run a task first to populate `.task-runner/last-summary.json`."):n.error(`Run summary "${s}" not found in .task-runner/runs/.`),process.exitCode=1;return}const u=I(c,e);if(!u){if(o==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:c.id,taskId:e},void 0,2)}
6
- `),process.exitCode=1;return}n.error(`Task "${e}" was not part of run ${c.id}.`),n.info(`Tasks in this run: ${c.tasks.map(d=>d.taskId).join(", ")||"(none)"}`),process.exitCode=1;return}const f=await Z(a,c.id),l=f?I(f,e):void 0,i=ee(u.hashDetails,l?.hashDetails);if(o==="json"){process.stdout.write(`${JSON.stringify({diff:i,previousRunId:f?.id??null,previousTask:l?{cacheStatus:l.cacheStatus,hash:l.hash??null,hashDetails:l.hashDetails??null}:null,runId:c.id,task:{cacheStatus:u.cacheStatus,hash:u.hash??null,hashDetails:u.hashDetails??null,taskId:u.taskId}},void 0,2)}
7
- `);return}if(n.info(`Why ${e}? (run ${c.id})`),t.info(""),t.info(` status: ${u.cacheStatus}`),t.info(` hash: ${u.hash??"(none)"}`),l?t.info(` prev: ${l.hash??"(none)"} [run ${f?.id??"?"}]`):t.info(" prev: (no prior run found)"),t.info(""),!l){n.info("No previous run to diff against — first time this task was recorded.");return}if(!i.commandChanged&&i.nodes.added.length===0&&i.nodes.changed.length===0&&i.nodes.removed.length===0&&i.runtime.added.length===0&&i.runtime.changed.length===0&&i.runtime.removed.length===0&&i.implicitDeps.added.length===0&&i.implicitDeps.changed.length===0&&i.implicitDeps.removed.length===0){n.success("No hash inputs changed since the previous run.");return}t.info("Hash inputs that changed since the previous run:"),t.info(""),i.commandChanged&&t.info(" command: changed");for(const d of["nodes","runtime","implicitDeps"]){const m=i[d];if(!(m.added.length===0&&m.changed.length===0&&m.removed.length===0)){t.info(` ${d}:`);for(const $ of m.added)t.info(` + ${$}`);for(const $ of m.changed)t.info(` ~ ${$}`);for(const $ of m.removed)t.info(` - ${$}`)}}t.info(""),n.info(`Last summary file: ${Q(a)}`)},"runWhy"),de=h(async(e,r,t)=>{const{format:o,runId:s,workspaceRoot:a}=r,c=s===void 0?await T(a):await J(a,s);if(!c){if(o==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:s??null,taskId:e},void 0,2)}
8
- `),process.exitCode=1;return}s===void 0?n.error("No previous run summary found. Run a task first to populate `.task-runner/last-summary.json`."):n.error(`Run summary "${s}" not found in .task-runner/runs/.`),process.exitCode=1;return}const u=I(c,e);if(!u){if(o==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:c.id,taskId:e},void 0,2)}
9
- `),process.exitCode=1;return}n.error(`Task "${e}" was not part of run ${c.id}.`),process.exitCode=1;return}if(o==="json"){process.stdout.write(`${JSON.stringify({cacheStatus:u.cacheStatus,hash:u.hash??null,hashDetails:u.hashDetails??null,runId:c.id,taskId:u.taskId},void 0,2)}
10
- `);return}n.info(`Hash for ${e} (run ${c.id})`),t.info(""),t.info(` status: ${u.cacheStatus}`),t.info(` hash: ${u.hash??"(none)"}`),u.hashDetails?(t.info(""),t.info(` command: ${P(u.hashDetails.command)}`),x("nodes",u.hashDetails.nodes,t),x("runtime",u.hashDetails.runtime,t),x("implicitDeps",u.hashDetails.implicitDeps,t)):(t.info(""),n.info("No hash details recorded for this task."))},"runHash"),he=h(async(e,r)=>{if(!v(e)){if(r==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
11
- `);return}n.info(`No cache directory at ${e}`);return}const t=await w(e),o=t.reduce((s,a)=>s+a.sizeBytes,0);if(r==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!0,totalBytes:o,totalCount:t.length})}
12
- `);return}n.info(`Cache directory: ${e}`),n.info(`Entries: ${String(t.length)}`),n.info(`Total size: ${g(o,{decimals:1,space:!1})}`)},"runSize"),_=h(e=>e==="task"||e==="ai"||e==="socket"||e==="all"?e:(e&&e.length>0&&n.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),"parseCacheTarget"),p=h((e,r)=>e==="all"||e===r,"includesTarget"),y=h(e=>e===void 0?null:new Date(e).toISOString(),"isoOrNull"),B=h((e,r)=>{n.info(`${e}:`),n.info(` Entries: ${String(r.entries)}`),n.info(` Total size: ${g(r.totalSizeBytes,{decimals:1,space:!1})}`),n.info(` Oldest: ${r.oldestEntry?new Date(r.oldestEntry).toISOString():"N/A"}`),n.info(` Newest: ${r.newestEntry?new Date(r.newestEntry).toISOString():"N/A"}`)},"printAuxStatsBlock"),le=h(e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&n.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),"parseScope"),S=h((e,r,t)=>{const o=e??process.cwd(),s=t??{},a=s.taskRunnerOptions??{},c=le(r.scope),u=r.cacheDir,f=N(o,u,a.cacheDirectory,!1),l=N(o,u,a.cacheDirectory,s.sharedWorktreeCache);let i,d;switch(c){case"all":{i=l,d=l===f?[l]:[l,f];break}case"worktree":{i=f,d=[f];break}default:i=l,d=[l]}return{cacheDirectories:d,cacheDirectory:i,scope:c,sharedWorktreeCache:s.sharedWorktreeCache,workspaceRoot:o}},"resolveCacheDirectoryFromContext"),Ce=h(async({logger:e,options:r,visConfig:t,workspaceRoot:o})=>{const{cacheDirectories:s}=S(o,r,t),a=r.format??"table";for(const c of s)s.length>1&&n.info(`# ${c}`),await oe(c,a,e)},"cacheListExecute"),xe=h(async({options:e,visConfig:r,workspaceRoot:t})=>{const o=_(e.type),s=!!e.dryRun;if(p(o,"task")){const{cacheDirectory:a,workspaceRoot:c}=S(t,e,r);await ie(a,c,{dryRun:s,force:!!e.force})}if(p(o,"ai"))if(s){const a=D();n.info(`Would clear ${String(a.entries)} cached AI response${a.entries===1?"":"s"}.`)}else ae();if(p(o,"socket"))if(s){const a=E();n.info(`Would clear ${String(a.entries)} cached Socket.dev report${a.entries===1?"":"s"}.`)}else ne()},"cacheCleanExecute"),De=h(async({options:e,visConfig:r,workspaceRoot:t})=>{const{cacheDirectories:o,workspaceRoot:s}=S(t,e,r);for(const a of o)o.length>1&&n.info(`# ${a}`),await ce(a,s,{keepLast:typeof e.keepLast=="number"?e.keepLast:void 0,maxCacheAgeDays:typeof e.maxAgeDays=="number"?e.maxAgeDays:void 0,maxCacheSize:e.maxSize})},"cachePruneExecute"),H=h(e=>e??process.cwd(),"resolveWorkspaceRoot"),Ee=h(async({argument:e,logger:r,options:t,workspaceRoot:o})=>{const s=e[0];if(!s){n.error("No task ID specified. Usage: vis cache why <project>:<target>"),process.exitCode=1;return}await ue(s,{format:t.format??"table",runId:t.run,workspaceRoot:H(o)},r)},"cacheWhyExecute"),Ie=h(async({argument:e,logger:r,options:t,workspaceRoot:o})=>{const s=e[0];if(!s){n.error("No task ID specified. Usage: vis cache hash <project>:<target>"),process.exitCode=1;return}await de(s,{format:t.format??"table",runId:t.run,workspaceRoot:H(o)},r)},"cacheHashExecute"),ze=h(async({options:e,visConfig:r,workspaceRoot:t})=>{const o=_(e.type);if((e.format??"table")==="json"){const s={};if(p(o,"task")){const{cacheDirectories:a}=S(t,e,r);s.task=await Promise.all(a.map(async c=>{const u=v(c),f=u?await w(c):[],l=f.reduce((i,d)=>i+d.sizeBytes,0);return{directory:c,entries:f.length,exists:u,newestEntry:y(f[0]?.mtimeMs),oldestEntry:y(f.at(-1)?.mtimeMs),totalBytes:l}}))}if(p(o,"ai")){const a=D();s.ai={entries:a.entries,newestEntry:y(a.newestEntry),oldestEntry:y(a.oldestEntry),totalBytes:a.totalSizeBytes}}if(p(o,"socket")){const a=E();s.socket={entries:a.entries,newestEntry:y(a.newestEntry),oldestEntry:y(a.oldestEntry),totalBytes:a.totalSizeBytes}}process.stdout.write(`${JSON.stringify(s,void 0,2)}
13
- `);return}if(p(o,"task")){const{cacheDirectories:s}=S(t,e,r);for(const a of s)s.length>1&&n.info(`# ${a}`),await he(a,"table")}p(o,"ai")&&B("AI response cache",D()),p(o,"socket")&&B("Socket.dev report cache",E())},"cacheSizeExecute");export{xe as cacheCleanExecute,Ie as cacheHashExecute,Ce as cacheListExecute,De as cachePruneExecute,ze as cacheSizeExecute,Ee as cacheWhyExecute,ae as clearAiCacheSafe,ne as clearSocketCacheSafe,w as collectCacheEntries,se as formatAge,ie as runClean,de as runHash,oe as runList,ce as runPrune,he as runSize,ue as runWhy};
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
- var I=Object.defineProperty;var S=(c,o)=>I(c,"name",{value:o,configurable:!0});import{findPackageManagerSync as J}from"@visulima/package";import{render as b,renderToString as V,Text as y}from"@visulima/tui";import{c as W,O as Z,W as q,p as f,V as G,B as H,d as K}from"./bin.js";import a from"react";import{z as Q,e as X,Z as _}from"../packem_shared/ai-analysis-CGuy7dfE.js";import{U as ee,B as te,f as j}from"../packem_shared/VisUpdateApp-D-L4_-Iu.js";import{o as oe,a as re,N as m,w as ne,v as N,O as se,T as ie}from"../packem_shared/catalog-BVPerCwG.js";var ae=Object.defineProperty,ce=S((c,o)=>ae(c,"name",{value:o,configurable:!0}),"$");const we=ce(async({argument:c,logger:o,options:e,visConfig:i,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.securityConfig){const t=W(d);if(Z(i??{},t.name),e.sync&&t.name==="pnpm"){const r=q(i??{});if(r.length>0){f.info(`
2
- Settings that would sync to pnpm-workspace.yaml:`);for(const x of r)f.success(` ${x}`)}else f.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(f.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),f.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!c?.length)return}const{packageManager:O}=J(d),U=oe(d),l=i?.update??{},w=re(d,O,{dev:e.dev,prod:e.prod});if(w.size===0){o.info("No catalogs found.");return}const v=e.target??l.target??"latest";if(!["latest","minor","patch"].includes(v))throw new Error(`Invalid target "${v}". Use: latest, minor, or patch.`);const z={exclude:[...m(e.exclude),...m(l.exclude)],ignore:m(l.ignore),include:[...m(e.include),...m(l.include),...c],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||l.prerelease||!1,security:!e.noSecurity,target:v};let E=0;for(const t of w.values())E+=t.size;const h=!!process.stdout.isTTY&&!K;let u;const B=h?(t,r)=>{u?u.rerender(a.createElement(j,{current:t,total:r})):u=b(a.createElement(j,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{o.info(`Checking ${String(t)}/${String(r)} dependencies...`)};h||o.info(`Checking ${String(E)} catalog dependencies against npm registry...
3
- `);const M=G(i?.security?.socket),{failed:$,outdated:s}=await ne(w,z,U,B,d,M,i?.security?.socket?.acceptedRisks);if(u&&(u.clear(),u.unmount()),$.length>0&&o.warn(`Failed to fetch: ${$.join(", ")}`),s.length===0){o.info("All catalog dependencies are up to date.");return}const k=e.format??l.format??"table",P=Q(e.aiType??"impact"),p=e.ai?await X(s,o,i?.ai,P):void 0;if(h&&k==="table"){const t=new ee(s,p??null),r=i?.tui?.autoExit??!1,x=r===!0?3:typeof r=="number"?r:0;await b(a.createElement(te,{autoExitSeconds:x,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const L=process.stdout.columns||80;process.stdout.write(`
4
- `);for(const n of s){const Y=n.vulnerabilities?.length||n.socketReport&&n.socketReport.alerts.length>0,T=!!n.acceptedRisk,A=Y?T?"✓":"⚠":"✓",D=T?"gray":n.updateType==="major"?"red":n.updateType==="minor"?"yellow":"green",g=n.socketReport?.score.overall,F=g===void 0?"":` [${String(Math.round(g*100))}%]`,R=g===void 0?void 0:H(g);process.stdout.write(`${V(a.createElement(y,null," ",a.createElement(y,{color:D},A),` ${n.packageName} ${n.currentRange} → ${n.newRange}`,a.createElement(y,{dimColor:!0},` ${n.updateType}`),R?a.createElement(y,{color:R},F):null),{columns:L})}
5
- `)}process.stdout.write(`
6
- `),o.info(N(s))}else if(k==="json"){const t={failed:$,outdated:s};p&&(t.aiAnalysis=p),process.stdout.write(`${JSON.stringify(t,void 0,2)}
7
- `)}else k==="minimal"?process.stdout.write(`${se(s)}
8
- `):(ie(s,o),o.info(N(s)),p&&(o.info(""),o.info(_(p))));e.exitCode&&s.length>0&&(process.exitCode=1)},"execute");export{we as default};
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
- var m=Object.defineProperty;var f=(r,n)=>m(r,"name",{value:n,configurable:!0});import{r as u}from"../packem_shared/toolchain-DQfTQY8E.js";var _=Object.defineProperty,a=f((r,n)=>_(r,"name",{value:n,configurable:!0}),"n");const C=a(()=>process.env.GITHUB_BASE_REF?{base:`origin/${process.env.GITHUB_BASE_REF}`,head:process.env.GITHUB_SHA??"HEAD"}:process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME?{base:`origin/${process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME}`,head:process.env.CI_COMMIT_SHA??"HEAD"}:process.env.CIRCLE_BRANCH&&process.env.CIRCLE_SHA1?{base:"origin/main",head:process.env.CIRCLE_SHA1}:{base:"origin/main",head:"HEAD"},"detectCiRefs"),w=a(async({argument:r,logger:n,options:e,runtime:t,visConfig:d,workspaceRoot:s})=>{const l=r[0];if(!l)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const p=l.split(",").map(o=>o.trim()).filter(Boolean);if(p.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!s)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const{base:E,head:h}=C(),c=e.base??E,g=e.head??h;e.skipToolchain||n.info("▸ Toolchain pre-flight"),await u(s,d?.toolchain,{error:a(o=>{n.error(o)},"error"),info:a(o=>{n.info(o)},"info"),warn:a(o=>{n.warn(o)},"warn")},!!e.skipToolchain),e.install===!1?n.info("▸ Skipping install (--no-install)"):(n.info("▸ Installing dependencies"),await t.runCommand("install",{argv:["--frozen-lockfile"]}));for(const o of p){n.info(`▸ Running affected ${o} (base=${c}, head=${g})`);const i=[o,`--base=${c}`,`--head=${g}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];e.parallel!==void 0&&i.push(`--parallel=${String(e.parallel)}`),e.partition&&i.push(`--partition=${String(e.partition)}`),e.query&&i.push(`--query=${String(e.query)}`),await t.runCommand("affected",{argv:i})}n.info("▸ CI pipeline complete")},"execute");export{w as default};
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
- var a=Object.defineProperty;var d=(s,o)=>a(s,"name",{value:o,configurable:!0});import{createRequire as p}from"node:module";import{isAccessibleSync as k}from"@visulima/fs";import{join as m}from"@visulima/path";import{cleanWorkspace as b}from"#native";import{p as c}from"./bin.js";import{f as R}from"../packem_shared/utils-DrNg0XTR.js";const g=p(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=d(s=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[o,n]=f.versions.node.split(".").map(Number);if(o>22||o===22&&n>=3||o===20&&n>=16)return f.getBuiltinModule(s)}return g(s)},"__cjs_getBuiltinModule"),{readdirSync:v,lstatSync:y,unlinkSync:_}=h("node:fs");var $=Object.defineProperty,u=d((s,o)=>$(s,"name",{value:o,configurable:!0}),"f");const j=u(s=>{const o=[],n=[s];for(;n.length>0;){const t=n.pop();let i;try{i=v(t)}catch{continue}for(const r of i){const e=m(t,r);try{const l=y(e);if(l.isSymbolicLink()||!l.isDirectory())continue}catch{continue}r==="node_modules"?o.push(e):r!==".git"&&r!==".hg"&&n.push(e)}}return o},"findNodeModulesDirectories"),S=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],x=u((s,o,n)=>{let t=0,i=!1;for(const r of S){const e=m(s,r);if(k(e)){if(o){n.info(` ${e}`),t++;continue}try{_(e),c.success(`Removed ${e}`),t++}catch(l){c.error(`${e}: ${R(l)}`),i=!0}}}return{hadError:i,removed:t}},"removeLockfiles"),D=u(async({logger:s,options:o,workspaceRoot:n})=>{const t=n??process.cwd(),i=o.lockfile||!1;if(o.dryRun){const e=j(t);if(e.length>0){c.info("Would remove:");for(const l of e)s.info(` ${l}`)}else c.info("No node_modules directories found.");i&&x(t,!0,s);return}const r=b(t,i);for(const e of r.removed)c.success(`Removed ${e}`);for(const e of r.lockfilesRemoved)c.success(`Removed ${e}`);for(const e of r.errors)c.error(e);r.removed.length===0&&r.lockfilesRemoved.length===0?c.info("No node_modules directories found."):c.info(`Cleaned ${r.removed.length} node_modules director${r.removed.length===1?"y":"ies"}`),r.errors.length>0&&(process.exitCode=1)},"execute");export{D as default};
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 };