@visulima/vis 3.0.2 → 3.0.3
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 +12 -0
- package/LICENSE.md +1 -130
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/CONFIG_FILES.js +1 -1
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +1 -1
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +168 -170
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler54.js +1 -1
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler58.js +1 -1
- package/dist/packem_chunks/handler6.js +5 -5
- package/dist/packem_chunks/handler62.js +1 -1
- package/dist/packem_chunks/handler64.js +2 -2
- package/dist/packem_chunks/handler67.js +1 -1
- package/dist/packem_chunks/handler69.js +1 -1
- package/dist/packem_chunks/handler70.js +1 -1
- package/dist/packem_chunks/handler72.js +1 -1
- package/dist/packem_chunks/handler73.js +1 -1
- package/dist/packem_chunks/handler74.js +1 -1
- package/dist/packem_chunks/handler75.js +1 -1
- package/dist/packem_chunks/handler76.js +1 -1
- package/dist/packem_chunks/handler77.js +40 -40
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_chunks/list.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_shared/{advisories-DZd1uGqa.js → advisories-0ScpWAHV.js} +1 -1
- package/dist/packem_shared/{affected-selection-CoRXp5H4.js → affected-selection-BMoQWuHl.js} +1 -1
- package/dist/packem_shared/{ai-fix-6nXZbecQ.js → ai-fix-CKN1JGRh.js} +1 -1
- package/dist/packem_shared/{bin-C2eYtJ_N.js → bin-CN4heKmb.js} +1 -1
- package/dist/packem_shared/{osv-bloom-1JS__1or.js → osv-bloom-JYIWcH3F.js} +1 -1
- package/dist/packem_shared/{package-version-Bb7KGF36.js → package-version-CJxZ_B7G.js} +3 -3
- package/dist/packem_shared/{project-name-filter-DYaIbrXa.js → project-name-filter-DsrVo0MY.js} +1 -1
- package/dist/packem_shared/{scan-progress-aVHGZYWf.js → scan-progress-5uTRdC1G.js} +2 -2
- package/dist/packem_shared/{spinner-CbJfWYwB.js → spinner-BM_0Bj6x.js} +1 -1
- package/dist/packem_shared/{tabs-BilwonkM.js → tabs-UDYQ3tqt.js} +1 -1
- package/dist/packem_shared/target-merge-B4No-LHM.js +4 -0
- package/dist/packem_shared/{vis-update-app-ngwL2mRv.js → vis-update-app-zqSa2clT.js} +1 -1
- package/dist/packem_shared/{vis-user-error-CAu9wIbe.js → vis-user-error-Dkc97rGY.js} +1 -1
- package/index.js +26 -26
- package/package.json +11 -11
- package/dist/packem_shared/target-merge-DCGow6Kw.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as T}from"node:module";import{j as $,F as R,b as P,q as L,X as S,J as k}from"../packem_shared/index.server-BAjDJSEu.js";import{a as N}from"../packem_shared/index-DHD8wb6Z.js";import{a as B,r as D,b as y,c as M}from"../packem_shared/ai-fix-
|
|
1
|
+
import{createRequire as T}from"node:module";import{j as $,F as R,b as P,q as L,X as S,J as k}from"../packem_shared/index.server-BAjDJSEu.js";import{a as N}from"../packem_shared/index-DHD8wb6Z.js";import{a as B,r as D,b as y,c as M}from"../packem_shared/ai-fix-CKN1JGRh.js";import{p as c}from"./cli-main.js";import{l as _}from"../packem_shared/failure-log-D92tM0ie.js";let A;const O=s=>(A??=T(import.meta.url))(s),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=s=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[t,i]=d.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return d.getBuiltinModule(s)}return O(s)},{createInterface:J}=q("node:readline"),U={"ambiguous-match":"ambiguous match",applied:"applied",error:"error","missing-file":"missing file","no-match":"no match","outside-workspace":"outside workspace"},j=(s,t,i)=>{const e=M(s,t,i),r=N(s,e);return r===""||r.startsWith("..")?e:r},W=(s,t,i)=>{const e=[$(`Fix proposal (${s.provider}, confidence: ${s.confidence})`),"",s.explanation||R("<no explanation>")];if(s.cannotFix)return e.push(""),e.push(P(`Cannot fix automatically: ${s.cannotFix}`)),e.join(`
|
|
2
2
|
`);if(s.patches.length===0)return e.push(""),e.push(P("No patches were proposed.")),e.join(`
|
|
3
3
|
`);e.push(""),e.push($(`Patches (${String(s.patches.length)}):`));for(const[r,o]of s.patches.entries()){const a=j(t,i,o.file);e.push(""),e.push(L(`[${String(r+1)}] ${a}`)),o.reason&&e.push(R(` reason: ${o.reason}`));for(const h of o.oldString.split(`
|
|
4
4
|
`))e.push(S(` - ${h}`));for(const h of o.newString.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as A}from"node:module";import{J as P,F as _,X as F,b as I}from"../packem_shared/index.server-BAjDJSEu.js";import{e as q}from"../packem_shared/index-DHD8wb6Z.js";import{c as b,p,O as N}from"./cli-main.js";import{c as B,h as z,d as H,r as U,x as W}from"./catalog.js";import{a as G,c as V,n as X}from"../packem_shared/pm-runner-de-jCq8q.js";import{r as Y,a as J}from"../packem_shared/command-runtime-CiLVo4ED.js";import{r as j,a as K,p as Q,b as Z}from"../packem_shared/resolve-explicit-DYaHAVDg.js";import{D as ee,e as y,f as te,h as S,i as re,j as se,s as ne}from"../packem_shared/formatBytes-BHAzNIrn-DFIppnY0.js";import{r as oe}from"../packem_shared/typosquats-Cdsnf6aN.js";import{p as R,t as C}from"../packem_shared/utils-DQFHJn72.js";import{p as ae}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{T as ce}from"../packem_shared/target-merge-
|
|
1
|
+
import{createRequire as A}from"node:module";import{J as P,F as _,X as F,b as I}from"../packem_shared/index.server-BAjDJSEu.js";import{e as q}from"../packem_shared/index-DHD8wb6Z.js";import{c as b,p,O as N}from"./cli-main.js";import{c as B,h as z,d as H,r as U,x as W}from"./catalog.js";import{a as G,c as V,n as X}from"../packem_shared/pm-runner-de-jCq8q.js";import{r as Y,a as J}from"../packem_shared/command-runtime-CiLVo4ED.js";import{r as j,a as K,p as Q,b as Z}from"../packem_shared/resolve-explicit-DYaHAVDg.js";import{D as ee,e as y,f as te,h as S,i as re,j as se,s as ne}from"../packem_shared/formatBytes-BHAzNIrn-DFIppnY0.js";import{r as oe}from"../packem_shared/typosquats-Cdsnf6aN.js";import{p as R,t as C}from"../packem_shared/utils-DQFHJn72.js";import{p as ae}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{T as ce}from"../packem_shared/target-merge-B4No-LHM.js";let L;const T=r=>(L??=A(import.meta.url))(r),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=r=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[i,e]=w.versions.node.split(".").map(Number);if(i>22||i===22&&e>=3||i===20&&e>=16)return w.getBuiltinModule(r)}return T(r)},{createInterface:O}=M("node:readline"),x=r=>r==="default"?"catalog:":`catalog:${r}`,v=r=>r==="default"?"default catalog":`catalog "${r}"`,ie=(r,i)=>{const e=[];for(const[t,s]of i)t.includes(":")||s.has(r)&&e.push(t);if(e.length===0)return;if(e.length===1){const[t]=e;return{source:v(t),spec:x(t)}}const o=e.find(t=>t==="default")??e[0],a=e.filter(t=>t!==o);return{candidates:[...e],conflict:!0,source:`${v(o)} (also in: ${a.map(t=>v(t)).join(", ")})`,spec:x(o)}},le=(r,i)=>{const e=new Map;for(const[c,u]of i){if(!c.includes(":"))continue;const f=u.get(r);f!==void 0&&e.set(f,(e.get(f)??0)+1)}if(e.size===0)return;const o=[...e.entries()],a=o.reduce((c,[,u])=>c+u,0);if(o.length===1){const[[c]]=o;return{source:`siblings (${String(a)} pkg${a===1?"":"s"} on ${c})`,spec:c}}const t=[...o].sort((c,u)=>u[1]-c[1]),[s,n]=t[0],l=t.slice(1).map(([c,u])=>`${c} (×${String(u)})`);return{candidates:t.map(([c])=>c),conflict:!0,source:`siblings (most common: ${s} ×${String(n)}; conflicts: ${l.join(", ")})`,spec:s}},fe=(r,i)=>{const e=ie(r,i);return e||le(r,i)},pe=(r,i,e)=>{const o=[];for(const a of r.values()){const{overall:t}=a.score,s=ne(t),n=`${String(Math.round(t*100))}%`,l=a.alerts.length,c=y(a),u=te(c,a.version,e),f=s==="red"?F:s==="yellow"?I:P;if(u?p.info(` ${f(n)} ${S(a)} ${_(`[accepted: ${u.reason}]`)}`):p.info(` ${f(n)} ${S(a)}`),l>0){const m=a.alerts.filter(d=>d.severity==="critical"||d.severity==="high").length;m>0&&p.warn(` ${String(m)} critical/high alert${m===1?"":"s"}`)}t<i&&!u&&o.push(a)}return o},ue=async(r,i)=>{const e=O({input:process.stdin,output:process.stdout}),o=n=>new Promise(l=>{e.question(n,c=>{l(c.trim())})}),a=String(Math.round(i*100));p.warn(""),p.warn(`${String(r.length)} package${r.length===1?"":"s"} scored below the minimum threshold (${a}%):`);for(const n of r){const l=y(n),c=`${String(Math.round(n.score.overall*100))}%`;p.warn(` • ${l}@${n.version} — score: ${c} (${re(n.score.overall)})`)}p.warn("");const t=await o("Continue adding these packages? [y/N] ");if(t.toLowerCase()!=="y"&&t.toLowerCase()!=="yes")return e.close(),!1;const s=await o("Remember this decision? (prints config snippet) [y/N] ");if(e.close(),s.toLowerCase()==="y"||s.toLowerCase()==="yes"){p.notice(""),p.notice("Add the following to security.acceptedRisks in vis.config.ts:"),p.notice("");for(const n of r){const l=y(n),c=se(l,n.version,n.score.overall,"Reviewed and accepted");p.notice(c)}p.notice("")}return!0},de=async(r,i,e,o)=>{const a=await j(r);if(a.length===0)return!0;p.info(""),p.info(`${i.map(n=>n.displayName).join(" + ")} security check:`);const t=await z(i,a);if(t.size===0)return p.info(" Could not fetch security data. Proceeding."),!0;const s=pe(t,e,o);return s.length===0?(p.info(""),!0):process.stdin.isTTY?ue(s,e):(p.warn(`Aborting: ${String(s.length)} package${s.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},me=["dependencies","devDependencies","peerDependencies","optionalDependencies"],ge=r=>r.savePeer?"peerDependencies":r.saveOptional?"optionalDependencies":r.saveDev?"devDependencies":"dependencies",D=(r,i)=>r.startsWith("catalog:")||!i?r:r.replace(/^[\^~]/,""),he=async(r,i)=>{const e=[];for(const t of r){const{name:s,versionSpec:n}=R(t);if(!s)continue;if(n!==void 0){e.push({explicit:n,name:s});continue}const l=fe(s,i);if(l){l.conflict&&p.warn(`${s}: ambiguous constraint — picking ${l.spec} (${l.source}). Pass ${s}@<version> to override.`),e.push({entry:{name:s,source:l.source,spec:l.spec},kind:"resolved",name:s});continue}e.push({kind:"missing",name:s})}const o=e.filter(t=>"kind"in t&&t.kind==="missing").map(t=>t.name),a=o.length>0?await Z(o):new Map;return e.map(t=>{if("explicit"in t)return{name:t.name,source:"explicit",spec:t.explicit};if(t.kind==="resolved")return t.entry;const s=a.get(t.name);if(s===void 0)throw new Error(`--to: cannot resolve a version for "${t.name}" (not in any catalog or sibling, and registry lookup failed). Pass ${t.name}@<version> explicitly.`);const n=`^${s}`;return p.info(`${t.name}: no existing constraint — using registry latest (${n}). Add to a catalog to share this version across workspace packages.`),{name:t.name,source:"registry latest",spec:n}})},ke=(r,i,e,o)=>{for(const{name:a,spec:t}of i){const s=D(t,o);for(const l of me){if(l===e)continue;const c=r[l];c?.[a]!==void 0&&(delete c[a],Object.keys(c).length===0&&delete r[l])}let n=r[e];n===void 0&&(n={},r[e]=n),n[a]=s}},we=async({ignoreScripts:r,logger:i,options:e,packages:o,pm:a,target:t,visConfig:s,workspaceRoot:n})=>{const{workspace:l}=H(n,s??{}),c=l.projects[t];if(!c){const g=Object.keys(l.projects).sort();throw new Error(`--to: workspace package "${t}" not found. Available: ${g.length>0?g.slice(0,10).join(", "):"(none)"}${g.length>10?`, ... (${String(g.length-10)} more)`:""}.`)}const u=q(n,c.root,"package.json"),{packageManager:f}=N(n),m=U(n,f),d=ge(e),k=e.exact??!1,h=await he(o,m);if(h.length===0)return 0;const $=ae(u);ke($,h,d,k),ce(u,$,{indent:W(u,{useEditorconfig:s?.editorconfig??!0}),overwrite:!0});for(const g of h){const E=D(g.spec,k);p.info(`${P("+")} ${g.name}@${E} → ${t}/${d} (${_(g.source)})`)}return X(a,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:r,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},n,i)},Ae=async({argument:r,logger:i,options:e,visConfig:o,workspaceRoot:a})=>{let t=r;if(!t||t.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(e.typosquatCheck!==!1){const f=t.map(d=>R(d)),m=await oe(f.map(d=>d.name),o?.security?.typosquatAllowlist);if(!m.ok){process.exitCode=1;return}t=f.map((d,k)=>{const h=m.packages[k];return h!==d.name?d.versionSpec?`${h}@${d.versionSpec}`:h??"":t[k]??""})}if(e.marshallCheck!==!1){const f=await j(t);if(f.length>0){const m=await K(f,{config:o?.security?.marshalls,workspaceRoot:a});if(!await Q(m)){process.exitCode=1;return}}}if(e.socketCheck!==!1){const f=new Set;b("socket")&&f.add("socket"),b("depsDev")&&f.add("deps-dev");const m=B(o?.security,{disabled:f,minimumScore:o?.security?.policies?.score?.minimum});if(m.length>0){const d=o?.security?.policies?.score?.minimum??ee;if(!await de(t,m,d,o?.security?.acceptedRisks)){process.exitCode=1;return}}}const s=process.cwd(),n=Y({logger:i,options:e,visConfig:o},a??s),l=G(a??s,{backend:J(n),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),c=!e.runScripts;if(e.to){if(e.global||e.workspaceRoot)throw new Error("--to is incompatible with --global / --workspace-root.");if(e.filter&&C(e.filter).length>0)throw new Error("--to and --filter are mutually exclusive — --to already targets one package.");if(!a)throw new Error("--to requires a monorepo workspace. Run from inside a pnpm/bun/yarn/npm workspace.");const f=await we({ignoreScripts:c,logger:i,options:e,packages:t,pm:l,target:e.to,visConfig:o,workspaceRoot:a});f!==0&&(process.exitCode=f);return}const u=V(l,{exact:e.exact||!1,filter:C(e.filter),global:e.global||!1,optional:e.saveOptional||!1,packages:t,peer:e.savePeer||!1,saveDev:e.saveDev||!1,workspace:e.workspace||!1,workspaceRoot:e.workspaceRoot||!1},s,i,{autoInstallPeers:e.autoInstallPeers||!1,ignoreScripts:c});u!==0&&(process.exitCode=u)};export{Ae as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{readLastRunSummary as S,getLastRunSummaryPath as I}from"@visulima/task-runner";import{p as f,l as x,
|
|
1
|
+
import{readLastRunSummary as S,getLastRunSummaryPath as I}from"@visulima/task-runner";import{p as f,l as x,f as w}from"./cli-main.js";import{c as $,d as m}from"../packem_shared/formatBytes-BHAzNIrn-DFIppnY0.js";const T=new Set(["json","table"]),k=(t,e)=>t??e,h=t=>t===void 0?"-":t<1e3?`${String(t)}ms`:`${(t/1e3).toFixed(2)}s`,p=t=>t.exitCode===void 0?t.cacheStatus:t.exitCode===0?t.cacheStatus==="MISS"?"OK":t.cacheStatus:`FAIL(${String(t.exitCode)})`,s=(t,e)=>t.length>=e?t:t+" ".repeat(e-t.length),v=t=>t.exitCode!==void 0&&t.exitCode!==0,l=(t,e)=>{e.info(`Run ${t.id}`),e.info(` start: ${t.startTime}`),e.info(` end: ${t.endTime}`),e.info(` duration: ${h(t.duration)}`),e.info(` totals: ${String(t.stats.total)} total · ${String(t.stats.succeeded)} ok · ${String(t.stats.cached)} cached · ${String(t.stats.skipped)} skipped · ${String(t.stats.failed)} failed`),e.info(` env: node ${t.environment.nodeVersion} · ${t.environment.platform}/${t.environment.arch}`),e.info("")},C=(t,e)=>{if(t.length===0){e.info("(no tasks match the current filter)");return}const i=t.map(n=>({duration:h(n.duration),hash:n.hash?n.hash.slice(0,12):"-",status:p(n),taskId:n.taskId})),a={duration:Math.max(8,...i.map(n=>n.duration.length)),hash:Math.max(4,...i.map(n=>n.hash.length)),status:Math.max(6,...i.map(n=>n.status.length)),taskId:Math.max(4,...i.map(n=>n.taskId.length))};e.info(` ${s("task",a.taskId)} ${s("status",a.status)} ${s("duration",a.duration)} ${s("hash",a.hash)}`),e.info(` ${"-".repeat(a.taskId)} ${"-".repeat(a.status)} ${"-".repeat(a.duration)} ${"-".repeat(a.hash)}`);for(const n of i)e.info(` ${s(n.taskId,a.taskId)} ${s(n.status,a.status)} ${s(n.duration,a.duration)} ${s(n.hash,a.hash)}`)},R=(t,e,i)=>{l(t,i),i.info(`Task ${e.taskId}`),i.info(` status: ${p(e)}`),i.info(` cache: ${e.cacheStatus}`),i.info(` duration: ${h(e.duration)}`),i.info(` exit: ${e.exitCode===void 0?"-":String(e.exitCode)}`),i.info(` hash: ${e.hash??"(none)"}`),i.info(` start: ${e.startTime??"-"}`),i.info(` end: ${e.endTime??"-"}`),e.dependencies.length>0&&i.info(` deps: ${e.dependencies.join(", ")}`),i.info(""),f.info(`Drill into hash inputs with: vis cache why ${e.taskId} --run ${t.id}`)},D=t=>{process.stdout.write(`${JSON.stringify(t.map(e=>({id:e.id,mtime:new Date(e.mtimeMs).toISOString(),path:e.path})),void 0,2)}
|
|
2
2
|
`)},M=(t,e,i)=>{if(t.length===0){f.info(`No recorded runs found in ${m(e)}/. Run with --summarize to record a run.`);return}const a={id:Math.max(2,...t.map(n=>n.id.length)),mtime:24};i.info(` ${s("id",a.id)} ${s("mtime",a.mtime)}`),i.info(` ${"-".repeat(a.id)} ${"-".repeat(a.mtime)}`);for(const n of t)i.info(` ${s(n.id,a.id)} ${new Date(n.mtimeMs).toISOString()}`)},O=(t,e)=>{let{tasks:i}=t;return e.task!==void 0&&(i=i.filter(a=>a.taskId===e.task)),e.failed&&(i=i.filter(a=>v(a))),i},j=async(t,e)=>{const{failed:i,format:a,runId:n,task:o,workspaceRoot:d}=t,r=n===void 0?await S(d,{dataDirectory:$(d)}):await w(d,n);if(!r){if(a==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:n??null},void 0,2)}
|
|
3
3
|
`),process.exitCode=1;return}n===void 0?f.error(`No previous run summary found. Run a task first to populate \`${I(d,{dataDirectory:$(d)})}\`.`):f.error(`Run summary "${n}" not found in ${m(d)}/.`),process.exitCode=1;return}const c=O(r,{failed:i,task:o});if(o!==void 0&&c.length===0){if(a==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:r.id,taskId:o},void 0,2)}
|
|
4
4
|
`),process.exitCode=1;return}f.error(`Task "${o}" was not part of run ${r.id}.`),process.exitCode=1;return}if(r.stats.failed>0&&(process.exitCode=1),a==="json"){process.stdout.write(`${JSON.stringify({duration:r.duration,endTime:r.endTime,environment:r.environment,runId:r.id,startTime:r.startTime,stats:r.stats,tasks:c.map(u=>({cacheStatus:u.cacheStatus,dependencies:u.dependencies,duration:u.duration,endTime:u.endTime,exitCode:u.exitCode,hash:u.hash??null,startTime:u.startTime,taskId:u.taskId}))},void 0,2)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createTaskGraph as $}from"@visulima/task-runner";import{d as b,b as O}from"./catalog.js";import{f as P}from"../packem_shared/project-name-filter-
|
|
1
|
+
import{createTaskGraph as $}from"@visulima/task-runner";import{d as b,b as O}from"./catalog.js";import{f as P}from"../packem_shared/project-name-filter-DsrVo0MY.js";import{r as S,f as E,a as G}from"../packem_shared/selectors-B7lSFz7l.js";const T=(l,s,t)=>{const a=[],e=new Set,n=(r,u)=>{if(e.has(r))return;e.add(r);const m=s[r]??[];for(const d of m)n(d,u+1);const o=t[r],h=" ".repeat(u);a.push(`${h}${r}${o?.cache===!1?" (no-cache)":""}`)};for(const r of l)n(r,0);return a},x=(l,s,t)=>({roots:l,tasks:Object.fromEntries(Object.entries(t).map(([a,e])=>[a,{cache:e.cache,dependsOn:s[a]??[],outputs:e.outputs,parallelism:e.parallelism,projectRoot:e.projectRoot,target:e.target}]))}),C=async({argument:l,logger:s,options:t,process:a,visConfig:e,workspaceRoot:n})=>{const r=l[0];if(!r)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!n)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:u,packageJsons:m,workspace:o}=b(n,e),h=O(n,o,m),d=await S(r,o,a.cwd,n),{target:f}=d;let i=d.projects;t.projects!==void 0&&(i=P(i,String(t.projects),Object.keys(o.projects))),t.query&&(i=E(i,o,t.query)),i=G(i,o,t.tag);const k=i.filter(p=>o.projects[p]?.targets?.[f]!==void 0);if(k.length===0){s.info(`No projects have a "${f}" target.`);return}const y=k.map(p=>{const g=o.projects[p],j=g.targets?.[f],v={project:p,target:f};return{cache:j?.cache,id:`${p}:${f}`,outputs:j?.outputs??[],overrides:{command:j?.command},parallelism:j?.parallelism,projectRoot:g.root,target:v}}),c=$(y,{projectGraph:h,targetDefaults:u.tasks,workspace:o});if(t.json){s.info(JSON.stringify(x(c.roots,c.dependencies,c.tasks),null,2));return}const w=T(c.roots,c.dependencies,c.tasks);s.info(`Execution plan (${Object.keys(c.tasks).length} task(s), ${c.roots.length} root(s)):`),s.info("");for(const p of w)s.info(p)};export{C as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as C}from"node:module";import"../packem_shared/index-DHD8wb6Z.js";import{w as A,d as I}from"./catalog.js";import{p as c,
|
|
1
|
+
import{createRequire as C}from"node:module";import"../packem_shared/index-DHD8wb6Z.js";import{w as A,d as I}from"./catalog.js";import{p as c,j as N}from"./cli-main.js";import{p as L,i as R,r as v,g as H,s as M,a as b,S as W,b as O,c as P,d as U,e as D}from"../packem_shared/lifecycle-CfTZQHOG.js";import{r as q,l as z}from"../packem_shared/target-options-d_rIrLyq.js";let T;const j=s=>(T??=C(import.meta.url))(s),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=s=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[e,r]=w.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return w.getBuiltinModule(s)}return j(s)},{open:E,stat:$,watch:F}=_("node:fs/promises"),h=async s=>{const e=s?.plugins;if(!e||e.length===0)return;const r=U();return await D(r,e),{callHook:async(d,...o)=>{try{await r.callHook(d,...o)}catch(t){const a=t instanceof Error?t.message:String(t);c.warn(`Plugin error in ${d}: ${a}`)}}}},V=s=>{const e=s.trim(),r=e.lastIndexOf(":");if(!(r<=0||r===e.length-1))return{project:e.slice(0,r),target:e.slice(r+1)}},y=async(s,e,r)=>{const d=V(r);if(!d){c.error(`Invalid target id "${r}". Expected "<project>:<target>", e.g. "@my/api:db".`);return}const o=await A(s),{projectOptions:t,workspace:a}=I(s,e,o),i=a.projects[d.project],n=t.get(d.project)?.[d.target];if(!i||!n){c.error(`Target "${r}" not found in this workspace.`);return}const p=n.options?.service;if(!p){c.error(`Target "${r}" is not a service. Add an \`options.service\` block to make it eligible for \`vis service\`.`);return}if(!n.command){c.error(`Target "${r}" has no command — services must be runnable.`);return}const g=q(s,i.root,n.options?.runFromWorkspaceRoot===!0),u=n.options?.envFile?z(g,n.options.envFile):{};return{command:n.command,cwd:g,env:{...u,...p.env},service:p,target:n,targetId:r}},m=s=>{if(!s)throw new Error("Could not determine workspace root. Run `vis service` inside a workspace.");return s},re=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),t=s[0]?.trim();if(!t){c.error("Missing target id. Usage: vis service start <project>:<target>"),process.exitCode=1;return}const a=await y(o,r,t);if(!a){process.exitCode=1;return}try{const{entry:i}=await b({command:a.command,config:a.service,cwd:a.cwd,env:a.env,id:t,readinessTimeoutMs:e.timeout,skipReadiness:e.readiness===!1,workspaceRoot:o});await(await h(r))?.callHook("service:start",i),c.success(`Started ${t} (pid ${String(i.pid)})`),c.info(` log: ${i.logFile}`)}catch(i){const n=i instanceof Error?i.message:String(i);i instanceof W?c.error(`Readiness probe failed for ${t}: ${n}`):c.error(`Failed to start ${t}: ${n}`),process.exitCode=1}},S=async({graceMs:s,hookSink:e,id:r,workspaceRoot:d})=>{const o=await v(d,r),{stopped:t}=await M({graceMs:s,id:r,workspaceRoot:d});return t?(o&&await e?.callHook("service:stop",o),c.success(`Stopped ${r}`),!0):(c.info(`No running service registered for ${r}`),!1)},se=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),{graceMs:t}=e,a=s[0]?.trim(),i=await h(r);if(e.all===!0){if(a){c.error("Cannot combine --all with a target id. Use one or the other."),process.exitCode=1;return}const p=await P(o);if(p.length===0){c.info("No running services registered for this workspace.");return}for(const g of p)await S({graceMs:t,hookSink:i,id:g.id,workspaceRoot:o});return}if(!a){c.error("Missing target id. Usage: vis service stop <project>:<target> | --all"),process.exitCode=1;return}await S({graceMs:t,hookSink:i,id:a,workspaceRoot:o})||(process.exitCode=1)},B=s=>{const e=s.config.readiness?.tcp.port??s.config.port;return e===void 0?"—":String(e)},x=new Set(["json","table"]),oe=async({logger:s,options:e,workspaceRoot:r})=>{const d=m(r),o=e.format??"table";if(!x.has(o)){c.error(`Invalid --format "${o}". Expected one of: ${[...x].sort().join(", ")}.`),process.exitCode=1;return}const{surviving:t}=await L(d);if(o==="json"){const l=Date.now();process.stdout.write(`${JSON.stringify(t.map(f=>{const k=Date.parse(f.startedAt);return{ageMs:Number.isFinite(k)?l-k:null,alive:R(f.pid),command:f.command,cwd:f.cwd,env:f.env,id:f.id,logFile:f.logFile,pid:f.pid,port:f.config.readiness?.tcp.port??f.config.port??null,startedAt:f.startedAt,visVersion:f.visVersion}}),void 0,2)}
|
|
2
2
|
`);return}if(t.length===0){c.info("No running services registered for this workspace.");return}const a=Date.now(),i=t.map(l=>{const f=Date.parse(l.startedAt);return{age:Number.isFinite(f)?N(f,a):"?",id:l.id,log:l.logFile,pid:String(l.pid),port:B(l)}}),n=Math.max(2,...i.map(l=>l.id.length)),p=Math.max(3,...i.map(l=>l.pid.length)),g=Math.max(4,...i.map(l=>l.port.length)),u=Math.max(3,...i.map(l=>l.age.length));s.info(` ${"id".padEnd(n)} ${"pid".padEnd(p)} ${"port".padEnd(g)} ${"age".padEnd(u)} log`),s.info(` ${"-".repeat(n)} ${"-".repeat(p)} ${"-".repeat(g)} ${"-".repeat(u)} ---`);for(const l of i)s.info(` ${l.id.padEnd(n)} ${l.pid.padEnd(p)} ${l.port.padEnd(g)} ${l.age.padEnd(u)} ${l.log}`)},ie=async({argument:s,options:e,workspaceRoot:r})=>{const d=m(r),o=s[0]?.trim();if(!o){c.error("Missing target id. Usage: vis service status <project>:<target>"),process.exitCode=1;return}const t=await v(d,o);if(!t){c.error(`No service registered for ${o}.`),process.exitCode=1;return}if(!R(t.pid)){c.error(`Service ${o} is not running (pid ${String(t.pid)} is dead). Run \`vis service start ${o}\` to recover.`),process.exitCode=1;return}try{await O(t.config,{timeoutMs:e.timeout}),c.success(`${o} healthy (pid ${String(t.pid)})`)}catch(a){const i=a instanceof Error?a.message:String(a);c.error(`${o} probe failed: ${i}`),process.exitCode=1}},ae=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),t=s[0]?.trim();if(!t){c.error("Missing target id. Usage: vis service restart <project>:<target>"),process.exitCode=1;return}const a=await h(r),i=await v(o,t);(await M({graceMs:e.graceMs,id:t,workspaceRoot:o})).stopped&&i&&await a?.callHook("service:stop",i);const p=await y(o,r,t);if(!p){process.exitCode=1;return}try{const{entry:g}=await b({command:p.command,config:p.service,cwd:p.cwd,env:p.env,id:t,readinessTimeoutMs:e.timeout,skipReadiness:e.readiness===!1,workspaceRoot:o});await a?.callHook("service:start",g),c.success(`Restarted ${t} (pid ${String(g.pid)})`)}catch(g){const u=g instanceof Error?g.message:String(g);c.error(`Failed to restart ${t}: ${u}`),process.exitCode=1}},G=200,J=1024*1024,K=async s=>{let e=0;try{e=(await $(s)).size}catch{e=0}const r=new AbortController;let d=!1;const o=()=>{d=!0,r.abort()},t=()=>{r.abort()};process.on("SIGINT",o),process.on("SIGTERM",t);let a=!1;const i=async()=>{if(!a){a=!0;try{const n=await $(s).catch(()=>{});if(!n||(n.size<e&&(e=0),n.size===e))return;const p=n.size-e,g=Math.min(p,J),u=await E(s,"r");try{const l=Buffer.alloc(g);await u.read(l,0,g,e),process.stdout.write(l),e+=g}finally{await u.close().catch(()=>{})}}finally{a=!1}}};try{const n=(async()=>{try{const p=F(s,{signal:r.signal});for(;!(await p.next()).done;)await i()}catch{}})();for(;!r.signal.aborted;)await i(),await new Promise(p=>{const g=setTimeout(p,G);r.signal.addEventListener("abort",()=>{clearTimeout(g),p()},{once:!0})});await n.catch(()=>{}),await i().catch(()=>{})}finally{process.off("SIGINT",o),process.off("SIGTERM",t)}d&&(process.exitCode=130)},ne=async({argument:s,options:e,workspaceRoot:r})=>{const d=m(r),o=s[0]?.trim();if(!o){c.error("Missing target id. Usage: vis service logs <project>:<target>"),process.exitCode=1;return}const t=await v(d,o);if(!t){c.error(`No service registered for ${o}.`),process.exitCode=1;return}if(!await H(t.logFile)){c.warn(`Log file is missing for ${o}: ${t.logFile}`),process.exitCode=1;return}if(e.follow===!0){await K(t.logFile);return}const a=await E(t.logFile,"r");try{const i=a.createReadStream();await new Promise((n,p)=>{i.on("end",n),i.on("error",p),i.pipe(process.stdout,{end:!1})})}finally{await a.close().catch(()=>{})}};export{oe as serviceListExecute,ne as serviceLogsExecute,ae as serviceRestartExecute,re as serviceStartExecute,ie as serviceStatusExecute,se as serviceStopExecute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as T,J as a,b as S,X as y}from"../packem_shared/index.server-BAjDJSEu.js";import{e as V}from"../packem_shared/index-DHD8wb6Z.js";import{enforceProjectConstraints as v}from"@visulima/task-runner";import{d as x,b as J}from"./catalog.js";import{
|
|
1
|
+
import{F as T,J as a,b as S,X as y}from"../packem_shared/index.server-BAjDJSEu.js";import{e as V}from"../packem_shared/index-DHD8wb6Z.js";import{enforceProjectConstraints as v}from"@visulima/task-runner";import{d as x,b as J}from"./catalog.js";import{k as w}from"./cli-main.js";import{c as z}from"../packem_shared/runtime-check-BklgEMkC.js";import{d as D}from"../packem_shared/formatBytes-BHAzNIrn-DFIppnY0.js";import{y as G}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as H}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";const e=c=>c?a("✓"):y("✗"),N=async({fs:c,logger:t,options:b,visConfig:g,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const{config:h,packageJsons:C,workspace:f}=x(n,g),O=J(n,f,C),k=Object.keys(f.projects).length,d=new Set(Object.values(f.projects).flatMap($=>Object.keys($.targets??{}))).size,i=z(n);let s=0;h.constraints&&(s=v(O,h.constraints).length);const o=w(n,{minRuns:2});let r;const l=D(n);if(G(l)){const F=(await c.readdir(l)).filter(u=>u.endsWith(".json")).sort();let p=0,j=0;for(const u of F.slice(-20))try{const m=H(V(l,u));m.stats&&(p+=m.stats.total??0,j+=m.stats.cached??0)}catch{continue}p>0&&(r=`${(j/p*100).toFixed(0)}%`)}if(b.json){t.info(JSON.stringify({cacheHitRate:r??null,constraintViolations:s,flakyTasks:o.length,projects:k,runtimeIssues:i.length,targets:d},null,2));return}t.info(""),t.info(` ${T("VIS STATUS")}`),t.info(""),t.info(` ${e(!0)} ${String(k)} projects · ${String(d)} unique targets`),t.info(` ${e(i.length===0)} Runtime: ${i.length===0?a("OK"):S(`${String(i.length)} issue(s)`)}`),t.info(` ${e(s===0)} Constraints: ${s===0?a("OK"):y(`${String(s)} violation(s)`)}`),t.info(` ${e(o.length===0)} Flaky tasks: ${o.length===0?a("none"):S(String(o.length))}`),r&&t.info(` ${e(!0)} Cache hit rate: ${r} (last 20 runs)`),t.info("")};export{N as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createRequire as u}from"node:module";import{g as m}from"../packem_shared/package-version-
|
|
1
|
+
import{createRequire as u}from"node:module";import{g as m}from"../packem_shared/package-version-CJxZ_B7G.js";let a;const f=t=>(a??=u(import.meta.url))(t),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=t=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,s]=r.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return r.getBuiltinModule(t)}return f(t)},{execSync:l,spawnSync:p}=d("node:child_process"),y=async({argument:t,logger:e,options:s})=>{const o=t?.[0];e.info("info: checking for updates...");const i=m();let n;try{const c=l("npm view @visulima/vis version",{encoding:"utf8"}).trim();n=o??c}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(i===n&&!s.force){e.info(`
|
|
2
2
|
✓ Already up to date (${i})`);return}if(s.check){i===n?e.info(`✓ Already up to date (${i})`):e.info(`info: found @visulima/vis@${n} (current: ${i})`);return}if(e.info(`info: found @visulima/vis@${n} (current: ${i})`),e.info("info: installing..."),p("npm",["install","-g",`@visulima/vis@${n}`],{encoding:"utf8",stdio:"inherit"}).status!==0)throw new Error("Failed to update. Try running with sudo or fix npm permissions.");e.info(`
|
|
3
3
|
✓ Updated @visulima/vis from ${i} → ${n}`)};export{y as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{d as l,b as g}from"./catalog.js";import{V as m}from"../packem_shared/vis-user-error-
|
|
1
|
+
import{d as l,b as g}from"./catalog.js";import{V as m}from"../packem_shared/vis-user-error-Dkc97rGY.js";import{s as j}from"../packem_shared/affected-selection-BMoQWuHl.js";import{f as h,a as k}from"../packem_shared/selectors-B7lSFz7l.js";const P=r=>{const e=r.indexOf("affected",2);return e===-1?[]:r.slice(e+1)},A=async({argument:r,options:e,runtime:u,visConfig:c,workspaceRoot:d})=>{if(!r[0])throw new m("Missing target. Usage: vis affected <target>");if(!d)throw new m("Could not determine workspace root. Run this command inside a monorepo.");if(e.sparseCheckout){const s=d,{packageJsons:i,workspace:t}=l(s,c),p=g(s,t,i),w=await j({base:e.base,downstream:e.downstream,head:e.head,uncommitted:e.uncommitted,upstream:e.upstream},{projectGraph:p,projects:t.projects,workspaceRoot:s},{defaultBase:c?.defaultBase});let o=h(w.affectedProjects,t,e.query);o=k(o,t,e.tag);const n=[...new Set(o.map(f=>t.projects[f]?.root??f))].sort();process.stdout.write(n.length>0?`${n.join(`
|
|
2
2
|
`)}
|
|
3
3
|
`:"");return}const a=P(process.argv);await u.runCommand("run",{argv:a.includes("--affected")?a:[...a,"--affected"]})};export{A as default,P as forwardedArgv};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{F as p}from"../packem_shared/index.server-BAjDJSEu.js";import{e as m,z as k}from"../packem_shared/index-DHD8wb6Z.js";import{a as y,b as h,f as w}from"../packem_shared/subtree-DtmcKAJK.js";import{n as u}from"../packem_shared/utils-DQFHJn72.js";import{v as $,j as x}from"./catalog.js";import{y as A}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{U as b}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{p as E}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{T as l}from"../packem_shared/target-merge-
|
|
1
|
+
import{F as p}from"../packem_shared/index.server-BAjDJSEu.js";import{e as m,z as k}from"../packem_shared/index-DHD8wb6Z.js";import{a as y,b as h,f as w}from"../packem_shared/subtree-DtmcKAJK.js";import{n as u}from"../packem_shared/utils-DQFHJn72.js";import{v as $,j as x}from"./catalog.js";import{y as A}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{U as b}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{p as E}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{T as l}from"../packem_shared/target-merge-B4No-LHM.js";const P=["aube-workspace.yaml","pnpm-workspace.yaml"],v=/^\s*packages\s*:\s*$/,j=/^(\s*)-\s/,I=(c,i)=>{const s=c.includes(`\r
|
|
2
2
|
`)?`\r
|
|
3
3
|
`:`
|
|
4
4
|
`,e=c.split(/\r?\n/),n=e.findIndex(r=>v.test(r));if(n===-1)return;let t=" ";for(let r=n+1;r<e.length;r++){const o=j.exec(e[r]);if(o){t=o[1];break}if(e[r].trim().length>0)break}return e.splice(n+1,0,`${t}- "${i}"`),e.join(s)},R=(c,i,s)=>{const e=m(c,"package.json");let n;try{n=E(e)}catch{return!1}const{workspaces:t}=n;return Array.isArray(t)?t.includes(i)?!1:(s||l(e,{...n,workspaces:[...t,i]},{detectIndent:!0}),!0):t&&typeof t=="object"&&Array.isArray(t.packages)?t.packages.includes(i)?!1:(s||l(e,{...n,workspaces:{...t,packages:[...t.packages,i]}},{detectIndent:!0}),!0):!1},q=({dryRun:c=!1,prefix:i,workspaceRoot:s})=>{const e=u(i),n=$(s);if(!n)return{status:"no-config"};if(x(s,n).some(r=>u(r)===e))return{status:"already-covered"};for(const r of P){const o=m(s,r);if(!A(o))continue;const a=I(k(o),e);if(a!==void 0)return c||b(o,a),{entry:e,file:r,status:"added"}}return R(s,e,c)?{entry:e,file:"package.json",status:"added"}:{status:"no-config"}},z=async({argument:c,fs:i,logger:s,options:e,process:n,workspaceRoot:t})=>{const r=c[0];if(!r)throw new Error("Missing <source>. Pass a git repository URL or local path to import.");if(!e.prefix)throw new Error("Missing --prefix <dir>. Pass the target directory in the monorepo (e.g. packages/tooling/foo).");const o=t??n.cwd,a=u(e.prefix),d=e.ref??"HEAD";if(y(o),await(async f=>{try{return await i.access(f),!0}catch{return!1}})(m(o,a)))throw new Error(`Target "${a}" already exists. git subtree add requires a non-existent prefix.`);if(e.dryRun){const f=e.squash?" --squash":"",g=e.message?` -m "${e.message}"`:"";s.info("Dry run — no changes will be made. Planned steps:"),s.info(` git subtree add --prefix=${a}${f}${g} ${r} ${d}`),e.noRegister||s.info(` register ${a} into the workspace config (skipped if already covered by an existing glob)`);return}if(h(o),s.info(`Importing ${p(r)}@${d} → ${a} ...`),w({cwd:o,message:e.message,prefix:a,ref:d,repo:r,squash:e.squash}),s.info(`✓ Imported ${r} into ${a} (history preserved).`),e.noRegister)s.info(p(`Skipped workspace registration (--no-register). Add ${a} to your workspace config manually.`));else{const f=q({prefix:a,workspaceRoot:o});f.status==="already-covered"?s.info(`✓ ${a} is already covered by an existing workspace glob.`):f.status==="added"?s.info(`✓ Registered ${f.entry} in ${f.file}.`):s.warn(`Could not auto-register ${a}: no workspace config found. Add it to pnpm-workspace.yaml or package.json#workspaces manually.`)}s.info(p("Note: project.json / nx tags are not generated. Add them if your tooling needs them."))};export{z as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as I}from"../packem_shared/index-DHD8wb6Z.js";import{d as
|
|
1
|
+
import{a as I}from"../packem_shared/index-DHD8wb6Z.js";import{d as v}from"./catalog.js";import{f as D,a as x}from"../packem_shared/selectors-B7lSFz7l.js";import E from"./index.js";import{w as J}from"./cli-main.js";const S=(e,t)=>{for(const l of t)if(E(l,e))return!0;return!1},q=(e,t={})=>{const{depTypes:l,excludePatterns:f,externalOnly:h,includePatterns:m,internalOnly:g}=t;if(g&&h)return[];const d=l&&l.length>0?new Set(l):void 0,k=m&&m.length>0?m:void 0,w=f&&f.length>0?f:void 0,N=[];for(const y of e)g&&!y.isInternal||h&&y.isInternal||d&&!d.has(y.depType)||k&&(!y.packageName||!S(y.packageName,k))||w&&y.packageName&&S(y.packageName,w)||N.push(y);return N},C=new Set(["json","ndjson","table"]),M=e=>{if(e===void 0)return"table";const t=e.toLowerCase();if(!C.has(t))throw new Error(`--format must be one of: table, json, ndjson (got "${e}")`);return t},P=(e,t)=>({depName:e.depName,depType:e.depType,isInternal:e.isInternal,packageDir:e.packageDir,packageJsonPath:I(t,e.packageJsonPath),packageName:e.packageName,specifier:e.specifier}),$=new Set(["dependencies","devDependencies","optionalDependencies","overrides","peerDependencies","pnpm.overrides","resolutions"]),A=e=>{if(!e||e.length===0)return;const t=[],l=[];for(const f of e)for(const h of f.split(",")){const m=h.trim();m&&($.has(m)?t.push(m):l.push(m))}if(l.length>0)throw new Error(`Unknown --dep-type value(s): ${l.join(", ")}. Valid: ${[...$].join(", ")}`);return t.length>0?t:void 0},V=async({logger:e,options:t,visConfig:l,workspaceRoot:f})=>{if(!f)throw new Error("Could not determine workspace root.");const h=M(t.format);if(t.deps===!0){if(t.internalOnly&&t.externalOnly)throw new Error("--internal-only and --external-only are mutually exclusive");const p=A(t.depType),c=J(f);let r=q(c,{depTypes:p,excludePatterns:t.exclude,externalOnly:t.externalOnly,includePatterns:t.include,internalOnly:t.internalOnly});if(t.query||t.tag&&t.tag.length>0){const{workspace:n}=v(f,l),i=D(Object.keys(n.projects),n,t.query),T=new Set(x(i,n,t.tag));r=r.filter(O=>O.packageName!==void 0&&T.has(O.packageName))}const u=[...r].sort((n,i)=>{const T=`${n.packageName??n.packageDir} ${n.depType} ${n.depName}`,O=`${i.packageName??i.packageDir} ${i.depType} ${i.depName}`;return T.localeCompare(O)});if(h==="ndjson"){for(const n of u)e.info(JSON.stringify(P(n,f)));return}if(h==="json"){const n=u.map(i=>P(i,f));e.info(JSON.stringify(n,null,t.pretty===!0?2:void 0));return}if(u.length===0){e.info("No matching dep-instances.");return}const o=["Package","Block","Dep","Specifier","Internal","Path"],a=u.map(n=>[n.packageName??n.packageDir,n.depType,n.depName,n.specifier,n.isInternal?"yes":"no",I(f,n.packageJsonPath)]),s=o.map((n,i)=>Math.max(n.length,...a.map(T=>(T[i]??"").length))),j=(n,i)=>n.padEnd(i);e.info(o.map((n,i)=>j(n,s[i])).join(" ")),e.info(s.map(n=>"─".repeat(n)).join("──"));for(const n of a)e.info(n.map((i,T)=>j(i,s[T])).join(" "));e.info(""),e.info(`${String(u.length)} dep-instance(s)`);return}if(h==="ndjson")throw new Error("--format=ndjson is only supported with --deps");const{projectOptions:m,workspace:g}=v(f,l);let d=Object.keys(g.projects).sort();if(t.query&&(d=D(d,g,t.query)),d=x(d,g,t.tag),d.length===0){e.info("No projects found.");return}const k=t.inferred===!0,w=t.targets===!0||k;if(h==="json"){const p=d.map(c=>{const r=g.projects[c],u=m.get(c)??{},o=Object.entries(r.targets??{}).map(([a])=>{const s=u[a],j=s?.inferred===!0;return{aliases:s?.aliases??[],command:s?.command,description:s?.description,...j?{inferred:!0}:{},name:a,type:s?.type}}).filter(a=>!k||a.inferred===!0);return{language:r.language,layer:r.layer,name:c,root:r.root,stack:r.stack,tags:r.tags??[],targets:o,type:r.projectType??"library"}});e.info(JSON.stringify(p,null,2));return}const N=(p,c)=>{const r=p.map((o,a)=>{let s=0;for(const j of c)s=Math.max(s,(j[a]??"").length);return Math.max(o.length,s)}),u=(o,a)=>o.padEnd(a);e.info(p.map((o,a)=>u(o,r[a])).join(" ")),e.info(r.map(o=>"─".repeat(o)).join("──"));for(const o of c)e.info(o.map((a,s)=>u(a,r[s])).join(" "))};if(w){const p=[];for(const c of d){const r=g.projects[c],u=m.get(c)??{};for(const o of Object.keys(r.targets??{}).sort()){const a=u[o],s=a?.inferred===!0;if(k&&!s)continue;const j=r.targets?.[o],n=j?.cache===!1?"no":j?.cache===!0?"yes":"default";p.push([c,o,a?.type??"—",n,s?"yes":"no",a?.description??"—"])}}if(p.length===0){e.info(k?"No inferred targets found.":"No targets found.");return}N(["Project","Target","Type","Cache","Inferred","Description"],p),e.info(""),e.info(`${String(p.length)} target(s) across ${String(d.length)} project(s)`);return}const y=["Project","Type","Layer","Tags","Targets"],b=d.map(p=>{const c=g.projects[p],r=Object.keys(c.targets??{});return[p,c.projectType??"library",c.layer??"—",(c.tags??[]).join(", ")||"—",r.length>4?`${r.slice(0,4).join(", ")}… (${String(r.length)})`:r.join(", ")||"—"]});N(y,b),e.info(""),e.info(`${String(d.length)} project(s)`)};export{V as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as G}from"node:module";import{
|
|
1
|
+
import{createRequire as G}from"node:module";import{z as N,A as q,B as z,C as f,D as J,E as W,F as Y,G as H,H as V,I as Q,J as U,K as X,L as Z,M as tt,N as nt,P as et,Q as P,R as st}from"./cli-main.js";import{e as p,z as j,l as rt,$ as ct}from"../packem_shared/index-DHD8wb6Z.js";import{loadVisConfig as at}from"./CONFIG_FILES.js";import{y as x}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{U as O}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{L as dt}from"./catalog.js";import{v as pt}from"../packem_shared/verify-D8wYvB85.js";let K;const L=t=>(K??=G(import.meta.url))(t),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,B=t=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[n,s]=E.versions.node.split(".").map(Number);if(n>22||n===22&&s>=3||n===20&&s>=16)return E.getBuiltinModule(t)}return L(t)},{readdirSync:it,statSync:ot}=B("node:fs"),{stdin:T,stdout:ut}=E,{createInterface:ft}=B("node:readline/promises"),k="__global__",b=t=>[...new Set(t)].sort((n,s)=>n.localeCompare(s)),mt=t=>`{${Object.keys(t).sort().map(i=>`${i}=${JSON.stringify(t[i])}`).join(",")}}`,h=t=>{if(!Array.isArray(t))return[];const n=[];for(const s of t)typeof s=="string"?n.push(s):s&&typeof s=="object"&&n.push(mt(s));return b(n)},v=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),g=(t,n,s)=>s?`^${n}`:t&&t!=="self"&&t!=="~"?`${t}#${n}`:n,lt=(t,n)=>{const s=t.trim();if(n==="moon"){if(s.startsWith("^:"))return g(void 0,s.slice(2),!0);if(s.startsWith("~:"))return g(void 0,s.slice(2),!1);if(s.includes(":")){const[i,e]=s.split(":");return g(i,e??"",!1)}return s}if(s.startsWith("^"))return g(void 0,s.slice(1),!0);if(s.includes("#")){const[i,e]=s.split("#");return g(i,e??"",!1)}return s},R=(t,n)=>{if(!Array.isArray(t))return[];const s=[];for(const i of t){if(typeof i=="string"){s.push(lt(i,n));continue}if(!i||typeof i!="object")continue;const e=i,{target:o}=e;if(!o)continue;if(e.dependencies===!0){s.push(g(void 0,o,!0));continue}if(e.projects===void 0){s.push(g(void 0,o,!1));continue}const r=Array.isArray(e.projects)?e.projects:[e.projects];for(const a of r)s.push(a==="^"?g(void 0,o,!0):g(a,o,!1))}return b(s)},M=t=>{if(x(t))try{return JSON.parse(j(t))}catch{return}},yt=t=>{const n=new Map,s=M(p(t,"turbo.json"));if(!s)return n;const i=s.tasks??s.pipeline??{};for(const[o,r]of Object.entries(i)){const a=o.includes("#")?o:`*#${o}`,c=v(a);c.dependsOn=R(r.dependsOn,"turbo"),c.inputs=h(r.inputs),c.outputs=h(r.outputs),c.env=b([...r.env??[],...r.passThroughEnv??[]]),c.cache=r.cache===!1?!1:void 0,n.set(a,c)}const e=v(k);return e.inputs=h(s.globalDependencies),e.env=b([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&n.set(k,e),n},ht=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),C=(t,n,s=8)=>{const i=[],e=(o,r)=>{if(r>s)return;let a;try{a=it(o)}catch{return}for(const c of a.toSorted()){if(c===n){i.push(p(o,c));continue}if(c.startsWith(".")&&c!==".moon"||ht.has(c))continue;const u=p(o,c);try{ot(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),i},I=(t,n)=>{t.dependsOn=R(n.dependsOn,"nx"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.cache=typeof n.cache=="boolean"?n.cache:void 0},gt=t=>{const n=new Map,s=M(p(t,"nx.json"));for(const[i,e]of Object.entries(s?.targetDefaults??{})){const o=`*#${i}`,r=v(o);I(r,e),n.set(o,r)}for(const i of C(t,"project.json")){const e=M(i);if(!(!e?.name||!e.targets))for(const[o,r]of Object.entries(e.targets)){const a=`${e.name}#${o}`,c=v(a);I(c,r),n.set(a,c)}}return n},_=(t,n)=>{t.dependsOn=R(n.deps,"moon"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.cache=typeof n.options?.cache=="boolean"?n.options.cache:void 0},A=t=>{if(x(t))try{return rt(t)}catch{return}},vt=t=>{const n=new Map,s=p(t,".moon"),i=[p(s,"tasks.yml"),p(s,"tasks.yaml")];for(const e of i){const o=A(e);if(o){for(const[r,a]of Object.entries(o.tasks??{})){const c=`*#${r}`,u=v(c);_(u,a),n.set(c,u)}if(o.implicitInputs&&o.implicitInputs.length>0){const r=v(k);r.inputs=h(o.implicitInputs),n.set(k,r)}}}for(const e of[...C(t,"moon.yml"),...C(t,"moon.yaml")]){const o=A(e);if(!o?.tasks)continue;const a=e.split(/[/\\]/).at(-2)??"*";for(const[c,u]of Object.entries(o.tasks)){const w=`${a}#${c}`,d=v(w);_(d,u),n.set(w,d)}}return n},xt=(t,n)=>{t.dependsOn=R(n.dependsOn,"vis"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.env=b([...n.env??[],...n.passThroughEnv??[],...n.options?.passThroughEnv??[]]),t.cache=n.cache===!1?!1:typeof n.cache=="boolean"?n.cache:void 0},kt=async t=>{const n=new Map,s=await at(t);for(const[o,r]of Object.entries(s.tasks??{})){const a=`*#${o}`,c=v(a);xt(c,r??{}),n.set(a,c)}const i=s.taskRunner??{},e=v(k);return e.inputs=h(i.globalInputs),e.env=b([...i.globalEnv??[],...i.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&n.set(k,e),n},bt=(t,n)=>{switch(n){case"moon":return vt(t);case"nx":return gt(t);default:return yt(t)}},wt=t=>{const n=[];return x(p(t,"turbo.json"))&&n.push("turbo"),x(p(t,"nx.json"))&&n.push("nx"),(x(p(t,".moon","tasks.yml"))||x(p(t,".moon","tasks.yaml")))&&n.push("moon"),n.length===1?n[0]:void 0},S=(t,n,s,i,e)=>{const o=i.filter(c=>!e.includes(c)),r=e.filter(c=>!i.includes(c));if(o.length===0&&r.length===0)return;const a=[];o.length>0&&a.push(`dropped [${o.join(", ")}]`),r.length>0&&a.push(`added [${r.join(", ")}]`),t.push({axis:s,detail:`${s} diverged: ${a.join("; ")}`,node:n,severity:o.length>0?"error":"warning"})},Et=(t,n,s)=>{const i=[],e=b([...t.keys(),...n.keys()]);for(const o of e){const r=t.get(o),a=n.get(o);if(r&&!a){const c=s==="turbo"&&o.includes("#")&&!o.startsWith("*#")&&o!==k;i.push({axis:"target-set",detail:c?`source target \`${o}\` was skipped by design (turbo project#task is migrated into per-project project.json — move it there and re-verify)`:`source target \`${o}\` has no equivalent in the migrated vis config`,node:o,severity:c?"warning":"error"});continue}if(!r&&a){i.push({axis:"target-set",detail:`migrated vis config defines \`${o}\` with no source equivalent (extra target — not a regression, but review)`,node:o,severity:"warning"});continue}!r||!a||(S(i,o,"dependsOn",r.dependsOn,a.dependsOn),S(i,o,"inputs",r.inputs,a.inputs),S(i,o,"outputs",r.outputs,a.outputs),S(i,o,"env",r.env,a.env),r.cache!==void 0&&a.cache!==void 0&&r.cache!==a.cache&&i.push({axis:"cache",detail:`cache flag diverged: source=${String(r.cache)} vis=${String(a.cache)} (changes what invalidates the cache)`,node:o,severity:"error"}))}return i.sort((o,r)=>o.node.localeCompare(r.node)||o.axis.localeCompare(r.axis)),{findings:i,source:s,sourceNodeCount:t.size,visNodeCount:n.size}},$t=new Set(["json","ndjson","table"]),St=t=>({equivalent:t.findings.every(n=>n.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),Rt=(t,n,s)=>{if(n==="json"){process.stdout.write(`${JSON.stringify(St(t),void 0,2)}
|
|
2
2
|
`);return}if(n==="ndjson"){for(const i of t.findings)process.stdout.write(`${JSON.stringify(i)}
|
|
3
3
|
`);return}if(s.info(`Migration equivalence: ${t.source} → vis`),s.info(` source nodes: ${String(t.sourceNodeCount)} vis nodes: ${String(t.visNodeCount)}`),t.findings.length===0){s.info(" ✓ task graph + cache-key surface preserved (no divergence).");return}for(const i of t.findings){const e=` [${i.severity}] ${i.node} (${i.axis}) — ${i.detail}`;i.severity==="error"?s.warn(e):s.info(e)}},jt=(t,n)=>t.findings.some(i=>n==="warning"?!0:i.severity==="error")?1:0,F=async t=>{if(!T.isTTY)return!0;const n=ft({input:T,output:ut});try{const i=(await n.question(`${t} [Y/n] `)).trim().toLowerCase();return i===""||i==="y"||i==="yes"}finally{n.close()}},Mt=[{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"}],Ct=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],Nt=t=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${t}\2(\s*:)`,"gmu"),Tt=(t,n)=>{let s=t;const i=[];for(const e of n){const o=Nt(e.previous);o.test(s)&&(o.lastIndex=0,s=s.replace(o,(r,a,c,u)=>`${a}${c}${e.next}${c}${u}`),i.push(e))}return{applied:i,output:s}},D=(t,n)=>Tt(t,n),Ot=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],It=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),_t=t=>{for(const n of Ot){const s=p(t,n);if(x(s))return s}},At=t=>{const n=[];try{for(const s of dt(t,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))It.has(ct(s.path))&&n.push(s.path)}catch{}return n},Dt=(t,n,s,i)=>{const e=_t(t);if(e){const r=j(e),{applied:a,output:c}=D(r,Mt);if(a.length===0)s.info(`${e} already uses the current schema — no rewrite needed.`);else if(n.dryRun)s.info(`── ${e} (preview) ──`),s.info(c),s.info("── end preview ──"),s.info(`Would apply ${String(a.length)} rename(s): ${a.map(u=>u.description).join(", ")}`);else{N(e,i),O(e,c),s.info(`Rewrote ${e} (backup at ${e}.bak). Applied ${String(a.length)} rename(s).`);for(const u of a)i.manualSteps.push(`Renamed ${u.description} in ${e}`)}}else s.warn("No vis.config.ts found at workspace root — nothing to migrate."),i.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const o=n.taskConfigPaths??At(t);for(const r of o){if(!x(r))continue;const a=j(r),c=D(a,Ct);if(c.applied.length!==0)if(n.dryRun)s.info(`── ${r} (preview) ──`),s.info(c.output),s.info("── end preview ──"),s.info(`Would apply ${String(c.applied.length)} rename(s): ${c.applied.map(u=>u.description).join(", ")}`);else{N(r,i),O(r,c.output),s.info(`Rewrote ${r} (backup at ${r}.bak). Applied ${String(c.applied.length)} rename(s).`);for(const u of c.applied)i.manualSteps.push(`Renamed ${u.description} in ${r}`)}}},m=t=>{const n=t.workspaceRoot??process.cwd(),s=t.visConfig??{};return{config:s,dryRun:!!t.options.dryRun,logger:t.logger,packageManager:st(n),report:P(),root:n,useEditorconfig:typeof s.editorconfig=="boolean"?s.editorconfig:!0}},l=async(t,n,s)=>{if(n.yes||n.dryRun)return!0;const i=await F(`This will edit files, scripts, and hooks for "${t}". Backups (.bak) will be created. Continue?`);return i||s.info("Aborted."),i},y=t=>{t.dryRun&&t.logger.info(`Running in dry-run mode — no changes will be made.
|
|
4
4
|
`)},Bt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("deps",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating dependencies and scripts ──"),J(e.root,e.packageManager,e.config,{dryRun:e.dryRun},t,e.report),t.info(""),f(e.report,t)},Vt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("lint-staged",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating lint-staged ──"),W(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Pt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("nano-staged",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating nano-staged ──"),Y(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Ft=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("turborepo",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating turborepo ──"),H(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),V(e.root,{dryRun:e.dryRun},t),t.info(""),f(e.report,t)},Gt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("nx",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating nx ──");const o=!!n.aggressive;Q(e.root,{aggressive:o,dryRun:e.dryRun,force:o||!!n.force,rewriteSyncGenerators:o||!!n.rewriteSyncGenerators,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Kt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("moon",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating moon ──"),U(e.root,{copyTemplates:!!n.copyTemplates,dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),V(e.root,{dryRun:e.dryRun},t),t.info(""),f(e.report,t)},Lt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("gitleaks",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating gitleaks ──"),X(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},qt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("kingfisher",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating Kingfisher ──"),Z(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},zt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("secretlint",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating secretlint ──"),tt(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Jt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("syncpack",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating syncpack ──"),nt(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Wt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("sherif",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating sherif ──"),et(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Yt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("self",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating vis.config.ts to current schema ──"),Dt(e.root,{dryRun:e.dryRun},t,e.report),t.info(""),f(e.report,t)},Ht=({logger:t,workspaceRoot:n})=>{const s=n??process.cwd();pt(s,t).length>0&&(process.exitCode=1)},Qt=async({logger:t,options:n,workspaceRoot:s})=>{const i=s??process.cwd(),e=n.format??"table";if(!$t.has(e)){t.warn(`Invalid --format: ${String(n.format)}. Expected table | json | ndjson.`),process.exitCode=1;return}const o=n.failOn==="warning"?"warning":"error";let r;if(n.from){if(n.from!=="turbo"&&n.from!=="nx"&&n.from!=="moon"){t.warn(`Invalid --from: ${n.from}. Expected turbo | nx | moon.`),process.exitCode=1;return}r=n.from}else if(r=wt(i),!r){t.warn("Could not auto-detect the source tool (need exactly one of turbo.json / nx.json / .moon/tasks.yml). Pass --from <turbo|nx|moon>."),process.exitCode=1;return}const a=bt(i,r);if(a.size===0){t.warn(`No ${r} task graph found at ${i} — nothing to verify.`),process.exitCode=1;return}const c=await kt(i);if(c.size===0){t.warn("No migrated vis task graph found (vis.config.ts has no tasks). Run the migrator first."),process.exitCode=1;return}const u=Et(a,c,r);Rt(u,e,t),process.exitCode=jt(u,o)},Ut=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{const e=i??process.cwd(),r=q(e,s??{}),a=z(r);if(a.length===0){t.info("No applicable migrations detected in this workspace.");return}const c=!!n.dryRun;t.info(`Detected ${String(a.length)} migration(s):`);for(const d of a)t.info(` • ${d.title} — ${d.description}`);if(t.info(""),!n.yes&&!c&&!await F("Apply all detected migrations? Backups (.bak) will be created.")){t.info("Aborted.");return}c&&t.info(`Running in dry-run mode — no changes will be made.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{a as J,b as q,p,O as G,c as T,
|
|
2
|
-
Settings that would sync to pnpm-workspace.yaml:`);for(const
|
|
3
|
-
`);const v=new Set;T("socket")&&v.add("socket"),T("depsDev")&&v.add("deps-dev");const g=o?.security?.policies?.score?.minimum,M=Q(o?.security,{disabled:v,minimumScore:g}),{failed:S,outdated:n}=await W(h,I,D,U,d,M,o?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),S.length>0&&s.warn(`Failed to fetch: ${S.join(", ")}`),n.length===0){s.info("All catalog dependencies are up to date.");return}const
|
|
1
|
+
import{a as J,b as q,p,O as G,c as T,d as O}from"./cli-main.js";import{l as H,r as K,t as m,c as Q,k as W,R as c,E as X,m as y,n as P,o as Z,s as _}from"./catalog.js";import{i as ee}from"../packem_shared/index-BjdW45xX.js";import{v as te,r as se,f as ae}from"../packem_shared/ai-analysis-DSQQDFU9.js";import{d as re}from"../packem_shared/pm-runner-de-jCq8q.js";import{s as ne}from"../packem_shared/formatBytes-BHAzNIrn-DFIppnY0.js";import{U as oe,V as ce,C as j}from"../packem_shared/vis-update-app-zqSa2clT.js";const he=async({argument:$,logger:s,options:e,visConfig:o,workspaceRoot:x})=>{if(!x)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=x;if(e.securityConfig){const t=re(d);if(J(o??{},t.name),e.sync&&t.name==="pnpm"){const a=q(o??{});if(a.length>0){p.info(`
|
|
2
|
+
Settings that would sync to pnpm-workspace.yaml:`);for(const R of a)p.success(` ${R}`)}else p.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(p.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),p.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!$?.length)return}const{packageManager:N}=G(d),D=H(d),i=o?.update??{},h=K(d,N,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(h.size===0){s.info("No catalogs found.");return}const k=e.target??i.target??"latest";if(!["latest","minor","patch"].includes(k))throw new Error(`Invalid target "${k}". Use: latest, minor, or patch.`);const I={exclude:[...m(e.exclude),...m(i.exclude)],ignore:m(i.ignore),include:[...m(e.include),...m(i.include),...$],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||i.prerelease||!1,security:e.security!==!1,target:k};let C=0;for(const t of h.values())C+=t.size;const w=!!process.stdout.isTTY&&!ee;let l;const U=w?(t,a)=>{l?l.rerender(c.createElement(j,{current:t,total:a})):l=O(c.createElement(j,{current:t,total:a}),{interactive:!0,patchConsole:!1})}:(t,a)=>{s.info(`Checking ${String(t)}/${String(a)} dependencies...`)};w||s.info(`Checking ${String(C)} catalog dependencies against npm registry...
|
|
3
|
+
`);const v=new Set;T("socket")&&v.add("socket"),T("depsDev")&&v.add("deps-dev");const g=o?.security?.policies?.score?.minimum,M=Q(o?.security,{disabled:v,minimumScore:g}),{failed:S,outdated:n}=await W(h,I,D,U,d,M,o?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),S.length>0&&s.warn(`Failed to fetch: ${S.join(", ")}`),n.length===0){s.info("All catalog dependencies are up to date.");return}const E=e.format??i.format??"table",B=te(e.aiType??"impact"),u=e.ai?await se(n,s,o?.ai,B):void 0;if(w&&E==="table"){const t=new oe(n,u??null),a=o?.tui?.autoExit??!1,R=a===!0?3:typeof a=="number"?a:0;await O(c.createElement(ce,{autoExitSeconds:R,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const Y=process.stdout.columns||80;process.stdout.write(`
|
|
4
4
|
`);for(const r of n){const z=r.vulnerabilities?.length||r.socketReport&&r.socketReport.alerts.length>0,b=!!r.acceptedRisk,F=z?b?"✓":"⚠":"✓",L=b?"gray":r.updateType==="major"?"red":r.updateType==="minor"?"yellow":"green",f=r.socketReport?.score.overall,V=f===void 0?"":` [${String(Math.round(f*100))}%]`,A=f===void 0?void 0:ne(f);process.stdout.write(`${X(c.createElement(y,null," ",c.createElement(y,{color:L},F),` ${r.packageName} ${r.currentRange} → ${r.newRange}`,c.createElement(y,{dimColor:!0},` ${r.updateType}`),A?c.createElement(y,{color:A},V):null),{columns:Y})}
|
|
5
5
|
`)}process.stdout.write(`
|
|
6
|
-
`),s.info(P(n,g))}else if(
|
|
7
|
-
`)}else
|
|
6
|
+
`),s.info(P(n,g))}else if(E==="json"){const t={failed:S,outdated:n};u&&(t.aiAnalysis=u),process.stdout.write(`${JSON.stringify(t,void 0,2)}
|
|
7
|
+
`)}else E==="minimal"?process.stdout.write(`${Z(n)}
|
|
8
8
|
`):(_(n,s),s.info(P(n,g)),u&&(s.info(""),s.info(ae(u))));e.exitCode&&n.length>0&&(process.exitCode=1)};export{he as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z as A,m as G,a as I,e as b}from"../packem_shared/index-DHD8wb6Z.js";import x from"./index.js";import{d as U,x as F}from"./catalog.js";import{n as B}from"../packem_shared/manifests-BNSmpPF_.js";import{_ as E,$ as J}from"./cli-main.js";import{l as K}from"../packem_shared/glob-Cyk1H9ZL-ox19CSsT.js";import{U as R,h as q}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{T as M}from"../packem_shared/target-merge-
|
|
1
|
+
import{z as A,m as G,a as I,e as b}from"../packem_shared/index-DHD8wb6Z.js";import x from"./index.js";import{d as U,x as F}from"./catalog.js";import{n as B}from"../packem_shared/manifests-BNSmpPF_.js";import{_ as E,$ as J}from"./cli-main.js";import{l as K}from"../packem_shared/glob-Cyk1H9ZL-ox19CSsT.js";import{U as R,h as q}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{T as M}from"../packem_shared/target-merge-B4No-LHM.js";const H=(e,t)=>{const n=t.replace(/^\.?\//,"");return n===""||n==="."?`/${e}/`:e===""||e==="."?`/${n}`:`/${e}/${n}`},N=(e,t,n=[])=>{const s=[],o=new Set;for(const[c,r]of Object.entries(t?.globalPaths??{}))s.push({owners:r,path:c,source:"project-json"}),o.add(c);for(const[c,r]of Object.entries(e.projects)){const a=r.owners??[];for(const f of a){const l=H(r.root??c,f.path);s.push({channel:f.channel,owners:f.owners,path:l,projectId:c,source:"project-json"}),o.add(l)}}for(const c of n)o.has(c.path)||(s.push(c),o.add(c.path));return(t?.orderBy??"file-source")==="project-id"?s.sort((c,r)=>(c.projectId??"").localeCompare(r.projectId??"")||c.path.localeCompare(r.path)):s.sort((c,r)=>c.path.localeCompare(r.path)),s},z="Update each project's project.json `owners` field and re-run the command.",Y=e=>["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.",e?`# Re-run with: ${e}`:`# ${z}`,""],D=e=>{const t=[];for(const n of e){const s=n.owners.join(" "),o=n.channel?` # notify: ${n.channel}`:"";t.push(`${n.path} ${s}${o}`)}return t},Q=(e,t={})=>[...Y(t.regenerationCommand),...D(e),""].join(`
|
|
2
2
|
`),O={begin:"# BEGIN vis-codeowners",end:"# END vis-codeowners"},X=(e,t=O,n={})=>{const s=n.regenerationCommand?`# Generated by vis sync codeowners — re-run with: ${n.regenerationCommand}`:"# Generated by `vis sync codeowners` — do not edit by hand.";return[t.begin,s,...D(e),t.end].join(`
|
|
3
3
|
`)},Z=(e,t,n=O)=>{const s=e.indexOf(n.begin),o=e.indexOf(n.end);if(s!==-1&&o!==-1&&o>s){const r=e.slice(0,s),a=o+n.end.length,f=e.slice(a);return`${r}${t}${f}`}const i=e.replace(/\s+$/u,"");return`${i.length===0?"":`${i}
|
|
4
4
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{a as B,z as J,e as C,$ as K,U as Y}from"../packem_shared/index-DHD8wb6Z.js";import{U as q,V,W as z,T as Z,u as Q,p as E,C as ee}from"./cli-main.js";import{i as re}from"../packem_shared/index-BjdW45xX.js";import{y as t,X as f,m as a,u as R,R as te,v as se,A as ne,B as oe,C as ie,i as ce,j as A}from"./catalog.js";import le from"./index.js";import{sortPackageJsonStringWithOptions as U}from"#native";import{e as I}from"../packem_shared/utils-DQFHJn72.js";import{y as L}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";const _={error:0,rewritten:1,"would-rewrite":1,unchanged:2},ae=e=>[...e].sort((r,s)=>_[r.status]-_[s.status]),de=(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");class fe{#e;#r=new Set;constructor(r){this.#e={entries:ae(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>de(this.#e.entries,this.#e.filterType);#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()}}const ue=({checkMode:e,entry:r,focused:s,scrollRef:c})=>{const o=s?"white":"gray";return r?t.jsxs(f,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(f,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.relativePath})}),t.jsxs(q,{flexGrow:1,flexShrink:1,paddingX:2,ref:c,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(f,{children:[t.jsx(f,{width:10,children:t.jsx(a,{dimColor:!0,children:"Status:"})}),r.status==="error"?t.jsx(a,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?t.jsx(a,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?t.jsx(a,{bold:!0,color:"yellow",children:"rewritten"}):t.jsx(a,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),t.jsxs(f,{children:[t.jsx(f,{width:10,children:t.jsx(a,{dimColor:!0,children:"Path:"})}),t.jsx(a,{children:r.filePath})]}),r.error?t.jsxs(t.Fragment,{children:[t.jsxs(f,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"red",children:"ERROR"}),t.jsxs(f,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(f,{children:[t.jsx(f,{width:10,children:t.jsx(a,{dimColor:!0,children:"Step:"})}),t.jsx(a,{color:"yellow",children:r.error.step})]}),r.error.context&&t.jsxs(f,{children:[t.jsx(f,{width:10,children:t.jsx(a,{dimColor:!0,children:"Position:"})}),t.jsx(a,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),t.jsx(f,{marginTop:1,children:t.jsx(a,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&t.jsxs(f,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"SNIPPET"}),t.jsxs(f,{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(f,{children:[t.jsx(a,{color:n.isErrorLine?"red":"gray",children:i}),t.jsx(a,{color:n.isErrorLine?"white":"gray",wrap:"truncate-end",children:n.content||" "})]},n.lineNumber)}),r.error.context.column>0&&t.jsx(f,{children:t.jsx(a,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):t.jsxs(f,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"KEY DIFF"}),t.jsx(f,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?t.jsx(a,{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)}`,u=i<0?"green":"yellow";return t.jsxs(f,{children:[t.jsx(f,{width:28,children:t.jsx(a,{wrap:"truncate",children:n.key})}),t.jsx(f,{width:10,children:t.jsxs(a,{dimColor:!0,children:[String(n.fromIndex)," → ",String(n.toIndex)]})}),t.jsx(a,{color:u,children:d})]},n.key)})}),e&&r.status==="would-rewrite"&&t.jsx(f,{marginTop:1,paddingLeft:2,children:t.jsx(a,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):t.jsx(f,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(a,{dimColor:!0,children:"No entry selected"})})},he={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},ge={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},W={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},xe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},pe=[{count:e=>e.errors+e.rewrites+e.sorted,key:"all",label:"All",shortcut:"1"},{count:e=>e.rewrites,key:"rewritten",label:"Rewrites",shortcut:"2"},{count:e=>e.errors,key:"errors",label:"Errors",shortcut:"3"},{count:e=>e.sorted,key:"unchanged",label:"Sorted",shortcut:"4"}],X=e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[W[s.status]]++;return r},me=({entry:e,isSelected:r})=>{const s=he[e.status],c=ge[e.status];return t.jsxs(f,{flexShrink:0,height:1,children:[t.jsx(a,{children:r?">":" "}),t.jsx(a,{children:" "}),t.jsx(a,{bold:!0,color:s,children:`[${c}]`.padEnd(10)}),t.jsx(a,{children:" "}),t.jsx(f,{flexGrow:1,children:t.jsx(a,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&t.jsx(a,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},je=({color:e,count:r,label:s})=>t.jsx(f,{flexShrink:0,height:1,children:t.jsx(a,{bold:!0,color:e,children:`${s} (${String(r)})`})}),Se=({counts:e,entries:r,filterType:s,focused:c,selectedIndex:o,totalEntries:n,viewportHeight:i})=>{const d=c?"white":"gray",u=X(r),x=(u.errors>0?1:0)+(u.rewrites>0?1:0)+(u.sorted>0?1:0),m=s==="all"&&x>1,h=[];let j;for(const[l,g]of r.entries()){const k=W[g.status];m&&k!==j&&(j!==void 0&&h.push({kind:"spacer"}),h.push({color:k==="errors"?"red":k==="rewrites"?"yellow":"green",count:u[k],kind:"header",label:xe[k]}),j=k),h.push({entry:g,entryIndex:l,kind:"entry"})}const p=h.findIndex(l=>l.kind==="entry"&&l.entryIndex===o),y=p!==-1,S=h.length,w=Math.max(0,S-i);let b=0;y&&i>0&&(b=Math.min(w,Math.max(0,p-i+1)));const O=S>i&&i>0;return t.jsxs(f,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(f,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(a,{bold:!0,inverse:!0,children:" VIS SORT "}),t.jsxs(a,{wrap:"truncate",children:[n," ","file",n===1?"":"s"]})]}),t.jsx(f,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pe.map(l=>{const g=s===l.key,k=l.count(e);return t.jsxs(f,{children:[t.jsx(a,{dimColor:!g,children:"["}),t.jsx(a,{bold:g,color:g?"cyan":"gray",children:l.shortcut}),t.jsx(a,{dimColor:!g,children:"]"}),t.jsxs(a,{color:g?"white":"gray",children:[" ",l.label]}),t.jsxs(a,{dimColor:!0,children:[" ","(",k,")"]})]},l.key)})}),t.jsxs(f,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(f,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(f,{flexDirection:"column",marginTop:-b,children:h.map((l,g)=>l.kind==="spacer"?t.jsx(f,{flexShrink:0,height:1},`s-${String(g)}`):l.kind==="header"?t.jsx(je,{color:l.color,count:l.count,label:l.label},`h-${l.label}`):t.jsx(me,{entry:l.entry,isSelected:l.entryIndex===o},l.entry.filePath))})}),O&&t.jsx(f,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(V,{contentHeight:S,placement:"inset",scrollOffset:b,style:"block",viewportHeight:i})})]})]})},we=100,D=10,ye=6,ke=1,M={1:"all",2:"rewritten",3:"errors",4:"unchanged"},Ee=({checkMode:e,store:r})=>{const{exit:s}=z(),{columns:c,rows:o}=Z(),n=R.useSyncExternalStore(r.subscribe,r.getSnapshot),i=R.useRef(null),d=r.getFilteredEntries(),u=d[n.selectedIndex]??null,x=X(n.entries),m=c>=we,h=Math.max(0,o-ke),j=m?h:Math.floor(h/2),p=Math.max(0,j-ye),y=R.useCallback(()=>{s()},[s]),S=R.useRef(0),w=R.useRef(void 0),b=R.useRef(!1),O=R.useCallback((l,g)=>{S.current+=g,w.current=l,!b.current&&(b.current=!0,queueMicrotask(()=>{b.current=!1;const k=S.current,N=w.current;S.current=0,w.current=void 0,!(k===0||N===void 0)&&(N==="list"?r.selectStep(Math.sign(k)):i.current?.scrollBy(Math.sign(k)))}))},[r]);return Q((l,g)=>{if(l==="q"||g.escape){y();return}if(M[l]){r.setFilter(M[l]);return}if(g.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}n.focusedPanel==="list"?g.upArrow||l==="k"?O("list",-1):(g.downArrow||l==="j")&&O("list",1):n.focusedPanel==="detail"&&(g.upArrow||l==="k"?O("detail",-1):(g.downArrow||l==="j")&&O("detail",1))}),o<D?t.jsx(f,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",D," ","rows."]})}):t.jsxs(f,{flexDirection:"column",height:o,width:c,children:[t.jsxs(f,{flexDirection:m?"row":"column",flexGrow:1,children:[t.jsx(f,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(Se,{counts:x,entries:d,filterType:n.filterType,focused:n.focusedPanel==="list",selectedIndex:n.selectedIndex,totalEntries:n.entries.length,viewportHeight:p})}),t.jsx(f,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(ue,{checkMode:e,entry:u,focused:n.focusedPanel==="detail",scrollRef:i})})]}),t.jsx(f,{flexShrink:0,paddingX:1,children:t.jsx(a,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},F=["types","node-addons","node","import","require","default"],be=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Oe=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,T=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>$(s));const r={};for(const[s,c]of Object.entries(e))r[s]=$(c);return r},Re=e=>{if(!T(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}},Ce=e=>e.endsWith(".git")?e.slice(0,-4):e,Ie=e=>{if(!T(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 c=be.exec(s)??Oe.exec(s);if(!c)return{changed:!1,value:e};const o=c[1],n=Ce(c[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}`}},Te=e=>{const r=Object.keys(e),s=[],c=[];for(const d of F)Object.hasOwn(e,d)&&s.push(d);for(const d of r)F.includes(d)||c.push(d);const o=[...s,...c];if(o.length===r.length&&o.every((d,u)=>d===r[u]))return{changed:!1,value:e};const i={};for(const d of o)i[d]=e[d];return{changed:!0,value:i}},H=e=>{if(!T(e))return{changed:!1,value:e};let r=!1;const s={};for(const[o,n]of Object.entries(e)){const i=H(n);s[o]=i.value,i.changed&&(r=!0)}const c=Te(s);return{changed:r||c.changed,value:c.value}},Pe=(e,r)=>{const s=$(e);let c=!1;if(r.formatBugs!==!1&&Object.hasOwn(s,"bugs")){const o=Re(s.bugs);o.changed&&(s.bugs=o.value,c=!0)}if(r.formatRepository!==!1&&Object.hasOwn(s,"repository")){const o=Ie(s.repository);o.changed&&(s.repository=o.value,c=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&T(s.exports)){const o=H(s.exports);o.changed&&(s.exports=o.value,c=!0)}return{changed:c,pkg:s}},$e=/at position (\d+)/,Ne=/\(?line (\d+) column (\d+)\)?/,Ae=e=>{const r=new Set,s=[],c=n=>{const i=Y(n);!r.has(i)&&L(i)&&(r.add(i),s.push(i))};c(C(e,"package.json"));const o=ce(e);if(o){const n=A(e,o);for(const i of n)c(C(e,i,"package.json"))}else{const n=C(e,"package.json");if(L(n)){const i=JSON.parse(J(n)),d=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;if(d){const u=A(e,d);for(const x of u)c(C(e,x,"package.json"))}}}return s},Le=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",_e=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},P=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(s=>s.split(",")).map(s=>s.trim()).filter(s=>s.length>0),De=e=>e.includes(`\r
|
|
1
|
+
import{a as B,z as J,e as I,$ as K,U as Y}from"../packem_shared/index-DHD8wb6Z.js";import{U as q,V,W as z,T as Z,v as Q,p as E,d as ee}from"./cli-main.js";import{i as re}from"../packem_shared/index-BjdW45xX.js";import{y as t,X as f,m as a,u as R,R as te,v as se,A as ne,B as oe,C as ie,i as ce,j as A}from"./catalog.js";import le from"./index.js";import{sortPackageJsonStringWithOptions as U}from"#native";import{e as C}from"../packem_shared/utils-DQFHJn72.js";import{y as L}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";const _={error:0,rewritten:1,"would-rewrite":1,unchanged:2},ae=e=>[...e].sort((r,s)=>_[r.status]-_[s.status]),de=(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");class fe{#e;#r=new Set;constructor(r){this.#e={entries:ae(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>de(this.#e.entries,this.#e.filterType);#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()}}const ue=({checkMode:e,entry:r,focused:s,scrollRef:c})=>{const o=s?"white":"gray";return r?t.jsxs(f,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(f,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.relativePath})}),t.jsxs(q,{flexGrow:1,flexShrink:1,paddingX:2,ref:c,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(f,{children:[t.jsx(f,{width:10,children:t.jsx(a,{dimColor:!0,children:"Status:"})}),r.status==="error"?t.jsx(a,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?t.jsx(a,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?t.jsx(a,{bold:!0,color:"yellow",children:"rewritten"}):t.jsx(a,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),t.jsxs(f,{children:[t.jsx(f,{width:10,children:t.jsx(a,{dimColor:!0,children:"Path:"})}),t.jsx(a,{children:r.filePath})]}),r.error?t.jsxs(t.Fragment,{children:[t.jsxs(f,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"red",children:"ERROR"}),t.jsxs(f,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(f,{children:[t.jsx(f,{width:10,children:t.jsx(a,{dimColor:!0,children:"Step:"})}),t.jsx(a,{color:"yellow",children:r.error.step})]}),r.error.context&&t.jsxs(f,{children:[t.jsx(f,{width:10,children:t.jsx(a,{dimColor:!0,children:"Position:"})}),t.jsx(a,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),t.jsx(f,{marginTop:1,children:t.jsx(a,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&t.jsxs(f,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"SNIPPET"}),t.jsxs(f,{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(f,{children:[t.jsx(a,{color:n.isErrorLine?"red":"gray",children:i}),t.jsx(a,{color:n.isErrorLine?"white":"gray",wrap:"truncate-end",children:n.content||" "})]},n.lineNumber)}),r.error.context.column>0&&t.jsx(f,{children:t.jsx(a,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):t.jsxs(f,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"KEY DIFF"}),t.jsx(f,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?t.jsx(a,{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)}`,u=i<0?"green":"yellow";return t.jsxs(f,{children:[t.jsx(f,{width:28,children:t.jsx(a,{wrap:"truncate",children:n.key})}),t.jsx(f,{width:10,children:t.jsxs(a,{dimColor:!0,children:[String(n.fromIndex)," → ",String(n.toIndex)]})}),t.jsx(a,{color:u,children:d})]},n.key)})}),e&&r.status==="would-rewrite"&&t.jsx(f,{marginTop:1,paddingLeft:2,children:t.jsx(a,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):t.jsx(f,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(a,{dimColor:!0,children:"No entry selected"})})},he={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},ge={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},W={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},xe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},pe=[{count:e=>e.errors+e.rewrites+e.sorted,key:"all",label:"All",shortcut:"1"},{count:e=>e.rewrites,key:"rewritten",label:"Rewrites",shortcut:"2"},{count:e=>e.errors,key:"errors",label:"Errors",shortcut:"3"},{count:e=>e.sorted,key:"unchanged",label:"Sorted",shortcut:"4"}],X=e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[W[s.status]]++;return r},me=({entry:e,isSelected:r})=>{const s=he[e.status],c=ge[e.status];return t.jsxs(f,{flexShrink:0,height:1,children:[t.jsx(a,{children:r?">":" "}),t.jsx(a,{children:" "}),t.jsx(a,{bold:!0,color:s,children:`[${c}]`.padEnd(10)}),t.jsx(a,{children:" "}),t.jsx(f,{flexGrow:1,children:t.jsx(a,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&t.jsx(a,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},je=({color:e,count:r,label:s})=>t.jsx(f,{flexShrink:0,height:1,children:t.jsx(a,{bold:!0,color:e,children:`${s} (${String(r)})`})}),Se=({counts:e,entries:r,filterType:s,focused:c,selectedIndex:o,totalEntries:n,viewportHeight:i})=>{const d=c?"white":"gray",u=X(r),x=(u.errors>0?1:0)+(u.rewrites>0?1:0)+(u.sorted>0?1:0),m=s==="all"&&x>1,h=[];let j;for(const[l,g]of r.entries()){const k=W[g.status];m&&k!==j&&(j!==void 0&&h.push({kind:"spacer"}),h.push({color:k==="errors"?"red":k==="rewrites"?"yellow":"green",count:u[k],kind:"header",label:xe[k]}),j=k),h.push({entry:g,entryIndex:l,kind:"entry"})}const p=h.findIndex(l=>l.kind==="entry"&&l.entryIndex===o),y=p!==-1,S=h.length,w=Math.max(0,S-i);let b=0;y&&i>0&&(b=Math.min(w,Math.max(0,p-i+1)));const O=S>i&&i>0;return t.jsxs(f,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(f,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(a,{bold:!0,inverse:!0,children:" VIS SORT "}),t.jsxs(a,{wrap:"truncate",children:[n," ","file",n===1?"":"s"]})]}),t.jsx(f,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pe.map(l=>{const g=s===l.key,k=l.count(e);return t.jsxs(f,{children:[t.jsx(a,{dimColor:!g,children:"["}),t.jsx(a,{bold:g,color:g?"cyan":"gray",children:l.shortcut}),t.jsx(a,{dimColor:!g,children:"]"}),t.jsxs(a,{color:g?"white":"gray",children:[" ",l.label]}),t.jsxs(a,{dimColor:!0,children:[" ","(",k,")"]})]},l.key)})}),t.jsxs(f,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(f,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(f,{flexDirection:"column",marginTop:-b,children:h.map((l,g)=>l.kind==="spacer"?t.jsx(f,{flexShrink:0,height:1},`s-${String(g)}`):l.kind==="header"?t.jsx(je,{color:l.color,count:l.count,label:l.label},`h-${l.label}`):t.jsx(me,{entry:l.entry,isSelected:l.entryIndex===o},l.entry.filePath))})}),O&&t.jsx(f,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(V,{contentHeight:S,placement:"inset",scrollOffset:b,style:"block",viewportHeight:i})})]})]})},we=100,D=10,ye=6,ke=1,M={1:"all",2:"rewritten",3:"errors",4:"unchanged"},Ee=({checkMode:e,store:r})=>{const{exit:s}=z(),{columns:c,rows:o}=Z(),n=R.useSyncExternalStore(r.subscribe,r.getSnapshot),i=R.useRef(null),d=r.getFilteredEntries(),u=d[n.selectedIndex]??null,x=X(n.entries),m=c>=we,h=Math.max(0,o-ke),j=m?h:Math.floor(h/2),p=Math.max(0,j-ye),y=R.useCallback(()=>{s()},[s]),S=R.useRef(0),w=R.useRef(void 0),b=R.useRef(!1),O=R.useCallback((l,g)=>{S.current+=g,w.current=l,!b.current&&(b.current=!0,queueMicrotask(()=>{b.current=!1;const k=S.current,N=w.current;S.current=0,w.current=void 0,!(k===0||N===void 0)&&(N==="list"?r.selectStep(Math.sign(k)):i.current?.scrollBy(Math.sign(k)))}))},[r]);return Q((l,g)=>{if(l==="q"||g.escape){y();return}if(M[l]){r.setFilter(M[l]);return}if(g.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}n.focusedPanel==="list"?g.upArrow||l==="k"?O("list",-1):(g.downArrow||l==="j")&&O("list",1):n.focusedPanel==="detail"&&(g.upArrow||l==="k"?O("detail",-1):(g.downArrow||l==="j")&&O("detail",1))}),o<D?t.jsx(f,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",D," ","rows."]})}):t.jsxs(f,{flexDirection:"column",height:o,width:c,children:[t.jsxs(f,{flexDirection:m?"row":"column",flexGrow:1,children:[t.jsx(f,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(Se,{counts:x,entries:d,filterType:n.filterType,focused:n.focusedPanel==="list",selectedIndex:n.selectedIndex,totalEntries:n.entries.length,viewportHeight:p})}),t.jsx(f,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(ue,{checkMode:e,entry:u,focused:n.focusedPanel==="detail",scrollRef:i})})]}),t.jsx(f,{flexShrink:0,paddingX:1,children:t.jsx(a,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},F=["types","node-addons","node","import","require","default"],be=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Oe=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,T=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>$(s));const r={};for(const[s,c]of Object.entries(e))r[s]=$(c);return r},Re=e=>{if(!T(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}},Ie=e=>e.endsWith(".git")?e.slice(0,-4):e,Ce=e=>{if(!T(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 c=be.exec(s)??Oe.exec(s);if(!c)return{changed:!1,value:e};const o=c[1],n=Ie(c[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}`}},Te=e=>{const r=Object.keys(e),s=[],c=[];for(const d of F)Object.hasOwn(e,d)&&s.push(d);for(const d of r)F.includes(d)||c.push(d);const o=[...s,...c];if(o.length===r.length&&o.every((d,u)=>d===r[u]))return{changed:!1,value:e};const i={};for(const d of o)i[d]=e[d];return{changed:!0,value:i}},H=e=>{if(!T(e))return{changed:!1,value:e};let r=!1;const s={};for(const[o,n]of Object.entries(e)){const i=H(n);s[o]=i.value,i.changed&&(r=!0)}const c=Te(s);return{changed:r||c.changed,value:c.value}},Pe=(e,r)=>{const s=$(e);let c=!1;if(r.formatBugs!==!1&&Object.hasOwn(s,"bugs")){const o=Re(s.bugs);o.changed&&(s.bugs=o.value,c=!0)}if(r.formatRepository!==!1&&Object.hasOwn(s,"repository")){const o=Ce(s.repository);o.changed&&(s.repository=o.value,c=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&T(s.exports)){const o=H(s.exports);o.changed&&(s.exports=o.value,c=!0)}return{changed:c,pkg:s}},$e=/at position (\d+)/,Ne=/\(?line (\d+) column (\d+)\)?/,Ae=e=>{const r=new Set,s=[],c=n=>{const i=Y(n);!r.has(i)&&L(i)&&(r.add(i),s.push(i))};c(I(e,"package.json"));const o=ce(e);if(o){const n=A(e,o);for(const i of n)c(I(e,i,"package.json"))}else{const n=I(e,"package.json");if(L(n)){const i=JSON.parse(J(n)),d=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;if(d){const u=A(e,d);for(const x of u)c(I(e,x,"package.json"))}}}return s},Le=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",_e=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},P=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(s=>s.split(",")).map(s=>s.trim()).filter(s=>s.length>0),De=e=>e.includes(`\r
|
|
2
2
|
`)?"crlf":"lf",Me=new Set(["auto","crlf","lf"]),Fe=e=>{if(e===void 0||e==="")return"auto";if(Me.has(e))return e;throw new Error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`)},Ge=(e,r,s)=>r.length===0?e:e.filter(c=>{const o=B(s,c),n=K(c);return!r.some(i=>{const d=i.includes("/")?o:n;return le(i,d)})}),ve=(e,r)=>{if(r.length===0)return e;const s={},c=new Set;for(const o of r)Object.hasOwn(e,o)&&(s[o]=e[o],c.add(o));for(const o of Object.keys(e))c.has(o)||(s[o]=e[o]);return s},Be=(e,r,s)=>{if(s.length===0)return e;const c={...e};for(const o of s)Object.hasOwn(r,o)&&(c[o]=r[o]);return c},Je=(e,r)=>{let s=1,c=1;const o=Math.min(r,e.length);for(let n=0;n<o;n++)e.codePointAt(n)===10?(s++,c=1):c++;return{column:c,line:s}},G=(e,r,s=2)=>{const c=e.split(`
|
|
3
3
|
`);if(r<1||r>c.length)return[];const o=Math.max(0,r-1-s),n=Math.min(c.length,r+s),i=[];for(let d=o;d<n;d++)i.push({content:c[d]??"",isErrorLine:d+1===r,lineNumber:d+1});return i},v=(e,r)=>{if(!(e instanceof Error))return;const s=$e.exec(e.message);if(s){const{column:o,line:n}=Je(r,Number.parseInt(s[1]??"0",10));return{column:o,line:n,snippet:G(r,n)}}const c=Ne.exec(e.message);if(c){const o=Number.parseInt(c[1]??"1",10);return{column:Number.parseInt(c[2]??"1",10),line:o,snippet:G(r,o)}}},Ue=(e,r)=>{const s=Object.keys(JSON.parse(e)),c=Object.keys(JSON.parse(r)),o=new Map(s.map((i,d)=>[i,d])),n=[];for(const[i,d]of c.entries()){const u=o.get(d);u!==void 0&&u!==i&&n.push({fromIndex:u,key:d,toIndex:i})}return n},We=(e,r,s)=>{const c=r.indent??s.indent??Le(e),o=r.lineEnding==="auto"?s.lineEnding??De(e):r.lineEnding,n=U(e,{pretty:!1,sortScripts:r.sortScripts});let i=JSON.parse(n);if(r.unsorted.length>0){const m=JSON.parse(e);i=Be(i,m,r.unsorted)}i=ve(i,r.sortOrder);const d={formatBugs:r.formatBugs,formatRepository:r.formatRepository,sortExports:r.sortExports},u=Pe(i,d);let x=JSON.stringify(u.pkg,null,c);return r.finalNewline&&(x+=`
|
|
4
4
|
`),o==="crlf"&&(x=x.replaceAll(`
|
|
5
5
|
`,`\r
|
|
6
|
-
`)),x},Xe=(e,r)=>{const s=Ae(e),c=se(e),o=ne({cwd:e,extraPatterns:oe(c)}),n=s.filter(d=>!o.ignores(d)),i=Ge(n,r,e);return{afterGitignore:n,allFiles:s,files:i}},He=async(e,{checkMode:r,cwd:s,fs:c,normalized:o})=>{const n=B(s,e)||e;let i;try{i=J(e)}catch(h){return{diff:[],error:{message:
|
|
6
|
+
`)),x},Xe=(e,r)=>{const s=Ae(e),c=se(e),o=ne({cwd:e,extraPatterns:oe(c)}),n=s.filter(d=>!o.ignores(d)),i=Ge(n,r,e);return{afterGitignore:n,allFiles:s,files:i}},He=async(e,{checkMode:r,cwd:s,fs:c,normalized:o})=>{const n=B(s,e)||e;let i;try{i=J(e)}catch(h){return{diff:[],error:{message:C(h),step:"read"},filePath:e,relativePath:n,status:"error"}}let d;try{d=U(i,{pretty:!1,sortScripts:o.sortScripts})}catch(h){const j={message:C(h),step:"native-sort"},p=v(h,i);return p&&(j.context=p),{diff:[],error:j,filePath:e,relativePath:n,status:"error"}}const u=o.editorconfig?ie(e):{};let x;try{x=We(i,o,u)}catch(h){const j={message:C(h),step:"json-parse"},p=v(h,i);return p&&(j.context=p),{diff:[],error:j,filePath:e,relativePath:n,status:"error"}}if(i===x)return{diff:[],filePath:e,relativePath:n,status:"unchanged"};let m;try{m=Ue(i,d)}catch{m=[]}if(r)return{diff:m,filePath:e,relativePath:n,status:"would-rewrite"};try{await c.writeFile(e,x,"utf8")}catch(h){return{diff:m,error:{message:C(h),step:"write"},filePath:e,relativePath:n,status:"error"}}return{diff:m,filePath:e,relativePath:n,status:"rewritten"}},Ke=e=>{if(e.error&&(E.error(`${e.filePath}: ${e.error.message}`),E.info(` step: ${e.error.step}`),e.error.context)){E.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?">":" ";E.info(` ${s} ${String(r.lineNumber).padStart(4)} | ${r.content}`)}}},tr=async({fs:e,options:r,visConfig:s,workspaceRoot:c})=>{const o=c??process.cwd(),n=s?.sortPackageJson,i=r.check||!1,u={editorconfig:r.editorconfig===!1?!1:n?.editorconfig??!0,finalNewline:r.finalNewline??n?.finalNewline??!0,formatBugs:r.formatBugs===!1?!1:n?.formatBugs??!0,formatRepository:r.formatRepository===!1?!1:n?.formatRepository??!0,ignore:[...P(r.ignore),...n?.ignore??[]],indent:_e(r.indent??n?.indent),lineEnding:Fe(r.lineEnding??n?.lineEnding),sortExports:r.sortExports===!1?!1:n?.sortExports??!0,sortOrder:[...P(r.sortOrder),...n?.sortOrder??[]],sortScripts:r.sortScripts||n?.sortScripts||!1,unsorted:[...P(r.unsorted),...n?.unsorted??[]]},x=Xe(o,u.ignore),{afterGitignore:m,allFiles:h,files:j}=x;if(j.length===0){h.length===0?E.info("No package.json files found."):m.length===0?E.info("All package.json files were excluded by .gitignore or workspace exclusions."):E.info("All package.json files were excluded by --ignore.");return}const p=[];for(const l of j)p.push(await He(l,{checkMode:i,cwd:o,fs:e,normalized:u}));let y=0,S=0,w=0;for(const l of p)l.status==="error"?w++:l.status==="rewritten"||l.status==="would-rewrite"?y++:S++;const b=y>0||w>0;if(!!process.stdout.isTTY&&!re&&b){const l=new fe(p);await ee(te.createElement(Ee,{checkMode:i,store:l}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit()}else for(const l of p)switch(l.status){case"error":{Ke(l);break}case"rewritten":{E.success(`Sorted ${l.filePath}`);break}case"would-rewrite":{E.warn(`${l.filePath} is not sorted`);break}}if(i)y>0?(E.info(`${String(y)} file${y===1?"":"s"} not sorted, ${String(S)} already sorted`),process.exitCode=1):w===0&&E.info(`All ${String(S)} package.json file${S===1?" is":"s are"} sorted`);else{const l=[];y>0&&l.push(`sorted ${String(y)} file${y===1?"":"s"}`),S>0&&l.push(`${String(S)} already sorted`),w>0&&l.push(`${String(w)} error${w===1?"":"s"}`),l.length>0&&E.info(l.join(", "))}w>0&&(process.exitCode=1)};export{G as buildSnippet,Ue as computeKeyDiff,Je as computeLineColumn,tr as default,Xe as discoverPackageJsonFiles,v as extractParseErrorContext,He as processFile};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b,X as D}from"../packem_shared/index.server-BAjDJSEu.js";import{e as I,z as se,a as $}from"../packem_shared/index-DHD8wb6Z.js";import U from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{$ as oe,_ as F,
|
|
1
|
+
import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b,X as D}from"../packem_shared/index.server-BAjDJSEu.js";import{e as I,z as se,a as $}from"../packem_shared/index-DHD8wb6Z.js";import U from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{$ as oe,_ as F,w as ne,a4 as ae,a5 as ie,a6 as re,a7 as ce}from"./cli-main.js";import{i as pe,j as z,x as W,p as L,D as K,r as fe}from"./catalog.js";import{p as S}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{U as le}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{T as j}from"../packem_shared/target-merge-B4No-LHM.js";import{l as ue}from"../packem_shared/missing-package-json-C0keIt78.js";let Z;const ee=e=>(Z??=Q(import.meta.url))(e),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,s]=V.versions.node.split(".").map(Number);if(a>22||a===22&&s>=3||a===20&&s>=16)return V.getBuiltinModule(e)}return ee(e)},{readFileSync:Y,writeFileSync:H}=te("node:fs"),de=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,me=e=>typeof e=="string"?void 0:e.replacement,q=(e,a)=>e.some(s=>U(s,a)),G=(e,a)=>{if(typeof e=="string")return!0;const s=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!s&&!t||s&&a.packageName!==void 0&&q(e.packages,a.packageName)||t&&q(e.paths,a.packageDir))},he=(e,a)=>{const s=a[e.depName];if(s!==void 0&&G(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&U(t,e.depName)&&G(r,e))return{pattern:t,rule:r}},ke=(e,a)=>{if(Object.keys(a).length===0)return[];const s=[];for(const t of e){if(t.isInternal)continue;const r=he(t,a);r&&s.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:me(r.rule),specifier:t.specifier})}return s},ye=new Set(["dependencies","devDependencies","peerDependencies"]),Pe=e=>e.startsWith("catalog:"),$e=e=>e.startsWith("workspace:"),we=(e,a)=>{if(!e)return!1;for(const s of e.values())if(s.has(a))return!0;return!1},ve=(e,a={})=>{const s=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!ye.has(i.depType)||$e(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const c=n.get(i.depName);c?c.push(i):n.set(i.depName,[i])}const o=[];for(const[i,c]of n){if(we(a.catalogs,i)||c.some(h=>Pe(h.specifier)))continue;const p=new Map;for(const h of c){let d=p.get(h.specifier);d||(d=new Set,p.set(h.specifier,d)),d.add(h.packageJsonPath)}const m=[...p.entries()].sort((h,d)=>h[1].size!==d[1].size?d[1].size-h[1].size:h[0].localeCompare(d[0]))[0];!m||m[1].size<s||o.push({catalogName:"default",depName:i,instanceCount:m[1].size,specifier:m[0]})}return o.sort((i,c)=>i.depName.localeCompare(c.depName))},De=(e,a)=>{if(a.length===0)return;const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=r.includes(`\r
|
|
2
2
|
`)?`\r
|
|
3
3
|
`:`
|
|
4
4
|
`,o=a.filter(d=>d.catalogName==="default").sort((d,u)=>d.depName.localeCompare(u.depName));if(o.length===0)return;const i=r.length>0?r.split(n):[],c=i.findIndex(d=>/^catalog\s*:\s*$/.test(d));if(c===-1){const d=["catalog:"];for(const J of o)d.push(` ${J.depName}: "${J.specifier}"`);let u=0;for(;u<i.length&&(i[u]??"").trim().length===0;)u+=1;const k=[...i.slice(0,u),...d,"",...i.slice(u)].join(n);return H(s,k.endsWith(n)?k:`${k}${n}`),s}let p=i.length;const f=new Set;for(let d=c+1;d<i.length;d+=1){const u=i[d]??"",k=u.trimStart();if(u.length===0)continue;if(u.length-k.length===0&&k.length>0&&!k.startsWith("#")){p=d;break}const P=/^([\w./@-]+)\s*:/.exec(k);P?.[1]&&f.add(P[1])}const m=[];for(const d of o)f.has(d.depName)||m.push(` ${d.depName}: "${d.specifier}"`);if(m.length===0)return;const h=[...i.slice(0,p),...m,...i.slice(p)].join(n);return H(s,h.endsWith(n)?h:`${h}${n}`),s},be=(e,a)=>{if(a.length===0)return"";const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=[...a].sort((f,m)=>f.depName.localeCompare(m.depName)),o=["--- pnpm-workspace.yaml","+++ pnpm-workspace.yaml"],i=r.includes(`\r
|