@visulima/vis 1.0.0-alpha.45 → 1.0.0-alpha.46

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 (113) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/packem_chunks/CONFIG_FILES.js +3 -3
  5. package/dist/packem_chunks/agent-instructions.js +11 -0
  6. package/dist/packem_chunks/bloom-status.js +1 -1
  7. package/dist/packem_chunks/bloom-sync.js +1 -1
  8. package/dist/packem_chunks/catalog.js +1 -1
  9. package/dist/packem_chunks/cli-exec.js +1 -1
  10. package/dist/packem_chunks/cli-main.js +23 -23
  11. package/dist/packem_chunks/defineReleasePlugin.js +3 -0
  12. package/dist/packem_chunks/fix.js +1 -1
  13. package/dist/packem_chunks/group-tags.js +1 -0
  14. package/dist/packem_chunks/handler10.js +1 -1
  15. package/dist/packem_chunks/handler12.js +1 -1
  16. package/dist/packem_chunks/handler13.js +1 -1
  17. package/dist/packem_chunks/handler14.js +1 -1
  18. package/dist/packem_chunks/handler15.js +1 -1
  19. package/dist/packem_chunks/handler19.js +1 -1
  20. package/dist/packem_chunks/handler20.js +1 -1
  21. package/dist/packem_chunks/handler21.js +1 -1
  22. package/dist/packem_chunks/handler24.js +1 -1
  23. package/dist/packem_chunks/handler26.js +1 -1
  24. package/dist/packem_chunks/handler28.js +1 -1
  25. package/dist/packem_chunks/handler32.js +1 -1
  26. package/dist/packem_chunks/handler4.js +1 -1
  27. package/dist/packem_chunks/handler40.js +19 -19
  28. package/dist/packem_chunks/handler5.js +1 -1
  29. package/dist/packem_chunks/handler50.js +1 -1
  30. package/dist/packem_chunks/handler51.js +1 -1
  31. package/dist/packem_chunks/handler54.js +1 -1
  32. package/dist/packem_chunks/handler57.js +11 -5
  33. package/dist/packem_chunks/handler58.js +5 -11
  34. package/dist/packem_chunks/handler59.js +11 -3
  35. package/dist/packem_chunks/handler6.js +1 -1
  36. package/dist/packem_chunks/handler60.js +3 -22
  37. package/dist/packem_chunks/handler61.js +21 -60
  38. package/dist/packem_chunks/handler62.js +61 -3
  39. package/dist/packem_chunks/handler63.js +3 -6
  40. package/dist/packem_chunks/handler64.js +6 -9
  41. package/dist/packem_chunks/handler65.js +9 -2
  42. package/dist/packem_chunks/handler66.js +2 -24
  43. package/dist/packem_chunks/handler67.js +24 -25
  44. package/dist/packem_chunks/handler68.js +25 -153
  45. package/dist/packem_chunks/handler69.js +153 -10
  46. package/dist/packem_chunks/handler7.js +1 -1
  47. package/dist/packem_chunks/handler70.js +10 -23
  48. package/dist/packem_chunks/handler71.js +23 -322
  49. package/dist/packem_chunks/handler72.js +273 -659
  50. package/dist/packem_chunks/handler73.js +708 -48
  51. package/dist/packem_chunks/handler74.js +48 -27
  52. package/dist/packem_chunks/handler75.js +27 -3
  53. package/dist/packem_chunks/handler76.js +3 -190
  54. package/dist/packem_chunks/handler77.js +189 -37
  55. package/dist/packem_chunks/handler78.js +38 -0
  56. package/dist/packem_chunks/heal.js +1 -1
  57. package/dist/packem_chunks/help-command.js +1 -1
  58. package/dist/packem_chunks/index3.js +1 -1
  59. package/dist/packem_chunks/keys-refresh.js +1 -1
  60. package/dist/packem_chunks/list.js +1 -1
  61. package/dist/packem_chunks/orchestrator.js +26 -23
  62. package/dist/packem_chunks/prune.js +1 -1
  63. package/dist/packem_chunks/state.js +3 -3
  64. package/dist/packem_chunks/status.js +1 -1
  65. package/dist/packem_chunks/sync.js +1 -1
  66. package/dist/packem_chunks/sync2.js +1 -1
  67. package/dist/packem_chunks/tripwire.js +1 -1
  68. package/dist/packem_chunks/verify-lockfile.js +1 -1
  69. package/dist/packem_shared/ReleaseClient-BY4OZNCK.js +1 -0
  70. package/dist/packem_shared/{Table-BGIHvenQ-D2oJtNQj.js → Table-CcVkyULl-DLWu6XHL.js} +1 -1
  71. package/dist/packem_shared/{advisories-CefYKEPe.js → advisories-B76fBVL-.js} +1 -1
  72. package/dist/packem_shared/{ai-analysis-rC48NLfB.js → ai-analysis-DF_AfeS3.js} +1 -1
  73. package/dist/packem_shared/{ai-fix-D_ijV3Rn.js → ai-fix-D1bFLkfk.js} +1 -1
  74. package/dist/packem_shared/{bin-CPMo34SM.js → bin-BlGVEhl8.js} +1 -1
  75. package/dist/packem_shared/{build-scripts-MTSK6TNr.js → build-scripts-q__dKE2y.js} +1 -1
  76. package/dist/packem_shared/{cyclonedx-BeUmPgfO.js → cyclonedx-CmrYQ0vx.js} +1 -1
  77. package/dist/packem_shared/{docker-CViFYtmM.js → docker-BYqiD711.js} +1 -1
  78. package/dist/packem_shared/{env-Ct3hMEYB.js → env-DJlbJiFh.js} +1 -1
  79. package/dist/packem_shared/{failure-log-Dy2G-rKi.js → failure-log-Bt7sW4p7.js} +1 -1
  80. package/dist/packem_shared/{index-XAb0QGqA.js → index-C6tpgeIV.js} +2 -2
  81. package/dist/packem_shared/{index-Cntyu-w8.js → index-D6fJJDli.js} +1 -1
  82. package/dist/packem_shared/{lifecycle-CHcFuWf_.js → lifecycle-XeMei1ED.js} +1 -1
  83. package/dist/packem_shared/{manifests-WBnsV_Eb.js → manifests-DSBr3-dw.js} +1 -1
  84. package/dist/packem_shared/{native-config-sync-BFDVK9LH.js → native-config-sync-D-z2Uwqu.js} +1 -1
  85. package/dist/packem_shared/{osv-bloom-DVMlkcAO.js → osv-bloom-DMhXP184.js} +1 -1
  86. package/dist/packem_shared/{packument-C-A3Uhhx.js → packument-CY2QDFml.js} +1 -1
  87. package/dist/packem_shared/plugins.d-ND23R9I3.d.ts +4 -0
  88. package/dist/packem_shared/{provenance-R2csDSNg.js → provenance-DVHiWZrW.js} +1 -1
  89. package/dist/packem_shared/{registry-keys-CMnS_Qt_.js → registry-keys-BKEq72qX.js} +1 -1
  90. package/dist/packem_shared/{resolve-explicit-C4oQMyoB.js → resolve-explicit-UtkNrGKq.js} +1 -1
  91. package/dist/packem_shared/{runtime-check-BXehSP06.js → runtime-check-qnrPTlma.js} +1 -1
  92. package/dist/packem_shared/{s1ngularity-BCDt28u0.js → s1ngularity-DUZtU95L.js} +1 -1
  93. package/dist/packem_shared/{scan-progress-YRpDs90j.js → scan-progress-BgtHexnt.js} +1 -1
  94. package/dist/packem_shared/{signatures-B3srzCEv.js → signatures-QoCuUv9E.js} +1 -1
  95. package/dist/packem_shared/target-merge-Dg25Izl5.js +11 -0
  96. package/dist/packem_shared/{toolchain-C44mPKPu.js → toolchain-Zb3VzZb4.js} +1 -1
  97. package/dist/packem_shared/{typosquats-CQz-1Y6K.js → typosquats-C12CP_2G.js} +1 -1
  98. package/dist/packem_shared/{use-measured-height-DHi0xOPO.js → use-measured-height-BpKmrlkw.js} +1 -1
  99. package/dist/packem_shared/{vis-update-app-B3I14Vfy.js → vis-update-app-BoCQ4ute.js} +1 -1
  100. package/dist/packem_shared/{watch-loop-JfGKIgKB.js → watch-loop-BZudYfcl.js} +1 -1
  101. package/dist/release/index.d.ts +39 -2
  102. package/dist/release/index.js +1 -1
  103. package/dist/release/plugin-sdk.d.ts +2 -1
  104. package/dist/release/plugin-sdk.js +1 -1
  105. package/dist/release/types.d.ts +117 -1
  106. package/dist/release/types.js +1 -1
  107. package/index.js +52 -52
  108. package/package.json +9 -9
  109. package/schemas/vis-config.schema.json +33 -0
  110. package/schemas/vis-release-config.schema.json +33 -0
  111. package/dist/packem_shared/ReleaseClient-YHzBIxYS.js +0 -1
  112. package/dist/packem_shared/target-merge-DOm6h6tW.js +0 -11
  113. /package/dist/packem_shared/{readJsonSync-CvkZyKmL-ihoybKvs.js → readJsonSync-DuMMeB3s-ihoybKvs.js} +0 -0
@@ -1,5 +1,11 @@
1
- import{createRequire as B}from"node:module";import{j as M,m as W,o as F,q as p,s as z,t as G,Y as P,u as Y,x as L,z as H,C as K,E as Q,L as U,F as X,H as Z,G as I,$ as tt}from"./cli-main.js";import{f as k,m as f,v as j,T as O,I as st,J as nt}from"../packem_shared/index-CE6MsgcV.js";import"../packem_shared/public-api-WqUCiyIe.js";import{u as it}from"./ts-loader.js";import{loadVisConfig as rt}from"./CONFIG_FILES.js";import{v as ut}from"../packem_shared/verify-DStfg3nb.js";const J=B(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,V=t=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[o,s]=$.versions.node.split(".").map(Number);if(o>22||o===22&&s>=3||o===20&&s>=16)return $.getBuiltinModule(t)}return J(t)},{readdirSync:ot,statSync:et}=V("node:fs"),{stdin:T,stdout:at}=$,{createInterface:ct}=V("node:readline/promises"),w="__global__",R=t=>[...new Set(t)].sort((o,s)=>o.localeCompare(s)),pt=t=>`{${Object.keys(t).sort().map(o=>`${o}=${JSON.stringify(t[o])}`).join(",")}}`,m=t=>{if(!Array.isArray(t))return[];const o=[];for(const s of t)typeof s=="string"?o.push(s):s&&typeof s=="object"&&o.push(pt(s));return R(o)},y=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),h=(t,o,s)=>s?`^${o}`:t&&t!=="self"&&t!=="~"?`${t}#${o}`:o,ft=(t,o)=>{const s=t.trim();if(o==="moon"){if(s.startsWith("^:"))return h(void 0,s.slice(2),!0);if(s.startsWith("~:"))return h(void 0,s.slice(2),!1);if(s.includes(":")){const[n,e]=s.split(":");return h(n,e??"",!1)}return s}if(s.startsWith("^"))return h(void 0,s.slice(1),!0);if(s.includes("#")){const[n,e]=s.split("#");return h(n,e??"",!1)}return s},C=(t,o)=>{if(!Array.isArray(t))return[];const s=[];for(const n of t){if(typeof n=="string"){s.push(ft(n,o));continue}if(!n||typeof n!="object")continue;const e=n,{target:i}=e;if(!i)continue;if(e.dependencies===!0){s.push(h(void 0,i,!0));continue}if(e.projects===void 0){s.push(h(void 0,i,!1));continue}const r=Array.isArray(e.projects)?e.projects:[e.projects];for(const c of r)s.push(c==="^"?h(void 0,i,!0):h(c,i,!1))}return R(s)},E=t=>{if(k(t))try{return JSON.parse(j(t))}catch{return}},gt=t=>{const o=new Map,s=E(f(t,"turbo.json"));if(!s)return o;const n=s.tasks??s.pipeline??{};for(const[i,r]of Object.entries(n)){const c=i.includes("#")?i:`*#${i}`,a=y(c);a.dependsOn=C(r.dependsOn,"turbo"),a.inputs=m(r.inputs),a.outputs=m(r.outputs),a.env=R([...r.env??[],...r.passThroughEnv??[]]),a.cache=r.cache===!1?!1:void 0,o.set(c,a)}const e=y(w);return e.inputs=m(s.globalDependencies),e.env=R([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(w,e),o},dt=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),S=(t,o,s=8)=>{const n=[],e=(i,r)=>{if(r>s)return;let c;try{c=ot(i)}catch{return}for(const a of c.toSorted()){if(a===o){n.push(f(i,a));continue}if(a.startsWith(".")&&a!==".moon"||dt.has(a))continue;const u=f(i,a);try{et(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),n},N=(t,o)=>{t.dependsOn=C(o.dependsOn,"nx"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.cache=typeof o.cache=="boolean"?o.cache:void 0},lt=t=>{const o=new Map,s=E(f(t,"nx.json"));for(const[n,e]of Object.entries(s?.targetDefaults??{})){const i=`*#${n}`,r=y(i);N(r,e),o.set(i,r)}for(const n of S(t,"project.json")){const e=E(n);if(!(!e?.name||!e.targets))for(const[i,r]of Object.entries(e.targets)){const c=`${e.name}#${i}`,a=y(c);N(a,r),o.set(c,a)}}return o},_=(t,o)=>{t.dependsOn=C(o.deps,"moon"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.cache=typeof o.options?.cache=="boolean"?o.options.cache:void 0},A=t=>{if(k(t))try{return it(t)}catch{return}},vt=t=>{const o=new Map,s=f(t,".moon"),n=[f(s,"tasks.yml"),f(s,"tasks.yaml")];for(const e of n){const i=A(e);if(i){for(const[r,c]of Object.entries(i.tasks??{})){const a=`*#${r}`,u=y(a);_(u,c),o.set(a,u)}if(i.implicitInputs&&i.implicitInputs.length>0){const r=y(w);r.inputs=m(i.implicitInputs),o.set(w,r)}}}for(const e of[...S(t,"moon.yml"),...S(t,"moon.yaml")]){const i=A(e);if(!i?.tasks)continue;const r=e.split(/[/\\]/).at(-2)??"*";for(const[c,a]of Object.entries(i.tasks)){const u=`${r}#${c}`,v=y(u);_(v,a),o.set(u,v)}}return o},mt=(t,o)=>{t.dependsOn=C(o.dependsOn,"vis"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.env=R([...o.env??[],...o.passThroughEnv??[],...o.options?.passThroughEnv??[]]),t.cache=o.cache===!1?!1:typeof o.cache=="boolean"?o.cache:void 0},ht=async t=>{const o=new Map,s=await rt(t);for(const[i,r]of Object.entries(s.tasks??{})){const c=`*#${i}`,a=y(c);mt(a,r??{}),o.set(c,a)}const n=s.taskRunner??{},e=y(w);return e.inputs=m(n.globalInputs),e.env=R([...n.globalEnv??[],...n.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(w,e),o},yt=(t,o)=>{switch(o){case"moon":return vt(t);case"nx":return lt(t);default:return gt(t)}},kt=t=>{const o=[];return k(f(t,"turbo.json"))&&o.push("turbo"),k(f(t,"nx.json"))&&o.push("nx"),(k(f(t,".moon","tasks.yml"))||k(f(t,".moon","tasks.yaml")))&&o.push("moon"),o.length===1?o[0]:void 0},x=(t,o,s,n,e)=>{const i=n.filter(a=>!e.includes(a)),r=e.filter(a=>!n.includes(a));if(i.length===0&&r.length===0)return;const c=[];i.length>0&&c.push(`dropped [${i.join(", ")}]`),r.length>0&&c.push(`added [${r.join(", ")}]`),t.push({axis:s,detail:`${s} diverged: ${c.join("; ")}`,node:o,severity:i.length>0?"error":"warning"})},wt=(t,o,s)=>{const n=[],e=R([...t.keys(),...o.keys()]);for(const i of e){const r=t.get(i),c=o.get(i);if(r&&!c){const a=s==="turbo"&&i.includes("#")&&!i.startsWith("*#")&&i!==w;n.push({axis:"target-set",detail:a?`source target \`${i}\` was skipped by design (turbo project#task is migrated into per-project project.json — move it there and re-verify)`:`source target \`${i}\` has no equivalent in the migrated vis config`,node:i,severity:a?"warning":"error"});continue}if(!r&&c){n.push({axis:"target-set",detail:`migrated vis config defines \`${i}\` with no source equivalent (extra target — not a regression, but review)`,node:i,severity:"warning"});continue}!r||!c||(x(n,i,"dependsOn",r.dependsOn,c.dependsOn),x(n,i,"inputs",r.inputs,c.inputs),x(n,i,"outputs",r.outputs,c.outputs),x(n,i,"env",r.env,c.env),r.cache!==void 0&&c.cache!==void 0&&r.cache!==c.cache&&n.push({axis:"cache",detail:`cache flag diverged: source=${String(r.cache)} vis=${String(c.cache)} (changes what invalidates the cache)`,node:i,severity:"error"}))}return n.sort((i,r)=>i.node.localeCompare(r.node)||i.axis.localeCompare(r.axis)),{findings:n,source:s,sourceNodeCount:t.size,visNodeCount:o.size}},Rt=new Set(["json","ndjson","table"]),$t=t=>({equivalent:t.findings.every(o=>o.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),bt=(t,o,s)=>{if(o==="json"){process.stdout.write(`${JSON.stringify($t(t),void 0,2)}
2
- `);return}if(o==="ndjson"){for(const n of t.findings)process.stdout.write(`${JSON.stringify(n)}
3
- `);return}if(s.info(`Migration equivalence: ${t.source} vis`),s.info(` source nodes: ${String(t.sourceNodeCount)} vis nodes: ${String(t.visNodeCount)}`),t.findings.length===0){s.info(" ✓ task graph + cache-key surface preserved (no divergence).");return}for(const n of t.findings){const e=` [${n.severity}] ${n.node} (${n.axis}) ${n.detail}`;n.severity==="error"?s.warn(e):s.info(e)}},xt=(t,o)=>t.findings.some(s=>o==="warning"?!0:s.severity==="error")?1:0,D=async t=>{if(!T.isTTY)return!0;const o=ct({input:T,output:at});try{const s=(await o.question(`${t} [Y/n] `)).trim().toLowerCase();return s===""||s==="y"||s==="yes"}finally{o.close()}},Ct=[{description:"VisConfig.targetDefaults → VisConfig.tasks",next:"tasks",previous:"targetDefaults"},{description:"VisConfig.taskDefaults → VisConfig.scopedTasks",next:"scopedTasks",previous:"taskDefaults"},{description:"VisConfig.taskRunnerOptions → VisConfig.taskRunner",next:"taskRunner",previous:"taskRunnerOptions"},{description:"ScopedTasksBlock.scope → ScopedTasksBlock.match",next:"match",previous:"scope"},{description:"ScopedTasksBlock.targets → ScopedTasksBlock.tasks",next:"tasks",previous:"targets"}],jt=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],Et=t=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${t}\2(\s*:)`,"gmu"),St=(t,o)=>{let s=t;const n=[];for(const e of o){const i=Et(e.previous);i.test(s)&&(i.lastIndex=0,s=s.replace(i,(r,c,a,u)=>`${c}${a}${e.next}${a}${u}`),n.push(e))}return{applied:n,output:s}},q=(t,o)=>St(t,o),Mt=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],Ot=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),Tt=t=>{for(const o of Mt){const s=f(t,o);if(k(s))return s}},Nt=t=>{const o=[];try{for(const s of st(t,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))Ot.has(nt(s.path))&&o.push(s.path)}catch{}return o},_t=(t,o,s,n)=>{const e=Tt(t);if(e){const r=j(e),{applied:c,output:a}=q(r,Ct);if(c.length===0)s.info(`${e} already uses the current schema — no rewrite needed.`);else if(o.dryRun)s.info(`── ${e} (preview) ──`),s.info(a),s.info("── end preview ──"),s.info(`Would apply ${String(c.length)} rename(s): ${c.map(u=>u.description).join(", ")}`);else{M(e,n),O(e,a),s.info(`Rewrote ${e} (backup at ${e}.bak). Applied ${String(c.length)} rename(s).`);for(const u of c)n.manualSteps.push(`Renamed ${u.description} in ${e}`)}}else s.warn("No vis.config.ts found at workspace root — nothing to migrate."),n.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const i=o.taskConfigPaths??Nt(t);for(const r of i){if(!k(r))continue;const c=j(r),a=q(c,jt);if(a.applied.length!==0)if(o.dryRun)s.info(`── ${r} (preview) ──`),s.info(a.output),s.info("── end preview ──"),s.info(`Would apply ${String(a.applied.length)} rename(s): ${a.applied.map(u=>u.description).join(", ")}`);else{M(r,n),O(r,a.output),s.info(`Rewrote ${r} (backup at ${r}.bak). Applied ${String(a.applied.length)} rename(s).`);for(const u of a.applied)n.manualSteps.push(`Renamed ${u.description} in ${r}`)}}},g=t=>{const o=t.workspaceRoot??process.cwd(),s=t.visConfig??{};return{config:s,dryRun:!!t.options.dryRun,logger:t.logger,packageManager:tt(o),report:I(),root:o,useEditorconfig:typeof s.editorconfig=="boolean"?s.editorconfig:!0}},d=async(t,o,s)=>{if(o.yes||o.dryRun)return!0;const n=await D(`This will edit files, scripts, and hooks for "${t}". Backups (.bak) will be created. Continue?`);return n||s.info("Aborted."),n},l=t=>{t.dryRun&&t.logger.info(`Running in dry-run mode — no changes will be made.
4
- `)},At=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("deps",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating dependencies and scripts ──"),z(e.root,e.packageManager,e.config,{dryRun:e.dryRun},t,e.report),t.info(""),p(e.report,t)},qt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("lint-staged",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating lint-staged ──"),G(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Vt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("nano-staged",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating nano-staged ──"),P(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},It=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("turborepo",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating turborepo ──"),Y(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Dt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("nx",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating nx ──");const i=!!o.aggressive;L(e.root,{aggressive:i,dryRun:e.dryRun,force:i||!!o.force,rewriteSyncGenerators:i||!!o.rewriteSyncGenerators,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Bt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("moon",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating moon ──"),H(e.root,{copyTemplates:!!o.copyTemplates,dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Jt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("gitleaks",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating gitleaks ──"),K(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Wt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("kingfisher",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating Kingfisher ──"),Q(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Ft=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("secretlint",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating secretlint ──"),U(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},zt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("syncpack",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating syncpack ──"),X(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Gt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("sherif",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating sherif ──"),Z(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Pt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("self",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating vis.config.ts to current schema ──"),_t(e.root,{dryRun:e.dryRun},t,e.report),t.info(""),p(e.report,t)},Yt=({logger:t,workspaceRoot:o})=>{const s=o??process.cwd();ut(s,t).length>0&&(process.exitCode=1)},Lt=async({logger:t,options:o,workspaceRoot:s})=>{const n=s??process.cwd(),e=o.format??"table";if(!Rt.has(e)){t.warn(`Invalid --format: ${String(o.format)}. Expected table | json | ndjson.`),process.exitCode=1;return}const i=o.failOn==="warning"?"warning":"error";let r;if(o.from){if(o.from!=="turbo"&&o.from!=="nx"&&o.from!=="moon"){t.warn(`Invalid --from: ${o.from}. Expected turbo | nx | moon.`),process.exitCode=1;return}r=o.from}else if(r=kt(n),!r){t.warn("Could not auto-detect the source tool (need exactly one of turbo.json / nx.json / .moon/tasks.yml). Pass --from <turbo|nx|moon>."),process.exitCode=1;return}const c=yt(n,r);if(c.size===0){t.warn(`No ${r} task graph found at ${n} — nothing to verify.`),process.exitCode=1;return}const a=await ht(n);if(a.size===0){t.warn("No migrated vis task graph found (vis.config.ts has no tasks). Run the migrator first."),process.exitCode=1;return}const u=wt(c,a,r);bt(u,e,t),process.exitCode=xt(u,i)},Ht=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{const e=n??process.cwd(),i=W(e,s??{}),r=F(i);if(r.length===0){t.info("No applicable migrations detected in this workspace.");return}const c=!!o.dryRun;t.info(`Detected ${String(r.length)} migration(s):`);for(const v of r)t.info(` • ${v.title} — ${v.description}`);if(t.info(""),!o.yes&&!c&&!await D("Apply all detected migrations? Backups (.bak) will be created.")){t.info("Aborted.");return}c&&t.info(`Running in dry-run mode — no changes will be made.
5
- `);const a=I(),u=[];for(const v of r)try{if(t.info(`── Applying ${v.title} ──`),c)for(const b of v.probe(i))t.info(b);else v.apply(i,a,t);t.info("")}catch(b){u.push({error:b,id:v.id}),t.warn(`Failed to apply ${v.title}: ${b.message}`)}p(a,t),u.length>0&&(t.warn(""),t.warn(`${String(u.length)} migration(s) failed see messages above.`),process.exitCode=1)},eo=At,so=qt,no=Vt,io=It,ro=Dt,ao=Bt,co=Jt,uo=Wt,po=Ft,fo=zt,go=Gt,lo=Pt,vo=Yt,mo=Lt,ho=Ht;export{ho as migrateAllExecute,eo as migrateDepsExecute,co as migrateGitleaksExecute,uo as migrateKingfisherExecute,so as migrateLintStagedExecute,ao as migrateMoonExecute,no as migrateNanoStagedExecute,ro as migrateNxExecute,po as migrateSecretlintExecute,lo as migrateSelfExecute,go as migrateSherifExecute,fo as migrateSyncpackExecute,io as migrateTurborepoExecute,vo as migrateVerifyExecute,mo as migrateVerifyGraphExecute};
1
+ import{createRequire as I}from"node:module";import{b as U}from"./orchestrator.js";const S=I(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,C=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,r]=b.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return b.getBuiltinModule(e)}return S(e)},{mkdtemp:E,writeFile:P,rm:M,readdir:N,readFile:D}=C("node:fs/promises"),{tmpdir:O}=C("node:os"),{join:v}=C("node:path"),A="https://www.npmjs.com",T=(e,t)=>t&&!/registry\.npmjs\.org/.test(t)?void 0:`${A}/package/${encodeURIComponent(e)}/access`,F=e=>`# ${e}
2
+
3
+ > ⚠️ **Placeholder packagedo not use.**
4
+
5
+ This version contains **no code** and is **not functional**. It was published by [\`vis release pretrust\`](https://visulima.com/packages/vis) only to register the package name on the registry so that **npm Trusted Publishing (OIDC)** can be configured before the first real release.
6
+
7
+ Do **not** add this as a dependency. A functional version will replace it when the package is first released.
8
+ `,q=(e,t,r,n)=>{const i={description:"Placeholder published by `vis release pretrust` to enable npm trusted publishing (OIDC). Not functional — do not use.",files:["README.md"],license:typeof e.manifest.license=="string"?e.manifest.license:"MIT",name:t,publishConfig:{access:n},version:r};return e.manifest.repository!==void 0&&(i.repository=e.manifest.repository),i},B=(e,t)=>{const r=["trust",t.provider,e,"--file",t.workflow];return t.repo&&r.push(t.provider==="gitlab"?"--project":"--repo",t.repo),t.env&&r.push("--env",t.env),r.push("--allow-publish"),t.allowStagePublish&&r.push("--allow-stage-publish"),r.push("-y"),r},_=(e,t)=>{if(e.includes("gitlab"))return{provider:"gitlab",repo:t};if(e.includes("github"))return{provider:"github",repo:t}},L=e=>{const t=e.trim().replace(/\.git$/,"");if(t.startsWith("ssh://"))try{const n=new URL(t);return _(n.hostname,n.pathname.replace(/^\/+/,""))}catch{return}const r=/(?:https?:\/\/|git@)([^/:]+)[/:](\S+)/.exec(t);if(r)return _(r[1]??"",r[2]??"")},W=async(e,t)=>{try{const r=await e.run("git",["config","--get","remote.origin.url"],{cwd:t,silent:!0});return r.exitCode!==0?void 0:L(r.stdout.trim())}catch{return}},H=async(e,t)=>{if(t==="gitlab")return".gitlab-ci.yml";const r=v(e,".github","workflows");let n;try{n=await N(r)}catch{return}const i=n.filter(u=>/\.ya?ml$/.test(u)),l=[];for(const u of i)try{const h=await D(v(r,u),"utf8");/vis\s+release/.test(h)&&/publish/.test(h)&&l.push(u)}catch{}if(l.length===1)return l[0];if(l.length>1)return;const c=i.filter(u=>/release/i.test(u));return c.length===1?c[0]:void 0},J=async(e,t,r,n,i)=>{const l=B(r,n);i&&l.push("--registry",i);try{const c=await e.run("npm",l,{cwd:t,silent:!0});return c.exitCode===0?{trusted:!0}:{reason:`${c.stdout}
9
+ ${c.stderr}`.trim()||`npm trust exited ${c.exitCode}`,trusted:!1}}catch(c){return{reason:c.message,trusted:!1}}},z=async(e,t,r,n)=>{const i=["view",t,"version","--silent"];n&&i.push("--registry",n);try{const l=await e.run("npm",i,{cwd:r,silent:!0});return l.exitCode===0&&l.stdout.trim().length>0}catch{return!1}},G=async e=>{const{context:t,dryRun:r=!1,force:n=!1,registry:i}=e,l=e.access??"public",c=e.tag??"placeholder",u=e.version??"0.0.0",{createShellRunner:h}=await import("./shell-runner.js"),a=e.runner??h();let g=t.packages.filter(o=>!o.private);if(e.filter){const{default:o}=await import("./index.js"),p=e.filter.split(",").map(d=>d.trim()).filter(Boolean);g=g.filter(d=>p.some(w=>d.name===w||o(w,d.name)))}const m=[],s=[],k=[],j=e.trust!==!1&&!r;let x,y;if(j){const o=e.provider&&e.repo?{provider:e.provider,repo:e.repo}:await W(a,t.cwd),p=e.provider??o?.provider;if(p){const d=e.workflow??await H(t.cwd,p);d?x={allowStagePublish:e.allowStagePublish,env:e.env,provider:p,repo:e.repo??o?.repo,workflow:d}:y="could not find a release workflow file (pass --workflow)"}else y="could not detect a github/gitlab remote (pass --provider + --repo)"}for(const o of g){if(!n&&await z(a,o.name,t.cwd,i)){s.push({name:o.name,reason:"already-on-registry"});continue}if(r){m.push({accessUrl:T(o.name,i),name:o.name,version:u});continue}let p;try{p=await E(v(O(),"vis-pretrust-"));const d=q(o,o.name,u,l);await P(v(p,"package.json"),`${JSON.stringify(d,null,2)}
10
+ `),await P(v(p,"README.md"),F(o.name));const w=["publish","--tag",c,"--access",l];i&&w.push("--registry",i);const $=await a.run("npm",w,{cwd:p,silent:!0});if($.exitCode===0){const f={accessUrl:T(o.name,i),name:o.name,version:u};if(x){const R=await J(a,t.cwd,o.name,x,i);f.trusted=R.trusted,R.trusted||(f.trustReason=R.reason)}else y&&(f.trusted=!1,f.trustReason=y);m.push(f)}else{const f=`${$.stdout}
11
+ ${$.stderr}`;/EPUBLISHCONFLICT|cannot publish over|previously published/i.test(f)?s.push({name:o.name,reason:"already-on-registry"}):k.push({name:o.name,reason:f.trim()||`npm publish exited ${$.exitCode}`})}}catch(d){k.push({name:o.name,reason:d.message})}finally{p&&await M(p,{force:!0,recursive:!0}).catch(()=>{})}}return{failed:k,published:m,skipped:s}},V=async({logger:e,options:t,workspaceRoot:r})=>{const n=r??process.cwd(),i=t.dryRun===!0;if(t.access!==void 0&&t.access!=="public"&&t.access!=="restricted"){e.error(`Invalid --access value: "${t.access}". Expected "public" or "restricted".`),process.exitCode=1;return}if(t.provider!==void 0&&t.provider!=="github"&&t.provider!=="gitlab"){e.error(`Invalid --provider value: "${t.provider}". Expected "github" or "gitlab".`),process.exitCode=1;return}const l=t.access??"public",{provider:c}=t,u=await U({cwd:n}),{printConfigIfRequested:h}=await import("./print-config.js");if(h(t,u,e))return;let a;try{a=await G({access:l,allowStagePublish:t.allowStagePublish===!0,context:u,dryRun:i,env:t.env,filter:t.filter,force:t.force===!0,provider:c,registry:t.registry,repo:t.repo,tag:t.tag,trust:t.noTrust!==!0,version:t.version,workflow:t.workflow})}catch(s){e.error(`Pretrust failed: ${s.message}`),process.exitCode=1;return}for(const s of a.published)e.info(` ${i?"[dry-run] ":"[published]"} ${s.name}@${s.version}`),!i&&(s.trusted===!0?e.info(" ✓ trusted publisher configured (npm trust)"):s.trustReason?(e.warn(` ⚠ trust not configured: ${s.trustReason}`),s.accessUrl&&e.info(` finish manually → ${s.accessUrl}`)):s.accessUrl&&e.info(` configure trusted publishing → ${s.accessUrl}`));for(const s of a.skipped)e.info(` [skipped] ${s.name} (${s.reason})`);for(const s of a.failed)e.error(` [failed] ${s.name}: ${s.reason}`);const g=a.published.filter(s=>s.trusted===!0).length,m=a.published.filter(s=>s.trusted===!1).length;e.info(""),e.info(`Placeholders: ${a.published.length} | Trusted: ${g} | Skipped: ${a.skipped.length} | Failed: ${a.failed.length}`),a.published.length>0&&!i&&(e.info(""),m>0?e.info("Next: finish trusted-publisher setup for the packages above (the first `npm trust` call may need a 2FA OTP), then run `vis release publish`."):e.info("Next: run `vis release publish` — trusted publishing is configured.")),process.exitCode=a.failed.length>0?2:0};export{V as default};
@@ -1,11 +1,5 @@
1
- import{createRequire as K}from"node:module";import{j as b,E as m,q as k,I as N,V as U,s as P}from"../packem_shared/index.server-J83sowC4.js";import{m as h,a as J,A,f as W}from"../packem_shared/index-CE6MsgcV.js";import{b as I,O as z}from"./catalog.js";import{d as G}from"../packem_shared/lockfile-C1qCKGH6.js";import{p as X,s as Q}from"../packem_shared/docker-CViFYtmM.js";import{I as ne}from"../packem_shared/index-B0EsgdzO.js";import{g as L}from"../packem_shared/env-Ct3hMEYB.js";const Y=K(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[o,t]=g.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return g.getBuiltinModule(e)}return Y(e)},{createInterface:_}=y("node:readline"),{spawn:Z}=y("node:child_process"),{createHash:ee}=y("node:crypto"),{existsSync:T,writeFileSync:oe,chmodSync:te}=y("node:fs"),D={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},re=e=>{const{focus:o,manager:t,nodeVersion:r}=e,n=D[t]??D.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${o?` --focus=${o}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...n.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",n.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",n.build(o),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
2
- `)},$="v2.14.0",S=`https://github.com/hadolint/hadolint/releases/download/${$}`,se={"hadolint-linux-arm64":"331f1d3511b84a4f1e3d18d52fec284723e4019552f4f47b19322a53ce9a40ed","hadolint-linux-x86_64":"6bf226944684f56c84dd014e8b979d27425c0148f61b3bd99bcc6f39e9dc5a47","hadolint-macos-arm64":"3625e2e9f43dcfe7bd38738a5f5520ed50ce39ed28485266e6803dd7bc197b10","hadolint-macos-x86_64":"2b69a853433f1eca522ffb921cd490bd1321424d03331fd8390f93b7fb4a02e9","hadolint-windows-x86_64.exe":"8e0ee174f88edb14f207a68430c7a53c2883ed509cdbde9a3a26fffa140fa5e4"},ie=e=>se[e],ae=(e=process.platform,o=process.arch)=>{const t=e==="darwin"?"macos":e==="linux"?"linux":e==="win32"?"windows":void 0;if(t===void 0)return;const r=o==="arm64"?"arm64":o==="x64"?"x86_64":void 0;if(t==="windows")return"hadolint-windows-x86_64.exe";if(r!==void 0)return`hadolint-${t}-${r}`},H=e=>h(L(),"hadolint",$,e.endsWith(".exe")?"hadolint.exe":"hadolint"),ce=()=>{const e=process.platform==="win32"?"hadolint.exe":"hadolint",o=(process.env.PATH??"").split(process.platform==="win32"?";":":");for(const t of o)if(t!==""&&T(h(t,e)))return e},le=e=>e.trim().split(/\s+/u)[0]??"",C=async e=>{const o=await fetch(e,{redirect:"follow"});if(!o.ok)throw new Error(`download failed (${String(o.status)} ${o.statusText}) for ${e}`);return Buffer.from(await o.arrayBuffer())},de=async e=>{const o=H(e),t=ie(e),r=await C(`${S}/${e}`),n=ee("sha256").update(r).digest("hex");if(t===void 0){const s=await C(`${S}/${e}.sha256`),i=le(s.toString("utf8")).toLowerCase();if(i==="")throw new Error("hadolint checksum sidecar was empty or unparseable. Refusing to use the download.");if(i!==n)throw new Error(`hadolint checksum mismatch (expected ${i}, got ${n}). Refusing to use the download.`)}else if(t.toLowerCase()!==n)throw new Error(`hadolint checksum mismatch (expected ${t.toLowerCase()}, got ${n}). Refusing to use the download.`);return J(h(L(),"hadolint",$)),oe(o,r),process.platform!=="win32"&&te(o,493),o},ue=async()=>{const e=_({input:process.stdin,output:process.stderr}),o=await new Promise(t=>{e.question(` Download hadolint ${k($)} now? ${m("[y/N]")} `,r=>{t(r.trim().toLowerCase())})});return e.close(),o==="y"||o==="yes"},fe=async e=>{const{autoInstall:o=!1,log:t}=e,r=ce();if(r!==void 0)return r;const n=ae();if(n===void 0){t(`hadolint has no prebuilt binary for ${process.platform}/${process.arch}. Install it manually: https://github.com/hadolint/hadolint`);return}const s=H(n);if(T(s))return s;if(!o){if(!(process.stdin.isTTY&&!ne)){t(`hadolint is not installed. Re-run with ${b("--install")} (or install hadolint on PATH) to enable Dockerfile linting.`);return}if(t(`${b("hadolint")} is required to lint Dockerfiles but was not found on your PATH.`),!await ue()){t(`Skipped. Install it yourself or re-run with ${b("--install")}.`);return}}t(`Downloading hadolint ${$} (${n})…`);try{const i=await de(n);return t(`Installed hadolint to ${m(i)}`),i}catch(i){t(`Failed to download hadolint: ${i.message}`);return}},O=async(e,o,t)=>{if(o.length===0)return[];const r=["--format","json","--no-fail",...t!==void 0&&t!==""?["--config",t]:[],...o],n=await new Promise((i,l)=>{const a=Z(e,r,{stdio:["ignore","pipe","pipe"],windowsHide:!0});let d="",u="";a.stdout?.on("data",c=>{d+=c.toString("utf8")}),a.stderr?.on("data",c=>{u+=c.toString("utf8")}),a.on("error",l),a.on("close",()=>{if(d.trim()===""&&u.trim()!==""){l(new Error(u.trim()));return}i(d)})});if(n.trim()==="")return[];let s;try{s=JSON.parse(n)}catch{throw new Error("Could not parse hadolint JSON output.")}return Array.isArray(s)?s:[]},E=(e,o,t)=>{if(!(!/\bapt-get\b/u.test(e)||!/\binstall\b/u.test(e)||t.test(e)))return e.replace(/\binstall\b/u,`install ${o}`)},R={DL3014:e=>E(e,"-y",/(?:^|\s)(?:-y|--yes|--assume-yes|-qq?)\b/u),DL3015:e=>E(e,"--no-install-recommends",/--no-install-recommends\b/u),DL3020:e=>/^\s*ADD\b/u.test(e)?e.replace(/^(\s*)ADD\b/u,"$1COPY"):void 0,DL3027:e=>/(?:^|\s)apt\s/u.test(e)&&!/\bapt-get\b/u.test(e)?e.replace(/(^|\s)apt(\s)/u,"$1apt-get$2"):void 0},M=new Set(Object.keys(R)),pe=(e,o)=>{const t=e.includes(`\r
3
- `)?`\r
4
- `:`
5
- `,r=e.split(/\r?\n/u),n=new Set;let s=0;const i=new Map;for(const l of o){if(!R[l.code])continue;const a=i.get(l.line)??[];a.push(l),i.set(l.line,a)}for(const[l,a]of i){const d=l-1;if(!(d<0||d>=r.length))for(const u of a){const c=R[u.code],f=c?.(r[d]??"");f!==void 0&&f!==r[d]&&(r[d]=f,n.add(u.code),s+=1)}}return{content:s>0?r.join(t):e,fixedCodes:[...n],fixedCount:s}},j={error:0,info:2,style:3,warning:1},me=(e,o)=>{switch(e){case"error":return U(o);case"info":return k(o);case"warning":return P(o);default:return m(o)}},he=(e,o)=>(e.length>0?e:["Dockerfile"]).map(t=>A(t)?t:h(o,t)).filter(t=>W(t)),we=(e,o)=>{const t=[...e].sort((n,s)=>n.file.localeCompare(s.file)||n.line-s.line||n.column-s.column||j[n.level]-j[s.level]);let r="";for(const n of t){n.file!==r&&(r=n.file,o.info(`
6
- ${b(r)}`));const s=m(`${String(n.line)}:${String(n.column)}`),i=me(n.level,n.level.padEnd(7)),l=M.has(n.code)?m(" (fixable)"):"";o.info(` ${s} ${i} ${k(n.code)} ${n.message}${l}`)}},ge=e=>{const o={error:0,info:0,style:0,warning:0};for(const t of e)o[t.level]+=1;return o},be=async e=>{const{autoInstall:o,configPath:t,cwd:r,files:n,fix:s,fs:i,json:l,logger:a}=e,d=he(n,r);if(d.length===0)return a.error(`No Dockerfile found${n.length>0?` at: ${n.join(", ")}`:` in ${r}`}. Pass a path: vis docker lint <path>`),1;const u=await fe({autoInstall:o,log:p=>{a.info(p)}});if(u===void 0)return 0;let c=await O(u,d,t),f=0;if(s&&c.length>0){for(const p of d){const F=c.filter(V=>V.file===p),q=await i.readFile(p,"utf8"),x=pe(q,F);x.fixedCount>0&&(await i.writeFile(p,x.content),f+=x.fixedCount)}f>0&&(c=await O(u,d,t))}if(l)return process.stdout.write(`${JSON.stringify({findings:c,fixed:f},null,2)}
7
- `),c.some(p=>p.level==="error")?1:0;if(s&&f>0&&a.info(N(`✔ Auto-fixed ${String(f)} issue${f===1?"":"s"}.`)),c.length===0)return a.info(N("✔ No Dockerfile issues found.")),0;we(c,a);const w=ge(c),v=c.filter(p=>M.has(p.code)).length;return a.info(`
8
- ${b(String(c.length))} issue${c.length===1?"":"s"}: ${U(`${String(w.error)} error`)}, ${P(`${String(w.warning)} warning`)}, ${k(`${String(w.info)} info`)}, ${m(`${String(w.style)} style`)}`),!s&&v>0&&a.info(m(`Run 'vis docker lint --fix' to auto-fix ${String(v)} of them.`)),w.error>0?1:0},B=e=>{if(!e)throw new Error("Could not determine workspace root. Run inside a monorepo.");return e},Oe=async({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const n=B(r),{packageJsons:s,workspace:i}=I(n,t),l=z(n,i,s),a=(o.focus??"").split(",").map(c=>c.trim()).filter(Boolean);if(a.length===0)throw new Error("Missing --focus. Pass one or more project names, comma-separated.");const d=h(n,o.out??".vis/docker"),{projects:u}=Q({focus:a,includeSources:!!o.includeSources,log:c=>{e.info(c)},outDir:d,projectGraph:l,pruneLockfile:o.pruneLockfile!==!1,workspace:i,workspaceRoot:n});e.info(`Scaffolded ${u.length} project(s) into ${d}`),e.info(`Focus closure: ${u.toSorted().join(", ")}`)},Ee=async({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const n=B(r),{workspace:s}=I(n,t),i=h(n,o.context??".vis/docker"),{removed:l}=X({contextRoot:i,workspace:s,workspaceRoot:n});e.info(`Pruned ${l.length} unfocused project(s)`),l.length>0&&e.debug?.(l.join(`
9
- `))},je=async({argument:e,fs:o,logger:t,options:r,process:n,workspaceRoot:s})=>{const i=await be({autoInstall:!!r.install,configPath:r.config,cwd:s??n.cwd,files:e.filter(Boolean),fix:!!r.fix,fs:o,json:!!r.json,logger:t});i!==0&&(process.exitCode=i)},$e=async(e,o)=>{try{return await e.access(o),!0}catch{return!1}},ye=async e=>{const o=_({input:process.stdin,output:process.stderr}),t=await new Promise(r=>{o.question(` ${e} already exists. Overwrite? ${m("[y/N]")} `,n=>{r(n.trim().toLowerCase())})});return o.close(),t==="y"||t==="yes"},_e=async({argument:e,fs:o,logger:t,options:r,process:n,workspaceRoot:s})=>{const i=s??n.cwd,l=e[0]??"Dockerfile",a=A(l)?l:h(i,l),d=G(i)?.manager??"npm",u=(r.focus??"").split(",").map(f=>f.trim()).find(Boolean),c=re({focus:u,manager:d,nodeVersion:r.node??"22"});if(r.dryRun){process.stdout.write(c.endsWith(`
10
- `)?c:`${c}
11
- `);return}if(await $e(o,a)&&!r.force){if(!process.stdin.isTTY){t.error(`${a} already exists. Re-run with --force to overwrite.`),process.exitCode=1;return}if(!await ye(a)){t.info("Aborted — existing Dockerfile left untouched.");return}}await o.writeFile(a,c),t.info(`Created ${a} (package manager: ${d}).`),t.info(m(`Next: vis docker scaffold${u?` --focus=${u}`:""} --include-sources, then DOCKER_BUILDKIT=1 docker build .`))};export{_e as initExecute,je as lintExecute,Ee as pruneExecute,Oe as scaffoldExecute};
1
+ import{createRequire as B}from"node:module";import{j as M,m as W,o as F,q as p,s as z,t as G,Y as P,u as Y,x as L,z as H,C as K,E as Q,L as U,F as X,H as Z,G as I,$ as tt}from"./cli-main.js";import{f as k,m as f,v as j,T as O,I as st,J as nt}from"../packem_shared/index-CE6MsgcV.js";import"../packem_shared/public-api-WqUCiyIe.js";import{u as it}from"./ts-loader.js";import{loadVisConfig as rt}from"./CONFIG_FILES.js";import{v as ut}from"../packem_shared/verify-DStfg3nb.js";const J=B(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,V=t=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[o,s]=$.versions.node.split(".").map(Number);if(o>22||o===22&&s>=3||o===20&&s>=16)return $.getBuiltinModule(t)}return J(t)},{readdirSync:ot,statSync:et}=V("node:fs"),{stdin:T,stdout:at}=$,{createInterface:ct}=V("node:readline/promises"),w="__global__",R=t=>[...new Set(t)].sort((o,s)=>o.localeCompare(s)),pt=t=>`{${Object.keys(t).sort().map(o=>`${o}=${JSON.stringify(t[o])}`).join(",")}}`,m=t=>{if(!Array.isArray(t))return[];const o=[];for(const s of t)typeof s=="string"?o.push(s):s&&typeof s=="object"&&o.push(pt(s));return R(o)},y=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),h=(t,o,s)=>s?`^${o}`:t&&t!=="self"&&t!=="~"?`${t}#${o}`:o,ft=(t,o)=>{const s=t.trim();if(o==="moon"){if(s.startsWith("^:"))return h(void 0,s.slice(2),!0);if(s.startsWith("~:"))return h(void 0,s.slice(2),!1);if(s.includes(":")){const[n,e]=s.split(":");return h(n,e??"",!1)}return s}if(s.startsWith("^"))return h(void 0,s.slice(1),!0);if(s.includes("#")){const[n,e]=s.split("#");return h(n,e??"",!1)}return s},C=(t,o)=>{if(!Array.isArray(t))return[];const s=[];for(const n of t){if(typeof n=="string"){s.push(ft(n,o));continue}if(!n||typeof n!="object")continue;const e=n,{target:i}=e;if(!i)continue;if(e.dependencies===!0){s.push(h(void 0,i,!0));continue}if(e.projects===void 0){s.push(h(void 0,i,!1));continue}const r=Array.isArray(e.projects)?e.projects:[e.projects];for(const c of r)s.push(c==="^"?h(void 0,i,!0):h(c,i,!1))}return R(s)},E=t=>{if(k(t))try{return JSON.parse(j(t))}catch{return}},gt=t=>{const o=new Map,s=E(f(t,"turbo.json"));if(!s)return o;const n=s.tasks??s.pipeline??{};for(const[i,r]of Object.entries(n)){const c=i.includes("#")?i:`*#${i}`,a=y(c);a.dependsOn=C(r.dependsOn,"turbo"),a.inputs=m(r.inputs),a.outputs=m(r.outputs),a.env=R([...r.env??[],...r.passThroughEnv??[]]),a.cache=r.cache===!1?!1:void 0,o.set(c,a)}const e=y(w);return e.inputs=m(s.globalDependencies),e.env=R([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(w,e),o},dt=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),S=(t,o,s=8)=>{const n=[],e=(i,r)=>{if(r>s)return;let c;try{c=ot(i)}catch{return}for(const a of c.toSorted()){if(a===o){n.push(f(i,a));continue}if(a.startsWith(".")&&a!==".moon"||dt.has(a))continue;const u=f(i,a);try{et(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),n},N=(t,o)=>{t.dependsOn=C(o.dependsOn,"nx"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.cache=typeof o.cache=="boolean"?o.cache:void 0},lt=t=>{const o=new Map,s=E(f(t,"nx.json"));for(const[n,e]of Object.entries(s?.targetDefaults??{})){const i=`*#${n}`,r=y(i);N(r,e),o.set(i,r)}for(const n of S(t,"project.json")){const e=E(n);if(!(!e?.name||!e.targets))for(const[i,r]of Object.entries(e.targets)){const c=`${e.name}#${i}`,a=y(c);N(a,r),o.set(c,a)}}return o},_=(t,o)=>{t.dependsOn=C(o.deps,"moon"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.cache=typeof o.options?.cache=="boolean"?o.options.cache:void 0},A=t=>{if(k(t))try{return it(t)}catch{return}},vt=t=>{const o=new Map,s=f(t,".moon"),n=[f(s,"tasks.yml"),f(s,"tasks.yaml")];for(const e of n){const i=A(e);if(i){for(const[r,c]of Object.entries(i.tasks??{})){const a=`*#${r}`,u=y(a);_(u,c),o.set(a,u)}if(i.implicitInputs&&i.implicitInputs.length>0){const r=y(w);r.inputs=m(i.implicitInputs),o.set(w,r)}}}for(const e of[...S(t,"moon.yml"),...S(t,"moon.yaml")]){const i=A(e);if(!i?.tasks)continue;const r=e.split(/[/\\]/).at(-2)??"*";for(const[c,a]of Object.entries(i.tasks)){const u=`${r}#${c}`,v=y(u);_(v,a),o.set(u,v)}}return o},mt=(t,o)=>{t.dependsOn=C(o.dependsOn,"vis"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.env=R([...o.env??[],...o.passThroughEnv??[],...o.options?.passThroughEnv??[]]),t.cache=o.cache===!1?!1:typeof o.cache=="boolean"?o.cache:void 0},ht=async t=>{const o=new Map,s=await rt(t);for(const[i,r]of Object.entries(s.tasks??{})){const c=`*#${i}`,a=y(c);mt(a,r??{}),o.set(c,a)}const n=s.taskRunner??{},e=y(w);return e.inputs=m(n.globalInputs),e.env=R([...n.globalEnv??[],...n.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(w,e),o},yt=(t,o)=>{switch(o){case"moon":return vt(t);case"nx":return lt(t);default:return gt(t)}},kt=t=>{const o=[];return k(f(t,"turbo.json"))&&o.push("turbo"),k(f(t,"nx.json"))&&o.push("nx"),(k(f(t,".moon","tasks.yml"))||k(f(t,".moon","tasks.yaml")))&&o.push("moon"),o.length===1?o[0]:void 0},x=(t,o,s,n,e)=>{const i=n.filter(a=>!e.includes(a)),r=e.filter(a=>!n.includes(a));if(i.length===0&&r.length===0)return;const c=[];i.length>0&&c.push(`dropped [${i.join(", ")}]`),r.length>0&&c.push(`added [${r.join(", ")}]`),t.push({axis:s,detail:`${s} diverged: ${c.join("; ")}`,node:o,severity:i.length>0?"error":"warning"})},wt=(t,o,s)=>{const n=[],e=R([...t.keys(),...o.keys()]);for(const i of e){const r=t.get(i),c=o.get(i);if(r&&!c){const a=s==="turbo"&&i.includes("#")&&!i.startsWith("*#")&&i!==w;n.push({axis:"target-set",detail:a?`source target \`${i}\` was skipped by design (turbo project#task is migrated into per-project project.json move it there and re-verify)`:`source target \`${i}\` has no equivalent in the migrated vis config`,node:i,severity:a?"warning":"error"});continue}if(!r&&c){n.push({axis:"target-set",detail:`migrated vis config defines \`${i}\` with no source equivalent (extra target not a regression, but review)`,node:i,severity:"warning"});continue}!r||!c||(x(n,i,"dependsOn",r.dependsOn,c.dependsOn),x(n,i,"inputs",r.inputs,c.inputs),x(n,i,"outputs",r.outputs,c.outputs),x(n,i,"env",r.env,c.env),r.cache!==void 0&&c.cache!==void 0&&r.cache!==c.cache&&n.push({axis:"cache",detail:`cache flag diverged: source=${String(r.cache)} vis=${String(c.cache)} (changes what invalidates the cache)`,node:i,severity:"error"}))}return n.sort((i,r)=>i.node.localeCompare(r.node)||i.axis.localeCompare(r.axis)),{findings:n,source:s,sourceNodeCount:t.size,visNodeCount:o.size}},Rt=new Set(["json","ndjson","table"]),$t=t=>({equivalent:t.findings.every(o=>o.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),bt=(t,o,s)=>{if(o==="json"){process.stdout.write(`${JSON.stringify($t(t),void 0,2)}
2
+ `);return}if(o==="ndjson"){for(const n of t.findings)process.stdout.write(`${JSON.stringify(n)}
3
+ `);return}if(s.info(`Migration equivalence: ${t.source} → vis`),s.info(` source nodes: ${String(t.sourceNodeCount)} vis nodes: ${String(t.visNodeCount)}`),t.findings.length===0){s.info(" ✓ task graph + cache-key surface preserved (no divergence).");return}for(const n of t.findings){const e=` [${n.severity}] ${n.node} (${n.axis}) — ${n.detail}`;n.severity==="error"?s.warn(e):s.info(e)}},xt=(t,o)=>t.findings.some(s=>o==="warning"?!0:s.severity==="error")?1:0,D=async t=>{if(!T.isTTY)return!0;const o=ct({input:T,output:at});try{const s=(await o.question(`${t} [Y/n] `)).trim().toLowerCase();return s===""||s==="y"||s==="yes"}finally{o.close()}},Ct=[{description:"VisConfig.targetDefaults → VisConfig.tasks",next:"tasks",previous:"targetDefaults"},{description:"VisConfig.taskDefaults → VisConfig.scopedTasks",next:"scopedTasks",previous:"taskDefaults"},{description:"VisConfig.taskRunnerOptions → VisConfig.taskRunner",next:"taskRunner",previous:"taskRunnerOptions"},{description:"ScopedTasksBlock.scope → ScopedTasksBlock.match",next:"match",previous:"scope"},{description:"ScopedTasksBlock.targets → ScopedTasksBlock.tasks",next:"tasks",previous:"targets"}],jt=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],Et=t=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${t}\2(\s*:)`,"gmu"),St=(t,o)=>{let s=t;const n=[];for(const e of o){const i=Et(e.previous);i.test(s)&&(i.lastIndex=0,s=s.replace(i,(r,c,a,u)=>`${c}${a}${e.next}${a}${u}`),n.push(e))}return{applied:n,output:s}},q=(t,o)=>St(t,o),Mt=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],Ot=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),Tt=t=>{for(const o of Mt){const s=f(t,o);if(k(s))return s}},Nt=t=>{const o=[];try{for(const s of st(t,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))Ot.has(nt(s.path))&&o.push(s.path)}catch{}return o},_t=(t,o,s,n)=>{const e=Tt(t);if(e){const r=j(e),{applied:c,output:a}=q(r,Ct);if(c.length===0)s.info(`${e} already uses the current schema — no rewrite needed.`);else if(o.dryRun)s.info(`── ${e} (preview) ──`),s.info(a),s.info("── end preview ──"),s.info(`Would apply ${String(c.length)} rename(s): ${c.map(u=>u.description).join(", ")}`);else{M(e,n),O(e,a),s.info(`Rewrote ${e} (backup at ${e}.bak). Applied ${String(c.length)} rename(s).`);for(const u of c)n.manualSteps.push(`Renamed ${u.description} in ${e}`)}}else s.warn("No vis.config.ts found at workspace root — nothing to migrate."),n.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const i=o.taskConfigPaths??Nt(t);for(const r of i){if(!k(r))continue;const c=j(r),a=q(c,jt);if(a.applied.length!==0)if(o.dryRun)s.info(`── ${r} (preview) ──`),s.info(a.output),s.info("── end preview ──"),s.info(`Would apply ${String(a.applied.length)} rename(s): ${a.applied.map(u=>u.description).join(", ")}`);else{M(r,n),O(r,a.output),s.info(`Rewrote ${r} (backup at ${r}.bak). Applied ${String(a.applied.length)} rename(s).`);for(const u of a.applied)n.manualSteps.push(`Renamed ${u.description} in ${r}`)}}},g=t=>{const o=t.workspaceRoot??process.cwd(),s=t.visConfig??{};return{config:s,dryRun:!!t.options.dryRun,logger:t.logger,packageManager:tt(o),report:I(),root:o,useEditorconfig:typeof s.editorconfig=="boolean"?s.editorconfig:!0}},d=async(t,o,s)=>{if(o.yes||o.dryRun)return!0;const n=await D(`This will edit files, scripts, and hooks for "${t}". Backups (.bak) will be created. Continue?`);return n||s.info("Aborted."),n},l=t=>{t.dryRun&&t.logger.info(`Running in dry-run mode — no changes will be made.
4
+ `)},At=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("deps",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating dependencies and scripts ──"),z(e.root,e.packageManager,e.config,{dryRun:e.dryRun},t,e.report),t.info(""),p(e.report,t)},qt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("lint-staged",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating lint-staged ──"),G(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Vt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("nano-staged",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating nano-staged ──"),P(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},It=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("turborepo",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating turborepo ──"),Y(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Dt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("nx",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating nx ──");const i=!!o.aggressive;L(e.root,{aggressive:i,dryRun:e.dryRun,force:i||!!o.force,rewriteSyncGenerators:i||!!o.rewriteSyncGenerators,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Bt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("moon",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating moon ──"),H(e.root,{copyTemplates:!!o.copyTemplates,dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Jt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("gitleaks",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating gitleaks ──"),K(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Wt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("kingfisher",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating Kingfisher ──"),Q(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Ft=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("secretlint",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating secretlint ──"),U(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},zt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("syncpack",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating syncpack ──"),X(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Gt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("sherif",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating sherif ──"),Z(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Pt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("self",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating vis.config.ts to current schema ──"),_t(e.root,{dryRun:e.dryRun},t,e.report),t.info(""),p(e.report,t)},Yt=({logger:t,workspaceRoot:o})=>{const s=o??process.cwd();ut(s,t).length>0&&(process.exitCode=1)},Lt=async({logger:t,options:o,workspaceRoot:s})=>{const n=s??process.cwd(),e=o.format??"table";if(!Rt.has(e)){t.warn(`Invalid --format: ${String(o.format)}. Expected table | json | ndjson.`),process.exitCode=1;return}const i=o.failOn==="warning"?"warning":"error";let r;if(o.from){if(o.from!=="turbo"&&o.from!=="nx"&&o.from!=="moon"){t.warn(`Invalid --from: ${o.from}. Expected turbo | nx | moon.`),process.exitCode=1;return}r=o.from}else if(r=kt(n),!r){t.warn("Could not auto-detect the source tool (need exactly one of turbo.json / nx.json / .moon/tasks.yml). Pass --from <turbo|nx|moon>."),process.exitCode=1;return}const c=yt(n,r);if(c.size===0){t.warn(`No ${r} task graph found at ${n} — nothing to verify.`),process.exitCode=1;return}const a=await ht(n);if(a.size===0){t.warn("No migrated vis task graph found (vis.config.ts has no tasks). Run the migrator first."),process.exitCode=1;return}const u=wt(c,a,r);bt(u,e,t),process.exitCode=xt(u,i)},Ht=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{const e=n??process.cwd(),i=W(e,s??{}),r=F(i);if(r.length===0){t.info("No applicable migrations detected in this workspace.");return}const c=!!o.dryRun;t.info(`Detected ${String(r.length)} migration(s):`);for(const v of r)t.info(` • ${v.title} — ${v.description}`);if(t.info(""),!o.yes&&!c&&!await D("Apply all detected migrations? Backups (.bak) will be created.")){t.info("Aborted.");return}c&&t.info(`Running in dry-run mode — no changes will be made.
5
+ `);const a=I(),u=[];for(const v of r)try{if(t.info(`── Applying ${v.title} ──`),c)for(const b of v.probe(i))t.info(b);else v.apply(i,a,t);t.info("")}catch(b){u.push({error:b,id:v.id}),t.warn(`Failed to apply ${v.title}: ${b.message}`)}p(a,t),u.length>0&&(t.warn(""),t.warn(`${String(u.length)} migration(s) failed — see messages above.`),process.exitCode=1)},eo=At,so=qt,no=Vt,io=It,ro=Dt,ao=Bt,co=Jt,uo=Wt,po=Ft,fo=zt,go=Gt,lo=Pt,vo=Yt,mo=Lt,ho=Ht;export{ho as migrateAllExecute,eo as migrateDepsExecute,co as migrateGitleaksExecute,uo as migrateKingfisherExecute,so as migrateLintStagedExecute,ao as migrateMoonExecute,no as migrateNanoStagedExecute,ro as migrateNxExecute,po as migrateSecretlintExecute,lo as migrateSelfExecute,go as migrateSherifExecute,fo as migrateSyncpackExecute,io as migrateTurborepoExecute,vo as migrateVerifyExecute,mo as migrateVerifyGraphExecute};
@@ -1,3 +1,11 @@
1
- import{createRequire as G}from"node:module";import{I as F,q as L,j as N,E as O}from"../packem_shared/index.server-J83sowC4.js";import{y as E}from"../packem_shared/index-CE6MsgcV.js";import{X as U}from"./cli-main.js";import{d as A,f as C,r as X,a as D,b as Q,s as Y,c as Z,e as ee,g as te,h as se,i as re,j as ie,k as ne,l as oe,m as ae,n as de,o as ce,p as fe,q as pe,t as le}from"../packem_shared/watch-loop-JfGKIgKB.js";import{p as h}from"./catalog.js";const H=G(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=t=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[e,s]=k.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return k.getBuiltinModule(t)}return H(t)},{createHash:q}=I("node:crypto"),ue=t=>t.startsWith("/")||/^[a-z]:[\\/]/i.test(t),_=(t,e)=>ue(e)?e:`${t}/${e}`,ge={argsCheck:(t,e)=>T(t,e,"check"),argsFix:(t,e)=>T(t,e,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(t,e)=>{const s=["dprint",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=A(e,h.dprint.packageNames[0]),r=C(t,h.dprint.configFiles);if(!(!s&&!r))return{adapter:"dprint",configFile:r,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","css","cts","dockerfile","html","js","json","jsonc","jsx","md","mdx","mjs","mts","toml","ts","tsx","yaml","yml"],id:"dprint",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const r of t.stdout.split(/\r?\n/)){const i=r.trim();!i||i.startsWith("[")||i.startsWith("Checked ")||i.startsWith("Error:")||s.push({adapter:"dprint",file:_(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},T=(t,e,s)=>{const r=s==="fix"?["fmt"]:["check","--list-different"];return e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},me={argsCheck:(t,e)=>B(t,e,"check"),argsFix:(t,e)=>B(t,e,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(t,e)=>{const s=["oxfmt",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=A(e,h.oxfmt.packageNames[0]),r=C(t,h.oxfmt.configFiles);if(!(!s&&!r))return{adapter:"oxfmt",configFile:r,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const r of t.stdout.split(/\r?\n/)){const i=r.trim();!i||i.startsWith("[")||s.push({adapter:"oxfmt",file:_(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},B=(t,e,s)=>{const r=s==="fix"?["--write"]:["--list-different"];return e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},he={argsCheck:(t,e)=>P(t,e,"check"),argsFix:(t,e)=>P(t,e,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(t,e)=>{const s=["prettier",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=A(e,h.prettier.packageNames[0]),r=C(t,h.prettier.configFiles);if(!(!s&&!r))return{adapter:"prettier",configFile:r,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const r of t.stdout.split(/\r?\n/)){const i=r.trim();i&&(i.startsWith("[")||s.push({adapter:"prettier",file:_(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},P=(t,e,s)=>{const r=s==="fix"?["--write"]:["--list-different"];return e.quiet&&r.push("--log-level","warn"),e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},xe=[me,de,ge,he,ce,fe],qe=async({logger:t,options:e,visConfig:s,workspaceRoot:r})=>{const i=r??process.cwd(),u=s?.fmt,w=X(xe,u?.order),K=D(i,w),x=Q(K,w,"fmt").filter(({adapter:p})=>u?.adapters?.[p.id]?.enabled!==!1);if(x.length===0){t.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff, deno-fmt).");return}const $=p=>{const o=u?.adapters?.[p]?.extraArgs;return o&&o.length>0?[...o]:void 0},j={quiet:e.quiet??!1},R=ke(e),y=e.check?"check":"fix";let d;if(e.staged){if(d=Y(i),d===void 0)t.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(d.length===0){t.info(F(" fmt: no staged files"));return}}else if(typeof e.since=="string"&&e.since.length>0){if(d=Z(i,e.since),d===void 0)t.warn(`vis fmt: could not resolve --since ${e.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(d.length===0){t.info(F(`✓ fmt: no files changed since ${e.since}`));return}}const z=U(i,void 0,void 0,!0),v=e.format??"human";v==="human"&&e.output!==void 0&&t.warn("vis fmt: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=async p=>{const o=R.length>0?R:p,g=[];if(o){const n=te(o,x,u?.extensionOverrides);for(const{adapter:a,presence:c}of x){const f=n.get(a.id);if(!f||f.length===0)continue;const W=$(a.id),V={adapter:a,files:f,presence:c};W&&(V.options={...j,extraArgs:W}),g.push(V)}}else for(const{adapter:n,presence:a}of x){const c=$(n.id),f={adapter:n,files:["."],presence:a};c&&(f.options={...j,extraArgs:c}),g.push(f)}if(g.length===0)return;const J=await se(g,j,y,{cacheRoot:z}),b=g.map((n,a)=>{const c=J[a],f=n.adapter.parse(c,n.presence);return{adapter:n.adapter,durationMs:c.durationMs,exitCode:c.exitCode,findings:f}}),l=re(b.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,exitCode:n.exitCode,findingCount:n.findings.length,findings:n.findings}))),m=v==="human"?void 0:ie({cwd:i,target:e.output});try{switch(v){case"github":{m.write(ae({runs:b.map(n=>({findings:n.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:l.findings,mode:y,runs:l.runs},null,2)}
2
- `);break}case"junit":{m.write(oe({runs:b.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,findings:n.findings})),workspaceRoot:i}));break}case"minimal":{ye(l.findings,i,m);break}case"sarif":{m.write(ne({runs:b.map(n=>({adapter:n.adapter.id,findings:n.findings,presence:g.find(a=>a.adapter.id===n.adapter.id)?.presence})),workspaceRoot:i}));break}default:we(l.findings,i,y,t)}}finally{m?.close()}const S=y==="fix"?l.hadProcessFailure?1:0:le({...l,maxSeverity:l.findings.length>0?"error":void 0});S!==0&&(process.exitCode=S)};if(e.watch){const p=[...new Set(x.flatMap(({adapter:o})=>o.extensions))];await ee({extensions:p,initialFiles:d,label:"fmt",log:o=>{t.info(o)},runCycle:M,workspaceRoot:i});return}await M(d)},ke=t=>{const e=t;return[...e._??e.args??[]]},we=(t,e,s,r)=>{if(t.length===0){r.info(F(s==="fix"?"✓ fmt: nothing to change":" fmt: all files already formatted"));return}const i=pe(t),u=s==="fix"?L(N("Formatted:")):N("Would change:");r.info(u);for(const w of i.keys())r.info(` ${O("·")} ${E(e,w)}`);s==="check"&&(r.info(""),r.info(O(`Run \`vis fmt\` to apply changes (${String(i.size)} file${i.size===1?"":"s"}).`)))},ye=(t,e,s)=>{for(const r of t)s.write(`${r.adapter} ${E(e,r.file)}
3
- `)};export{qe as default};
1
+ import{createRequire as K}from"node:module";import{j as b,E as m,q as k,I as N,V as U,s as P}from"../packem_shared/index.server-J83sowC4.js";import{m as h,a as J,A,f as W}from"../packem_shared/index-CE6MsgcV.js";import{b as I,O as z}from"./catalog.js";import{d as G}from"../packem_shared/lockfile-C1qCKGH6.js";import{p as X,s as Q}from"../packem_shared/docker-BYqiD711.js";import{I as ne}from"../packem_shared/index-B0EsgdzO.js";import{g as L}from"../packem_shared/env-DJlbJiFh.js";const Y=K(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[o,t]=g.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return g.getBuiltinModule(e)}return Y(e)},{createInterface:_}=y("node:readline"),{spawn:Z}=y("node:child_process"),{createHash:ee}=y("node:crypto"),{existsSync:T,writeFileSync:oe,chmodSync:te}=y("node:fs"),D={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},re=e=>{const{focus:o,manager:t,nodeVersion:r}=e,n=D[t]??D.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${o?` --focus=${o}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...n.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",n.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",n.build(o),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
2
+ `)},$="v2.14.0",S=`https://github.com/hadolint/hadolint/releases/download/${$}`,se={"hadolint-linux-arm64":"331f1d3511b84a4f1e3d18d52fec284723e4019552f4f47b19322a53ce9a40ed","hadolint-linux-x86_64":"6bf226944684f56c84dd014e8b979d27425c0148f61b3bd99bcc6f39e9dc5a47","hadolint-macos-arm64":"3625e2e9f43dcfe7bd38738a5f5520ed50ce39ed28485266e6803dd7bc197b10","hadolint-macos-x86_64":"2b69a853433f1eca522ffb921cd490bd1321424d03331fd8390f93b7fb4a02e9","hadolint-windows-x86_64.exe":"8e0ee174f88edb14f207a68430c7a53c2883ed509cdbde9a3a26fffa140fa5e4"},ie=e=>se[e],ae=(e=process.platform,o=process.arch)=>{const t=e==="darwin"?"macos":e==="linux"?"linux":e==="win32"?"windows":void 0;if(t===void 0)return;const r=o==="arm64"?"arm64":o==="x64"?"x86_64":void 0;if(t==="windows")return"hadolint-windows-x86_64.exe";if(r!==void 0)return`hadolint-${t}-${r}`},H=e=>h(L(),"hadolint",$,e.endsWith(".exe")?"hadolint.exe":"hadolint"),ce=()=>{const e=process.platform==="win32"?"hadolint.exe":"hadolint",o=(process.env.PATH??"").split(process.platform==="win32"?";":":");for(const t of o)if(t!==""&&T(h(t,e)))return e},le=e=>e.trim().split(/\s+/u)[0]??"",C=async e=>{const o=await fetch(e,{redirect:"follow"});if(!o.ok)throw new Error(`download failed (${String(o.status)} ${o.statusText}) for ${e}`);return Buffer.from(await o.arrayBuffer())},de=async e=>{const o=H(e),t=ie(e),r=await C(`${S}/${e}`),n=ee("sha256").update(r).digest("hex");if(t===void 0){const s=await C(`${S}/${e}.sha256`),i=le(s.toString("utf8")).toLowerCase();if(i==="")throw new Error("hadolint checksum sidecar was empty or unparseable. Refusing to use the download.");if(i!==n)throw new Error(`hadolint checksum mismatch (expected ${i}, got ${n}). Refusing to use the download.`)}else if(t.toLowerCase()!==n)throw new Error(`hadolint checksum mismatch (expected ${t.toLowerCase()}, got ${n}). Refusing to use the download.`);return J(h(L(),"hadolint",$)),oe(o,r),process.platform!=="win32"&&te(o,493),o},ue=async()=>{const e=_({input:process.stdin,output:process.stderr}),o=await new Promise(t=>{e.question(` Download hadolint ${k($)} now? ${m("[y/N]")} `,r=>{t(r.trim().toLowerCase())})});return e.close(),o==="y"||o==="yes"},fe=async e=>{const{autoInstall:o=!1,log:t}=e,r=ce();if(r!==void 0)return r;const n=ae();if(n===void 0){t(`hadolint has no prebuilt binary for ${process.platform}/${process.arch}. Install it manually: https://github.com/hadolint/hadolint`);return}const s=H(n);if(T(s))return s;if(!o){if(!(process.stdin.isTTY&&!ne)){t(`hadolint is not installed. Re-run with ${b("--install")} (or install hadolint on PATH) to enable Dockerfile linting.`);return}if(t(`${b("hadolint")} is required to lint Dockerfiles but was not found on your PATH.`),!await ue()){t(`Skipped. Install it yourself or re-run with ${b("--install")}.`);return}}t(`Downloading hadolint ${$} (${n})…`);try{const i=await de(n);return t(`Installed hadolint to ${m(i)}`),i}catch(i){t(`Failed to download hadolint: ${i.message}`);return}},O=async(e,o,t)=>{if(o.length===0)return[];const r=["--format","json","--no-fail",...t!==void 0&&t!==""?["--config",t]:[],...o],n=await new Promise((i,l)=>{const a=Z(e,r,{stdio:["ignore","pipe","pipe"],windowsHide:!0});let d="",u="";a.stdout?.on("data",c=>{d+=c.toString("utf8")}),a.stderr?.on("data",c=>{u+=c.toString("utf8")}),a.on("error",l),a.on("close",()=>{if(d.trim()===""&&u.trim()!==""){l(new Error(u.trim()));return}i(d)})});if(n.trim()==="")return[];let s;try{s=JSON.parse(n)}catch{throw new Error("Could not parse hadolint JSON output.")}return Array.isArray(s)?s:[]},E=(e,o,t)=>{if(!(!/\bapt-get\b/u.test(e)||!/\binstall\b/u.test(e)||t.test(e)))return e.replace(/\binstall\b/u,`install ${o}`)},R={DL3014:e=>E(e,"-y",/(?:^|\s)(?:-y|--yes|--assume-yes|-qq?)\b/u),DL3015:e=>E(e,"--no-install-recommends",/--no-install-recommends\b/u),DL3020:e=>/^\s*ADD\b/u.test(e)?e.replace(/^(\s*)ADD\b/u,"$1COPY"):void 0,DL3027:e=>/(?:^|\s)apt\s/u.test(e)&&!/\bapt-get\b/u.test(e)?e.replace(/(^|\s)apt(\s)/u,"$1apt-get$2"):void 0},M=new Set(Object.keys(R)),pe=(e,o)=>{const t=e.includes(`\r
3
+ `)?`\r
4
+ `:`
5
+ `,r=e.split(/\r?\n/u),n=new Set;let s=0;const i=new Map;for(const l of o){if(!R[l.code])continue;const a=i.get(l.line)??[];a.push(l),i.set(l.line,a)}for(const[l,a]of i){const d=l-1;if(!(d<0||d>=r.length))for(const u of a){const c=R[u.code],f=c?.(r[d]??"");f!==void 0&&f!==r[d]&&(r[d]=f,n.add(u.code),s+=1)}}return{content:s>0?r.join(t):e,fixedCodes:[...n],fixedCount:s}},j={error:0,info:2,style:3,warning:1},me=(e,o)=>{switch(e){case"error":return U(o);case"info":return k(o);case"warning":return P(o);default:return m(o)}},he=(e,o)=>(e.length>0?e:["Dockerfile"]).map(t=>A(t)?t:h(o,t)).filter(t=>W(t)),we=(e,o)=>{const t=[...e].sort((n,s)=>n.file.localeCompare(s.file)||n.line-s.line||n.column-s.column||j[n.level]-j[s.level]);let r="";for(const n of t){n.file!==r&&(r=n.file,o.info(`
6
+ ${b(r)}`));const s=m(`${String(n.line)}:${String(n.column)}`),i=me(n.level,n.level.padEnd(7)),l=M.has(n.code)?m(" (fixable)"):"";o.info(` ${s} ${i} ${k(n.code)} ${n.message}${l}`)}},ge=e=>{const o={error:0,info:0,style:0,warning:0};for(const t of e)o[t.level]+=1;return o},be=async e=>{const{autoInstall:o,configPath:t,cwd:r,files:n,fix:s,fs:i,json:l,logger:a}=e,d=he(n,r);if(d.length===0)return a.error(`No Dockerfile found${n.length>0?` at: ${n.join(", ")}`:` in ${r}`}. Pass a path: vis docker lint <path>`),1;const u=await fe({autoInstall:o,log:p=>{a.info(p)}});if(u===void 0)return 0;let c=await O(u,d,t),f=0;if(s&&c.length>0){for(const p of d){const F=c.filter(V=>V.file===p),q=await i.readFile(p,"utf8"),x=pe(q,F);x.fixedCount>0&&(await i.writeFile(p,x.content),f+=x.fixedCount)}f>0&&(c=await O(u,d,t))}if(l)return process.stdout.write(`${JSON.stringify({findings:c,fixed:f},null,2)}
7
+ `),c.some(p=>p.level==="error")?1:0;if(s&&f>0&&a.info(N(`✔ Auto-fixed ${String(f)} issue${f===1?"":"s"}.`)),c.length===0)return a.info(N("✔ No Dockerfile issues found.")),0;we(c,a);const w=ge(c),v=c.filter(p=>M.has(p.code)).length;return a.info(`
8
+ ${b(String(c.length))} issue${c.length===1?"":"s"}: ${U(`${String(w.error)} error`)}, ${P(`${String(w.warning)} warning`)}, ${k(`${String(w.info)} info`)}, ${m(`${String(w.style)} style`)}`),!s&&v>0&&a.info(m(`Run 'vis docker lint --fix' to auto-fix ${String(v)} of them.`)),w.error>0?1:0},B=e=>{if(!e)throw new Error("Could not determine workspace root. Run inside a monorepo.");return e},Oe=async({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const n=B(r),{packageJsons:s,workspace:i}=I(n,t),l=z(n,i,s),a=(o.focus??"").split(",").map(c=>c.trim()).filter(Boolean);if(a.length===0)throw new Error("Missing --focus. Pass one or more project names, comma-separated.");const d=h(n,o.out??".vis/docker"),{projects:u}=Q({focus:a,includeSources:!!o.includeSources,log:c=>{e.info(c)},outDir:d,projectGraph:l,pruneLockfile:o.pruneLockfile!==!1,workspace:i,workspaceRoot:n});e.info(`Scaffolded ${u.length} project(s) into ${d}`),e.info(`Focus closure: ${u.toSorted().join(", ")}`)},Ee=async({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const n=B(r),{workspace:s}=I(n,t),i=h(n,o.context??".vis/docker"),{removed:l}=X({contextRoot:i,workspace:s,workspaceRoot:n});e.info(`Pruned ${l.length} unfocused project(s)`),l.length>0&&e.debug?.(l.join(`
9
+ `))},je=async({argument:e,fs:o,logger:t,options:r,process:n,workspaceRoot:s})=>{const i=await be({autoInstall:!!r.install,configPath:r.config,cwd:s??n.cwd,files:e.filter(Boolean),fix:!!r.fix,fs:o,json:!!r.json,logger:t});i!==0&&(process.exitCode=i)},$e=async(e,o)=>{try{return await e.access(o),!0}catch{return!1}},ye=async e=>{const o=_({input:process.stdin,output:process.stderr}),t=await new Promise(r=>{o.question(` ${e} already exists. Overwrite? ${m("[y/N]")} `,n=>{r(n.trim().toLowerCase())})});return o.close(),t==="y"||t==="yes"},_e=async({argument:e,fs:o,logger:t,options:r,process:n,workspaceRoot:s})=>{const i=s??n.cwd,l=e[0]??"Dockerfile",a=A(l)?l:h(i,l),d=G(i)?.manager??"npm",u=(r.focus??"").split(",").map(f=>f.trim()).find(Boolean),c=re({focus:u,manager:d,nodeVersion:r.node??"22"});if(r.dryRun){process.stdout.write(c.endsWith(`
10
+ `)?c:`${c}
11
+ `);return}if(await $e(o,a)&&!r.force){if(!process.stdin.isTTY){t.error(`${a} already exists. Re-run with --force to overwrite.`),process.exitCode=1;return}if(!await ye(a)){t.info("Aborted — existing Dockerfile left untouched.");return}}await o.writeFile(a,c),t.info(`Created ${a} (package manager: ${d}).`),t.info(m(`Next: vis docker scaffold${u?` --focus=${u}`:""} --include-sources, then DOCKER_BUILDKIT=1 docker build .`))};export{_e as initExecute,je as lintExecute,Ee as pruneExecute,Oe as scaffoldExecute};
@@ -1,4 +1,4 @@
1
- import{createRequire as G}from"node:module";import{w as H,k as J,p,P as O,i as S}from"./cli-main.js";import"../packem_shared/index-CE6MsgcV.js";import"../packem_shared/public-api-WqUCiyIe.js";import{g as V,R as W,c as K,V as Z,$ as T,d as a,h as Q,i as g,H as M,j as X,G as ee,F as m}from"./catalog.js";import{B as te}from"../packem_shared/env-Ct3hMEYB.js";import{I as oe}from"../packem_shared/index-B0EsgdzO.js";import{K as re,Z as se,W as ne}from"../packem_shared/ai-analysis-rC48NLfB.js";import{A as ie}from"../packem_shared/pm-runner-CQcraCcu.js";import{U as ae,b as ce,u as N}from"../packem_shared/vis-update-app-B3I14Vfy.js";const de=G(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const ke=async({argument:E,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=ie(d);if(H(i??{},t.name),e.sync&&t.name==="pnpm"){const r=J(i??{});if(r.length>0){p.info(`
1
+ import{createRequire as G}from"node:module";import{w as H,k as J,p,P as O,i as S}from"./cli-main.js";import"../packem_shared/index-CE6MsgcV.js";import"../packem_shared/public-api-WqUCiyIe.js";import{g as V,R as W,c as K,V as Z,$ as T,d as a,h as Q,i as g,H as M,j as X,G as ee,F as m}from"./catalog.js";import{B as te}from"../packem_shared/env-DJlbJiFh.js";import{I as oe}from"../packem_shared/index-B0EsgdzO.js";import{K as re,Z as se,W as ne}from"../packem_shared/ai-analysis-DF_AfeS3.js";import{A as ie}from"../packem_shared/pm-runner-CQcraCcu.js";import{U as ae,b as ce,u as N}from"../packem_shared/vis-update-app-BoCQ4ute.js";const de=G(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const ke=async({argument:E,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=ie(d);if(H(i??{},t.name),e.sync&&t.name==="pnpm"){const r=J(i??{});if(r.length>0){p.info(`
2
2
  Settings that would sync to pnpm-workspace.yaml:`);for(const b of r)p.success(` ${b}`)}else p.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(p.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),p.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!E?.length)return}const{packageManager:U}=O(d),B=V(d),c=i?.update??{},y=W(d,U,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(y.size===0){o.info("No catalogs found.");return}const h=e.target??c.target??"latest";if(!["latest","minor","patch"].includes(h))throw new Error(`Invalid target "${h}". Use: latest, minor, or patch.`);const D={exclude:[...m(e.exclude),...m(c.exclude)],ignore:m(c.ignore),include:[...m(e.include),...m(c.include),...E],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||c.prerelease||!1,security:e.security!==!1,target:h};let j=0;for(const t of y.values())j+=t.size;const $=!!process.stdout.isTTY&&!oe;let l;const F=$?(t,r)=>{l?l.rerender(a.createElement(N,{current:t,total:r})):l=T(a.createElement(N,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{o.info(`Checking ${String(t)}/${String(r)} dependencies...`)};$||o.info(`Checking ${String(j)} catalog dependencies against npm registry...
3
3
  `);const v=new Set;S("socket")&&v.add("socket"),S("depsDev")&&v.add("deps-dev");const w=i?.security?.policies?.score?.minimum,I=K(i?.security,{disabled:v,minimumScore:w}),{failed:k,outdated:n}=await Z(y,D,B,F,d,I,i?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),k.length>0&&o.warn(`Failed to fetch: ${k.join(", ")}`),n.length===0){o.info("All catalog dependencies are up to date.");return}const R=e.format??c.format??"table",P=re(e.aiType??"impact"),u=e.ai?await se(n,o,i?.ai,P):void 0;if($&&R==="table"){const t=new ae(n,u??null),r=i?.tui?.autoExit??!1,b=r===!0?3:typeof r=="number"?r:0;await T(a.createElement(ce,{autoExitSeconds:b,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const q=process.stdout.columns||80;process.stdout.write(`
4
4
  `);for(const s of n){const z=s.vulnerabilities?.length||s.socketReport&&s.socketReport.alerts.length>0,_=!!s.acceptedRisk,A=z?_?"✓":"⚠":"✓",L=_?"gray":s.updateType==="major"?"red":s.updateType==="minor"?"yellow":"green",f=s.socketReport?.score.overall,Y=f===void 0?"":` [${String(Math.round(f*100))}%]`,x=f===void 0?void 0:te(f);process.stdout.write(`${Q(a.createElement(g,null," ",a.createElement(g,{color:L},A),` ${s.packageName} ${s.currentRange} → ${s.newRange}`,a.createElement(g,{dimColor:!0},` ${s.updateType}`),x?a.createElement(g,{color:x},Y):null),{columns:q})}
@@ -1,22 +1,3 @@
1
- import{createRequire as te}from"node:module";import{E as u,j as g,q as y}from"../packem_shared/index.server-J83sowC4.js";import{m as T,f as j,I as V,H as G,y as K,a as L,A as P,o as se,T as ne,B as oe}from"../packem_shared/index-CE6MsgcV.js";import{f as ue}from"../packem_shared/giget-DVTFJlbR.js";import{p as l}from"./cli-main.js";const re=te(import.meta.url),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=t=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[e,r]=R.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return R.getBuiltinModule(t)}return re(t)},{fileURLToPath:ie}=E("node:url"),{createInterface:ae}=E("node:readline"),{mkdtempSync:ce,rmSync:le}=E("node:fs"),{tmpdir:fe}=E("node:os"),{spawnSync:pe}=E("node:child_process"),J=[".ts",".mts",".cts",".js",".mjs",".cjs"],de="template.yml",me=[".d",".test",".spec",".config",".bench",".stories"],he=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],Y=t=>{for(const e of J)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(he.some(r=>t.endsWith(r))||!J.some(r=>t.endsWith(r)))return!1;const e=Y(t);return!me.some(r=>e.endsWith(r))},H=(t,e)=>{const r=[];if(!j(t))return r;for(const s of V(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(s.name))continue;const n=Y(s.name);r.push({load:()=>ge(s.path),name:n,path:s.path,source:e})}return r},x=(t,e)=>{const r=[];if(!j(t))return r;for(const s of V(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=T(s.path,de);j(n)&&r.push({load:()=>ye(s.path,s.name),name:s.name,path:s.path,source:e})}return r},we=()=>{try{const t=ie(import.meta.url),e=T(G(t),"..","..","templates");return j(e)?e:void 0}catch{return}},I=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...H(T(s,".vis","templates"),"native"),...x(T(s,".vis","templates"),"moon"),...x(T(s,".moon","templates"),"moon")];for(const o of e)n.push(...x(o,"config")),n.push(...H(o,"config"));const i=we();i&&n.push(...x(i,"builtin"));const a=new Map;for(const o of n){const c=a.get(o.name);if(!c){a.set(o.name,o);continue}r&&r(`Template "${o.name}" exists in multiple sources using ${c.source} (${c.path}), ignoring ${o.source} (${o.path}).`)}return[...a.values()].sort((o,c)=>o.name.localeCompare(c.name))},ge=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},ye=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index3.js");return r(t,e)},q=(t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),ve=async(t,e,r)=>{const s=await q(t,` ${e} ${u(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},be=async(t,e,r,s)=>{process.stderr.write(` ${e}
2
- `);for(const[n,i]of r.entries()){const a=g(y(` ${String(n+1)}.`)),o=i===s?u(" (default)"):"";process.stderr.write(`${a} ${i}${o}
3
- `)}for(;;){const n=await q(t,`
4
- ${u(`Enter choice (1-${String(r.length)}):`)} `);if(n===""&&s!==void 0)return s;const i=Number.parseInt(n,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const a=r.find(o=>o===n);if(a)return a;process.stderr.write(` ${u("Invalid choice. Try again.")}
5
- `)}},Te=async(t,e,r,s)=>{process.stderr.write(` ${e} ${u("(comma-separated numbers)")}
6
- `);for(const[n,i]of r.entries()){const a=g(y(` ${String(n+1)}.`)),o=s.includes(i)?u(" (default)"):"";process.stderr.write(`${a} ${i}${o}
7
- `)}for(;;){const n=await q(t,`
8
- ${u("Enter choices:")} `);if(n===""&&s.length>0)return s;const i=n.split(",").map(a=>Number.parseInt(a.trim(),10)).filter(a=>Number.isInteger(a)&&a>=1&&a<=r.length);if(i.length>0)return i.map(a=>r[a-1]);process.stderr.write(` ${u("Invalid choice. Try again.")}
9
- `)}},Se=t=>` ${u(`${t}:`)} `,Ne=(t,e)=>e.prompt??t,Re=t=>Object.entries(t).sort(([e,r],[s,n])=>{const i=r.order??0,a=n.order??0;return i!==a?i-a:e.localeCompare(s)}),U=(t,e)=>{switch(t.type){case"array":return e.split(",").map(r=>r.trim()).filter(Boolean);case"boolean":return e==="true"||e==="1"||e==="yes"||e==="y";case"enum":return t.multiple?e.split(",").map(r=>r.trim()).filter(Boolean):e;case"number":{const r=Number(e);if(Number.isNaN(r))throw new TypeError(`Expected a number, got "${e}"`);return r}default:return e}},B=(t,e,r)=>{if(e.type==="enum"){const s=Array.isArray(r)?r:[r];for(const n of s)if(typeof n!="string"||!e.values.includes(n))throw new Error(`Variable "${t}" must be one of: ${e.values.join(", ")} (got "${String(n)}")`)}},je=async t=>{const{defaults:e,interactive:r,overrides:s,variables:n}=t,i={},a=r?ae({input:process.stdin,output:process.stderr}):null;try{for(const[o,c]of Re(n)){if(Object.hasOwn(s,o)){const w=U(c,s[o]??"");B(o,c,w),i[o]=w;continue}if(e||!r||c.internal){if(c.default!==void 0){B(o,c,c.default),i[o]=c.default;continue}if(c.required)throw new Error(`Required variable "${o}" not provided. Pass --${o}=<value> or remove --defaults.`);continue}const m=Ne(o,c);let f;if(c.type==="boolean")f=await ve(a,m,!!(c.default??!1));else if(c.type==="enum")if(c.multiple){const w=Array.isArray(c.default)?c.default:[];f=await Te(a,m,c.values,w)}else{const w=typeof c.default=="string"?c.default:void 0;f=await be(a,m,c.values,w)}else{const w=c.default===void 0?"":` (${String(c.default)})`,v=await q(a,Se(`${m}${w}`));if(v===""&&c.default!==void 0)f=c.default;else if(v===""){if(c.required)throw new Error(`Variable "${o}" is required`);continue}else f=U(c,v)}B(o,c,f),i[o]=f}return i}finally{a?.close()}},Ee=["git://","npm://","https://","github:","gitlab:","bitbucket:","sourcehut:"],ke=t=>Ee.some(e=>t.startsWith(e)),Oe=async(t,e={})=>{const r=e.targetDirectory===void 0,s=e.targetDirectory??ce(T(fe(),"vis-generate-")),n=()=>{if(r)try{le(s,{force:!0,recursive:!0})}catch{}};l.info(`Downloading ${t}…`);try{const i=await ue(t,{auth:e.auth||process.env.GIGET_AUTH||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,dir:s,force:!0,preferOffline:e.preferOffline});return{cleanup:n,directory:i.dir}}catch(i){n();const a=i instanceof Error?i.message:String(i);throw l.warn(`Failed to download template: ${a}`),i}},z=(t,e="")=>{const r=[];for(const[s,n]of Object.entries(t)){const i=e?`${e}/${s}`:s;typeof n=="string"||Buffer.isBuffer(n)?r.push({content:n,path:i}):n&&typeof n=="object"&&r.push(...z(n,i))}return r},_e=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,xe=(t,e)=>{if(P(e))throw new Error(`Refusing to write outside destination: template produced absolute path "${e}".`);const r=T(t,e),s=K(t,r);if(s===".."||s.startsWith(`..${se}`)||P(s))throw new Error(`Refusing to write outside destination: "${e}" resolves to "${r}" which escapes "${t}".`);return r},Ie=(t,e)=>{L(G(t)),ne(t,e)},qe=(t,e,r=!1)=>{const s=typeof t=="string"?[t]:t.commands,n=typeof t=="string"?r:t.silent??r;for(const i of s){n||l.info(`$ ${i}`);const a=pe(i,{cwd:e,shell:!0,stdio:n?"ignore":"inherit"});if(a.status!==0)return l.warn(`Script failed (exit ${String(a.status)}): ${i}`),!1}return!0},De=t=>{const e=new Map;for(const r of t){const s=typeof r=="string"?0:r.phase??0,n=e.get(s);n?n.push(r):e.set(s,[r])}return[...e.entries()].sort(([r],[s])=>r-s)},We=async(t,e)=>{const r={builtins:{dest_dir:e.destination,dest_rel_dir:K(e.workspaceRoot,e.destination)||".",working_dir:e.cwd,workspace_root:e.workspaceRoot},options:e.options},s=await t.produce(r),n=s.files?z(s.files):[],i=s.filesMeta??{},a=[];for(const o of n){const c=xe(e.destination,o.path);a.push({file:o,meta:i[o.path]??{},target:c})}if(e.dryRun){l.info(`${g(y("Plan"))} ${u("(dry-run, no files written)")}`);for(const o of a){const c=Buffer.isBuffer(o.file.content)?o.file.content.length:Buffer.byteLength(o.file.content,"utf8");process.stderr.write(` ${u("write")} ${o.file.path} ${u(`(${_e(c)})`)}
10
- `)}}else{L(e.destination);let o=0,c=0;for(const m of a){const{file:f,meta:w,target:v}=m,D=j(v),b=e.force||w.force===!0;if(D&&!b){l.warn(`Skipped existing file: ${f.path} (use --force or set frontmatter force: true to overwrite)`),c+=1;continue}Ie(v,f.content),o+=1}l.success(`Wrote ${String(o)} file${o===1?"":"s"}${c>0?`, skipped ${String(c)}`:""}`)}if(!e.dryRun&&!e.skipScripts&&s.scripts&&s.scripts.length>0){const o=De(s.scripts);l.info(`Running ${String(s.scripts.length)} script${s.scripts.length===1?"":"s"} across ${String(o.length)} phase${o.length===1?"":"s"}…`);for(const[,c]of o)if((await Promise.all(c.map(m=>Promise.resolve(qe(m,e.destination))))).includes(!1))throw new Error("Script failed — aborting.")}if(s.suggestions&&s.suggestions.length>0){process.stderr.write(`
11
- `),l.notice("Next steps:");for(const o of s.suggestions)process.stderr.write(` ${u("•")} ${o}
12
- `)}},Be=async t=>{let e;try{e=(await t.load()).about?.description}catch{}return{description:e,name:t.name,path:t.path,source:t.source}},Pe=(t,e)=>{const r={default:e.default,name:t,order:e.order,prompt:e.prompt,required:e.required,type:e.type};return e.type==="enum"&&(r.multiple=e.multiple,r.values=e.values),r},Ae=async t=>{const e=await t.load(),r=Object.entries(e.options??{}).sort(([s,n],[i,a])=>{const o=n.order??0,c=a.order??0;return o===c?s.localeCompare(i):o-c}).map(([s,n])=>Pe(s,n));return{description:e.about?.description??"",destination:e.destination,name:t.name,path:t.path,source:t.source,variables:r}},Ce=t=>{if(t.length===0){l.info("No templates found."),l.notice("Create one at .vis/templates/<name>.ts (programmatic) or .vis/templates/<name>/ (moon-format with template.yml).");return}l.info("Available templates:");for(const e of t){const r=u(`(${e.source})`);process.stderr.write(` ${g(y(e.name))} ${r}
13
- `)}},Me=(t,e)=>{const r={},s=[];for(let n=0;n<t.length;n++){const i=t[n];if(!i.startsWith("--")){s.push(i);continue}const a=i.indexOf("=");if(a===-1){const m=i.slice(2);if(m.startsWith("no-"))r[m.slice(3)]="false";else{r[m]="true";const f=t[n+1];f!==void 0&&!f.startsWith("-")&&e?.(`\`--${m} ${f}\` was read as boolean \`--${m}=true\` and \`${f}\` was ignored. For a string value use \`--${m}=${f}\`.`)}continue}const o=i.slice(2,a),c=i.slice(a+1);r[o]=c}return{overrides:r,remaining:s}},Fe=async t=>{const{createInterface:e}=await import("node:readline"),r=e({input:process.stdin,output:process.stderr});try{process.stderr.write(` ${g(y("vis generate"))} ${u("— pick a template")}
14
-
15
- `);for(const[s,n]of t.entries()){const i=g(y(` ${String(s+1)}.`));process.stderr.write(`${i} ${n.name} ${u(`(${n.source})`)}
16
- `)}return new Promise((s,n)=>{r.question(`
17
- ${u(`Enter choice (1-${String(t.length)}):`)} `,i=>{const a=Number.parseInt(i.trim(),10);Number.isInteger(a)&&a>=1&&a<=t.length?s(t[a-1].name):n(new Error("Invalid choice."))})})}finally{r.close()}},Le=async({argument:t,options:e,rawUnknown:r,visConfig:s,workspaceRoot:n})=>{const i=e.cwd||n||process.cwd(),a=n??i,o=s?.generator,c=Array.isArray(t)?t:t?[t]:[];if(e.list){const p=I({extraDirectories:o?.templates??[],onWarning:d=>{l.warn(d)},workspaceRoot:a});if(e.json){const d=await Promise.all(p.map(h=>Be(h)));process.stdout.write(`${JSON.stringify(d,null,2)}
18
- `);return}Ce(p);return}if(e.describe){const p=c[0];if(!p)throw new Error("`--describe` requires a template name. Run `vis generate --list` to see available templates.");const d=I({extraDirectories:o?.templates??[],onWarning:$=>{l.warn($)},workspaceRoot:a}).find($=>$.name===p);if(!d)throw new Error(`Template "${p}" not found. Run \`vis generate --list\` to see available templates.`);const h=await Ae(d);if(e.json){process.stdout.write(`${JSON.stringify(h,null,2)}
19
- `);return}if(l.info(`Template: ${g(y(h.name))} ${u(`(${h.source})`)}`),h.description&&l.info(h.description),h.destination&&l.info(`Destination: ${u(h.destination)}`),h.variables.length===0)l.info("No variables.");else{l.info("Variables:");for(const $ of h.variables){const _=[$.type];$.required&&_.push("required"),$.default!==void 0&&_.push(`default=${JSON.stringify($.default)}`),$.values&&_.push(`values=${$.values.join("|")}`),process.stderr.write(` ${g(y($.name))} ${u(`(${_.join(", ")})`)}
20
- `)}}return}let m=[...r??[]];if(m.length===0){const p=process.argv.slice(2),d=p.indexOf("--");d!==-1&&(m=p.slice(d+1))}const f=c.indexOf("--"),w=f===-1?[]:c.slice(f+1),v=f===-1?c:c.slice(0,f),{overrides:D}=Me([...w,...m],p=>{l.warn(p)});let b,k,O;const N=v[0];let W;if(N&&ke(N)){const p=await Oe(N,{auth:o?.auth,preferOffline:!!e.preferOffline||o?.preferOffline});W=p.cleanup;try{const d=I({extraDirectories:[p.directory],workspaceRoot:a}).find(h=>h.path.startsWith(p.directory));if(!d)throw new Error(`Downloaded template at ${p.directory} contains no template.yml or *.ts entrypoint.`);b=await d.load(),k=d.name,O=b.destination}catch(d){throw W(),d}}else{const p=I({extraDirectories:o?.templates??[],onWarning:$=>{l.warn($)},workspaceRoot:a});if(p.length===0)throw new Error("No templates found. Create one at .vis/templates/<name>.ts or .vis/templates/<name>/template.yml.");let d;if(N)d=N;else{if(e.interactive===!1||!process.stdin.isTTY)throw new Error("No template specified. Pass a template name (see `vis generate --list`) or run interactively in a terminal.");d=await Fe(p)}const h=p.find($=>$.name===d);if(!h)throw new Error(`Template "${d}" not found. Run 'vis generate --list' to see available templates.`);b=await h.load(),k=h.name,O=b.destination}const A=e.to,C=!!e.dryRun,Q=!!e.force,M=!!e.defaults,X=!!e.skipScripts,Z=e.interactive!==!1&&!!process.stdin.isTTY&&!M;let S;A?S=A:O?S=O:S=".";const F=P(S)?S:oe(i,S);l.info(`Template: ${g(y(k))}`),l.info(`Target: ${u(F)}`),process.stderr.write(`
21
- `);const ee=await je({defaults:M,interactive:Z,overrides:D,variables:b.options??{}});try{await We(b,{cwd:i,destination:F,dryRun:C,force:Q,options:ee,skipScripts:X,workspaceRoot:a}),C||(process.stderr.write(`
22
- `),l.success(`Template '${k}' applied.`))}finally{W?.()}};export{Le as default};
1
+ import{createRequire as G}from"node:module";import{I as F,q as L,j as N,E as O}from"../packem_shared/index.server-J83sowC4.js";import{y as E}from"../packem_shared/index-CE6MsgcV.js";import{X as U}from"./cli-main.js";import{d as A,f as C,r as X,a as D,b as Q,s as Y,c as Z,e as ee,g as te,h as se,i as re,j as ie,k as ne,l as oe,m as ae,n as de,o as ce,p as fe,q as pe,t as le}from"../packem_shared/watch-loop-BZudYfcl.js";import{p as h}from"./catalog.js";const H=G(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=t=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[e,s]=k.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return k.getBuiltinModule(t)}return H(t)},{createHash:q}=I("node:crypto"),ue=t=>t.startsWith("/")||/^[a-z]:[\\/]/i.test(t),_=(t,e)=>ue(e)?e:`${t}/${e}`,ge={argsCheck:(t,e)=>T(t,e,"check"),argsFix:(t,e)=>T(t,e,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(t,e)=>{const s=["dprint",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=A(e,h.dprint.packageNames[0]),r=C(t,h.dprint.configFiles);if(!(!s&&!r))return{adapter:"dprint",configFile:r,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","css","cts","dockerfile","html","js","json","jsonc","jsx","md","mdx","mjs","mts","toml","ts","tsx","yaml","yml"],id:"dprint",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const r of t.stdout.split(/\r?\n/)){const i=r.trim();!i||i.startsWith("[")||i.startsWith("Checked ")||i.startsWith("Error:")||s.push({adapter:"dprint",file:_(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},T=(t,e,s)=>{const r=s==="fix"?["fmt"]:["check","--list-different"];return e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},me={argsCheck:(t,e)=>B(t,e,"check"),argsFix:(t,e)=>B(t,e,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(t,e)=>{const s=["oxfmt",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=A(e,h.oxfmt.packageNames[0]),r=C(t,h.oxfmt.configFiles);if(!(!s&&!r))return{adapter:"oxfmt",configFile:r,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const r of t.stdout.split(/\r?\n/)){const i=r.trim();!i||i.startsWith("[")||s.push({adapter:"oxfmt",file:_(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},B=(t,e,s)=>{const r=s==="fix"?["--write"]:["--list-different"];return e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},he={argsCheck:(t,e)=>P(t,e,"check"),argsFix:(t,e)=>P(t,e,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(t,e)=>{const s=["prettier",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=A(e,h.prettier.packageNames[0]),r=C(t,h.prettier.configFiles);if(!(!s&&!r))return{adapter:"prettier",configFile:r,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const r of t.stdout.split(/\r?\n/)){const i=r.trim();i&&(i.startsWith("[")||s.push({adapter:"prettier",file:_(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},P=(t,e,s)=>{const r=s==="fix"?["--write"]:["--list-different"];return e.quiet&&r.push("--log-level","warn"),e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},xe=[me,de,ge,he,ce,fe],qe=async({logger:t,options:e,visConfig:s,workspaceRoot:r})=>{const i=r??process.cwd(),u=s?.fmt,w=X(xe,u?.order),K=D(i,w),x=Q(K,w,"fmt").filter(({adapter:p})=>u?.adapters?.[p.id]?.enabled!==!1);if(x.length===0){t.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff, deno-fmt).");return}const $=p=>{const o=u?.adapters?.[p]?.extraArgs;return o&&o.length>0?[...o]:void 0},j={quiet:e.quiet??!1},R=ke(e),y=e.check?"check":"fix";let d;if(e.staged){if(d=Y(i),d===void 0)t.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(d.length===0){t.info(F("✓ fmt: no staged files"));return}}else if(typeof e.since=="string"&&e.since.length>0){if(d=Z(i,e.since),d===void 0)t.warn(`vis fmt: could not resolve --since ${e.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(d.length===0){t.info(F(`✓ fmt: no files changed since ${e.since}`));return}}const z=U(i,void 0,void 0,!0),v=e.format??"human";v==="human"&&e.output!==void 0&&t.warn("vis fmt: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=async p=>{const o=R.length>0?R:p,g=[];if(o){const n=te(o,x,u?.extensionOverrides);for(const{adapter:a,presence:c}of x){const f=n.get(a.id);if(!f||f.length===0)continue;const W=$(a.id),V={adapter:a,files:f,presence:c};W&&(V.options={...j,extraArgs:W}),g.push(V)}}else for(const{adapter:n,presence:a}of x){const c=$(n.id),f={adapter:n,files:["."],presence:a};c&&(f.options={...j,extraArgs:c}),g.push(f)}if(g.length===0)return;const J=await se(g,j,y,{cacheRoot:z}),b=g.map((n,a)=>{const c=J[a],f=n.adapter.parse(c,n.presence);return{adapter:n.adapter,durationMs:c.durationMs,exitCode:c.exitCode,findings:f}}),l=re(b.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,exitCode:n.exitCode,findingCount:n.findings.length,findings:n.findings}))),m=v==="human"?void 0:ie({cwd:i,target:e.output});try{switch(v){case"github":{m.write(ae({runs:b.map(n=>({findings:n.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:l.findings,mode:y,runs:l.runs},null,2)}
2
+ `);break}case"junit":{m.write(oe({runs:b.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,findings:n.findings})),workspaceRoot:i}));break}case"minimal":{ye(l.findings,i,m);break}case"sarif":{m.write(ne({runs:b.map(n=>({adapter:n.adapter.id,findings:n.findings,presence:g.find(a=>a.adapter.id===n.adapter.id)?.presence})),workspaceRoot:i}));break}default:we(l.findings,i,y,t)}}finally{m?.close()}const S=y==="fix"?l.hadProcessFailure?1:0:le({...l,maxSeverity:l.findings.length>0?"error":void 0});S!==0&&(process.exitCode=S)};if(e.watch){const p=[...new Set(x.flatMap(({adapter:o})=>o.extensions))];await ee({extensions:p,initialFiles:d,label:"fmt",log:o=>{t.info(o)},runCycle:M,workspaceRoot:i});return}await M(d)},ke=t=>{const e=t;return[...e._??e.args??[]]},we=(t,e,s,r)=>{if(t.length===0){r.info(F(s==="fix"?" fmt: nothing to change":"✓ fmt: all files already formatted"));return}const i=pe(t),u=s==="fix"?L(N("Formatted:")):N("Would change:");r.info(u);for(const w of i.keys())r.info(` ${O("·")} ${E(e,w)}`);s==="check"&&(r.info(""),r.info(O(`Run \`vis fmt\` to apply changes (${String(i.size)} file${i.size===1?"":"s"}).`)))},ye=(t,e,s)=>{for(const r of t)s.write(`${r.adapter} ${E(e,r.file)}
3
+ `)};export{qe as default};
@@ -1,61 +1,22 @@
1
- import{v as F,H as P,y as S,m as b,T as I,O as U,a as T}from"../packem_shared/index-CE6MsgcV.js";import _ from"./index.js";import{b as J,l as M}from"./catalog.js";import{n as q}from"../packem_shared/manifests-WBnsV_Eb.js";import{Z as C,a0 as B}from"./cli-main.js";import{s as H}from"../packem_shared/glob-fqg4KepW-1S3z30c8.js";const K=(e,t)=>{const o=t.replace(/^\.?\//,"");return o===""||o==="."?`/${e}/`:e===""||e==="."?`/${o}`:`/${e}/${o}`},v=(e,t,o=[])=>{const s=[],n=new Set;for(const[r,a]of Object.entries(t?.globalPaths??{}))s.push({owners:a,path:r,source:"project-json"}),n.add(r);for(const[r,a]of Object.entries(e.projects)){const i=a.owners??[];for(const c of i){const f=K(a.root??r,c.path);s.push({channel:c.channel,owners:c.owners,path:f,projectId:r,source:"project-json"}),n.add(f)}}for(const r of o)n.has(r.path)||(s.push(r),n.add(r.path));return(t?.orderBy??"file-source")==="project-id"?s.sort((r,a)=>(r.projectId??"").localeCompare(a.projectId??"")||r.path.localeCompare(a.path)):s.sort((r,a)=>r.path.localeCompare(a.path)),s},z="Update each project's project.json `owners` field and re-run the command.",Y=e=>["# CODEOWNERS generated by `vis sync codeowners`. Do not edit by hand.",e?`# Re-run with: ${e}`:`# ${z}`,""],W=e=>{const t=[];for(const o of e){const s=o.owners.join(" "),n=o.channel?` # notify: ${o.channel}`:"";t.push(`${o.path} ${s}${n}`)}return t},Q=(e,t={})=>[...Y(t.regenerationCommand),...W(e),""].join(`
2
- `),O={begin:"# BEGIN vis-codeowners",end:"# END vis-codeowners"},V=(e,t=O,o={})=>{const s=o.regenerationCommand?`# Generated by vis sync codeowners — re-run with: ${o.regenerationCommand}`:"# Generated by `vis sync codeowners` — do not edit by hand.";return[t.begin,s,...W(e),t.end].join(`
3
- `)},X=(e,t,o=O)=>{const s=e.indexOf(o.begin),n=e.indexOf(o.end);if(s!==-1&&n!==-1&&n>s){const a=e.slice(0,s),i=n+o.end.length,c=e.slice(i);return`${a}${t}${c}`}const r=e.replace(/\s+$/u,"");return`${r.length===0?"":`${r}
1
+ import{createRequire as te}from"node:module";import{E as u,j as g,q as y}from"../packem_shared/index.server-J83sowC4.js";import{m as T,f as j,I as V,H as G,y as K,a as L,A as P,o as se,T as ne,B as oe}from"../packem_shared/index-CE6MsgcV.js";import{f as ue}from"../packem_shared/giget-DVTFJlbR.js";import{p as l}from"./cli-main.js";const re=te(import.meta.url),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=t=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[e,r]=R.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return R.getBuiltinModule(t)}return re(t)},{fileURLToPath:ie}=E("node:url"),{createInterface:ae}=E("node:readline"),{mkdtempSync:ce,rmSync:le}=E("node:fs"),{tmpdir:fe}=E("node:os"),{spawnSync:pe}=E("node:child_process"),J=[".ts",".mts",".cts",".js",".mjs",".cjs"],de="template.yml",me=[".d",".test",".spec",".config",".bench",".stories"],he=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],Y=t=>{for(const e of J)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(he.some(r=>t.endsWith(r))||!J.some(r=>t.endsWith(r)))return!1;const e=Y(t);return!me.some(r=>e.endsWith(r))},H=(t,e)=>{const r=[];if(!j(t))return r;for(const s of V(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(s.name))continue;const n=Y(s.name);r.push({load:()=>ge(s.path),name:n,path:s.path,source:e})}return r},x=(t,e)=>{const r=[];if(!j(t))return r;for(const s of V(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=T(s.path,de);j(n)&&r.push({load:()=>ye(s.path,s.name),name:s.name,path:s.path,source:e})}return r},we=()=>{try{const t=ie(import.meta.url),e=T(G(t),"..","..","templates");return j(e)?e:void 0}catch{return}},I=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...H(T(s,".vis","templates"),"native"),...x(T(s,".vis","templates"),"moon"),...x(T(s,".moon","templates"),"moon")];for(const o of e)n.push(...x(o,"config")),n.push(...H(o,"config"));const i=we();i&&n.push(...x(i,"builtin"));const a=new Map;for(const o of n){const c=a.get(o.name);if(!c){a.set(o.name,o);continue}r&&r(`Template "${o.name}" exists in multiple sources using ${c.source} (${c.path}), ignoring ${o.source} (${o.path}).`)}return[...a.values()].sort((o,c)=>o.name.localeCompare(c.name))},ge=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},ye=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index3.js");return r(t,e)},q=(t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),ve=async(t,e,r)=>{const s=await q(t,` ${e} ${u(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},be=async(t,e,r,s)=>{process.stderr.write(` ${e}
2
+ `);for(const[n,i]of r.entries()){const a=g(y(` ${String(n+1)}.`)),o=i===s?u(" (default)"):"";process.stderr.write(`${a} ${i}${o}
3
+ `)}for(;;){const n=await q(t,`
4
+ ${u(`Enter choice (1-${String(r.length)}):`)} `);if(n===""&&s!==void 0)return s;const i=Number.parseInt(n,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const a=r.find(o=>o===n);if(a)return a;process.stderr.write(` ${u("Invalid choice. Try again.")}
5
+ `)}},Te=async(t,e,r,s)=>{process.stderr.write(` ${e} ${u("(comma-separated numbers)")}
6
+ `);for(const[n,i]of r.entries()){const a=g(y(` ${String(n+1)}.`)),o=s.includes(i)?u(" (default)"):"";process.stderr.write(`${a} ${i}${o}
7
+ `)}for(;;){const n=await q(t,`
8
+ ${u("Enter choices:")} `);if(n===""&&s.length>0)return s;const i=n.split(",").map(a=>Number.parseInt(a.trim(),10)).filter(a=>Number.isInteger(a)&&a>=1&&a<=r.length);if(i.length>0)return i.map(a=>r[a-1]);process.stderr.write(` ${u("Invalid choice. Try again.")}
9
+ `)}},Se=t=>` ${u(`${t}:`)} `,Ne=(t,e)=>e.prompt??t,Re=t=>Object.entries(t).sort(([e,r],[s,n])=>{const i=r.order??0,a=n.order??0;return i!==a?i-a:e.localeCompare(s)}),U=(t,e)=>{switch(t.type){case"array":return e.split(",").map(r=>r.trim()).filter(Boolean);case"boolean":return e==="true"||e==="1"||e==="yes"||e==="y";case"enum":return t.multiple?e.split(",").map(r=>r.trim()).filter(Boolean):e;case"number":{const r=Number(e);if(Number.isNaN(r))throw new TypeError(`Expected a number, got "${e}"`);return r}default:return e}},B=(t,e,r)=>{if(e.type==="enum"){const s=Array.isArray(r)?r:[r];for(const n of s)if(typeof n!="string"||!e.values.includes(n))throw new Error(`Variable "${t}" must be one of: ${e.values.join(", ")} (got "${String(n)}")`)}},je=async t=>{const{defaults:e,interactive:r,overrides:s,variables:n}=t,i={},a=r?ae({input:process.stdin,output:process.stderr}):null;try{for(const[o,c]of Re(n)){if(Object.hasOwn(s,o)){const w=U(c,s[o]??"");B(o,c,w),i[o]=w;continue}if(e||!r||c.internal){if(c.default!==void 0){B(o,c,c.default),i[o]=c.default;continue}if(c.required)throw new Error(`Required variable "${o}" not provided. Pass --${o}=<value> or remove --defaults.`);continue}const m=Ne(o,c);let f;if(c.type==="boolean")f=await ve(a,m,!!(c.default??!1));else if(c.type==="enum")if(c.multiple){const w=Array.isArray(c.default)?c.default:[];f=await Te(a,m,c.values,w)}else{const w=typeof c.default=="string"?c.default:void 0;f=await be(a,m,c.values,w)}else{const w=c.default===void 0?"":` (${String(c.default)})`,v=await q(a,Se(`${m}${w}`));if(v===""&&c.default!==void 0)f=c.default;else if(v===""){if(c.required)throw new Error(`Variable "${o}" is required`);continue}else f=U(c,v)}B(o,c,f),i[o]=f}return i}finally{a?.close()}},Ee=["git://","npm://","https://","github:","gitlab:","bitbucket:","sourcehut:"],ke=t=>Ee.some(e=>t.startsWith(e)),Oe=async(t,e={})=>{const r=e.targetDirectory===void 0,s=e.targetDirectory??ce(T(fe(),"vis-generate-")),n=()=>{if(r)try{le(s,{force:!0,recursive:!0})}catch{}};l.info(`Downloading ${t}…`);try{const i=await ue(t,{auth:e.auth||process.env.GIGET_AUTH||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,dir:s,force:!0,preferOffline:e.preferOffline});return{cleanup:n,directory:i.dir}}catch(i){n();const a=i instanceof Error?i.message:String(i);throw l.warn(`Failed to download template: ${a}`),i}},z=(t,e="")=>{const r=[];for(const[s,n]of Object.entries(t)){const i=e?`${e}/${s}`:s;typeof n=="string"||Buffer.isBuffer(n)?r.push({content:n,path:i}):n&&typeof n=="object"&&r.push(...z(n,i))}return r},_e=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,xe=(t,e)=>{if(P(e))throw new Error(`Refusing to write outside destination: template produced absolute path "${e}".`);const r=T(t,e),s=K(t,r);if(s===".."||s.startsWith(`..${se}`)||P(s))throw new Error(`Refusing to write outside destination: "${e}" resolves to "${r}" which escapes "${t}".`);return r},Ie=(t,e)=>{L(G(t)),ne(t,e)},qe=(t,e,r=!1)=>{const s=typeof t=="string"?[t]:t.commands,n=typeof t=="string"?r:t.silent??r;for(const i of s){n||l.info(`$ ${i}`);const a=pe(i,{cwd:e,shell:!0,stdio:n?"ignore":"inherit"});if(a.status!==0)return l.warn(`Script failed (exit ${String(a.status)}): ${i}`),!1}return!0},De=t=>{const e=new Map;for(const r of t){const s=typeof r=="string"?0:r.phase??0,n=e.get(s);n?n.push(r):e.set(s,[r])}return[...e.entries()].sort(([r],[s])=>r-s)},We=async(t,e)=>{const r={builtins:{dest_dir:e.destination,dest_rel_dir:K(e.workspaceRoot,e.destination)||".",working_dir:e.cwd,workspace_root:e.workspaceRoot},options:e.options},s=await t.produce(r),n=s.files?z(s.files):[],i=s.filesMeta??{},a=[];for(const o of n){const c=xe(e.destination,o.path);a.push({file:o,meta:i[o.path]??{},target:c})}if(e.dryRun){l.info(`${g(y("Plan"))} ${u("(dry-run, no files written)")}`);for(const o of a){const c=Buffer.isBuffer(o.file.content)?o.file.content.length:Buffer.byteLength(o.file.content,"utf8");process.stderr.write(` ${u("write")} ${o.file.path} ${u(`(${_e(c)})`)}
10
+ `)}}else{L(e.destination);let o=0,c=0;for(const m of a){const{file:f,meta:w,target:v}=m,D=j(v),b=e.force||w.force===!0;if(D&&!b){l.warn(`Skipped existing file: ${f.path} (use --force or set frontmatter force: true to overwrite)`),c+=1;continue}Ie(v,f.content),o+=1}l.success(`Wrote ${String(o)} file${o===1?"":"s"}${c>0?`, skipped ${String(c)}`:""}`)}if(!e.dryRun&&!e.skipScripts&&s.scripts&&s.scripts.length>0){const o=De(s.scripts);l.info(`Running ${String(s.scripts.length)} script${s.scripts.length===1?"":"s"} across ${String(o.length)} phase${o.length===1?"":"s"}…`);for(const[,c]of o)if((await Promise.all(c.map(m=>Promise.resolve(qe(m,e.destination))))).includes(!1))throw new Error("Script failed — aborting.")}if(s.suggestions&&s.suggestions.length>0){process.stderr.write(`
11
+ `),l.notice("Next steps:");for(const o of s.suggestions)process.stderr.write(` ${u("•")} ${o}
12
+ `)}},Be=async t=>{let e;try{e=(await t.load()).about?.description}catch{}return{description:e,name:t.name,path:t.path,source:t.source}},Pe=(t,e)=>{const r={default:e.default,name:t,order:e.order,prompt:e.prompt,required:e.required,type:e.type};return e.type==="enum"&&(r.multiple=e.multiple,r.values=e.values),r},Ae=async t=>{const e=await t.load(),r=Object.entries(e.options??{}).sort(([s,n],[i,a])=>{const o=n.order??0,c=a.order??0;return o===c?s.localeCompare(i):o-c}).map(([s,n])=>Pe(s,n));return{description:e.about?.description??"",destination:e.destination,name:t.name,path:t.path,source:t.source,variables:r}},Ce=t=>{if(t.length===0){l.info("No templates found."),l.notice("Create one at .vis/templates/<name>.ts (programmatic) or .vis/templates/<name>/ (moon-format with template.yml).");return}l.info("Available templates:");for(const e of t){const r=u(`(${e.source})`);process.stderr.write(` ${g(y(e.name))} ${r}
13
+ `)}},Me=(t,e)=>{const r={},s=[];for(let n=0;n<t.length;n++){const i=t[n];if(!i.startsWith("--")){s.push(i);continue}const a=i.indexOf("=");if(a===-1){const m=i.slice(2);if(m.startsWith("no-"))r[m.slice(3)]="false";else{r[m]="true";const f=t[n+1];f!==void 0&&!f.startsWith("-")&&e?.(`\`--${m} ${f}\` was read as boolean \`--${m}=true\` and \`${f}\` was ignored. For a string value use \`--${m}=${f}\`.`)}continue}const o=i.slice(2,a),c=i.slice(a+1);r[o]=c}return{overrides:r,remaining:s}},Fe=async t=>{const{createInterface:e}=await import("node:readline"),r=e({input:process.stdin,output:process.stderr});try{process.stderr.write(` ${g(y("vis generate"))} ${u("— pick a template")}
4
14
 
5
- `}${t}
6
- `},Z=["**/CODEOWNERS"],ee=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"],te=e=>{const t=[];for(const o of e.split(/\r?\n/u)){const s=o.indexOf("#"),n=(s===-1?o:o.slice(0,s)).trim();if(n.length===0)continue;const r=n.split(/\s+/u);if(r.length<2)continue;const[a,...i]=r,c=i.filter(f=>f.length>0);!a||c.length===0||t.push({owners:c,path:a})}return t},oe=(e,t)=>{const o=t.replace(/^\.\/?/,"").replace(/\/$/,"");return e.startsWith("/")?o===""?e:`/${o}${e}`:o===""?`/${e}`:`/${o}/${e}`},ne=async(e,t,o)=>{const s=t&&t.length>0?[...t]:[...Z],n=[...ee];if(o){const i=o.replace(/^\.\/?/,"").replace(/^\/+/,"");i.length>0&&n.push(i)}const r=await H(s,{absolute:!0,cwd:e,ignore:n}),a=[];for(const i of r){let c;try{c=F(i)}catch{continue}const f=P(i),h=S(e,f);for(const p of te(c))a.push({owners:p.owners,path:oe(p.path,h)})}return a},re=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)/iu,se=e=>{if(!e)return;const t=e.match(re);if(!t?.[1])return;const o=t[1].trim();if(!(o===""||o.includes(" ")))return`@${o.replace(/^@/,"")}`},ie=(e,t)=>{const o=[];for(const[s,n]of Object.entries(e.projects)){if(n.owners&&n.owners.length>0)continue;const r=n.root??s,a=b(t,r,"package.json"),i=C(a);if(!i)continue;const c=q(i.maintainers);if(!c||c.length===0)continue;const f=[],h=new Set;for(const p of c){const $=se(p.url);$&&!h.has($)&&(h.add($),f.push($))}f.length!==0&&o.push({owners:f,path:r===""||r==="."?"/":`/${r}/`,projectId:s})}return o},ae=["author","bugs","homepage","license","repository","engines"],N=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),E=(e,t)=>{if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(const[o,s]of e.entries())if(!E(s,t[o]))return!1;return!0}if(typeof e=="object"&&typeof t=="object"){const o=Object.keys(e),s=Object.keys(t);if(o.length!==s.length)return!1;for(const n of o)if(!E(e[n],t[n]))return!1;return!0}return!1},R=e=>e===void 0?e:structuredClone(e),ce=(e,t,o)=>{if(e==="repository"&&N(t)&&N(o)){const s={};for(const[n,r]of Object.entries(t))n!=="directory"&&(s[n]=R(r));return typeof o.directory=="string"&&(s.directory=o.directory),s}return R(t)},de=(e,t,o)=>{const s=[];for(const n of o.fields){if(!Object.hasOwn(e,n))continue;const r=e[n],a=t[n],i=ce(n,r,a);E(i,a)||s.push({after:i,before:a,field:n,packageJsonPath:""})}return s},fe=(e,t)=>{for(const o of t)e[o.field]=o.after},x="Generated by `vis sync codeowners --write-guard`. Do not edit by hand.",le=e=>{const t=e.replace(/^\.?\/+/u,"").replace(/\/+$/u,"");return t===""||t==="."?"**":`${t}/**`},D=e=>{const t=new Set,o=[];for(const s of[...e].sort((n,r)=>n.name.localeCompare(r.name))){const n=le(s.root);t.has(n)||(t.add(n),o.push(n))}return o},pe=e=>{const t=D(e),o=t.map(n=>` - "${n}"`).join(`
7
- `),s=t.map(n=>` ${n}`).join(`
8
- `);return`# ${x}
9
- name: Write Guard
10
-
11
- on:
12
- pull_request:
13
- paths:
14
- ${o}
15
-
16
- permissions:
17
- contents: read
18
- pull-requests: read
19
-
20
- jobs:
21
- write-guard:
22
- runs-on: ubuntu-latest
23
- steps:
24
- - uses: actions/checkout@v4
25
- with:
26
- fetch-depth: 0
27
- - uses: geritol/write-guard@v1
28
- with:
29
- codeowners: CODEOWNERS
30
- paths: |
31
- ${s}
32
- `},ue=e=>{const t=D(e).map(o=>` - "${o}/*"`).join(`
33
- `);return`# ${x}
34
- #
35
- # SOFT GUARD ONLY — this job does NOT block a merge by itself.
36
- # It verifies the generated CODEOWNERS is in sync and flags that a
37
- # restricted path changed. GitLab CI cannot portably gate a merge on
38
- # code-owner *approval* from a job, so REAL ENFORCEMENT REQUIRES the
39
- # native GitLab setting:
40
- # Settings -> Repository -> Protected branches ->
41
- # "Require approval from Code Owners" (GitLab Premium / Ultimate)
42
- # https://docs.gitlab.com/ee/user/project/codeowners/
43
- # Without that setting enabled, this job is advisory only.
44
- write-guard:
45
- stage: test
46
- image: node:22-alpine
47
- rules:
48
- - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
49
- changes:
50
- ${t}
51
- script:
52
- - corepack enable
53
- - pnpm install --frozen-lockfile
54
- - pnpm vis sync codeowners --check
55
- - >-
56
- echo "SOFT GUARD: a restricted path changed. This job does NOT enforce
57
- code-owner approval. Enable 'Require approval from Code Owners' on the
58
- protected branch (GitLab Premium/Ultimate) for a real merge gate:
59
- https://docs.gitlab.com/ee/user/project/codeowners/"
60
- `},he=e=>e.length===0?[]:[{content:pe(e),path:".github/workflows/write-guard.yml"},{content:ue(e),path:".gitlab/write-guard.gitlab-ci.yml"}],L=new Set(["nested-codeowners","package-json-maintainers","project-json"]),A=(e,t,o)=>{const s=new Set,n=[];for(const r of e??[])for(const a of r.split(",")){const i=a.trim();if(i.length===0)continue;if(o&&!o(i))throw new Error(`Unknown codeowners source: "${i}". Known: ${[...L].join(", ")}.`);const c=i;s.has(c)||(s.add(c),n.push(c))}return n.length>0?n:[...t]},ge=e=>L.has(e),G=["codeowners","package-json-fields"],me=(e,t)=>t.some(o=>_(o,e)),we=async(e,t,o,s,n)=>{const r=Object.entries(s.projects).filter(([,i])=>i.restricted===!0).map(([i,c])=>({name:i,root:c.root??i})),a=he(r);if(a.length===0){t.info("No projects flagged `restricted: true` in project.json. Skipping Write Guard.");return}if(n){let i=!1;for(const c of a){const f=b(o,c.path);let h="";try{h=await e.readFile(f,"utf8")}catch(p){if(p.code!=="ENOENT")throw p}h.trim()!==c.content.trim()&&(t.error(`${c.path} is out of date. Run \`vis sync codeowners --write-guard\` to update it.`),i=!0)}i?process.exitCode=1:t.info(`Write Guard CI is up to date (${a.length} files, ${r.length} restricted projects).`);return}for(const i of a){const c=b(o,i.path);T(P(c)),I(c,i.content),t.info(`Wrote ${i.path}`)}t.info(`Write Guard CI scoped to ${r.length} restricted project${r.length===1?"":"s"}.`)},$e=async({fs:e,logger:t,options:o,visConfig:s,workspaceRoot:n})=>{const r=n,{workspace:a}=J(r,s),i=s?.codeowners;o.writeGuard===!0&&await we(e,t,r,a,o.check===!0);const c=A(o.from,i?.sources??["project-json"],ge),f=o.regenerationCommand??i?.regenerationCommand,h=o.preserveBlock===!0||i?.preserveBlock===!0,p=i?.blockMarker??O,$=o.nestedIncludes??i?.nestedIncludes,g=o.out??"CODEOWNERS",w=[];if(c.includes("nested-codeowners")){const m=await ne(r,$,g);for(const j of m)w.push({...j,source:"nested"})}if(c.includes("package-json-maintainers")){const m=ie(a,r);for(const j of m)w.push({...j,source:"maintainers"})}const l=c.includes("project-json")?v(a,i,w):v({projects:{}},i,w);if(l.length===0){t.info("No `owners` entries found in any source. Nothing to sync.");return}const y=b(r,g);let d="";try{d=await e.readFile(y,"utf8")}catch(m){if(m.code!=="ENOENT")throw m}const u={regenerationCommand:f},k=h?X(d,V(l,p,u),p):Q(l,u);if(o.check){if(d.trim()!==k.trim()){t.error(`${y} is out of date. Run \`vis sync codeowners\` to update it.`),process.exitCode=1;return}t.info(`${y} is up to date.`);return}I(y,k),t.info(`Wrote ${l.length} entries to ${y}`)},ke=({logger:e,options:t,visConfig:o,workspaceRoot:s})=>{const n=s,r=o?.editorconfig??!0,a=C(b(n,"package.json"));if(!a){e.error("Could not read root package.json. Nothing to sync."),process.exitCode=1;return}const i=A(t.fields,ae),c=t.ignorePackageName??[],f=t.check===!0,h=(t.format??"human").toLowerCase(),p=t.quiet===!0,$=B(n).filter(d=>d!=="."),g=[];let w=0;for(const d of $){const u=b(n,d,"package.json"),k=C(u);if(!k)continue;const m=typeof k.name=="string"?k.name:void 0;if(m!==void 0&&c.length>0&&me(m,c))continue;w+=1;const j=de(a,k,{fields:i});j.length!==0&&g.push({filePath:u,packageJsonPath:S(n,u),packageName:m,pkg:k,pkgChanges:j})}if(!f)for(const d of g)fe(d.pkg,d.pkgChanges),U(d.filePath,d.pkg,{indent:M(d.filePath,{useEditorconfig:r}),overwrite:!0});const l=g.flatMap(d=>d.pkgChanges.map(u=>({after:u.after,before:u.before,field:u.field,packageJsonPath:d.packageJsonPath,packageName:d.packageName}))),y={changes:l,fields:i,kind:"package-json-fields",mode:f?"check":"write",totalChanges:l.length,totalPackages:w};if(h==="json")process.stdout.write(`${JSON.stringify(y,null,4)}
61
- `);else if(l.length===0)e.info(`All ${w} package${w===1?"":"s"} in sync (fields: ${i.join(", ")}).`);else if(f){if(!p)for(const d of l)e.error(`${d.packageJsonPath}: ${d.field} drifts from root`);e.error(`Found ${l.length} field drift${l.length===1?"":"s"} across ${g.length} package${g.length===1?"":"s"}. Run \`vis sync package-json-fields\` to fix.`)}else{if(!p)for(const d of g)e.info(`${d.packageJsonPath}: synced ${d.pkgChanges.map(u=>u.field).join(", ")}`);e.info(`Synced ${l.length} field${l.length===1?"":"s"} across ${g.length} package${g.length===1?"":"s"}.`)}f&&l.length>0&&(process.exitCode=1)},ve=async e=>{const t=e.argument[0];if(!t)throw new Error(`Missing sync kind. Usage: vis sync <kind> (known kinds: ${G.join(", ")})`);if(!e.workspaceRoot)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(t==="codeowners"){await $e(e);return}if(t==="package-json-fields"){ke(e);return}throw new Error(`Unknown sync kind: "${t}". Known kinds: ${G.join(", ")}.`)};export{ve as default};
15
+ `);for(const[s,n]of t.entries()){const i=g(y(` ${String(s+1)}.`));process.stderr.write(`${i} ${n.name} ${u(`(${n.source})`)}
16
+ `)}return new Promise((s,n)=>{r.question(`
17
+ ${u(`Enter choice (1-${String(t.length)}):`)} `,i=>{const a=Number.parseInt(i.trim(),10);Number.isInteger(a)&&a>=1&&a<=t.length?s(t[a-1].name):n(new Error("Invalid choice."))})})}finally{r.close()}},Le=async({argument:t,options:e,rawUnknown:r,visConfig:s,workspaceRoot:n})=>{const i=e.cwd||n||process.cwd(),a=n??i,o=s?.generator,c=Array.isArray(t)?t:t?[t]:[];if(e.list){const p=I({extraDirectories:o?.templates??[],onWarning:d=>{l.warn(d)},workspaceRoot:a});if(e.json){const d=await Promise.all(p.map(h=>Be(h)));process.stdout.write(`${JSON.stringify(d,null,2)}
18
+ `);return}Ce(p);return}if(e.describe){const p=c[0];if(!p)throw new Error("`--describe` requires a template name. Run `vis generate --list` to see available templates.");const d=I({extraDirectories:o?.templates??[],onWarning:$=>{l.warn($)},workspaceRoot:a}).find($=>$.name===p);if(!d)throw new Error(`Template "${p}" not found. Run \`vis generate --list\` to see available templates.`);const h=await Ae(d);if(e.json){process.stdout.write(`${JSON.stringify(h,null,2)}
19
+ `);return}if(l.info(`Template: ${g(y(h.name))} ${u(`(${h.source})`)}`),h.description&&l.info(h.description),h.destination&&l.info(`Destination: ${u(h.destination)}`),h.variables.length===0)l.info("No variables.");else{l.info("Variables:");for(const $ of h.variables){const _=[$.type];$.required&&_.push("required"),$.default!==void 0&&_.push(`default=${JSON.stringify($.default)}`),$.values&&_.push(`values=${$.values.join("|")}`),process.stderr.write(` ${g(y($.name))} ${u(`(${_.join(", ")})`)}
20
+ `)}}return}let m=[...r??[]];if(m.length===0){const p=process.argv.slice(2),d=p.indexOf("--");d!==-1&&(m=p.slice(d+1))}const f=c.indexOf("--"),w=f===-1?[]:c.slice(f+1),v=f===-1?c:c.slice(0,f),{overrides:D}=Me([...w,...m],p=>{l.warn(p)});let b,k,O;const N=v[0];let W;if(N&&ke(N)){const p=await Oe(N,{auth:o?.auth,preferOffline:!!e.preferOffline||o?.preferOffline});W=p.cleanup;try{const d=I({extraDirectories:[p.directory],workspaceRoot:a}).find(h=>h.path.startsWith(p.directory));if(!d)throw new Error(`Downloaded template at ${p.directory} contains no template.yml or *.ts entrypoint.`);b=await d.load(),k=d.name,O=b.destination}catch(d){throw W(),d}}else{const p=I({extraDirectories:o?.templates??[],onWarning:$=>{l.warn($)},workspaceRoot:a});if(p.length===0)throw new Error("No templates found. Create one at .vis/templates/<name>.ts or .vis/templates/<name>/template.yml.");let d;if(N)d=N;else{if(e.interactive===!1||!process.stdin.isTTY)throw new Error("No template specified. Pass a template name (see `vis generate --list`) or run interactively in a terminal.");d=await Fe(p)}const h=p.find($=>$.name===d);if(!h)throw new Error(`Template "${d}" not found. Run 'vis generate --list' to see available templates.`);b=await h.load(),k=h.name,O=b.destination}const A=e.to,C=!!e.dryRun,Q=!!e.force,M=!!e.defaults,X=!!e.skipScripts,Z=e.interactive!==!1&&!!process.stdin.isTTY&&!M;let S;A?S=A:O?S=O:S=".";const F=P(S)?S:oe(i,S);l.info(`Template: ${g(y(k))}`),l.info(`Target: ${u(F)}`),process.stderr.write(`
21
+ `);const ee=await je({defaults:M,interactive:Z,overrides:D,variables:b.options??{}});try{await We(b,{cwd:i,destination:F,dryRun:C,force:Q,options:ee,skipScripts:X,workspaceRoot:a}),C||(process.stderr.write(`
22
+ `),l.success(`Template '${k}' applied.`))}finally{W?.()}};export{Le as default};