@visulima/vis 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/LICENSE.md +403 -921
- package/README.md +2 -2
- package/dashboard/dist/index.html +12 -12
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +34 -34
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +157 -157
- package/dist/packem_chunks/doctor-probe.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/git.js +4 -3
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler26.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler39.js +6 -6
- package/dist/packem_chunks/handler40.js +1 -75
- package/dist/packem_chunks/handler50.js +1 -1
- package/dist/packem_chunks/handler53.js +1 -1
- package/dist/packem_chunks/handler54.js +1 -1
- package/dist/packem_chunks/handler56.js +6 -6
- package/dist/packem_chunks/handler59.js +73 -9
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler60.js +11 -3
- package/dist/packem_chunks/handler61.js +3 -22
- package/dist/packem_chunks/handler62.js +21 -60
- package/dist/packem_chunks/handler63.js +61 -3
- package/dist/packem_chunks/handler64.js +3 -6
- package/dist/packem_chunks/handler65.js +6 -9
- package/dist/packem_chunks/handler66.js +1 -1
- package/dist/packem_chunks/handler67.js +1 -1
- package/dist/packem_chunks/handler68.js +1 -1
- package/dist/packem_chunks/handler69.js +1 -1
- package/dist/packem_chunks/handler70.js +1 -1
- package/dist/packem_chunks/handler72.js +1 -1
- package/dist/packem_chunks/handler73.js +1 -1
- package/dist/packem_chunks/handler74.js +1 -1
- package/dist/packem_chunks/handler75.js +1 -1
- package/dist/packem_chunks/handler76.js +1 -1
- package/dist/packem_chunks/handler78.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +5 -5
- package/dist/packem_chunks/index6.js +7 -21
- package/dist/packem_chunks/index7.js +47 -47
- package/dist/packem_chunks/prompts.js +1 -1
- package/dist/packem_chunks/resolveFormatter.js +7 -5
- package/dist/packem_chunks/root-handler.js +1 -0
- package/dist/packem_chunks/shell-runner.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/version-resolver.js +3 -2
- package/dist/packem_shared/DEFAULT_BREAKING_SECTION-DUAcKVLD.js +1 -0
- package/dist/packem_shared/DEFAULT_CONVENTIONAL_HEADING-D7oNGUcP.js +1 -0
- package/dist/packem_shared/{affected-selection-DLrq50Mz.js → affected-selection-DP4GM66N.js} +1 -1
- package/dist/packem_shared/{api.d-BPftyU9r.d.ts → api.d-C10vHKJZ.d.ts} +1 -1
- package/dist/packem_shared/{bin-As0Wq5ZN.js → bin-BO1M68aW.js} +1 -1
- package/dist/packem_shared/buildCompareUrl-BLaukjgu.js +1 -0
- package/dist/packem_shared/conventional-CGiOOEq1.js +4 -0
- package/dist/packem_shared/{cyclonedx-B1vzerwP.js → cyclonedx-CX2fFvDi.js} +1 -1
- package/dist/packem_shared/docker-Dy-X_BuM.js +59 -0
- package/dist/packem_shared/hasBulletMarker-BX2KwzI5.js +1 -0
- package/dist/packem_shared/{index-CcVv0V1y.js → index-rcfHhvVo.js} +1 -1
- package/dist/packem_shared/index.server-sXNQYpsl.js +2 -0
- package/dist/packem_shared/main-CgDAlZkm.js +1 -0
- package/dist/packem_shared/{package-version-BFsJ8iyZ.js → package-version-BO37_qsn.js} +1 -1
- package/dist/packem_shared/{project-name-filter-DdXd3P3a.js → project-name-filter-C_mppI1h.js} +1 -1
- package/dist/packem_shared/release-heading-DRpkhETz.js +1 -0
- package/dist/packem_shared/{resolve-explicit-ZZEPWdpP.js → resolve-explicit-CsTmALmE.js} +1 -1
- package/dist/packem_shared/run-D-uVGHQ4.js +10 -0
- package/dist/packem_shared/{s1ngularity-R-zLjQjp.js → s1ngularity-BRk_GMUj.js} +1 -1
- package/dist/packem_shared/{scan-progress-5uTRdC1G.js → scan-progress-DRIGQRMr.js} +1 -1
- package/dist/packem_shared/{typosquats-Cdsnf6aN.js → typosquats-CSkIFgF5.js} +1 -1
- package/dist/packem_shared/{vis-user-error-DJvfOpBX.js → vis-user-error-YIyfYNBK.js} +1 -1
- package/dist/release/core/changelog/index.d.ts +274 -31
- package/dist/release/core/changelog/index.js +1 -1
- package/dist/release/plugin-sdk.d.ts +2 -2
- package/dist/release/types.d.ts +44 -2
- package/index.js +52 -52
- package/package.json +11 -11
- package/schemas/vis-config.schema.json +19 -1
- package/schemas/vis-release-config.schema.json +19 -1
- package/dist/packem_shared/docker-Bex05Qcn.js +0 -59
- package/dist/packem_shared/index.server-BAjDJSEu.js +0 -2
- package/dist/packem_shared/main-BP-w-K-6.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as $,a as l,D as d,T as y}from"../packem_shared/ai-analysis-DSQQDFU9.js";import{E as g,R as x,q as S}from"./catalog.js";import{j as w,F as u,q as E,J as I,b as A}from"../packem_shared/index.server-
|
|
1
|
+
import{c as $,a as l,D as d,T as y}from"../packem_shared/ai-analysis-DSQQDFU9.js";import{E as g,R as x,q as S}from"./catalog.js";import{j as w,F as u,q as E,J as I,b as A}from"../packem_shared/index.server-sXNQYpsl.js";const p={command:"ai",description:"AI-assisted commands: provider detection, cache management, and failure-fix proposals."},D=e=>{if(typeof e!="function")return String(e);const{name:t}=e;return t==="Boolean"?"boolean":t==="Number"?"number":t==="String"?"string":t??"unknown"},R=e=>e===void 0?[]:Array.isArray(e)?e.map(t=>[t.name,t]):Object.entries(e),O=e=>{const t=[...e.commandPath??[],e.name].join(" "),a=(e.examples??[]).map(([n,o])=>({command:n??"",description:o??""})),s=R(e.options).map(([n,o])=>({defaultValue:o.defaultValue,description:o.description,name:n,type:D(o.type)}));return{argument:e.argument?{description:e.argument.description,name:e.argument.name}:void 0,description:e.description??"",examples:a,name:e.name,options:s,path:t}},f=(e,t=p)=>({command:t.command,description:t.description,subcommands:e.map(a=>O(a))}),P=(e,t=p)=>`${JSON.stringify(f(e,t),void 0,2)}
|
|
2
2
|
`,T=(e,t=p)=>{const a=f(e,t),s=[w(`vis ${a.command} — ${a.description}`),"",u("Subcommands:")];for(const n of a.subcommands){const o=n.argument?` ${E(`<${n.argument.name}>`)}`:"";if(s.push(""),s.push(` ${I(`vis ${n.path}`)}${o}`),n.description&&s.push(` ${n.description}`),n.options.length>0){const i=n.options.map(c=>`--${c.name}${c.type==="boolean"?"":`=<${c.type}>`}`).join(", ");s.push(u(` options: ${i}`))}if(n.examples.length>0){s.push(u(" examples:"));for(const i of n.examples){const c=i.description?u(` — ${i.description}`):"";s.push(` ${A(i.command)}${c}`)}}}return s.push(""),s.push(u(`Run \`vis ${a.command} discover-help\` for the machine-readable JSON catalogue (designed for AI agents).`)),s.push(u(`Run \`vis ${a.command} <subcommand> --help\` for full usage of a specific subcommand.`)),`${s.join(`
|
|
3
3
|
`)}
|
|
4
4
|
`},h=async()=>{const{default:e}=await import("./cli-main.js").then(t=>t.aw);return e.filter(t=>t.name!=="ai")},J=async()=>{const e=await h();process.stderr.write(T(e))},F=async()=>{const e=await h();process.stdout.write(P(e))},M=async({logger:e,visConfig:t})=>{const a=t?.ai,s=l(a);if(!s){e.error("No AI provider available to test."),process.exitCode=1;return}e.info(`Testing ${s.name}...`);try{const n=await y(s,"Reply with exactly: OK",{timeoutMs:3e4});e.info(`Provider ${s.name} responded: ${n.stdout.trim().slice(0,200)}`)}catch(n){const o=n instanceof Error?n.message:String(n);e.error(`Provider ${s.name} failed: ${o}`),process.exitCode=1}},q=({logger:e,options:t,visConfig:a})=>{const s=t.format??"table",n=a?.ai,o=$(),i=l(n);if(s==="json"){const r=o.map(m=>({available:m.available,method:m.detectionMethod,name:m.name,path:m.path,priority:d[m.name]??0,selected:m.name===i?.name,version:m.version}));process.stdout.write(`${JSON.stringify(r,void 0,2)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{F as p}from"../packem_shared/index.server-
|
|
1
|
+
import{F as p}from"../packem_shared/index.server-sXNQYpsl.js";import{e as f}from"../packem_shared/index-DHD8wb6Z.js";const g={docker:".dockerignore",npm:".npmignore",slug:".slugignore",vercel:".vercelignore"},m=[".git",".gitattributes",".gitignore",".editorconfig",".vscode/",".idea/",".DS_Store","*.md","LICENSE*","LICENCE*","CHANGELOG*","CONTRIBUTING*","AUTHORS*","docs/","doc/","examples/","example/",".github/",".gitlab-ci.yml",".circleci/","appveyor.yml",".eslintrc*","eslint.config.*",".prettierrc*","prettier.config.*","*.log","npm-debug.log*","*.d.ts","*.map","*.flow","tsconfig*.json","__tests__/","__mocks__/","test/","tests/","*.test.*","*.spec.*","coverage/",".nyc_output/"],w={docker:["node_modules",".vis/","Dockerfile*",".dockerignore"],npm:[],slug:["node_modules"],vercel:["node_modules",".vercel/"]},E=e=>{const r=new Set,o=[];for(const t of[...m,...w[e]])r.has(t)||(r.add(t),o.push(t));return o},_=e=>e.trim(),h="# Added by vis ignore",$=(e,r)=>{const o=new Set;for(const n of e.split(/\r?\n/u)){const i=_(n);i!==""&&!i.startsWith("#")&&o.add(i)}const t=[];for(const n of r)o.has(n)||(o.add(n),t.push(n));if(t.length===0)return{added:t,content:e};const s=e.includes(`\r
|
|
2
2
|
`)?`\r
|
|
3
3
|
`:`
|
|
4
4
|
`,d=[h,...t].join(s);if(e.trim()==="")return{added:t,content:`${d}${s}`};const c=e.endsWith(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{F as p}from"../packem_shared/index.server-
|
|
1
|
+
import{F as p}from"../packem_shared/index.server-sXNQYpsl.js";import{e as m,z as k}from"../packem_shared/index-DHD8wb6Z.js";import{a as y,b as h,f as w}from"../packem_shared/subtree-DtmcKAJK.js";import{n as u}from"../packem_shared/utils-DQFHJn72.js";import{v as $,j as x}from"./catalog.js";import{y as A}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{U as b}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{p as E}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{T as l}from"../packem_shared/target-merge-B4No-LHM.js";const P=["aube-workspace.yaml","pnpm-workspace.yaml"],v=/^\s*packages\s*:\s*$/,j=/^(\s*)-\s/,I=(c,i)=>{const s=c.includes(`\r
|
|
2
2
|
`)?`\r
|
|
3
3
|
`:`
|
|
4
4
|
`,e=c.split(/\r?\n/),n=e.findIndex(r=>v.test(r));if(n===-1)return;let t=" ";for(let r=n+1;r<e.length;r++){const o=j.exec(e[r]);if(o){t=o[1];break}if(e[r].trim().length>0)break}return e.splice(n+1,0,`${t}- "${i}"`),e.join(s)},q=(c,i,s)=>{const e=m(c,"package.json");let n;try{n=E(e)}catch{return!1}const{workspaces:t}=n;return Array.isArray(t)?t.includes(i)?!1:(s||l(e,{...n,workspaces:[...t,i]},{detectIndent:!0}),!0):t&&typeof t=="object"&&Array.isArray(t.packages)?t.packages.includes(i)?!1:(s||l(e,{...n,workspaces:{...t,packages:[...t.packages,i]}},{detectIndent:!0}),!0):!1},M=({dryRun:c=!1,prefix:i,workspaceRoot:s})=>{const e=u(i),n=$(s);if(!n)return{status:"no-config"};if(x(s,n).some(r=>u(r)===e))return{status:"already-covered"};for(const r of P){const o=m(s,r);if(!A(o))continue;const a=I(k(o),e);if(a!==void 0)return c||b(o,a),{entry:e,file:r,status:"added"}}return q(s,e,c)?{entry:e,file:"package.json",status:"added"}:{status:"no-config"}},z=async({argument:c,fs:i,logger:s,options:e,process:n,workspaceRoot:t})=>{const r=c[0];if(!r)throw new Error("Missing <source>. Pass a git repository URL or local path to import.");if(!e.prefix)throw new Error("Missing --prefix <dir>. Pass the target directory in the monorepo (e.g. packages/tooling/foo).");const o=t??n.cwd,a=u(e.prefix),d=e.ref??"HEAD";if(y(o),await(async f=>{try{return await i.access(f),!0}catch{return!1}})(m(o,a)))throw new Error(`Target "${a}" already exists. git subtree add requires a non-existent prefix.`);if(e.dryRun){const f=e.squash?" --squash":"",g=e.message?` -m "${e.message}"`:"";s.info("Dry run — no changes will be made. Planned steps:"),s.info(` git subtree add --prefix=${a}${f}${g} ${r} ${d}`),e.register&&s.info(` register ${a} into the workspace config (skipped if already covered by an existing glob)`);return}if(h(o),s.info(`Importing ${p(r)}@${d} → ${a} ...`),w({cwd:o,message:e.message,prefix:a,ref:d,repo:r,squash:e.squash}),s.info(`✓ Imported ${r} into ${a} (history preserved).`),e.register){const f=M({prefix:a,workspaceRoot:o});f.status==="already-covered"?s.info(`✓ ${a} is already covered by an existing workspace glob.`):f.status==="added"?s.info(`✓ Registered ${f.entry} in ${f.file}.`):s.warn(`Could not auto-register ${a}: no workspace config found. Add it to pnpm-workspace.yaml or package.json#workspaces manually.`)}else s.info(p(`Skipped workspace registration (--no-register). Add ${a} to your workspace config manually.`));s.info(p("Note: project.json / nx tags are not generated. Add them if your tooling needs them."))};export{z as default};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{DEFAULT_CHANGES_DIR as
|
|
1
|
+
import{createRequire as I}from"node:module";import{DEFAULT_CHANGES_DIR as T}from"./DEFAULT_CLEAN_KEEP.js";import{b as _,c as q,a as k,p as F}from"./orchestrator.js";import{r as V}from"../packem_shared/run-D-uVGHQ4.js";import{toRepoRelativePath as S,listUncommittedPaths as H,getShortSha as U,getCurrentBranch as K,pushBranch as E,stageAndCommit as W}from"./git.js";import{createShellRunner as B}from"./shell-runner.js";import{stateFilePath as z}from"./state.js";import{d as J}from"../packem_shared/sticky-comment-DjhyCIZt.js";import{VisReleaseError as A}from"../packem_shared/VisReleaseError-DZtgcKf8.js";let M;const O=r=>(M??=I(import.meta.url))(r),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=r=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[e,s]=$.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return $.getBuiltinModule(r)}return O(r)},{join:G}=L("node:path"),Q="<!-- vis:user-content -->",X="<!-- /vis:user-content -->",Y=/<!-- vis:user-content -->([\s\S]*?)<!-- \/vis:user-content -->/g,Z=/<!-- vis:user-content -->(?:(?!<!-- \/vis:user-content -->)[\s\S])*?<!-- vis:user-content -->/,ee=r=>`${Q}${r}${X}`,te=(r,e)=>{const s=[],c=/<!-- vis:user-content -->\s*<!-- \/vis:user-content -->/g;let n=c.exec(r);for(;n!==null;)s.push({end:n.index+n[0].length,start:n.index}),n=c.exec(r);if(s.length===0)return{body:r,remaining:e};let i=0;const t=[],u=Math.min(s.length,e.length);for(let d=0;d<u;d+=1){const h=s[d],l=e[d];t.push(r.slice(i,h.start)),t.push(l),i=h.end}return t.push(r.slice(i)),{body:t.join(""),remaining:e.slice(u)}},ne=(r,e)=>{if(r===void 0||r==="")return e;const s=r.replaceAll(/```[\s\S]*?```/g,"").replaceAll(/~~~[\s\S]*?~~~/g,""),c=(s.match(/<!-- vis:user-content -->/g)??[]).length,n=(s.match(/<!-- \/vis:user-content -->/g)??[]).length;if(c!==n)throw new A({code:"CONFIG_INVALID",hint:"Fix the marker pairs in the PR body and re-run.",message:`PR body has unbalanced <!-- vis:user-content --> markers (${c} opens, ${n} closes). Refusing to merge to prevent silent edit loss.`});if(Z.test(s))throw new A({code:"CONFIG_INVALID",hint:"Flatten the nesting in the PR body and re-run.",message:"Nested <!-- vis:user-content --> markers are not allowed in PR body. The merger refuses to operate to prevent silent edit loss."});const i=[];for(const l of r.matchAll(Y)){const g=l[1]??"";g.trim()!==""&&i.push(ee(g))}if(i.length===0)return e;const{body:t,remaining:u}=te(e,i);if(u.length===0)return t;const d=t.replace(/\s+$/u,""),h=u.join(`
|
|
2
2
|
|
|
3
|
-
`);return`${
|
|
3
|
+
`);return`${d}
|
|
4
4
|
|
|
5
|
-
${
|
|
6
|
-
`},
|
|
5
|
+
${h}
|
|
6
|
+
`},re=async(r,e,s)=>{try{return await r.access(z(e,s)),!0}catch{return!1}},se=async(r,e,s,c,n,i,t)=>{const u=await r.run("gh",["pr","list","--head",c,"--state","open","--json","number"],{cwd:s,silent:!0});if(u.exitCode===0&&u.stdout.trim()!==""&&u.stdout.trim()!=="[]")try{const l=JSON.parse(u.stdout);if(l[0]){let g=i,m=!1;try{const b=await r.run("gh",["pr","view",String(l[0].number),"--json","body","-q",".body"],{cwd:s,silent:!0});if(b.exitCode===0)try{g=ne(b.stdout.replace(/\n$/,""),i)}catch(w){m=!0,e.warn(`Skipping PR body update for #${l[0].number} — protected-content blocks are unbalanced, refusing to overwrite operator content. Please clean up markers manually. Cause: ${w.message}`)}}catch(b){e.warn(`Could not read existing body of PR #${l[0].number} for protected-edit merge: ${b.message}. Proceeding with the unmerged body.`)}const v=m?["pr","edit",String(l[0].number),"--title",n]:["pr","edit",String(l[0].number),"--title",n,"--body",g],C=await r.run("gh",v,{cwd:s,silent:!0});if(C.exitCode!==0)throw new Error(`gh pr edit #${l[0].number} failed: ${C.stderr.trim()}`);return{existing:!0,number:l[0].number}}}catch{}const d=await r.run("gh",["pr","create","--head",c,"--base",t,"--title",n,"--body",i],{cwd:s,silent:!0});if(d.exitCode!==0)return;const h=/\/pull\/(\d+)/.exec(d.stdout);return h?{existing:!1,number:Number.parseInt(h[1]??"0",10)}:void 0},ie=async(r,e,s,c)=>{const n=c.labels??["autorelease: pending"];n.length>0&&await r.run("gh",["pr","edit",String(s),...n.flatMap(i=>["--add-label",i])],{cwd:e,silent:!0}),c.reviewers&&c.reviewers.length>0&&await r.run("gh",["pr","edit",String(s),"--add-reviewer",c.reviewers.join(",")],{cwd:e,silent:!0}),c.assignees&&c.assignees.length>0&&await r.run("gh",["pr","edit",String(s),"--add-assignee",c.assignees.join(",")],{cwd:e,silent:!0})},ae=/^ci-(?:head|[\da-f]{4,40})\.md$/,oe=(r,e)=>{const s=e===""?"":`${e}/`;return r.startsWith(s)&&ae.test(r.slice(s.length))},we=async({fs:r,logger:e,options:s,workspaceRoot:c})=>{const n=c??process.cwd(),i=B();let t=await _({channel:s.channel,cwd:n});const{printConfigIfRequested:u}=await import("./print-config.js");if(u(s,t,e))return;const d=t.config.changesDir??T,h=s.generate===!0,l=h?await S({cwd:n,runner:i},G(n,d)):"",g=await H({cwd:n,runner:i}),m=h?g.filter(o=>oe(o,l)):[],v=g.filter(o=>!m.includes(o));if(v.length>0){const o=v.slice(0,5).join(", "),a=v.length>5?` (+${v.length-5} more)`:"";e.warn(`Working tree has uncommitted changes. CI mode requires a clean tree. Offending paths: ${o}${a}`),process.exitCode=1;return}if(m.length>0&&e.warn(`Keeping ${m.length} change file(s) left behind by an interrupted --generate run: ${m.join(", ")}.`),h){const o=await U({cwd:n,runner:i}),a=await V({allowFullHistory:s.allowFullHistory===!0,config:t.config,cwd:n,from:s.generateFrom,fs:r,name:`ci-${o??"head"}`,packages:t.packages,perPackageConfig:t.perPackageConfig,runner:i,sinceLastRelease:s.generateFrom===void 0});for(const f of a.notes)e.info(f);for(const f of a.warnings)e.warn(f);if(a.status==="failed"){e.error(a.error),process.exitCode=1;return}if(a.status==="written"){const f=await S({cwd:n,runner:i},a.createdFile),P=await i.run("git",["add","--",a.createdFile],{cwd:n,silent:!0});if(P.exitCode!==0){e.error(`Could not stage the generated change file ${f}: ${P.stderr.trim()||`exit ${P.exitCode}`}`);try{await r.rm(a.createdFile,{force:!0})}catch{e.warn(`Could not clean up ${f} after the staging failure — remove it before the next run.`)}process.exitCode=1;return}e.info(`Generated ${f} from ${a.fromRef}..HEAD (${a.bumps.size} package(s)).`),t=await _({channel:s.channel,cwd:n})}else e.info(`--generate derived no bumps from ${a.fromRef}..HEAD.`)}const C=s.autoPublish===!0?"auto-publish":t.channel?.mode??"auto-publish",{files:b}=await q({changesDir:t.config.changesDir,cwd:n});if(C==="auto-publish"){if(b.length===0){e.info("No pending change files. Nothing to release.");return}e.info(`Auto-publish mode — versioning + publishing ${t.plan.releases.length} package(s).`),await k(t,{commit:!0});const o=await F(t,{resume:!0,tag:t.channel?.tag}),a=await K({cwd:n,runner:i});if(a)try{await E({cwd:n,runner:i},a)}catch(f){e.error(`Failed to push branch: ${f.message}`)}e.info(`Published: ${o.published.length} | Skipped: ${o.skipped.length} | Failed: ${o.failed.length}`),process.exitCode=o.failed.length>0?2:0;return}if(b.length===0){const o=await re(r,n,d);o?e.info("No pending change files but `.state.json` is present — resuming the prior wave's publish."):e.info("No pending change files — assuming this push is a merged release PR. Publishing.");const a=await F(t,{resume:o,tag:t.channel?.tag});e.info(`Published: ${a.published.length} | Skipped: ${a.skipped.length} | Failed: ${a.failed.length}`),process.exitCode=a.failed.length>0?2:0;return}e.info(`Version-PR mode — maintaining release PR for ${t.plan.releases.length} package(s).`);const w=s.branch??t.config.versionPr?.branch??"vis-release/version-packages",j=t.config.versionPr?.title??"🚀 Versioned release";if(!await J(i,n)){e.error("Could not detect repository slug via gh CLI. Cannot maintain version PR."),process.exitCode=1;return}const R=await i.run("git",["switch","-C",w],{cwd:n,silent:!0});if(R.exitCode!==0){e.error(`Could not switch to ${w}: ${R.stderr}`),process.exitCode=1;return}const x=await k(t,{commit:!1}),y=[...x.changedFiles,...x.deletedFiles];if(y.length===0){e.warn("Apply produced no file changes. Aborting version PR.");return}await W({cwd:n,runner:i},y,t.config.gitUser?`release(${t.channel?.tag??"main"}): version packages [skip ci]`:"release: version packages [skip ci]",{author:t.config.gitUser});try{await E({cwd:n,runner:i},w,{force:!0})}catch(o){e.error(`Could not push ${w}: ${o.message}`),process.exitCode=1;return}const N=t.branch??t.config.baseBranch??"main",D=`${t.config.versionPr?.preamble??""}
|
|
7
7
|
|
|
8
8
|
## Pending releases
|
|
9
9
|
|
|
10
|
-
${t.plan.releases.map(
|
|
10
|
+
${t.plan.releases.map(o=>`- \`${o.name}\`: ${o.oldVersion} → **${o.newVersion}**`).join(`
|
|
11
11
|
`)}
|
|
12
|
-
`,
|
|
12
|
+
`,p=await se(i,e,n,w,j,D,N);if(p){if(e.info(`${p.existing?"Updated":"Opened"} version PR #${p.number}.`),await ie(i,n,p.number,{assignees:p.existing?void 0:t.config.versionPr?.assignees,labels:t.config.versionPr?.labels,reviewers:p.existing?void 0:t.config.versionPr?.reviewers}),t.config.versionPr?.autoMerge&&!p.existing){const o=t.config.versionPr.autoMergeMethod??"squash",a=await i.run("gh",["pr","merge",String(p.number),"--auto",`--${o}`],{cwd:n,silent:!0});a.exitCode===0?e.info(`Auto-merge enabled (${o}).`):e.warn(`Could not enable auto-merge on PR #${p.number}: ${a.stderr.trim()||`exit ${a.exitCode}`}`)}}else e.error("Failed to create / update version PR."),process.exitCode=1};export{we as default};
|
|
@@ -1,11 +1,75 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`)
|
|
1
|
+
import{createRequire as D}from"node:module";import{V as q}from"../packem_shared/vis-user-error-YIyfYNBK.js";let W;const L=e=>(W??=D(import.meta.url))(e),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=e=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[t,n]=R.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return R.getBuiltinModule(e)}return L(e)},{relative:h,join:u,dirname:_}=E("node:path"),{lstat:G}=E("node:fs/promises"),U=new Set(["ENOENT","ENOTDIR"]),$=e=>U.has(e?.code??""),T=async(e,t)=>{const n=e.lstat;try{return(typeof n=="function"?await n.call(e,t):await G(t)).isSymbolicLink()}catch(i){if($(i))return!1;throw i}},v=async(e,t,n)=>{if(await T(e,t))throw new q(`Refusing to write ${t}: it is a symlink, and following it would write somewhere else. Remove or replace the link, then re-run.`);await e.writeFile(t,n)},g=async(e,t)=>{try{return await e.access(t),!0}catch(n){if($(n))return!1;throw n}},Y=async(e,t)=>{try{return(await e.stat(t)).isDirectory()}catch(n){if($(n))return!1;throw n}},b=async(e,t)=>{try{return await e.readFile(t,"utf8")}catch(n){if($(n))return;throw n}},K=e=>{const t=/\n([\t ]+)\S/.exec(e);return t?.[1]!==void 0?t[1]:e.includes(`
|
|
2
|
+
`)?" ":""},V=(e,t)=>{const n=t.includes(`\r
|
|
3
3
|
`)?`\r
|
|
4
4
|
`:`
|
|
5
|
-
`,
|
|
6
|
-
|
|
7
|
-
`),
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`)?c
|
|
11
|
-
|
|
5
|
+
`,i=JSON.stringify(e,void 0,K(t)).replaceAll(`
|
|
6
|
+
`,n);return t.endsWith(`
|
|
7
|
+
`)?`${i}${n}`:i},H=[/defineConfig\s*\(\s*\{/,/export\s+default\s+\{/],X=new Set(["","!","%","&","(","*","+",",","-",":",";","<","=",">","?","[","^","{","|","}","~"]),Z=e=>{const t=Array.from({length:e.length}),n=[];let i="code",r="",o="",a=0;const s=(c,f)=>{const d=e[c];t[c]=f||d===`
|
|
8
|
+
`?d:" ",f&&d.trim()!==""&&(o=d)},l=()=>{s(a,!1),a+1<e.length&&s(a+1,!1),a+=2};for(;a<e.length;){const c=e[a],f=e[a+1];if(i==="code"){c==="/"&&f==="/"?(s(a,!1),s(a+1,!1),a+=2,i="line-comment"):c==="/"&&f==="*"?(s(a,!1),s(a+1,!1),a+=2,i="block-comment"):c==='"'||c==="'"?(r=c,s(a,!0),a+=1,i="string"):c==="`"?(s(a,!1),a+=1,i="template"):c==="/"&&X.has(o)?(s(a,!1),a+=1,i="regex"):n.length>0&&c==="}"&&n.at(-1)===0?(n.pop(),s(a,!1),a+=1,i="template"):(n.length>0&&(c==="{"||c==="}")&&(n[n.length-1]=n.at(-1)+(c==="{"?1:-1)),s(a,!0),a+=1);continue}if(i==="line-comment"){s(a,!1),a+=1,c===`
|
|
9
|
+
`&&(i="code");continue}if(i==="block-comment"){s(a,!1),c==="*"&&f==="/"?(s(a+1,!1),a+=2,i="code"):a+=1;continue}if(i==="string"){if(c==="\\"){l();continue}if(c===r||c===`
|
|
10
|
+
`){s(a,c===r),a+=1,i="code";continue}s(a,!1),a+=1;continue}if(i==="template"){if(c==="\\"){l();continue}s(a,!1),c==="`"?(a+=1,i="code"):c==="$"&&f==="{"?(s(a+1,!1),n.push(0),a+=2,i="code"):a+=1;continue}if(c==="\\"){l();continue}s(a,!1),a+=1,c===`
|
|
11
|
+
`?i="code":i==="regex"&&c==="["?i="regex-class":i==="regex"&&c==="/"?i="code":i==="regex-class"&&c==="]"&&(i="regex")}return t.join("")},j=/[A-Z_$][\w$]*/iy,N=/\s*[:(,}]/y,F=(e,t)=>(N.lastIndex=t,N.test(e)),z=e=>{const t=Z(e);let n;for(const a of H){const s=a.exec(t);if(s!==null){n=s.index+s[0].length;break}}if(n===void 0)return{kind:"no-anchor"};let i=1,r=!1,o=n;for(;o<t.length;){const a=t[o];if(a==="{"){i+=1,o+=1;continue}if(a==="}"){if(i-=1,i===0)return{bodyStart:n,hasReleaseKey:r,kind:"found"};o+=1;continue}if(a==='"'||a==="'"){const l=t.indexOf(a,o+1);if(l===-1)return{kind:"unterminated"};i===1&&e.slice(o+1,l)==="release"&&F(t,l+1)&&(r=!0),o=l+1;continue}j.lastIndex=o;const s=j.exec(t);if(s!==null){const l=o+s[0].length;i===1&&s[0]==="release"&&t[o-1]!=="."&&F(t,l)&&(r=!0),o=l;continue}o+=1}return{kind:"unterminated"}},P=new Set([".releaserc.cjs",".releaserc.js",".releaserc.json"]),Q=5e3,I=async(e,t,n)=>{const i=[];for(const a of P){const s=u(t,a);if(await g(e,s)&&(i.push(s),n))return i}const r=[u(t,"packages"),u(t,"apps")];let o=0;for(;r.length>0&&o<Q;){const a=r.shift();o+=1;let s;try{s=await e.readdir(a)}catch(l){if(!$(l))throw l;continue}for(const l of s){const c=u(a,l);if(P.has(l)){if(i.push(c),n)return i;continue}l==="node_modules"||l.startsWith(".")||await Y(e,c)&&!await T(e,c)&&r.push(c)}}return i},ee=async(e,t)=>(await I(e,t,!0)).length>0,te=(e,t)=>I(e,t,!1),ne=async(e,t)=>{if(!t.endsWith(".json"))return{path:t};const n=await b(e,t);if(n!==void 0)try{const i=JSON.parse(n);return{branches:i.branches,extends:typeof i.extends=="string"?i.extends:void 0,path:t,plugins:Array.isArray(i.plugins)?i.plugins:void 0}}catch{return}},ie=e=>Array.isArray(e)?e.map(t=>{if(typeof t=="string")return{name:t};if(typeof t=="object"&&t!==null&&typeof t.name=="string"){const n=t;return{channel:n.channel,name:n.name,prerelease:n.prerelease}}}).filter(t=>t!==void 0):[],ae=e=>{const t={};for(const n of e){const i={tag:"latest"};typeof n.prerelease=="string"?(i.prerelease=n.prerelease,i.tag=n.prerelease,i.mode="auto-publish"):n.prerelease===!0?(i.prerelease=n.name,i.tag=n.name,i.mode="auto-publish"):(i.tag=n.channel??(n.name==="main"||n.name==="master"?"latest":n.name),i.mode="version-pr"),t[n.name]=i}return t},se=(e,t)=>{const n=Object.entries(e).map(([r,o])=>` ${JSON.stringify(r)}: ${JSON.stringify(o)},`).join(`
|
|
12
|
+
`);return` release: {
|
|
13
|
+
baseBranch: "main",
|
|
14
|
+
${t?" defaultManaged: true,":" defaultManaged: false, // per-package opt-in; --cutover flips this to true"}
|
|
15
|
+
channels: {
|
|
16
|
+
${n}
|
|
17
|
+
},
|
|
18
|
+
publish: {
|
|
19
|
+
packManager: "auto",
|
|
20
|
+
publishStrategy: "npm-publish-tarball",
|
|
21
|
+
publishArgs: ["--provenance"],
|
|
22
|
+
protocolResolution: "pack",
|
|
23
|
+
catalogResolution: "auto",
|
|
24
|
+
cleanPackageJson: true,
|
|
25
|
+
},
|
|
26
|
+
gitUser: { name: "release-bot", email: "release-bot@example.com" },
|
|
27
|
+
},`},J=e=>e.visConfig?[e.visConfig,...e.manifests]:e.manifests,re=async(e,t,n)=>{const i=u(t,"vis.config.ts"),r=await b(e,i);if(r===void 0)return{kind:"write",write:{action:"create",content:`import { defineConfig } from "@visulima/vis/config";
|
|
28
|
+
|
|
29
|
+
export default defineConfig({
|
|
30
|
+
${n}
|
|
31
|
+
});
|
|
32
|
+
`,detail:"release block",path:i}};const o=z(r);return o.kind==="no-anchor"?{kind:"skip",skipped:{blocking:!0,path:i,reason:"could not locate `defineConfig({` or `export default {` to inject into; merge the suggested block manually"}}:o.kind==="unterminated"?{kind:"skip",skipped:{blocking:!0,path:i,reason:"its config object is never closed (unbalanced braces); fix the file, or merge the suggested block manually"}}:o.hasReleaseKey?{kind:"skip",skipped:{blocking:!1,path:i,reason:"already has a `release` key; merge the suggested block manually"}}:{kind:"write",write:{action:"update",content:`${r.slice(0,o.bodyStart)}
|
|
33
|
+
${n}
|
|
34
|
+
${r.slice(o.bodyStart)}`,detail:"release block",path:i}}},oe=async(e,t,n,i)=>{const r=[],o=[],a=new Set;for(const s of n){const l=_(s),c=u(l,"package.json"),f=await b(e,c);if(f===void 0)continue;let d;try{d=JSON.parse(f)}catch{r.push(` skipped ${h(t,c)} — invalid JSON.`);continue}const p=h(t,l).replaceAll("\\","/"),w=typeof d.name=="string"?d.name:p;if(i!==void 0){const A=i.find(x=>x===w||x.replaceAll("\\","/").replace(/\/+$/,"")===p);if(A===void 0)continue;a.add(A)}if(d.private===!0){r.push(` skipped ${h(t,c)} — \`private: true\` packages are not published, so they are not opted in.`);continue}const m=d["vis-release"];if(m!==null&&typeof m=="object"&&m.managed===!0)continue;const k=m!==null&&typeof m=="object"?{...m,managed:!0}:{managed:!0};o.push({action:"update",content:V({...d,"vis-release":k},f),detail:"add vis-release.managed = true",path:c})}if(i!==void 0)for(const s of i)a.has(s)||r.push(`--packages: no package with a sibling .releaserc.* matched "${s}".`);return{warnings:r,writes:o}},ce=async(e,t,n,i,{cutover:r,selection:o})=>{const a=r||o!==void 0?await oe(e,t,n,r?void 0:o):{warnings:[],writes:[]},s=await re(e,t,i);return{deletions:r?n:[],manifests:a.writes,skipped:s.kind==="skip"?[s.skipped]:[],visConfig:s.kind==="write"?s.write:void 0,warnings:a.warnings}},le=(e,t,n)=>{for(const i of t.skipped)n.info(`[dry-run] would skip ${h(e,i.path)} — ${i.reason}`);for(const i of J(t))n.info(`[dry-run] would ${i.action} ${h(e,i.path)} (${i.detail})`);for(const i of t.deletions)n.info(`[dry-run] would delete ${h(e,i)}`);t.manifests.length===0&&t.deletions.length===0&&n.info("[dry-run] no package.json or .releaserc.* is touched — pass `--packages <a,b>` to opt packages in, or `--cutover` for all of them.")},fe=async(e,t)=>{for(const n of t.toReversed())try{await(n.previous===void 0?e.rm(n.path,{force:!0}):e.writeFile(n.path,n.previous))}catch{}},de=async(e,t,n,i)=>{for(const o of n.skipped)i.warn(` skipped ${h(t,o.path)} — ${o.reason}.`);const r=[];try{for(const o of J(n))r.push({path:o.path,previous:await b(e,o.path)}),await v(e,o.path,o.content),i.info(` ${o.action==="create"?"wrote":"updated"} ${h(t,o.path)} (${o.detail})`);for(const o of n.deletions)r.push({path:o,previous:await b(e,o)}),await e.rm(o,{force:!0}),i.info(` deleted ${h(t,o)}`)}catch(o){throw i.error(`Migration write failed — rolling back ${r.length} change(s).`),await fe(e,r),o}},ue=()=>process.stdout.isTTY&&process.env.CI!=="true",pe=async(e,t,n)=>{if(e.deletions.length===0||t)return"confirmed";if(!ue())return n.error(`Refusing to delete ${e.deletions.length} .releaserc.* file(s) without confirmation.`),n.error("Re-run with `--yes` to confirm in a non-interactive shell, or with `--dry-run` to preview the run first."),"refused";const i=`Delete ${e.deletions.length} .releaserc.* file(s) and mark ${e.manifests.length} package.json file(s) managed?`;try{const{confirmPrompt:r}=await import("./prompts.js");return await r(i,!1)?"confirmed":"declined"}catch{return"declined"}},he=e=>e.deletions.length===0?[]:e.skipped.filter(t=>t.blocking),me=(e,t,n)=>{n.error("Refusing to run the cutover — the vis release config could not be written:");for(const i of t)n.error(` ${h(e,i.path)} — ${i.reason}`);n.error("Deleting every .releaserc.* now would leave this repo with no release configuration at all."),n.error("Paste the release block above into your config (or remove the file so init can create it), then re-run with `--apply --cutover`.")},O=(e,t,n)=>{if(n.info(""),t?(n.info("Full cutover (--cutover): every detected package is marked `vis-release.managed` and its `.releaserc.*` removed."),n.info("Backfill any missing git tags so already-published detection works.")):(n.info("Migration is per-package opt-in (RFC §17.1). For each package you want to migrate:"),n.info(' 1. Add to its package.json: "vis-release": { "managed": true } (or re-run with `--packages <a,b>`)'),n.info(" 2. Backfill any missing git tags so already-published detection works."),n.info(" 3. Add to multi-semantic-release's --ignore-packages list in your release workflow."),n.info(""),n.info("Existing .releaserc.json files are kept in place during transition."),n.info("Once every package is migrated, re-run with `--apply --cutover` to delete them (Phase 6).")),!e){n.info(`Re-run with \`--apply${t?" --cutover --yes":""}\` to perform the writes automatically.`);return}n.info(""),n.info("Migration writes complete. Follow-up steps you still need to do manually:"),n.info(" - Update your CI workflow: remove `multi-semantic-release` step, add `vis release ci/release` step (see `.github/workflows/vis-release.yml` example in the vis package)"),n.info(" - Run `pnpm install` to drop semantic-release deps once you remove them from root package.json"),n.info(" - Run `vis release doctor` to verify the migration")},ye=async(e,t)=>{let n=[],i=0;for(const a of t){const s=await ne(e,a);s&&(s.branches&&(n=[...n,...ie(s.branches)]),s.plugins?.some(l=>typeof l=="string"&&l.includes("native-addons"))&&(i+=1),s.plugins?.some(l=>Array.isArray(l)&&typeof l[0]=="string"&&l[0].includes("native-addons"))&&(i+=1))}const r=new Set,o=n.filter(a=>r.has(a.name)?!1:(r.add(a.name),!0));return{channels:o.length>0?ae(o):{alpha:{mode:"auto-publish",prerelease:"alpha",tag:"alpha"},main:{mode:"version-pr",tag:"latest"}},nativeAddonCount:i}},we=async(e,t,{apply:n,autoYes:i,cutover:r,dryRun:o,selection:a},s)=>{const l=await te(e,t);if(s.info(`Found ${l.length} .releaserc file(s).`),l.length===0)return;const{channels:c,nativeAddonCount:f}=await ye(e,l),d=se(c,r);s.info(""),s.info("Suggested vis.config.ts release block (paste into your existing config):"),s.info(""),s.info(d),s.info(""),f>0&&(s.info(`Found ${f} package(s) using a NAPI native-addons plugin.`),s.info("These will auto-detect via the `napi` field in package.json — no config needed."),s.info(""));const p=await ce(e,t,l,d,{cutover:r,selection:a});for(const k of p.warnings)s.warn(k);const w=he(p);if(o||!n){if(o&&(s.info("Planned writes:"),le(t,p,s)),w.length>0){s.warn("This cutover would be refused: the vis release config cannot be written, so the .releaserc.* deletions would strip the repo bare.");for(const k of w)s.warn(` ${h(t,k.path)} — ${k.reason}`)}O(!1,r,s);return}if(w.length>0){me(t,w,s),process.exitCode=1;return}const m=await pe(p,i,s);if(m!=="confirmed"){s.info(""),s.info("Cutover cancelled — no migration writes were made."),m==="refused"&&(process.exitCode=1);return}s.info("Applying migration writes (--apply set)…"),await de(e,t,p,s),O(!0,r,s)},ke=async(e,t)=>await g(e,u(t,".changeset"))?"changesets":await g(e,u(t,".bumpy"))?"bumpy":await ee(e,t)?"semantic-release":"fresh",ve=e=>{if(typeof e!="string")return;const t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0},ge=e=>new Set(e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t.length>0)),M=async(e,t,n,i)=>{const{entries:r,header:o,label:a,path:s}=n,l=await b(e,s),c=l===void 0?void 0:ge(l),f=c===void 0?r:r.filter(d=>!c.has(d.trim()));if(f.length!==0){if(t){i.info(`[dry-run] would add to ${a}:
|
|
35
|
+
${f.map(d=>` ${d}`).join(`
|
|
36
|
+
`)}`);return}if(l===void 0){await v(e,s,`${o}
|
|
37
|
+
${f.join(`
|
|
38
|
+
`)}
|
|
39
|
+
`),i.info(`Created ${a}.`);return}await v(e,s,`${l.replace(/\n*$/,`
|
|
40
|
+
`)}
|
|
41
|
+
${o}
|
|
42
|
+
${f.join(`
|
|
43
|
+
`)}
|
|
44
|
+
`),i.info(`Updated ${a}.`)}},be=async(e,t,n,i)=>{const{upsertAgentSection:r}=await import("./agent-instructions.js"),o=u(t,"AGENTS.md");let a;try{a=await e.readFile(o,"utf8")}catch(c){if(!$(c))throw c;a=void 0}const{changed:s,content:l}=r(a);s?n?i.info(`[dry-run] would ${a?"update":"create"} AGENTS.md with the 'Releasing with vis' section`):(await v(e,o,l),i.info(`${a?"Updated":"Created"} AGENTS.md.`)):i.info("AGENTS.md already up to date.")},$e=e=>{e.info(""),e.info("Next steps:"),e.info(" 1. Add the `release: { ... }` block above to your vis.config.mjs"),e.info(" 2. Author your first change file: vis release add"),e.info(" 3. Preview the plan: vis release status"),e.info(" 4. Apply: vis release version --dry-run")},Fe=async({fs:e,logger:t,options:n,workspaceRoot:i})=>{const r=i??process.cwd(),o=n.dryRun===!0,a=n.cutover===!0,s=n.yes===!0,l=ve(n.packages);let c=n.apply===!0;o&&c&&(t.warn("--apply is ignored because --dry-run is set (dry-run takes precedence)."),c=!1),a&&l!==void 0&&t.warn("--packages is ignored because --cutover opts every detected package in.");let f;n.fromSemanticRelease?f="semantic-release":n.fromChangesets?f="changesets":n.fromBumpy?f="bumpy":n.fresh?f="fresh":f=await ke(e,r),t.info(`Detected source: ${f}`),(a||l!==void 0)&&f!=="semantic-release"&&t.warn("`--cutover` / `--packages` only affect the semantic-release migration path.");const d=o||f==="semantic-release"&&!c;d&&!o&&t.info("Preview only — a semantic-release migration writes nothing without `--apply`."),t.info("");const p=u(r,".vis","release");switch(d?t.info(`[dry-run] would create directory: ${p}`):(await e.mkdir(p,{recursive:!0}),t.info(`Created ${h(r,p)}/`)),await M(e,d,{entries:[".vis/release/.state.json",".vis/release/.lock"],header:"# vis release subsystem",label:".gitignore",path:u(r,".gitignore")},t),n.agent&&await be(e,r,d,t),await M(e,d,{entries:[".vis/release/**"],header:"# vis release change files (author handles false-positive secretlint)",label:".secretlintignore",path:u(r,".secretlintignore")},t),f){case"bumpy":{await xe(e,r,d,t);break}case"changesets":{await Se(e,r,d,t);break}case"semantic-release":{await we(e,r,{apply:c,autoYes:s,cutover:a,dryRun:d,selection:l},t);break}default:Ce(t)}await Re(e,r,d,s,t),await Ae(e,r,d,n,t),$e(t)},B=async(e,t,n,i,r)=>{const o=[];try{for(const c of await e.readdir(n))c.endsWith(".md")&&c!=="README.md"&&o.push(c)}catch(c){if(!$(c))throw c}const a=u(t,".vis","release");let s=0,l=0;for(const c of o){const f=u(n,c),d=u(a,c);if(i){r.info(`[dry-run] would copy ${f} → ${d}`);continue}if(await g(e,d)){r.info(`Skipping existing ${h(t,d)}.`),l+=1;continue}await v(e,d,await e.readFile(f,"utf8")),s+=1}return l>0&&r.info(`Skipped ${l} file(s) that already exist in .vis/release/.`),{found:o.length,preserved:s}},Se=async(e,t,n,i)=>{const r=u(t,".changeset"),o=u(r,"config.json");if(await g(e,u(r,"pre.json"))){i.error("Pre-release mode is active in changesets (.changeset/pre.json exists)."),i.error("Run `changeset pre exit && changeset version` to consume pending changes, then re-run `vis release init`."),process.exitCode=1;return}let a={};try{a=JSON.parse(await e.readFile(o,"utf8"))}catch{i.warn(".changeset/config.json missing or unreadable; using defaults.")}const s={access:a.access==="restricted"?"restricted":"public",baseBranch:typeof a.baseBranch=="string"?a.baseBranch:"main",defaultManaged:!0,fixed:Array.isArray(a.fixed)?a.fixed:[],ignore:Array.isArray(a.ignore)?a.ignore:[],linked:Array.isArray(a.linked)?a.linked:[],privatePackages:a.privatePackages??{tag:!1,version:!1},updateInternalDependencies:a.updateInternalDependencies??"out-of-range"},l=a.changelog,c=typeof l=="string"?l:Array.isArray(l)&&typeof l[0]=="string"?l[0]:void 0;let f;l===!1?f="false":c?.includes("@changesets/changelog-github")?f='"github"':(c?.includes("@changesets/cli"),f='"default"');const{found:d,preserved:p}=await B(e,t,r,n,i);i.info(`Found ${d} pending .changeset/*.md file(s); ${p>0?`copied ${p} to .vis/release/`:"(dry-run — would copy)"}.`),i.info(""),i.info("Suggested vis.config.ts release block:"),i.info(""),i.info(` release: {
|
|
45
|
+
baseBranch: ${JSON.stringify(s.baseBranch)},
|
|
46
|
+
access: ${JSON.stringify(s.access)},
|
|
47
|
+
defaultManaged: ${s.defaultManaged},
|
|
48
|
+
updateInternalDependencies: ${JSON.stringify(s.updateInternalDependencies)},
|
|
49
|
+
fixed: ${JSON.stringify(s.fixed)},
|
|
50
|
+
linked: ${JSON.stringify(s.linked)},
|
|
51
|
+
ignore: ${JSON.stringify(s.ignore)},
|
|
52
|
+
privatePackages: ${JSON.stringify(s.privatePackages)},
|
|
53
|
+
changelog: ${f},
|
|
54
|
+
publish: {
|
|
55
|
+
packManager: "auto",
|
|
56
|
+
publishStrategy: "npm-publish-tarball",
|
|
57
|
+
cleanPackageJson: true,
|
|
58
|
+
},
|
|
59
|
+
},`),i.info(""),i.info("After confirming the config, you can delete `.changeset/` (or run `vis release init --remove-changesets`).")},xe=async(e,t,n,i)=>{const r=u(t,".bumpy"),o=u(r,"_config.json");let a={};try{a=JSON.parse(await e.readFile(o,"utf8"))}catch{i.warn(".bumpy/_config.json missing or unreadable; using defaults.")}const s=JSON.stringify(a,null,4).split(`
|
|
60
|
+
`).map(f=>` ${f}`).join(`
|
|
61
|
+
`),{found:l,preserved:c}=await B(e,t,r,n,i);i.info(`Found ${l} pending .bumpy/*.md file(s); ${c>0?`copied ${c} to .vis/release/`:"(dry-run)"}.`),i.info(""),i.info("Suggested vis.config.ts release block (bumpy config translates 1:1):"),i.info(""),i.info(` release: ${s.trimStart()},`),i.info(""),i.info("After confirming, delete `.bumpy/`.")},Re=async(e,t,n,i,r)=>{const o=u(t,".husky","pre-commit");if(!await g(e,o))return;const a=await b(e,o)??"";if(a.includes("vis release check"))return;const s="vis release check --hook pre-commit --no-fail";if(!await(async()=>{if(!process.stdout.isTTY||process.env.CI==="true")return!1;if(i)return!0;try{const{confirmPrompt:c}=await import("./prompts.js");return await c(`Wire \`${s}\` into your .husky/pre-commit hook?`,!0)}catch{return!1}})()){r.info(""),r.info("Optional: add this line to .husky/pre-commit:"),r.info(` ${s}`);return}if(n){r.info(`[dry-run] would append \`${s}\` to .husky/pre-commit`);return}await v(e,o,`${a.replace(/\n*$/,`
|
|
62
|
+
`)}${s}
|
|
63
|
+
`),r.info("Wired vis release check into .husky/pre-commit.")},Ae=async(e,t,n,i,r)=>{const o=i.workflows===!0,a=i.yes===!0;if(!o&&(!process.stdout.isTTY||process.env.CI==="true"))return;if(!(o||a||await(async()=>{try{const{confirmPrompt:y}=await import("./prompts.js");return await y("Generate CI workflow files for the active provider?",!0)}catch{return!1}})())){r.info(""),r.info("Skipped workflow generation. Re-run with `vis release init --workflows` later.");return}const{detectRemoteProvider:l}=await import("./detect.js"),{generateWorkflowFiles:c}=await import("./workflow-templates.js"),{detectPackageManager:f}=await import("../packem_shared/createAdapter-F7GidOzU.js"),{createShellRunner:d}=await import("./shell-runner.js"),p=d(),w=await l(t,p,void 0),m=await f(t,p),A=i.packageManager??m;let x={};try{const{loadVisConfig:y}=await import("./CONFIG_FILES.js"),S=await y(t);S.release&&(x=S.release)}catch{}const C=c(x,{packageManager:A,provider:w});r.info(""),r.info(`Generating ${C.length} workflow file(s) for ${w}:`);for(const y of C){const S=u(t,y.path);if(await g(e,S)){r.warn(` ${y.path} — already exists, skipping`);continue}if(n){r.info(` ${y.path} — [dry-run] would write ${y.content.length} bytes`);continue}await e.mkdir(_(S),{recursive:!0}),await v(e,S,y.content),r.info(` ${y.path} — wrote ${y.content.length} bytes`)}},Ce=e=>{e.info(""),e.info("Suggested vis.config.ts release block:"),e.info(""),e.info(` release: {
|
|
64
|
+
baseBranch: "main",
|
|
65
|
+
defaultManaged: true,
|
|
66
|
+
channels: {
|
|
67
|
+
main: { tag: "latest", mode: "version-pr" },
|
|
68
|
+
},
|
|
69
|
+
publish: {
|
|
70
|
+
packManager: "auto",
|
|
71
|
+
publishStrategy: "npm-publish-tarball",
|
|
72
|
+
publishArgs: ["--provenance"],
|
|
73
|
+
cleanPackageJson: true,
|
|
74
|
+
},
|
|
75
|
+
},`)};export{Fe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as q,b as J,p as f,O as G,c as T,d as O}from"./cli-main.js";import{l as H,r as K,t as m,c as Q,k as W,R as c,E as X,m as y,n as P,o as Z,s as _}from"./catalog.js";import{i as ee}from"../packem_shared/index-BjdW45xX.js";import{v as te,r as se,f as re}from"../packem_shared/ai-analysis-DSQQDFU9.js";import{V as ae}from"../packem_shared/vis-user-error-
|
|
1
|
+
import{a as q,b as J,p as f,O as G,c as T,d as O}from"./cli-main.js";import{l as H,r as K,t as m,c as Q,k as W,R as c,E as X,m as y,n as P,o as Z,s as _}from"./catalog.js";import{i as ee}from"../packem_shared/index-BjdW45xX.js";import{v as te,r as se,f as re}from"../packem_shared/ai-analysis-DSQQDFU9.js";import{V as ae}from"../packem_shared/vis-user-error-YIyfYNBK.js";import{d as ne}from"../packem_shared/pm-runner-d93_73O6.js";import{s as oe}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{U as ce,V as ie,C as j}from"../packem_shared/vis-update-app-DNeU8RBQ.js";const we=async({argument:$,logger:s,options:e,visConfig:o,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.sync&&!e.securityConfig)throw new ae("--sync requires --security-config. Run `vis check --security-config --sync`.");if(e.securityConfig){const t=ne(d);if(q(o??{},t.name),e.sync&&t.name==="pnpm"){const r=J(o??{});if(r.length>0){f.info(`
|
|
2
2
|
Settings that would sync to pnpm-workspace.yaml:`);for(const S of r)f.success(` ${S}`)}else f.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(f.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),f.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!$?.length)return}const{packageManager:N}=G(d),U=H(d),i=o?.update??{},h=K(d,N,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(h.size===0){s.info("No catalogs found.");return}const k=e.target??i.target??"latest";if(!["latest","minor","patch"].includes(k))throw new Error(`Invalid target "${k}". Use: latest, minor, or patch.`);const D={exclude:[...m(e.exclude),...m(i.exclude)],ignore:m(i.ignore),include:[...m(e.include),...m(i.include),...$],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||i.prerelease||!1,security:e.security!==!1,target:k};let x=0;for(const t of h.values())x+=t.size;const w=!!process.stdout.isTTY&&!ee;let l;const I=w?(t,r)=>{l?l.rerender(c.createElement(j,{current:t,total:r})):l=O(c.createElement(j,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{s.info(`Checking ${String(t)}/${String(r)} dependencies...`)};w||s.info(`Checking ${String(x)} catalog dependencies against npm registry...
|
|
3
3
|
`);const g=new Set;T("socket")&&g.add("socket"),T("depsDev")&&g.add("deps-dev");const v=o?.security?.policies?.score?.minimum,M=Q(o?.security,{disabled:g,minimumScore:v}),{failed:E,outdated:n}=await W(h,D,U,I,d,M,o?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),E.length>0&&s.warn(`Failed to fetch: ${E.join(", ")}`),n.length===0){s.info("All catalog dependencies are up to date.");return}const R=e.format??i.format??"table",V=te(e.aiType??"impact"),u=e.ai?await se(n,s,o?.ai,V):void 0;if(w&&R==="table"){const t=new ce(n,u??null),r=o?.tui?.autoExit??!1,S=r===!0?3:typeof r=="number"?r:0;await O(c.createElement(ie,{autoExitSeconds:S,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const B=process.stdout.columns||80;process.stdout.write(`
|
|
4
4
|
`);for(const a of n){const Y=a.vulnerabilities?.length||a.socketReport&&a.socketReport.alerts.length>0,b=!!a.acceptedRisk,z=Y?b?"✓":"⚠":"✓",F=b?"gray":a.updateType==="major"?"red":a.updateType==="minor"?"yellow":"green",p=a.socketReport?.score.overall,L=p===void 0?"":` [${String(Math.round(p*100))}%]`,A=p===void 0?void 0:oe(p);process.stdout.write(`${X(c.createElement(y,null," ",c.createElement(y,{color:F},z),` ${a.packageName} ${a.currentRange} → ${a.newRange}`,c.createElement(y,{dimColor:!0},` ${a.updateType}`),A?c.createElement(y,{color:A},L):null),{columns:B})}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`)
|
|
3
|
-
`)
|
|
1
|
+
import{createRequire as K}from"node:module";import{j as g,F as m,q as v,J as N,X as P,b as j}from"../packem_shared/index.server-sXNQYpsl.js";import{e as h,v as U}from"../packem_shared/index-DHD8wb6Z.js";import{d as F,b as Y}from"./catalog.js";import{d as J}from"../packem_shared/lockfile-DVFySxTS.js";import{p as z,s as X}from"../packem_shared/docker-Dy-X_BuM.js";import{i as ne}from"../packem_shared/index-BjdW45xX.js";import{g as B}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{h as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{y as re}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";let G;const W=e=>(G??=K(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,n]=b.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return b.getBuiltinModule(e)}return W(e)},{createInterface:O}=y("node:readline"),{spawn:Q}=y("node:child_process"),{createHash:Z}=y("node:crypto"),{existsSync:I,writeFileSync:ee,chmodSync:te}=y("node:fs"),S={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"}},se=e=>{const{focus:t,manager:n,nodeVersion:r}=e,o=S[n]??S.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${t?` --focus=${t}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...o.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",o.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",o.build(t),"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",D=`https://github.com/hadolint/hadolint/releases/download/${$}`,ie={"hadolint-linux-arm64":"331f1d3511b84a4f1e3d18d52fec284723e4019552f4f47b19322a53ce9a40ed","hadolint-linux-x86_64":"6bf226944684f56c84dd014e8b979d27425c0148f61b3bd99bcc6f39e9dc5a47","hadolint-macos-arm64":"3625e2e9f43dcfe7bd38738a5f5520ed50ce39ed28485266e6803dd7bc197b10","hadolint-macos-x86_64":"2b69a853433f1eca522ffb921cd490bd1321424d03331fd8390f93b7fb4a02e9","hadolint-windows-x86_64.exe":"8e0ee174f88edb14f207a68430c7a53c2883ed509cdbde9a3a26fffa140fa5e4"},ae=e=>ie[e],ce=(e=process.platform,t=process.arch)=>{const n=e==="darwin"?"macos":e==="linux"?"linux":e==="win32"?"windows":void 0;if(n===void 0)return;const r=t==="arm64"?"arm64":t==="x64"?"x86_64":void 0;if(n==="windows")return"hadolint-windows-x86_64.exe";if(r!==void 0)return`hadolint-${n}-${r}`},L=e=>h(B(),"hadolint",$,e.endsWith(".exe")?"hadolint.exe":"hadolint"),le=()=>{const e=process.platform==="win32"?"hadolint.exe":"hadolint",t=(process.env.PATH??"").split(process.platform==="win32"?";":":");for(const n of t)if(n!==""&&I(h(n,e)))return e},de=e=>e.trim().split(/\s+/u)[0]??"",E=async e=>{const t=await fetch(e,{redirect:"follow"});if(!t.ok)throw new Error(`download failed (${String(t.status)} ${t.statusText}) for ${e}`);return Buffer.from(await t.arrayBuffer())},ue=async e=>{const t=L(e),n=ae(e),r=await E(`${D}/${e}`),o=Z("sha256").update(r).digest("hex");if(n===void 0){const s=await E(`${D}/${e}.sha256`),i=de(s.toString("utf8")).toLowerCase();if(i==="")throw new Error("hadolint checksum sidecar was empty or unparseable. Refusing to use the download.");if(i!==o)throw new Error(`hadolint checksum mismatch (expected ${i}, got ${o}). Refusing to use the download.`)}else if(n.toLowerCase()!==o)throw new Error(`hadolint checksum mismatch (expected ${n.toLowerCase()}, got ${o}). Refusing to use the download.`);return oe(h(B(),"hadolint",$)),ee(t,r),process.platform!=="win32"&&te(t,493),t},fe=async()=>{const e=O({input:process.stdin,output:process.stderr}),t=await new Promise(n=>{e.question(` Download hadolint ${v($)} now? ${m("[y/N]")} `,r=>{n(r.trim().toLowerCase())})});return e.close(),t==="y"||t==="yes"},pe=async e=>{const{autoInstall:t=!1,log:n}=e,r=le();if(r!==void 0)return r;const o=ce();if(o===void 0){n(`hadolint has no prebuilt binary for ${process.platform}/${process.arch}. Install it manually: https://github.com/hadolint/hadolint`);return}const s=L(o);if(I(s))return s;if(!t){if(!(!!process.stdin.isTTY&&!ne)){n(`hadolint is not installed. Re-run with ${g("--install")} (or install hadolint on PATH) to enable Dockerfile linting.`);return}if(n(`${g("hadolint")} is required to lint Dockerfiles but was not found on your PATH.`),!await fe()){n(`Skipped. Install it yourself or re-run with ${g("--install")}.`);return}}n(`Downloading hadolint ${$} (${o})…`);try{const i=await ue(o);return n(`Installed hadolint to ${m(i)}`),i}catch(i){n(`Failed to download hadolint: ${i.message}`);return}},_=async(e,t,n)=>{if(t.length===0)return[];const r=["--format","json","--no-fail",...n!==void 0&&n!==""?["--config",n]:[],...t],o=await new Promise((i,l)=>{const a=Q(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(o.trim()==="")return[];let s;try{s=JSON.parse(o)}catch{throw new Error("Could not parse hadolint JSON output.")}return Array.isArray(s)?s:[]},C=(e,t,n)=>{if(!(!/\bapt-get\b/u.test(e)||!/\binstall\b/u.test(e)||n.test(e)))return e.replace(/\binstall\b/u,`install ${t}`)},k={DL3014:e=>C(e,"-y",/(?:^|\s)(?:-y|--yes|--assume-yes|-qq?)\b/u),DL3015:e=>C(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},T=new Set(Object.keys(k)),me=(e,t)=>{const n=e.includes(`\r
|
|
3
|
+
`)?`\r
|
|
4
|
+
`:`
|
|
5
|
+
`,r=e.split(/\r?\n/u),o=new Set;let s=0;const i=new Map;for(const l of t){if(!k[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=k[u.code],f=c?.(r[d]??"");f!==void 0&&f!==r[d]&&(r[d]=f,o.add(u.code),s+=1)}}return{content:s>0?r.join(n):e,fixedCodes:[...o],fixedCount:s}},A={error:0,info:2,style:3,warning:1},he=(e,t)=>{switch(e){case"error":return P(t);case"info":return v(t);case"warning":return j(t);default:return m(t)}},we=(e,t)=>(e.length>0?e:["Dockerfile"]).map(r=>U(r)?r:h(t,r)).filter(r=>re(r)),be=(e,t)=>{const n=[...e].sort((o,s)=>o.file.localeCompare(s.file)||o.line-s.line||o.column-s.column||A[o.level]-A[s.level]);let r="";for(const o of n){o.file!==r&&(r=o.file,t.info(`
|
|
6
|
+
${g(r)}`));const s=m(`${String(o.line)}:${String(o.column)}`),i=he(o.level,o.level.padEnd(7)),l=T.has(o.code)?m(" (fixable)"):"";t.info(` ${s} ${i} ${v(o.code)} ${o.message}${l}`)}},ge=e=>{const t={error:0,info:0,style:0,warning:0};for(const n of e)t[n.level]+=1;return t},$e=async e=>{const{autoInstall:t,configPath:n,cwd:r,files:o,fix:s,fs:i,json:l,logger:a}=e,d=we(o,r);if(d.length===0)return a.error(`No Dockerfile found${o.length>0?` at: ${o.join(", ")}`:` in ${r}`}. Pass a path: vis docker lint <path>`),1;const u=await pe({autoInstall:t,log:p=>{a.info(p)}});if(u===void 0)return 0;let c=await _(u,d,n),f=0;if(s&&c.length>0){for(const p of d){const H=c.filter(V=>V.file===p),q=await i.readFile(p,"utf8"),x=me(q,H);x.fixedCount>0&&(await i.writeFile(p,x.content),f+=x.fixedCount)}f>0&&(c=await _(u,d,n))}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;be(c,a);const w=ge(c),R=c.filter(p=>T.has(p.code)).length;return a.info(`
|
|
8
|
+
${g(String(c.length))} issue${c.length===1?"":"s"}: ${P(`${String(w.error)} error`)}, ${j(`${String(w.warning)} warning`)}, ${v(`${String(w.info)} info`)}, ${m(`${String(w.style)} style`)}`),!s&&R>0&&a.info(m(`Run 'vis docker lint --fix' to auto-fix ${String(R)} of them.`)),w.error>0?1:0},M=e=>{if(!e)throw new Error("Could not determine workspace root. Run inside a monorepo.");return e},Oe=async({logger:e,options:t,visConfig:n,workspaceRoot:r})=>{const o=M(r),{packageJsons:s,workspace:i}=F(o,n),l=Y(o,i,s),a=(t.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(o,t.out??".vis/docker"),{projects:u}=X({focus:a,includeSources:!!t.includeSources,log:c=>{e.info(c)},outDir:d,projectGraph:l,pruneLockfile:t.pruneLockfile,workspace:i,workspaceRoot:o});e.info(`Scaffolded ${u.length} project(s) into ${d}`),e.info(`Focus closure: ${u.toSorted().join(", ")}`)},Pe=async({logger:e,options:t,visConfig:n,workspaceRoot:r})=>{const o=M(r),{workspace:s}=F(o,n),i=h(o,t.context??".vis/docker"),{removed:l}=z({contextRoot:i,workspace:s,workspaceRoot:o});e.info(`Pruned ${l.length} unfocused project(s)`),l.length>0&&e.debug?.(l.join(`
|
|
9
|
+
`))},je=async({argument:e,fs:t,logger:n,options:r,process:o,workspaceRoot:s})=>{const i=await $e({autoInstall:!!r.install,configPath:r.config,cwd:s??o.cwd,files:e.filter(Boolean),fix:!!r.fix,fs:t,json:!!r.json,logger:n});i!==0&&(process.exitCode=i)},ye=async(e,t)=>{try{return await e.access(t),!0}catch{return!1}},ve=async e=>{const t=O({input:process.stdin,output:process.stderr}),n=await new Promise(r=>{t.question(` ${e} already exists. Overwrite? ${m("[y/N]")} `,o=>{r(o.trim().toLowerCase())})});return t.close(),n==="y"||n==="yes"},Ue=async({argument:e,fs:t,logger:n,options:r,process:o,workspaceRoot:s})=>{const i=s??o.cwd,l=e[0]??"Dockerfile",a=U(l)?l:h(i,l),d=J(i)?.manager??"npm",u=(r.focus??"").split(",").map(f=>f.trim()).find(Boolean),c=se({focus:u,manager:d,nodeVersion:r.node??"22"});if(r.dryRun){process.stdout.write(c.endsWith(`
|
|
10
|
+
`)?c:`${c}
|
|
11
|
+
`);return}if(await ye(t,a)&&!r.force){if(!!!process.stdin.isTTY){n.error(`${a} already exists. Re-run with --force to overwrite.`),process.exitCode=1;return}if(!await ve(a)){n.info("Aborted — existing Dockerfile left untouched.");return}}await t.writeFile(a,c),n.info(`Created ${a} (package manager: ${d}).`),n.info(m(`Next: vis docker scaffold${u?` --focus=${u}`:""} --include-sources, then DOCKER_BUILDKIT=1 docker build .`))};export{Ue as initExecute,je as lintExecute,Pe as pruneExecute,Oe as scaffoldExecute};
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`);
|
|
3
|
-
`)}
|
|
4
|
-
${d(`Enter choice (1-${String(r.length)}):`)} `);if(s===""&&n!==void 0)return n;const i=Number.parseInt(s,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const a=r.find(c=>c===s);if(a)return a;process.stderr.write(` ${d("Invalid choice. Try again.")}
|
|
5
|
-
`)}},Ee=async(t,e,r,n)=>{process.stderr.write(` ${e} ${d("(comma-separated numbers)")}
|
|
6
|
-
`);for(const[s,i]of r.entries()){const a=y(v(` ${String(s+1)}.`)),c=n.includes(i)?d(" (default)"):"";process.stderr.write(`${a} ${i}${c}
|
|
7
|
-
`)}for(;;){const s=await q(t,`
|
|
8
|
-
${d("Enter choices:")} `);if(s===""&&n.length>0)return n;const i=s.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(` ${d("Invalid choice. Try again.")}
|
|
9
|
-
`)}},xe=t=>` ${d(`${t}:`)} `,Ne=(t,e)=>e.prompt??t,Oe=t=>Object.entries(t).sort(([e,r],[n,s])=>{const i=r.order??0,a=s.order??0;return i!==a?i-a:e.localeCompare(n)}),V=(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}},W=(t,e,r)=>{if(e.type==="enum"){const n=Array.isArray(r)?r:[r];for(const s of n)if(typeof s!="string"||!e.values.includes(s))throw new Error(`Variable "${t}" must be one of: ${e.values.join(", ")} (got "${String(s)}")`)}},_e=async t=>{const{defaults:e,interactive:r,overrides:n,variables:s}=t,i={},a=r?ce({input:process.stdin,output:process.stderr}):null;try{for(const[c,o]of Oe(s)){if(Object.hasOwn(n,c)){const m=V(o,n[c]??"");W(c,o,m),i[c]=m;continue}if(e||!r||o.internal){if(o.default!==void 0){W(c,o,o.default),i[c]=o.default;continue}if(o.required)throw new Error(`Required variable "${c}" not provided. Pass --${c}=<value> or remove --defaults.`);continue}const l=Ne(c,o);let u;if(o.type==="boolean")u=await Te(a,l,!!(o.default??!1));else if(o.type==="enum")if(o.multiple){const m=Array.isArray(o.default)?o.default:[];u=await Ee(a,l,o.values,m)}else{const m=typeof o.default=="string"?o.default:void 0;u=await Se(a,l,o.values,m)}else{const m=o.default===void 0?"":` (${String(o.default)})`,T=await q(a,xe(`${l}${m}`));if(T===""&&o.default!==void 0)u=o.default;else if(T===""){if(o.required)throw new Error(`Variable "${c}" is required`);continue}else u=V(o,T)}W(c,o,u),i[c]=u}return i}finally{a?.close()}},Be=["git://","npm://","https://","github:","gitlab:","bitbucket:","sourcehut:"],ke=t=>Be.some(e=>t.startsWith(e)),De=async(t,e={})=>{const r=e.targetDirectory===void 0,n=e.targetDirectory??le(S(ue(),"vis-generate-")),s=()=>{if(r)try{fe(n,{force:!0,recursive:!0})}catch{}};f.info(`Downloading ${t}…`);try{const i=await de(t,{auth:e.auth||process.env.GIGET_AUTH||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,dir:n,force:!0,preferOffline:e.preferOffline});return{cleanup:s,directory:i.dir}}catch(i){s();const a=i instanceof Error?i.message:String(i);throw f.warn(`Failed to download template: ${a}`),i}},Y=(t,e="")=>{const r=[];for(const[n,s]of Object.entries(t)){const i=e?`${e}/${n}`:n;typeof s=="string"||Buffer.isBuffer(s)?r.push({content:s,path:i}):s&&typeof s=="object"&&r.push(...Y(s,i))}return r},je=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,Ie=(t,e)=>{if(F(e))throw new Error(`Refusing to write outside destination: template produced absolute path "${e}".`);const r=S(t,e),n=G(t,r);if(n===".."||n.startsWith(`..${oe}`)||F(n))throw new Error(`Refusing to write outside destination: "${e}" resolves to "${r}" which escapes "${t}".`);return r},Re=(t,e)=>{J(K(t)),me(t,e)},qe=(t,e,r=!1)=>{const n=typeof t=="string"?[t]:t.commands,s=typeof t=="string"?r:t.silent??r;for(const i of n){s||f.info(`$ ${i}`);const a=pe(i,{cwd:e,shell:!0,stdio:s?"ignore":"inherit"});if(a.status!==0)return f.warn(`Script failed (exit ${String(a.status)}): ${i}`),!1}return!0},Le=t=>{const e=new Map;for(const r of t){const n=typeof r=="string"?0:r.phase??0,s=e.get(n);s?s.push(r):e.set(n,[r])}return[...e.entries()].sort(([r],[n])=>r-n)},We=async(t,e)=>{const n={builtins:{dest_dir:e.destination,dest_rel_dir:G(e.workspaceRoot,e.destination)||".",working_dir:e.cwd,workspace_root:e.workspaceRoot},options:e.options},s=await t.produce(n),i=s.files?Y(s.files):[],a=s.filesMeta??{},c=[];for(const o of i){const l=Ie(e.destination,o.path);c.push({file:o,meta:a[o.path]??{},target:l})}if(e.dryRun){f.info(`${y(v("Plan"))} ${d("(dry-run, no files written)")}`);for(const o of c){const l=Buffer.isBuffer(o.file.content)?o.file.content.length:Buffer.byteLength(o.file.content,"utf8");process.stderr.write(` ${d("write")} ${o.file.path} ${d(`(${je(l)})`)}
|
|
10
|
-
`)}}else{J(e.destination);let o=0,l=0;for(const u of c){const{file:m,meta:T,target:k}=u,b=_(k),E=e.force||T.force===!0;if(b&&!E){f.warn(`Skipped existing file: ${m.path} (use --force or set frontmatter force: true to overwrite)`),l+=1;continue}Re(k,m.content),o+=1}f.success(`Wrote ${String(o)} file${o===1?"":"s"}${l>0?`, skipped ${String(l)}`:""}`)}if(!e.dryRun&&!e.skipScripts&&s.scripts&&s.scripts.length>0){const o=Le(s.scripts);f.info(`Running ${String(s.scripts.length)} script${s.scripts.length===1?"":"s"} across ${String(o.length)} phase${o.length===1?"":"s"}…`);for(const[,l]of o)if((await Promise.all(l.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
|
-
`),f.notice("Next steps:");for(const o of s.suggestions)process.stderr.write(` ${d("•")} ${o}
|
|
12
|
-
`)}},Fe=async t=>{let e;try{e=(await t.load()).about?.description}catch{}return{description:e,name:t.name,path:t.path,source:t.source}},Me=(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(([n,s],[i,a])=>{const c=s.order??0,o=a.order??0;return c===o?n.localeCompare(i):c-o}).map(([n,s])=>Me(n,s));return{description:e.about?.description??"",destination:e.destination,name:t.name,path:t.path,source:t.source,variables:r}},Pe=t=>{if(t.length===0){f.info("No templates found."),f.notice("Create one at .vis/templates/<name>.ts (programmatic) or .vis/templates/<name>/ (moon-format with template.yml).");return}f.info("Available templates:");for(const e of t){const r=d(`(${e.source})`);process.stderr.write(` ${y(v(e.name))} ${r}
|
|
13
|
-
`)}},Ce=(t,e)=>{const r={},n=[];for(let s=0;s<t.length;s++){const i=t[s];if(!i.startsWith("--")){n.push(i);continue}const a=i.indexOf("=");if(a===-1){const l=i.slice(2);if(l.startsWith("no-"))r[l.slice(3)]="false";else{r[l]="true";const u=t[s+1];u!==void 0&&!u.startsWith("-")&&e?.(`\`--${l} ${u}\` was read as boolean \`--${l}=true\` and \`${u}\` was ignored. For a string value use \`--${l}=${u}\`.`)}continue}const c=i.slice(2,a),o=i.slice(a+1);r[c]=o}return{overrides:r,remaining:n}},Ue=async t=>{const{createInterface:e}=await import("node:readline"),r=e({input:process.stdin,output:process.stderr});try{process.stderr.write(` ${y(v("vis generate"))} ${d("— pick a template")}
|
|
14
|
-
|
|
15
|
-
`);for(const[n,s]of t.entries()){const i=y(v(` ${String(n+1)}.`));process.stderr.write(`${i} ${s.name} ${d(`(${s.source})`)}
|
|
16
|
-
`)}return new Promise((n,s)=>{r.question(`
|
|
17
|
-
${d(`Enter choice (1-${String(t.length)}):`)} `,i=>{const a=Number.parseInt(i.trim(),10);Number.isInteger(a)&&a>=1&&a<=t.length?n(t[a-1].name):s(new Error("Invalid choice."))})})}finally{r.close()}},Qe=async({argument:t,options:e,rawUnknown:r,visConfig:n,workspaceRoot:s})=>{const i=e.cwd||s||process.cwd(),a=s??i,c=n?.generator,o=Array.isArray(t)?t:t?[t]:[];if(e.list){const p=R({extraDirectories:c?.templates??[],onWarning:h=>{f.warn(h)},workspaceRoot:a});if(e.json){const h=await Promise.all(p.map(w=>Fe(w)));process.stdout.write(`${JSON.stringify(h,null,2)}
|
|
18
|
-
`);return}Pe(p);return}if(e.describe){const p=o[0];if(!p)throw new Error("`--describe` requires a template name. Run `vis generate --list` to see available templates.");const w=R({extraDirectories:c?.templates??[],onWarning:$=>{f.warn($)},workspaceRoot:a}).find($=>$.name===p);if(!w)throw new Error(`Template "${p}" not found. Run \`vis generate --list\` to see available templates.`);const g=await Ae(w);if(e.json){process.stdout.write(`${JSON.stringify(g,null,2)}
|
|
19
|
-
`);return}if(f.info(`Template: ${y(v(g.name))} ${d(`(${g.source})`)}`),g.description&&f.info(g.description),g.destination&&f.info(`Destination: ${d(g.destination)}`),g.variables.length===0)f.info("No variables.");else{f.info("Variables:");for(const $ of g.variables){const j=[$.type];$.required&&j.push("required"),$.default!==void 0&&j.push(`default=${JSON.stringify($.default)}`),$.values&&j.push(`values=${$.values.join("|")}`),process.stderr.write(` ${y(v($.name))} ${d(`(${j.join(", ")})`)}
|
|
20
|
-
`)}}return}let l=[...r??[]];if(l.length===0){const p=process.argv.slice(2),h=p.indexOf("--");h!==-1&&(l=p.slice(h+1))}const u=o.indexOf("--"),m=u===-1?[]:o.slice(u+1),T=u===-1?o:o.slice(0,u),{overrides:k}=Ce([...m,...l],p=>{f.warn(p)});let b,E,D;const N=T[0];let L;if(N&&ke(N)){const p=await De(N,{auth:c?.auth,preferOffline:!!e.preferOffline||c?.preferOffline});L=p.cleanup;try{const w=R({extraDirectories:[p.directory],workspaceRoot:a}).find(g=>g.path.startsWith(p.directory));if(!w)throw new Error(`Downloaded template at ${p.directory} contains no template.yml or *.ts entrypoint.`);b=await w.load(),E=w.name,D=b.destination}catch(h){throw L(),h}}else{const p=R({extraDirectories:c?.templates??[],onWarning:g=>{f.warn(g)},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 h;if(N)h=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.");h=await Ue(p)}const w=p.find(g=>g.name===h);if(!w)throw new Error(`Template "${h}" not found. Run 'vis generate --list' to see available templates.`);b=await w.load(),E=w.name,D=b.destination}const M=e.to,A=!!e.dryRun,Q=!!e.force,P=!!e.defaults,Z=!!e.skipScripts,ee=e.interactive!==!1&&!!process.stdin.isTTY&&!P;let x;M?x=M:D?x=D:x=".";const C=F(x)?x:ie(i,x);f.info(`Template: ${y(v(E))}`),f.info(`Target: ${d(C)}`),process.stderr.write(`
|
|
21
|
-
`);const te=await _e({defaults:P,interactive:ee,overrides:k,variables:b.options??{}});try{await We(b,{cwd:i,destination:C,dryRun:A,force:Q,options:te,skipScripts:Z,workspaceRoot:a}),A||(process.stderr.write(`
|
|
22
|
-
`),f.success(`Template '${E}' applied.`))}finally{L?.()}};export{Qe as default};
|
|
1
|
+
import{createRequire as H}from"node:module";import{J as A,q as U,j as W,F as E}from"../packem_shared/index.server-sXNQYpsl.js";import{a as P}from"../packem_shared/index-DHD8wb6Z.js";import{Z as I}from"./cli-main.js";import{d as F,f as C,r as Z,a as Q,b as X,s as Y,c as ee,e as te,g as se,h as ie,i as ne,j as re,k as ae,l as oe,m as ce,n as de,o as fe,p as le,q as ue,t as pe}from"../packem_shared/watch-loop-COWvvSbR.js";import{T as h}from"./catalog.js";let J;const D=t=>(J??=H(import.meta.url))(t),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=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 D(t)},{createHash:_}=G("node:crypto"),ge=t=>t.startsWith("/")||/^[a-z]:[\\/]/i.test(t),q=(t,e)=>ge(e)?e:`${t}/${e}`,me={argsCheck:(t,e)=>O(t,e,"check"),argsFix:(t,e)=>O(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 _("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=F(e,h.dprint.packageNames[0]),i=C(t,h.dprint.configFiles);if(!(!s&&!i))return{adapter:"dprint",configFile:i,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 i of t.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||n.startsWith("Checked ")||n.startsWith("Error:")||s.push({adapter:"dprint",file:q(e.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},O=(t,e,s)=>{const i=s==="fix"?["fmt"]:["check","--list-different"];return e.extraArgs?.length&&i.push(...e.extraArgs),i.push(...t),i},he={argsCheck:(t,e)=>V(t,e,"check"),argsFix:(t,e)=>V(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 _("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=F(e,h.oxfmt.packageNames[0]),i=C(t,h.oxfmt.configFiles);if(!(!s&&!i))return{adapter:"oxfmt",configFile:i,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 i of t.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||s.push({adapter:"oxfmt",file:q(e.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},V=(t,e,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return e.extraArgs?.length&&i.push(...e.extraArgs),i.push(...t),i},xe={argsCheck:(t,e)=>N(t,e,"check"),argsFix:(t,e)=>N(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 _("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=F(e,h.prettier.packageNames[0]),i=C(t,h.prettier.configFiles);if(!(!s&&!i))return{adapter:"prettier",configFile:i,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 i of t.stdout.split(/\r?\n/)){const n=i.trim();n&&(n.startsWith("[")||s.push({adapter:"prettier",file:q(e.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},N=(t,e,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return e.quiet&&i.push("--log-level","warn"),e.extraArgs?.length&&i.push(...e.extraArgs),i.push(...t),i},ke=[he,se,me,xe,ie,ne],Re=async({logger:t,options:e,visConfig:s,workspaceRoot:i})=>{const n=i??process.cwd(),p=s?.fmt,w=Z(ke,p?.order),L=Q(n,w),x=X(L,w,"fmt").filter(({adapter:l})=>p?.adapters?.[l.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 R=l=>{const a=p?.adapters?.[l]?.extraArgs;return a&&a.length>0?[...a]:void 0},v={quiet:e.quiet??!1},$=we(e),b=e.check?"check":"fix";let c;if(e.staged){if(c=Y(n),c===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(c.length===0){t.info(A("✓ fmt: no staged files"));return}}else if(typeof e.since=="string"&&e.since.length>0){if(c=ee(n,e.since),c===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(c.length===0){t.info(A(`✓ fmt: no files changed since ${e.since}`));return}}const K=I(n,void 0,void 0,!0),y=e.format??"human";y==="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 l=>{const a=$.length>0?$:l,g=[];if(a){const r=re(a,x,p?.extensionOverrides);for(const{adapter:o,presence:d}of x){const f=r.get(o.id);if(!f||f.length===0)continue;const B=R(o.id),T={adapter:o,files:f,presence:d};B&&(T.options={...v,extraArgs:B}),g.push(T)}}else for(const{adapter:r,presence:o}of x){const d=R(r.id),f={adapter:r,files:["."],presence:o};d&&(f.options={...v,extraArgs:d}),g.push(f)}if(g.length===0)return;const z=await ae(g,v,b,{cacheRoot:K}),j=g.map((r,o)=>{const d=z[o],f=r.adapter.parse(d,r.presence);return{adapter:r.adapter,durationMs:d.durationMs,exitCode:d.exitCode,findings:f}}),u=oe(j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,exitCode:r.exitCode,findingCount:r.findings.length,findings:r.findings}))),m=y==="human"?void 0:ce({cwd:n,target:e.output});try{switch(y){case"github":{m.write(le({runs:j.map(r=>({findings:r.findings})),workspaceRoot:n}));break}case"json":{m.write(`${JSON.stringify({findings:u.findings,mode:b,runs:u.runs},null,2)}
|
|
2
|
+
`);break}case"junit":{m.write(fe({runs:j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,findings:r.findings})),workspaceRoot:n}));break}case"minimal":{je(u.findings,n,m);break}case"sarif":{m.write(de({runs:j.map(r=>({adapter:r.adapter.id,findings:r.findings,presence:g.find(o=>o.adapter.id===r.adapter.id)?.presence})),workspaceRoot:n}));break}default:be(u.findings,n,b,t)}}finally{m?.close()}const S=b==="fix"?u.hadProcessFailure?1:0:ue({...u,maxSeverity:u.findings.length>0?"error":void 0});S!==0&&(process.exitCode=S)};if(e.watch){const l=[...new Set(x.flatMap(({adapter:a})=>a.extensions))];await te({extensions:l,initialFiles:c,label:"fmt",log:a=>{t.info(a)},runCycle:M,workspaceRoot:n});return}await M(c)},we=t=>{const e=t;return[...e._??e.args??[]]},be=(t,e,s,i)=>{if(t.length===0){i.info(A(s==="fix"?"✓ fmt: nothing to change":"✓ fmt: all files already formatted"));return}const n=pe(t),p=s==="fix"?U(W("Formatted:")):W("Would change:");i.info(p);for(const w of n.keys())i.info(` ${E("·")} ${P(e,w)}`);s==="check"&&(i.info(""),i.info(E(`Run \`vis fmt\` to apply changes (${String(n.size)} file${n.size===1?"":"s"}).`)))},je=(t,e,s)=>{for(const i of t)s.write(`${i.adapter} ${P(e,i.file)}
|
|
3
|
+
`)};export{Re as default};
|