@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,214 @@
1
- var m=Object.defineProperty;var d=(r,o)=>m(r,"name",{value:o,configurable:!0});import{createRequire as g}from"node:module";import{writeFileSync as $}from"@visulima/fs";import{join as w}from"@visulima/path";import{r as v}from"./bin.js";const j=g(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=d(r=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[o,e]=a.versions.node.split(".").map(Number);if(o>22||o===22&&e>=3||o===20&&e>=16)return a.getBuiltinModule(r)}return j(r)},"__cjs_getBuiltinModule"),{readFileSync:b}=y("node:fs");var k=Object.defineProperty,f=d((r,o)=>k(r,"name",{value:o,configurable:!0}),"i");const C=f((r,o)=>{const e=o.replace(/^\.?\//,"");return e===""||e==="."?`/${r}/`:r===""||r==="."?`/${e}`:`/${r}/${e}`},"toWorkspacePath"),_=f((r,o)=>{const e=[];for(const[n,t]of Object.entries(o?.globalPaths??{}))e.push({owners:t,path:n});for(const[n,t]of Object.entries(r.projects)){const s=t.owners??[];for(const c of s)e.push({channel:c.channel,owners:c.owners,path:C(t.root??n,c.path),projectId:n})}return(o?.orderBy??"file-source")==="project-id"?e.sort((n,t)=>(n.projectId??"").localeCompare(t.projectId??"")||n.path.localeCompare(t.path)):e.sort((n,t)=>n.path.localeCompare(t.path)),e},"buildCodeownersLines"),E=["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.","# Update each project's project.json `owners` field and re-run the command.",""],O=f((r,o="github")=>{const e=[...E];for(const n of r){const t=n.owners.join(" "),s=n.channel?` # notify: ${n.channel}`:"";e.push(`${n.path} ${t}${s}`)}return e.push(""),e.join(`
2
- `)},"renderCodeowners");var N=Object.defineProperty,R=d((r,o)=>N(r,"name",{value:o,configurable:!0}),"p");const x=R(async({argument:r,logger:o,options:e,visConfig:n,workspaceRoot:t})=>{const s=r[0];if(!s)throw new Error("Missing sync kind. Usage: vis sync <kind> (known kinds: codeowners)");if(!t)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(s!=="codeowners")throw new Error(`Unknown sync kind: "${s}". Known kinds: codeowners.`);const{workspace:c}=v(t,n),p=_(c,n?.codeowners);if(p.length===0){o.info("No `owners` entries found in any project. Nothing to sync.");return}const l=O(p,n?.codeowners?.provider??"github"),i=e.out?w(t,e.out):w(t,"CODEOWNERS");if(e.check){let u="";try{u=b(i,"utf8")}catch(h){if(h.code==="ENOENT")u="";else throw h}if(u.trim()!==l.trim()){o.error(`${i} is out of date. Run \`vis sync codeowners\` to update it.`),process.exitCode=1;return}o.info(`${i} is up to date.`);return}$(i,l),o.info(`Wrote ${p.length} entries to ${i}`)},"execute");export{x 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
+ import { getAffectedProjects } from '@visulima/task-runner';
21
+ import { d as discoverWorkspace, b as buildProjectGraph } from './bin.js';
22
+ const {
23
+ execFile
24
+ } = __cjs_getBuiltinModule("node:child_process");
25
+ const {
26
+ promisify
27
+ } = __cjs_getBuiltinModule("node:util");
28
+
29
+ const execFileAsync = promisify(execFile);
30
+ const SKIP_TOKENS = ["[skip ci]", "[ci skip]", "[no ci]", "[vis skip]", "[nx skip]"];
31
+ const FORCE_TOKENS = ["[vis deploy]", "[nx deploy]"];
32
+ const PER_PROJECT_TOKEN_PREFIXES = ["vis", "nx"];
33
+ const CI_BASE_SHA_ENV_VARS = [
34
+ "CACHED_COMMIT_REF",
35
+ // Netlify
36
+ "VERCEL_GIT_PREVIOUS_SHA",
37
+ // Vercel
38
+ "GITHUB_BASE_REF",
39
+ // GitHub Actions (PRs; ref name, not SHA — validated below)
40
+ "CI_COMMIT_BEFORE_SHA"
41
+ // GitLab CI
42
+ ];
43
+ const GIT_REF_RE = /^[\w./~^@{}][\w.\-/~^@{}]*$/;
44
+ const resolveCiBaseSha = (env = process.env) => {
45
+ for (const name of CI_BASE_SHA_ENV_VARS) {
46
+ const value = env[name];
47
+ if (value && value.trim().length > 0) {
48
+ return value.trim();
49
+ }
50
+ }
51
+ return void 0;
52
+ };
53
+ const validateGitRef = (ref) => {
54
+ if (!GIT_REF_RE.test(ref)) {
55
+ throw new Error(
56
+ `Invalid git ref: "${ref}". Refs must start with an alphanumeric character or one of _ . / ~ ^ @ { } and may only contain letters, digits, dots, dashes, underscores, slashes, tildes, carets, @, and braces.`
57
+ );
58
+ }
59
+ };
60
+ const isRefReachable = async (cwd, ref) => {
61
+ try {
62
+ await execFileAsync("git", ["rev-parse", "--verify", `${ref}^{commit}`], { cwd });
63
+ return true;
64
+ } catch {
65
+ return false;
66
+ }
67
+ };
68
+ const readLastCommitMessage = async (cwd) => {
69
+ try {
70
+ const { stdout } = await execFileAsync("git", ["log", "-1", "--pretty=%B"], { cwd });
71
+ return stdout;
72
+ } catch {
73
+ return "";
74
+ }
75
+ };
76
+ const matchesPerProjectToken = (message, verb, project) => PER_PROJECT_TOKEN_PREFIXES.some((prefix) => message.includes(`[${prefix} ${verb} ${project}]`));
77
+ const commitHasSkipMessage = (message, project) => SKIP_TOKENS.some((token) => message.includes(token)) || matchesPerProjectToken(message, "skip", project);
78
+ const commitHasForceDeployMessage = (message, project) => FORCE_TOKENS.some((token) => message.includes(token)) || matchesPerProjectToken(message, "deploy", project);
79
+ const decideBuild = (project, reason, message, extra) => {
80
+ return {
81
+ action: "build",
82
+ message,
83
+ project,
84
+ reason,
85
+ ...extra
86
+ };
87
+ };
88
+ const decideSkip = (project, reason, message, extra) => {
89
+ return {
90
+ action: "skip",
91
+ message,
92
+ project,
93
+ reason,
94
+ ...extra
95
+ };
96
+ };
97
+ const formatDecisionLine = (decision) => {
98
+ const prefix = decision.action === "skip" ? "🛑" : "✅";
99
+ return `${prefix} ${decision.message}`;
100
+ };
101
+ const exitCodeFor = (decision, exitZeroOnBuild) => {
102
+ if (decision.action === "skip") {
103
+ return 0;
104
+ }
105
+ return exitZeroOnBuild ? 0 : 1;
106
+ };
107
+
108
+ const VALID_SCOPES = /* @__PURE__ */ new Set(["deep", "direct", "none"]);
109
+ const execute = async ({ argument, logger, options, visConfig, workspaceRoot }) => {
110
+ const project = argument[0] ?? "";
111
+ const isJson = Boolean(options.json);
112
+ const isVerbose = Boolean(options.verbose);
113
+ const exitZeroOnBuild = Boolean(options["exit-zero-on-build"] ?? options.exitZeroOnBuild);
114
+ const debug = (message) => {
115
+ if (isVerbose && !isJson) {
116
+ logger.info(`❱ ${message}`);
117
+ }
118
+ };
119
+ const emit = (decision) => {
120
+ if (isJson) {
121
+ process.stdout.write(`${JSON.stringify(decision)}
122
+ `);
123
+ } else {
124
+ logger.info(formatDecisionLine(decision));
125
+ }
126
+ process.exit(exitCodeFor(decision, exitZeroOnBuild));
127
+ };
128
+ if (!project) {
129
+ return emit(decideBuild("", "missing-project-argument", "Missing project argument. Usage: vis ignore <project>"));
130
+ }
131
+ if (!workspaceRoot) {
132
+ return emit(decideBuild(project, "workspace-error", "Could not determine workspace root — building defensively"));
133
+ }
134
+ const commitMessage = await readLastCommitMessage(workspaceRoot);
135
+ const commitSubject = commitMessage.trim().split("\n")[0] ?? "";
136
+ debug(`commit: ${commitSubject}`);
137
+ if (commitMessage && commitHasForceDeployMessage(commitMessage, project)) {
138
+ return emit(decideBuild(project, "commit-force-deploy", `Force-deploy keyword in commit: "${commitSubject}"`));
139
+ }
140
+ if (commitMessage && commitHasSkipMessage(commitMessage, project)) {
141
+ return emit(decideSkip(project, "commit-skip", `Skip keyword in commit: "${commitSubject}"`));
142
+ }
143
+ let workspace;
144
+ let packageJsons;
145
+ try {
146
+ ({ packageJsons, workspace } = discoverWorkspace(workspaceRoot, visConfig));
147
+ } catch (error) {
148
+ const message = error instanceof Error ? error.message : String(error);
149
+ return emit(decideBuild(project, "workspace-error", `Workspace discovery failed (${message}) — building defensively`));
150
+ }
151
+ if (!Object.hasOwn(workspace.projects, project)) {
152
+ return emit(decideBuild(project, "project-unknown", `Project "${project}" not found in workspace — building defensively`));
153
+ }
154
+ try {
155
+ const explicitBase = options.base?.trim();
156
+ const ciBase = resolveCiBaseSha();
157
+ let baseRef = explicitBase || ciBase || "HEAD~1";
158
+ const headRef = options.head?.trim() || "HEAD";
159
+ validateGitRef(baseRef);
160
+ validateGitRef(headRef);
161
+ debug(`resolved base ref: ${baseRef} (source: ${explicitBase ? "flag" : ciBase ? "ci-env" : "default"})`);
162
+ const reachablePromise = isRefReachable(workspaceRoot, baseRef);
163
+ const projectGraph = buildProjectGraph(workspaceRoot, workspace, packageJsons);
164
+ if (!await reachablePromise) {
165
+ debug(`base ref ${baseRef} not reachable — falling back to HEAD~1`);
166
+ baseRef = "HEAD~1";
167
+ }
168
+ debug(`comparing ${baseRef}...${headRef}`);
169
+ const downstream = options.downstream ?? "deep";
170
+ const upstream = options.upstream ?? "none";
171
+ if (!VALID_SCOPES.has(downstream)) {
172
+ throw new Error(`Invalid --downstream value: "${downstream}". Must be "none", "direct", or "deep".`);
173
+ }
174
+ if (!VALID_SCOPES.has(upstream)) {
175
+ throw new Error(`Invalid --upstream value: "${upstream}". Must be "none", "direct", or "deep".`);
176
+ }
177
+ const affectedOptions = {
178
+ base: baseRef,
179
+ downstream,
180
+ head: headRef,
181
+ projectGraph,
182
+ projects: workspace.projects,
183
+ upstream,
184
+ workspaceRoot
185
+ };
186
+ const result = await getAffectedProjects(affectedOptions);
187
+ debug(`changed files: ${result.changedFiles.length}`);
188
+ debug(`affected projects: ${result.affectedProjects.join(", ") || "(none)"}`);
189
+ const refs = { base: baseRef, head: headRef };
190
+ if (result.changedFiles.length === 0) {
191
+ return emit(decideSkip(project, "no-changes", `No files changed between ${baseRef}...${headRef}`, { ...refs, affectedProjects: [] }));
192
+ }
193
+ if (result.affectedProjects.includes(project)) {
194
+ return emit(
195
+ decideBuild(project, "project-affected", `Build ${project}: affected by ${result.changedFiles.length} changed file(s)`, {
196
+ ...refs,
197
+ affectedProjects: result.affectedProjects
198
+ })
199
+ );
200
+ }
201
+ return emit(
202
+ decideSkip(project, "project-not-affected", `Skip ${project}: not affected by changes between ${baseRef}...${headRef}`, {
203
+ ...refs,
204
+ affectedProjects: result.affectedProjects
205
+ })
206
+ );
207
+ } catch (error) {
208
+ const errorMessage = error instanceof Error ? error.message : String(error);
209
+ logger.error(`Affected detection failed: ${errorMessage}`);
210
+ return emit(decideBuild(project, "workspace-error", `Affected detection failed (${errorMessage}) — building defensively`));
211
+ }
212
+ };
213
+
214
+ export { execute as default };
@@ -1,24 +1,119 @@
1
- var ue=Object.defineProperty;var M=(e,t)=>ue(e,"name",{value:t,configurable:!0});import{createRequire as de}from"node:module";import{yellow as D,red as fe}from"@visulima/colorize";import{isAccessibleSync as G,readJsonSync as he}from"@visulima/fs";import{readYamlSync as $e}from"@visulima/fs/yaml";import{findPackageManagerSync as ke,getPackageManagerVersion as ve}from"@visulima/package";import{join as H}from"@visulima/path";import{render as K,renderToString as W,Text as b}from"@visulima/tui";import{k as we,V as ye,B as be,d as Se,J as Re}from"./bin.js";import $ from"react";import{z as Ce,e as Ae,Z as Q}from"../packem_shared/ai-analysis-CGuy7dfE.js";import{r as Ee,s as Te}from"../packem_shared/typosquats-DOR8izpX.js";import{U as xe,B as je,f as X}from"../packem_shared/VisUpdateApp-D-L4_-Iu.js";import{N as A,C as Ue,O as Ne,T as _e,v as re,V as Be,L as ae,o as Oe,a as qe,w as Me,c as Pe,E as Fe,S as Ve,s as ze}from"../packem_shared/catalog-BVPerCwG.js";import{d as Ye}from"../packem_shared/utils-DrNg0XTR.js";const ge=de(import.meta.url),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,me=M(e=>{if(typeof _<"u"&&_.versions&&_.versions.node){const[t,n]=_.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return _.getBuiltinModule(e)}return ge(e)},"__cjs_getBuiltinModule"),{execSync:oe}=me("node:child_process");var Le=Object.defineProperty,E=M((e,t)=>Le(e,"name",{value:t,configurable:!0}),"s");const We=E(e=>{const t=[];for(const n of e.filters)t.push("--filter",n);return e.workspaceRoot&&t.push("--filter","."),t.push("update"),e.latest&&t.push("--latest"),e.recursive&&t.push("--recursive"),e.interactive&&t.push("--interactive"),e.dev&&t.push("--dev"),e.prod&&t.push("--prod"),e.noOptional&&t.push("--no-optional"),e.noSave&&t.push("--no-save"),t.push(...e.packages),{args:t,bin:"pnpm"}},"resolvePnpm"),De=E(e=>{const t=[];return e.filters.length>0&&t.push("workspace",e.filters[0]),t.push("upgrade"),e.latest&&t.push("--latest"),t.push(...e.packages),{args:t,bin:"yarn"}},"resolveYarnV1"),Ie=E(e=>{const t=[];if(e.filters.length>0||e.recursive){t.push("workspaces","foreach","--all");for(const n of e.filters)t.push("--include",n)}return t.push("up"),e.interactive&&t.push("--interactive"),t.push(...e.packages),{args:t,bin:"yarn"}},"resolveYarnBerry"),Je=E((e,t)=>{const n=["update"];e.latest&&t.push("npm does not support --latest flag. Packages will be updated within their semver range."),e.interactive&&t.push("npm does not support --interactive mode.");for(const o of e.filters)n.push("--workspace",o);return e.recursive&&n.push("--workspaces"),e.workspaceRoot&&n.push("--include-workspace-root"),e.dev&&n.push("--dev"),e.prod&&n.push("--production"),e.noOptional&&n.push("--no-optional"),e.noSave&&n.push("--no-save"),n.push(...e.packages),{args:n,bin:"npm"}},"resolveNpm"),Ze=E(e=>{const t=["update"];e.latest&&t.push("--latest");for(const n of e.filters)t.push("--filter",n);return t.push(...e.packages),{args:t,bin:"bun"}},"resolveBun"),Ge=E((e,t,n)=>{const o=[];if(n.global&&e!=="aube")return{command:{args:["update","--global",...n.packages],bin:"npm"},warnings:o};let l;switch(e){case"aube":{const r=we(n);l={args:r.args,bin:r.bin},o.push(...r.warnings);break}case"bun":{l=Ze(n);break}case"npm":{l=Je(n,o);break}case"pnpm":{l=We(n);break}case"yarn":{l=t.startsWith("1.")?De(n):Ie(n);break}default:{const r=e;throw new Error(`Unsupported package manager: ${String(r)}`)}}return{command:l,warnings:o}},"resolveUpdateCommand");var He=Object.defineProperty,S=M((e,t)=>He(e,"name",{value:t,configurable:!0}),"w");const Ke=S((e,t)=>{try{if(t==="pnpm"){const n=H(e,"pnpm-workspace.yaml");if(G(n)){const o=$e(n);if(typeof o?.minimumReleaseAge=="number")return o.minimumReleaseAge}}else if(t==="bun"){const n=H(e,"package.json");if(G(n)){const o=he(n);if(typeof o.minimumReleaseAge=="number")return o.minimumReleaseAge}}}catch{}},"readPmNativeMinimumReleaseAge"),Qe=S((e,t,n)=>{const o=e.latest?"latest":e.target??t.target??"latest";if(!["latest","minor","patch"].includes(o))throw new Error(`Invalid target "${o}". Use: latest, minor, or patch.`);return{exclude:[...A(e.exclude),...A(t.exclude)],ignore:A(t.ignore),include:[...A(e.include),...A(t.include),...n],includeLocked:e.includeLocked||t.includeLocked||!1,includePrerelease:e.prerelease||t.prerelease||!1,minimumReleaseAge:t.minimumReleaseAge,minimumReleaseAgeExclude:t.minimumReleaseAgeExclude,packageMode:t.packageMode,security:e.security||e.ai||t.security||!1,target:o}},"buildCatalogCheckOptions"),ee=S((e,t)=>{if(e.length!==0){t.info(`
2
- ${D("⚠")} ${String(e.length)} package${e.length===1?"":"s"} skipped by target constraint (use --target latest to include):`);for(const n of e)t.info(` ${n.packageName} ${n.currentRange} → ${n.newRange} (${n.updateType})`)}},"logFilteredByTarget"),te=S((e,t,n,o)=>{n==="json"?process.stdout.write(`${Ue({checkedCount:0,failed:t,filteredByTarget:[],ignored:[],outdated:e})}
3
- `):n==="minimal"?process.stdout.write(`${Ne(e)}
4
- `):(_e(e,o),o.info(re(e)))},"writeFormattedOutput"),ne=S(async(e,t,n,o,l)=>{const r=Be(e,n,t),s=t==="pnpm"?"pnpm-workspace.yaml":"package.json";if(l.info(`
5
- Updated ${s}`),r&&l.info(`Backup saved to ${r}`),o.changelog){l.info(`
6
- Fetching changelogs...`);const u=await ae(n);for(const c of u){const f=c.releaseUrl??c.repoUrl??c.npmUrl;l.info(` ${c.packageName}: ${f}`)}}if(o.install??!0){const u={bun:"bun install",npm:"npm install",pnpm:"pnpm install",yarn:"yarn install"}[t]??`${t} install`;l.info(`Running ${u}...
7
- `);try{oe(u,{cwd:e,env:process.env,stdio:"inherit"})}catch{l.warn(`${u} failed. You may need to run it manually.`)}}},"applyCatalogAndInstall"),Xe=S(async(e,t,n,o,l,r)=>{const s=n.update??{},u=[["global","--global is not supported in catalog mode"],["recursive","--recursive is not needed in catalog mode (catalogs are workspace-level)"],["filter","--filter is not supported in catalog mode (use --include/--exclude instead)"],["no-save","--no-save is not supported in catalog mode"],["workspace-root","--workspace-root is not needed in catalog mode"],["no-optional","--no-optional is not supported in catalog mode"]];for(const[a,h]of u)o[a]&&r.warn(`${D("⚠")} ${h}, ignoring.`);const c=Ke(e,t),f=s.minimumReleaseAge??c;if(s.minimumReleaseAge!==void 0&&c!==void 0&&s.minimumReleaseAge!==c){const a=t==="pnpm"?"pnpm-workspace.yaml":"package.json";r.warn(`${D("⚠")} minimumReleaseAge mismatch: vis config = ${String(s.minimumReleaseAge)} min, ${a} = ${String(c)} min. Consider keeping them in sync.`)}const w=Oe(e),p=qe(e,t,{depFields:s.depFields,dev:o.dev,prod:o.prod});if(p.size===0){r.info("No catalogs found.");return}const B={...s,minimumReleaseAge:f},T=Qe(o,B,l);let P=0;for(const a of p.values())P+=a.size;const O=!!process.stdout.isTTY&&!Se;let C;const se=O?(a,h)=>{C?C.rerender($.createElement(X,{current:a,total:h})):C=K($.createElement(X,{current:a,total:h}),{interactive:!0,patchConsole:!1})}:(a,h)=>{r.info(`Checking ${String(a)}/${String(h)} dependencies...`)};O||r.info(`Checking ${String(P)} catalog dependencies...
8
- `);const ie=ye(n.security?.socket),{checkedCount:k,failed:v,filteredByTarget:g,ignored:x,outdated:d}=await Me(p,T,w,se,e,ie,n.security?.socket?.acceptedRisks);C&&(C.clear(),C.unmount());const I=k-d.length-v.length;if(v.length>0&&r.warn(`Failed to fetch: ${v.join(", ")}`),x.length>0&&r.info(`Skipped ${String(x.length)} ignored package${x.length===1?"":"s"}: ${x.join(", ")}`),!O&&k>d.length){const a=[...p.values()].reduce((N,V)=>N+V.size,0),h=a>k?` (${String(a)} catalog entries, ${String(a-k)} duplicates)`:"";r.info(`Checked ${String(k)} unique packages${h}: ${String(d.length)} outdated, ${String(I)} up-to-date${v.length>0?`, ${String(v.length)} failed`:""}${g.length>0?`, ${String(g.length)} skipped by target`:""}`)}if(d.length===0){g.length>0?r.info(`All catalog dependencies are up to date within the current target.
9
- ${String(g.length)} package${g.length===1?" has":"s have"} newer versions available with --target latest:
10
- ${g.map(a=>` ${a.packageName} ${a.currentRange} → ${a.newRange} (${a.updateType})`).join(`
11
- `)}`):r.info("All catalog dependencies are up to date.");return}const j=o.format??s.format??"table";let y;if(o.ai){const a=Ce(o.aiType??"impact");y=await Ae(d,r,n.ai,a)}const F=!!o.dryRun;if(O&&j==="table"){const a=new xe(d,y??null);let h;if(o.changelog){r.info("Fetching changelogs...");const i=await ae(d);h=new Map;for(const m of i){const R=m.releaseUrl??m.repoUrl??m.npmUrl;R&&h.set(m.packageName,R)}}const N=n.tui?.autoExit??!1,V=N===!0?3:typeof N=="number"?N:0,J=await K($.createElement(je,{autoExitSeconds:V,changelogUrls:h,checkedCount:k,filteredOutEntries:g,isDryRun:F,store:a,totalCatalogEntries:P}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),z=process.stdout.columns||80;process.stdout.write(`
12
- `);for(const i of d){const m=i.vulnerabilities?.length||i.socketReport&&i.socketReport.alerts.length>0,R=!!i.acceptedRisk,L=m?R?"✓":"⚠":"✓",ce=R?"gray":i.updateType==="major"?"red":i.updateType==="minor"?"yellow":"green",q=i.socketReport?.score.overall,pe=q===void 0?"":` [${String(Math.round(q*100))}%]`,Z=q===void 0?void 0:be(q);process.stdout.write(`${W($.createElement(b,null," ",$.createElement(b,{color:ce},L),` ${i.packageName} ${i.currentRange} ${i.newRange}`,$.createElement(b,{dimColor:!0},` ${i.updateType}`),Z?$.createElement(b,{color:Z},pe):null),{columns:z})}
13
- `)}if(process.stdout.write(`
14
- `),r.info(re(d)),k>d.length){const i=[...p.values()].reduce((R,L)=>R+L.size,0),m=i>k?` (${String(i)} catalog entries, ${String(i-k)} duplicates)`:"";r.info(` Checked ${String(k)} unique packages${m}: ${String(I)} up-to-date${v.length>0?`, ${String(v.length)} failed`:""}`)}if(g.length>0){process.stdout.write(`
15
- `);const i=`${String(g.length)} package${g.length===1?"":"s"} skipped by target constraint (use --target latest to include):`;process.stdout.write(`${W($.createElement(b,{color:"yellow"},` ${i}`),{columns:z})}
16
- `);for(const m of g)process.stdout.write(`${W($.createElement(b,null," ",$.createElement(b,{dimColor:!0},m.packageName),` ${m.currentRange} → ${m.newRange}`,$.createElement(b,{dimColor:!0},` ${m.updateType}`)),{columns:z})}
17
- `)}const Y=Array.isArray(J)?J:[];if(Y.length>0&&!F){r.info(`
18
- Applying ${String(Y.length)} updates...
19
- `);const i={...o,install:o.install??s.install};await ne(e,t,Y,i,r)}return}if(F){if(j==="json"){const a={failed:v,filteredByTarget:g,ignored:x,outdated:d};y&&(a.aiAnalysis=y),process.stdout.write(`${JSON.stringify(a,void 0,2)}
20
- `)}else r.info(`Would update ${String(d.length)} dependencies:
21
- `),te(d,v,j,r),y&&(r.info(""),r.info(Q(y))),ee(g,r);return}y&&j!=="json"&&(r.info(Q(y)),r.info(""));let U=d;if(o.interactive&&(U=await Pe(d),U.length===0)){r.info("No updates selected.");return}r.info(`Updating ${String(U.length)} catalog dependencies...
22
- `),te(U,[],j,r),ee(g,r);const le={...o,install:o.install??s.install};await ne(e,t,U,le,r)},"executeCatalogUpdate"),et=S((e,t,n,o,l,r)=>{const s={dev:o.dev,filters:A(o.filter),global:o.global,interactive:o.interactive,latest:o.latest||o.target==="latest",noOptional:o.noOptional,noSave:o.noSave,packages:l,prod:o.prod,recursive:o.recursive,workspaceRoot:o.workspaceRoot},{command:u,warnings:c}=Ge(t,n,s);for(const w of c)r.warn(w);const f=`${u.bin} ${u.args.join(" ")}`.trim();if(o.dryRun){r.info(`Would run: ${f}`);return}r.info(`Running: ${f}`);try{oe(f,{cwd:e,env:process.env,stdio:"inherit"})}catch(w){const p=w.status??1;r.error(`
23
- ${fe("✖")} Update failed (exit code ${String(p)})`),r.error(` Command: ${f}`),r.error(` Directory: ${e}
24
- `),process.exitCode=p}},"executePmWrapper"),ht=S(async({argument:e,logger:t,options:n,visConfig:o,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");let r=e;const s=l,{packageManager:u}=ke(s);if(!n.noTyposquatCheck){if(r.length>0){const c=r.map(p=>Ye(p)),f=o?.security?.typosquatAllowlist,w=await Ee(c.map(p=>p.name),f);if(!w.ok){process.exitCode=1;return}r=c.map((p,B)=>{const T=w.packages[B];return T!==p.name?p.versionSpec?`${T}@${p.versionSpec}`:T??"":r[B]??""})}else if(!await Te(s,o?.security?.typosquatAllowlist)){process.exitCode=1;return}}if(n.rollback){if(!Fe(s,u)){t.info("No backup found. Run 'vis update' first to create a backup.");return}if(Ve(s,u))t.info("Restored from backup.");else throw new Error("Failed to restore from backup.");return}if(!n.noCatalog&&ze(s,u))await Xe(s,u,o??{},n,r,t);else{const c=Re(s,{configBackend:o?.install?.backend}),f=c.name==="aube"?"":ve(c.name);et(s,c.name,f,n,r,t)}},"execute");export{ht 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
+ readFileSync
22
+ } = __cjs_getBuiltinModule("node:fs");
23
+ import { writeFileSync } from '@visulima/fs';
24
+ import { join } from '@visulima/path';
25
+ import { d as discoverWorkspace } from './bin.js';
26
+
27
+ const toWorkspacePath = (projectRoot, entryPath) => {
28
+ const trimmed = entryPath.replace(/^\.?\//, "");
29
+ if (trimmed === "" || trimmed === ".") {
30
+ return `/${projectRoot}/`;
31
+ }
32
+ if (projectRoot === "" || projectRoot === ".") {
33
+ return `/${trimmed}`;
34
+ }
35
+ return `/${projectRoot}/${trimmed}`;
36
+ };
37
+ const buildCodeownersLines = (workspace, config) => {
38
+ const lines = [];
39
+ for (const [globalPath, owners] of Object.entries(config?.globalPaths ?? {})) {
40
+ lines.push({ owners, path: globalPath });
41
+ }
42
+ for (const [name, project] of Object.entries(workspace.projects)) {
43
+ const ownersList = project.owners ?? [];
44
+ for (const entry of ownersList) {
45
+ lines.push({
46
+ channel: entry.channel,
47
+ owners: entry.owners,
48
+ path: toWorkspacePath(project.root ?? name, entry.path),
49
+ projectId: name
50
+ });
51
+ }
52
+ }
53
+ const orderBy = config?.orderBy ?? "file-source";
54
+ if (orderBy === "project-id") {
55
+ lines.sort((a, b) => (a.projectId ?? "").localeCompare(b.projectId ?? "") || a.path.localeCompare(b.path));
56
+ } else {
57
+ lines.sort((a, b) => a.path.localeCompare(b.path));
58
+ }
59
+ return lines;
60
+ };
61
+ const HEADER_LINES = [
62
+ "# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.",
63
+ "# Update each project's project.json `owners` field and re-run the command.",
64
+ ""
65
+ ];
66
+ const renderCodeowners = (lines, _provider = "github") => {
67
+ const out = [...HEADER_LINES];
68
+ for (const line of lines) {
69
+ const owners = line.owners.join(" ");
70
+ const channel = line.channel ? ` # notify: ${line.channel}` : "";
71
+ out.push(`${line.path} ${owners}${channel}`);
72
+ }
73
+ out.push("");
74
+ return out.join("\n");
75
+ };
76
+
77
+ const execute = async ({ argument, logger, options, visConfig, workspaceRoot: wsRoot }) => {
78
+ const kind = argument[0];
79
+ if (!kind) {
80
+ throw new Error("Missing sync kind. Usage: vis sync <kind> (known kinds: codeowners)");
81
+ }
82
+ if (!wsRoot) {
83
+ throw new Error("Could not determine workspace root. Run inside a monorepo.");
84
+ }
85
+ if (kind !== "codeowners") {
86
+ throw new Error(`Unknown sync kind: "${kind}". Known kinds: codeowners.`);
87
+ }
88
+ const { workspace } = discoverWorkspace(wsRoot, visConfig);
89
+ const lines = buildCodeownersLines(workspace, visConfig?.codeowners);
90
+ if (lines.length === 0) {
91
+ logger.info("No `owners` entries found in any project. Nothing to sync.");
92
+ return;
93
+ }
94
+ const rendered = renderCodeowners(lines, visConfig?.codeowners?.provider ?? "github");
95
+ const outPath = options.out ? join(wsRoot, options.out) : join(wsRoot, "CODEOWNERS");
96
+ if (options.check) {
97
+ let existing = "";
98
+ try {
99
+ existing = readFileSync(outPath, "utf8");
100
+ } catch (error) {
101
+ if (error.code === "ENOENT") {
102
+ existing = "";
103
+ } else {
104
+ throw error;
105
+ }
106
+ }
107
+ if (existing.trim() !== rendered.trim()) {
108
+ logger.error(`${outPath} is out of date. Run \`vis sync codeowners\` to update it.`);
109
+ process.exitCode = 1;
110
+ return;
111
+ }
112
+ logger.info(`${outPath} is up to date.`);
113
+ return;
114
+ }
115
+ writeFileSync(outPath, rendered);
116
+ logger.info(`Wrote ${lines.length} entries to ${outPath}`);
117
+ };
118
+
119
+ export { execute as default };