@visulima/vis 1.0.0-alpha.27 → 1.0.0-alpha.28
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 +7 -0
- package/LICENSE.md +3228 -110
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/bin.js +468 -364
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/config.js +15 -15
- package/dist/packem_chunks/devtools.js +82 -0
- package/dist/packem_chunks/doctor-probe.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +3 -3
- package/dist/packem_chunks/handler22.js +1 -1
- package/dist/packem_chunks/handler23.js +2 -2
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler26.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler30.js +6 -6
- package/dist/packem_chunks/handler31.js +2 -2
- package/dist/packem_chunks/handler33.js +1 -1
- package/dist/packem_chunks/handler34.js +4 -4
- package/dist/packem_chunks/handler35.js +2 -2
- package/dist/packem_chunks/handler36.js +1 -1
- package/dist/packem_chunks/handler37.js +4 -4
- package/dist/packem_chunks/handler38.js +2 -2
- package/dist/packem_chunks/handler39.js +5 -5
- package/dist/packem_chunks/handler4.js +5 -5
- package/dist/packem_chunks/handler40.js +18 -18
- package/dist/packem_chunks/handler41.js +1 -1
- package/dist/packem_chunks/handler42.js +25 -10
- package/dist/packem_chunks/handler43.js +10 -25
- package/dist/packem_chunks/handler44.js +11 -11
- package/dist/packem_chunks/handler45.js +15 -15
- package/dist/packem_chunks/handler46.js +19 -19
- package/dist/packem_chunks/handler47.js +16 -16
- package/dist/packem_chunks/handler48.js +3 -3
- package/dist/packem_chunks/handler49.js +12 -12
- package/dist/packem_chunks/handler5.js +7 -7
- package/dist/packem_chunks/handler50.js +70 -71
- package/dist/packem_chunks/handler51.js +23 -23
- 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 +7 -17
- package/dist/packem_chunks/index.js +3 -3
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/list.js +2 -2
- package/dist/packem_chunks/loader.js +1 -1
- 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/verify-lockfile.js +1 -1
- package/dist/packem_shared/Table-CwC2kW07-EjFLNV0q.js +12 -0
- package/dist/packem_shared/_commonjsHelpers-CLblCigl.js +1 -0
- package/dist/packem_shared/{advisories-xIOdLbAI.js → advisories-BxXiKFbL.js} +1 -1
- package/dist/packem_shared/{ai-analysis-Csn82p17.js → ai-analysis-BnmDFqc8.js} +5 -5
- package/dist/packem_shared/{ai-fix-BlYyz5bI.js → ai-fix-BGbnrWCz.js} +7 -7
- package/dist/packem_shared/{cyclonedx-B3ILsY74.js → cyclonedx-C2k2HmvI.js} +1 -1
- package/dist/packem_shared/{dependency-scan-s2MD0vi-.js → dependency-scan-Bki15Yi-.js} +1 -1
- package/dist/packem_shared/{docker-BynKrOLe.js → docker-k-Sl8b-w.js} +1 -1
- package/dist/packem_shared/{failure-log-B0Uh-65U.js → failure-log-C3bG1bCA.js} +1 -1
- package/dist/packem_shared/index-2r730kXY.js +29 -0
- package/dist/packem_shared/{index-B_KtN1MB.js → index-DBq4TVu5.js} +1 -1
- package/dist/packem_shared/{lifecycle-CJRNbN3x.js → lifecycle-B91p_ra8.js} +2 -2
- package/dist/packem_shared/{lockfile-BG1HvBzH.js → lockfile-DmDfgKaT.js} +1 -1
- package/dist/packem_shared/{min-release-age-aEn0x8Vy.js → min-release-age-B1Jm1_JY.js} +1 -1
- package/dist/packem_shared/{native-config-sync-DdhTLlKL.js → native-config-sync-Cnpj2xcn.js} +6 -6
- package/dist/packem_shared/{osv-bloom-BJhlc_I2.js → osv-bloom-ep8GlDGT.js} +2 -2
- package/dist/packem_shared/pm-runner-COoPLGKi.js +1 -0
- package/dist/packem_shared/{provenance-BuiEsWbI.js → provenance-DbkJRDqt.js} +1 -1
- package/dist/packem_shared/{registry-keys-pemEkRM9.js → registry-keys-SylX07bs.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-RgRrUDZv.js → resolve-explicit-CJ_5wYSu.js} +1 -1
- package/dist/packem_shared/s1ngularity-DlS-4a6K.js +1 -0
- package/dist/packem_shared/scan-progress-CU4ttEHQ.js +2 -0
- package/dist/packem_shared/{signatures-LYMy8OR5.js → signatures-B-1u4t-c.js} +1 -1
- package/dist/packem_shared/spinner-B9ZPv1iT.js +1 -0
- package/dist/packem_shared/spinners-f91Rbo99-Bjf3NcO0.js +1 -0
- package/dist/packem_shared/tabs-C-qFIoUv.js +1 -0
- package/dist/packem_shared/typosquats-BxCOUvTJ.js +1 -0
- package/dist/packem_shared/use-measured-height-kIDCuc76.js +1 -0
- package/dist/packem_shared/vis-update-app-COYmjGKv.js +1 -0
- package/dist/packem_shared/{watch-loop-DLlMLg_J.js → watch-loop-CP318TfG.js} +2 -2
- package/index.js +26 -26
- package/package.json +9 -9
- package/dist/packem_shared/index-efSniSRN.js +0 -29
- package/dist/packem_shared/index.server-B7ETiT4C.js +0 -2
- package/dist/packem_shared/pm-runner-BwX5AL3W.js +0 -1
- package/dist/packem_shared/s1ngularity-Bs9fUf3q.js +0 -1
- package/dist/packem_shared/scan-progress-DjPT66jy.js +0 -2
- package/dist/packem_shared/typosquats-znskIR5j.js +0 -1
- package/dist/packem_shared/use-measured-height-DjYgUOKk.js +0 -1
- package/dist/packem_shared/vis-update-app-qhQPV97i.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var F=Object.defineProperty;var R=(e,t)=>F(e,"name",{value:t,configurable:!0});import{createRequire as J}from"node:module";import{o as L,
|
|
1
|
+
var F=Object.defineProperty;var R=(e,t)=>F(e,"name",{value:t,configurable:!0});import{createRequire as J}from"node:module";import{o as L,an as Q,ao as I,ap as B,aq as K,ar as Y,as as g,at as H,au as U,av as X,aw as Z,ax as ee,ay as te,az as oe,aA as ne,aB as se,aC as ie,aD as re,aE as ae}from"./bin.js";import{i as $,$ as T,M as d,Q as pe}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{e as fe,B as A}from"./config.js";import{v as le}from"../packem_shared/verify-C8EAHql6.js";const G=J(import.meta.url),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,z=R(e=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[t,n]=E.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return E.getBuiltinModule(e)}return G(e)},"__cjs_getBuiltinModule"),{readdirSync:ce,statSync:ue}=z("node:fs"),{stdin:_,stdout:ge}=E,{createInterface:de}=z("node:readline/promises");var me=Object.defineProperty,p=R((e,t)=>me(e,"name",{value:t,configurable:!0}),"u");const x="__global__",b=p(e=>[...new Set(e)].sort((t,n)=>t.localeCompare(n)),"sortStrings"),ve=p(e=>`{${Object.keys(e).sort().map(t=>`${t}=${JSON.stringify(e[t])}`).join(",")}}`,"canonicalizeObjectToken"),h=p(e=>{if(!Array.isArray(e))return[];const t=[];for(const n of e)typeof n=="string"?t.push(n):n&&typeof n=="object"&&t.push(ve(n));return b(t)},"normalizeTokenList"),w=p(e=>({cache:void 0,dependsOn:[],env:[],id:e,inputs:[],outputs:[]}),"emptyNode"),k=p((e,t,n)=>n?`^${t}`:e&&e!=="self"&&e!=="~"?`${e}#${t}`:t,"canonicalEdge"),ye=p((e,t)=>{const n=e.trim();if(t==="moon"){if(n.startsWith("^:"))return k(void 0,n.slice(2),!0);if(n.startsWith("~:"))return k(void 0,n.slice(2),!1);if(n.includes(":")){const[s,o]=n.split(":");return k(s,o??"",!1)}return n}if(n.startsWith("^"))return k(void 0,n.slice(1),!0);if(n.includes("#")){const[s,o]=n.split("#");return k(s,o??"",!1)}return n},"normalizeStringEdge"),M=p((e,t)=>{if(!Array.isArray(e))return[];const n=[];for(const s of e){if(typeof s=="string"){n.push(ye(s,t));continue}if(!s||typeof s!="object")continue;const o=s,{target:i}=o;if(!i)continue;if(o.dependencies===!0){n.push(k(void 0,i,!0));continue}if(o.projects===void 0){n.push(k(void 0,i,!1));continue}const r=Array.isArray(o.projects)?o.projects:[o.projects];for(const c of r)n.push(c==="^"?k(void 0,i,!0):k(c,i,!1))}return b(n)},"normalizeDependsOn"),O=p(e=>{if($(e))try{return JSON.parse(T(e))}catch{return}},"readJson"),he=p(e=>{const t=new Map,n=O(d(e,"turbo.json"));if(!n)return t;const s=n.tasks??n.pipeline??{};for(const[i,r]of Object.entries(s)){const c=i.includes("#")?i:`*#${i}`,a=w(c);a.dependsOn=M(r.dependsOn,"turbo"),a.inputs=h(r.inputs),a.outputs=h(r.outputs),a.env=b([...r.env??[],...r.passThroughEnv??[]]),a.cache=r.cache===!1?!1:void 0,t.set(c,a)}const o=w(x);return o.inputs=h(n.globalDependencies),o.env=b([...n.globalEnv??[],...n.globalPassThroughEnv??[]]),(o.inputs.length>0||o.env.length>0)&&t.set(x,o),t},"parseTurboModel"),ke=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),N=p((e,t,n=8)=>{const s=[],o=p((i,r)=>{if(r>n)return;let c;try{c=ce(i)}catch{return}for(const a of c.toSorted()){if(a===t){s.push(d(i,a));continue}if(a.startsWith(".")&&a!==".moon"||ke.has(a))continue;const u=d(i,a);try{ue(u).isDirectory()&&o(u,r+1)}catch{}}},"walk");return o(e,0),s},"findFiles"),D=p((e,t)=>{e.dependsOn=M(t.dependsOn,"nx"),e.inputs=h(t.inputs),e.outputs=h(t.outputs),e.cache=typeof t.cache=="boolean"?t.cache:void 0},"applyNxTarget"),we=p(e=>{const t=new Map,n=O(d(e,"nx.json"));for(const[s,o]of Object.entries(n?.targetDefaults??{})){const i=`*#${s}`,r=w(i);D(r,o),t.set(i,r)}for(const s of N(e,"project.json")){const o=O(s);if(!(!o?.name||!o.targets))for(const[i,r]of Object.entries(o.targets)){const c=`${o.name}#${i}`,a=w(c);D(a,r),t.set(c,a)}}return t},"parseNxModel"),V=p((e,t)=>{e.dependsOn=M(t.deps,"moon"),e.inputs=h(t.inputs),e.outputs=h(t.outputs),e.cache=typeof t.options?.cache=="boolean"?t.options.cache:void 0},"applyMoonTask"),q=p(e=>{if($(e))try{return L(e)}catch{return}},"readMoonYaml"),$e=p(e=>{const t=new Map,n=d(e,".moon"),s=[d(n,"tasks.yml"),d(n,"tasks.yaml")];for(const o of s){const i=q(o);if(i){for(const[r,c]of Object.entries(i.tasks??{})){const a=`*#${r}`,u=w(a);V(u,c),t.set(a,u)}if(i.implicitInputs&&i.implicitInputs.length>0){const r=w(x);r.inputs=h(i.implicitInputs),t.set(x,r)}}}for(const o of[...N(e,"moon.yml"),...N(e,"moon.yaml")]){const i=q(o);if(!i?.tasks)continue;const r=o.split(/[/\\]/).at(-2)??"*";for(const[c,a]of Object.entries(i.tasks)){const u=`${r}#${c}`,y=w(u);V(y,a),t.set(u,y)}}return t},"parseMoonModel"),xe=p((e,t)=>{e.dependsOn=M(t.dependsOn,"vis"),e.inputs=h(t.inputs),e.outputs=h(t.outputs),e.env=b([...t.env??[],...t.passThroughEnv??[],...t.options?.passThroughEnv??[]]),e.cache=t.cache===!1?!1:typeof t.cache=="boolean"?t.cache:void 0},"applyVisTask"),be=p(async e=>{const t=new Map,n=await fe(e);for(const[i,r]of Object.entries(n.tasks??{})){const c=`*#${i}`,a=w(c);xe(a,r??{}),t.set(c,a)}const s=n.taskRunner??{},o=w(x);return o.inputs=h(s.globalInputs),o.env=b([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(o.inputs.length>0||o.env.length>0)&&t.set(x,o),t},"buildVisModel"),Re=p((e,t)=>{switch(t){case"moon":return $e(e);case"nx":return we(e);default:return he(e)}},"buildSourceModel"),Ee=p(e=>{const t=[];return $(d(e,"turbo.json"))&&t.push("turbo"),$(d(e,"nx.json"))&&t.push("nx"),($(d(e,".moon","tasks.yml"))||$(d(e,".moon","tasks.yaml")))&&t.push("moon"),t.length===1?t[0]:void 0},"detectSourceTool"),j=p((e,t,n,s,o)=>{const i=s.filter(a=>!o.includes(a)),r=o.filter(a=>!s.includes(a));if(i.length===0&&r.length===0)return;const c=[];i.length>0&&c.push(`dropped [${i.join(", ")}]`),r.length>0&&c.push(`added [${r.join(", ")}]`),e.push({axis:n,detail:`${n} diverged: ${c.join("; ")}`,node:t,severity:i.length>0?"error":"warning"})},"diffArrayAxis"),Ce=p((e,t,n)=>{const s=[],o=b([...e.keys(),...t.keys()]);for(const i of o){const r=e.get(i),c=t.get(i);if(r&&!c){const a=n==="turbo"&&i.includes("#")&&!i.startsWith("*#")&&i!==x;s.push({axis:"target-set",detail:a?`source target \`${i}\` was skipped by design (turbo project#task is migrated into per-project project.json — move it there and re-verify)`:`source target \`${i}\` has no equivalent in the migrated vis config`,node:i,severity:a?"warning":"error"});continue}if(!r&&c){s.push({axis:"target-set",detail:`migrated vis config defines \`${i}\` with no source equivalent (extra target — not a regression, but review)`,node:i,severity:"warning"});continue}!r||!c||(j(s,i,"dependsOn",r.dependsOn,c.dependsOn),j(s,i,"inputs",r.inputs,c.inputs),j(s,i,"outputs",r.outputs,c.outputs),j(s,i,"env",r.env,c.env),r.cache!==void 0&&c.cache!==void 0&&r.cache!==c.cache&&s.push({axis:"cache",detail:`cache flag diverged: source=${String(r.cache)} vis=${String(c.cache)} (changes what invalidates the cache)`,node:i,severity:"error"}))}return s.sort((i,r)=>i.node.localeCompare(r.node)||i.axis.localeCompare(r.axis)),{findings:s,source:n,sourceNodeCount:e.size,visNodeCount:t.size}},"diffModels"),Se=new Set(["json","ndjson","table"]),je=p(e=>({equivalent:e.findings.every(t=>t.severity!=="error"),findings:e.findings,source:e.source,sourceNodeCount:e.sourceNodeCount,visNodeCount:e.visNodeCount}),"toJsonPayload"),Me=p((e,t,n)=>{if(t==="json"){process.stdout.write(`${JSON.stringify(je(e),void 0,2)}
|
|
2
2
|
`);return}if(t==="ndjson"){for(const s of e.findings)process.stdout.write(`${JSON.stringify(s)}
|
|
3
|
-
`);return}if(n.info(`Migration equivalence: ${e.source} → vis`),n.info(` source nodes: ${String(e.sourceNodeCount)} vis nodes: ${String(e.visNodeCount)}`),e.findings.length===0){n.info(" ✓ task graph + cache-key surface preserved (no divergence).");return}for(const s of e.findings){const o=` [${s.severity}] ${s.node} (${s.axis}) — ${s.detail}`;s.severity==="error"?n.warn(o):n.info(o)}},"formatEquivalenceReport"),Te=p((e,t)=>e.findings.some(n=>t==="warning"?!0:n.severity==="error")?1:0,"equivalenceExitCode");var Oe=Object.defineProperty,Ne=R((e,t)=>Oe(e,"name",{value:t,configurable:!0}),"n");const W=Ne(async e=>{if(!
|
|
4
|
-
`)},"announceDryRun"),Je=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("deps",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating dependencies and scripts ──"),Y(o.root,o.packageManager,o.config,{dryRun:o.dryRun},e,o.report),e.info(""),g(o.report,e)},"migrateDepsExecuteImpl"),Ge=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("lint-staged",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating lint-staged ──"),H(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateLintStagedExecuteImpl"),Le=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("nano-staged",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating nano-staged ──"),U(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateNanoStagedExecuteImpl"),Qe=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("turborepo",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating turborepo ──"),X(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateTurborepoExecuteImpl"),Ke=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("nx",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating nx ──");const i=!!t.aggressive;Z(o.root,{aggressive:i,dryRun:o.dryRun,force:i||!!t.force,rewriteSyncGenerators:i||!!t.rewriteSyncGenerators,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateNxExecuteImpl"),Ye=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("moon",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating moon ──"),ee(o.root,{copyTemplates:!!t.copyTemplates,dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateMoonExecuteImpl"),He=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("gitleaks",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating gitleaks ──"),te(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateGitleaksExecuteImpl"),Ue=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("kingfisher",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating Kingfisher ──"),oe(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateKingfisherExecuteImpl"),Xe=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("secretlint",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating secretlint ──"),ne(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateSecretlintExecuteImpl"),Ze=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("syncpack",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating syncpack ──"),se(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateSyncpackExecuteImpl"),et=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("sherif",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating sherif ──"),ie(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateSherifExecuteImpl"),tt=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("self",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating vis.config.ts to current schema ──"),We(o.root,{dryRun:o.dryRun},e,o.report),e.info(""),g(o.report,e)},"migrateSelfExecuteImpl"),ot=f(({logger:e,workspaceRoot:t})=>{const n=t??process.cwd();le(n,e).length>0&&(process.exitCode=1)},"migrateVerifyExecuteImpl"),nt=f(async({logger:e,options:t,workspaceRoot:n})=>{const s=n??process.cwd(),o=t.format??"table";if(!
|
|
5
|
-
`);const a=B(),u=[];for(const y of r)try{if(e.info(`── Applying ${y.title} ──`),c)for(const
|
|
3
|
+
`);return}if(n.info(`Migration equivalence: ${e.source} → vis`),n.info(` source nodes: ${String(e.sourceNodeCount)} vis nodes: ${String(e.visNodeCount)}`),e.findings.length===0){n.info(" ✓ task graph + cache-key surface preserved (no divergence).");return}for(const s of e.findings){const o=` [${s.severity}] ${s.node} (${s.axis}) — ${s.detail}`;s.severity==="error"?n.warn(o):n.info(o)}},"formatEquivalenceReport"),Te=p((e,t)=>e.findings.some(n=>t==="warning"?!0:n.severity==="error")?1:0,"equivalenceExitCode");var Oe=Object.defineProperty,Ne=R((e,t)=>Oe(e,"name",{value:t,configurable:!0}),"n");const W=Ne(async e=>{if(!_.isTTY)return!0;const t=de({input:_,output:ge});try{const n=(await t.question(`${e} [Y/n] `)).trim().toLowerCase();return n===""||n==="y"||n==="yes"}finally{t.close()}},"confirm");var Ie=Object.defineProperty,C=R((e,t)=>Ie(e,"name",{value:t,configurable:!0}),"p");const Ae=[{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"}],_e=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],De=C(e=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${e}\2(\s*:)`,"gmu"),"buildKeyRegex"),Ve=C((e,t)=>{let n=e;const s=[];for(const o of t){const i=De(o.previous);i.test(n)&&(i.lastIndex=0,n=n.replace(i,(r,c,a,u)=>`${c}${a}${o.next}${a}${u}`),s.push(o))}return{applied:s,output:n}},"applyRenames"),P=C((e,t)=>Ve(e,t),"rewriteSource"),qe=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],Pe=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),ze=C(e=>{for(const t of qe){const n=d(e,t);if($(n))return n}},"findConfigFile"),Be=C(e=>{const t=[];try{for(const n of Q(e,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))Pe.has(pe(n.path))&&t.push(n.path)}catch{}return t},"findTaskConfigFiles"),We=C((e,t,n,s)=>{const o=ze(e);if(o){const r=T(o),{applied:c,output:a}=P(r,Ae);if(c.length===0)n.info(`${o} already uses the current schema — no rewrite needed.`);else if(t.dryRun)n.info(`── ${o} (preview) ──`),n.info(a),n.info("── end preview ──"),n.info(`Would apply ${String(c.length)} rename(s): ${c.map(u=>u.description).join(", ")}`);else{I(o,s),A(o,a),n.info(`Rewrote ${o} (backup at ${o}.bak). Applied ${String(c.length)} rename(s).`);for(const u of c)s.manualSteps.push(`Renamed ${u.description} in ${o}`)}}else n.warn("No vis.config.ts found at workspace root — nothing to migrate."),s.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const i=t.taskConfigPaths??Be(e);for(const r of i){if(!$(r))continue;const c=T(r),a=P(c,_e);if(a.applied.length!==0)if(t.dryRun)n.info(`── ${r} (preview) ──`),n.info(a.output),n.info("── end preview ──"),n.info(`Would apply ${String(a.applied.length)} rename(s): ${a.applied.map(u=>u.description).join(", ")}`);else{I(r,s),A(r,a.output),n.info(`Rewrote ${r} (backup at ${r}.bak). Applied ${String(a.applied.length)} rename(s).`);for(const u of a.applied)s.manualSteps.push(`Renamed ${u.description} in ${r}`)}}},"migrateSelf");var Fe=Object.defineProperty,f=R((e,t)=>Fe(e,"name",{value:t,configurable:!0}),"r");const l=f(e=>{const t=e.workspaceRoot??process.cwd(),n=e.visConfig??{};return{config:n,dryRun:!!e.options.dryRun,logger:e.logger,packageManager:K(t),report:B(),root:t,useEditorconfig:typeof n.editorconfig=="boolean"?n.editorconfig:!0}},"buildContext"),m=f(async(e,t,n)=>{if(t.yes||t.dryRun)return!0;const s=await W(`This will edit files, scripts, and hooks for "${e}". Backups (.bak) will be created. Continue?`);return s||n.info("Aborted."),s},"maybeConfirm"),v=f(e=>{e.dryRun&&e.logger.info(`Running in dry-run mode — no changes will be made.
|
|
4
|
+
`)},"announceDryRun"),Je=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("deps",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating dependencies and scripts ──"),Y(o.root,o.packageManager,o.config,{dryRun:o.dryRun},e,o.report),e.info(""),g(o.report,e)},"migrateDepsExecuteImpl"),Ge=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("lint-staged",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating lint-staged ──"),H(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateLintStagedExecuteImpl"),Le=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("nano-staged",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating nano-staged ──"),U(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateNanoStagedExecuteImpl"),Qe=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("turborepo",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating turborepo ──"),X(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateTurborepoExecuteImpl"),Ke=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("nx",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating nx ──");const i=!!t.aggressive;Z(o.root,{aggressive:i,dryRun:o.dryRun,force:i||!!t.force,rewriteSyncGenerators:i||!!t.rewriteSyncGenerators,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateNxExecuteImpl"),Ye=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("moon",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating moon ──"),ee(o.root,{copyTemplates:!!t.copyTemplates,dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateMoonExecuteImpl"),He=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("gitleaks",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating gitleaks ──"),te(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateGitleaksExecuteImpl"),Ue=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("kingfisher",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating Kingfisher ──"),oe(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateKingfisherExecuteImpl"),Xe=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("secretlint",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating secretlint ──"),ne(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateSecretlintExecuteImpl"),Ze=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("syncpack",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating syncpack ──"),se(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateSyncpackExecuteImpl"),et=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("sherif",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating sherif ──"),ie(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateSherifExecuteImpl"),tt=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("self",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating vis.config.ts to current schema ──"),We(o.root,{dryRun:o.dryRun},e,o.report),e.info(""),g(o.report,e)},"migrateSelfExecuteImpl"),ot=f(({logger:e,workspaceRoot:t})=>{const n=t??process.cwd();le(n,e).length>0&&(process.exitCode=1)},"migrateVerifyExecuteImpl"),nt=f(async({logger:e,options:t,workspaceRoot:n})=>{const s=n??process.cwd(),o=t.format??"table";if(!Se.has(o)){e.warn(`Invalid --format: ${String(t.format)}. Expected table | json | ndjson.`),process.exitCode=1;return}const i=t.failOn==="warning"?"warning":"error";let r;if(t.from){if(t.from!=="turbo"&&t.from!=="nx"&&t.from!=="moon"){e.warn(`Invalid --from: ${t.from}. Expected turbo | nx | moon.`),process.exitCode=1;return}r=t.from}else if(r=Ee(s),!r){e.warn("Could not auto-detect the source tool (need exactly one of turbo.json / nx.json / .moon/tasks.yml). Pass --from <turbo|nx|moon>."),process.exitCode=1;return}const c=Re(s,r);if(c.size===0){e.warn(`No ${r} task graph found at ${s} — nothing to verify.`),process.exitCode=1;return}const a=await be(s);if(a.size===0){e.warn("No migrated vis task graph found (vis.config.ts has no tasks). Run the migrator first."),process.exitCode=1;return}const u=Ce(c,a,r);Me(u,o,e),process.exitCode=Te(u,i)},"migrateVerifyGraphExecuteImpl"),st=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{const o=s??process.cwd(),i=re(o,n??{}),r=ae(i);if(r.length===0){e.info("No applicable migrations detected in this workspace.");return}const c=!!t.dryRun;e.info(`Detected ${String(r.length)} migration(s):`);for(const y of r)e.info(` • ${y.title} — ${y.description}`);if(e.info(""),!t.yes&&!c&&!await W("Apply all detected migrations? Backups (.bak) will be created.")){e.info("Aborted.");return}c&&e.info(`Running in dry-run mode — no changes will be made.
|
|
5
|
+
`);const a=B(),u=[];for(const y of r)try{if(e.info(`── Applying ${y.title} ──`),c)for(const S of y.probe(i))e.info(S);else y.apply(i,a,e);e.info("")}catch(S){u.push({error:S,id:y.id}),e.warn(`Failed to apply ${y.title}: ${S.message}`)}g(a,e),u.length>0&&(e.warn(""),e.warn(`${String(u.length)} migration(s) failed — see messages above.`),process.exitCode=1)},"migrateAllExecuteImpl"),ft=Je,gt=Ge,dt=Le,lt=Qe,mt=Ke,vt=Ye,yt=He,ht=Ue,kt=Xe,wt=Ze,$t=et,xt=tt,bt=ot,Rt=nt,Et=st;export{Et as migrateAllExecute,ft as migrateDepsExecute,yt as migrateGitleaksExecute,ht as migrateKingfisherExecute,gt as migrateLintStagedExecute,vt as migrateMoonExecute,dt as migrateNanoStagedExecute,mt as migrateNxExecute,kt as migrateSecretlintExecute,xt as migrateSelfExecute,$t as migrateSherifExecute,wt as migrateSyncpackExecute,lt as migrateTurborepoExecute,bt as migrateVerifyExecute,Rt as migrateVerifyGraphExecute};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var Q=Object.defineProperty;var p=(t,e)=>Q(t,"name",{value:e,configurable:!0});import{createRequire as X}from"node:module";import{I as _,q as ee,j as N,E as T}from"../packem_shared/
|
|
2
|
-
`);break}case"junit":{k.write(me({runs:C.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,findings:n.findings})),workspaceRoot:i}));break}case"minimal":{Oe(u.findings,i,k);break}case"sarif":{k.write(ge({runs:C.map(n=>({adapter:n.adapter.id,findings:n.findings,presence:v.find(o=>o.adapter.id===n.adapter.id)?.presence})),workspaceRoot:i}));break}default:
|
|
1
|
+
var Q=Object.defineProperty;var p=(t,e)=>Q(t,"name",{value:e,configurable:!0});import{createRequire as X}from"node:module";import{I as _,q as ee,j as N,E as T}from"../packem_shared/Table-CwC2kW07-EjFLNV0q.js";import{z as G}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{aL as y,aM as te}from"./bin.js";import{d as M,f as P,r as re,b as se,a as ie,c as ne,e as ae,g as oe,s as ce,h as de,i as fe,j as le,k as ue,l as pe,m as ge,n as me,o as he,p as xe,q as be,t as ve}from"../packem_shared/watch-loop-CP318TfG.js";const Y=X(import.meta.url),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=p(t=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[e,r]=j.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return j.getBuiltinModule(t)}return Y(t)},"__cjs_getBuiltinModule"),{createHash:O}=Z("node:crypto");var ke=Object.defineProperty,I=p((t,e)=>ke(t,"name",{value:e,configurable:!0}),"o");const ye=I(t=>t.startsWith("/")||/^[a-z]:[\\/]/i.test(t),"isAbsolutePath"),R=I((t,e)=>ye(e)?e:`${t}/${e}`,"resolveFile");var we=Object.defineProperty,g=p((t,e)=>we(t,"name",{value:e,configurable:!0}),"n$1");const je={argsCheck:g((t,e)=>z(t,e,"check"),"argsCheck"),argsFix:g((t,e)=>z(t,e,"fix"),"argsFix"),bin:g(()=>["pnpm","exec","dprint"],"bin"),cacheKey:g((t,e)=>{const r=["dprint",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return O("sha256").update(r.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:g((t,e)=>{const r=M(e,y.dprint.packageNames[0]),s=P(t,y.dprint.configFiles);if(!(!r&&!s))return{adapter:"dprint",configFile:s,declared:!!r,declaredVersion:r,root:t}},"detect"),extensions:["cjs","css","cts","dockerfile","html","js","json","jsonc","jsx","md","mdx","mjs","mts","toml","ts","tsx","yaml","yml"],id:"dprint",kind:"fmt",parse:g((t,e)=>{if(t.exitCode===0)return[];const r=[];for(const s of t.stdout.split(/\r?\n/)){const i=s.trim();!i||i.startsWith("[")||i.startsWith("Checked ")||i.startsWith("Error:")||r.push({adapter:"dprint",file:R(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return r},"parse")},z=g((t,e,r)=>{const s=r==="fix"?["fmt"]:["check","--list-different"];return e.extraArgs?.length&&s.push(...e.extraArgs),s.push(...t),s},"buildArgs");var Fe=Object.defineProperty,m=p((t,e)=>Fe(t,"name",{value:e,configurable:!0}),"n");const Ae={argsCheck:m((t,e)=>H(t,e,"check"),"argsCheck"),argsFix:m((t,e)=>H(t,e,"fix"),"argsFix"),bin:m(()=>["pnpm","exec","oxfmt"],"bin"),cacheKey:m((t,e)=>{const r=["oxfmt",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return O("sha256").update(r.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:m((t,e)=>{const r=M(e,y.oxfmt.packageNames[0]),s=P(t,y.oxfmt.configFiles);if(!(!r&&!s))return{adapter:"oxfmt",configFile:s,declared:!!r,declaredVersion:r,root:t}},"detect"),extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:m((t,e)=>{if(t.exitCode===0)return[];const r=[];for(const s of t.stdout.split(/\r?\n/)){const i=s.trim();!i||i.startsWith("[")||r.push({adapter:"oxfmt",file:R(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return r},"parse")},H=m((t,e,r)=>{const s=r==="fix"?["--write"]:["--list-different"];return e.extraArgs?.length&&s.push(...e.extraArgs),s.push(...t),s},"buildArgs");var Ce=Object.defineProperty,h=p((t,e)=>Ce(t,"name",{value:e,configurable:!0}),"s");const $e={argsCheck:h((t,e)=>L(t,e,"check"),"argsCheck"),argsFix:h((t,e)=>L(t,e,"fix"),"argsFix"),bin:h(()=>["pnpm","exec","prettier"],"bin"),cacheKey:h((t,e)=>{const r=["prettier",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return O("sha256").update(r.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:h((t,e)=>{const r=M(e,y.prettier.packageNames[0]),s=P(t,y.prettier.configFiles);if(!(!r&&!s))return{adapter:"prettier",configFile:s,declared:!!r,declaredVersion:r,root:t}},"detect"),extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:h((t,e)=>{if(t.exitCode===0)return[];const r=[];for(const s of t.stdout.split(/\r?\n/)){const i=s.trim();i&&(i.startsWith("[")||r.push({adapter:"prettier",file:R(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return r},"parse")},L=h((t,e,r)=>{const s=r==="fix"?["--write"]:["--list-different"];return e.quiet&&s.push("--log-level","warn"),e.extraArgs?.length&&s.push(...e.extraArgs),s.push(...t),s},"buildArgs");var qe=Object.defineProperty,x=p((t,e)=>qe(t,"name",{value:e,configurable:!0}),"c");const _e=[Ae,se,je,$e,ie,ne],Be=x(async({logger:t,options:e,visConfig:r,workspaceRoot:s})=>{const i=s??process.cwd(),b=r?.fmt,F=re(_e,b?.order),J=ae(i,F),w=oe(J,F,"fmt").filter(({adapter:l})=>b?.adapters?.[l.id]?.enabled!==!1);if(w.length===0){t.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff, deno-fmt).");return}const S=x(l=>{const a=b?.adapters?.[l]?.extraArgs;return a&&a.length>0?[...a]:void 0},"baseExtraArgs"),$={quiet:e.quiet??!1},W=Me(e),A=e.check?"check":"fix";let c;if(e.staged){if(c=ce(i),c===void 0)t.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(c.length===0){t.info(_("✓ fmt: no staged files"));return}}else if(typeof e.since=="string"&&e.since.length>0){if(c=de(i,e.since),c===void 0)t.warn(`vis fmt: could not resolve --since ${e.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(c.length===0){t.info(_(`✓ fmt: no files changed since ${e.since}`));return}}const U=te(i,void 0,void 0,!0),q=e.format??"human";q==="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 E=x(async l=>{const a=W.length>0?W:l,v=[];if(a){const n=fe(a,w,b?.extensionOverrides);for(const{adapter:o,presence:d}of w){const f=n.get(o.id);if(!f||f.length===0)continue;const V=S(o.id),B={adapter:o,files:f,presence:d};V&&(B.options={...$,extraArgs:V}),v.push(B)}}else for(const{adapter:n,presence:o}of w){const d=S(n.id),f={adapter:n,files:["."],presence:o};d&&(f.options={...$,extraArgs:d}),v.push(f)}if(v.length===0)return;const D=await le(v,$,A,{cacheRoot:U}),C=v.map((n,o)=>{const d=D[o],f=n.adapter.parse(d,n.presence);return{adapter:n.adapter,durationMs:d.durationMs,exitCode:d.exitCode,findings:f}}),u=ue(C.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,exitCode:n.exitCode,findingCount:n.findings.length,findings:n.findings}))),k=q==="human"?void 0:pe({cwd:i,target:e.output});try{switch(q){case"github":{k.write(he({runs:C.map(n=>({findings:n.findings})),workspaceRoot:i}));break}case"json":{k.write(`${JSON.stringify({findings:u.findings,mode:A,runs:u.runs},null,2)}
|
|
2
|
+
`);break}case"junit":{k.write(me({runs:C.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,findings:n.findings})),workspaceRoot:i}));break}case"minimal":{Oe(u.findings,i,k);break}case"sarif":{k.write(ge({runs:C.map(n=>({adapter:n.adapter.id,findings:n.findings,presence:v.find(o=>o.adapter.id===n.adapter.id)?.presence})),workspaceRoot:i}));break}default:Pe(u.findings,i,A,t)}}finally{k?.close()}const K=A==="fix"?u.hadProcessFailure?1:0:xe({...u,maxSeverity:u.findings.length>0?"error":void 0});K!==0&&(process.exitCode=K)},"runCycle");if(e.watch){const l=[...new Set(w.flatMap(({adapter:a})=>a.extensions))];await be({extensions:l,initialFiles:c,label:"fmt",log:x(a=>{t.info(a)},"log"),runCycle:E,workspaceRoot:i});return}await E(c)},"execute"),Me=x(t=>{const e=t;return[...e._??e.args??[]]},"collectPositional"),Pe=x((t,e,r,s)=>{if(t.length===0){s.info(_(r==="fix"?"✓ fmt: nothing to change":"✓ fmt: all files already formatted"));return}const i=ve(t),b=r==="fix"?ee(N("Formatted:")):N("Would change:");s.info(b);for(const F of i.keys())s.info(` ${T("·")} ${G(e,F)}`);r==="check"&&(s.info(""),s.info(T(`Run \`vis fmt\` to apply changes (${String(i.size)} file${i.size===1?"":"s"}).`)))},"printHuman"),Oe=x((t,e,r)=>{for(const s of t)r.write(`${s.adapter} ${G(e,s.file)}
|
|
3
3
|
`)},"printMinimal");export{Be as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ae=Object.defineProperty;var j=(t,e)=>ae(t,"name",{value:e,configurable:!0});import{createRequire as ce}from"node:module";import{E as p,j as b,q as T}from"../packem_shared/
|
|
1
|
+
var ae=Object.defineProperty;var j=(t,e)=>ae(t,"name",{value:e,configurable:!0});import{createRequire as ce}from"node:module";import{E as p,j as b,q as T}from"../packem_shared/Table-CwC2kW07-EjFLNV0q.js";import{i as _,M as N,K as Y,a as L,z as Q,y as pe,C as fe}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{an as X,p as l}from"./bin.js";import{f as $e}from"../packem_shared/giget-CcEy_Elm.js";import{d as Z,B as ye}from"./config.js";const le=ce(import.meta.url),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=j(t=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[e,r]=x.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return x.getBuiltinModule(t)}return le(t)},"__cjs_getBuiltinModule"),{fileURLToPath:ue}=P("node:url"),{createInterface:de}=P("node:readline"),{mkdtempSync:me,rmSync:he}=P("node:fs"),{tmpdir:ge}=P("node:os"),{spawnSync:we}=P("node:child_process");var ve=Object.defineProperty,y=j((t,e)=>ve(t,"name",{value:e,configurable:!0}),"i");const ee=[".ts",".mts",".cts",".js",".mjs",".cjs"],be="template.yml",Te=[".d",".test",".spec",".config",".bench",".stories"],Se=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],te=y(t=>{for(const e of ee)if(t.endsWith(e))return t.slice(0,-e.length);return t},"stripExtension"),Oe=y(t=>{if(Se.some(r=>t.endsWith(r))||!ee.some(r=>t.endsWith(r)))return!1;const e=te(t);return!Te.some(r=>e.endsWith(r))},"isNativeFile"),J=y((t,e)=>{const r=[];if(!_(t))return r;for(const s of X(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!Oe(s.name))continue;const n=te(s.name);r.push({load:y(()=>Ne(s.path),"load"),name:n,path:s.path,source:e})}return r},"scanNativeDirectory"),q=y((t,e)=>{const r=[];if(!_(t))return r;for(const s of X(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=N(s.path,be);_(n)&&r.push({load:y(()=>Re(s.path,s.name),"load"),name:s.name,path:s.path,source:e})}return r},"scanMoonDirectory"),je=y(()=>{try{const t=ue(import.meta.url),e=N(Y(t),"..","..","templates");return _(e)?e:void 0}catch{return}},"resolveBuiltinTemplatesDirectory"),I=y(t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...J(N(s,".vis","templates"),"native"),...q(N(s,".vis","templates"),"moon"),...q(N(s,".moon","templates"),"moon")];for(const o of e)n.push(...q(o,"config")),n.push(...J(o,"config"));const i=je();i&&n.push(...q(i,"builtin"));const a=new Map;for(const o of n){const c=a.get(o.name);if(!c){a.set(o.name,o);continue}r&&r(`Template "${o.name}" exists in multiple sources — using ${c.source} (${c.path}), ignoring ${o.source} (${o.path}).`)}return[...a.values()].sort((o,c)=>o.name.localeCompare(c.name))},"discoverTemplates"),Ne=y(async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},"loadNativeFromPath"),Re=y(async(t,e)=>{const{loadMoonTemplate:r}=await import("./index.js");return r(t,e)},"loadMoonFromPath");var Ee=Object.defineProperty,v=j((t,e)=>Ee(t,"name",{value:e,configurable:!0}),"c");const M=v((t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),"ask"),ke=v(async(t,e,r)=>{const s=await M(t,` ${e} ${p(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},"confirm"),xe=v(async(t,e,r,s)=>{process.stderr.write(` ${e}
|
|
2
2
|
`);for(const[n,i]of r.entries()){const a=b(T(` ${String(n+1)}.`)),o=i===s?p(" (default)"):"";process.stderr.write(`${a} ${i}${o}
|
|
3
3
|
`)}for(;;){const n=await M(t,`
|
|
4
4
|
${p(`Enter choice (1-${String(r.length)}):`)} `);if(n===""&&s!==void 0)return s;const i=Number.parseInt(n,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const a=r.find(o=>o===n);if(a)return a;process.stderr.write(` ${p("Invalid choice. Try again.")}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var H=Object.defineProperty;var j=(e,t)=>H(e,"name",{value:t,configurable:!0});import{createRequire as K}from"node:module";import{
|
|
1
|
+
var H=Object.defineProperty;var j=(e,t)=>H(e,"name",{value:t,configurable:!0});import{createRequire as K}from"node:module";import{d as V,B as A,w as Y}from"./config.js";import{$ as X,K as D,z as T,M as C}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{o as Z}from"../packem_shared/index-DH-5hsrC.js";import{aN as P,C as ee,aO as te,a3 as oe}from"./bin.js";import{i as re}from"../packem_shared/glob-MHJQjR39-CQ2GC0b_.js";import{n as ne}from"../packem_shared/manifests-Z3spBpxv.js";const z=K(import.meta.url),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Q=j(e=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[t,o]=E.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return E.getBuiltinModule(e)}return z(e)},"__cjs_getBuiltinModule"),{readFileSync:F}=Q("node:fs");var se=Object.defineProperty,y=j((e,t)=>se(e,"name",{value:t,configurable:!0}),"c");const ie=y((e,t)=>{const o=t.replace(/^\.?\//,"");return o===""||o==="."?`/${e}/`:e===""||e==="."?`/${o}`:`/${e}/${o}`},"toWorkspacePath"),_=y((e,t,o=[])=>{const s=[],r=new Set;for(const[i,n]of Object.entries(t?.globalPaths??{}))s.push({owners:n,path:i,source:"project-json"}),r.add(i);for(const[i,n]of Object.entries(e.projects)){const a=n.owners??[];for(const c of a){const l=ie(n.root??i,c.path);s.push({channel:c.channel,owners:c.owners,path:l,projectId:i,source:"project-json"}),r.add(l)}}for(const i of o)r.has(i.path)||(s.push(i),r.add(i.path));return(t?.orderBy??"file-source")==="project-id"?s.sort((i,n)=>(i.projectId??"").localeCompare(n.projectId??"")||i.path.localeCompare(n.path)):s.sort((i,n)=>i.path.localeCompare(n.path)),s},"buildCodeownersLines"),ae="Update each project's project.json `owners` field and re-run the command.",ce=y(e=>["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.",e?`# Re-run with: ${e}`:`# ${ae}`,""],"buildHeader"),M=y(e=>{const t=[];for(const o of e){const s=o.owners.join(" "),r=o.channel?` # notify: ${o.channel}`:"";t.push(`${o.path} ${s}${r}`)}return t},"renderEntries"),de=y((e,t={})=>[...ce(t.regenerationCommand),...M(e),""].join(`
|
|
2
2
|
`),"renderCodeowners"),S={begin:"# BEGIN vis-codeowners",end:"# END vis-codeowners"},le=y((e,t=S,o={})=>{const s=o.regenerationCommand?`# Generated by vis sync codeowners — re-run with: ${o.regenerationCommand}`:"# Generated by `vis sync codeowners` — do not edit by hand.";return[t.begin,s,...M(e),t.end].join(`
|
|
3
3
|
`)},"renderCodeownersBlock"),ue=y((e,t,o=S)=>{const s=e.indexOf(o.begin),r=e.indexOf(o.end);if(s!==-1&&r!==-1&&r>s){const n=e.slice(0,s),a=r+o.end.length,c=e.slice(a);return`${n}${t}${c}`}const i=e.replace(/\s+$/u,"");return`${i.length===0?"":`${i}
|
|
4
4
|
|
|
5
5
|
`}${t}
|
|
6
|
-
`},"mergeIntoExisting");var fe=Object.defineProperty,N=j((e,t)=>fe(e,"name",{value:t,configurable:!0}),"f$1");const pe=["**/CODEOWNERS"],he=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"],ge=N(e=>{const t=[];for(const o of e.split(/\r?\n/u)){const s=o.indexOf("#"),r=(s===-1?o:o.slice(0,s)).trim();if(r.length===0)continue;const i=r.split(/\s+/u);if(i.length<2)continue;const[n,...a]=i,c=a.filter(l=>l.length>0);!n||c.length===0||t.push({owners:c,path:n})}return t},"parseCodeownersFile"),me=N((e,t)=>{const o=t.replace(/^\.\/?/,"").replace(/\/$/,"");return e.startsWith("/")?o===""?e:`/${o}${e}`:o===""?`/${e}`:`/${o}/${e}`},"rewriteNestedPath"),we=N(async(e,t,o)=>{const s=t&&t.length>0?[...t]:[...pe],r=[...he];if(o){const a=o.replace(/^\.\/?/,"").replace(/^\/+/,"");a.length>0&&r.push(a)}const i=await re(s,{absolute:!0,cwd:e,ignore:r}),n=[];for(const a of i){let c;try{c=
|
|
6
|
+
`},"mergeIntoExisting");var fe=Object.defineProperty,N=j((e,t)=>fe(e,"name",{value:t,configurable:!0}),"f$1");const pe=["**/CODEOWNERS"],he=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"],ge=N(e=>{const t=[];for(const o of e.split(/\r?\n/u)){const s=o.indexOf("#"),r=(s===-1?o:o.slice(0,s)).trim();if(r.length===0)continue;const i=r.split(/\s+/u);if(i.length<2)continue;const[n,...a]=i,c=a.filter(l=>l.length>0);!n||c.length===0||t.push({owners:c,path:n})}return t},"parseCodeownersFile"),me=N((e,t)=>{const o=t.replace(/^\.\/?/,"").replace(/\/$/,"");return e.startsWith("/")?o===""?e:`/${o}${e}`:o===""?`/${e}`:`/${o}/${e}`},"rewriteNestedPath"),we=N(async(e,t,o)=>{const s=t&&t.length>0?[...t]:[...pe],r=[...he];if(o){const a=o.replace(/^\.\/?/,"").replace(/^\/+/,"");a.length>0&&r.push(a)}const i=await re(s,{absolute:!0,cwd:e,ignore:r}),n=[];for(const a of i){let c;try{c=X(a)}catch{continue}const l=D(a),p=T(e,l);for(const m of ge(c))n.push({owners:m.owners,path:me(m.path,p)})}return n},"collectNestedCodeownersLines"),be=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)/iu,$e=N(e=>{if(!e)return;const t=e.match(be);if(!t?.[1])return;const o=t[1].trim();if(!(o===""||o.includes(" ")))return`@${o.replace(/^@/,"")}`},"extractGitHubHandle"),je=N((e,t)=>{const o=[];for(const[s,r]of Object.entries(e.projects)){if(r.owners&&r.owners.length>0)continue;const i=r.root??s,n=C(t,i,"package.json"),a=P(n);if(!a)continue;const c=ne(a.maintainers);if(!c||c.length===0)continue;const l=[],p=new Set;for(const m of c){const w=$e(m.url);w&&!p.has(w)&&(p.add(w),l.push(w))}l.length!==0&&o.push({owners:l,path:i===""||i==="."?"/":`/${i}/`,projectId:s})}return o},"collectMaintainerLines");var ye=Object.defineProperty,v=j((e,t)=>ye(e,"name",{value:t,configurable:!0}),"s");const ke=["author","bugs","homepage","license","repository","engines"],I=v(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isPlainObject"),R=v((e,t)=>{if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(const[o,s]of e.entries())if(!R(s,t[o]))return!1;return!0}if(typeof e=="object"&&typeof t=="object"){const o=Object.keys(e),s=Object.keys(t);if(o.length!==s.length)return!1;for(const r of o)if(!R(e[r],t[r]))return!1;return!0}return!1},"deepEqual"),x=v(e=>e===void 0?e:structuredClone(e),"cloneJson"),Ce=v((e,t,o)=>{if(e==="repository"&&I(t)&&I(o)){const s={};for(const[r,i]of Object.entries(t))r!=="directory"&&(s[r]=x(i));return typeof o.directory=="string"&&(s.directory=o.directory),s}return x(t)},"buildTargetValue"),ve=v((e,t,o)=>{const s=[];for(const r of o.fields){if(!Object.hasOwn(e,r))continue;const i=e[r],n=t[r],a=Ce(r,i,n);R(a,n)||s.push({after:a,before:n,field:r,packageJsonPath:""})}return s},"computeFieldChanges"),Oe=v((e,t)=>{for(const o of t)e[o.field]=o.after},"applyFieldChanges");var Ee=Object.defineProperty,G=j((e,t)=>Ee(e,"name",{value:t,configurable:!0}),"n");const U="Generated by `vis sync codeowners --write-guard`. Do not edit by hand.",Ne=G(e=>{const t=e.replace(/^\.?\/+/u,"").replace(/\/+$/u,"");return t===""||t==="."?"**":`${t}/**`},"toPathGlob"),q=G(e=>{const t=new Set,o=[];for(const s of[...e].sort((r,i)=>r.name.localeCompare(i.name))){const r=Ne(s.root);t.has(r)||(t.add(r),o.push(r))}return o},"resolveGlobs"),Ge=G(e=>{const t=q(e),o=t.map(r=>` - "${r}"`).join(`
|
|
7
7
|
`),s=t.map(r=>` ${r}`).join(`
|
|
8
8
|
`);return`# ${U}
|
|
9
9
|
name: Write Guard
|
|
@@ -57,5 +57,5 @@ ${t}
|
|
|
57
57
|
code-owner approval. Enable 'Require approval from Code Owners' on the
|
|
58
58
|
protected branch (GitLab Premium/Ultimate) for a real merge gate:
|
|
59
59
|
https://docs.gitlab.com/ee/user/project/codeowners/"
|
|
60
|
-
`},"renderGitlabWriteGuard"),Re=G(e=>e.length===0?[]:[{content:Ge(e),path:".github/workflows/write-guard.yml"},{content:Pe(e),path:".gitlab/write-guard.gitlab-ci.yml"}],"buildWriteGuardArtifacts");var Se=Object.defineProperty,k=j((e,t)=>Se(e,"name",{value:t,configurable:!0}),"m");const B=new Set(["nested-codeowners","package-json-maintainers","project-json"]),J=k((e,t,o)=>{const s=new Set,r=[];for(const i of e??[])for(const n of i.split(",")){const a=n.trim();if(a.length===0)continue;if(o&&!o(a))throw new Error(`Unknown codeowners source: "${a}". Known: ${[...B].join(", ")}.`);const c=a;s.has(c)||(s.add(c),r.push(c))}return r.length>0?r:[...t]},"parseCsvOption"),We=k(e=>B.has(e),"isCodeownersSource"),L=["codeowners","package-json-fields"],_e=k((e,t)=>t.some(o=>Z(o,e)),"matchesAnyGlob"),
|
|
61
|
-
`);else if(u.length===0)e.info(`All ${b} package${b===1?"":"s"} in sync (fields: ${a.join(", ")}).`);else if(l){if(!m)for(const d of u)e.error(`${d.packageJsonPath}: ${d.field} drifts from root`);e.error(`Found ${u.length} field drift${u.length===1?"":"s"} across ${f.length} package${f.length===1?"":"s"}. Run \`vis sync package-json-fields\` to fix.`)}else{if(!m)for(const d of f)e.info(`${d.packageJsonPath}: synced ${d.pkgChanges.map(h=>h.field).join(", ")}`);e.info(`Synced ${u.length} field${u.length===1?"":"s"} across ${f.length} package${f.length===1?"":"s"}.`)}l&&u.length>0&&(process.exitCode=1)},"runPackageJsonFields"),Je=k(async e=>{const t=e.argument[0];if(!t)throw new Error(`Missing sync kind. Usage: vis sync <kind> (known kinds: ${L.join(", ")})`);if(!e.workspaceRoot)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(t==="codeowners"){await
|
|
60
|
+
`},"renderGitlabWriteGuard"),Re=G(e=>e.length===0?[]:[{content:Ge(e),path:".github/workflows/write-guard.yml"},{content:Pe(e),path:".gitlab/write-guard.gitlab-ci.yml"}],"buildWriteGuardArtifacts");var Se=Object.defineProperty,k=j((e,t)=>Se(e,"name",{value:t,configurable:!0}),"m");const B=new Set(["nested-codeowners","package-json-maintainers","project-json"]),J=k((e,t,o)=>{const s=new Set,r=[];for(const i of e??[])for(const n of i.split(",")){const a=n.trim();if(a.length===0)continue;if(o&&!o(a))throw new Error(`Unknown codeowners source: "${a}". Known: ${[...B].join(", ")}.`);const c=a;s.has(c)||(s.add(c),r.push(c))}return r.length>0?r:[...t]},"parseCsvOption"),We=k(e=>B.has(e),"isCodeownersSource"),L=["codeowners","package-json-fields"],_e=k((e,t)=>t.some(o=>Z(o,e)),"matchesAnyGlob"),Ie=k((e,t,o,s)=>{const r=Object.entries(o.projects).filter(([,n])=>n.restricted===!0).map(([n,a])=>({name:n,root:a.root??n})),i=Re(r);if(i.length===0){e.info("No projects flagged `restricted: true` in project.json. Skipping Write Guard.");return}if(s){let n=!1;for(const a of i){const c=C(t,a.path);let l="";try{l=F(c,"utf8")}catch(p){if(p.code!=="ENOENT")throw p}l.trim()!==a.content.trim()&&(e.error(`${a.path} is out of date. Run \`vis sync codeowners --write-guard\` to update it.`),n=!0)}n?process.exitCode=1:e.info(`Write Guard CI is up to date (${i.length} files, ${r.length} restricted projects).`);return}for(const n of i){const a=C(t,n.path);V(D(a)),A(a,n.content),e.info(`Wrote ${n.path}`)}e.info(`Write Guard CI scoped to ${r.length} restricted project${r.length===1?"":"s"}.`)},"handleWriteGuard"),xe=k(async({logger:e,options:t,visConfig:o,workspaceRoot:s})=>{const r=s,{workspace:i}=ee(r,o),n=o?.codeowners;t.writeGuard===!0&&Ie(e,r,i,t.check===!0);const a=J(t.from,n?.sources??["project-json"],We),c=t.regenerationCommand??n?.regenerationCommand,l=t.preserveBlock===!0||n?.preserveBlock===!0,p=n?.blockMarker??S,m=t.nestedIncludes??n?.nestedIncludes,w=t.out??"CODEOWNERS",f=[];if(a.includes("nested-codeowners")){const g=await we(r,m,w);for(const $ of g)f.push({...$,source:"nested"})}if(a.includes("package-json-maintainers")){const g=je(i,r);for(const $ of g)f.push({...$,source:"maintainers"})}const b=a.includes("project-json")?_(i,n,f):_({projects:{}},n,f);if(b.length===0){e.info("No `owners` entries found in any source. Nothing to sync.");return}const u=C(r,w);let O="";try{O=F(u,"utf8")}catch(g){if(g.code!=="ENOENT")throw g}const d={regenerationCommand:c},h=l?ue(O,le(b,p,d),p):de(b,d);if(t.check){if(O.trim()!==h.trim()){e.error(`${u} is out of date. Run \`vis sync codeowners\` to update it.`),process.exitCode=1;return}e.info(`${u} is up to date.`);return}A(u,h),e.info(`Wrote ${b.length} entries to ${u}`)},"runCodeowners"),Le=k(({logger:e,options:t,visConfig:o,workspaceRoot:s})=>{const r=s,i=o?.editorconfig??!0,n=P(C(r,"package.json"));if(!n){e.error("Could not read root package.json. Nothing to sync."),process.exitCode=1;return}const a=J(t.fields,ke),c=t.ignorePackageName??[],l=t.check===!0,p=(t.format??"human").toLowerCase(),m=t.quiet===!0,w=te(r).filter(d=>d!=="."),f=[];let b=0;for(const d of w){const h=C(r,d,"package.json"),g=P(h);if(!g)continue;const $=typeof g.name=="string"?g.name:void 0;if($!==void 0&&c.length>0&&_e($,c))continue;b+=1;const W=ve(n,g,{fields:a});W.length!==0&&f.push({filePath:h,packageJsonPath:T(r,h),packageName:$,pkg:g,pkgChanges:W})}if(!l)for(const d of f)Oe(d.pkg,d.pkgChanges),Y(d.filePath,d.pkg,{indent:oe(d.filePath,{useEditorconfig:i}),overwrite:!0});const u=f.flatMap(d=>d.pkgChanges.map(h=>({after:h.after,before:h.before,field:h.field,packageJsonPath:d.packageJsonPath,packageName:d.packageName}))),O={changes:u,fields:a,kind:"package-json-fields",mode:l?"check":"write",totalChanges:u.length,totalPackages:b};if(p==="json")process.stdout.write(`${JSON.stringify(O,null,4)}
|
|
61
|
+
`);else if(u.length===0)e.info(`All ${b} package${b===1?"":"s"} in sync (fields: ${a.join(", ")}).`);else if(l){if(!m)for(const d of u)e.error(`${d.packageJsonPath}: ${d.field} drifts from root`);e.error(`Found ${u.length} field drift${u.length===1?"":"s"} across ${f.length} package${f.length===1?"":"s"}. Run \`vis sync package-json-fields\` to fix.`)}else{if(!m)for(const d of f)e.info(`${d.packageJsonPath}: synced ${d.pkgChanges.map(h=>h.field).join(", ")}`);e.info(`Synced ${u.length} field${u.length===1?"":"s"} across ${f.length} package${f.length===1?"":"s"}.`)}l&&u.length>0&&(process.exitCode=1)},"runPackageJsonFields"),Je=k(async e=>{const t=e.argument[0];if(!t)throw new Error(`Missing sync kind. Usage: vis sync <kind> (known kinds: ${L.join(", ")})`);if(!e.workspaceRoot)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(t==="codeowners"){await xe(e);return}if(t==="package-json-fields"){Le(e);return}throw new Error(`Unknown sync kind: "${t}". Known kinds: ${L.join(", ")}.`)},"execute");export{Je as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var Z=Object.defineProperty;var x=(e,r)=>Z(e,"name",{value:r,configurable:!0});import{createRequire as ee}from"node:module";import{I as L,j as ne,E as R,T as G,e as U,q as ie}from"../packem_shared/index.server-B7ETiT4C.js";import{z as D}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{av as c,aw as se}from"./bin.js";import{d as j,f as C,r as ae,b as oe,u as le,v as ce,e as de,g as ue,s as ge,h as fe,w as pe,j as me,k as he,l as xe,m as ve,n as we,o as ye,p as ke,q as be,t as $e}from"../packem_shared/watch-loop-DLlMLg_J.js";const re=ee(import.meta.url),F=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=x(e=>{if(typeof F<"u"&&F.versions&&F.versions.node){const[r,t]=F.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return F.getBuiltinModule(e)}return re(e)},"__cjs_getBuiltinModule"),{createHash:S}=te("node:crypto");var Ae=Object.defineProperty,v=x((e,r)=>Ae(e,"name",{value:r,configurable:!0}),"s$1");const Fe={1:"warning",2:"error"},je={argsCheck:v((e,r)=>T(e,r,!1),"argsCheck"),argsFix:v((e,r)=>T(e,r,!0),"argsFix"),bin:v(()=>["pnpm","exec","eslint"],"bin"),cacheKey:v((e,r)=>{const t=["eslint",e.declaredVersion??"unknown",e.configFile??"no-config",r.maxWarnings===void 0?"":`mw=${r.maxWarnings}`,r.quiet?"q":"",...r.extraArgs??[]];return S("sha256").update(t.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:v((e,r)=>{const t=j(r,c.eslint.packageNames[0]),n=C(e,c.eslint.configFiles);if(!(!t&&!n))return{adapter:"eslint",configFile:n,declared:!!t,declaredVersion:t,root:e}},"detect"),extensions:["cjs","cts","js","jsx","mjs","mts","ts","tsx","vue"],id:"eslint",kind:"lint",parse:v((e,r)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"eslint",file:r.root,fixable:!1,message:`eslint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const i of t)for(const s of i.messages)n.push({adapter:"eslint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.filePath,fixable:!!s.fix,line:s.line,message:s.message,ruleId:s.ruleId??void 0,severity:s.fatal?"error":Fe[s.severity]??"warning"});return n},"parse")},T=v((e,r,t)=>{const n=["--format","json","--no-error-on-unmatched-pattern"];return t&&n.push("--fix"),r.quiet&&n.push("--quiet"),typeof r.maxWarnings=="number"&&n.push("--max-warnings",String(r.maxWarnings)),r.extraArgs?.length&&n.push(...r.extraArgs),n.push(...e),n},"buildArgs");var Ce=Object.defineProperty,g=x((e,r)=>Ce(e,"name",{value:r,configurable:!0}),"s");const Se=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,qe=g(e=>{const r=Se.exec(e);if(!r)return;const[,t,n,i,s,o]=r;return{column:i===void 0?void 0:Number(i),file:t,line:Number(n),message:o,ruleId:s}},"tryParseFindingLine"),We=g(e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),"isAbsolutePath"),Oe={argsCheck:g((e,r)=>E(e,r,!1),"argsCheck"),argsFix:g((e,r)=>E(e,r,!0),"argsFix"),bin:g(()=>["pnpm","exec","markdownlint-cli2"],"bin"),cacheKey:g((e,r)=>{const t=["markdownlint",e.declaredVersion??"unknown",e.configFile??"no-config",r.maxWarnings===void 0?"":`mw=${r.maxWarnings}`,r.quiet?"q":"",...r.extraArgs??[]];return S("sha256").update(t.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:g((e,r)=>{const t=c.markdownlint.packageNames.map(i=>j(r,i)).find(i=>i!==void 0),n=C(e,c.markdownlint.configFiles);if(!(!t&&!n))return{adapter:"markdownlint",configFile:n,declared:!!t,declaredVersion:t,root:e}},"detect"),extensions:["markdown","md"],id:"markdownlint",kind:"lint",parse:g((e,r)=>{const t=(e.stderr||e.stdout||"").trim();if(!t)return[];const n=[];for(const i of t.split(/\r?\n/)){const s=qe(i.trim());s&&n.push({adapter:"markdownlint",column:s.column,file:We(s.file)?s.file:`${r.root}/${s.file}`,fixable:!0,line:s.line,message:s.message,ruleId:s.ruleId,severity:"warning"})}return n},"parse")},E=g((e,r,t)=>{const n=[];return t&&n.push("--fix"),r.extraArgs?.length&&n.push(...r.extraArgs),e.length===0?n.push("**/*.md"):n.push(...e),n},"buildArgs");var Ne=Object.defineProperty,w=x((e,r)=>Ne(e,"name",{value:r,configurable:!0}),"t");const Pe={advice:"info",error:"error",warning:"warning"},_e={argsCheck:w((e,r)=>B(e,r,!1),"argsCheck"),argsFix:w((e,r)=>B(e,r,!0),"argsFix"),bin:w(()=>["pnpm","exec","oxlint"],"bin"),cacheKey:w((e,r)=>{const t=["oxlint",e.declaredVersion??"unknown",e.configFile??"no-config",r.maxWarnings===void 0?"":`mw=${r.maxWarnings}`,r.quiet?"q":"",...r.extraArgs??[]];return S("sha256").update(t.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:w((e,r)=>{const t=j(r,c.oxlint.packageNames[0]),n=C(e,c.oxlint.configFiles);if(!(!t&&!n))return{adapter:"oxlint",configFile:n,declared:!!t,declaredVersion:t,root:e}},"detect"),extensions:["astro","cjs","cts","js","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"oxlint",kind:"lint",parse:w((e,r)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"oxlint",file:r.root,fixable:!1,message:`oxlint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const i of t.diagnostics??[]){const s=i.labels?.[0]?.span;n.push({adapter:"oxlint",column:s?.column,file:i.filename??r.root,fixable:!1,line:s?.line,message:i.message??"",ruleId:i.code,severity:Pe[i.severity??""]??"warning"})}return n},"parse")},B=w((e,r,t)=>{const n=["--format","json"];return t&&n.push("--fix"),r.quiet&&n.push("--quiet"),typeof r.maxWarnings=="number"&&n.push(`--max-warnings=${String(r.maxWarnings)}`),r.extraArgs?.length&&n.push(...r.extraArgs),n.push(...e),n},"buildArgs");var Ie=Object.defineProperty,f=x((e,r)=>Ie(e,"name",{value:r,configurable:!0}),"i$1");const Le={error:"error",info:"info",style:"info",warning:"warning"},Ke=f(e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),"isAbsolutePath"),Ve=f((e,r)=>e?Ke(e)?e:`${r}/${e}`:r,"resolveFilename"),Je={argsCheck:f((e,r)=>z(e,r),"argsCheck"),argsFix:f((e,r)=>z(e,r),"argsFix"),bin:f(()=>["shellcheck"],"bin"),cacheKey:f((e,r)=>{const t=["shellcheck",e.declaredVersion??"unknown",e.configFile??"no-config",r.quiet?"q":"",...r.extraArgs??[]];return S("sha256").update(t.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:f((e,r)=>{const t=j(r,c.shellcheck.packageNames[0]),n=C(e,c.shellcheck.configFiles);if(!(!t&&!n))return{adapter:"shellcheck",configFile:n,declared:!!t,declaredVersion:t,root:e}},"detect"),extensions:["bash","ksh","sh"],id:"shellcheck",kind:"lint",parse:f((e,r)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"shellcheck",file:r.root,fixable:!1,message:`shellcheck output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const i of t.comments??[])n.push({adapter:"shellcheck",column:i.column,endColumn:i.endColumn,endLine:i.endLine,file:Ve(i.file,r.root),fixable:!!i.fix,line:i.line,message:i.message??"",ruleId:i.code===void 0?void 0:`SC${String(i.code)}`,severity:Le[i.level??""]??"warning"});return n},"parse")},z=f((e,r)=>{const t=["--format=json1"];return r.extraArgs?.length&&t.push(...r.extraArgs),t.push(...e),t},"buildArgs");var Me=Object.defineProperty,y=x((e,r)=>Me(e,"name",{value:r,configurable:!0}),"i");const Re={error:"error",warning:"warning"},Te={argsCheck:y((e,r)=>H(e,r,!1),"argsCheck"),argsFix:y((e,r)=>H(e,r,!0),"argsFix"),bin:y(()=>["pnpm","exec","stylelint"],"bin"),cacheKey:y((e,r)=>{const t=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",r.maxWarnings===void 0?"":`mw=${r.maxWarnings}`,r.quiet?"q":"",...r.extraArgs??[]];return S("sha256").update(t.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:y((e,r)=>{const t=j(r,c.stylelint.packageNames[0]),n=C(e,c.stylelint.configFiles);if(!(!t&&!n))return{adapter:"stylelint",configFile:n,declared:!!t,declaredVersion:t,root:e}},"detect"),extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:y((e,r)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:r.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const i of t)for(const s of i.warnings??[])n.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:Re[s.severity??""]??"warning"});return n},"parse")},H=y((e,r,t)=>{const n=["--formatter","json"];return t&&n.push("--fix"),r.quiet&&n.push("--quiet"),typeof r.maxWarnings=="number"&&n.push("--max-warnings",String(r.maxWarnings)),r.extraArgs?.length&&n.push(...r.extraArgs),n.push(...e),n},"buildArgs");var Ee=Object.defineProperty,p=x((e,r)=>Ee(e,"name",{value:r,configurable:!0}),"a");const Be=[_e,oe,je,Te,le,Oe,Je,ce],tr=p(async({logger:e,options:r,visConfig:t,workspaceRoot:n})=>{const i=n??process.cwd(),s=t?.lint,o=ae(Be,s?.order),P=de(i,o),d=ue(P,o,"lint").filter(({adapter:l})=>s?.adapters?.[l.id]?.enabled!==!1);if(d.length===0){e.warn("vis lint: no linter detected in this workspace (looked for: oxlint, biome, eslint, stylelint, ruff, markdownlint, shellcheck, deno).");return}const _=p(l=>{const u=s?.adapters?.[l]?.extraArgs;return u&&u.length>0?[...u]:void 0},"baseExtraArgs"),q={extraArgs:void 0,maxWarnings:typeof r.maxWarnings=="number"?r.maxWarnings:void 0,quiet:r.quiet??!1},W=ze(r),Q=r.fix?"fix":"check";let m;if(r.staged){if(m=ge(i),m===void 0)e.warn("vis lint: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(m.length===0){e.info(L("✓ lint: no staged files"));return}}else if(typeof r.since=="string"&&r.since.length>0){if(m=fe(i,r.since),m===void 0)e.warn(`vis lint: could not resolve --since ${r.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(m.length===0){e.info(L(`✓ lint: no files changed since ${r.since}`));return}}const K=W.length>0?W:void 0,X=se(i,void 0,void 0,!0),I=r.format??"human";I==="human"&&r.output!==void 0&&e.warn("vis lint: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const V=p(async l=>{const u=l!==void 0&&l.length>0&&K===void 0,b=[];for(const{adapter:a,presence:A}of d){let h;if(u){if(h=pe(l,a.extensions),h.length===0)continue}else h=K??l??["."];const N=_(a.id),M={adapter:a,files:h,presence:A};N&&(M.options={...q,extraArgs:N}),b.push(M)}if(b.length===0)return;const Y=await me(b,q,Q,{cacheRoot:X}),O=b.map((a,A)=>{const h=Y[A],N=a.adapter.parse(h,a.presence);return{adapter:a.adapter,durationMs:h.durationMs,exitCode:h.exitCode,findings:N}}),$=he(O.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,exitCode:a.exitCode,findingCount:a.findings.length,findings:a.findings}))),k=I==="human"?void 0:xe({cwd:i,target:r.output});try{switch(I){case"github":{k.write(ye({runs:O.map(a=>({findings:a.findings})),workspaceRoot:i}));break}case"json":{k.write(`${JSON.stringify({findings:$.findings,runs:$.runs},null,2)}
|
|
2
|
-
`);break}case"junit":{k.write(we({runs:O.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,findings:a.findings})),workspaceRoot:i}));break}case"minimal":{Ge($.findings,i,k);break}case"sarif":{k.write(ve({runs:O.map(a=>({adapter:a.adapter.id,findings:a.findings,presence:b.find(A=>A.adapter.id===a.adapter.id)?.presence})),workspaceRoot:i}));break}default:He($.findings,i,e)}}finally{k?.close()}const
|
|
1
|
+
var Z=Object.defineProperty;var x=(e,r)=>Z(e,"name",{value:r,configurable:!0});import{createRequire as ee}from"node:module";import{I as L,j as ne,E as R,T as G,e as U,q as ie}from"../packem_shared/Table-CwC2kW07-EjFLNV0q.js";import{z as D}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{aL as c,aM as se}from"./bin.js";import{d as j,f as C,r as ae,b as oe,u as le,v as ce,e as de,g as ue,s as ge,h as fe,w as pe,j as me,k as he,l as xe,m as ve,n as we,o as ye,p as ke,q as be,t as $e}from"../packem_shared/watch-loop-CP318TfG.js";const re=ee(import.meta.url),F=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=x(e=>{if(typeof F<"u"&&F.versions&&F.versions.node){const[r,t]=F.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return F.getBuiltinModule(e)}return re(e)},"__cjs_getBuiltinModule"),{createHash:S}=te("node:crypto");var Ae=Object.defineProperty,v=x((e,r)=>Ae(e,"name",{value:r,configurable:!0}),"s$1");const Fe={1:"warning",2:"error"},je={argsCheck:v((e,r)=>T(e,r,!1),"argsCheck"),argsFix:v((e,r)=>T(e,r,!0),"argsFix"),bin:v(()=>["pnpm","exec","eslint"],"bin"),cacheKey:v((e,r)=>{const t=["eslint",e.declaredVersion??"unknown",e.configFile??"no-config",r.maxWarnings===void 0?"":`mw=${r.maxWarnings}`,r.quiet?"q":"",...r.extraArgs??[]];return S("sha256").update(t.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:v((e,r)=>{const t=j(r,c.eslint.packageNames[0]),n=C(e,c.eslint.configFiles);if(!(!t&&!n))return{adapter:"eslint",configFile:n,declared:!!t,declaredVersion:t,root:e}},"detect"),extensions:["cjs","cts","js","jsx","mjs","mts","ts","tsx","vue"],id:"eslint",kind:"lint",parse:v((e,r)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"eslint",file:r.root,fixable:!1,message:`eslint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const i of t)for(const s of i.messages)n.push({adapter:"eslint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.filePath,fixable:!!s.fix,line:s.line,message:s.message,ruleId:s.ruleId??void 0,severity:s.fatal?"error":Fe[s.severity]??"warning"});return n},"parse")},T=v((e,r,t)=>{const n=["--format","json","--no-error-on-unmatched-pattern"];return t&&n.push("--fix"),r.quiet&&n.push("--quiet"),typeof r.maxWarnings=="number"&&n.push("--max-warnings",String(r.maxWarnings)),r.extraArgs?.length&&n.push(...r.extraArgs),n.push(...e),n},"buildArgs");var Ce=Object.defineProperty,g=x((e,r)=>Ce(e,"name",{value:r,configurable:!0}),"s");const Se=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,qe=g(e=>{const r=Se.exec(e);if(!r)return;const[,t,n,i,s,o]=r;return{column:i===void 0?void 0:Number(i),file:t,line:Number(n),message:o,ruleId:s}},"tryParseFindingLine"),We=g(e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),"isAbsolutePath"),Oe={argsCheck:g((e,r)=>E(e,r,!1),"argsCheck"),argsFix:g((e,r)=>E(e,r,!0),"argsFix"),bin:g(()=>["pnpm","exec","markdownlint-cli2"],"bin"),cacheKey:g((e,r)=>{const t=["markdownlint",e.declaredVersion??"unknown",e.configFile??"no-config",r.maxWarnings===void 0?"":`mw=${r.maxWarnings}`,r.quiet?"q":"",...r.extraArgs??[]];return S("sha256").update(t.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:g((e,r)=>{const t=c.markdownlint.packageNames.map(i=>j(r,i)).find(i=>i!==void 0),n=C(e,c.markdownlint.configFiles);if(!(!t&&!n))return{adapter:"markdownlint",configFile:n,declared:!!t,declaredVersion:t,root:e}},"detect"),extensions:["markdown","md"],id:"markdownlint",kind:"lint",parse:g((e,r)=>{const t=(e.stderr||e.stdout||"").trim();if(!t)return[];const n=[];for(const i of t.split(/\r?\n/)){const s=qe(i.trim());s&&n.push({adapter:"markdownlint",column:s.column,file:We(s.file)?s.file:`${r.root}/${s.file}`,fixable:!0,line:s.line,message:s.message,ruleId:s.ruleId,severity:"warning"})}return n},"parse")},E=g((e,r,t)=>{const n=[];return t&&n.push("--fix"),r.extraArgs?.length&&n.push(...r.extraArgs),e.length===0?n.push("**/*.md"):n.push(...e),n},"buildArgs");var Ne=Object.defineProperty,w=x((e,r)=>Ne(e,"name",{value:r,configurable:!0}),"t");const Pe={advice:"info",error:"error",warning:"warning"},_e={argsCheck:w((e,r)=>B(e,r,!1),"argsCheck"),argsFix:w((e,r)=>B(e,r,!0),"argsFix"),bin:w(()=>["pnpm","exec","oxlint"],"bin"),cacheKey:w((e,r)=>{const t=["oxlint",e.declaredVersion??"unknown",e.configFile??"no-config",r.maxWarnings===void 0?"":`mw=${r.maxWarnings}`,r.quiet?"q":"",...r.extraArgs??[]];return S("sha256").update(t.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:w((e,r)=>{const t=j(r,c.oxlint.packageNames[0]),n=C(e,c.oxlint.configFiles);if(!(!t&&!n))return{adapter:"oxlint",configFile:n,declared:!!t,declaredVersion:t,root:e}},"detect"),extensions:["astro","cjs","cts","js","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"oxlint",kind:"lint",parse:w((e,r)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"oxlint",file:r.root,fixable:!1,message:`oxlint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const i of t.diagnostics??[]){const s=i.labels?.[0]?.span;n.push({adapter:"oxlint",column:s?.column,file:i.filename??r.root,fixable:!1,line:s?.line,message:i.message??"",ruleId:i.code,severity:Pe[i.severity??""]??"warning"})}return n},"parse")},B=w((e,r,t)=>{const n=["--format","json"];return t&&n.push("--fix"),r.quiet&&n.push("--quiet"),typeof r.maxWarnings=="number"&&n.push(`--max-warnings=${String(r.maxWarnings)}`),r.extraArgs?.length&&n.push(...r.extraArgs),n.push(...e),n},"buildArgs");var Ie=Object.defineProperty,f=x((e,r)=>Ie(e,"name",{value:r,configurable:!0}),"i$1");const Le={error:"error",info:"info",style:"info",warning:"warning"},Ke=f(e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),"isAbsolutePath"),Me=f((e,r)=>e?Ke(e)?e:`${r}/${e}`:r,"resolveFilename"),Ve={argsCheck:f((e,r)=>z(e,r),"argsCheck"),argsFix:f((e,r)=>z(e,r),"argsFix"),bin:f(()=>["shellcheck"],"bin"),cacheKey:f((e,r)=>{const t=["shellcheck",e.declaredVersion??"unknown",e.configFile??"no-config",r.quiet?"q":"",...r.extraArgs??[]];return S("sha256").update(t.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:f((e,r)=>{const t=j(r,c.shellcheck.packageNames[0]),n=C(e,c.shellcheck.configFiles);if(!(!t&&!n))return{adapter:"shellcheck",configFile:n,declared:!!t,declaredVersion:t,root:e}},"detect"),extensions:["bash","ksh","sh"],id:"shellcheck",kind:"lint",parse:f((e,r)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"shellcheck",file:r.root,fixable:!1,message:`shellcheck output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const i of t.comments??[])n.push({adapter:"shellcheck",column:i.column,endColumn:i.endColumn,endLine:i.endLine,file:Me(i.file,r.root),fixable:!!i.fix,line:i.line,message:i.message??"",ruleId:i.code===void 0?void 0:`SC${String(i.code)}`,severity:Le[i.level??""]??"warning"});return n},"parse")},z=f((e,r)=>{const t=["--format=json1"];return r.extraArgs?.length&&t.push(...r.extraArgs),t.push(...e),t},"buildArgs");var Je=Object.defineProperty,y=x((e,r)=>Je(e,"name",{value:r,configurable:!0}),"i");const Re={error:"error",warning:"warning"},Te={argsCheck:y((e,r)=>H(e,r,!1),"argsCheck"),argsFix:y((e,r)=>H(e,r,!0),"argsFix"),bin:y(()=>["pnpm","exec","stylelint"],"bin"),cacheKey:y((e,r)=>{const t=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",r.maxWarnings===void 0?"":`mw=${r.maxWarnings}`,r.quiet?"q":"",...r.extraArgs??[]];return S("sha256").update(t.join("|")).digest("hex").slice(0,16)},"cacheKey"),detect:y((e,r)=>{const t=j(r,c.stylelint.packageNames[0]),n=C(e,c.stylelint.configFiles);if(!(!t&&!n))return{adapter:"stylelint",configFile:n,declared:!!t,declaredVersion:t,root:e}},"detect"),extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:y((e,r)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:r.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const i of t)for(const s of i.warnings??[])n.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:Re[s.severity??""]??"warning"});return n},"parse")},H=y((e,r,t)=>{const n=["--formatter","json"];return t&&n.push("--fix"),r.quiet&&n.push("--quiet"),typeof r.maxWarnings=="number"&&n.push("--max-warnings",String(r.maxWarnings)),r.extraArgs?.length&&n.push(...r.extraArgs),n.push(...e),n},"buildArgs");var Ee=Object.defineProperty,p=x((e,r)=>Ee(e,"name",{value:r,configurable:!0}),"a");const Be=[_e,oe,je,Te,le,Oe,Ve,ce],tr=p(async({logger:e,options:r,visConfig:t,workspaceRoot:n})=>{const i=n??process.cwd(),s=t?.lint,o=ae(Be,s?.order),P=de(i,o),d=ue(P,o,"lint").filter(({adapter:l})=>s?.adapters?.[l.id]?.enabled!==!1);if(d.length===0){e.warn("vis lint: no linter detected in this workspace (looked for: oxlint, biome, eslint, stylelint, ruff, markdownlint, shellcheck, deno).");return}const _=p(l=>{const u=s?.adapters?.[l]?.extraArgs;return u&&u.length>0?[...u]:void 0},"baseExtraArgs"),q={extraArgs:void 0,maxWarnings:typeof r.maxWarnings=="number"?r.maxWarnings:void 0,quiet:r.quiet??!1},W=ze(r),Q=r.fix?"fix":"check";let m;if(r.staged){if(m=ge(i),m===void 0)e.warn("vis lint: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(m.length===0){e.info(L("✓ lint: no staged files"));return}}else if(typeof r.since=="string"&&r.since.length>0){if(m=fe(i,r.since),m===void 0)e.warn(`vis lint: could not resolve --since ${r.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(m.length===0){e.info(L(`✓ lint: no files changed since ${r.since}`));return}}const K=W.length>0?W:void 0,X=se(i,void 0,void 0,!0),I=r.format??"human";I==="human"&&r.output!==void 0&&e.warn("vis lint: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=p(async l=>{const u=l!==void 0&&l.length>0&&K===void 0,b=[];for(const{adapter:a,presence:A}of d){let h;if(u){if(h=pe(l,a.extensions),h.length===0)continue}else h=K??l??["."];const N=_(a.id),J={adapter:a,files:h,presence:A};N&&(J.options={...q,extraArgs:N}),b.push(J)}if(b.length===0)return;const Y=await me(b,q,Q,{cacheRoot:X}),O=b.map((a,A)=>{const h=Y[A],N=a.adapter.parse(h,a.presence);return{adapter:a.adapter,durationMs:h.durationMs,exitCode:h.exitCode,findings:N}}),$=he(O.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,exitCode:a.exitCode,findingCount:a.findings.length,findings:a.findings}))),k=I==="human"?void 0:xe({cwd:i,target:r.output});try{switch(I){case"github":{k.write(ye({runs:O.map(a=>({findings:a.findings})),workspaceRoot:i}));break}case"json":{k.write(`${JSON.stringify({findings:$.findings,runs:$.runs},null,2)}
|
|
2
|
+
`);break}case"junit":{k.write(we({runs:O.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,findings:a.findings})),workspaceRoot:i}));break}case"minimal":{Ge($.findings,i,k);break}case"sarif":{k.write(ve({runs:O.map(a=>({adapter:a.adapter.id,findings:a.findings,presence:b.find(A=>A.adapter.id===a.adapter.id)?.presence})),workspaceRoot:i}));break}default:He($.findings,i,e)}}finally{k?.close()}const V=ke($);V!==0&&(process.exitCode=V)},"runCycle");if(r.watch){const l=[...new Set(d.flatMap(({adapter:u})=>u.extensions))];await be({extensions:l,initialFiles:m,label:"lint",log:p(u=>{e.info(u)},"log"),runCycle:M,workspaceRoot:i});return}await M(m)},"execute"),ze=p(e=>{const r=e;return[...r._??r.args??[]]},"collectPositional"),He=p((e,r,t)=>{if(e.length===0){t.info(L("✓ lint: no findings"));return}const n=$e(e);for(const[o,P]of n){t.info(ne(D(r,o)));for(const d of P){const _=Ue(d),q=De(d.severity),W=d.ruleId?R(` ${d.ruleId}`):"";t.info(` ${R(_)} ${q} ${d.message}${W}`)}}const i=e.filter(o=>o.severity==="error").length,s=e.filter(o=>o.severity==="warning").length;t.info(""),t.info(`${G(`${String(i)} error${i===1?"":"s"}`)}, ${U(`${String(s)} warning${s===1?"":"s"}`)}`)},"printHuman"),Ge=p((e,r,t)=>{for(const n of e){const i=D(r,n.file),s=n.line??"",o=n.column??"";t.write(`${n.adapter} ${i} ${String(s)} ${String(o)} ${n.severity} ${n.ruleId??""} ${n.message}
|
|
3
3
|
`)}},"printMinimal"),Ue=p(e=>e.line===void 0?"":e.column===void 0?String(e.line):`${String(e.line)}:${String(e.column)}`,"formatLocation"),De=p(e=>e==="error"?G("error"):e==="warning"?U("warn "):ie("info "),"severityChipFor");export{tr as default};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var re=Object.defineProperty;var E=(e,r)=>re(e,"name",{value:r,configurable:!0});import{createRequire as te}from"node:module";import{C as se,i as J,M,$ as K,z as Q,Q as le}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{render as ce}from"@visulima/tui";import{h as ae,J as G,az as de,aA as ue,aB as fe,aC as he,p as k,s as pe}from"./bin.js";import ge,{useSyncExternalStore as me,useRef as F,useCallback as _}from"react";import{o as we}from"../packem_shared/index-DH-5hsrC.js";import{sortPackageJsonStringWithOptions as Y}from"#native";import{jsxs as f,jsx as s,Fragment as ye}from"react/jsx-runtime";import{Box as a}from"@visulima/tui/components/box";import{Text as c}from"@visulima/tui/components/text";import{useApp as xe}from"@visulima/tui/hooks/use-app";import{useInput as be}from"@visulima/tui/hooks/use-input";import{useWindowSize as Se}from"@visulima/tui/hooks/use-window-size";import{ScrollView as ke}from"@visulima/tui/components/scroll-view";import{ScrollBar as ve}from"@visulima/tui/components/scroll-bar";import{f as N}from"../packem_shared/utils-DrNg0XTR.js";const oe=te(import.meta.url),T=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=E(e=>{if(typeof T<"u"&&T.versions&&T.versions.node){const[r,t]=T.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return T.getBuiltinModule(e)}return oe(e)},"__cjs_getBuiltinModule"),{writeFileSync:ie}=ne("node:fs");var $e=Object.defineProperty,I=E((e,r)=>$e(e,"name",{value:r,configurable:!0}),"i$1");const q={error:0,rewritten:1,"would-rewrite":1,unchanged:2},Pe=I(e=>[...e].sort((r,t)=>q[r.status]-q[t.status]),"sortByStatusRank"),Ee=I((e,r)=>r==="all"?e:r==="errors"?e.filter(t=>t.status==="error"):r==="rewritten"?e.filter(t=>t.status==="rewritten"||t.status==="would-rewrite"):e.filter(t=>t.status==="unchanged"),"filterEntries");class Oe{static{E(this,"a")}static{I(this,"SortPackageJsonStore")}#e;#r=new Set;constructor(r){this.#e={entries:Pe(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=I(()=>this.#e,"getSnapshot");subscribe=I(r=>(this.#r.add(r),()=>{this.#r.delete(r)}),"subscribe");getFilteredEntries=I(()=>Ee(this.#e.entries,this.#e.filterType),"getFilteredEntries");#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const t=this.getFilteredEntries();this.#e.selectedIndex=t.length===0?-1:Math.max(0,Math.min(r,t.length-1)),this.#t()}selectStep(r){this.select(this.#e.selectedIndex+r)}setFilter(r){this.#e.filterType=r,this.#e.selectedIndex=0,this.#t()}setFocusedPanel(r){this.#e.focusedPanel=r,this.#t()}}var je=Object.defineProperty,Ce=E((e,r)=>je(e,"name",{value:r,configurable:!0}),"c$2");const Re=Ce(({checkMode:e,entry:r,focused:t,scrollRef:l})=>r?f(a,{borderColor:t?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[s(a,{flexShrink:0,paddingTop:1,paddingX:2,children:s(c,{bold:!0,color:"white",children:r.relativePath})}),f(ke,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[s(c,{}),f(a,{children:[s(a,{width:10,children:s(c,{dimColor:!0,children:"Status:"})}),r.status==="error"?s(c,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?s(c,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?s(c,{bold:!0,color:"yellow",children:"rewritten"}):s(c,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),f(a,{children:[s(a,{width:10,children:s(c,{dimColor:!0,children:"Path:"})}),s(c,{children:r.filePath})]}),r.error?f(ye,{children:[f(a,{flexDirection:"column",marginTop:1,children:[s(c,{dimColor:!0,children:"── "}),s(c,{bold:!0,color:"red",children:"ERROR"}),f(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[f(a,{children:[s(a,{width:10,children:s(c,{dimColor:!0,children:"Step:"})}),s(c,{color:"yellow",children:r.error.step})]}),r.error.context&&f(a,{children:[s(a,{width:10,children:s(c,{dimColor:!0,children:"Position:"})}),s(c,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),s(a,{marginTop:1,children:s(c,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&f(a,{flexDirection:"column",marginTop:1,children:[s(c,{dimColor:!0,children:"── "}),s(c,{bold:!0,color:"white",children:"SNIPPET"}),f(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(n=>{const i=`${n.isErrorLine?"❯":" "} ${String(n.lineNumber).padStart(4)} `;return f(a,{children:[s(c,{color:n.isErrorLine?"red":"gray",children:i}),s(c,{color:n.isErrorLine?"white":"gray",wrap:"truncate-end",children:n.content||" "})]},n.lineNumber)}),r.error.context.column>0&&s(a,{children:s(c,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):f(a,{flexDirection:"column",marginTop:1,children:[s(c,{dimColor:!0,children:"── "}),s(c,{bold:!0,color:"white",children:"KEY DIFF"}),s(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?s(c,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(n=>{const i=n.toIndex-n.fromIndex,d=i<0?`↑ ${String(Math.abs(i))}`:`↓ ${String(i)}`,p=i<0?"green":"yellow";return f(a,{children:[s(a,{width:28,children:s(c,{wrap:"truncate",children:n.key})}),s(a,{width:10,children:f(c,{dimColor:!0,children:[String(n.fromIndex)," → ",String(n.toIndex)]})}),s(c,{color:p,children:d})]},n.key)})}),e&&r.status==="would-rewrite"&&s(a,{marginTop:1,paddingLeft:2,children:s(c,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):s(a,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:s(c,{dimColor:!0,children:"No entry selected"})}),"SortDetailPanel");var Ie=Object.defineProperty,O=E((e,r)=>Ie(e,"name",{value:r,configurable:!0}),"i");const Te={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},Me={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},U={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},Fe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},Ne=[{count:O(e=>e.errors+e.rewrites+e.sorted,"count"),key:"all",label:"All",shortcut:"1"},{count:O(e=>e.rewrites,"count"),key:"rewritten",label:"Rewrites",shortcut:"2"},{count:O(e=>e.errors,"count"),key:"errors",label:"Errors",shortcut:"3"},{count:O(e=>e.sorted,"count"),key:"unchanged",label:"Sorted",shortcut:"4"}],Z=O(e=>{const r={errors:0,rewrites:0,sorted:0};for(const t of e)r[U[t.status]]++;return r},"computeGroupCounts"),Ae=O(({entry:e,isSelected:r})=>{const t=Te[e.status],l=Me[e.status];return f(a,{flexShrink:0,height:1,children:[s(c,{children:r?">":" "}),s(c,{children:" "}),s(c,{bold:!0,color:t,children:`[${l}]`.padEnd(10)}),s(c,{children:" "}),s(a,{flexGrow:1,children:s(c,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&s(c,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},"EntryRow"),De=O(({color:e,count:r,label:t})=>s(a,{flexShrink:0,height:1,children:s(c,{bold:!0,color:e,children:`${t} (${String(r)})`})}),"SectionHeader"),Be=O(({counts:e,entries:r,filterType:t,focused:l,selectedIndex:o,totalEntries:n,viewportHeight:i})=>{const d=l?"white":"gray",p=Z(r),b=(p.errors>0?1:0)+(p.rewrites>0?1:0)+(p.sorted>0?1:0),w=t==="all"&&b>1,g=[];let m;for(const[u,y]of r.entries()){const S=U[y.status];w&&S!==m&&(m!==void 0&&g.push({kind:"spacer"}),g.push({color:S==="errors"?"red":S==="rewrites"?"yellow":"green",count:p[S],kind:"header",label:Fe[S]}),m=S),g.push({entry:y,entryIndex:u,kind:"entry"})}const v=g.findIndex(u=>u.kind==="entry"&&u.entryIndex===o),$=v!==-1,P=g.length,h=Math.max(0,P-i);let C=0;$&&i>0&&(C=Math.min(h,Math.max(0,v-i+1)));const R=P>i&&i>0;return f(a,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[f(a,{flexShrink:0,gap:1,paddingX:1,children:[s(c,{bold:!0,inverse:!0,children:" VIS SORT "}),f(c,{wrap:"truncate",children:[n," ","file",n===1?"":"s"]})]}),s(a,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:Ne.map(u=>{const y=t===u.key,S=u.count(e);return f(a,{children:[s(c,{dimColor:!y,children:"["}),s(c,{bold:y,color:y?"cyan":"gray",children:u.shortcut}),s(c,{dimColor:!y,children:"]"}),f(c,{color:y?"white":"gray",children:[" ",u.label]}),f(c,{dimColor:!0,children:[" ","(",S,")"]})]},u.key)})}),f(a,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[s(a,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:s(a,{flexDirection:"column",marginTop:-C,children:g.map((u,y)=>u.kind==="spacer"?s(a,{flexShrink:0,height:1},`s-${String(y)}`):u.kind==="header"?s(De,{color:u.color,count:u.count,label:u.label},`h-${u.label}`):s(Ae,{entry:u.entry,isSelected:u.entryIndex===o},u.entry.filePath))})}),R&&s(a,{flexShrink:0,marginLeft:1,marginRight:1,children:s(ve,{contentHeight:P,placement:"inset",scrollOffset:C,style:"block",viewportHeight:i})})]})]})},"SortListPanel");var Le=Object.defineProperty,Je=E((e,r)=>Le(e,"name",{value:r,configurable:!0}),"T");const Ge=100,z=10,_e=6,qe=1,H={1:"all",2:"rewritten",3:"errors",4:"unchanged"},ze=Je(({checkMode:e,store:r})=>{const{exit:t}=xe(),{columns:l,rows:o}=Se(),n=me(r.subscribe,r.getSnapshot),i=F(null),d=r.getFilteredEntries(),p=d[n.selectedIndex]??null,b=Z(n.entries),w=l>=Ge,g=Math.max(0,o-qe),m=w?g:Math.floor(g/2),v=Math.max(0,m-_e),$=_(()=>{t()},[t]),P=F(0),h=F(void 0),C=F(!1),R=_((u,y)=>{P.current+=y,h.current=u,!C.current&&(C.current=!0,queueMicrotask(()=>{C.current=!1;const S=P.current,L=h.current;P.current=0,h.current=void 0,!(S===0||L===void 0)&&(L==="list"?r.selectStep(Math.sign(S)):i.current?.scrollBy(Math.sign(S)))}))},[r]);return be((u,y)=>{if(u==="q"||y.escape){$();return}if(H[u]){r.setFilter(H[u]);return}if(y.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}n.focusedPanel==="list"?y.upArrow||u==="k"?R("list",-1):(y.downArrow||u==="j")&&R("list",1):n.focusedPanel==="detail"&&(y.upArrow||u==="k"?R("detail",-1):(y.downArrow||u==="j")&&R("detail",1))}),o<z?s(a,{alignItems:"center",justifyContent:"center",children:f(c,{color:"yellow",children:["Terminal too small. Resize to at least",z," ","rows."]})}):f(a,{flexDirection:"column",height:o,width:l,children:[f(a,{flexDirection:w?"row":"column",flexGrow:1,children:[s(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:s(Be,{counts:b,entries:d,filterType:n.filterType,focused:n.focusedPanel==="list",selectedIndex:n.selectedIndex,totalEntries:n.entries.length,viewportHeight:v})}),s(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:s(Re,{checkMode:e,entry:p,focused:n.focusedPanel==="detail",scrollRef:i})})]}),s(a,{flexShrink:0,paddingX:1,children:s(c,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},"VisSortPackageJsonApp");var He=Object.defineProperty,j=E((e,r)=>He(e,"name",{value:r,configurable:!0}),"c$1");const W=["types","node-addons","node","import","require","default"],We=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Xe=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,A=j(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isPlainObject"),B=j(e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(t=>B(t));const r={};for(const[t,l]of Object.entries(e))r[t]=B(l);return r},"cloneDeep"),Ve=j(e=>{if(!A(e))return{changed:!1,value:e};const r=Object.keys(e);return r.length===1&&r[0]==="url"&&typeof e.url=="string"?{changed:!0,value:e.url}:{changed:!1,value:e}},"tryFormatBugs"),Ke=j(e=>e.endsWith(".git")?e.slice(0,-4):e,"stripGitSuffix"),Qe=j(e=>{if(!A(e))return{changed:!1,value:e};if(typeof e.directory=="string"&&e.directory.length>0)return{changed:!1,value:e};const{type:r}=e;if(r!==void 0&&r!=="git")return{changed:!1,value:e};const{url:t}=e;if(typeof t!="string")return{changed:!1,value:e};const l=We.exec(t)??Xe.exec(t);if(!l)return{changed:!1,value:e};const o=l[1],n=Ke(l[2]??"");if(!o||!n)return{changed:!1,value:e};const i=new Set(["type","url"]);for(const d of Object.keys(e))if(!i.has(d))return{changed:!1,value:e};return{changed:!0,value:`${o}/${n}`}},"tryFormatRepository"),Ye=j(e=>{const r=Object.keys(e),t=[],l=[];for(const i of W)Object.hasOwn(e,i)&&t.push(i);for(const i of r)W.includes(i)||l.push(i);const o=[...t,...l];if(o.length===r.length&&o.every((i,d)=>i===r[d]))return{changed:!1,value:e};const n={};for(const i of o)n[i]=e[i];return{changed:!0,value:n}},"orderConditions"),ee=j(e=>{if(!A(e))return{changed:!1,value:e};let r=!1;const t={};for(const[o,n]of Object.entries(e)){const i=ee(n);t[o]=i.value,i.changed&&(r=!0)}const l=Ye(t);return{changed:r||l.changed,value:l.value}},"sortExportsRecursive"),Ue=j((e,r)=>{const t=B(e);let l=!1;if(r.formatBugs!==!1&&Object.hasOwn(t,"bugs")){const o=Ve(t.bugs);o.changed&&(t.bugs=o.value,l=!0)}if(r.formatRepository!==!1&&Object.hasOwn(t,"repository")){const o=Qe(t.repository);o.changed&&(t.repository=o.value,l=!0)}if(r.sortExports!==!1&&Object.hasOwn(t,"exports")&&A(t.exports)){const o=ee(t.exports);o.changed&&(t.exports=o.value,l=!0)}return{changed:l,pkg:t}},"formatPackageJsonFields");var Ze=Object.defineProperty,x=E((e,r)=>Ze(e,"name",{value:r,configurable:!0}),"c");const er=/at position (\d+)/,rr=/\(?line (\d+) column (\d+)\)?/,tr=x(e=>{const r=new Set,t=[],l=x(n=>{const i=se(n);!r.has(i)&&J(i)&&(r.add(i),t.push(i))},"addFile");l(M(e,"package.json"));const o=ae(e);if(o){const n=G(e,o);for(const i of n)l(M(e,i,"package.json"))}else{const n=M(e,"package.json");if(J(n)){const i=JSON.parse(K(n)),d=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;if(d){const p=G(e,d);for(const b of p)l(M(e,b,"package.json"))}}}return t},"findPackageJsonFiles"),or=x(e=>/\n([ \t]+)/.exec(e)?.[1]??" ","detectIndent"),nr=x(e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},"resolveIndentOverride"),D=x(e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),"splitList"),ir=x(e=>e.includes(`\r
|
|
2
|
-
`)?"crlf":"lf","detectLineEnding"),
|
|
3
|
-
`);if(r<1||r>l.length)return[];const o=Math.max(0,r-1-
|
|
4
|
-
`),o==="crlf"&&(
|
|
1
|
+
var Z=Object.defineProperty;var $=(e,r)=>Z(e,"name",{value:r,configurable:!0});import{createRequire as ee}from"node:module";import{C as oe,i as G,M as T,$ as Q,z as W,Q as ne}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{a5 as t,a6 as a,n as c,aG as ie,aH as le,aI as ce,aF as ae,r as C,af as de,l as ue,J,aP as fe,aQ as he,aR as ge,aS as pe,p as b,s as xe,v as me,d as je}from"./bin.js";import{o as we}from"../packem_shared/index-DH-5hsrC.js";import{sortPackageJsonStringWithOptions as K}from"#native";import{f as F}from"../packem_shared/utils-DrNg0XTR.js";const re=ee(import.meta.url),M=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=$(e=>{if(typeof M<"u"&&M.versions&&M.versions.node){const[r,s]=M.versions.node.split(".").map(Number);if(r>22||r===22&&s>=3||r===20&&s>=16)return M.getBuiltinModule(e)}return re(e)},"__cjs_getBuiltinModule"),{writeFileSync:se}=te("node:fs");var ye=Object.defineProperty,I=$((e,r)=>ye(e,"name",{value:r,configurable:!0}),"i$1");const B={error:0,rewritten:1,"would-rewrite":1,unchanged:2},be=I(e=>[...e].sort((r,s)=>B[r.status]-B[s.status]),"sortByStatusRank"),Se=I((e,r)=>r==="all"?e:r==="errors"?e.filter(s=>s.status==="error"):r==="rewritten"?e.filter(s=>s.status==="rewritten"||s.status==="would-rewrite"):e.filter(s=>s.status==="unchanged"),"filterEntries");class ke{static{$(this,"a")}static{I(this,"SortPackageJsonStore")}#e;#r=new Set;constructor(r){this.#e={entries:be(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=I(()=>this.#e,"getSnapshot");subscribe=I(r=>(this.#r.add(r),()=>{this.#r.delete(r)}),"subscribe");getFilteredEntries=I(()=>Se(this.#e.entries,this.#e.filterType),"getFilteredEntries");#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const s=this.getFilteredEntries();this.#e.selectedIndex=s.length===0?-1:Math.max(0,Math.min(r,s.length-1)),this.#t()}selectStep(r){this.select(this.#e.selectedIndex+r)}setFilter(r){this.#e.filterType=r,this.#e.selectedIndex=0,this.#t()}setFocusedPanel(r){this.#e.focusedPanel=r,this.#t()}}var ve=Object.defineProperty,$e=$((e,r)=>ve(e,"name",{value:r,configurable:!0}),"c$2");const Pe=$e(({checkMode:e,entry:r,focused:s,scrollRef:l})=>{const o=s?"white":"gray";return r?t.jsxs(a,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(a,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(c,{bold:!0,color:"white",children:r.relativePath})}),t.jsxs(ie,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(c,{}),t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Status:"})}),r.status==="error"?t.jsx(c,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?t.jsx(c,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?t.jsx(c,{bold:!0,color:"yellow",children:"rewritten"}):t.jsx(c,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Path:"})}),t.jsx(c,{children:r.filePath})]}),r.error?t.jsxs(t.Fragment,{children:[t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"red",children:"ERROR"}),t.jsxs(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Step:"})}),t.jsx(c,{color:"yellow",children:r.error.step})]}),r.error.context&&t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Position:"})}),t.jsx(c,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),t.jsx(a,{marginTop:1,children:t.jsx(c,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"white",children:"SNIPPET"}),t.jsxs(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(n=>{const i=`${n.isErrorLine?"❯":" "} ${String(n.lineNumber).padStart(4)} `;return t.jsxs(a,{children:[t.jsx(c,{color:n.isErrorLine?"red":"gray",children:i}),t.jsx(c,{color:n.isErrorLine?"white":"gray",wrap:"truncate-end",children:n.content||" "})]},n.lineNumber)}),r.error.context.column>0&&t.jsx(a,{children:t.jsx(c,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"white",children:"KEY DIFF"}),t.jsx(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?t.jsx(c,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(n=>{const i=n.toIndex-n.fromIndex,d=i<0?`↑ ${String(Math.abs(i))}`:`↓ ${String(i)}`,h=i<0?"green":"yellow";return t.jsxs(a,{children:[t.jsx(a,{width:28,children:t.jsx(c,{wrap:"truncate",children:n.key})}),t.jsx(a,{width:10,children:t.jsxs(c,{dimColor:!0,children:[String(n.fromIndex)," → ",String(n.toIndex)]})}),t.jsx(c,{color:h,children:d})]},n.key)})}),e&&r.status==="would-rewrite"&&t.jsx(a,{marginTop:1,paddingLeft:2,children:t.jsx(c,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):t.jsx(a,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(c,{dimColor:!0,children:"No entry selected"})})},"SortDetailPanel");var Ee=Object.defineProperty,P=$((e,r)=>Ee(e,"name",{value:r,configurable:!0}),"i");const Oe={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},Ce={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},V={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},Re={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},Ie=[{count:P(e=>e.errors+e.rewrites+e.sorted,"count"),key:"all",label:"All",shortcut:"1"},{count:P(e=>e.rewrites,"count"),key:"rewritten",label:"Rewrites",shortcut:"2"},{count:P(e=>e.errors,"count"),key:"errors",label:"Errors",shortcut:"3"},{count:P(e=>e.sorted,"count"),key:"unchanged",label:"Sorted",shortcut:"4"}],Y=P(e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[V[s.status]]++;return r},"computeGroupCounts"),Me=P(({entry:e,isSelected:r})=>{const s=Oe[e.status],l=Ce[e.status];return t.jsxs(a,{flexShrink:0,height:1,children:[t.jsx(c,{children:r?">":" "}),t.jsx(c,{children:" "}),t.jsx(c,{bold:!0,color:s,children:`[${l}]`.padEnd(10)}),t.jsx(c,{children:" "}),t.jsx(a,{flexGrow:1,children:t.jsx(c,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&t.jsx(c,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},"EntryRow"),Te=P(({color:e,count:r,label:s})=>t.jsx(a,{flexShrink:0,height:1,children:t.jsx(c,{bold:!0,color:e,children:`${s} (${String(r)})`})}),"SectionHeader"),Fe=P(({counts:e,entries:r,filterType:s,focused:l,selectedIndex:o,totalEntries:n,viewportHeight:i})=>{const d=l?"white":"gray",h=Y(r),w=(h.errors>0?1:0)+(h.rewrites>0?1:0)+(h.sorted>0?1:0),x=s==="all"&&w>1,g=[];let p;for(const[u,m]of r.entries()){const y=V[m.status];x&&y!==p&&(p!==void 0&&g.push({kind:"spacer"}),g.push({color:y==="errors"?"red":y==="rewrites"?"yellow":"green",count:h[y],kind:"header",label:Re[y]}),p=y),g.push({entry:m,entryIndex:u,kind:"entry"})}const S=g.findIndex(u=>u.kind==="entry"&&u.entryIndex===o),k=S!==-1,v=g.length,f=Math.max(0,v-i);let O=0;k&&i>0&&(O=Math.min(f,Math.max(0,S-i+1)));const R=v>i&&i>0;return t.jsxs(a,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(a,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(c,{bold:!0,inverse:!0,children:" VIS SORT "}),t.jsxs(c,{wrap:"truncate",children:[n," ","file",n===1?"":"s"]})]}),t.jsx(a,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:Ie.map(u=>{const m=s===u.key,y=u.count(e);return t.jsxs(a,{children:[t.jsx(c,{dimColor:!m,children:"["}),t.jsx(c,{bold:m,color:m?"cyan":"gray",children:u.shortcut}),t.jsx(c,{dimColor:!m,children:"]"}),t.jsxs(c,{color:m?"white":"gray",children:[" ",u.label]}),t.jsxs(c,{dimColor:!0,children:[" ","(",y,")"]})]},u.key)})}),t.jsxs(a,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(a,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(a,{flexDirection:"column",marginTop:-O,children:g.map((u,m)=>u.kind==="spacer"?t.jsx(a,{flexShrink:0,height:1},`s-${String(m)}`):u.kind==="header"?t.jsx(Te,{color:u.color,count:u.count,label:u.label},`h-${u.label}`):t.jsx(Me,{entry:u.entry,isSelected:u.entryIndex===o},u.entry.filePath))})}),R&&t.jsx(a,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(le,{contentHeight:v,placement:"inset",scrollOffset:O,style:"block",viewportHeight:i})})]})]})},"SortListPanel");var Ne=Object.defineProperty,De=$((e,r)=>Ne(e,"name",{value:r,configurable:!0}),"T");const Ae=100,_=10,Le=6,Ge=1,q={1:"all",2:"rewritten",3:"errors",4:"unchanged"},Je=De(({checkMode:e,store:r})=>{const{exit:s}=ce(),{columns:l,rows:o}=ae(),n=C.useSyncExternalStore(r.subscribe,r.getSnapshot),i=C.useRef(null),d=r.getFilteredEntries(),h=d[n.selectedIndex]??null,w=Y(n.entries),x=l>=Ae,g=Math.max(0,o-Ge),p=x?g:Math.floor(g/2),S=Math.max(0,p-Le),k=C.useCallback(()=>{s()},[s]),v=C.useRef(0),f=C.useRef(void 0),O=C.useRef(!1),R=C.useCallback((u,m)=>{v.current+=m,f.current=u,!O.current&&(O.current=!0,queueMicrotask(()=>{O.current=!1;const y=v.current,L=f.current;v.current=0,f.current=void 0,!(y===0||L===void 0)&&(L==="list"?r.selectStep(Math.sign(y)):i.current?.scrollBy(Math.sign(y)))}))},[r]);return de((u,m)=>{if(u==="q"||m.escape){k();return}if(q[u]){r.setFilter(q[u]);return}if(m.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}n.focusedPanel==="list"?m.upArrow||u==="k"?R("list",-1):(m.downArrow||u==="j")&&R("list",1):n.focusedPanel==="detail"&&(m.upArrow||u==="k"?R("detail",-1):(m.downArrow||u==="j")&&R("detail",1))}),o<_?t.jsx(a,{alignItems:"center",justifyContent:"center",children:t.jsxs(c,{color:"yellow",children:["Terminal too small. Resize to at least",_," ","rows."]})}):t.jsxs(a,{flexDirection:"column",height:o,width:l,children:[t.jsxs(a,{flexDirection:x?"row":"column",flexGrow:1,children:[t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(Fe,{counts:w,entries:d,filterType:n.filterType,focused:n.focusedPanel==="list",selectedIndex:n.selectedIndex,totalEntries:n.entries.length,viewportHeight:S})}),t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(Pe,{checkMode:e,entry:h,focused:n.focusedPanel==="detail",scrollRef:i})})]}),t.jsx(a,{flexShrink:0,paddingX:1,children:t.jsx(c,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},"VisSortPackageJsonApp");var Be=Object.defineProperty,E=$((e,r)=>Be(e,"name",{value:r,configurable:!0}),"c$1");const H=["types","node-addons","node","import","require","default"],_e=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,qe=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,N=E(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isPlainObject"),A=E(e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>A(s));const r={};for(const[s,l]of Object.entries(e))r[s]=A(l);return r},"cloneDeep"),He=E(e=>{if(!N(e))return{changed:!1,value:e};const r=Object.keys(e);return r.length===1&&r[0]==="url"&&typeof e.url=="string"?{changed:!0,value:e.url}:{changed:!1,value:e}},"tryFormatBugs"),ze=E(e=>e.endsWith(".git")?e.slice(0,-4):e,"stripGitSuffix"),Xe=E(e=>{if(!N(e))return{changed:!1,value:e};if(typeof e.directory=="string"&&e.directory.length>0)return{changed:!1,value:e};const{type:r}=e;if(r!==void 0&&r!=="git")return{changed:!1,value:e};const{url:s}=e;if(typeof s!="string")return{changed:!1,value:e};const l=_e.exec(s)??qe.exec(s);if(!l)return{changed:!1,value:e};const o=l[1],n=ze(l[2]??"");if(!o||!n)return{changed:!1,value:e};const i=new Set(["type","url"]);for(const d of Object.keys(e))if(!i.has(d))return{changed:!1,value:e};return{changed:!0,value:`${o}/${n}`}},"tryFormatRepository"),Qe=E(e=>{const r=Object.keys(e),s=[],l=[];for(const i of H)Object.hasOwn(e,i)&&s.push(i);for(const i of r)H.includes(i)||l.push(i);const o=[...s,...l];if(o.length===r.length&&o.every((i,d)=>i===r[d]))return{changed:!1,value:e};const n={};for(const i of o)n[i]=e[i];return{changed:!0,value:n}},"orderConditions"),U=E(e=>{if(!N(e))return{changed:!1,value:e};let r=!1;const s={};for(const[o,n]of Object.entries(e)){const i=U(n);s[o]=i.value,i.changed&&(r=!0)}const l=Qe(s);return{changed:r||l.changed,value:l.value}},"sortExportsRecursive"),We=E((e,r)=>{const s=A(e);let l=!1;if(r.formatBugs!==!1&&Object.hasOwn(s,"bugs")){const o=He(s.bugs);o.changed&&(s.bugs=o.value,l=!0)}if(r.formatRepository!==!1&&Object.hasOwn(s,"repository")){const o=Xe(s.repository);o.changed&&(s.repository=o.value,l=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&N(s.exports)){const o=U(s.exports);o.changed&&(s.exports=o.value,l=!0)}return{changed:l,pkg:s}},"formatPackageJsonFields");var Ke=Object.defineProperty,j=$((e,r)=>Ke(e,"name",{value:r,configurable:!0}),"c");const Ve=/at position (\d+)/,Ye=/\(?line (\d+) column (\d+)\)?/,Ue=j(e=>{const r=new Set,s=[],l=j(n=>{const i=oe(n);!r.has(i)&&G(i)&&(r.add(i),s.push(i))},"addFile");l(T(e,"package.json"));const o=ue(e);if(o){const n=J(e,o);for(const i of n)l(T(e,i,"package.json"))}else{const n=T(e,"package.json");if(G(n)){const i=JSON.parse(Q(n)),d=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;if(d){const h=J(e,d);for(const w of h)l(T(e,w,"package.json"))}}}return s},"findPackageJsonFiles"),Ze=j(e=>/\n([ \t]+)/.exec(e)?.[1]??" ","detectIndent"),er=j(e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},"resolveIndentOverride"),D=j(e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),"splitList"),rr=j(e=>e.includes(`\r
|
|
2
|
+
`)?"crlf":"lf","detectLineEnding"),tr=new Set(["auto","crlf","lf"]),sr=j(e=>{if(e===void 0||e==="")return"auto";if(tr.has(e))return e;throw new Error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`)},"validateLineEnding"),or=j((e,r,s)=>r.length===0?e:e.filter(l=>{const o=W(s,l),n=ne(l);return!r.some(i=>{const d=i.includes("/")?o:n;return we(i,d)})}),"filterByIgnore"),nr=j((e,r)=>{if(r.length===0)return e;const s={},l=new Set;for(const o of r)Object.hasOwn(e,o)&&(s[o]=e[o],l.add(o));for(const o of Object.keys(e))l.has(o)||(s[o]=e[o]);return s},"applySortOrder"),ir=j((e,r,s)=>{if(s.length===0)return e;const l={...e};for(const o of s)Object.hasOwn(r,o)&&(l[o]=r[o]);return l},"restoreUnsortedSections"),lr=j((e,r)=>{let s=1,l=1;const o=Math.min(r,e.length);for(let n=0;n<o;n++)e.codePointAt(n)===10?(s++,l=1):l++;return{column:l,line:s}},"computeLineColumn"),z=j((e,r,s=2)=>{const l=e.split(`
|
|
3
|
+
`);if(r<1||r>l.length)return[];const o=Math.max(0,r-1-s),n=Math.min(l.length,r+s),i=[];for(let d=o;d<n;d++)i.push({content:l[d]??"",isErrorLine:d+1===r,lineNumber:d+1});return i},"buildSnippet"),X=j((e,r)=>{if(!(e instanceof Error))return;const s=Ve.exec(e.message);if(s){const{column:o,line:n}=lr(r,Number.parseInt(s[1]??"0",10));return{column:o,line:n,snippet:z(r,n)}}const l=Ye.exec(e.message);if(l){const o=Number.parseInt(l[1]??"1",10);return{column:Number.parseInt(l[2]??"1",10),line:o,snippet:z(r,o)}}},"extractParseErrorContext"),cr=j((e,r)=>{const s=Object.keys(JSON.parse(e)),l=Object.keys(JSON.parse(r)),o=new Map(s.map((i,d)=>[i,d])),n=[];for(const[i,d]of l.entries()){const h=o.get(d);h!==void 0&&h!==i&&n.push({fromIndex:h,key:d,toIndex:i})}return n},"computeKeyDiff"),ar=j((e,r,s)=>{const l=r.indent??s.indent??Ze(e),o=r.lineEnding==="auto"?s.lineEnding??rr(e):r.lineEnding,n=K(e,{pretty:!1,sortScripts:r.sortScripts});let i=JSON.parse(n);if(r.unsorted.length>0){const x=JSON.parse(e);i=ir(i,x,r.unsorted)}i=nr(i,r.sortOrder);const d={formatBugs:r.formatBugs,formatRepository:r.formatRepository,sortExports:r.sortExports},h=We(i,d);let w=JSON.stringify(h.pkg,null,l);return r.finalNewline&&(w+=`
|
|
4
|
+
`),o==="crlf"&&(w=w.replaceAll(`
|
|
5
5
|
`,`\r
|
|
6
|
-
`)),
|
|
6
|
+
`)),w},"sortContents"),dr=j((e,r)=>{const s=Ue(e),l=fe(e),o=he({cwd:e,extraPatterns:ge(l)}),n=s.filter(d=>!o.ignores(d)),i=or(n,r,e);return{afterGitignore:n,allFiles:s,files:i}},"discoverPackageJsonFiles"),ur=j((e,{checkMode:r,cwd:s,normalized:l})=>{const o=W(s,e)||e;let n;try{n=Q(e)}catch(x){return{diff:[],error:{message:F(x),step:"read"},filePath:e,relativePath:o,status:"error"}}let i;try{i=K(n,{pretty:!1,sortScripts:l.sortScripts})}catch(x){const g={message:F(x),step:"native-sort"},p=X(x,n);return p&&(g.context=p),{diff:[],error:g,filePath:e,relativePath:o,status:"error"}}const d=l.editorconfig?pe(e):{};let h;try{h=ar(n,l,d)}catch(x){const g={message:F(x),step:"json-parse"},p=X(x,n);return p&&(g.context=p),{diff:[],error:g,filePath:e,relativePath:o,status:"error"}}if(n===h)return{diff:[],filePath:e,relativePath:o,status:"unchanged"};let w;try{w=cr(n,i)}catch{w=[]}if(r)return{diff:w,filePath:e,relativePath:o,status:"would-rewrite"};try{se(e,h,"utf8")}catch(x){return{diff:w,error:{message:F(x),step:"write"},filePath:e,relativePath:o,status:"error"}}return{diff:w,filePath:e,relativePath:o,status:"rewritten"}},"processFile"),fr=j(e=>{if(e.error&&(b.error(`${e.filePath}: ${e.error.message}`),b.info(` step: ${e.error.step}`),e.error.context)){b.info(` at line ${String(e.error.context.line)}, column ${String(e.error.context.column)}`);for(const r of e.error.context.snippet){const s=r.isErrorLine?">":" ";b.info(` ${s} ${String(r.lineNumber).padStart(4)} | ${r.content}`)}}},"printStaticError"),yr=j(async({options:e,visConfig:r,workspaceRoot:s})=>{const l=s??process.cwd(),o=r?.sortPackageJson,n=e.check||!1,i={editorconfig:e.editorconfig===!1?!1:o?.editorconfig??!0,finalNewline:e.finalNewline??o?.finalNewline??!0,formatBugs:e.formatBugs===!1?!1:o?.formatBugs??!0,formatRepository:e.formatRepository===!1?!1:o?.formatRepository??!0,ignore:[...D(e.ignore),...o?.ignore??[]],indent:er(e.indent??o?.indent),lineEnding:sr(e.lineEnding??o?.lineEnding),sortExports:e.sortExports===!1?!1:o?.sortExports??!0,sortOrder:[...D(e.sortOrder),...o?.sortOrder??[]],sortScripts:e.sortScripts||o?.sortScripts||!1,unsorted:[...D(e.unsorted),...o?.unsorted??[]]},d=dr(l,i.ignore),{afterGitignore:h,allFiles:w,files:x}=d;if(x.length===0){w.length===0?b.info("No package.json files found."):h.length===0?b.info("All package.json files were excluded by .gitignore or workspace exclusions."):b.info("All package.json files were excluded by --ignore.");return}const g=[];for(const f of x)g.push(ur(f,{checkMode:n,cwd:l,normalized:i}));let p=0,S=0,k=0;for(const f of g)f.status==="error"?k++:f.status==="rewritten"||f.status==="would-rewrite"?p++:S++;const v=p>0||k>0;if(process.stdout.isTTY&&!xe&&v){const f=new ke(g);await me(je.createElement(Je,{checkMode:n,store:f}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit()}else for(const f of g)switch(f.status){case"error":{fr(f);break}case"rewritten":{b.success(`Sorted ${f.filePath}`);break}case"would-rewrite":{b.warn(`${f.filePath} is not sorted`);break}}if(n)p>0?(b.info(`${String(p)} file${p===1?"":"s"} not sorted, ${String(S)} already sorted`),process.exitCode=1):k===0&&b.info(`All ${String(S)} package.json file${S===1?" is":"s are"} sorted`);else{const f=[];p>0&&f.push(`sorted ${String(p)} file${p===1?"":"s"}`),S>0&&f.push(`${String(S)} already sorted`),k>0&&f.push(`${String(k)} error${k===1?"":"s"}`),f.length>0&&b.info(f.join(", "))}k>0&&(process.exitCode=1)},"execute");export{z as buildSnippet,cr as computeKeyDiff,lr as computeLineColumn,yr as default,dr as discoverPackageJsonFiles,X as extractParseErrorContext,ur as processFile};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var $=Object.defineProperty;var w=(
|
|
1
|
+
var $=Object.defineProperty;var w=(s,e)=>$(s,"name",{value:e,configurable:!0});import{createRequire as _}from"node:module";import{c as R,d as I,y as C}from"./bin.js";import{A as P}from"../packem_shared/pm-runner-COoPLGKi.js";import{l as T}from"../packem_shared/dependency-scan-Bki15Yi-.js";import{r as D}from"../packem_shared/provenance-DbkJRDqt.js";import{r as x}from"../packem_shared/signatures-B-1u4t-c.js";import{loadOptionalSigstore as q}from"./loader.js";const N=_(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=w(s=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[e,o]=d.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return d.getBuiltinModule(s)}return N(s)},"__cjs_getBuiltinModule"),{createHash:O}=y("node:crypto"),{readFileSync:E,writeFileSync:j}=y("node:fs"),{isAbsolute:k,resolve:S,basename:v}=y("node:path");var J=Object.defineProperty,u=w((s,e)=>J(s,"name",{value:e,configurable:!0}),"d");const U=u(s=>(s??"").split(",").map(e=>e.trim()).filter(e=>e.length>0),"splitList"),W=u(async({logger:s,options:e,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=e.format??"table",p=e.prodOnly??!1,m=e.failOn==="error"?"error":"warning",n=U(e.allowlist),h=P(o),l=T(o,h.name,{includeDev:!p}).map(({name:t,version:r})=>({name:t,version:r})),[g,c]=await Promise.all([D(l,{allowlist:n,workspaceRoot:o}),x(l,{allowlist:n,workspaceRoot:o})]),a=[...g.map(t=>({code:"provenance-regression",message:`Resolved ${t.packageName}@${t.version} has no published provenance attestation, but ${t.packageName}@${t.priorVersionWithProvenance} did — a provenance regression.`,packageName:t.packageName,severity:"warning",version:t.version})),...c.map(t=>({code:t.code,message:t.message,packageName:t.packageName,severity:t.severity,version:t.version}))],f=a.filter(t=>m==="error"?t.severity==="error":!0);if(i==="json")process.stdout.write(`${JSON.stringify({findings:a,ok:f.length===0},void 0,2)}
|
|
2
2
|
`);else if(i==="ndjson")for(const t of a)process.stdout.write(`${JSON.stringify(t)}
|
|
3
|
-
`);else if(a.length===0)
|
|
4
|
-
`);return}e.warn(`${b} Skipping signing (subject sha256: ${c}). Pass --require-signing to make this fatal.`);return}const a=B(v(n),c,i),f=Buffer.from(JSON.stringify(a)),t=await(await q({workspaceRoot:i})).attest(f,"application/vnd.in-toto+json"),
|
|
5
|
-
`),l==="json"){process.stdout.write(`${JSON.stringify({bundle:
|
|
6
|
-
`);return}e.info(`Signed SLSA v1 provenance for ${v(n)} (sha256 ${c.slice(0,16)}…).`),e.info(`Bundle written to ${
|
|
3
|
+
`);else if(a.length===0)s.info(`No provenance regressions or signature problems across ${String(l.length)} locked packages.`);else{const t=process.stdout.columns||80;s.info(R(I.createElement(C,{data:a.map(r=>({code:r.code,package:`${r.packageName}@${r.version}`,severity:r.severity}))}),{columns:t}));for(const r of a)s.warn(`${r.packageName}@${r.version}: ${r.message}`)}f.length>0&&(process.exitCode=1)},"attestVerifyExecute"),A=u(()=>process.env.CI==="true"||typeof process.env.ACTIONS_ID_TOKEN_REQUEST_URL=="string"||typeof process.env.SIGSTORE_ID_TOKEN=="string","detectAmbientOidc"),B=u((s,e,o)=>({_type:"https://in-toto.io/Statement/v1",predicate:{buildDefinition:{buildType:"https://visulima.com/vis/attest/v1",externalParameters:{workspaceRoot:o},internalParameters:{},resolvedDependencies:[]},runDetails:{builder:{id:"https://visulima.com/vis"},metadata:{invocationId:process.env.GITHUB_RUN_ID??"",startedOn:new Date().toISOString()}}},predicateType:"https://slsa.dev/provenance/v1",subject:[{digest:{sha256:e},name:s}]}),"buildSlsaStatement"),z=u(async({argument:s,logger:e,options:o,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const p=s[0];if(!p)throw new Error("Missing subject. Usage: vis attest <path-to-artifact>");const m=o.predicate??"slsaProvenance";if(m!=="slsaProvenance")throw new Error(`Unsupported predicate '${m}'. Only 'slsaProvenance' is supported.`);const n=k(p)?p:S(i,p),h=o.requireSigning??!1,l=o.format??"table";let g;try{g=E(n)}catch{throw new Error(`Cannot read subject artifact at ${n}.`)}const c=O("sha256").update(g).digest("hex");if(!A()){const b="No ambient OIDC token (not running in CI). Keyless signing needs a Fulcio identity from CI OIDC.";if(h)throw new Error(`${b} Re-run in CI or drop --require-signing.`);if(l==="json"){process.stdout.write(`${JSON.stringify({ok:!1,reason:"no-ambient-oidc",sha256:c,skipped:!0,subject:v(n)},void 0,2)}
|
|
4
|
+
`);return}e.warn(`${b} Skipping signing (subject sha256: ${c}). Pass --require-signing to make this fatal.`);return}const a=B(v(n),c,i),f=Buffer.from(JSON.stringify(a)),t=await(await q({workspaceRoot:i})).attest(f,"application/vnd.in-toto+json"),r=o.output?k(o.output)?o.output:S(i,o.output):`${n}.sigstore`;if(j(r,`${JSON.stringify(t,void 0,2)}
|
|
5
|
+
`),l==="json"){process.stdout.write(`${JSON.stringify({bundle:r,ok:!0,sha256:c,subject:v(n)},void 0,2)}
|
|
6
|
+
`);return}e.info(`Signed SLSA v1 provenance for ${v(n)} (sha256 ${c.slice(0,16)}…).`),e.info(`Bundle written to ${r}.`)},"attestEmitExecute");export{z as attestEmitExecute,W as attestVerifyExecute};
|