@visulima/vis 1.0.0-alpha.23 → 1.0.0-alpha.25
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 +88 -0
- package/LICENSE.md +1262 -151
- package/README.md +5 -3
- package/dashboard/dist/index.html +29 -29
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/config/index.d.ts +27 -8
- package/dist/packem_chunks/bin.js +299 -290
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +2 -2
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +10 -10
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler2.js +2 -2
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +5 -5
- package/dist/packem_chunks/handler22.js +2 -2
- package/dist/packem_chunks/handler23.js +2 -2
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler30.js +1 -1
- package/dist/packem_chunks/handler31.js +1 -1
- package/dist/packem_chunks/handler32.js +3 -3
- package/dist/packem_chunks/handler34.js +5 -26
- package/dist/packem_chunks/handler35.js +22 -5
- package/dist/packem_chunks/handler36.js +60 -21
- package/dist/packem_chunks/handler37.js +6 -61
- package/dist/packem_chunks/handler38.js +24 -6
- package/dist/packem_chunks/handler39.js +152 -707
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler40.js +10 -24
- package/dist/packem_chunks/handler41.js +25 -286
- package/dist/packem_chunks/handler42.js +707 -152
- package/dist/packem_chunks/handler43.js +24 -10
- package/dist/packem_chunks/handler44.js +322 -25
- package/dist/packem_chunks/handler45.js +46 -24
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler47.js +7 -7
- package/dist/packem_chunks/handler48.js +65 -53
- package/dist/packem_chunks/handler5.js +3 -3
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +16 -16
- package/dist/packem_chunks/index.js +6 -6
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +2 -2
- package/dist/packem_chunks/prune.js +3 -3
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_shared/affected-shas-Dm7eqcI8.js +1 -0
- package/dist/packem_shared/{ai-analysis-B8pDCOuT.js → ai-analysis-Csn82p17.js} +1 -1
- package/dist/packem_shared/{ai-fix-DiGSrGKv.js → ai-fix-BlYyz5bI.js} +3 -3
- package/dist/packem_shared/{cyclonedx-B293T7R0.js → cyclonedx-D6F9rAay.js} +1 -1
- package/dist/packem_shared/dependency-scan-s2MD0vi-.js +1 -0
- package/dist/packem_shared/{docker-BhBBfWfc.js → docker-BU-7veP5.js} +1 -1
- package/dist/packem_shared/index-D9ZIw4ra.js +29 -0
- package/dist/packem_shared/index-PexbdLyT.js +1 -0
- package/dist/packem_shared/lifecycle-ChCFTm5Q.js +2 -0
- package/dist/packem_shared/{lockfile-CQLFNyVa.js → lockfile-BG1HvBzH.js} +1 -1
- package/dist/packem_shared/{min-release-age-Cz6HbF-I.js → min-release-age-heJgeP7o.js} +1 -1
- package/dist/packem_shared/peer-warnings-EvSJ18gE.js +1 -0
- package/dist/packem_shared/pm-runner-Cj76BV8q.js +1 -0
- package/dist/packem_shared/{provenance-BcldGs02.js → provenance-CdvMwB2R.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-2G-2HWtR.js → resolve-explicit-CRFybyxv.js} +1 -1
- package/dist/packem_shared/{s1ngularity-Boxkax0D.js → s1ngularity-CiZla5EP.js} +1 -1
- package/dist/packem_shared/{signatures-SO-fyExV.js → signatures-BsEDWhME.js} +1 -1
- package/dist/packem_shared/{typosquats-CioMnpnb.js → typosquats-_7T7U2q2.js} +1 -1
- package/dist/packem_shared/vis-update-app-qhQPV97i.js +1 -0
- package/index.js +52 -52
- package/package.json +14 -25
- package/schemas/project.schema.json +4 -0
- package/schemas/vis-config.schema.json +18 -13
- package/dist/packem_shared/dependency-scan-BbtivycX.js +0 -1
- package/dist/packem_shared/index-C1w1GXdS.js +0 -1
- package/dist/packem_shared/index-CZX_II5N.js +0 -29
- package/dist/packem_shared/lifecycle-wRE7ymVc.js +0 -2
- package/dist/packem_shared/pm-runner-CVliR6Ie.js +0 -1
- package/dist/packem_shared/vis-update-app-BWA1kA1q.js +0 -1
|
@@ -1,26 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
`):n==="
|
|
4
|
-
`):(
|
|
5
|
-
|
|
6
|
-
Fetching changelogs...`);const m=await he(n,void 0,s);for(const l of m){const f=l.releaseUrl??l.repoUrl??l.npmUrl;o.info(` ${l.packageName}: ${f}`)}}if(a.install??!0){const m=t,l=["install"];o.info(`Running ${m} ${l.join(" ")}...
|
|
7
|
-
`);try{ge(m,l,{cwd:e,env:process.env,stdio:"inherit"})}catch{o.warn(`${m} ${l.join(" ")} failed. You may need to run it manually.`)}}},"applyCatalogAndInstall"),vt=$(async(e,t,n,a,o,s)=>{const i=n.update??{},p=[["global","--global is not supported in catalog mode"],["recursive","--recursive is not needed in catalog mode (catalogs are workspace-level)"],["filter","--filter is not supported in catalog mode (use --include/--exclude instead)"],["no-save","--no-save is not supported in catalog mode"],["workspace-root","--workspace-root is not needed in catalog mode"],["no-optional","--no-optional is not supported in catalog mode"]];for(const[r,c]of p)a[r]&&s.warn(`${G("⚠")} ${c}, ignoring.`);const g=X("minReleaseAge"),{excludes:m,minutes:l}=g?{excludes:void 0,minutes:void 0}:ft(e,t),f=g?void 0:i.minimumReleaseAge??l,q=g?void 0:i.minimumReleaseAgeExclude??m;if(g&&(i.minimumReleaseAge!==void 0||l!==void 0)&&s.info("minimumReleaseAge gate disabled via MARSHALL_DISABLE_MIN_RELEASE_AGE."),!g&&i.minimumReleaseAge!==void 0&&l!==void 0&&i.minimumReleaseAge!==l){const r=t==="pnpm"?"pnpm-workspace.yaml":"bunfig.toml";s.warn(`${G("⚠")} minimumReleaseAge mismatch: vis config = ${String(i.minimumReleaseAge)} min, ${r} = ${String(l)} min. Consider keeping them in sync.`)}const b=_e(e),ee=a["include-internal"],te=a.peer,M=qe(e,t,{depFields:i.depFields,dev:a.dev,includeInternal:ee,peer:te,prod:a.prod});if(M.size===0){s.info("No catalogs found.");return}const ke={...i,minimumReleaseAge:f,minimumReleaseAgeExclude:q},E=ht(a,ke,o);let H=0;for(const r of M.values())H+=r.size;const B=!!process.stdout.isTTY&&!ve;let T;const we=B?(r,c)=>{T?T.rerender(k.createElement(le,{current:r,total:c})):(process.stdout.write(`
|
|
8
|
-
`),T=re(k.createElement(le,{current:r,total:c}),{interactive:!0,patchConsole:!1}))}:(r,c)=>{s.info(`Checking ${String(r)}/${String(c)} dependencies...`)};B||s.info(`Checking ${String(H)} catalog dependencies...
|
|
9
|
-
`);const Y=new Set;X("socket")&&Y.add("socket"),X("depsDev")&&Y.add("deps-dev");const L=n.security?.policies?.score?.minimum,ye=Be(n.security,{disabled:Y,minimumScore:L}),{checkedCount:w,failed:y,filteredByTarget:h,ignored:S,outdated:d}=await Le(M,E,b,we,e,ye,n.security?.acceptedRisks);T&&(T.clear(),T.unmount());const O=ee?{ignored:[],outdated:[]}:Oe(e,{depFields:i.depFields,dev:a.dev,exclude:E.exclude,ignore:E.ignore,include:E.include,packageMode:E.packageMode,peer:te,prod:a.prod,target:E.target});if(O.outdated.length>0){const r=new Set(d.map(c=>`${c.catalogName}|${c.packageName}`));for(const c of O.outdated)r.has(`${c.catalogName}|${c.packageName}`)||d.push(c)}if(O.ignored.length>0)for(const r of O.ignored)S.includes(r)||S.push(r);const ne=w-d.length-y.length;if(y.length>0&&s.warn(`Failed to fetch: ${y.join(", ")}`),S.length>0&&s.info(`Skipped ${String(S.length)} ignored package${S.length===1?"":"s"}: ${S.join(", ")}`),!B&&w>d.length){const r=[...M.values()].reduce((F,z)=>F+z.size,0),c=r>w?` (${String(r)} catalog entries, ${String(r-w)} duplicates)`:"";s.info(`Checked ${String(w)} unique packages${c}: ${String(d.length)} outdated, ${String(ne)} up-to-date${y.length>0?`, ${String(y.length)} failed`:""}${h.length>0?`, ${String(h.length)} skipped by target`:""}`)}if(d.length===0){h.length>0?s.info(`All catalog dependencies are up to date within the current target.
|
|
10
|
-
${String(h.length)} package${h.length===1?" has":"s have"} newer versions available with --target latest:
|
|
11
|
-
${h.map(r=>` ${r.packageName} ${r.currentRange} → ${r.newRange} (${r.updateType})`).join(`
|
|
12
|
-
`)}`):s.info("All catalog dependencies are up to date.");return}const U=a.format??i.format??"table";let R;if(a.ai){const r=Ye(a.aiType??"impact");R=await ze(d,s,n.ai,r)}const P=!!a.dryRun;if(!P&&o.length>0&&a.marshallCheck!==!1){const r=await Ke(o);if(r.length>0){const c=await Xe(r,{config:n?.security?.marshalls,workspaceRoot:e});if(!await Qe(c)){process.exitCode=1;return}}}if(B&&U==="table"){const r=new nt(d,R??null);let c;if(a.changelog){s.info("Fetching changelogs...");const u=await he(d,void 0,b);c=new Map;for(const v of u){const A=v.releaseUrl??v.repoUrl??v.npmUrl;A&&c.set(v.packageName,A)}}const F=n.tui?.autoExit??!1,z=F===!0?3:typeof F=="number"?F:0,ae=await re(k.createElement(at,{autoExitSeconds:z,changelogUrls:c,checkedCount:w,filteredOutEntries:h,isDryRun:P,store:r,totalCatalogEntries:H}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),Z=process.stdout.columns||80;process.stdout.write(`
|
|
13
|
-
`);for(const u of d){const v=u.vulnerabilities?.length||u.socketReport&&u.socketReport.alerts.length>0,A=!!u.acceptedRisk,K=v?A?"✓":"⚠":"✓",Re=A?"gray":u.updateType==="major"?"red":u.updateType==="minor"?"yellow":"green",I=u.socketReport?.score.overall,Ce=I===void 0?"":` [${String(Math.round(I*100))}%]`,se=I===void 0?void 0:Pe(I);process.stdout.write(`${Q(k.createElement(C,null," ",k.createElement(C,{color:Re},K),` ${u.packageName} ${u.currentRange} → ${u.newRange}`,k.createElement(C,{dimColor:!0},` ${u.updateType}`),se?k.createElement(C,{color:se},Ce):null),{columns:Z})}
|
|
14
|
-
`)}if(process.stdout.write(`
|
|
15
|
-
`),s.info(fe(d,L)),w>d.length){const u=[...M.values()].reduce((A,K)=>A+K.size,0),v=u>w?` (${String(u)} catalog entries, ${String(u-w)} duplicates)`:"";s.log(),s.info(`Checked ${String(w)} unique packages${v}: ${String(ne)} up-to-date${y.length>0?`, ${String(y.length)} failed`:""}`)}if(h.length>0){process.stdout.write(`
|
|
16
|
-
`);const u=`${String(h.length)} package${h.length===1?"":"s"} skipped by target constraint (use --target latest to include):`;process.stdout.write(`${Q(k.createElement(C,{color:"yellow"},` ${u}`),{columns:Z})}
|
|
17
|
-
`);for(const v of h)process.stdout.write(`${Q(k.createElement(C,null," ",k.createElement(C,{dimColor:!0},v.packageName),` ${v.currentRange} → ${v.newRange}`,k.createElement(C,{dimColor:!0},` ${v.updateType}`)),{columns:Z})}
|
|
18
|
-
`)}const J=Array.isArray(ae)?ae:[];if(J.length>0&&!P){s.info(`
|
|
19
|
-
Applying ${String(J.length)} updates...
|
|
20
|
-
`);const u={...a,install:a.install??i.install};await de(e,t,J,u,s,b,n.editorconfig??!0)}return}if(P){if(U==="json"){const r={failed:y,filteredByTarget:h,ignored:S,outdated:d};R&&(r.aiAnalysis=R),process.stdout.write(`${JSON.stringify(r,void 0,2)}
|
|
21
|
-
`)}else s.info(`Would update ${String(d.length)} dependencies:
|
|
22
|
-
`),ue(d,y,U,s,L),R&&(s.info(""),s.info(ie(R))),ce(h,s);return}R&&U!=="json"&&(s.info(ie(R)),s.info(""));let j=d;if(a.interactive&&(j=await Ie(d),j.length===0)){s.info("No updates selected.");return}s.info(`Updating ${String(j.length)} catalog dependencies...
|
|
23
|
-
`),ue(j,[],U,s,L),ce(h,s);const be={...a,install:a.install??i.install};await de(e,t,j,be,s,b)},"executeCatalogUpdate"),$t=$((e,t,n,a,o,s)=>{const i={dev:a.dev,filters:N(a.filter),global:a.global,interactive:a.interactive,latest:a.latest||a.target==="latest",noOptional:a.optional===!1,noSave:a.save===!1,packages:o,prod:a.prod,recursive:a.recursive,workspaceRoot:a.workspaceRoot},{command:p,warnings:g}=pt(t,n,i);for(const l of g)s.warn(l);const m=`${p.bin} ${p.args.join(" ")}`.trim();if(a.dryRun){s.info(`Would run: ${m}`);return}s.info(`Running: ${m}`);try{ge(p.bin,p.args,{cwd:e,env:process.env,stdio:"inherit"})}catch(l){const f=l.status??1;s.error(`
|
|
24
|
-
${me("✖")} Update failed (exit code ${String(f)})`),s.error(` Command: ${m}`),s.error(` Directory: ${e}
|
|
25
|
-
`),process.exitCode=f}},"executePmWrapper"),kt=$(async(e,t,n)=>{const a=e.latest===!0||e.target==="latest";if(t||!a||e.dryRun===!0||e.yes===!0||e.interactive===!0)return!0;if(!(process.stdout.isTTY&&!ve))return n.error(`${me("✖")} Refusing to run blanket --latest update in a non-interactive context.`),n.error(" Re-run with --yes to confirm, --dry-run to preview, or pass explicit package names."),process.exitCode=1,!1;const o=Ee({input:process.stdin,output:process.stdout});try{const s=(await new Promise(i=>{o.question(`${G("⚠")} About to upgrade ALL dependencies to their latest versions. This may include breaking changes.
|
|
26
|
-
Continue? [y/N] `,i)})).trim().toLowerCase();return s==="y"||s==="yes"?!0:(n.info("Aborted."),!1)}finally{o.close()}},"requireBlanketUpdateConfirmation"),_t=$(async({argument:e,logger:t,options:n,visConfig:a,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");let s=e;const i=o,{packageManager:p}=De(i);if(n.typosquatCheck!==!1){if(s.length>0){const g=s.map(f=>st(f)),m=a?.security?.typosquatAllowlist,l=await et(g.map(f=>f.name),m);if(!l.ok){process.exitCode=1;return}s=g.map((f,q)=>{const b=l.packages[q];return b!==f.name?f.versionSpec?`${b}@${f.versionSpec}`:b??"":s[q]??""})}else if(!await tt(i,a?.security?.typosquatAllowlist)){process.exitCode=1;return}}if(n.rollback){if(!We(i,p)){t.info("No backup found. Run 'vis update' first to create a backup.");return}if(Ve(i,p))t.info("Restored from backup.");else throw new Error("Failed to restore from backup.");return}if(await kt(n,s.length>0,t))if(n.catalog!==!1&&Ge(i,p))await vt(i,p,a??{},n,s,t);else{const g=Je(i,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),m=g.name==="aube"?"":He(g.name);$t(i,g.name,m,n,s,t)}},"execute");export{_t as default,Ft as formatMinutesAsTimeString,mt as parseNpmReleaseAgeValue,$e as parseTimeStringToMinutes,ft as readPmNativeMinimumReleaseAge,kt as requireBlanketUpdateConfirmation};
|
|
1
|
+
var F=Object.defineProperty;var R=(e,t)=>F(e,"name",{value:t,configurable:!0});import{createRequire as J}from"node:module";import{o as L,ac as Q,ad as I,ae as B,af as K,ag as Y,ah as g,ai as H,aj as U,ak as X,al as Z,am as ee,an as te,ao as oe,ap as ne,aq as se,ar as ie,as as re,at as ae}from"./bin.js";import{i as $,$ as T,M as d,Q as pe}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{e as fe,B as _}from"./config.js";import{v as le}from"../packem_shared/verify-C8EAHql6.js";const G=J(import.meta.url),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,z=R(e=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[t,n]=E.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return E.getBuiltinModule(e)}return G(e)},"__cjs_getBuiltinModule"),{readdirSync:ce,statSync:ue}=z("node:fs"),{stdin:A,stdout:ge}=E,{createInterface:de}=z("node:readline/promises");var me=Object.defineProperty,p=R((e,t)=>me(e,"name",{value:t,configurable:!0}),"u");const x="__global__",b=p(e=>[...new Set(e)].sort((t,n)=>t.localeCompare(n)),"sortStrings"),ve=p(e=>`{${Object.keys(e).sort().map(t=>`${t}=${JSON.stringify(e[t])}`).join(",")}}`,"canonicalizeObjectToken"),h=p(e=>{if(!Array.isArray(e))return[];const t=[];for(const n of e)typeof n=="string"?t.push(n):n&&typeof n=="object"&&t.push(ve(n));return b(t)},"normalizeTokenList"),w=p(e=>({cache:void 0,dependsOn:[],env:[],id:e,inputs:[],outputs:[]}),"emptyNode"),k=p((e,t,n)=>n?`^${t}`:e&&e!=="self"&&e!=="~"?`${e}#${t}`:t,"canonicalEdge"),ye=p((e,t)=>{const n=e.trim();if(t==="moon"){if(n.startsWith("^:"))return k(void 0,n.slice(2),!0);if(n.startsWith("~:"))return k(void 0,n.slice(2),!1);if(n.includes(":")){const[s,o]=n.split(":");return k(s,o??"",!1)}return n}if(n.startsWith("^"))return k(void 0,n.slice(1),!0);if(n.includes("#")){const[s,o]=n.split("#");return k(s,o??"",!1)}return n},"normalizeStringEdge"),M=p((e,t)=>{if(!Array.isArray(e))return[];const n=[];for(const s of e){if(typeof s=="string"){n.push(ye(s,t));continue}if(!s||typeof s!="object")continue;const o=s,{target:i}=o;if(!i)continue;if(o.dependencies===!0){n.push(k(void 0,i,!0));continue}if(o.projects===void 0){n.push(k(void 0,i,!1));continue}const r=Array.isArray(o.projects)?o.projects:[o.projects];for(const c of r)n.push(c==="^"?k(void 0,i,!0):k(c,i,!1))}return b(n)},"normalizeDependsOn"),O=p(e=>{if($(e))try{return JSON.parse(T(e))}catch{return}},"readJson"),he=p(e=>{const t=new Map,n=O(d(e,"turbo.json"));if(!n)return t;const s=n.tasks??n.pipeline??{};for(const[i,r]of Object.entries(s)){const c=i.includes("#")?i:`*#${i}`,a=w(c);a.dependsOn=M(r.dependsOn,"turbo"),a.inputs=h(r.inputs),a.outputs=h(r.outputs),a.env=b([...r.env??[],...r.passThroughEnv??[]]),a.cache=r.cache===!1?!1:void 0,t.set(c,a)}const o=w(x);return o.inputs=h(n.globalDependencies),o.env=b([...n.globalEnv??[],...n.globalPassThroughEnv??[]]),(o.inputs.length>0||o.env.length>0)&&t.set(x,o),t},"parseTurboModel"),ke=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),N=p((e,t,n=8)=>{const s=[],o=p((i,r)=>{if(r>n)return;let c;try{c=ce(i)}catch{return}for(const a of c.toSorted()){if(a===t){s.push(d(i,a));continue}if(a.startsWith(".")&&a!==".moon"||ke.has(a))continue;const u=d(i,a);try{ue(u).isDirectory()&&o(u,r+1)}catch{}}},"walk");return o(e,0),s},"findFiles"),V=p((e,t)=>{e.dependsOn=M(t.dependsOn,"nx"),e.inputs=h(t.inputs),e.outputs=h(t.outputs),e.cache=typeof t.cache=="boolean"?t.cache:void 0},"applyNxTarget"),we=p(e=>{const t=new Map,n=O(d(e,"nx.json"));for(const[s,o]of Object.entries(n?.targetDefaults??{})){const i=`*#${s}`,r=w(i);V(r,o),t.set(i,r)}for(const s of N(e,"project.json")){const o=O(s);if(!(!o?.name||!o.targets))for(const[i,r]of Object.entries(o.targets)){const c=`${o.name}#${i}`,a=w(c);V(a,r),t.set(c,a)}}return t},"parseNxModel"),D=p((e,t)=>{e.dependsOn=M(t.deps,"moon"),e.inputs=h(t.inputs),e.outputs=h(t.outputs),e.cache=typeof t.options?.cache=="boolean"?t.options.cache:void 0},"applyMoonTask"),q=p(e=>{if($(e))try{return L(e)}catch{return}},"readMoonYaml"),$e=p(e=>{const t=new Map,n=d(e,".moon"),s=[d(n,"tasks.yml"),d(n,"tasks.yaml")];for(const o of s){const i=q(o);if(i){for(const[r,c]of Object.entries(i.tasks??{})){const a=`*#${r}`,u=w(a);D(u,c),t.set(a,u)}if(i.implicitInputs&&i.implicitInputs.length>0){const r=w(x);r.inputs=h(i.implicitInputs),t.set(x,r)}}}for(const o of[...N(e,"moon.yml"),...N(e,"moon.yaml")]){const i=q(o);if(!i?.tasks)continue;const r=o.split(/[/\\]/).at(-2)??"*";for(const[c,a]of Object.entries(i.tasks)){const u=`${r}#${c}`,y=w(u);D(y,a),t.set(u,y)}}return t},"parseMoonModel"),xe=p((e,t)=>{e.dependsOn=M(t.dependsOn,"vis"),e.inputs=h(t.inputs),e.outputs=h(t.outputs),e.env=b([...t.env??[],...t.passThroughEnv??[],...t.options?.passThroughEnv??[]]),e.cache=t.cache===!1?!1:typeof t.cache=="boolean"?t.cache:void 0},"applyVisTask"),be=p(async e=>{const t=new Map,n=await fe(e);for(const[i,r]of Object.entries(n.tasks??{})){const c=`*#${i}`,a=w(c);xe(a,r??{}),t.set(c,a)}const s=n.taskRunner??{},o=w(x);return o.inputs=h(s.globalInputs),o.env=b([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(o.inputs.length>0||o.env.length>0)&&t.set(x,o),t},"buildVisModel"),Re=p((e,t)=>{switch(t){case"moon":return $e(e);case"nx":return we(e);default:return he(e)}},"buildSourceModel"),Ee=p(e=>{const t=[];return $(d(e,"turbo.json"))&&t.push("turbo"),$(d(e,"nx.json"))&&t.push("nx"),($(d(e,".moon","tasks.yml"))||$(d(e,".moon","tasks.yaml")))&&t.push("moon"),t.length===1?t[0]:void 0},"detectSourceTool"),S=p((e,t,n,s,o)=>{const i=s.filter(a=>!o.includes(a)),r=o.filter(a=>!s.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(", ")}]`),e.push({axis:n,detail:`${n} diverged: ${c.join("; ")}`,node:t,severity:i.length>0?"error":"warning"})},"diffArrayAxis"),Ce=p((e,t,n)=>{const s=[],o=b([...e.keys(),...t.keys()]);for(const i of o){const r=e.get(i),c=t.get(i);if(r&&!c){const a=n==="turbo"&&i.includes("#")&&!i.startsWith("*#")&&i!==x;s.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){s.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||(S(s,i,"dependsOn",r.dependsOn,c.dependsOn),S(s,i,"inputs",r.inputs,c.inputs),S(s,i,"outputs",r.outputs,c.outputs),S(s,i,"env",r.env,c.env),r.cache!==void 0&&c.cache!==void 0&&r.cache!==c.cache&&s.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 s.sort((i,r)=>i.node.localeCompare(r.node)||i.axis.localeCompare(r.axis)),{findings:s,source:n,sourceNodeCount:e.size,visNodeCount:t.size}},"diffModels"),je=new Set(["json","ndjson","table"]),Se=p(e=>({equivalent:e.findings.every(t=>t.severity!=="error"),findings:e.findings,source:e.source,sourceNodeCount:e.sourceNodeCount,visNodeCount:e.visNodeCount}),"toJsonPayload"),Me=p((e,t,n)=>{if(t==="json"){process.stdout.write(`${JSON.stringify(Se(e),void 0,2)}
|
|
2
|
+
`);return}if(t==="ndjson"){for(const s of e.findings)process.stdout.write(`${JSON.stringify(s)}
|
|
3
|
+
`);return}if(n.info(`Migration equivalence: ${e.source} → vis`),n.info(` source nodes: ${String(e.sourceNodeCount)} vis nodes: ${String(e.visNodeCount)}`),e.findings.length===0){n.info(" ✓ task graph + cache-key surface preserved (no divergence).");return}for(const s of e.findings){const o=` [${s.severity}] ${s.node} (${s.axis}) — ${s.detail}`;s.severity==="error"?n.warn(o):n.info(o)}},"formatEquivalenceReport"),Te=p((e,t)=>e.findings.some(n=>t==="warning"?!0:n.severity==="error")?1:0,"equivalenceExitCode");var Oe=Object.defineProperty,Ne=R((e,t)=>Oe(e,"name",{value:t,configurable:!0}),"n");const W=Ne(async e=>{if(!A.isTTY)return!0;const t=de({input:A,output:ge});try{const n=(await t.question(`${e} [Y/n] `)).trim().toLowerCase();return n===""||n==="y"||n==="yes"}finally{t.close()}},"confirm");var Ie=Object.defineProperty,C=R((e,t)=>Ie(e,"name",{value:t,configurable:!0}),"p");const _e=[{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"}],Ae=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],Ve=C(e=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${e}\2(\s*:)`,"gmu"),"buildKeyRegex"),De=C((e,t)=>{let n=e;const s=[];for(const o of t){const i=Ve(o.previous);i.test(n)&&(i.lastIndex=0,n=n.replace(i,(r,c,a,u)=>`${c}${a}${o.next}${a}${u}`),s.push(o))}return{applied:s,output:n}},"applyRenames"),P=C((e,t)=>De(e,t),"rewriteSource"),qe=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],Pe=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),ze=C(e=>{for(const t of qe){const n=d(e,t);if($(n))return n}},"findConfigFile"),Be=C(e=>{const t=[];try{for(const n of Q(e,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))Pe.has(pe(n.path))&&t.push(n.path)}catch{}return t},"findTaskConfigFiles"),We=C((e,t,n,s)=>{const o=ze(e);if(o){const r=T(o),{applied:c,output:a}=P(r,_e);if(c.length===0)n.info(`${o} already uses the current schema — no rewrite needed.`);else if(t.dryRun)n.info(`── ${o} (preview) ──`),n.info(a),n.info("── end preview ──"),n.info(`Would apply ${String(c.length)} rename(s): ${c.map(u=>u.description).join(", ")}`);else{I(o,s),_(o,a),n.info(`Rewrote ${o} (backup at ${o}.bak). Applied ${String(c.length)} rename(s).`);for(const u of c)s.manualSteps.push(`Renamed ${u.description} in ${o}`)}}else n.warn("No vis.config.ts found at workspace root — nothing to migrate."),s.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const i=t.taskConfigPaths??Be(e);for(const r of i){if(!$(r))continue;const c=T(r),a=P(c,Ae);if(a.applied.length!==0)if(t.dryRun)n.info(`── ${r} (preview) ──`),n.info(a.output),n.info("── end preview ──"),n.info(`Would apply ${String(a.applied.length)} rename(s): ${a.applied.map(u=>u.description).join(", ")}`);else{I(r,s),_(r,a.output),n.info(`Rewrote ${r} (backup at ${r}.bak). Applied ${String(a.applied.length)} rename(s).`);for(const u of a.applied)s.manualSteps.push(`Renamed ${u.description} in ${r}`)}}},"migrateSelf");var Fe=Object.defineProperty,f=R((e,t)=>Fe(e,"name",{value:t,configurable:!0}),"r");const l=f(e=>{const t=e.workspaceRoot??process.cwd(),n=e.visConfig??{};return{config:n,dryRun:!!e.options.dryRun,logger:e.logger,packageManager:K(t),report:B(),root:t,useEditorconfig:typeof n.editorconfig=="boolean"?n.editorconfig:!0}},"buildContext"),m=f(async(e,t,n)=>{if(t.yes||t.dryRun)return!0;const s=await W(`This will edit files, scripts, and hooks for "${e}". Backups (.bak) will be created. Continue?`);return s||n.info("Aborted."),s},"maybeConfirm"),v=f(e=>{e.dryRun&&e.logger.info(`Running in dry-run mode — no changes will be made.
|
|
4
|
+
`)},"announceDryRun"),Je=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("deps",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating dependencies and scripts ──"),Y(o.root,o.packageManager,o.config,{dryRun:o.dryRun},e,o.report),e.info(""),g(o.report,e)},"migrateDepsExecuteImpl"),Ge=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("lint-staged",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating lint-staged ──"),H(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateLintStagedExecuteImpl"),Le=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("nano-staged",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating nano-staged ──"),U(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateNanoStagedExecuteImpl"),Qe=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("turborepo",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating turborepo ──"),X(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateTurborepoExecuteImpl"),Ke=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("nx",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating nx ──");const i=!!t.aggressive;Z(o.root,{aggressive:i,dryRun:o.dryRun,force:i||!!t.force,rewriteSyncGenerators:i||!!t.rewriteSyncGenerators,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateNxExecuteImpl"),Ye=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("moon",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating moon ──"),ee(o.root,{copyTemplates:!!t.copyTemplates,dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateMoonExecuteImpl"),He=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("gitleaks",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating gitleaks ──"),te(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateGitleaksExecuteImpl"),Ue=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("kingfisher",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating Kingfisher ──"),oe(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateKingfisherExecuteImpl"),Xe=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("secretlint",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating secretlint ──"),ne(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateSecretlintExecuteImpl"),Ze=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("syncpack",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating syncpack ──"),se(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateSyncpackExecuteImpl"),et=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("sherif",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating sherif ──"),ie(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateSherifExecuteImpl"),tt=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("self",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating vis.config.ts to current schema ──"),We(o.root,{dryRun:o.dryRun},e,o.report),e.info(""),g(o.report,e)},"migrateSelfExecuteImpl"),ot=f(({logger:e,workspaceRoot:t})=>{const n=t??process.cwd();le(n,e).length>0&&(process.exitCode=1)},"migrateVerifyExecuteImpl"),nt=f(async({logger:e,options:t,workspaceRoot:n})=>{const s=n??process.cwd(),o=t.format??"table";if(!je.has(o)){e.warn(`Invalid --format: ${String(t.format)}. Expected table | json | ndjson.`),process.exitCode=1;return}const i=t.failOn==="warning"?"warning":"error";let r;if(t.from){if(t.from!=="turbo"&&t.from!=="nx"&&t.from!=="moon"){e.warn(`Invalid --from: ${t.from}. Expected turbo | nx | moon.`),process.exitCode=1;return}r=t.from}else if(r=Ee(s),!r){e.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=Re(s,r);if(c.size===0){e.warn(`No ${r} task graph found at ${s} — nothing to verify.`),process.exitCode=1;return}const a=await be(s);if(a.size===0){e.warn("No migrated vis task graph found (vis.config.ts has no tasks). Run the migrator first."),process.exitCode=1;return}const u=Ce(c,a,r);Me(u,o,e),process.exitCode=Te(u,i)},"migrateVerifyGraphExecuteImpl"),st=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{const o=s??process.cwd(),i=re(o,n??{}),r=ae(i);if(r.length===0){e.info("No applicable migrations detected in this workspace.");return}const c=!!t.dryRun;e.info(`Detected ${String(r.length)} migration(s):`);for(const y of r)e.info(` • ${y.title} — ${y.description}`);if(e.info(""),!t.yes&&!c&&!await W("Apply all detected migrations? Backups (.bak) will be created.")){e.info("Aborted.");return}c&&e.info(`Running in dry-run mode — no changes will be made.
|
|
5
|
+
`);const a=B(),u=[];for(const y of r)try{if(e.info(`── Applying ${y.title} ──`),c)for(const j of y.probe(i))e.info(j);else y.apply(i,a,e);e.info("")}catch(j){u.push({error:j,id:y.id}),e.warn(`Failed to apply ${y.title}: ${j.message}`)}g(a,e),u.length>0&&(e.warn(""),e.warn(`${String(u.length)} migration(s) failed — see messages above.`),process.exitCode=1)},"migrateAllExecuteImpl"),ft=Je,gt=Ge,dt=Le,lt=Qe,mt=Ke,vt=Ye,yt=He,ht=Ue,kt=Xe,wt=Ze,$t=et,xt=tt,bt=ot,Rt=nt,Et=st;export{Et as migrateAllExecute,ft as migrateDepsExecute,yt as migrateGitleaksExecute,ht as migrateKingfisherExecute,gt as migrateLintStagedExecute,vt as migrateMoonExecute,dt as migrateNanoStagedExecute,mt as migrateNxExecute,kt as migrateSecretlintExecute,xt as migrateSelfExecute,$t as migrateSherifExecute,wt as migrateSyncpackExecute,lt as migrateTurborepoExecute,bt as migrateVerifyExecute,Rt as migrateVerifyGraphExecute};
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
`);
|
|
3
|
-
`)
|
|
4
|
-
|
|
5
|
-
`)
|
|
1
|
+
var ae=Object.defineProperty;var j=(t,e)=>ae(t,"name",{value:e,configurable:!0});import{createRequire as ce}from"node:module";import{E as p,j as b,q as T}from"../packem_shared/index.server-B7ETiT4C.js";import{i as _,M as N,K as Y,a as L,z as Q,y as pe,C as fe}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{ac as X,p as l}from"./bin.js";import{f as $e}from"../packem_shared/giget-CcEy_Elm.js";import{b as Z,B as ye}from"./config.js";const le=ce(import.meta.url),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=j(t=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[e,r]=x.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return x.getBuiltinModule(t)}return le(t)},"__cjs_getBuiltinModule"),{fileURLToPath:ue}=P("node:url"),{createInterface:de}=P("node:readline"),{mkdtempSync:me,rmSync:he}=P("node:fs"),{tmpdir:ge}=P("node:os"),{spawnSync:we}=P("node:child_process");var ve=Object.defineProperty,y=j((t,e)=>ve(t,"name",{value:e,configurable:!0}),"i");const ee=[".ts",".mts",".cts",".js",".mjs",".cjs"],be="template.yml",Te=[".d",".test",".spec",".config",".bench",".stories"],Se=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],te=y(t=>{for(const e of ee)if(t.endsWith(e))return t.slice(0,-e.length);return t},"stripExtension"),Oe=y(t=>{if(Se.some(r=>t.endsWith(r))||!ee.some(r=>t.endsWith(r)))return!1;const e=te(t);return!Te.some(r=>e.endsWith(r))},"isNativeFile"),J=y((t,e)=>{const r=[];if(!_(t))return r;for(const s of X(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!Oe(s.name))continue;const n=te(s.name);r.push({load:y(()=>Ne(s.path),"load"),name:n,path:s.path,source:e})}return r},"scanNativeDirectory"),q=y((t,e)=>{const r=[];if(!_(t))return r;for(const s of X(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=N(s.path,be);_(n)&&r.push({load:y(()=>Re(s.path,s.name),"load"),name:s.name,path:s.path,source:e})}return r},"scanMoonDirectory"),je=y(()=>{try{const t=ue(import.meta.url),e=N(Y(t),"..","..","templates");return _(e)?e:void 0}catch{return}},"resolveBuiltinTemplatesDirectory"),I=y(t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...J(N(s,".vis","templates"),"native"),...q(N(s,".vis","templates"),"moon"),...q(N(s,".moon","templates"),"moon")];for(const o of e)n.push(...q(o,"config")),n.push(...J(o,"config"));const i=je();i&&n.push(...q(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))},"discoverTemplates"),Ne=y(async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},"loadNativeFromPath"),Re=y(async(t,e)=>{const{loadMoonTemplate:r}=await import("./index.js");return r(t,e)},"loadMoonFromPath");var Ee=Object.defineProperty,v=j((t,e)=>Ee(t,"name",{value:e,configurable:!0}),"c");const M=v((t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),"ask"),ke=v(async(t,e,r)=>{const s=await M(t,` ${e} ${p(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},"confirm"),xe=v(async(t,e,r,s)=>{process.stderr.write(` ${e}
|
|
2
|
+
`);for(const[n,i]of r.entries()){const a=b(T(` ${String(n+1)}.`)),o=i===s?p(" (default)"):"";process.stderr.write(`${a} ${i}${o}
|
|
3
|
+
`)}for(;;){const n=await M(t,`
|
|
4
|
+
${p(`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(` ${p("Invalid choice. Try again.")}
|
|
5
|
+
`)}},"selectOne"),_e=v(async(t,e,r,s)=>{process.stderr.write(` ${e} ${p("(comma-separated numbers)")}
|
|
6
|
+
`);for(const[n,i]of r.entries()){const a=b(T(` ${String(n+1)}.`)),o=s.includes(i)?p(" (default)"):"";process.stderr.write(`${a} ${i}${o}
|
|
7
|
+
`)}for(;;){const n=await M(t,`
|
|
8
|
+
${p("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(` ${p("Invalid choice. Try again.")}
|
|
9
|
+
`)}},"selectMany"),Pe=v(t=>` ${p(`${t}:`)} `,"promptText"),De=v((t,e)=>e.prompt??t,"variableLabel"),We=v(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)}),"sortVariables"),H=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}},"parseValue"),F=v((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)}")`)}},"validateValue"),Be=v(async t=>{const{defaults:e,interactive:r,overrides:s,variables:n}=t,i={},a=r?de({input:process.stdin,output:process.stderr}):null;try{for(const[o,c]of We(n)){if(Object.hasOwn(s,o)){const $=H(c,s[o]??"");F(o,c,$),i[o]=$;continue}if(e||!r||c.internal){if(c.default!==void 0){F(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 g=De(o,c);let m;if(c.type==="boolean")m=await ke(a,g,!!(c.default??!1));else if(c.type==="enum")if(c.multiple){const $=Array.isArray(c.default)?c.default:[];m=await _e(a,g,c.values,$)}else{const $=typeof c.default=="string"?c.default:void 0;m=await xe(a,g,c.values,$)}else{const $=c.default===void 0?"":` (${String(c.default)})`,S=await M(a,Pe(`${g}${$}`));if(S===""&&c.default!==void 0)m=c.default;else if(S===""){if(c.required)throw new Error(`Variable "${o}" is required`);continue}else m=H(c,S)}F(o,c,m),i[o]=m}return i}finally{a?.close()}},"collectOptions");var qe=Object.defineProperty,V=j((t,e)=>qe(t,"name",{value:e,configurable:!0}),"o");const Ie=["git://","npm://","https://","github:","gitlab:","bitbucket:","sourcehut:"],Me=V(t=>Ie.some(e=>t.startsWith(e)),"isRemoteSource"),Ce=V(async(t,e={})=>{const r=e.targetDirectory===void 0,s=e.targetDirectory??me(N(ge(),"vis-generate-")),n=V(()=>{if(r)try{he(s,{force:!0,recursive:!0})}catch{}},"cleanup");l.info(`Downloading ${t}…`);try{const i=await $e(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}},"fetchRemoteTemplate");var Ae=Object.defineProperty,R=j((t,e)=>Ae(t,"name",{value:e,configurable:!0}),"a");const re=R((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(...re(n,i))}return r},"flattenTree"),Fe=R(t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,"formatSize"),Le=R((t,e)=>{if(L(e))throw new Error(`Refusing to write outside destination: template produced absolute path "${e}".`);const r=N(t,e),s=Q(t,r);if(s===".."||s.startsWith(`..${pe}`)||L(s))throw new Error(`Refusing to write outside destination: "${e}" resolves to "${r}" which escapes "${t}".`);return r},"safeJoinDestination"),Ve=R((t,e)=>{Z(Y(t)),ye(t,e)},"writeOne"),Ke=R((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=we(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},"runScript"),ze=R(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)},"groupByPhase"),Ue=R(async(t,e)=>{const r={builtins:{dest_dir:e.destination,dest_rel_dir:Q(e.workspaceRoot,e.destination)||".",working_dir:e.cwd,workspace_root:e.workspaceRoot},options:e.options},s=await t.produce(r),n=s.files?re(s.files):[],i=s.filesMeta??{},a=[];for(const o of n){const c=Le(e.destination,o.path);a.push({file:o,meta:i[o.path]??{},target:c})}if(e.dryRun){l.info(`${b(T("Plan"))} ${p("(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(` ${p("write")} ${o.file.path} ${p(`(${Fe(c)})`)}
|
|
10
|
+
`)}}else{Z(e.destination);let o=0,c=0;for(const g of a){const{file:m,meta:$,target:S}=g,C=_(S),O=e.force||$.force===!0;if(C&&!O){l.warn(`Skipped existing file: ${m.path} (use --force or set frontmatter force: true to overwrite)`),c+=1;continue}Ve(S,m.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=ze(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(g=>Promise.resolve(Ke(g,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(` ${p("•")} ${o}
|
|
12
|
+
`)}},"runTemplate");var Ge=Object.defineProperty,w=j((t,e)=>Ge(t,"name",{value:e,configurable:!0}),"u");const Je=w(async t=>{let e;try{e=(await t.load()).about?.description}catch{}return{description:e,name:t.name,path:t.path,source:t.source}},"toListEntry"),He=w((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},"summarizeVariable"),Ye=w(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])=>He(s,n));return{description:e.about?.description??"",destination:e.destination,name:t.name,path:t.path,source:t.source,variables:r}},"describeTemplate"),Qe=w(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=p(`(${e.source})`);process.stderr.write(` ${b(T(e.name))} ${r}
|
|
13
|
+
`)}},"printList"),Xe=w(t=>{const e={},r=[];for(const s of t){if(!s.startsWith("--")){r.push(s);continue}const n=s.indexOf("=");if(n===-1){const o=s.slice(2);o.startsWith("no-")?e[o.slice(3)]="false":e[o]="true";continue}const i=s.slice(2,n),a=s.slice(n+1);e[i]=a}return{overrides:e,remaining:r}},"parsePassthroughOverrides"),Ze=w(async t=>{const{createInterface:e}=await import("node:readline"),r=e({input:process.stdin,output:process.stderr});try{process.stderr.write(` ${b(T("vis generate"))} ${p("— pick a template")}
|
|
14
|
+
|
|
15
|
+
`);for(const[s,n]of t.entries()){const i=b(T(` ${String(s+1)}.`));process.stderr.write(`${i} ${n.name} ${p(`(${n.source})`)}
|
|
16
|
+
`)}return new Promise((s,n)=>{r.question(`
|
|
17
|
+
${p(`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()}},"pickInteractive"),at=w(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 u=I({extraDirectories:o?.templates??[],onWarning:w(f=>{l.warn(f)},"onWarning"),workspaceRoot:a});if(e.json){const f=await Promise.all(u.map(d=>Je(d)));process.stdout.write(`${JSON.stringify(f,null,2)}
|
|
18
|
+
`);return}Qe(u);return}if(e.describe){const u=c[0];if(!u)throw new Error("`--describe` requires a template name. Run `vis generate --list` to see available templates.");const f=I({extraDirectories:o?.templates??[],onWarning:w(h=>{l.warn(h)},"onWarning"),workspaceRoot:a}).find(h=>h.name===u);if(!f)throw new Error(`Template "${u}" not found. Run \`vis generate --list\` to see available templates.`);const d=await Ye(f);if(e.json){process.stdout.write(`${JSON.stringify(d,null,2)}
|
|
19
|
+
`);return}if(l.info(`Template: ${b(T(d.name))} ${p(`(${d.source})`)}`),d.description&&l.info(d.description),d.destination&&l.info(`Destination: ${p(d.destination)}`),d.variables.length===0)l.info("No variables.");else{l.info("Variables:");for(const h of d.variables){const B=[h.type];h.required&&B.push("required"),h.default!==void 0&&B.push(`default=${JSON.stringify(h.default)}`),h.values&&B.push(`values=${h.values.join("|")}`),process.stderr.write(` ${b(T(h.name))} ${p(`(${B.join(", ")})`)}
|
|
20
|
+
`)}}return}let g=[...r??[]];if(g.length===0){const u=process.argv.slice(2),f=u.indexOf("--");f!==-1&&(g=u.slice(f+1))}const m=c.indexOf("--"),$=m===-1?[]:c.slice(m+1),S=m===-1?c:c.slice(0,m),{overrides:C}=Xe([...$,...g]);let O,D,W;const k=S[0];let A;if(k&&Me(k)){const u=await Ce(k,{auth:o?.auth,preferOffline:!!e.preferOffline||o?.preferOffline});A=u.cleanup;try{const f=I({extraDirectories:[u.directory],workspaceRoot:a}).find(d=>d.path.startsWith(u.directory));if(!f)throw new Error(`Downloaded template at ${u.directory} contains no template.yml or *.ts entrypoint.`);O=await f.load(),D=f.name,W=O.destination}catch(f){throw A(),f}}else{const u=I({extraDirectories:o?.templates??[],onWarning:w(h=>{l.warn(h)},"onWarning"),workspaceRoot:a});if(u.length===0)throw new Error("No templates found. Create one at .vis/templates/<name>.ts or .vis/templates/<name>/template.yml.");let f;if(k)f=k;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.");f=await Ze(u)}const d=u.find(h=>h.name===f);if(!d)throw new Error(`Template "${f}" not found. Run 'vis generate --list' to see available templates.`);O=await d.load(),D=d.name,W=O.destination}const K=e.to,z=!!e.dryRun,se=!!e.force,U=!!e.defaults,oe=!!e.skipScripts,ne=e.interactive!==!1&&!!process.stdin.isTTY&&!U;let E;K?E=K:W?E=W:E=".";const G=L(E)?E:fe(i,E);l.info(`Template: ${b(T(D))}`),l.info(`Target: ${p(G)}`),process.stderr.write(`
|
|
21
|
+
`);const ie=await Be({defaults:U,interactive:ne,overrides:C,variables:O.options??{}});try{await Ue(O,{cwd:i,destination:G,dryRun:z,force:se,options:ie,skipScripts:oe,workspaceRoot:a}),z||(process.stderr.write(`
|
|
22
|
+
`),l.success(`Template '${D}' applied.`))}finally{A?.()}},"execute");export{at as default};
|
|
@@ -1,22 +1,61 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)
|
|
3
|
-
`)}
|
|
4
|
-
${p(`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(` ${p("Invalid choice. Try again.")}
|
|
5
|
-
`)}},"selectOne"),_e=v(async(t,e,r,s)=>{process.stderr.write(` ${e} ${p("(comma-separated numbers)")}
|
|
6
|
-
`);for(const[n,i]of r.entries()){const a=b(T(` ${String(n+1)}.`)),o=s.includes(i)?p(" (default)"):"";process.stderr.write(`${a} ${i}${o}
|
|
7
|
-
`)}for(;;){const n=await M(t,`
|
|
8
|
-
${p("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(` ${p("Invalid choice. Try again.")}
|
|
9
|
-
`)}},"selectMany"),Pe=v(t=>` ${p(`${t}:`)} `,"promptText"),De=v((t,e)=>e.prompt??t,"variableLabel"),We=v(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)}),"sortVariables"),H=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}},"parseValue"),F=v((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)}")`)}},"validateValue"),Be=v(async t=>{const{defaults:e,interactive:r,overrides:s,variables:n}=t,i={},a=r?de({input:process.stdin,output:process.stderr}):null;try{for(const[o,c]of We(n)){if(Object.hasOwn(s,o)){const $=H(c,s[o]??"");F(o,c,$),i[o]=$;continue}if(e||!r||c.internal){if(c.default!==void 0){F(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 g=De(o,c);let m;if(c.type==="boolean")m=await ke(a,g,!!(c.default??!1));else if(c.type==="enum")if(c.multiple){const $=Array.isArray(c.default)?c.default:[];m=await _e(a,g,c.values,$)}else{const $=typeof c.default=="string"?c.default:void 0;m=await xe(a,g,c.values,$)}else{const $=c.default===void 0?"":` (${String(c.default)})`,S=await M(a,Pe(`${g}${$}`));if(S===""&&c.default!==void 0)m=c.default;else if(S===""){if(c.required)throw new Error(`Variable "${o}" is required`);continue}else m=H(c,S)}F(o,c,m),i[o]=m}return i}finally{a?.close()}},"collectOptions");var qe=Object.defineProperty,V=j((t,e)=>qe(t,"name",{value:e,configurable:!0}),"o");const Ie=["git://","npm://","https://","github:","gitlab:","bitbucket:","sourcehut:"],Me=V(t=>Ie.some(e=>t.startsWith(e)),"isRemoteSource"),Ce=V(async(t,e={})=>{const r=e.targetDirectory===void 0,s=e.targetDirectory??me(N(ge(),"vis-generate-")),n=V(()=>{if(r)try{he(s,{force:!0,recursive:!0})}catch{}},"cleanup");l.info(`Downloading ${t}…`);try{const i=await $e(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}},"fetchRemoteTemplate");var Ae=Object.defineProperty,R=j((t,e)=>Ae(t,"name",{value:e,configurable:!0}),"a");const re=R((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(...re(n,i))}return r},"flattenTree"),Fe=R(t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,"formatSize"),Le=R((t,e)=>{if(L(e))throw new Error(`Refusing to write outside destination: template produced absolute path "${e}".`);const r=N(t,e),s=Q(t,r);if(s===".."||s.startsWith(`..${pe}`)||L(s))throw new Error(`Refusing to write outside destination: "${e}" resolves to "${r}" which escapes "${t}".`);return r},"safeJoinDestination"),Ve=R((t,e)=>{Z(Y(t)),ye(t,e)},"writeOne"),Ke=R((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=we(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},"runScript"),ze=R(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)},"groupByPhase"),Ue=R(async(t,e)=>{const r={builtins:{dest_dir:e.destination,dest_rel_dir:Q(e.workspaceRoot,e.destination)||".",working_dir:e.cwd,workspace_root:e.workspaceRoot},options:e.options},s=await t.produce(r),n=s.files?re(s.files):[],i=s.filesMeta??{},a=[];for(const o of n){const c=Le(e.destination,o.path);a.push({file:o,meta:i[o.path]??{},target:c})}if(e.dryRun){l.info(`${b(T("Plan"))} ${p("(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(` ${p("write")} ${o.file.path} ${p(`(${Fe(c)})`)}
|
|
10
|
-
`)}}else{Z(e.destination);let o=0,c=0;for(const g of a){const{file:m,meta:$,target:S}=g,C=_(S),O=e.force||$.force===!0;if(C&&!O){l.warn(`Skipped existing file: ${m.path} (use --force or set frontmatter force: true to overwrite)`),c+=1;continue}Ve(S,m.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=ze(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(g=>Promise.resolve(Ke(g,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(` ${p("•")} ${o}
|
|
12
|
-
`)}},"runTemplate");var Ge=Object.defineProperty,w=j((t,e)=>Ge(t,"name",{value:e,configurable:!0}),"u");const Je=w(async t=>{let e;try{e=(await t.load()).about?.description}catch{}return{description:e,name:t.name,path:t.path,source:t.source}},"toListEntry"),He=w((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},"summarizeVariable"),Ye=w(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])=>He(s,n));return{description:e.about?.description??"",destination:e.destination,name:t.name,path:t.path,source:t.source,variables:r}},"describeTemplate"),Qe=w(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=p(`(${e.source})`);process.stderr.write(` ${b(T(e.name))} ${r}
|
|
13
|
-
`)}},"printList"),Xe=w(t=>{const e={},r=[];for(const s of t){if(!s.startsWith("--")){r.push(s);continue}const n=s.indexOf("=");if(n===-1){const o=s.slice(2);o.startsWith("no-")?e[o.slice(3)]="false":e[o]="true";continue}const i=s.slice(2,n),a=s.slice(n+1);e[i]=a}return{overrides:e,remaining:r}},"parsePassthroughOverrides"),Ze=w(async t=>{const{createInterface:e}=await import("node:readline"),r=e({input:process.stdin,output:process.stderr});try{process.stderr.write(` ${b(T("vis generate"))} ${p("— pick a template")}
|
|
1
|
+
var H=Object.defineProperty;var j=(e,t)=>H(e,"name",{value:t,configurable:!0});import{createRequire as K}from"node:module";import{b as V,B as A,w as X}from"./config.js";import{$ as Y,K as D,z as T,M as C}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{o as Z}from"../packem_shared/index-DH-5hsrC.js";import{av as P,C as ee,aw as te,X as oe}from"./bin.js";import{i as re}from"../packem_shared/glob-MHJQjR39-CQ2GC0b_.js";import{n as ne}from"../packem_shared/manifests-Z3spBpxv.js";const z=K(import.meta.url),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Q=j(e=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[t,o]=O.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return O.getBuiltinModule(e)}return z(e)},"__cjs_getBuiltinModule"),{readFileSync:F}=Q("node:fs");var se=Object.defineProperty,y=j((e,t)=>se(e,"name",{value:t,configurable:!0}),"c");const ie=y((e,t)=>{const o=t.replace(/^\.?\//,"");return o===""||o==="."?`/${e}/`:e===""||e==="."?`/${o}`:`/${e}/${o}`},"toWorkspacePath"),_=y((e,t,o=[])=>{const s=[],r=new Set;for(const[i,n]of Object.entries(t?.globalPaths??{}))s.push({owners:n,path:i,source:"project-json"}),r.add(i);for(const[i,n]of Object.entries(e.projects)){const a=n.owners??[];for(const c of a){const l=ie(n.root??i,c.path);s.push({channel:c.channel,owners:c.owners,path:l,projectId:i,source:"project-json"}),r.add(l)}}for(const i of o)r.has(i.path)||(s.push(i),r.add(i.path));return(t?.orderBy??"file-source")==="project-id"?s.sort((i,n)=>(i.projectId??"").localeCompare(n.projectId??"")||i.path.localeCompare(n.path)):s.sort((i,n)=>i.path.localeCompare(n.path)),s},"buildCodeownersLines"),ae="Update each project's project.json `owners` field and re-run the command.",ce=y(e=>["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.",e?`# Re-run with: ${e}`:`# ${ae}`,""],"buildHeader"),M=y(e=>{const t=[];for(const o of e){const s=o.owners.join(" "),r=o.channel?` # notify: ${o.channel}`:"";t.push(`${o.path} ${s}${r}`)}return t},"renderEntries"),de=y((e,t={})=>[...ce(t.regenerationCommand),...M(e),""].join(`
|
|
2
|
+
`),"renderCodeowners"),S={begin:"# BEGIN vis-codeowners",end:"# END vis-codeowners"},le=y((e,t=S,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,...M(e),t.end].join(`
|
|
3
|
+
`)},"renderCodeownersBlock"),ue=y((e,t,o=S)=>{const s=e.indexOf(o.begin),r=e.indexOf(o.end);if(s!==-1&&r!==-1&&r>s){const n=e.slice(0,s),a=r+o.end.length,c=e.slice(a);return`${n}${t}${c}`}const i=e.replace(/\s+$/u,"");return`${i.length===0?"":`${i}
|
|
14
4
|
|
|
15
|
-
`
|
|
16
|
-
`)}return new
|
|
17
|
-
|
|
18
|
-
`);return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
`}${t}
|
|
6
|
+
`},"mergeIntoExisting");var fe=Object.defineProperty,N=j((e,t)=>fe(e,"name",{value:t,configurable:!0}),"f$1");const pe=["**/CODEOWNERS"],he=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"],ge=N(e=>{const t=[];for(const o of e.split(/\r?\n/u)){const s=o.indexOf("#"),r=(s===-1?o:o.slice(0,s)).trim();if(r.length===0)continue;const i=r.split(/\s+/u);if(i.length<2)continue;const[n,...a]=i,c=a.filter(l=>l.length>0);!n||c.length===0||t.push({owners:c,path:n})}return t},"parseCodeownersFile"),me=N((e,t)=>{const o=t.replace(/^\.\/?/,"").replace(/\/$/,"");return e.startsWith("/")?o===""?e:`/${o}${e}`:o===""?`/${e}`:`/${o}/${e}`},"rewriteNestedPath"),we=N(async(e,t,o)=>{const s=t&&t.length>0?[...t]:[...pe],r=[...he];if(o){const a=o.replace(/^\.\/?/,"").replace(/^\/+/,"");a.length>0&&r.push(a)}const i=await re(s,{absolute:!0,cwd:e,ignore:r}),n=[];for(const a of i){let c;try{c=Y(a)}catch{continue}const l=D(a),p=T(e,l);for(const m of ge(c))n.push({owners:m.owners,path:me(m.path,p)})}return n},"collectNestedCodeownersLines"),be=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)/iu,$e=N(e=>{if(!e)return;const t=e.match(be);if(!t?.[1])return;const o=t[1].trim();if(!(o===""||o.includes(" ")))return`@${o.replace(/^@/,"")}`},"extractGitHubHandle"),je=N((e,t)=>{const o=[];for(const[s,r]of Object.entries(e.projects)){if(r.owners&&r.owners.length>0)continue;const i=r.root??s,n=C(t,i,"package.json"),a=P(n);if(!a)continue;const c=ne(a.maintainers);if(!c||c.length===0)continue;const l=[],p=new Set;for(const m of c){const w=$e(m.url);w&&!p.has(w)&&(p.add(w),l.push(w))}l.length!==0&&o.push({owners:l,path:i===""||i==="."?"/":`/${i}/`,projectId:s})}return o},"collectMaintainerLines");var ye=Object.defineProperty,v=j((e,t)=>ye(e,"name",{value:t,configurable:!0}),"s");const ke=["author","bugs","homepage","license","repository","engines"],I=v(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isPlainObject"),R=v((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(!R(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 r of o)if(!R(e[r],t[r]))return!1;return!0}return!1},"deepEqual"),x=v(e=>e===void 0?e:structuredClone(e),"cloneJson"),Ce=v((e,t,o)=>{if(e==="repository"&&I(t)&&I(o)){const s={};for(const[r,i]of Object.entries(t))r!=="directory"&&(s[r]=x(i));return typeof o.directory=="string"&&(s.directory=o.directory),s}return x(t)},"buildTargetValue"),ve=v((e,t,o)=>{const s=[];for(const r of o.fields){if(!Object.hasOwn(e,r))continue;const i=e[r],n=t[r],a=Ce(r,i,n);R(a,n)||s.push({after:a,before:n,field:r,packageJsonPath:""})}return s},"computeFieldChanges"),Ee=v((e,t)=>{for(const o of t)e[o.field]=o.after},"applyFieldChanges");var Oe=Object.defineProperty,G=j((e,t)=>Oe(e,"name",{value:t,configurable:!0}),"n");const U="Generated by `vis sync codeowners --write-guard`. Do not edit by hand.",Ne=G(e=>{const t=e.replace(/^\.?\/+/u,"").replace(/\/+$/u,"");return t===""||t==="."?"**":`${t}/**`},"toPathGlob"),q=G(e=>{const t=new Set,o=[];for(const s of[...e].sort((r,i)=>r.name.localeCompare(i.name))){const r=Ne(s.root);t.has(r)||(t.add(r),o.push(r))}return o},"resolveGlobs"),Ge=G(e=>{const t=q(e),o=t.map(r=>` - "${r}"`).join(`
|
|
7
|
+
`),s=t.map(r=>` ${r}`).join(`
|
|
8
|
+
`);return`# ${U}
|
|
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
|
+
`},"renderGithubWriteGuard"),Pe=G(e=>{const t=q(e).map(o=>` - "${o}/*"`).join(`
|
|
33
|
+
`);return`# ${U}
|
|
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
|
+
`},"renderGitlabWriteGuard"),Re=G(e=>e.length===0?[]:[{content:Ge(e),path:".github/workflows/write-guard.yml"},{content:Pe(e),path:".gitlab/write-guard.gitlab-ci.yml"}],"buildWriteGuardArtifacts");var Se=Object.defineProperty,k=j((e,t)=>Se(e,"name",{value:t,configurable:!0}),"m");const B=new Set(["nested-codeowners","package-json-maintainers","project-json"]),J=k((e,t,o)=>{const s=new Set,r=[];for(const i of e??[])for(const n of i.split(",")){const a=n.trim();if(a.length===0)continue;if(o&&!o(a))throw new Error(`Unknown codeowners source: "${a}". Known: ${[...B].join(", ")}.`);const c=a;s.has(c)||(s.add(c),r.push(c))}return r.length>0?r:[...t]},"parseCsvOption"),We=k(e=>B.has(e),"isCodeownersSource"),L=["codeowners","package-json-fields"],_e=k((e,t)=>t.some(o=>Z(o,e)),"matchesAnyGlob"),Ie=k((e,t,o,s)=>{const r=Object.entries(o.projects).filter(([,n])=>n.restricted===!0).map(([n,a])=>({name:n,root:a.root??n})),i=Re(r);if(i.length===0){e.info("No projects flagged `restricted: true` in project.json. Skipping Write Guard.");return}if(s){let n=!1;for(const a of i){const c=C(t,a.path);let l="";try{l=F(c,"utf8")}catch(p){if(p.code!=="ENOENT")throw p}l.trim()!==a.content.trim()&&(e.error(`${a.path} is out of date. Run \`vis sync codeowners --write-guard\` to update it.`),n=!0)}n?process.exitCode=1:e.info(`Write Guard CI is up to date (${i.length} files, ${r.length} restricted projects).`);return}for(const n of i){const a=C(t,n.path);V(D(a)),A(a,n.content),e.info(`Wrote ${n.path}`)}e.info(`Write Guard CI scoped to ${r.length} restricted project${r.length===1?"":"s"}.`)},"handleWriteGuard"),xe=k(async({logger:e,options:t,visConfig:o,workspaceRoot:s})=>{const r=s,{workspace:i}=ee(r,o),n=o?.codeowners;t.writeGuard===!0&&Ie(e,r,i,t.check===!0);const a=J(t.from,n?.sources??["project-json"],We),c=t.regenerationCommand??n?.regenerationCommand,l=t.preserveBlock===!0||n?.preserveBlock===!0,p=n?.blockMarker??S,m=t.nestedIncludes??n?.nestedIncludes,w=t.out??"CODEOWNERS",f=[];if(a.includes("nested-codeowners")){const g=await we(r,m,w);for(const $ of g)f.push({...$,source:"nested"})}if(a.includes("package-json-maintainers")){const g=je(i,r);for(const $ of g)f.push({...$,source:"maintainers"})}const b=a.includes("project-json")?_(i,n,f):_({projects:{}},n,f);if(b.length===0){e.info("No `owners` entries found in any source. Nothing to sync.");return}const u=C(r,w);let E="";try{E=F(u,"utf8")}catch(g){if(g.code!=="ENOENT")throw g}const d={regenerationCommand:c},h=l?ue(E,le(b,p,d),p):de(b,d);if(t.check){if(E.trim()!==h.trim()){e.error(`${u} is out of date. Run \`vis sync codeowners\` to update it.`),process.exitCode=1;return}e.info(`${u} is up to date.`);return}A(u,h),e.info(`Wrote ${b.length} entries to ${u}`)},"runCodeowners"),Le=k(({logger:e,options:t,visConfig:o,workspaceRoot:s})=>{const r=s,i=o?.editorconfig??!0,n=P(C(r,"package.json"));if(!n){e.error("Could not read root package.json. Nothing to sync."),process.exitCode=1;return}const a=J(t.fields,ke),c=t.ignorePackageName??[],l=t.check===!0,p=(t.format??"human").toLowerCase(),m=t.quiet===!0,w=te(r).filter(d=>d!=="."),f=[];let b=0;for(const d of w){const h=C(r,d,"package.json"),g=P(h);if(!g)continue;const $=typeof g.name=="string"?g.name:void 0;if($!==void 0&&c.length>0&&_e($,c))continue;b+=1;const W=ve(n,g,{fields:a});W.length!==0&&f.push({filePath:h,packageJsonPath:T(r,h),packageName:$,pkg:g,pkgChanges:W})}if(!l)for(const d of f)Ee(d.pkg,d.pkgChanges),X(d.filePath,d.pkg,{indent:oe(d.filePath,{useEditorconfig:i}),overwrite:!0});const u=f.flatMap(d=>d.pkgChanges.map(h=>({after:h.after,before:h.before,field:h.field,packageJsonPath:d.packageJsonPath,packageName:d.packageName}))),E={changes:u,fields:a,kind:"package-json-fields",mode:l?"check":"write",totalChanges:u.length,totalPackages:b};if(p==="json")process.stdout.write(`${JSON.stringify(E,null,4)}
|
|
61
|
+
`);else if(u.length===0)e.info(`All ${b} package${b===1?"":"s"} in sync (fields: ${a.join(", ")}).`);else if(l){if(!m)for(const d of u)e.error(`${d.packageJsonPath}: ${d.field} drifts from root`);e.error(`Found ${u.length} field drift${u.length===1?"":"s"} across ${f.length} package${f.length===1?"":"s"}. Run \`vis sync package-json-fields\` to fix.`)}else{if(!m)for(const d of f)e.info(`${d.packageJsonPath}: synced ${d.pkgChanges.map(h=>h.field).join(", ")}`);e.info(`Synced ${u.length} field${u.length===1?"":"s"} across ${f.length} package${f.length===1?"":"s"}.`)}l&&u.length>0&&(process.exitCode=1)},"runPackageJsonFields"),Je=k(async e=>{const t=e.argument[0];if(!t)throw new Error(`Missing sync kind. Usage: vis sync <kind> (known kinds: ${L.join(", ")})`);if(!e.workspaceRoot)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(t==="codeowners"){await xe(e);return}if(t==="package-json-fields"){Le(e);return}throw new Error(`Unknown sync kind: "${t}". Known kinds: ${L.join(", ")}.`)},"execute");export{Je as default};
|