@visulima/vis 1.0.0-alpha.42 → 1.0.0-alpha.44
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 +54 -0
- package/LICENSE.md +256 -0
- package/bin/resolve-binary.mjs +85 -0
- package/bin/vis.mjs +76 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +1 -2
- package/dist/binx.js +1 -1
- package/dist/config/index.js +1 -1
- package/dist/packem_chunks/CONFIG_FILES.js +8 -0
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +113 -0
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +297 -434
- package/dist/packem_chunks/detect.js +3 -3
- package/dist/packem_chunks/dispatch.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +5 -1
- package/dist/packem_chunks/handler11.js +1 -5
- package/dist/packem_chunks/handler12.js +27 -1
- package/dist/packem_chunks/handler13.js +5 -27
- package/dist/packem_chunks/handler14.js +1 -5
- 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 +5 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +2 -5
- package/dist/packem_chunks/handler21.js +2 -2
- package/dist/packem_chunks/handler22.js +14 -2
- package/dist/packem_chunks/handler23.js +1 -5
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler26.js +5 -1
- package/dist/packem_chunks/handler27.js +1 -5
- package/dist/packem_chunks/handler28.js +3 -1
- package/dist/packem_chunks/handler29.js +1 -3
- package/dist/packem_chunks/handler3.js +4 -1
- package/dist/packem_chunks/handler30.js +1 -1
- package/dist/packem_chunks/handler31.js +2 -1
- package/dist/packem_chunks/handler32.js +2 -2
- package/dist/packem_chunks/handler33.js +2 -2
- package/dist/packem_chunks/handler34.js +3 -2
- package/dist/packem_chunks/handler35.js +6 -3
- package/dist/packem_chunks/handler36.js +1 -6
- package/dist/packem_chunks/handler37.js +42 -1
- package/dist/packem_chunks/handler38.js +8 -42
- package/dist/packem_chunks/handler39.js +9 -8
- package/dist/packem_chunks/handler4.js +4 -4
- package/dist/packem_chunks/handler40.js +75 -9
- package/dist/packem_chunks/handler41.js +5 -75
- package/dist/packem_chunks/handler42.js +4 -5
- package/dist/packem_chunks/handler43.js +3 -4
- package/dist/packem_chunks/handler44.js +2 -3
- package/dist/packem_chunks/handler45.js +1 -2
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler47.js +1 -1
- package/dist/packem_chunks/handler48.js +3 -1
- package/dist/packem_chunks/handler49.js +1 -3
- package/dist/packem_chunks/handler5.js +6 -4
- package/dist/packem_chunks/handler50.js +7 -1
- package/dist/packem_chunks/handler51.js +32 -6
- package/dist/packem_chunks/handler52.js +3 -33
- package/dist/packem_chunks/handler53.js +8 -3
- package/dist/packem_chunks/handler54.js +2 -6
- package/dist/packem_chunks/handler55.js +1 -4
- package/dist/packem_chunks/handler56.js +12 -1
- package/dist/packem_chunks/handler57.js +5 -12
- package/dist/packem_chunks/handler58.js +11 -5
- package/dist/packem_chunks/handler59.js +3 -11
- package/dist/packem_chunks/handler6.js +8 -6
- package/dist/packem_chunks/handler60.js +22 -3
- package/dist/packem_chunks/handler61.js +60 -21
- package/dist/packem_chunks/handler62.js +3 -61
- package/dist/packem_chunks/handler63.js +6 -3
- package/dist/packem_chunks/handler64.js +9 -6
- package/dist/packem_chunks/handler65.js +2 -9
- package/dist/packem_chunks/handler66.js +13 -13
- package/dist/packem_chunks/handler67.js +5 -5
- package/dist/packem_chunks/handler68.js +1 -1
- package/dist/packem_chunks/handler69.js +4 -4
- package/dist/packem_chunks/handler7.js +1 -8
- package/dist/packem_chunks/handler70.js +16 -17
- package/dist/packem_chunks/handler71.js +12 -12
- package/dist/packem_chunks/handler72.js +5 -5
- package/dist/packem_chunks/handler73.js +7 -7
- package/dist/packem_chunks/handler74.js +3 -3
- package/dist/packem_chunks/handler75.js +3 -3
- package/dist/packem_chunks/handler76.js +63 -63
- package/dist/packem_chunks/handler77.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 +1 -1
- package/dist/packem_chunks/index2.js +2 -2
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/lean.js +3 -3
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/loader2.js +1 -1
- package/dist/packem_chunks/orchestrator.js +19 -19
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/ts-loader.js +22 -2
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_chunks/version-resolver.js +1 -1
- package/dist/packem_shared/{advisories-aiDtubZQ.js → advisories-CefYKEPe.js} +1 -1
- package/dist/packem_shared/{affected-shas-C1XuRlvo.js → affected-shas-CwRY5aoc.js} +1 -1
- package/dist/packem_shared/{ai-analysis-CubpCxZJ.js → ai-analysis-CO6S0afy.js} +7 -7
- package/dist/packem_shared/{ai-fix-Btd5AnSr.js → ai-fix-CI0Vvqld.js} +9 -9
- package/dist/packem_shared/augment-DaSS2Lgs.js +4 -0
- package/dist/packem_shared/bin-P6Q5tKrP.js +1 -0
- package/dist/packem_shared/{build-scripts-Doxce2VM.js → build-scripts-MTSK6TNr.js} +1 -1
- package/dist/packem_shared/{command-runtime-RiCMa2C8.js → command-runtime-BE-vKsGH.js} +1 -1
- package/dist/packem_shared/{cyclonedx-NUJ9R2GQ.js → cyclonedx-BeUmPgfO.js} +1 -1
- package/dist/packem_shared/dependency-scan-DpOFiZuI.js +1 -0
- package/dist/packem_shared/{docker-DKlF-gk3.js → docker-CViFYtmM.js} +1 -1
- package/dist/packem_shared/env-C2ZCnfP_.js +27 -0
- package/dist/packem_shared/failure-log-jFfZRJK9.js +2 -0
- package/dist/packem_shared/glob-fqg4KepW-1S3z30c8.js +1 -0
- package/dist/packem_shared/index-B0EsgdzO.js +1 -0
- package/dist/packem_shared/index-CE6MsgcV.js +22 -0
- package/dist/packem_shared/index-CQjzW7m8.js +1 -0
- package/dist/packem_shared/{index-Cb4x6lWY.js → index-Cg0IHaFI.js} +1 -1
- package/dist/packem_shared/{index-CPhv-r4c.js → index-D7EZ612R.js} +13 -13
- package/dist/packem_shared/{lifecycle-D5roTh0a.js → lifecycle-Dyb47wbD.js} +1 -1
- package/dist/packem_shared/{lockfile-DIGyLfmF.js → lockfile-C1qCKGH6.js} +1 -1
- package/dist/packem_shared/{manifests-pLwnVmCN.js → manifests-WBnsV_Eb.js} +1 -1
- package/dist/packem_shared/{min-release-age-pUAqTiv3.js → min-release-age-C71MO72F.js} +1 -1
- package/dist/packem_shared/missing-package-json-CTF71tE5.js +1 -0
- package/dist/packem_shared/{native-config-sync-4K9wWTj5.js → native-config-sync-BFDVK9LH.js} +4 -4
- package/dist/packem_shared/{osv-bloom-OuTfu_LE.js → osv-bloom-BsQ-aFiM.js} +1 -1
- package/dist/packem_shared/packument-DquNPIq9.js +1 -0
- package/dist/packem_shared/{pm-runner-Dws_Bw1y.js → pm-runner-D4jM58Oz.js} +1 -1
- package/dist/packem_shared/prompt-DjXHVgYU.js +1 -0
- package/dist/packem_shared/provenance-DIq8KyBV.js +1 -0
- package/dist/packem_shared/readJsonSync-CvkZyKmL-ihoybKvs.js +1 -0
- package/dist/packem_shared/registry-keys-C8K11ets.js +1 -0
- package/dist/packem_shared/resolve-explicit-Dr4kIybR.js +5 -0
- package/dist/packem_shared/{resolve-runtime-CJSWV-K8.js → resolve-runtime-Tx0bvg0h.js} +1 -1
- package/dist/packem_shared/run-file-DD7Ne23Z.js +1 -0
- package/dist/packem_shared/{runtime-check-0lUJvgKt.js → runtime-check-BXehSP06.js} +1 -1
- package/dist/packem_shared/s1ngularity-CtMmtXJo.js +1 -0
- package/dist/packem_shared/scan-progress-D4yywI6P.js +2 -0
- package/dist/packem_shared/{selectors-UmnAuc26.js → selectors-D4iCvITE.js} +1 -1
- package/dist/packem_shared/{signatures-BOUhghTv.js → signatures-CE8OAK-i.js} +2 -2
- package/dist/packem_shared/spinner-DuJJvFTl.js +1 -0
- package/dist/packem_shared/tabs-CgxCvjCY.js +1 -0
- package/dist/packem_shared/target-merge-DOm6h6tW.js +11 -0
- package/dist/packem_shared/target-options-CR0OuYJr.js +1 -0
- package/dist/packem_shared/toolchain-C44mPKPu.js +5 -0
- package/dist/packem_shared/{typosquats-DBOvXwph.js → typosquats-CQz-1Y6K.js} +1 -1
- package/dist/packem_shared/use-measured-height-XK9YSwtv.js +1 -0
- package/dist/packem_shared/utils-CRueU43T.js +1 -0
- package/dist/packem_shared/verify-DStfg3nb.js +1 -0
- package/dist/packem_shared/vis-update-app-Cpme_3Du.js +1 -0
- package/dist/packem_shared/{watch-Bkp_AAbc.js → watch-BXNI7dC6.js} +1 -1
- package/dist/packem_shared/watch-loop-JfGKIgKB.js +11 -0
- package/dist/packem_shared/window-ops-DDePlWLV.js +2 -0
- package/dist/runtime/preload.js +1 -1
- package/index.js +52 -52
- package/package.json +17 -13
- package/dist/packem_chunks/config.js +0 -18
- package/dist/packem_shared/CONFIG_FILES-MsOntfYT.js +0 -1
- package/dist/packem_shared/augment-8fIWWGSc.js +0 -3
- package/dist/packem_shared/bin-CnDBuLh3.js +0 -2
- package/dist/packem_shared/dependency-scan-B0HV_qeB.js +0 -1
- package/dist/packem_shared/failure-log-C7r6UZLP.js +0 -2
- package/dist/packem_shared/glob-fqg4KepW-7Bs2kZuM.js +0 -1
- package/dist/packem_shared/index-BKFEWXU_.js +0 -1
- package/dist/packem_shared/index-OQZQyN5R.js +0 -19
- package/dist/packem_shared/missing-package-json-DhYzuKhD.js +0 -1
- package/dist/packem_shared/provenance-C0P-UYOM.js +0 -1
- package/dist/packem_shared/readJsonSync-CvkZyKmL-CY7PZob_.js +0 -4
- package/dist/packem_shared/registry-keys-D4chF-Wj.js +0 -1
- package/dist/packem_shared/resolve-explicit-Cgheka3B.js +0 -5
- package/dist/packem_shared/run-file-B4TqKa0X.js +0 -1
- package/dist/packem_shared/s1ngularity-Du1NnSFP.js +0 -1
- package/dist/packem_shared/scan-progress-CN9ONR0y.js +0 -2
- package/dist/packem_shared/spinner-lhXugSx3.js +0 -1
- package/dist/packem_shared/tabs-DTiU3usb.js +0 -1
- package/dist/packem_shared/target-options-ChWcK60i.js +0 -1
- package/dist/packem_shared/toolchain-DyCKnGch.js +0 -5
- package/dist/packem_shared/use-measured-height-CK2Co3XI.js +0 -1
- package/dist/packem_shared/utils-Cxree603.js +0 -1
- package/dist/packem_shared/verify-CVPYlUrF.js +0 -1
- package/dist/packem_shared/vis-update-app-DtHkwBca.js +0 -1
- package/dist/packem_shared/watch-loop-D9zbXzRd.js +0 -11
|
@@ -1,7 +1,33 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
|
|
1
|
+
import{createRequire as P}from"node:module";import{f as D,v as V,T as w}from"../packem_shared/index-CE6MsgcV.js";import{findVisConfigFile as F}from"./CONFIG_FILES.js";import{p as e}from"./cli-main.js";import{w as O}from"../packem_shared/pm-runner-D4jM58Oz.js";import{W as q}from"../packem_shared/build-scripts-MTSK6TNr.js";import{O as A}from"../packem_shared/native-config-sync-BFDVK9LH.js";const C=P(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,R=l=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(l)}return C(l)},{spawnSync:T}=R("node:child_process"),M=/(defineConfig\s*\(\s*\{)/,W=/(export\s+default\s+\{)/,v=(l,t)=>`${t}${JSON.stringify(l)}: true,`,B=(l,t)=>{if(t.length===0)return{added:[],skipped:[],status:"noop"};const s=F(l);if(!s)return{added:[],skipped:t,status:"no-config"};if(!D(s))return{added:[],skipped:t,status:"no-config"};const i=V(s),h=i.search(/installScripts\s*:\s*\{/);let a=null,r=0;if(h!==-1){const c=i.slice(h),d=/(allow\s*:\s*\{)([^}]*)(\})/.exec(c);d?.index!==void 0&&(a=d,r=h+d.index)}if(a){const c=a[2]??"",d=new Set;for(const g of c.matchAll(/["']([^"']+)["']\s*:/g))d.add(g[1]);for(const g of c.matchAll(/(?:^|,|\{)\s*([a-z_$][\w-]*)\s*:/gi))d.add(g[1]);const u=[],k=[];for(const g of t)d.has(g)?k.push(g):u.push(g);if(u.length===0)return{added:[],configPath:s,skipped:k,status:"noop"};const b=/\n([ \t]+)\S/.exec(c)?.[1]??" ",_=`
|
|
2
|
+
${u.map(g=>v(g,b)).join(`
|
|
3
|
+
`)}`,y=c.replace(/\s+$/,""),S=c.slice(y.length),j=`${y}${y.endsWith(",")||y===""?"":","}${_}${S.length>0?S:`
|
|
4
|
+
`}`,N=`${i.slice(0,r)}${a[1]}${j}${a[3]}${i.slice(r+a[0].length)}`;return w(s,N),{added:u,configPath:s,skipped:k,status:"updated"}}const n=/(installScripts\s*:\s*\{)/;if(n.test(i)){const c=`
|
|
5
|
+
allow: {
|
|
6
|
+
${t.map(u=>v(u," ")).join(`
|
|
3
7
|
`)}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
},`,d=i.replace(n,`$1${c}`);return w(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const o=/(policies\s*:\s*\{)/;if(o.test(i)){const c=`
|
|
9
|
+
installScripts: {
|
|
10
|
+
allow: {
|
|
11
|
+
${t.map(u=>v(u," ")).join(`
|
|
12
|
+
`)}
|
|
13
|
+
},
|
|
14
|
+
},`,d=i.replace(o,`$1${c}`);return w(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const f=/(security\s*:\s*\{)/;if(f.test(i)){const c=`
|
|
15
|
+
policies: {
|
|
16
|
+
installScripts: {
|
|
17
|
+
allow: {
|
|
18
|
+
${t.map(u=>v(u," ")).join(`
|
|
19
|
+
`)}
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},`,d=i.replace(f,`$1${c}`);return w(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const p=M.exec(i)??W.exec(i);if(!p)return{added:[],configPath:s,skipped:t,status:"missing-anchor"};const m=`
|
|
23
|
+
security: {
|
|
24
|
+
policies: {
|
|
25
|
+
installScripts: {
|
|
26
|
+
allow: {
|
|
27
|
+
${t.map(c=>v(c," ")).join(`
|
|
28
|
+
`)}
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},`,x=`${i.slice(0,p.index+p[0].length)}${m}${i.slice(p.index+p[0].length)}`;return w(s,x),{added:t,configPath:s,skipped:[],status:"updated"}},L=async({options:l,visConfig:t,workspaceRoot:s})=>{const i=s??process.cwd(),h=O(i);if(h.name==="pnpm"&&!l.scan){e.info("Delegating to pnpm approve-builds...");const a=["approve-builds"];l.all&&a.push("--all");const r=T("pnpm",a,{cwd:i,stdio:"inherit"});if(r.error)throw new Error(`Failed to run pnpm approve-builds: ${r.error.message}`);if(r.status!==0&&r.status!==null&&(e.error(`pnpm approve-builds exited with code ${r.status}`),process.exitCode=r.status),!l.syncNative){e.notice(""),e.notice("Tip: vis.config.ts security.policies.installScripts.allow may now be out of sync with pnpm-workspace.yaml."),e.notice("Run 'vis check --security-config' to compare, or copy the new entries into vis.config.ts.");return}}else{const a=t?.security?.policies?.installScripts?.allow??{},r=t?.security?.pinVersions===!0,n=q(i,a,{pinVersions:r});if(n.unapproved.length===0)e.success("No unapproved build scripts found."),l.write&&(e.info(""),e.info("Nothing to write — there are no unapproved build scripts."));else{e.warn(`Found ${n.unapproved.length} package${n.unapproved.length===1?"":"s"} with unapproved build scripts:
|
|
33
|
+
`);for(const o of n.unapproved)e.info(` ${o.name} (${o.hooks.join(", ")})`);e.notice(""),e.notice("To approve these packages, add them to vis.config.ts:"),e.notice(""),e.notice(" security: {"),e.notice(" policies: {"),e.notice(" installScripts: {"),e.notice(" allow: {");for(const o of n.unapproved){const f=r&&o.version?`${o.name}@${o.version}`:o.name;e.notice(` "${f}": true,`)}if(e.notice(" },"),e.notice(" },"),e.notice(" },"),e.notice(" },"),h.name==="pnpm"&&(e.notice(""),e.notice("Or run 'pnpm approve-builds' to update pnpm-workspace.yaml directly.")),l.write){const o=t?.security?.pinVersions===!0,f=n.unapproved.map(m=>o&&m.version?`${m.name}@${m.version}`:m.name),p=B(i,f);switch(e.info(""),p.status){case"missing-anchor":{e.warn(`Could not locate 'defineConfig({' or 'export default {' in ${String(p.configPath)} — please add entries manually.`);break}case"no-config":{e.warn("No vis.config.ts found. Run 'vis init' first, then re-run with --write.");break}case"noop":{e.info(`All ${String(f.length)} entr${f.length===1?"y":"ies"} were already present in vis.config.ts security.policies.installScripts.allow.`);break}default:e.success(`Wrote ${String(p.added.length)} entr${p.added.length===1?"y":"ies"} to ${String(p.configPath)}.`),p.skipped.length>0&&e.info(`Skipped ${String(p.skipped.length)} already-present entr${p.skipped.length===1?"y":"ies"}.`)}}}if(n.excess.length>0){e.notice(""),e.warn(`Stale installScripts.allow entries — ${String(n.excess.length)} pattern${n.excess.length===1?"":"s"} no longer match any installed package:`);for(const o of n.excess)e.info(` ${o}`);e.notice("Consider removing these entries from vis.config.ts security.policies.installScripts.allow.")}if(n.versionDrift.length>0){e.notice(""),e.warn(`Version drift — ${String(n.versionDrift.length)} entr${n.versionDrift.length===1?"y":"ies"} pinned to an outdated version:`);for(const{from:o,to:f}of n.versionDrift)e.info(` ${o} → ${f}`);e.notice("Rename the keys in vis.config.ts security.policies.installScripts.allow to migrate.")}}if(l.syncNative){const a=t?.security?.policies?.installScripts?.allow??{};if(Object.keys(a).length===0)e.warn("No security.policies.installScripts.allow configured in vis.config.ts. Nothing to sync.");else{const r=A(h.name,i,a);e.info("");for(const n of r)e.success(n)}}};export{L as default};
|
|
@@ -1,33 +1,3 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
|
|
3
|
-
`)}
|
|
4
|
-
`}`,N=`${i.slice(0,r)}${a[1]}${j}${a[3]}${i.slice(r+a[0].length)}`;return w(s,N),{added:u,configPath:s,skipped:k,status:"updated"}}const n=/(installScripts\s*:\s*\{)/;if(n.test(i)){const c=`
|
|
5
|
-
allow: {
|
|
6
|
-
${t.map(u=>v(u," ")).join(`
|
|
7
|
-
`)}
|
|
8
|
-
},`,d=i.replace(n,`$1${c}`);return w(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const o=/(policies\s*:\s*\{)/;if(o.test(i)){const c=`
|
|
9
|
-
installScripts: {
|
|
10
|
-
allow: {
|
|
11
|
-
${t.map(u=>v(u," ")).join(`
|
|
12
|
-
`)}
|
|
13
|
-
},
|
|
14
|
-
},`,d=i.replace(o,`$1${c}`);return w(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const f=/(security\s*:\s*\{)/;if(f.test(i)){const c=`
|
|
15
|
-
policies: {
|
|
16
|
-
installScripts: {
|
|
17
|
-
allow: {
|
|
18
|
-
${t.map(u=>v(u," ")).join(`
|
|
19
|
-
`)}
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},`,d=i.replace(f,`$1${c}`);return w(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const p=M.exec(i)??W.exec(i);if(!p)return{added:[],configPath:s,skipped:t,status:"missing-anchor"};const m=`
|
|
23
|
-
security: {
|
|
24
|
-
policies: {
|
|
25
|
-
installScripts: {
|
|
26
|
-
allow: {
|
|
27
|
-
${t.map(c=>v(c," ")).join(`
|
|
28
|
-
`)}
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},`,x=`${i.slice(0,p.index+p[0].length)}${m}${i.slice(p.index+p[0].length)}`;return w(s,x),{added:t,configPath:s,skipped:[],status:"updated"}},L=async({options:l,visConfig:t,workspaceRoot:s})=>{const i=s??process.cwd(),h=q(i);if(h.name==="pnpm"&&!l.scan){e.info("Delegating to pnpm approve-builds...");const a=["approve-builds"];l.all&&a.push("--all");const r=T("pnpm",a,{cwd:i,stdio:"inherit"});if(r.error)throw new Error(`Failed to run pnpm approve-builds: ${r.error.message}`);if(r.status!==0&&r.status!==null&&(e.error(`pnpm approve-builds exited with code ${r.status}`),process.exitCode=r.status),!l.syncNative){e.notice(""),e.notice("Tip: vis.config.ts security.policies.installScripts.allow may now be out of sync with pnpm-workspace.yaml."),e.notice("Run 'vis check --security-config' to compare, or copy the new entries into vis.config.ts.");return}}else{const a=t?.security?.policies?.installScripts?.allow??{},r=t?.security?.pinVersions===!0,n=A(i,a,{pinVersions:r});if(n.unapproved.length===0)e.success("No unapproved build scripts found."),l.write&&(e.info(""),e.info("Nothing to write — there are no unapproved build scripts."));else{e.warn(`Found ${n.unapproved.length} package${n.unapproved.length===1?"":"s"} with unapproved build scripts:
|
|
33
|
-
`);for(const o of n.unapproved)e.info(` ${o.name} (${o.hooks.join(", ")})`);e.notice(""),e.notice("To approve these packages, add them to vis.config.ts:"),e.notice(""),e.notice(" security: {"),e.notice(" policies: {"),e.notice(" installScripts: {"),e.notice(" allow: {");for(const o of n.unapproved){const f=r&&o.version?`${o.name}@${o.version}`:o.name;e.notice(` "${f}": true,`)}if(e.notice(" },"),e.notice(" },"),e.notice(" },"),e.notice(" },"),h.name==="pnpm"&&(e.notice(""),e.notice("Or run 'pnpm approve-builds' to update pnpm-workspace.yaml directly.")),l.write){const o=t?.security?.pinVersions===!0,f=n.unapproved.map(m=>o&&m.version?`${m.name}@${m.version}`:m.name),p=B(i,f);switch(e.info(""),p.status){case"missing-anchor":{e.warn(`Could not locate 'defineConfig({' or 'export default {' in ${String(p.configPath)} — please add entries manually.`);break}case"no-config":{e.warn("No vis.config.ts found. Run 'vis init' first, then re-run with --write.");break}case"noop":{e.info(`All ${String(f.length)} entr${f.length===1?"y":"ies"} were already present in vis.config.ts security.policies.installScripts.allow.`);break}default:e.success(`Wrote ${String(p.added.length)} entr${p.added.length===1?"y":"ies"} to ${String(p.configPath)}.`),p.skipped.length>0&&e.info(`Skipped ${String(p.skipped.length)} already-present entr${p.skipped.length===1?"y":"ies"}.`)}}}if(n.excess.length>0){e.notice(""),e.warn(`Stale installScripts.allow entries — ${String(n.excess.length)} pattern${n.excess.length===1?"":"s"} no longer match any installed package:`);for(const o of n.excess)e.info(` ${o}`);e.notice("Consider removing these entries from vis.config.ts security.policies.installScripts.allow.")}if(n.versionDrift.length>0){e.notice(""),e.warn(`Version drift — ${String(n.versionDrift.length)} entr${n.versionDrift.length===1?"y":"ies"} pinned to an outdated version:`);for(const{from:o,to:f}of n.versionDrift)e.info(` ${o} → ${f}`);e.notice("Rename the keys in vis.config.ts security.policies.installScripts.allow to migrate.")}}if(l.syncNative){const a=t?.security?.policies?.installScripts?.allow??{};if(Object.keys(a).length===0)e.warn("No security.policies.installScripts.allow configured in vis.config.ts. Nothing to sync.");else{const r=F(h.name,i,a);e.info("");for(const n of r)e.success(n)}}};export{L as default};
|
|
1
|
+
import{createRequire as B}from"node:module";import{getAffectedProjects as F}from"@visulima/task-runner";import{b as H,O as T}from"./catalog.js";const C=B(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[t,r]=g.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return g.getBuiltinModule(e)}return C(e)},{execFile:D}=A("node:child_process"),{promisify:q}=A("node:util"),P=q(D),G=["[skip ci]","[ci skip]","[no ci]","[vis skip]","[nx skip]"],N=["[vis deploy]","[nx deploy]"],U=["vis","nx"],J=["CACHED_COMMIT_REF","VERCEL_GIT_PREVIOUS_SHA","GITHUB_BASE_REF","CI_COMMIT_BEFORE_SHA"],V=/^[\w./~^@{}][\w.\-/~^@{}]*$/,z=(e=process.env)=>{for(const t of J){const r=e[t];if(r&&r.trim().length>0)return r.trim()}},_=e=>{if(!V.test(e))throw new Error(`Invalid git ref: "${e}". Refs must start with an alphanumeric character or one of _ . / ~ ^ @ { } and may only contain letters, digits, dots, dashes, underscores, slashes, tildes, carets, @, and braces.`)},L=async(e,t)=>{try{return await P("git",["rev-parse","--verify",`${t}^{commit}`],{cwd:e}),!0}catch{return!1}},W=async e=>{try{const{stdout:t}=await P("git",["log","-1","--pretty=%B"],{cwd:e});return t}catch{return""}},O=(e,t,r)=>U.some(c=>e.includes(`[${c} ${t} ${r}]`)),Z=(e,t)=>G.some(r=>e.includes(r))||O(e,"skip",t),K=(e,t)=>N.some(r=>e.includes(r))||O(e,"deploy",t),f=(e,t,r,c)=>({action:"build",message:r,project:e,reason:t,...c}),b=(e,t,r,c)=>({action:"skip",message:r,project:e,reason:t,...c}),Q=e=>`${e.action==="skip"?"🛑":"✅"} ${e.message}`,X=(e,t)=>e.action==="skip"||t?0:1,E=new Set(["deep","direct","none"]),re=async({argument:e,logger:t,options:r,visConfig:c,workspaceRoot:l})=>{const o=e[0]??"",k=!!r.json,R=!!r.verbose,I=!!(r["exit-zero-on-build"]??r.exitZeroOnBuild),p=s=>{R&&!k&&t.info(`❱ ${s}`)},n=s=>{k?process.stdout.write(`${JSON.stringify(s)}
|
|
2
|
+
`):t.info(Q(s)),process.exit(X(s,I))};if(!o)return n(f("","missing-project-argument","Missing project argument. Usage: vis ci ignore <project>"));if(!l)return n(f(o,"workspace-error","Could not determine workspace root — building defensively"));const m=await W(l),$=m.trim().split(`
|
|
3
|
+
`)[0]??"";if(p(`commit: ${$}`),m&&K(m,o))return n(f(o,"commit-force-deploy",`Force-deploy keyword in commit: "${$}"`));if(m&&Z(m,o))return n(b(o,"commit-skip",`Skip keyword in commit: "${$}"`));let h,v;try{({packageJsons:v,workspace:h}=H(l,c))}catch(s){const a=s instanceof Error?s.message:String(s);return n(f(o,"workspace-error",`Workspace discovery failed (${a}) — building defensively`))}if(!Object.hasOwn(h.projects,o))return n(f(o,"project-unknown",`Project "${o}" not found in workspace — building defensively`));try{const s=r.base?.trim(),a=z();let i=s||a||"HEAD~1";const u=r.head?.trim()||"HEAD";_(i),_(u),p(`resolved base ref: ${i} (source: ${s?"flag":a?"ci-env":"default"})`);const S=L(l,i),x=T(l,h,v);await S||(p(`base ref ${i} not reachable — falling back to HEAD~1`),i="HEAD~1"),p(`comparing ${i}...${u}`);const w=r.downstream??"deep",y=r.upstream??"none";if(!E.has(w))throw new Error(`Invalid --downstream value: "${w}". Must be "none", "direct", or "deep".`);if(!E.has(y))throw new Error(`Invalid --upstream value: "${y}". Must be "none", "direct", or "deep".`);const M={base:i,downstream:w,head:u,projectGraph:x,projects:h.projects,upstream:y,workspaceRoot:l},d=await F(M);p(`changed files: ${d.changedFiles.length}`),p(`affected projects: ${d.affectedProjects.join(", ")||"(none)"}`);const j={base:i,head:u};return d.changedFiles.length===0?n(b(o,"no-changes",`No files changed between ${i}...${u}`,{...j,affectedProjects:[]})):d.affectedProjects.includes(o)?n(f(o,"project-affected",`Build ${o}: affected by ${d.changedFiles.length} changed file(s)`,{...j,affectedProjects:d.affectedProjects})):n(b(o,"project-not-affected",`Skip ${o}: not affected by changes between ${i}...${u}`,{...j,affectedProjects:d.affectedProjects}))}catch(s){const a=s instanceof Error?s.message:String(s);return t.error(`Affected detection failed: ${a}`),n(f(o,"workspace-error",`Affected detection failed (${a}) — building defensively`))}};export{re as default};
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)
|
|
3
|
-
|
|
1
|
+
import{E as u}from"../packem_shared/index.server-J83sowC4.js";import{m as p}from"../packem_shared/index-CE6MsgcV.js";const f={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=>{const r=new Set,n=[];for(const t of[...m,...w[e]])r.has(t)||(r.add(t),n.push(t));return n},h=e=>e.trim(),_="# Added by vis ignore",v=(e,r)=>{const n=new Set;for(const o of e.split(/\r?\n/u)){const c=h(o);c!==""&&!c.startsWith("#")&&n.add(c)}const t=[];for(const o of r)n.has(o)||(n.add(o),t.push(o));if(t.length===0)return{added:t,content:e};const s=e.includes(`\r
|
|
2
|
+
`)?`\r
|
|
3
|
+
`:`
|
|
4
|
+
`,d=[_,...t].join(s);if(e.trim()==="")return{added:t,content:`${d}${s}`};const i=e.endsWith(`
|
|
5
|
+
`)?s:`${s}${s}`;return{added:t,content:`${e}${i}${d}${s}`}},E=e=>e==="docker"||e==="npm"||e==="slug"||e==="vercel",k=async(e,r)=>{try{return await e.readFile(r,"utf8")}catch{return""}},N=async({fs:e,logger:r,options:n,process:t,workspaceRoot:s})=>{const d=s??t.cwd,i=n.target??"docker";if(!E(i))throw new Error(`Invalid --target "${i}". Expected one of: docker, vercel, npm, slug.`);const o=f[i],c=p(d,o),g=await k(e,c),{added:a,content:l}=v(g,$(i));if(n.json){process.stdout.write(`${JSON.stringify({added:a,file:o,target:i},null,2)}
|
|
6
|
+
`);return}if(n.write){if(a.length===0){r.info(`${o} is already up to date (no new patterns).`);return}await e.writeFile(c,l),r.info(`Added ${a.length} pattern(s) to ${o}.`);return}process.stdout.write(l.endsWith(`
|
|
7
|
+
`)?l:`${l}
|
|
8
|
+
`),r.info(u(`(${a.length} new pattern(s); re-run with --write to save ${o})`))};export{N as default};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import{E as
|
|
1
|
+
import{E as d}from"../packem_shared/index.server-J83sowC4.js";import{m as g,f as y,v as k,T as w,O as l}from"../packem_shared/index-CE6MsgcV.js";import{a as $,b as h,f as x}from"../packem_shared/subtree-C7bZuiSQ.js";import{a as u}from"../packem_shared/utils-CRueU43T.js";import{k as b,W as A}from"./catalog.js";import{a as R}from"../packem_shared/readJsonSync-CvkZyKmL-ihoybKvs.js";const j=["aube-workspace.yaml","pnpm-workspace.yaml"],v=/^\s*packages\s*:\s*$/,E=/^(\s*)-\s/,q=(c,i)=>{const r=c.includes(`\r
|
|
2
2
|
`)?`\r
|
|
3
3
|
`:`
|
|
4
|
-
`,
|
|
5
|
-
`)?s:`${s}${s}`;return{added:t,content:`${e}${i}${d}${s}`}},E=e=>e==="docker"||e==="npm"||e==="slug"||e==="vercel",k=async(e,r)=>{try{return await e.readFile(r,"utf8")}catch{return""}},N=async({fs:e,logger:r,options:n,process:t,workspaceRoot:s})=>{const d=s??t.cwd,i=n.target??"docker";if(!E(i))throw new Error(`Invalid --target "${i}". Expected one of: docker, vercel, npm, slug.`);const o=f[i],c=p(d,o),g=await k(e,c),{added:a,content:l}=v(g,$(i));if(n.json){process.stdout.write(`${JSON.stringify({added:a,file:o,target:i},null,2)}
|
|
6
|
-
`);return}if(n.write){if(a.length===0){r.info(`${o} is already up to date (no new patterns).`);return}await e.writeFile(c,l),r.info(`Added ${a.length} pattern(s) to ${o}.`);return}process.stdout.write(l.endsWith(`
|
|
7
|
-
`)?l:`${l}
|
|
8
|
-
`),r.info(u(`(${a.length} new pattern(s); re-run with --write to save ${o})`))};export{N as default};
|
|
4
|
+
`,e=c.split(/\r?\n/),o=e.findIndex(t=>v.test(t));if(o===-1)return;let s=" ";for(let t=o+1;t<e.length;t++){const a=E.exec(e[t]);if(a){s=a[1];break}if(e[t].trim().length>0)break}return e.splice(o+1,0,`${s}- "${i}"`),e.join(r)},I=(c,i,r)=>{const e=g(c,"package.json");let o;try{o=R(e)}catch{return!1}const{workspaces:s}=o;return Array.isArray(s)?s.includes(i)?!1:(r||l(e,{...o,workspaces:[...s,i]},{detectIndent:!0}),!0):s&&typeof s=="object"&&Array.isArray(s.packages)?s.packages.includes(i)?!1:(r||l(e,{...o,workspaces:{...s,packages:[...s.packages,i]}},{detectIndent:!0}),!0):!1},P=({dryRun:c=!1,prefix:i,workspaceRoot:r})=>{const e=u(i),o=b(r);if(!o)return{status:"no-config"};if(A(r,o).some(s=>u(s)===e))return{status:"already-covered"};for(const s of j){const t=g(r,s);if(!y(t))continue;const a=q(k(t),e);if(a!==void 0)return c||w(t,a),{entry:e,file:s,status:"added"}}return I(r,e,c)?{entry:e,file:"package.json",status:"added"}:{status:"no-config"}},H=async({argument:c,fs:i,logger:r,options:e,process:o,workspaceRoot:s})=>{const t=c[0];if(!t)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 a=s??o.cwd,n=u(e.prefix),f=e.ref??"HEAD";if($(a),await(async p=>{try{return await i.access(p),!0}catch{return!1}})(g(a,n)))throw new Error(`Target "${n}" already exists. git subtree add requires a non-existent prefix.`);if(e.dryRun){const p=e.squash?" --squash":"",m=e.message?` -m "${e.message}"`:"";r.info("Dry run — no changes will be made. Planned steps:"),r.info(` git subtree add --prefix=${n}${p}${m} ${t} ${f}`),e.noRegister||r.info(` register ${n} into the workspace config (skipped if already covered by an existing glob)`);return}if(h(a),r.info(`Importing ${d(t)}@${f} → ${n} ...`),x({cwd:a,message:e.message,prefix:n,ref:f,repo:t,squash:e.squash}),r.info(`✓ Imported ${t} into ${n} (history preserved).`),e.noRegister)r.info(d(`Skipped workspace registration (--no-register). Add ${n} to your workspace config manually.`));else{const p=P({prefix:n,workspaceRoot:a});p.status==="already-covered"?r.info(`✓ ${n} is already covered by an existing workspace glob.`):p.status==="added"?r.info(`✓ Registered ${p.entry} in ${p.file}.`):r.warn(`Could not auto-register ${n}: no workspace config found. Add it to pnpm-workspace.yaml or package.json#workspaces manually.`)}r.info(d("Note: project.json / nx tags are not generated. Add them if your tooling needs them."))};export{H as default};
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)?`\r
|
|
3
|
-
`:`
|
|
4
|
-
`,e=c.split(/\r?\n/),o=e.findIndex(t=>v.test(t));if(o===-1)return;let s=" ";for(let t=o+1;t<e.length;t++){const a=E.exec(e[t]);if(a){s=a[1];break}if(e[t].trim().length>0)break}return e.splice(o+1,0,`${s}- "${i}"`),e.join(r)},I=(c,i,r)=>{const e=g(c,"package.json");let o;try{o=$(e)}catch{return!1}const{workspaces:s}=o;return Array.isArray(s)?s.includes(i)?!1:(r||l(e,{...o,workspaces:[...s,i]},{detectIndent:!0}),!0):s&&typeof s=="object"&&Array.isArray(s.packages)?s.packages.includes(i)?!1:(r||l(e,{...o,workspaces:{...s,packages:[...s.packages,i]}},{detectIndent:!0}),!0):!1},P=({dryRun:c=!1,prefix:i,workspaceRoot:r})=>{const e=u(i),o=A(r);if(!o)return{status:"no-config"};if(R(r,o).some(s=>u(s)===e))return{status:"already-covered"};for(const s of j){const t=g(r,s);if(!y(t))continue;const a=q(k(t),e);if(a!==void 0)return c||w(t,a),{entry:e,file:s,status:"added"}}return I(r,e,c)?{entry:e,file:"package.json",status:"added"}:{status:"no-config"}},H=async({argument:c,fs:i,logger:r,options:e,process:o,workspaceRoot:s})=>{const t=c[0];if(!t)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 a=s??o.cwd,n=u(e.prefix),f=e.ref??"HEAD";if(h(a),await(async p=>{try{return await i.access(p),!0}catch{return!1}})(g(a,n)))throw new Error(`Target "${n}" already exists. git subtree add requires a non-existent prefix.`);if(e.dryRun){const p=e.squash?" --squash":"",m=e.message?` -m "${e.message}"`:"";r.info("Dry run — no changes will be made. Planned steps:"),r.info(` git subtree add --prefix=${n}${p}${m} ${t} ${f}`),e.noRegister||r.info(` register ${n} into the workspace config (skipped if already covered by an existing glob)`);return}if(x(a),r.info(`Importing ${d(t)}@${f} → ${n} ...`),b({cwd:a,message:e.message,prefix:n,ref:f,repo:t,squash:e.squash}),r.info(`✓ Imported ${t} into ${n} (history preserved).`),e.noRegister)r.info(d(`Skipped workspace registration (--no-register). Add ${n} to your workspace config manually.`));else{const p=P({prefix:n,workspaceRoot:a});p.status==="already-covered"?r.info(`✓ ${n} is already covered by an existing workspace glob.`):p.status==="added"?r.info(`✓ Registered ${p.entry} in ${p.file}.`):r.warn(`Could not auto-register ${n}: no workspace config found. Add it to pnpm-workspace.yaml or package.json#workspaces manually.`)}r.info(d("Note: project.json / nx tags are not generated. Add them if your tooling needs them."))};export{H as default};
|
|
1
|
+
import{y as x}from"../packem_shared/index-CE6MsgcV.js";import{b as T}from"./catalog.js";import{f as $}from"../packem_shared/selectors-D4iCvITE.js";import I from"./index.js";import{g as E}from"./cli-main.js";const b=(e,n)=>{for(const l of n)if(I(l,e))return!0;return!1},J=(e,n={})=>{const{depTypes:l,excludePatterns:f,externalOnly:y,includePatterns:d,internalOnly:j}=n;if(j&&y)return[];const u=l&&l.length>0?new Set(l):void 0,N=d&&d.length>0?d:void 0,O=f&&f.length>0?f:void 0,w=[];for(const m of e)j&&!m.isInternal||y&&m.isInternal||u&&!u.has(m.depType)||N&&(!m.packageName||!b(m.packageName,N))||O&&m.packageName&&b(m.packageName,O)||w.push(m);return w},C=new Set(["json","ndjson","table"]),q=e=>{if(e===void 0)return"table";const n=e.toLowerCase();if(!C.has(n))throw new Error(`--format must be one of: table, json, ndjson (got "${e}")`);return n},v=(e,n)=>({depName:e.depName,depType:e.depType,isInternal:e.isInternal,packageDir:e.packageDir,packageJsonPath:x(n,e.packageJsonPath),packageName:e.packageName,specifier:e.specifier}),S=new Set(["dependencies","devDependencies","optionalDependencies","overrides","peerDependencies","pnpm.overrides","resolutions"]),L=e=>{if(!e||e.length===0)return;const n=[],l=[];for(const f of e)for(const y of f.split(",")){const d=y.trim();d&&(S.has(d)?n.push(d):l.push(d))}if(l.length>0)throw new Error(`Unknown --dep-type value(s): ${l.join(", ")}. Valid: ${[...S].join(", ")}`);return n.length>0?n:void 0},V=async({logger:e,options:n,visConfig:l,workspaceRoot:f})=>{if(!f)throw new Error("Could not determine workspace root.");const y=q(n.format);if(n.deps===!0){if(n.internalOnly&&n.externalOnly)throw new Error("--internal-only and --external-only are mutually exclusive");const c=L(n.depType),i=E(f);let r=J(i,{depTypes:c,excludePatterns:n.exclude,externalOnly:n.externalOnly,includePatterns:n.include,internalOnly:n.internalOnly});if(n.query){const{workspace:t}=T(f,l),p=new Set($(Object.keys(t.projects),t,n.query));r=r.filter(k=>k.packageName!==void 0&&p.has(k.packageName))}const g=[...r].sort((t,p)=>{const k=`${t.packageName??t.packageDir} ${t.depType} ${t.depName}`,D=`${p.packageName??p.packageDir} ${p.depType} ${p.depName}`;return k.localeCompare(D)});if(y==="ndjson"){for(const t of g)e.info(JSON.stringify(v(t,f)));return}if(y==="json"){const t=g.map(p=>v(p,f));e.info(JSON.stringify(t,null,n.pretty===!0?2:void 0));return}if(g.length===0){e.info("No matching dep-instances.");return}const a=["Package","Block","Dep","Specifier","Internal","Path"],o=g.map(t=>[t.packageName??t.packageDir,t.depType,t.depName,t.specifier,t.isInternal?"yes":"no",x(f,t.packageJsonPath)]),s=a.map((t,p)=>Math.max(t.length,...o.map(k=>(k[p]??"").length))),h=(t,p)=>t.padEnd(p);e.info(a.map((t,p)=>h(t,s[p])).join(" ")),e.info(s.map(t=>"─".repeat(t)).join("──"));for(const t of o)e.info(t.map((p,k)=>h(p,s[k])).join(" "));e.info(""),e.info(`${String(g.length)} dep-instance(s)`);return}if(y==="ndjson")throw new Error("--format=ndjson is only supported with --deps");const{projectOptions:d,workspace:j}=T(f,l);let u=Object.keys(j.projects).sort();if(n.query&&(u=$(u,j,n.query)),u.length===0){e.info("No projects found.");return}const N=n.inferred===!0,O=n.targets===!0||N;if(y==="json"){const c=u.map(i=>{const r=j.projects[i],g=d.get(i)??{},a=Object.entries(r.targets??{}).map(([o])=>{const s=g[o],h=s?.inferred===!0;return{aliases:s?.aliases??[],command:s?.command,description:s?.description,...h?{inferred:!0}:{},name:o,type:s?.type}}).filter(o=>!N||o.inferred===!0);return{language:r.language,layer:r.layer,name:i,root:r.root,stack:r.stack,tags:r.tags??[],targets:a,type:r.projectType??"library"}});e.info(JSON.stringify(c,null,2));return}const w=(c,i)=>{const r=c.map((a,o)=>{let s=0;for(const h of i)s=Math.max(s,(h[o]??"").length);return Math.max(a.length,s)}),g=(a,o)=>a.padEnd(o);e.info(c.map((a,o)=>g(a,r[o])).join(" ")),e.info(r.map(a=>"─".repeat(a)).join("──"));for(const a of i)e.info(a.map((o,s)=>g(o,r[s])).join(" "))};if(O){const c=[];for(const i of u){const r=j.projects[i],g=d.get(i)??{};for(const a of Object.keys(r.targets??{}).sort()){const o=g[a],s=o?.inferred===!0;if(N&&!s)continue;const h=r.targets?.[a],t=h?.cache===!1?"no":h?.cache===!0?"yes":"default";c.push([i,a,o?.type??"—",t,s?"yes":"no",o?.description??"—"])}}if(c.length===0){e.info(N?"No inferred targets found.":"No targets found.");return}w(["Project","Target","Type","Cache","Inferred","Description"],c),e.info(""),e.info(`${String(c.length)} target(s) across ${String(u.length)} project(s)`);return}const m=["Project","Type","Layer","Tags","Targets"],P=u.map(c=>{const i=j.projects[c],r=Object.keys(i.targets??{});return[c,i.projectType??"library",i.layer??"—",(i.tags??[]).join(", ")||"—",r.length>4?`${r.slice(0,4).join(", ")}… (${String(r.length)})`:r.join(", ")||"—"]});w(m,P),e.info(""),e.info(`${String(u.length)} project(s)`)};export{V as default};
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{DEFAULT_CHANGES_DIR as R}from"./DEFAULT_CLEAN_KEEP.js";import{b as k,c as S,a as C,p as x}from"./orchestrator.js";import{hasUncommittedChanges as F,getCurrentBranch as N,pushBranch as P,stageAndCommit as A}from"./git.js";import{createShellRunner as I}from"./shell-runner.js";import{stateFilePath as j}from"./state.js";import{d as D}from"../packem_shared/sticky-comment-D6_7-w8T.js";import{VisReleaseError as y}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const V="<!-- vis:user-content -->",M="<!-- /vis:user-content -->",U=/<!-- vis:user-content -->([\s\S]*?)<!-- \/vis:user-content -->/g,q=/<!-- vis:user-content -->(?:(?!<!-- \/vis:user-content -->)[\s\S])*?<!-- vis:user-content -->/,E=r=>`${V}${r}${M}`,L=(r,e)=>{const s=[],o=/<!-- vis:user-content -->\s*<!-- \/vis:user-content -->/g;let n=o.exec(r);for(;n!==null;)s.push({end:n.index+n[0].length,start:n.index}),n=o.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 l=0;l<u;l+=1){const d=s[l],a=e[l];t.push(r.slice(i,d.start)),t.push(a),i=d.end}return t.push(r.slice(i)),{body:t.join(""),remaining:e.slice(u)}},O=(r,e)=>{if(r===void 0||r==="")return e;const s=r.replaceAll(/```[\s\S]*?```/g,"").replaceAll(/~~~[\s\S]*?~~~/g,""),o=(s.match(/<!-- vis:user-content -->/g)??[]).length,n=(s.match(/<!-- \/vis:user-content -->/g)??[]).length;if(o!==n)throw new y({code:"CONFIG_INVALID",hint:"Fix the marker pairs in the PR body and re-run.",message:`PR body has unbalanced <!-- vis:user-content --> markers (${o} opens, ${n} closes). Refusing to merge to prevent silent edit loss.`});if(q.test(s))throw new y({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 a of r.matchAll(U)){const p=a[1]??"";p.trim()!==""&&i.push(E(p))}if(i.length===0)return e;const{body:t,remaining:u}=L(e,i);if(u.length===0)return t;const l=t.replace(/\s+$/u,""),d=u.join(`
|
|
2
|
+
|
|
3
|
+
`);return`${l}
|
|
4
|
+
|
|
5
|
+
${d}
|
|
6
|
+
`},_=async(r,e,s)=>{try{return await r.access(j(e,s)),!0}catch{return!1}},B=async(r,e,s,o,n,i,t)=>{const u=await r.run("gh",["pr","list","--head",o,"--state","open","--json","number"],{cwd:s,silent:!0});if(u.exitCode===0&&u.stdout.trim()!==""&&u.stdout.trim()!=="[]")try{const a=JSON.parse(u.stdout);if(a[0]){let p=i,w=!1;try{const m=await r.run("gh",["pr","view",String(a[0].number),"--json","body","-q",".body"],{cwd:s,silent:!0});if(m.exitCode===0)try{p=O(m.stdout.replace(/\n$/,""),i)}catch($){w=!0,e.warn(`Skipping PR body update for #${a[0].number} — protected-content blocks are unbalanced, refusing to overwrite operator content. Please clean up markers manually. Cause: ${$.message}`)}}catch(m){e.warn(`Could not read existing body of PR #${a[0].number} for protected-edit merge: ${m.message}. Proceeding with the unmerged body.`)}const v=w?["pr","edit",String(a[0].number),"--title",n]:["pr","edit",String(a[0].number),"--title",n,"--body",p],b=await r.run("gh",v,{cwd:s,silent:!0});if(b.exitCode!==0)throw new Error(`gh pr edit #${a[0].number} failed: ${b.stderr.trim()}`);return{existing:!0,number:a[0].number}}}catch{}const l=await r.run("gh",["pr","create","--head",o,"--base",t,"--title",n,"--body",i],{cwd:s,silent:!0});if(l.exitCode!==0)return;const d=/\/pull\/(\d+)/.exec(l.stdout);return d?{existing:!1,number:Number.parseInt(d[1]??"0",10)}:void 0},G=async(r,e,s,o)=>{const n=o.labels??["autorelease: pending"];n.length>0&&await r.run("gh",["pr","edit",String(s),...n.flatMap(i=>["--add-label",i])],{cwd:e,silent:!0}),o.reviewers&&o.reviewers.length>0&&await r.run("gh",["pr","edit",String(s),"--add-reviewer",o.reviewers.join(",")],{cwd:e,silent:!0}),o.assignees&&o.assignees.length>0&&await r.run("gh",["pr","edit",String(s),"--add-assignee",o.assignees.join(",")],{cwd:e,silent:!0})},X=async({fs:r,logger:e,options:s,workspaceRoot:o})=>{const n=o??process.cwd(),i=I(),t=await k({channel:s.channel,cwd:n}),{printConfigIfRequested:u}=await import("./print-config.js");if(u(s,t,e))return;const l=s.autoPublish===!0?"auto-publish":t.channel?.mode??"auto-publish";if(await F({cwd:n,runner:i})){e.warn("Working tree has uncommitted changes. CI mode requires a clean tree."),process.exitCode=1;return}const{files:d}=await S({changesDir:t.config.changesDir,cwd:n});if(l==="auto-publish"){if(d.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 C(t,{commit:!0});const c=await x(t,{resume:!0,tag:t.channel?.tag}),h=await N({cwd:n,runner:i});if(h)try{await P({cwd:n,runner:i},h)}catch(f){e.error(`Failed to push branch: ${f.message}`)}e.info(`Published: ${c.published.length} | Skipped: ${c.skipped.length} | Failed: ${c.failed.length}`),process.exitCode=c.failed.length>0?2:0;return}if(d.length===0){const c=t.config.changesDir??R,h=await _(r,n,c);h?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 f=await x(t,{resume:h,tag:t.channel?.tag});e.info(`Published: ${f.published.length} | Skipped: ${f.skipped.length} | Failed: ${f.failed.length}`),process.exitCode=f.failed.length>0?2:0;return}e.info(`Version-PR mode — maintaining release PR for ${t.plan.releases.length} package(s).`);const a=s.branch??t.config.versionPr?.branch??"vis-release/version-packages",p=t.config.versionPr?.title??"🚀 Versioned release";if(!await D(i,n)){e.error("Could not detect repository slug via gh CLI. Cannot maintain version PR."),process.exitCode=1;return}const w=await i.run("git",["switch","-C",a],{cwd:n,silent:!0});if(w.exitCode!==0){e.error(`Could not switch to ${a}: ${w.stderr}`),process.exitCode=1;return}const v=await C(t,{commit:!1}),b=[...v.changedFiles,...v.deletedFiles];if(b.length===0){e.warn("Apply produced no file changes. Aborting version PR.");return}await A({cwd:n,runner:i},b,t.config.gitUser?`release(${t.channel?.tag??"main"}): version packages [skip ci]`:"release: version packages [skip ci]",{author:t.config.gitUser});try{await P({cwd:n,runner:i},a,{force:!0})}catch(c){e.error(`Could not push ${a}: ${c.message}`),process.exitCode=1;return}const m=t.branch??t.config.baseBranch??"main",$=`${t.config.versionPr?.preamble??""}
|
|
7
|
+
|
|
8
|
+
## Pending releases
|
|
9
|
+
|
|
10
|
+
${t.plan.releases.map(c=>`- \`${c.name}\`: ${c.oldVersion} → **${c.newVersion}**`).join(`
|
|
11
|
+
`)}
|
|
12
|
+
`,g=await B(i,e,n,a,p,$,m);if(g){if(e.info(`${g.existing?"Updated":"Opened"} version PR #${g.number}.`),await G(i,n,g.number,{assignees:g.existing?void 0:t.config.versionPr?.assignees,labels:t.config.versionPr?.labels,reviewers:g.existing?void 0:t.config.versionPr?.reviewers}),t.config.versionPr?.autoMerge&&!g.existing){const c=t.config.versionPr.autoMergeMethod??"squash",h=await i.run("gh",["pr","merge",String(g.number),"--auto",`--${c}`],{cwd:n,silent:!0});h.exitCode===0?e.info(`Auto-merge enabled (${c}).`):e.warn(`Could not enable auto-merge on PR #${g.number}: ${h.stderr.trim()||`exit ${h.exitCode}`}`)}}else e.error("Failed to create / update version PR."),process.exitCode=1};export{X as default};
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
`);return`${l
|
|
4
|
-
|
|
5
|
-
${
|
|
6
|
-
`},_=async(r,e,s)=>{try{return await r.access(j(e,s)),!0}catch{return!1}},B=async(r,e,s,o,n,i,t)=>{const u=await r.run("gh",["pr","list","--head",o,"--state","open","--json","number"],{cwd:s,silent:!0});if(u.exitCode===0&&u.stdout.trim()!==""&&u.stdout.trim()!=="[]")try{const a=JSON.parse(u.stdout);if(a[0]){let p=i,w=!1;try{const m=await r.run("gh",["pr","view",String(a[0].number),"--json","body","-q",".body"],{cwd:s,silent:!0});if(m.exitCode===0)try{p=O(m.stdout.replace(/\n$/,""),i)}catch($){w=!0,e.warn(`Skipping PR body update for #${a[0].number} — protected-content blocks are unbalanced, refusing to overwrite operator content. Please clean up markers manually. Cause: ${$.message}`)}}catch(m){e.warn(`Could not read existing body of PR #${a[0].number} for protected-edit merge: ${m.message}. Proceeding with the unmerged body.`)}const v=w?["pr","edit",String(a[0].number),"--title",n]:["pr","edit",String(a[0].number),"--title",n,"--body",p],b=await r.run("gh",v,{cwd:s,silent:!0});if(b.exitCode!==0)throw new Error(`gh pr edit #${a[0].number} failed: ${b.stderr.trim()}`);return{existing:!0,number:a[0].number}}}catch{}const l=await r.run("gh",["pr","create","--head",o,"--base",t,"--title",n,"--body",i],{cwd:s,silent:!0});if(l.exitCode!==0)return;const d=/\/pull\/(\d+)/.exec(l.stdout);return d?{existing:!1,number:Number.parseInt(d[1]??"0",10)}:void 0},G=async(r,e,s,o)=>{const n=o.labels??["autorelease: pending"];n.length>0&&await r.run("gh",["pr","edit",String(s),...n.flatMap(i=>["--add-label",i])],{cwd:e,silent:!0}),o.reviewers&&o.reviewers.length>0&&await r.run("gh",["pr","edit",String(s),"--add-reviewer",o.reviewers.join(",")],{cwd:e,silent:!0}),o.assignees&&o.assignees.length>0&&await r.run("gh",["pr","edit",String(s),"--add-assignee",o.assignees.join(",")],{cwd:e,silent:!0})},X=async({fs:r,logger:e,options:s,workspaceRoot:o})=>{const n=o??process.cwd(),i=I(),t=await k({channel:s.channel,cwd:n}),{printConfigIfRequested:u}=await import("./print-config.js");if(u(s,t,e))return;const l=s.autoPublish===!0?"auto-publish":t.channel?.mode??"auto-publish";if(await F({cwd:n,runner:i})){e.warn("Working tree has uncommitted changes. CI mode requires a clean tree."),process.exitCode=1;return}const{files:d}=await S({changesDir:t.config.changesDir,cwd:n});if(l==="auto-publish"){if(d.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 C(t,{commit:!0});const c=await x(t,{resume:!0,tag:t.channel?.tag}),h=await N({cwd:n,runner:i});if(h)try{await P({cwd:n,runner:i},h)}catch(f){e.error(`Failed to push branch: ${f.message}`)}e.info(`Published: ${c.published.length} | Skipped: ${c.skipped.length} | Failed: ${c.failed.length}`),process.exitCode=c.failed.length>0?2:0;return}if(d.length===0){const c=t.config.changesDir??R,h=await _(r,n,c);h?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 f=await x(t,{resume:h,tag:t.channel?.tag});e.info(`Published: ${f.published.length} | Skipped: ${f.skipped.length} | Failed: ${f.failed.length}`),process.exitCode=f.failed.length>0?2:0;return}e.info(`Version-PR mode — maintaining release PR for ${t.plan.releases.length} package(s).`);const a=s.branch??t.config.versionPr?.branch??"vis-release/version-packages",p=t.config.versionPr?.title??"🚀 Versioned release";if(!await D(i,n)){e.error("Could not detect repository slug via gh CLI. Cannot maintain version PR."),process.exitCode=1;return}const w=await i.run("git",["switch","-C",a],{cwd:n,silent:!0});if(w.exitCode!==0){e.error(`Could not switch to ${a}: ${w.stderr}`),process.exitCode=1;return}const v=await C(t,{commit:!1}),b=[...v.changedFiles,...v.deletedFiles];if(b.length===0){e.warn("Apply produced no file changes. Aborting version PR.");return}await A({cwd:n,runner:i},b,t.config.gitUser?`release(${t.channel?.tag??"main"}): version packages [skip ci]`:"release: version packages [skip ci]",{author:t.config.gitUser});try{await P({cwd:n,runner:i},a,{force:!0})}catch(c){e.error(`Could not push ${a}: ${c.message}`),process.exitCode=1;return}const m=t.branch??t.config.baseBranch??"main",$=`${t.config.versionPr?.preamble??""}
|
|
7
|
-
|
|
8
|
-
## Pending releases
|
|
9
|
-
|
|
10
|
-
${t.plan.releases.map(c=>`- \`${c.name}\`: ${c.oldVersion} → **${c.newVersion}**`).join(`
|
|
11
|
-
`)}
|
|
12
|
-
`,g=await B(i,e,n,a,p,$,m);if(g){if(e.info(`${g.existing?"Updated":"Opened"} version PR #${g.number}.`),await G(i,n,g.number,{assignees:g.existing?void 0:t.config.versionPr?.assignees,labels:t.config.versionPr?.labels,reviewers:g.existing?void 0:t.config.versionPr?.reviewers}),t.config.versionPr?.autoMerge&&!g.existing){const c=t.config.versionPr.autoMergeMethod??"squash",h=await i.run("gh",["pr","merge",String(g.number),"--auto",`--${c}`],{cwd:n,silent:!0});h.exitCode===0?e.info(`Auto-merge enabled (${c}).`):e.warn(`Could not enable auto-merge on PR #${g.number}: ${h.stderr.trim()||`exit ${h.exitCode}`}`)}}else e.error("Failed to create / update version PR."),process.exitCode=1};export{X as default};
|
|
1
|
+
import{createRequire as B}from"node:module";import{j as M,m as W,o as F,q as p,s as z,t as G,u as P,x as L,z as H,C as Y,E as K,F as Q,L as U,G as X,H as Z,I as V,$ as tt}from"./cli-main.js";import{f as k,m as f,v as j,T as O,I as st,J as nt}from"../packem_shared/index-CE6MsgcV.js";import"../packem_shared/public-api-WqUCiyIe.js";import{u as it}from"./ts-loader.js";import{loadVisConfig as rt}from"./CONFIG_FILES.js";import{v as ut}from"../packem_shared/verify-DStfg3nb.js";const J=B(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=t=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[o,s]=$.versions.node.split(".").map(Number);if(o>22||o===22&&s>=3||o===20&&s>=16)return $.getBuiltinModule(t)}return J(t)},{readdirSync:ot,statSync:et}=I("node:fs"),{stdin:T,stdout:at}=$,{createInterface:ct}=I("node:readline/promises"),w="__global__",R=t=>[...new Set(t)].sort((o,s)=>o.localeCompare(s)),pt=t=>`{${Object.keys(t).sort().map(o=>`${o}=${JSON.stringify(t[o])}`).join(",")}}`,m=t=>{if(!Array.isArray(t))return[];const o=[];for(const s of t)typeof s=="string"?o.push(s):s&&typeof s=="object"&&o.push(pt(s));return R(o)},y=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),h=(t,o,s)=>s?`^${o}`:t&&t!=="self"&&t!=="~"?`${t}#${o}`:o,ft=(t,o)=>{const s=t.trim();if(o==="moon"){if(s.startsWith("^:"))return h(void 0,s.slice(2),!0);if(s.startsWith("~:"))return h(void 0,s.slice(2),!1);if(s.includes(":")){const[n,e]=s.split(":");return h(n,e??"",!1)}return s}if(s.startsWith("^"))return h(void 0,s.slice(1),!0);if(s.includes("#")){const[n,e]=s.split("#");return h(n,e??"",!1)}return s},C=(t,o)=>{if(!Array.isArray(t))return[];const s=[];for(const n of t){if(typeof n=="string"){s.push(ft(n,o));continue}if(!n||typeof n!="object")continue;const e=n,{target:i}=e;if(!i)continue;if(e.dependencies===!0){s.push(h(void 0,i,!0));continue}if(e.projects===void 0){s.push(h(void 0,i,!1));continue}const r=Array.isArray(e.projects)?e.projects:[e.projects];for(const c of r)s.push(c==="^"?h(void 0,i,!0):h(c,i,!1))}return R(s)},E=t=>{if(k(t))try{return JSON.parse(j(t))}catch{return}},gt=t=>{const o=new Map,s=E(f(t,"turbo.json"));if(!s)return o;const n=s.tasks??s.pipeline??{};for(const[i,r]of Object.entries(n)){const c=i.includes("#")?i:`*#${i}`,a=y(c);a.dependsOn=C(r.dependsOn,"turbo"),a.inputs=m(r.inputs),a.outputs=m(r.outputs),a.env=R([...r.env??[],...r.passThroughEnv??[]]),a.cache=r.cache===!1?!1:void 0,o.set(c,a)}const e=y(w);return e.inputs=m(s.globalDependencies),e.env=R([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(w,e),o},dt=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),S=(t,o,s=8)=>{const n=[],e=(i,r)=>{if(r>s)return;let c;try{c=ot(i)}catch{return}for(const a of c.toSorted()){if(a===o){n.push(f(i,a));continue}if(a.startsWith(".")&&a!==".moon"||dt.has(a))continue;const u=f(i,a);try{et(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),n},N=(t,o)=>{t.dependsOn=C(o.dependsOn,"nx"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.cache=typeof o.cache=="boolean"?o.cache:void 0},lt=t=>{const o=new Map,s=E(f(t,"nx.json"));for(const[n,e]of Object.entries(s?.targetDefaults??{})){const i=`*#${n}`,r=y(i);N(r,e),o.set(i,r)}for(const n of S(t,"project.json")){const e=E(n);if(!(!e?.name||!e.targets))for(const[i,r]of Object.entries(e.targets)){const c=`${e.name}#${i}`,a=y(c);N(a,r),o.set(c,a)}}return o},_=(t,o)=>{t.dependsOn=C(o.deps,"moon"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.cache=typeof o.options?.cache=="boolean"?o.options.cache:void 0},A=t=>{if(k(t))try{return it(t)}catch{return}},vt=t=>{const o=new Map,s=f(t,".moon"),n=[f(s,"tasks.yml"),f(s,"tasks.yaml")];for(const e of n){const i=A(e);if(i){for(const[r,c]of Object.entries(i.tasks??{})){const a=`*#${r}`,u=y(a);_(u,c),o.set(a,u)}if(i.implicitInputs&&i.implicitInputs.length>0){const r=y(w);r.inputs=m(i.implicitInputs),o.set(w,r)}}}for(const e of[...S(t,"moon.yml"),...S(t,"moon.yaml")]){const i=A(e);if(!i?.tasks)continue;const r=e.split(/[/\\]/).at(-2)??"*";for(const[c,a]of Object.entries(i.tasks)){const u=`${r}#${c}`,v=y(u);_(v,a),o.set(u,v)}}return o},mt=(t,o)=>{t.dependsOn=C(o.dependsOn,"vis"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.env=R([...o.env??[],...o.passThroughEnv??[],...o.options?.passThroughEnv??[]]),t.cache=o.cache===!1?!1:typeof o.cache=="boolean"?o.cache:void 0},ht=async t=>{const o=new Map,s=await rt(t);for(const[i,r]of Object.entries(s.tasks??{})){const c=`*#${i}`,a=y(c);mt(a,r??{}),o.set(c,a)}const n=s.taskRunner??{},e=y(w);return e.inputs=m(n.globalInputs),e.env=R([...n.globalEnv??[],...n.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(w,e),o},yt=(t,o)=>{switch(o){case"moon":return vt(t);case"nx":return lt(t);default:return gt(t)}},kt=t=>{const o=[];return k(f(t,"turbo.json"))&&o.push("turbo"),k(f(t,"nx.json"))&&o.push("nx"),(k(f(t,".moon","tasks.yml"))||k(f(t,".moon","tasks.yaml")))&&o.push("moon"),o.length===1?o[0]:void 0},x=(t,o,s,n,e)=>{const i=n.filter(a=>!e.includes(a)),r=e.filter(a=>!n.includes(a));if(i.length===0&&r.length===0)return;const c=[];i.length>0&&c.push(`dropped [${i.join(", ")}]`),r.length>0&&c.push(`added [${r.join(", ")}]`),t.push({axis:s,detail:`${s} diverged: ${c.join("; ")}`,node:o,severity:i.length>0?"error":"warning"})},wt=(t,o,s)=>{const n=[],e=R([...t.keys(),...o.keys()]);for(const i of e){const r=t.get(i),c=o.get(i);if(r&&!c){const a=s==="turbo"&&i.includes("#")&&!i.startsWith("*#")&&i!==w;n.push({axis:"target-set",detail:a?`source target \`${i}\` was skipped by design (turbo project#task is migrated into per-project project.json — move it there and re-verify)`:`source target \`${i}\` has no equivalent in the migrated vis config`,node:i,severity:a?"warning":"error"});continue}if(!r&&c){n.push({axis:"target-set",detail:`migrated vis config defines \`${i}\` with no source equivalent (extra target — not a regression, but review)`,node:i,severity:"warning"});continue}!r||!c||(x(n,i,"dependsOn",r.dependsOn,c.dependsOn),x(n,i,"inputs",r.inputs,c.inputs),x(n,i,"outputs",r.outputs,c.outputs),x(n,i,"env",r.env,c.env),r.cache!==void 0&&c.cache!==void 0&&r.cache!==c.cache&&n.push({axis:"cache",detail:`cache flag diverged: source=${String(r.cache)} vis=${String(c.cache)} (changes what invalidates the cache)`,node:i,severity:"error"}))}return n.sort((i,r)=>i.node.localeCompare(r.node)||i.axis.localeCompare(r.axis)),{findings:n,source:s,sourceNodeCount:t.size,visNodeCount:o.size}},Rt=new Set(["json","ndjson","table"]),$t=t=>({equivalent:t.findings.every(o=>o.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),bt=(t,o,s)=>{if(o==="json"){process.stdout.write(`${JSON.stringify($t(t),void 0,2)}
|
|
2
|
+
`);return}if(o==="ndjson"){for(const n of t.findings)process.stdout.write(`${JSON.stringify(n)}
|
|
3
|
+
`);return}if(s.info(`Migration equivalence: ${t.source} → vis`),s.info(` source nodes: ${String(t.sourceNodeCount)} vis nodes: ${String(t.visNodeCount)}`),t.findings.length===0){s.info(" ✓ task graph + cache-key surface preserved (no divergence).");return}for(const n of t.findings){const e=` [${n.severity}] ${n.node} (${n.axis}) — ${n.detail}`;n.severity==="error"?s.warn(e):s.info(e)}},xt=(t,o)=>t.findings.some(s=>o==="warning"?!0:s.severity==="error")?1:0,D=async t=>{if(!T.isTTY)return!0;const o=ct({input:T,output:at});try{const s=(await o.question(`${t} [Y/n] `)).trim().toLowerCase();return s===""||s==="y"||s==="yes"}finally{o.close()}},Ct=[{description:"VisConfig.targetDefaults → VisConfig.tasks",next:"tasks",previous:"targetDefaults"},{description:"VisConfig.taskDefaults → VisConfig.scopedTasks",next:"scopedTasks",previous:"taskDefaults"},{description:"VisConfig.taskRunnerOptions → VisConfig.taskRunner",next:"taskRunner",previous:"taskRunnerOptions"},{description:"ScopedTasksBlock.scope → ScopedTasksBlock.match",next:"match",previous:"scope"},{description:"ScopedTasksBlock.targets → ScopedTasksBlock.tasks",next:"tasks",previous:"targets"}],jt=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],Et=t=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${t}\2(\s*:)`,"gmu"),St=(t,o)=>{let s=t;const n=[];for(const e of o){const i=Et(e.previous);i.test(s)&&(i.lastIndex=0,s=s.replace(i,(r,c,a,u)=>`${c}${a}${e.next}${a}${u}`),n.push(e))}return{applied:n,output:s}},q=(t,o)=>St(t,o),Mt=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],Ot=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),Tt=t=>{for(const o of Mt){const s=f(t,o);if(k(s))return s}},Nt=t=>{const o=[];try{for(const s of st(t,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))Ot.has(nt(s.path))&&o.push(s.path)}catch{}return o},_t=(t,o,s,n)=>{const e=Tt(t);if(e){const r=j(e),{applied:c,output:a}=q(r,Ct);if(c.length===0)s.info(`${e} already uses the current schema — no rewrite needed.`);else if(o.dryRun)s.info(`── ${e} (preview) ──`),s.info(a),s.info("── end preview ──"),s.info(`Would apply ${String(c.length)} rename(s): ${c.map(u=>u.description).join(", ")}`);else{M(e,n),O(e,a),s.info(`Rewrote ${e} (backup at ${e}.bak). Applied ${String(c.length)} rename(s).`);for(const u of c)n.manualSteps.push(`Renamed ${u.description} in ${e}`)}}else s.warn("No vis.config.ts found at workspace root — nothing to migrate."),n.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const i=o.taskConfigPaths??Nt(t);for(const r of i){if(!k(r))continue;const c=j(r),a=q(c,jt);if(a.applied.length!==0)if(o.dryRun)s.info(`── ${r} (preview) ──`),s.info(a.output),s.info("── end preview ──"),s.info(`Would apply ${String(a.applied.length)} rename(s): ${a.applied.map(u=>u.description).join(", ")}`);else{M(r,n),O(r,a.output),s.info(`Rewrote ${r} (backup at ${r}.bak). Applied ${String(a.applied.length)} rename(s).`);for(const u of a.applied)n.manualSteps.push(`Renamed ${u.description} in ${r}`)}}},g=t=>{const o=t.workspaceRoot??process.cwd(),s=t.visConfig??{};return{config:s,dryRun:!!t.options.dryRun,logger:t.logger,packageManager:tt(o),report:V(),root:o,useEditorconfig:typeof s.editorconfig=="boolean"?s.editorconfig:!0}},d=async(t,o,s)=>{if(o.yes||o.dryRun)return!0;const n=await D(`This will edit files, scripts, and hooks for "${t}". Backups (.bak) will be created. Continue?`);return n||s.info("Aborted."),n},l=t=>{t.dryRun&&t.logger.info(`Running in dry-run mode — no changes will be made.
|
|
4
|
+
`)},At=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("deps",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating dependencies and scripts ──"),z(e.root,e.packageManager,e.config,{dryRun:e.dryRun},t,e.report),t.info(""),p(e.report,t)},qt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("lint-staged",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating lint-staged ──"),G(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},It=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("nano-staged",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating nano-staged ──"),P(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Vt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("turborepo",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating turborepo ──"),L(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Dt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("nx",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating nx ──");const i=!!o.aggressive;H(e.root,{aggressive:i,dryRun:e.dryRun,force:i||!!o.force,rewriteSyncGenerators:i||!!o.rewriteSyncGenerators,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Bt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("moon",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating moon ──"),Y(e.root,{copyTemplates:!!o.copyTemplates,dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Jt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("gitleaks",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating gitleaks ──"),K(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Wt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("kingfisher",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating Kingfisher ──"),Q(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Ft=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("secretlint",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating secretlint ──"),U(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},zt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("syncpack",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating syncpack ──"),X(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Gt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("sherif",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating sherif ──"),Z(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Pt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("self",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating vis.config.ts to current schema ──"),_t(e.root,{dryRun:e.dryRun},t,e.report),t.info(""),p(e.report,t)},Lt=({logger:t,workspaceRoot:o})=>{const s=o??process.cwd();ut(s,t).length>0&&(process.exitCode=1)},Ht=async({logger:t,options:o,workspaceRoot:s})=>{const n=s??process.cwd(),e=o.format??"table";if(!Rt.has(e)){t.warn(`Invalid --format: ${String(o.format)}. Expected table | json | ndjson.`),process.exitCode=1;return}const i=o.failOn==="warning"?"warning":"error";let r;if(o.from){if(o.from!=="turbo"&&o.from!=="nx"&&o.from!=="moon"){t.warn(`Invalid --from: ${o.from}. Expected turbo | nx | moon.`),process.exitCode=1;return}r=o.from}else if(r=kt(n),!r){t.warn("Could not auto-detect the source tool (need exactly one of turbo.json / nx.json / .moon/tasks.yml). Pass --from <turbo|nx|moon>."),process.exitCode=1;return}const c=yt(n,r);if(c.size===0){t.warn(`No ${r} task graph found at ${n} — nothing to verify.`),process.exitCode=1;return}const a=await ht(n);if(a.size===0){t.warn("No migrated vis task graph found (vis.config.ts has no tasks). Run the migrator first."),process.exitCode=1;return}const u=wt(c,a,r);bt(u,e,t),process.exitCode=xt(u,i)},Yt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{const e=n??process.cwd(),i=W(e,s??{}),r=F(i);if(r.length===0){t.info("No applicable migrations detected in this workspace.");return}const c=!!o.dryRun;t.info(`Detected ${String(r.length)} migration(s):`);for(const v of r)t.info(` • ${v.title} — ${v.description}`);if(t.info(""),!o.yes&&!c&&!await D("Apply all detected migrations? Backups (.bak) will be created.")){t.info("Aborted.");return}c&&t.info(`Running in dry-run mode — no changes will be made.
|
|
5
|
+
`);const a=V(),u=[];for(const v of r)try{if(t.info(`── Applying ${v.title} ──`),c)for(const b of v.probe(i))t.info(b);else v.apply(i,a,t);t.info("")}catch(b){u.push({error:b,id:v.id}),t.warn(`Failed to apply ${v.title}: ${b.message}`)}p(a,t),u.length>0&&(t.warn(""),t.warn(`${String(u.length)} migration(s) failed — see messages above.`),process.exitCode=1)},eo=At,so=qt,no=It,io=Vt,ro=Dt,ao=Bt,co=Jt,uo=Wt,po=Ft,fo=zt,go=Gt,lo=Pt,vo=Lt,mo=Ht,ho=Yt;export{ho as migrateAllExecute,eo as migrateDepsExecute,co as migrateGitleaksExecute,uo as migrateKingfisherExecute,so as migrateLintStagedExecute,ao as migrateMoonExecute,no as migrateNanoStagedExecute,ro as migrateNxExecute,po as migrateSecretlintExecute,lo as migrateSelfExecute,go as migrateSherifExecute,fo as migrateSyncpackExecute,io as migrateTurborepoExecute,vo as migrateVerifyExecute,mo as migrateVerifyGraphExecute};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`);return
|
|
3
|
-
`)
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import{createRequire as K}from"node:module";import{j as b,E as m,q as k,I as N,V as U,s as P}from"../packem_shared/index.server-J83sowC4.js";import{m as h,a as J,A,f as W}from"../packem_shared/index-CE6MsgcV.js";import{b as I,O as z}from"./catalog.js";import{d as G}from"../packem_shared/lockfile-C1qCKGH6.js";import{p as X,s as Q}from"../packem_shared/docker-CViFYtmM.js";import{I as ne}from"../packem_shared/index-B0EsgdzO.js";import{g as L}from"../packem_shared/env-C2ZCnfP_.js";const Y=K(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[o,t]=g.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return g.getBuiltinModule(e)}return Y(e)},{createInterface:_}=y("node:readline"),{spawn:Z}=y("node:child_process"),{createHash:ee}=y("node:crypto"),{existsSync:T,writeFileSync:oe,chmodSync:te}=y("node:fs"),D={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},re=e=>{const{focus:o,manager:t,nodeVersion:r}=e,n=D[t]??D.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${o?` --focus=${o}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...n.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",n.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",n.build(o),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
|
|
2
|
+
`)},$="v2.14.0",S=`https://github.com/hadolint/hadolint/releases/download/${$}`,se={"hadolint-linux-arm64":"331f1d3511b84a4f1e3d18d52fec284723e4019552f4f47b19322a53ce9a40ed","hadolint-linux-x86_64":"6bf226944684f56c84dd014e8b979d27425c0148f61b3bd99bcc6f39e9dc5a47","hadolint-macos-arm64":"3625e2e9f43dcfe7bd38738a5f5520ed50ce39ed28485266e6803dd7bc197b10","hadolint-macos-x86_64":"2b69a853433f1eca522ffb921cd490bd1321424d03331fd8390f93b7fb4a02e9","hadolint-windows-x86_64.exe":"8e0ee174f88edb14f207a68430c7a53c2883ed509cdbde9a3a26fffa140fa5e4"},ie=e=>se[e],ae=(e=process.platform,o=process.arch)=>{const t=e==="darwin"?"macos":e==="linux"?"linux":e==="win32"?"windows":void 0;if(t===void 0)return;const r=o==="arm64"?"arm64":o==="x64"?"x86_64":void 0;if(t==="windows")return"hadolint-windows-x86_64.exe";if(r!==void 0)return`hadolint-${t}-${r}`},H=e=>h(L(),"hadolint",$,e.endsWith(".exe")?"hadolint.exe":"hadolint"),ce=()=>{const e=process.platform==="win32"?"hadolint.exe":"hadolint",o=(process.env.PATH??"").split(process.platform==="win32"?";":":");for(const t of o)if(t!==""&&T(h(t,e)))return e},le=e=>e.trim().split(/\s+/u)[0]??"",C=async e=>{const o=await fetch(e,{redirect:"follow"});if(!o.ok)throw new Error(`download failed (${String(o.status)} ${o.statusText}) for ${e}`);return Buffer.from(await o.arrayBuffer())},de=async e=>{const o=H(e),t=ie(e),r=await C(`${S}/${e}`),n=ee("sha256").update(r).digest("hex");if(t===void 0){const s=await C(`${S}/${e}.sha256`),i=le(s.toString("utf8")).toLowerCase();if(i==="")throw new Error("hadolint checksum sidecar was empty or unparseable. Refusing to use the download.");if(i!==n)throw new Error(`hadolint checksum mismatch (expected ${i}, got ${n}). Refusing to use the download.`)}else if(t.toLowerCase()!==n)throw new Error(`hadolint checksum mismatch (expected ${t.toLowerCase()}, got ${n}). Refusing to use the download.`);return J(h(L(),"hadolint",$)),oe(o,r),process.platform!=="win32"&&te(o,493),o},ue=async()=>{const e=_({input:process.stdin,output:process.stderr}),o=await new Promise(t=>{e.question(` Download hadolint ${k($)} now? ${m("[y/N]")} `,r=>{t(r.trim().toLowerCase())})});return e.close(),o==="y"||o==="yes"},fe=async e=>{const{autoInstall:o=!1,log:t}=e,r=ce();if(r!==void 0)return r;const n=ae();if(n===void 0){t(`hadolint has no prebuilt binary for ${process.platform}/${process.arch}. Install it manually: https://github.com/hadolint/hadolint`);return}const s=H(n);if(T(s))return s;if(!o){if(!(process.stdin.isTTY&&!ne)){t(`hadolint is not installed. Re-run with ${b("--install")} (or install hadolint on PATH) to enable Dockerfile linting.`);return}if(t(`${b("hadolint")} is required to lint Dockerfiles but was not found on your PATH.`),!await ue()){t(`Skipped. Install it yourself or re-run with ${b("--install")}.`);return}}t(`Downloading hadolint ${$} (${n})…`);try{const i=await de(n);return t(`Installed hadolint to ${m(i)}`),i}catch(i){t(`Failed to download hadolint: ${i.message}`);return}},O=async(e,o,t)=>{if(o.length===0)return[];const r=["--format","json","--no-fail",...t!==void 0&&t!==""?["--config",t]:[],...o],n=await new Promise((i,l)=>{const a=Z(e,r,{stdio:["ignore","pipe","pipe"],windowsHide:!0});let d="",u="";a.stdout?.on("data",c=>{d+=c.toString("utf8")}),a.stderr?.on("data",c=>{u+=c.toString("utf8")}),a.on("error",l),a.on("close",()=>{if(d.trim()===""&&u.trim()!==""){l(new Error(u.trim()));return}i(d)})});if(n.trim()==="")return[];let s;try{s=JSON.parse(n)}catch{throw new Error("Could not parse hadolint JSON output.")}return Array.isArray(s)?s:[]},E=(e,o,t)=>{if(!(!/\bapt-get\b/u.test(e)||!/\binstall\b/u.test(e)||t.test(e)))return e.replace(/\binstall\b/u,`install ${o}`)},R={DL3014:e=>E(e,"-y",/(?:^|\s)(?:-y|--yes|--assume-yes|-qq?)\b/u),DL3015:e=>E(e,"--no-install-recommends",/--no-install-recommends\b/u),DL3020:e=>/^\s*ADD\b/u.test(e)?e.replace(/^(\s*)ADD\b/u,"$1COPY"):void 0,DL3027:e=>/(?:^|\s)apt\s/u.test(e)&&!/\bapt-get\b/u.test(e)?e.replace(/(^|\s)apt(\s)/u,"$1apt-get$2"):void 0},M=new Set(Object.keys(R)),pe=(e,o)=>{const t=e.includes(`\r
|
|
3
|
+
`)?`\r
|
|
4
|
+
`:`
|
|
5
|
+
`,r=e.split(/\r?\n/u),n=new Set;let s=0;const i=new Map;for(const l of o){if(!R[l.code])continue;const a=i.get(l.line)??[];a.push(l),i.set(l.line,a)}for(const[l,a]of i){const d=l-1;if(!(d<0||d>=r.length))for(const u of a){const c=R[u.code],f=c?.(r[d]??"");f!==void 0&&f!==r[d]&&(r[d]=f,n.add(u.code),s+=1)}}return{content:s>0?r.join(t):e,fixedCodes:[...n],fixedCount:s}},j={error:0,info:2,style:3,warning:1},me=(e,o)=>{switch(e){case"error":return U(o);case"info":return k(o);case"warning":return P(o);default:return m(o)}},he=(e,o)=>(e.length>0?e:["Dockerfile"]).map(t=>A(t)?t:h(o,t)).filter(t=>W(t)),we=(e,o)=>{const t=[...e].sort((n,s)=>n.file.localeCompare(s.file)||n.line-s.line||n.column-s.column||j[n.level]-j[s.level]);let r="";for(const n of t){n.file!==r&&(r=n.file,o.info(`
|
|
6
|
+
${b(r)}`));const s=m(`${String(n.line)}:${String(n.column)}`),i=me(n.level,n.level.padEnd(7)),l=M.has(n.code)?m(" (fixable)"):"";o.info(` ${s} ${i} ${k(n.code)} ${n.message}${l}`)}},ge=e=>{const o={error:0,info:0,style:0,warning:0};for(const t of e)o[t.level]+=1;return o},be=async e=>{const{autoInstall:o,configPath:t,cwd:r,files:n,fix:s,fs:i,json:l,logger:a}=e,d=he(n,r);if(d.length===0)return a.error(`No Dockerfile found${n.length>0?` at: ${n.join(", ")}`:` in ${r}`}. Pass a path: vis docker lint <path>`),1;const u=await fe({autoInstall:o,log:p=>{a.info(p)}});if(u===void 0)return 0;let c=await O(u,d,t),f=0;if(s&&c.length>0){for(const p of d){const F=c.filter(V=>V.file===p),q=await i.readFile(p,"utf8"),x=pe(q,F);x.fixedCount>0&&(await i.writeFile(p,x.content),f+=x.fixedCount)}f>0&&(c=await O(u,d,t))}if(l)return process.stdout.write(`${JSON.stringify({findings:c,fixed:f},null,2)}
|
|
7
|
+
`),c.some(p=>p.level==="error")?1:0;if(s&&f>0&&a.info(N(`✔ Auto-fixed ${String(f)} issue${f===1?"":"s"}.`)),c.length===0)return a.info(N("✔ No Dockerfile issues found.")),0;we(c,a);const w=ge(c),v=c.filter(p=>M.has(p.code)).length;return a.info(`
|
|
8
|
+
${b(String(c.length))} issue${c.length===1?"":"s"}: ${U(`${String(w.error)} error`)}, ${P(`${String(w.warning)} warning`)}, ${k(`${String(w.info)} info`)}, ${m(`${String(w.style)} style`)}`),!s&&v>0&&a.info(m(`Run 'vis docker lint --fix' to auto-fix ${String(v)} of them.`)),w.error>0?1:0},B=e=>{if(!e)throw new Error("Could not determine workspace root. Run inside a monorepo.");return e},Oe=async({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const n=B(r),{packageJsons:s,workspace:i}=I(n,t),l=z(n,i,s),a=(o.focus??"").split(",").map(c=>c.trim()).filter(Boolean);if(a.length===0)throw new Error("Missing --focus. Pass one or more project names, comma-separated.");const d=h(n,o.out??".vis/docker"),{projects:u}=Q({focus:a,includeSources:!!o.includeSources,log:c=>{e.info(c)},outDir:d,projectGraph:l,pruneLockfile:o.pruneLockfile!==!1,workspace:i,workspaceRoot:n});e.info(`Scaffolded ${u.length} project(s) into ${d}`),e.info(`Focus closure: ${u.toSorted().join(", ")}`)},Ee=async({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const n=B(r),{workspace:s}=I(n,t),i=h(n,o.context??".vis/docker"),{removed:l}=X({contextRoot:i,workspace:s,workspaceRoot:n});e.info(`Pruned ${l.length} unfocused project(s)`),l.length>0&&e.debug?.(l.join(`
|
|
9
|
+
`))},je=async({argument:e,fs:o,logger:t,options:r,process:n,workspaceRoot:s})=>{const i=await be({autoInstall:!!r.install,configPath:r.config,cwd:s??n.cwd,files:e.filter(Boolean),fix:!!r.fix,fs:o,json:!!r.json,logger:t});i!==0&&(process.exitCode=i)},$e=async(e,o)=>{try{return await e.access(o),!0}catch{return!1}},ye=async e=>{const o=_({input:process.stdin,output:process.stderr}),t=await new Promise(r=>{o.question(` ${e} already exists. Overwrite? ${m("[y/N]")} `,n=>{r(n.trim().toLowerCase())})});return o.close(),t==="y"||t==="yes"},_e=async({argument:e,fs:o,logger:t,options:r,process:n,workspaceRoot:s})=>{const i=s??n.cwd,l=e[0]??"Dockerfile",a=A(l)?l:h(i,l),d=G(i)?.manager??"npm",u=(r.focus??"").split(",").map(f=>f.trim()).find(Boolean),c=re({focus:u,manager:d,nodeVersion:r.node??"22"});if(r.dryRun){process.stdout.write(c.endsWith(`
|
|
10
|
+
`)?c:`${c}
|
|
11
|
+
`);return}if(await $e(o,a)&&!r.force){if(!process.stdin.isTTY){t.error(`${a} already exists. Re-run with --force to overwrite.`),process.exitCode=1;return}if(!await ye(a)){t.info("Aborted — existing Dockerfile left untouched.");return}}await o.writeFile(a,c),t.info(`Created ${a} (package manager: ${d}).`),t.info(m(`Next: vis docker scaffold${u?` --focus=${u}`:""} --include-sources, then DOCKER_BUILDKIT=1 docker build .`))};export{_e as initExecute,je as lintExecute,Ee as pruneExecute,Oe as scaffoldExecute};
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`)}
|
|
3
|
-
`)
|
|
4
|
-
`:`
|
|
5
|
-
`,r=e.split(/\r?\n/u),n=new Set;let s=0;const i=new Map;for(const l of o){if(!R[l.code])continue;const a=i.get(l.line)??[];a.push(l),i.set(l.line,a)}for(const[l,a]of i){const d=l-1;if(!(d<0||d>=r.length))for(const u of a){const c=R[u.code],f=c?.(r[d]??"");f!==void 0&&f!==r[d]&&(r[d]=f,n.add(u.code),s+=1)}}return{content:s>0?r.join(t):e,fixedCodes:[...n],fixedCount:s}},j={error:0,info:2,style:3,warning:1},me=(e,o)=>{switch(e){case"error":return U(o);case"info":return k(o);case"warning":return P(o);default:return m(o)}},he=(e,o)=>(e.length>0?e:["Dockerfile"]).map(t=>A(t)?t:h(o,t)).filter(t=>W(t)),we=(e,o)=>{const t=[...e].sort((n,s)=>n.file.localeCompare(s.file)||n.line-s.line||n.column-s.column||j[n.level]-j[s.level]);let r="";for(const n of t){n.file!==r&&(r=n.file,o.info(`
|
|
6
|
-
${b(r)}`));const s=m(`${String(n.line)}:${String(n.column)}`),i=me(n.level,n.level.padEnd(7)),l=M.has(n.code)?m(" (fixable)"):"";o.info(` ${s} ${i} ${k(n.code)} ${n.message}${l}`)}},ge=e=>{const o={error:0,info:0,style:0,warning:0};for(const t of e)o[t.level]+=1;return o},be=async e=>{const{autoInstall:o,configPath:t,cwd:r,files:n,fix:s,fs:i,json:l,logger:a}=e,d=he(n,r);if(d.length===0)return a.error(`No Dockerfile found${n.length>0?` at: ${n.join(", ")}`:` in ${r}`}. Pass a path: vis docker lint <path>`),1;const u=await fe({autoInstall:o,log:p=>{a.info(p)}});if(u===void 0)return 0;let c=await O(u,d,t),f=0;if(s&&c.length>0){for(const p of d){const F=c.filter(V=>V.file===p),q=await i.readFile(p,"utf8"),x=pe(q,F);x.fixedCount>0&&(await i.writeFile(p,x.content),f+=x.fixedCount)}f>0&&(c=await O(u,d,t))}if(l)return process.stdout.write(`${JSON.stringify({findings:c,fixed:f},null,2)}
|
|
7
|
-
`),c.some(p=>p.level==="error")?1:0;if(s&&f>0&&a.info(N(`✔ Auto-fixed ${String(f)} issue${f===1?"":"s"}.`)),c.length===0)return a.info(N("✔ No Dockerfile issues found.")),0;we(c,a);const w=ge(c),v=c.filter(p=>M.has(p.code)).length;return a.info(`
|
|
8
|
-
${b(String(c.length))} issue${c.length===1?"":"s"}: ${U(`${String(w.error)} error`)}, ${P(`${String(w.warning)} warning`)}, ${k(`${String(w.info)} info`)}, ${m(`${String(w.style)} style`)}`),!s&&v>0&&a.info(m(`Run 'vis docker lint --fix' to auto-fix ${String(v)} of them.`)),w.error>0?1:0},B=e=>{if(!e)throw new Error("Could not determine workspace root. Run inside a monorepo.");return e},Ce=async({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const n=B(r),{packageJsons:s,workspace:i}=T(n,t),l=z(n,i,s),a=(o.focus??"").split(",").map(c=>c.trim()).filter(Boolean);if(a.length===0)throw new Error("Missing --focus. Pass one or more project names, comma-separated.");const d=h(n,o.out??".vis/docker"),{projects:u}=Q({focus:a,includeSources:!!o.includeSources,log:c=>{e.info(c)},outDir:d,projectGraph:l,pruneLockfile:o.pruneLockfile!==!1,workspace:i,workspaceRoot:n});e.info(`Scaffolded ${u.length} project(s) into ${d}`),e.info(`Focus closure: ${u.toSorted().join(", ")}`)},Oe=async({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const n=B(r),{workspace:s}=T(n,t),i=h(n,o.context??".vis/docker"),{removed:l}=X({contextRoot:i,workspace:s,workspaceRoot:n});e.info(`Pruned ${l.length} unfocused project(s)`),l.length>0&&e.debug?.(l.join(`
|
|
9
|
-
`))},Ee=async({argument:e,fs:o,logger:t,options:r,process:n,workspaceRoot:s})=>{const i=await be({autoInstall:!!r.install,configPath:r.config,cwd:s??n.cwd,files:e.filter(Boolean),fix:!!r.fix,fs:o,json:!!r.json,logger:t});i!==0&&(process.exitCode=i)},$e=async(e,o)=>{try{return await e.access(o),!0}catch{return!1}},ye=async e=>{const o=_({input:process.stdin,output:process.stderr}),t=await new Promise(r=>{o.question(` ${e} already exists. Overwrite? ${m("[y/N]")} `,n=>{r(n.trim().toLowerCase())})});return o.close(),t==="y"||t==="yes"},je=async({argument:e,fs:o,logger:t,options:r,process:n,workspaceRoot:s})=>{const i=s??n.cwd,l=e[0]??"Dockerfile",a=A(l)?l:h(i,l),d=G(i)?.manager??"npm",u=(r.focus??"").split(",").map(f=>f.trim()).find(Boolean),c=re({focus:u,manager:d,nodeVersion:r.node??"22"});if(r.dryRun){process.stdout.write(c.endsWith(`
|
|
10
|
-
`)?c:`${c}
|
|
11
|
-
`);return}if(await $e(o,a)&&!r.force){if(!process.stdin.isTTY){t.error(`${a} already exists. Re-run with --force to overwrite.`),process.exitCode=1;return}if(!await ye(a)){t.info("Aborted — existing Dockerfile left untouched.");return}}await o.writeFile(a,c),t.info(`Created ${a} (package manager: ${d}).`),t.info(m(`Next: vis docker scaffold${u?` --focus=${u}`:""} --include-sources, then DOCKER_BUILDKIT=1 docker build .`))};export{je as initExecute,Ee as lintExecute,Oe as pruneExecute,Ce as scaffoldExecute};
|
|
1
|
+
import{createRequire as G}from"node:module";import{I as F,q as L,j as N,E as O}from"../packem_shared/index.server-J83sowC4.js";import{y as E}from"../packem_shared/index-CE6MsgcV.js";import{Z as U}from"./cli-main.js";import{d as A,f as C,r as Z,a as D,b as Q,s as X,c as Y,e as ee,g as te,h as se,i as re,j as ie,k as ne,l as oe,m as ae,n as de,o as ce,p as fe,q as pe,t as le}from"../packem_shared/watch-loop-JfGKIgKB.js";import{p as h}from"./catalog.js";const H=G(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=t=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[e,s]=k.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return k.getBuiltinModule(t)}return H(t)},{createHash:q}=I("node:crypto"),ue=t=>t.startsWith("/")||/^[a-z]:[\\/]/i.test(t),_=(t,e)=>ue(e)?e:`${t}/${e}`,ge={argsCheck:(t,e)=>T(t,e,"check"),argsFix:(t,e)=>T(t,e,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(t,e)=>{const s=["dprint",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=A(e,h.dprint.packageNames[0]),r=C(t,h.dprint.configFiles);if(!(!s&&!r))return{adapter:"dprint",configFile:r,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","css","cts","dockerfile","html","js","json","jsonc","jsx","md","mdx","mjs","mts","toml","ts","tsx","yaml","yml"],id:"dprint",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const r of t.stdout.split(/\r?\n/)){const i=r.trim();!i||i.startsWith("[")||i.startsWith("Checked ")||i.startsWith("Error:")||s.push({adapter:"dprint",file:_(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},T=(t,e,s)=>{const r=s==="fix"?["fmt"]:["check","--list-different"];return e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},me={argsCheck:(t,e)=>B(t,e,"check"),argsFix:(t,e)=>B(t,e,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(t,e)=>{const s=["oxfmt",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=A(e,h.oxfmt.packageNames[0]),r=C(t,h.oxfmt.configFiles);if(!(!s&&!r))return{adapter:"oxfmt",configFile:r,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const r of t.stdout.split(/\r?\n/)){const i=r.trim();!i||i.startsWith("[")||s.push({adapter:"oxfmt",file:_(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},B=(t,e,s)=>{const r=s==="fix"?["--write"]:["--list-different"];return e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},he={argsCheck:(t,e)=>P(t,e,"check"),argsFix:(t,e)=>P(t,e,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(t,e)=>{const s=["prettier",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=A(e,h.prettier.packageNames[0]),r=C(t,h.prettier.configFiles);if(!(!s&&!r))return{adapter:"prettier",configFile:r,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const r of t.stdout.split(/\r?\n/)){const i=r.trim();i&&(i.startsWith("[")||s.push({adapter:"prettier",file:_(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},P=(t,e,s)=>{const r=s==="fix"?["--write"]:["--list-different"];return e.quiet&&r.push("--log-level","warn"),e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},xe=[me,de,ge,he,ce,fe],qe=async({logger:t,options:e,visConfig:s,workspaceRoot:r})=>{const i=r??process.cwd(),u=s?.fmt,w=Z(xe,u?.order),K=D(i,w),x=Q(K,w,"fmt").filter(({adapter:p})=>u?.adapters?.[p.id]?.enabled!==!1);if(x.length===0){t.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff, deno-fmt).");return}const $=p=>{const o=u?.adapters?.[p]?.extraArgs;return o&&o.length>0?[...o]:void 0},j={quiet:e.quiet??!1},R=ke(e),y=e.check?"check":"fix";let d;if(e.staged){if(d=X(i),d===void 0)t.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(d.length===0){t.info(F("✓ fmt: no staged files"));return}}else if(typeof e.since=="string"&&e.since.length>0){if(d=Y(i,e.since),d===void 0)t.warn(`vis fmt: could not resolve --since ${e.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(d.length===0){t.info(F(`✓ fmt: no files changed since ${e.since}`));return}}const z=U(i,void 0,void 0,!0),v=e.format??"human";v==="human"&&e.output!==void 0&&t.warn("vis fmt: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=async p=>{const o=R.length>0?R:p,g=[];if(o){const n=te(o,x,u?.extensionOverrides);for(const{adapter:a,presence:c}of x){const f=n.get(a.id);if(!f||f.length===0)continue;const W=$(a.id),V={adapter:a,files:f,presence:c};W&&(V.options={...j,extraArgs:W}),g.push(V)}}else for(const{adapter:n,presence:a}of x){const c=$(n.id),f={adapter:n,files:["."],presence:a};c&&(f.options={...j,extraArgs:c}),g.push(f)}if(g.length===0)return;const J=await se(g,j,y,{cacheRoot:z}),b=g.map((n,a)=>{const c=J[a],f=n.adapter.parse(c,n.presence);return{adapter:n.adapter,durationMs:c.durationMs,exitCode:c.exitCode,findings:f}}),l=re(b.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,exitCode:n.exitCode,findingCount:n.findings.length,findings:n.findings}))),m=v==="human"?void 0:ie({cwd:i,target:e.output});try{switch(v){case"github":{m.write(ae({runs:b.map(n=>({findings:n.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:l.findings,mode:y,runs:l.runs},null,2)}
|
|
2
|
+
`);break}case"junit":{m.write(oe({runs:b.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,findings:n.findings})),workspaceRoot:i}));break}case"minimal":{ye(l.findings,i,m);break}case"sarif":{m.write(ne({runs:b.map(n=>({adapter:n.adapter.id,findings:n.findings,presence:g.find(a=>a.adapter.id===n.adapter.id)?.presence})),workspaceRoot:i}));break}default:we(l.findings,i,y,t)}}finally{m?.close()}const S=y==="fix"?l.hadProcessFailure?1:0:le({...l,maxSeverity:l.findings.length>0?"error":void 0});S!==0&&(process.exitCode=S)};if(e.watch){const p=[...new Set(x.flatMap(({adapter:o})=>o.extensions))];await ee({extensions:p,initialFiles:d,label:"fmt",log:o=>{t.info(o)},runCycle:M,workspaceRoot:i});return}await M(d)},ke=t=>{const e=t;return[...e._??e.args??[]]},we=(t,e,s,r)=>{if(t.length===0){r.info(F(s==="fix"?"✓ fmt: nothing to change":"✓ fmt: all files already formatted"));return}const i=pe(t),u=s==="fix"?L(N("Formatted:")):N("Would change:");r.info(u);for(const w of i.keys())r.info(` ${O("·")} ${E(e,w)}`);s==="check"&&(r.info(""),r.info(O(`Run \`vis fmt\` to apply changes (${String(i.size)} file${i.size===1?"":"s"}).`)))},ye=(t,e,s)=>{for(const r of t)s.write(`${r.adapter} ${E(e,r.file)}
|
|
3
|
+
`)};export{qe as default};
|