@visulima/vis 1.0.0-alpha.37 → 1.0.0-alpha.38
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 +6 -0
- package/LICENSE.md +1 -503
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/config/index.d.ts +7 -0
- package/dist/packem_chunks/DEFAULT_CLEAN_KEEP.js +1 -0
- package/dist/packem_chunks/bin.js +302 -515
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog-detector.js +1 -0
- package/dist/packem_chunks/detect.js +3 -0
- package/dist/packem_chunks/detect2.js +8 -0
- package/dist/packem_chunks/discord.js +4 -0
- package/dist/packem_chunks/dynamic-import.js +1 -0
- package/dist/packem_chunks/extra-files.js +3 -0
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/git.js +3 -0
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler3.js +4 -4
- package/dist/packem_chunks/handler30.js +2 -7
- package/dist/packem_chunks/handler31.js +2 -33
- package/dist/packem_chunks/handler32.js +2 -3
- package/dist/packem_chunks/handler33.js +3 -8
- package/dist/packem_chunks/handler34.js +6 -4
- package/dist/packem_chunks/handler35.js +1 -1
- package/dist/packem_chunks/handler36.js +42 -5
- package/dist/packem_chunks/handler37.js +8 -11
- package/dist/packem_chunks/handler38.js +9 -3
- package/dist/packem_chunks/handler39.js +74 -21
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler40.js +5 -61
- package/dist/packem_chunks/handler41.js +4 -3
- package/dist/packem_chunks/handler42.js +3 -6
- package/dist/packem_chunks/handler43.js +2 -24
- package/dist/packem_chunks/handler44.js +1 -25
- package/dist/packem_chunks/handler45.js +1 -153
- package/dist/packem_chunks/handler46.js +1 -10
- package/dist/packem_chunks/handler47.js +3 -24
- package/dist/packem_chunks/handler48.js +1 -322
- package/dist/packem_chunks/handler49.js +7 -708
- package/dist/packem_chunks/handler5.js +6 -6
- package/dist/packem_chunks/handler50.js +33 -48
- package/dist/packem_chunks/handler51.js +3 -27
- package/dist/packem_chunks/handler52.js +8 -3
- package/dist/packem_chunks/handler53.js +4 -200
- package/dist/packem_chunks/handler54.js +1 -38
- package/dist/packem_chunks/handler55.js +12 -0
- package/dist/packem_chunks/handler56.js +7 -0
- package/dist/packem_chunks/handler57.js +5 -0
- package/dist/packem_chunks/handler58.js +11 -0
- package/dist/packem_chunks/handler59.js +3 -0
- package/dist/packem_chunks/handler60.js +22 -0
- package/dist/packem_chunks/handler61.js +61 -0
- package/dist/packem_chunks/handler62.js +3 -0
- package/dist/packem_chunks/handler63.js +6 -0
- package/dist/packem_chunks/handler64.js +708 -0
- package/dist/packem_chunks/handler65.js +24 -0
- package/dist/packem_chunks/handler66.js +25 -0
- package/dist/packem_chunks/handler67.js +153 -0
- package/dist/packem_chunks/handler68.js +10 -0
- package/dist/packem_chunks/handler69.js +24 -0
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler70.js +322 -0
- package/dist/packem_chunks/handler71.js +48 -0
- package/dist/packem_chunks/handler72.js +27 -0
- package/dist/packem_chunks/handler73.js +3 -0
- package/dist/packem_chunks/handler74.js +190 -0
- package/dist/packem_chunks/handler75.js +38 -0
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_chunks/index.js +1 -7
- package/dist/packem_chunks/index2.js +7 -0
- package/dist/packem_chunks/interface.js +2 -0
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/orchestrator.js +39 -0
- package/dist/packem_chunks/pre-mode.js +2 -0
- package/dist/packem_chunks/print-config.js +2 -0
- package/dist/packem_chunks/prompts.js +7 -0
- package/dist/packem_chunks/publish-guards.js +1 -0
- package/dist/packem_chunks/registry.js +48 -0
- package/dist/packem_chunks/resolveFormatter.js +9 -0
- package/dist/packem_chunks/security.js +1 -0
- package/dist/packem_chunks/shell-runner.js +1 -0
- package/dist/packem_chunks/slack.js +2 -0
- package/dist/packem_chunks/snapshot.js +2 -0
- package/dist/packem_chunks/stage-publisher.js +1 -0
- package/dist/packem_chunks/staged-registry.js +2 -0
- package/dist/packem_chunks/state.js +3 -0
- package/dist/packem_chunks/success-walk.js +8 -0
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +2 -2
- package/dist/packem_chunks/version-resolver.js +2 -0
- package/dist/packem_chunks/webhook.js +1 -0
- package/dist/packem_chunks/workflow-templates.js +167 -0
- package/dist/packem_chunks/workspace.js +2 -0
- package/dist/packem_shared/AfterAllProjectsVersioned-CAKI2nWf.js +1 -0
- package/dist/packem_shared/ReleaseClient-YHzBIxYS.js +1 -0
- package/dist/packem_shared/VisReleaseError-DMGRBTNO.js +1 -0
- package/dist/packem_shared/{ai-analysis-DT3bU-_M.js → ai-analysis-K-DKU3ZA.js} +1 -1
- package/dist/packem_shared/{ai-fix-BkNqd5nP.js → ai-fix-BPrYoCk8.js} +1 -1
- package/dist/packem_shared/api.d-BPftyU9r.d.ts +27 -0
- package/dist/packem_shared/createAdapter-bU4DIP3F.js +1 -0
- package/dist/packem_shared/createVersionActions-BK43SNDH.js +1 -0
- package/dist/packem_shared/{cyclonedx-86-DbHtf.js → cyclonedx-kYozDyxp.js} +3 -3
- package/dist/packem_shared/defineFormatter-D5dCp6Kv.js +1 -0
- package/dist/packem_shared/dependency-scan-anTuZB1t.js +1 -0
- package/dist/packem_shared/{docker-tNrDU3oK.js → docker-BMLrNtWm.js} +1 -1
- package/dist/packem_shared/{failure-log-Dwqt6_Ga.js → failure-log-CEWP3bP0.js} +1 -1
- package/dist/packem_shared/index-BJbpNthk.js +1 -0
- package/dist/packem_shared/index-CgcF6_wo.js +1 -0
- package/dist/packem_shared/{index-dQ37x8_P.js → index-D1_fbGbj.js} +1 -1
- package/dist/packem_shared/interface.d-B7VK2rcH.d.ts +148 -0
- package/dist/packem_shared/interface.d-Cezzifoh.d.ts +106 -0
- package/dist/packem_shared/{missing-package-json-41VUWFBY.js → missing-package-json-BfWUxTGv.js} +1 -1
- package/dist/packem_shared/{native-config-sync-BKAZ0NIs.js → native-config-sync-BEkJW7g3.js} +8 -8
- package/dist/packem_shared/pm-runner-OGResYrA.js +1 -0
- package/dist/packem_shared/provenance-_CJjMKwu.js +1 -0
- package/dist/packem_shared/public-api-WqUCiyIe.js +131 -0
- package/dist/packem_shared/{registry-keys-Bf2zzlcZ.js → registry-keys-BfFto6vI.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-jH0RKyMJ.js → resolve-explicit-CMDl55Nz.js} +2 -2
- package/dist/packem_shared/s1ngularity-Dhr3bPk0.js +1 -0
- package/dist/packem_shared/{scan-progress-JBbd9QeT.js → scan-progress-DG7_JmTV.js} +1 -1
- package/dist/packem_shared/{signatures-D1H6h6GH.js → signatures-C730vkyK.js} +2 -2
- package/dist/packem_shared/slug-DoueYuLo.js +1 -0
- package/dist/packem_shared/spinner-CV3WVJLv.js +1 -0
- package/dist/packem_shared/sticky-comment-D6_7-w8T.js +1 -0
- package/dist/packem_shared/{tabs-BqUepRaD.js → tabs-BuTy5gPV.js} +1 -1
- package/dist/packem_shared/{typosquats-C8qg1neE.js → typosquats-DN78xx1x.js} +1 -1
- package/dist/packem_shared/use-measured-height-_eVGWtWt.js +1 -0
- package/dist/packem_shared/verify-6WCmFmy8.js +1 -0
- package/dist/packem_shared/{vis-update-app-CTwRkNgj.js → vis-update-app-k3fDxech.js} +1 -1
- package/dist/release/core/changelog/index.d.ts +5 -0
- package/dist/release/core/changelog/index.js +1 -0
- package/dist/release/core/package-managers/index.d.ts +6 -0
- package/dist/release/core/package-managers/index.js +1 -0
- package/dist/release/core/version-actions/index.d.ts +14 -0
- package/dist/release/core/version-actions/index.js +1 -0
- package/dist/release/index.d.ts +196 -0
- package/dist/release/index.js +1 -0
- package/dist/release/plugin-sdk.d.ts +127 -0
- package/dist/release/plugin-sdk.js +1 -0
- package/dist/release/presets.d.ts +225 -0
- package/dist/release/presets.js +1 -0
- package/dist/release/types.d.ts +1377 -0
- package/dist/release/types.js +1 -0
- package/index.d.ts +201 -201
- package/index.js +578 -752
- package/package.json +52 -10
- package/schemas/vis-config.schema.json +1394 -6
- package/schemas/vis-release-config.schema.json +1390 -0
- package/dist/packem_shared/dependency-scan-BDTH898x.js +0 -1
- package/dist/packem_shared/index-CB4p298r.js +0 -1
- package/dist/packem_shared/index-DMefdF51.js +0 -1
- package/dist/packem_shared/pm-runner-pVihAfxV.js +0 -1
- package/dist/packem_shared/provenance-DMuEftgc.js +0 -1
- package/dist/packem_shared/s1ngularity-BkfgC6NO.js +0 -1
- package/dist/packem_shared/spinner-BXSl864p.js +0 -1
- package/dist/packem_shared/use-measured-height-BBJ9intr.js +0 -1
- package/dist/packem_shared/verify-Du7xZ2BJ.js +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`)
|
|
3
|
-
`)
|
|
1
|
+
import{createRequire as k}from"node:module";import{b as N}from"./orchestrator.js";import{createShellRunner as v}from"./shell-runner.js";const b=k(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[o,r]=g.versions.node.split(".").map(Number);if(o>22||o===22&&r>=3||o===20&&r>=16)return g.getBuiltinModule(e)}return b(e)},{resolve:A}=$("node:path"),x=["test"],C=e=>e===void 0||e===""?"test":x.includes(e)?e:void 0,w=e=>e==null?[]:Array.isArray(e)?e:[e],S=async(e,o)=>{const r=v();let i,n;try{const{createRemoteClient:u,detectRemoteProvider:l}=await import("./detect2.js"),c=await l(o,r,void 0);i=await u(c,{}).detectRepoSlug(o,r)}catch{}try{n=JSON.parse(await e.readFile(`${o}/package.json`,"utf8")).name}catch{}const p=n?`${n.startsWith("@")?n:`@${n}`}/example`:"@scope/example",s=i?`https://github.com/${i}/releases/tag/v1.0.0`:"https://github.com/example/example/releases/tag/v1.0.0";return{channel:"latest",completedAt:new Date().toISOString(),...n===void 0?{}:{monorepoName:n},published:[{name:p,tag:"latest",url:s,version:"1.0.0"}],...i===void 0?{}:{repo:i},skipped:[]}},j=(e,o)=>o?o.includes(":")?e===o:e===o||e.startsWith(`${o}:`):!0,_=async e=>{const o=[],r=[];if(!e)return{channels:o,pluginFailures:r};const{SlackNotificationChannel:i}=await import("./slack.js");for(const s of w(e.slack))o.push(new i(s));const{DiscordNotificationChannel:n}=await import("./discord.js");for(const s of w(e.discord))o.push(new n(s));const{WebhookNotificationChannel:p}=await import("./webhook.js");for(const s of w(e.webhook))o.push(new p(s));if(e.plugins&&e.plugins.length>0){const{pathToFileURL:s}=await import("node:url"),{dynamicEsmImport:u}=await import("./dynamic-import.js");for(const l of e.plugins){const[c,h]=Array.isArray(l)?l:[l,void 0],m=c;try{const d=c.startsWith(".")?s(`${process.cwd()}/${c}`).href:c,f=await u(d),t=f.default??f;let a;typeof t=="function"?a=t(h):t&&typeof t=="object"&&typeof t.send=="function"&&(a=t),a&&typeof a=="object"&&typeof a.send=="function"?o.push(a):r.push({error:"did not export a NotificationChannel (object with .send) or a factory returning one",id:m})}catch(d){r.push({error:d.message,id:m})}}}return{channels:o,pluginFailures:r}},R=async(e,o)=>{try{return await e.send(o),{id:e.id,ok:!0}}catch(r){const i=r instanceof Error?r.message:String(r),{redactTokens:n}=await import("./security.js");return{error:n(i),id:e.id,ok:!1}}},F=async(e,o)=>{const r=A(process.cwd(),o),i=await e.readFile(r,"utf8"),n=JSON.parse(i);return{channel:n.channel,completedAt:n.completedAt??new Date().toISOString(),...n.monorepoName===void 0?{}:{monorepoName:n.monorepoName},published:Array.isArray(n.published)?n.published:[],...n.repo===void 0?{}:{repo:n.repo},skipped:Array.isArray(n.skipped)?n.skipped:[]}},D=async({fs:e,logger:o,options:r,workspaceRoot:i})=>{const n=i??process.cwd();if(C(r.action)===void 0){o.error(`Unknown action "${r.action}". Expected: test.`),process.exitCode=1;return}let p;try{p=await N({cwd:n,skipRegistryLookup:!0})}catch(t){o.error(`Failed to load release context: ${t instanceof Error?t.message:String(t)}`),process.exitCode=1;return}const s=p.config.notifications;if(!(s&&(s.slack&&(!Array.isArray(s.slack)||s.slack.length>0)||s.discord&&(!Array.isArray(s.discord)||s.discord.length>0)||s.webhook&&(!Array.isArray(s.webhook)||s.webhook.length>0)||s.plugins&&s.plugins.length>0))){const t={channels:[],hint:"No notifications configured. Add `release.notifications.{slack,discord,webhook,plugins}` to vis.config.ts.",ok:!0};r.json?process.stdout.write(`${JSON.stringify(t,null,2)}
|
|
2
|
+
`):o.info(t.hint);return}let u;try{u=r.customContext?await F(e,r.customContext):await S(e,n)}catch(t){o.error(`Could not load NotificationContext: ${t.message}`),process.exitCode=1;return}const{channels:l,pluginFailures:c}=await _(s),h=r.channel,m=l.filter(t=>j(t.id,h));if(m.length===0&&c.length===0){const t=h?`No channels matched filter "${h}". Configured ids: ${l.map(a=>a.id).join(", ")||"(none)"}.`:"No channels could be materialised from the configured notifications block.";r.json?process.stdout.write(`${JSON.stringify({channels:[],hint:t,ok:!1},null,2)}
|
|
3
|
+
`):o.error(t),process.exitCode=1;return}const d=[...await Promise.all(m.map(t=>R(t,u))),...c.map(t=>({error:`plugin load failed: ${t.error}`,id:t.id,ok:!1}))],f=d.filter(t=>!t.ok);if(r.json)process.stdout.write(`${JSON.stringify({channels:d,ok:f.length===0},null,2)}
|
|
4
|
+
`);else{for(const y of d)y.ok?o.info(` ${y.id} OK`):o.error(` ${y.id} FAIL — ${y.error??"unknown error"}`);const t=d.length,a=t-f.length;o.info(""),o.info(`Dispatched ${a}/${t} channel${t===1?"":"s"}.`)}f.length>0&&(process.exitCode=1)};export{D as default};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import{createRequire as z}from"node:module";import{y as L,v as _,m as P,f as M,J as V,B as Y}from"../packem_shared/index-BDmTbWX1.js";import{a4 as t,a5 as a,g as c,aE as K,aF as Q,aG as U,aD as Z,t as v,ae as ee,p as k,j as re,$ as te,k as se,m as ne,aN as oe,aO as ie,aP as le,l as ce,s as N}from"./bin.js";import{o as ae}from"../packem_shared/index-CB4p298r.js";import{sortPackageJsonStringWithOptions as q}from"#native";import{c as O}from"../packem_shared/utils-Cxree603.js";const Ke=z(import.meta.url),Qe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const D={error:0,rewritten:1,"would-rewrite":1,unchanged:2},de=e=>[...e].sort((r,s)=>D[r.status]-D[s.status]),ue=(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:de(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>ue(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 he=({checkMode:e,entry:r,focused:s,scrollRef:l})=>{const i=s?"white":"gray";return r?t.jsxs(a,{borderColor:i,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(a,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(c,{bold:!0,color:"white",children:r.relativePath})}),t.jsxs(K,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(c,{}),t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Status:"})}),r.status==="error"?t.jsx(c,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?t.jsx(c,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?t.jsx(c,{bold:!0,color:"yellow",children:"rewritten"}):t.jsx(c,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Path:"})}),t.jsx(c,{children:r.filePath})]}),r.error?t.jsxs(t.Fragment,{children:[t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"red",children:"ERROR"}),t.jsxs(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Step:"})}),t.jsx(c,{color:"yellow",children:r.error.step})]}),r.error.context&&t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Position:"})}),t.jsx(c,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),t.jsx(a,{marginTop:1,children:t.jsx(c,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"white",children:"SNIPPET"}),t.jsxs(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(n=>{const o=`${n.isErrorLine?"❯":" "} ${String(n.lineNumber).padStart(4)} `;return t.jsxs(a,{children:[t.jsx(c,{color:n.isErrorLine?"red":"gray",children:o}),t.jsx(c,{color:n.isErrorLine?"white":"gray",wrap:"truncate-end",children:n.content||" "})]},n.lineNumber)}),r.error.context.column>0&&t.jsx(a,{children:t.jsx(c,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"white",children:"KEY DIFF"}),t.jsx(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?t.jsx(c,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(n=>{const o=n.toIndex-n.fromIndex,d=o<0?`↑ ${String(Math.abs(o))}`:`↓ ${String(o)}`,g=o<0?"green":"yellow";return t.jsxs(a,{children:[t.jsx(a,{width:28,children:t.jsx(c,{wrap:"truncate",children:n.key})}),t.jsx(a,{width:10,children:t.jsxs(c,{dimColor:!0,children:[String(n.fromIndex)," → ",String(n.toIndex)]})}),t.jsx(c,{color:g,children:d})]},n.key)})}),e&&r.status==="would-rewrite"&&t.jsx(a,{marginTop:1,paddingLeft:2,children:t.jsx(c,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):t.jsx(a,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(c,{dimColor:!0,children:"No entry selected"})})},ge={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},xe={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},H={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},pe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},me=[{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[H[s.status]]++;return r},we=({entry:e,isSelected:r})=>{const s=ge[e.status],l=xe[e.status];return t.jsxs(a,{flexShrink:0,height:1,children:[t.jsx(c,{children:r?">":" "}),t.jsx(c,{children:" "}),t.jsx(c,{bold:!0,color:s,children:`[${l}]`.padEnd(10)}),t.jsx(c,{children:" "}),t.jsx(a,{flexGrow:1,children:t.jsx(c,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&t.jsx(c,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},je=({color:e,count:r,label:s})=>t.jsx(a,{flexShrink:0,height:1,children:t.jsx(c,{bold:!0,color:e,children:`${s} (${String(r)})`})}),ye=({counts:e,entries:r,filterType:s,focused:l,selectedIndex:i,totalEntries:n,viewportHeight:o})=>{const d=l?"white":"gray",g=X(r),m=(g.errors>0?1:0)+(g.rewrites>0?1:0)+(g.sorted>0?1:0),y=s==="all"&&m>1,h=[];let w;for(const[u,p]of r.entries()){const b=H[p.status];y&&b!==w&&(w!==void 0&&h.push({kind:"spacer"}),h.push({color:b==="errors"?"red":b==="rewrites"?"yellow":"green",count:g[b],kind:"header",label:pe[b]}),w=b),h.push({entry:p,entryIndex:u,kind:"entry"})}const x=h.findIndex(u=>u.kind==="entry"&&u.entryIndex===i),S=x!==-1,j=h.length,$=Math.max(0,j-o);let f=0;S&&o>0&&(f=Math.min($,Math.max(0,x-o+1)));const E=j>o&&o>0;return t.jsxs(a,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(a,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(c,{bold:!0,inverse:!0,children:" VIS SORT "}),t.jsxs(c,{wrap:"truncate",children:[n," ","file",n===1?"":"s"]})]}),t.jsx(a,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:me.map(u=>{const p=s===u.key,b=u.count(e);return t.jsxs(a,{children:[t.jsx(c,{dimColor:!p,children:"["}),t.jsx(c,{bold:p,color:p?"cyan":"gray",children:u.shortcut}),t.jsx(c,{dimColor:!p,children:"]"}),t.jsxs(c,{color:p?"white":"gray",children:[" ",u.label]}),t.jsxs(c,{dimColor:!0,children:[" ","(",b,")"]})]},u.key)})}),t.jsxs(a,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(a,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(a,{flexDirection:"column",marginTop:-f,children:h.map((u,p)=>u.kind==="spacer"?t.jsx(a,{flexShrink:0,height:1},`s-${String(p)}`):u.kind==="header"?t.jsx(je,{color:u.color,count:u.count,label:u.label},`h-${u.label}`):t.jsx(we,{entry:u.entry,isSelected:u.entryIndex===i},u.entry.filePath))})}),E&&t.jsx(a,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(Q,{contentHeight:j,placement:"inset",scrollOffset:f,style:"block",viewportHeight:o})})]})]})},be=100,A=10,ke=6,Se=1,F={1:"all",2:"rewritten",3:"errors",4:"unchanged"},$e=({checkMode:e,store:r})=>{const{exit:s}=U(),{columns:l,rows:i}=Z(),n=v.useSyncExternalStore(r.subscribe,r.getSnapshot),o=v.useRef(null),d=r.getFilteredEntries(),g=d[n.selectedIndex]??null,m=X(n.entries),y=l>=be,h=Math.max(0,i-Se),w=y?h:Math.floor(h/2),x=Math.max(0,w-ke),S=v.useCallback(()=>{s()},[s]),j=v.useRef(0),$=v.useRef(void 0),f=v.useRef(!1),E=v.useCallback((u,p)=>{j.current+=p,$.current=u,!f.current&&(f.current=!0,queueMicrotask(()=>{f.current=!1;const b=j.current,T=$.current;j.current=0,$.current=void 0,!(b===0||T===void 0)&&(T==="list"?r.selectStep(Math.sign(b)):o.current?.scrollBy(Math.sign(b)))}))},[r]);return ee((u,p)=>{if(u==="q"||p.escape){S();return}if(F[u]){r.setFilter(F[u]);return}if(p.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}n.focusedPanel==="list"?p.upArrow||u==="k"?E("list",-1):(p.downArrow||u==="j")&&E("list",1):n.focusedPanel==="detail"&&(p.upArrow||u==="k"?E("detail",-1):(p.downArrow||u==="j")&&E("detail",1))}),i<A?t.jsx(a,{alignItems:"center",justifyContent:"center",children:t.jsxs(c,{color:"yellow",children:["Terminal too small. Resize to at least",A," ","rows."]})}):t.jsxs(a,{flexDirection:"column",height:i,width:l,children:[t.jsxs(a,{flexDirection:y?"row":"column",flexGrow:1,children:[t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(ye,{counts:m,entries:d,filterType:n.filterType,focused:n.focusedPanel==="list",selectedIndex:n.selectedIndex,totalEntries:n.entries.length,viewportHeight:x})}),t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(he,{checkMode:e,entry:g,focused:n.focusedPanel==="detail",scrollRef:o})})]}),t.jsx(a,{flexShrink:0,paddingX:1,children:t.jsx(c,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},B=["types","node-addons","node","import","require","default"],ve=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Ee=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,C=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),I=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>I(s));const r={};for(const[s,l]of Object.entries(e))r[s]=I(l);return r},Pe=e=>{if(!C(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}},Oe=e=>e.endsWith(".git")?e.slice(0,-4):e,Ce=e=>{if(!C(e))return{changed:!1,value:e};if(typeof e.directory=="string"&&e.directory.length>0)return{changed:!1,value:e};const{type:r}=e;if(r!==void 0&&r!=="git")return{changed:!1,value:e};const{url:s}=e;if(typeof s!="string")return{changed:!1,value:e};const l=ve.exec(s)??Ee.exec(s);if(!l)return{changed:!1,value:e};const i=l[1],n=Oe(l[2]??"");if(!i||!n)return{changed:!1,value:e};const o=new Set(["type","url"]);for(const d of Object.keys(e))if(!o.has(d))return{changed:!1,value:e};return{changed:!0,value:`${i}/${n}`}},Re=e=>{const r=Object.keys(e),s=[],l=[];for(const o of B)Object.hasOwn(e,o)&&s.push(o);for(const o of r)B.includes(o)||l.push(o);const i=[...s,...l];if(i.length===r.length&&i.every((o,d)=>o===r[d]))return{changed:!1,value:e};const n={};for(const o of i)n[o]=e[o];return{changed:!0,value:n}},W=e=>{if(!C(e))return{changed:!1,value:e};let r=!1;const s={};for(const[i,n]of Object.entries(e)){const o=W(n);s[i]=o.value,o.changed&&(r=!0)}const l=Re(s);return{changed:r||l.changed,value:l.value}},Ie=(e,r)=>{const s=I(e);let l=!1;if(r.formatBugs!==!1&&Object.hasOwn(s,"bugs")){const i=Pe(s.bugs);i.changed&&(s.bugs=i.value,l=!0)}if(r.formatRepository!==!1&&Object.hasOwn(s,"repository")){const i=Ce(s.repository);i.changed&&(s.repository=i.value,l=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&C(s.exports)){const i=W(s.exports);i.changed&&(s.exports=i.value,l=!0)}return{changed:l,pkg:s}},Te=/at position (\d+)/,Me=/\(?line (\d+) column (\d+)\)?/,Ne=e=>{const r=new Set,s=[],l=n=>{const o=Y(n);!r.has(o)&&M(o)&&(r.add(o),s.push(o))};l(P(e,"package.json"));const i=ce(e);if(i){const n=N(e,i);for(const o of n)l(P(e,o,"package.json"))}else{const n=P(e,"package.json");if(M(n)){const o=JSON.parse(_(n)),d=Array.isArray(o.workspaces)?o.workspaces:o.workspaces?.packages;if(d){const g=N(e,d);for(const m of g)l(P(e,m,"package.json"))}}}return s},De=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",Ae=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},R=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),Fe=e=>e.includes(`\r
|
|
2
|
-
|
|
3
|
-
`);
|
|
4
|
-
`),i==="crlf"&&(m=m.replaceAll(`
|
|
5
|
-
`,`\r
|
|
6
|
-
`)),m},We=(e,r)=>{const s=Ne(e),l=ne(e),i=oe({cwd:e,extraPatterns:ie(l)}),n=s.filter(d=>!i.ignores(d)),o=Je(n,r,e);return{afterGitignore:n,allFiles:s,files:o}},ze=async(e,{checkMode:r,cwd:s,fs:l,normalized:i})=>{const n=L(s,e)||e;let o;try{o=_(e)}catch(h){return{diff:[],error:{message:O(h),step:"read"},filePath:e,relativePath:n,status:"error"}}let d;try{d=q(o,{pretty:!1,sortScripts:i.sortScripts})}catch(h){const w={message:O(h),step:"native-sort"},x=J(h,o);return x&&(w.context=x),{diff:[],error:w,filePath:e,relativePath:n,status:"error"}}const g=i.editorconfig?le(e):{};let m;try{m=Xe(o,i,g)}catch(h){const w={message:O(h),step:"json-parse"},x=J(h,o);return x&&(w.context=x),{diff:[],error:w,filePath:e,relativePath:n,status:"error"}}if(o===m)return{diff:[],filePath:e,relativePath:n,status:"unchanged"};let y;try{y=He(o,d)}catch{y=[]}if(r)return{diff:y,filePath:e,relativePath:n,status:"would-rewrite"};try{await l.writeFile(e,m,"utf8")}catch(h){return{diff:y,error:{message:O(h),step:"write"},filePath:e,relativePath:n,status:"error"}}return{diff:y,filePath:e,relativePath:n,status:"rewritten"}},Ve=e=>{if(e.error&&(k.error(`${e.filePath}: ${e.error.message}`),k.info(` step: ${e.error.step}`),e.error.context)){k.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?">":" ";k.info(` ${s} ${String(r.lineNumber).padStart(4)} | ${r.content}`)}}},sr=async({fs:e,options:r,visConfig:s,workspaceRoot:l})=>{const i=l??process.cwd(),n=s?.sortPackageJson,o=r.check||!1,d={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:[...R(r.ignore),...n?.ignore??[]],indent:Ae(r.indent??n?.indent),lineEnding:Ge(r.lineEnding??n?.lineEnding),sortExports:r.sortExports===!1?!1:n?.sortExports??!0,sortOrder:[...R(r.sortOrder),...n?.sortOrder??[]],sortScripts:r.sortScripts||n?.sortScripts||!1,unsorted:[...R(r.unsorted),...n?.unsorted??[]]},g=We(i,d.ignore),{afterGitignore:m,allFiles:y,files:h}=g;if(h.length===0){y.length===0?k.info("No package.json files found."):m.length===0?k.info("All package.json files were excluded by .gitignore or workspace exclusions."):k.info("All package.json files were excluded by --ignore.");return}const w=[];for(const f of h)w.push(await ze(f,{checkMode:o,cwd:i,fs:e,normalized:d}));let x=0,S=0,j=0;for(const f of w)f.status==="error"?j++:f.status==="rewritten"||f.status==="would-rewrite"?x++:S++;const $=x>0||j>0;if(process.stdout.isTTY&&!re&&$){const f=new fe(w);await te(se.createElement($e,{checkMode:o,store:f}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit()}else for(const f of w)switch(f.status){case"error":{Ve(f);break}case"rewritten":{k.success(`Sorted ${f.filePath}`);break}case"would-rewrite":{k.warn(`${f.filePath} is not sorted`);break}}if(o)x>0?(k.info(`${String(x)} file${x===1?"":"s"} not sorted, ${String(S)} already sorted`),process.exitCode=1):j===0&&k.info(`All ${String(S)} package.json file${S===1?" is":"s are"} sorted`);else{const f=[];x>0&&f.push(`sorted ${String(x)} file${x===1?"":"s"}`),S>0&&f.push(`${String(S)} already sorted`),j>0&&f.push(`${String(j)} error${j===1?"":"s"}`),f.length>0&&k.info(f.join(", "))}j>0&&(process.exitCode=1)};export{G as buildSnippet,He as computeKeyDiff,qe as computeLineColumn,sr as default,We as discoverPackageJsonFiles,J as extractParseErrorContext,ze as processFile};
|
|
1
|
+
import{createRequire as y}from"node:module";import{DEFAULT_CHANGES_DIR as j}from"./DEFAULT_CLEAN_KEEP.js";import{b as C,f as T}from"./orchestrator.js";import{a as x}from"../packem_shared/slug-DoueYuLo.js";import B from"./handler43.js";const k=y(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=e=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[t,o]=l.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return l.getBuiltinModule(e)}return k(e)},{join:h}=_("node:path"),f=["none","patch","minor","major"],g=(e,t)=>{const o=f.indexOf(e)+t;return f[Math.min(Math.max(o,0),f.length-1)]??e},v=e=>e.chosen!==e.release.type,R=(e,t)=>{const o=[];e.isCascadeBump&&o.push("cascade"),e.isGroupBump&&o.push("group"),e.isDependencyBump&&!e.isCascadeBump&&o.push("dep-bump");const r=o.length>0?` [${o.join(", ")}]`:"";return`${e.name}: ${e.oldVersion} → ${e.newVersion} (${t})${r}`},q=async e=>{const{selectPrompt:t}=await import("./prompts.js");process.stdout.write(`
|
|
2
|
+
${R(e,e.type)}
|
|
3
|
+
`);const o=await t("Action?",[{label:"accept (keep as-is)",value:"accept"},{label:"promote (bump up one level)",value:"promote"},{label:"demote (bump down one level)",value:"demote"},{label:"set explicitly (major | minor | patch | none)",value:"set"},{label:"skip this package",value:"skip"}]);return o==="promote"?g(e.type,1):o==="demote"?g(e.type,-1):o==="skip"?"none":o==="set"?t("Set bump level to?",[{label:"major",value:"major"},{label:"minor",value:"minor"},{label:"patch",value:"patch"},{label:"none (skip)",value:"none"}]):e.type},D=async e=>{const t=[];for(const o of e)t.push({chosen:await q(o),release:o});return t},N=async(e,t,o,r,c)=>{const i={};for(const s of r)s.chosen!=="none"&&(i[s.release.name]=s.chosen);const n=h(t,o,`${x("plan")}.md`),u={bumps:i};return await e.mkdir(h(t,o),{recursive:!0}),await e.writeFile(n,T(u,c)),n},S=async e=>{const{fs:t,logger:o,options:r,workspaceRoot:c}=e,i=c??process.cwd();if(!process.stdout.isTTY){o.error("--interactive requires a TTY. Drop the flag to get JSON output."),process.exitCode=1;return}const n=await C({channel:r.channel,cwd:i,skipRegistryLookup:!0}),{printConfigIfRequested:u}=await import("./print-config.js");if(u(r,n,o))return;const{releases:s}=n.plan;if(s.length===0){o.info("No pending releases.");return}n.channel&&o.info(`Channel: ${n.channel.tag}${n.channel.prerelease?` (preid: ${n.channel.prerelease})`:""} | mode: ${n.channel.mode}`),o.info(`Walking through ${s.length} pending release(s). Press Ctrl-C to abort.`);const p=await D(s),m=p.filter(a=>v(a)).length,w=p.filter(a=>a.chosen==="none").length;o.info(""),o.info("Summary:");for(const a of p){const d=v(a)?` (was ${a.release.type})`:"";o.info(` ${a.release.name}: ${a.chosen}${d}`)}if(o.info(""),o.info(`${m} overridden, ${w} skipped, ${p.length-m} accepted as-is.`),r.write){if(m===0){o.info("Nothing to write — every package was accepted as-is.");return}const{textPrompt:a}=await import("./prompts.js"),d=await a("Changelog body for the override change file:","Operator-driven plan adjustment via `vis release plan -i`."),b=n.config.changesDir??j,$=await N(t,i,b,p,d);o.info(`Wrote ${$}`)}},L=async e=>{if(e.options.interactive){await S(e);return}await B({...e,options:{...e.options,bump:void 0,json:!0}})};export{L as default};
|
|
@@ -1,24 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
const
|
|
3
|
-
const nr=ce(import.meta.url),or=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const Oe=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ne=["overrides","pnpm","resolutions"],Ee=["engines","files"],Te=r=>{const e=Z.coerce(r)?.major;return e!==void 0&&e>=10},Pe=r=>{const e=O(r,"pnpm-workspace.yaml");if(!z(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:de(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},De=(r,e)=>{let n={};return e==="deno"?{overrides:{},source:"package.json"}:(e==="pnpm"?n=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?n=r.resolutions??{}:n=r.overrides??{},{overrides:n,source:"package.json"})},_e=(r,e,n)=>n.name==="pnpm"&&Te(n.version)?Pe(r):De(e,n.name),H=(r,e)=>{const n=e;for(const c of Ne){const i=r.indexOf(c);if(i!==-1&&c!==n)return n==="overrides"?i:i+1}let o=-1;for(const c of Oe){const i=r.indexOf(c);i>o&&(o=i)}if(o!==-1)return o+1;for(const c of Ee){const i=r.indexOf(c);if(i!==-1)return i}return r.length},Ae=(r,e)=>{const n=O(r,"pnpm-workspace.yaml");if(!z(n))throw new Error(`pnpm-workspace.yaml not found at ${n}. Cannot write overrides for pnpm v10+.`);let o=A(n);const c=`overrides:
|
|
4
|
-
${Object.entries(e).map(([i,l])=>` '${i}': '${l}'`).join(`
|
|
5
|
-
`)}
|
|
6
|
-
`;o=/^overrides:\s*$/m.test(o)||/^overrides:\s*\n/m.test(o)?o.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,c):`${o.trimEnd()}
|
|
7
|
-
|
|
8
|
-
${c}`,_(n,o)},Re=(r,e,n,o,c)=>{const i=A(r),l=le(r,i,{useEditorconfig:c});if(o==="pnpm"){const u=e.pnpm??{};if(u.overrides=n,e.pnpm)e.pnpm=u,_(r,`${JSON.stringify(e,null,l)}
|
|
9
|
-
`);else{const k=Object.keys(e),s=H(k,"pnpm"),d=Object.entries(e);d.splice(s,0,["pnpm",u]),_(r,`${JSON.stringify(Object.fromEntries(d),null,l)}
|
|
10
|
-
`)}}else{const u=o==="yarn"||o==="bun"?"resolutions":"overrides";if(e[u])e[u]=n,_(r,`${JSON.stringify(e,null,l)}
|
|
11
|
-
`);else{const k=Object.keys(e),s=H(k,u),d=Object.entries(e);d.splice(s,0,[u,n]),_(r,`${JSON.stringify(Object.fromEntries(d),null,l)}
|
|
12
|
-
`)}}},Ie=(r,e,n,o,c)=>{if(o.name==="deno")return{added:[],updated:[]};const i=A(e),l=JSON.parse(i),{overrides:u,source:k}=_e(r,l,o),s=[],d=[],m=new Set;if(o.name==="npm")for(const f of["dependencies","devDependencies"]){const x=l[f];if(x)for(const $ of Object.keys(x))m.add($)}for(const f of n){const x=u[f.original];if(typeof x=="object")continue;let $=f.spec;o.name==="npm"&&m.has(f.original)&&($=`$${f.original}`),x!==$&&(x?d.push(f.original):s.push(f.original),u[f.original]=$)}if(s.length===0&&d.length===0)return{added:s,updated:d};const j=Object.fromEntries(Object.entries(u).sort(([f],[x])=>f.localeCompare(x)));return k==="pnpm-workspace.yaml"?Ae(r,j):Re(e,l,j,o.name,c),{added:s,updated:d}},Fe=(r,e)=>{const n={bun:["bun.lock"],deno:["deno.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const o of n[e]??[]){const c=O(r,o);try{return A(c)}catch{continue}}return""},Me=(r,e,n)=>{if(!r)return!1;const o=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(n){case"bun":return r.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${o}@`,"m").test(r);case"deno":return r.includes(`"${e}"`)||r.includes(`"npm:${e}@`)||r.includes(`"jsr:${e}@`);case"npm":return r.includes(`"${e}":`)||r.includes(`"node_modules/${e}":`);case"pnpm":return new RegExp(String.raw`(^|\s|['"/])${o}(@|['"]?:)`,"m").test(r);case"yarn":return new RegExp(String.raw`(^|\s|[",])${o}@`,"m").test(r);default:return!1}};var q={exports:{}},B,X;function K(){if(X)return B;X=1;var r=Object.defineProperty,e=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,c=(s,d)=>{for(var m in d)r(s,m,{get:d[m],enumerable:!0})},i=(s,d,m,j)=>{if(d&&typeof d=="object"||typeof d=="function")for(let f of n(d))!o.call(s,f)&&f!==m&&r(s,f,{get:()=>d[f],enumerable:!(j=e(d,f))||j.enumerable});return s},l=s=>i(r({},"__esModule",{value:!0}),s),u={};c(u,{PURL_Type:()=>k}),B=l(u);var k=(s=>(s.APK="apk",s.BITBUCKET="bitbucket",s.COCOAPODS="cocoapods",s.CARGO="cargo",s.CHROME="chrome",s.COMPOSER="composer",s.CONAN="conan",s.CONDA="conda",s.CRAN="cran",s.DEB="deb",s.DOCKER="docker",s.GEM="gem",s.GENERIC="generic",s.GITHUB="github",s.GOLANG="golang",s.HACKAGE="hackage",s.HEX="hex",s.HUGGINGFACE="huggingface",s.MAVEN="maven",s.MLFLOW="mlflow",s.NPM="npm",s.NUGET="nuget",s.OCI="oci",s.PUB="pub",s.PYPI="pypi",s.QPKG="qpkg",s.RPM="rpm",s.SWID="swid",s.SWIFT="swift",s.VCS="vcs",s))(k||{});return B}var V;function Ge(){return V||(V=1,(function(r){var e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,i=(d,m)=>{for(var j in m)e(d,j,{get:m[j],enumerable:!0})},l=(d,m,j,f)=>{if(m&&typeof m=="object"||typeof m=="function")for(let x of o(m))!c.call(d,x)&&x!==j&&e(d,x,{get:()=>m[x],enumerable:!(f=n(m,x))||f.enumerable});return d},u=(d,m,j)=>(l(d,m,"default"),j&&l(j,m,"default")),k={};i(k,{getManifestData:()=>s}),u(k,K(),r.exports);function s(d,m){try{const j=require("../manifest.json");if(!d)return j;const f=j[d];if(!f)return;if(!m)return f;const x=f.find(([$,g])=>g.package===m);return x?x[1]:void 0}catch{return}}r.exports={getManifestData:s,...K()}})(q)),q.exports}var Le=Ge();const qe=(r,e,n)=>{let o=r;if(e!=="all"&&(o=o.filter(c=>c.category===e)),n){const c=n.toLowerCase();o=o.filter(i=>i.packageName.toLowerCase().includes(c))}return o};class Be{#e;#t=new Set;constructor(e){this.#e={applyProgress:null,checkedEntries:new Set,entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",phase:"browsing",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=e=>(this.#t.add(e),()=>{this.#t.delete(e)});getFilteredEntries=()=>qe(this.#e.entries,this.#e.filterType,this.#e.filterText);#r(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const n=this.getFilteredEntries();this.#e.selectedIndex=n.length===0?-1:Math.max(0,Math.min(e,n.length-1)),this.#r()}toggleCheck(e){const n=new Set(this.#e.checkedEntries);n.has(e)?n.delete(e):n.add(e),this.#e.checkedEntries=n,this.#r()}toggleAll(){const e=this.getFilteredEntries(),n=new Set(this.#e.checkedEntries);if(e.every(o=>n.has(o.packageName)))for(const o of e)n.delete(o.packageName);else for(const o of e)n.add(o.packageName);this.#e.checkedEntries=n,this.#r()}setFilter(e){this.#e.filterType=e,this.#e.selectedIndex=0,this.#r()}setFilterText(e){this.#e.filterText=e,this.#e.selectedIndex=0,this.#r()}setFilterActive(e){this.#e.filterActive=e,this.#r()}setFocusedPanel(e){this.#e.focusedPanel=e,this.#r()}setPhase(e){this.#e.phase=e,this.#r()}setProgress(e,n){this.#e.applyProgress={current:e,total:n},this.#r()}setError(e){this.#e.error=e,this.#e.phase="error",this.#r()}getCheckedEntries(){return this.#e.entries.filter(e=>this.#e.checkedEntries.has(e.packageName))}}const ee={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},Ue={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},ze={"micro-utility":"Trivial utility package that can be replaced with inline code.",native:"Polyfill for a native JS/Node.js API. Use the built-in instead.",preferred:"A lighter or faster alternative package exists.",socket:"Security-hardened replacement from Socket.dev's @socketregistry."},Je=({entry:r,focused:e,scrollRef:n})=>{const o=e?"white":"gray";if(!r)return t.jsx(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(a,{dimColor:!0,children:"No entry selected"})});const c=ee[r.category]??"gray";return t.jsxs(h,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(h,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.packageName})}),t.jsxs(pe,{flexGrow:1,flexShrink:1,paddingX:2,ref:n,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Category:"})}),t.jsx(a,{bold:!0,color:c,children:r.category})]}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Replace with:"})}),t.jsx(a,{children:r.replacement})]}),r.overrideSpec&&t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Override:"})}),t.jsx(a,{color:"cyan",children:r.overrideSpec})]}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Codemod:"})}),t.jsx(a,{color:r.hasCodemod?"green":"gray",children:r.hasCodemod?"available ⚙":"not available"})]}),t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"DESCRIPTION"}),t.jsx(h,{marginTop:1,paddingLeft:2,children:t.jsx(a,{children:ze[r.category]??""})})]}),r.category==="native"&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"green",children:"ACTION"}),t.jsx(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),t.jsx(a,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),t.jsx(a,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),r.category==="socket"&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"cyan",children:"ACTION"}),t.jsxs(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),t.jsx(a,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),(r.category==="preferred"||r.category==="micro-utility")&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"yellow",children:"ACTION"}),t.jsx(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"green",children:["✓"," ","Codemod will rewrite imports to the recommended alternative."]}),t.jsx(a,{dimColor:!0,children:" The original package can then be removed from dependencies."})]}):t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"yellow",children:["ℹ"," ","Manual migration required."]}),r.docUrl?t.jsx(a,{dimColor:!0,children:" Open the migration guide below for the recommended alternative and steps."}):t.jsx(a,{dimColor:!0,children:" Consult the package's docs or the e18e module-replacements guide for an alternative."})]})})]}),t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"LINKS"}),t.jsxs(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{color:"cyan",underline:!0,children:["https://npmx.dev/",r.packageName]}),r.docUrl&&t.jsx(a,{color:"cyan",underline:!0,children:r.docUrl})]})]})]})]})},He=[{key:"all",label:"All",shortcut:"1"},{key:"native",label:"Native",shortcut:"2"},{key:"preferred",label:"Preferred",shortcut:"3"},{key:"micro-utility",label:"Micro",shortcut:"4"},{key:"socket",label:"Socket",shortcut:"5"}],Xe=({checked:r,entry:e,isSelected:n})=>{const o=ee[e.category]??"white",c=Ue[e.category]??e.category,i=r?"☑":"☐",l=e.hasCodemod?"⚙":" ";return t.jsxs(h,{flexShrink:0,height:1,children:[t.jsx(a,{children:n?">":" "}),t.jsxs(a,{color:r?"white":"gray",children:[" ",i," "]}),t.jsx(a,{bold:!0,color:o,children:`[${c}]`.padEnd(9)}),t.jsxs(a,{children:[" ",l," "]}),t.jsx(h,{flexGrow:1,children:t.jsx(a,{bold:n,inverse:n,wrap:"truncate",children:e.packageName})}),t.jsx(a,{dimColor:!0,children:" → "}),t.jsx(a,{wrap:"truncate",children:e.replacement})]})},Ke=({checkedEntries:r,entries:e,filterActive:n,filterText:o,filterType:c,focused:i,isDryRun:l,scrollOffset:u,selectedIndex:k,totalEntries:s,viewportHeight:d})=>{const m=i?"white":"gray";let j=0,f=0,x=0,$=0;for(const C of e)switch(C.category){case"micro-utility":{x++;break}case"native":{j++;break}case"preferred":{f++;break}case"socket":{$++;break}}const g=[];j>0&&g.push(`${j} native`),f>0&&g.push(`${f} preferred`),x>0&&g.push(`${x} micro`),$>0&&g.push(`${$} socket`);const w=g.length>0?` (${g.join(", ")})`:"",b=r.size,T=[];for(const[C,p]of e.entries())T.push(t.jsx(Xe,{checked:r.has(p.packageName),entry:p,isSelected:C===k},p.packageName));const N=e.length,P=N>d&&d>0;return t.jsxs(h,{borderColor:m,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(h,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(a,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),t.jsxs(a,{wrap:"truncate",children:[s," ","optimizations",w]}),!l&&b>0&&t.jsxs(a,{dimColor:!0,children:[" ","—",b," ","selected"]})]}),t.jsx(h,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:He.map(C=>{const p=c===C.key;return t.jsxs(h,{children:[t.jsx(a,{dimColor:!p,children:"["}),t.jsx(a,{bold:p,color:p?"cyan":"gray",children:C.shortcut}),t.jsx(a,{dimColor:!p,children:"]"}),t.jsxs(a,{color:p?"white":"gray",children:[" ",C.label]})]},C.key)})}),n&&t.jsxs(h,{flexShrink:0,paddingX:1,children:[t.jsx(a,{bold:!0,color:"white",children:"/ "}),t.jsx(a,{children:o}),t.jsx(a,{inverse:!0,children:" "})]}),t.jsxs(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(h,{flexDirection:"column",marginTop:-u,children:T})}),P&&t.jsx(h,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(fe,{contentHeight:N,placement:"inset",scrollOffset:u,style:"block",viewportHeight:d})})]})]})},Ve=100,W=10,Y={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},We=({isDryRun:r,store:e})=>{const{exit:n}=he(),{columns:o,rows:c}=ue(),i=D.useSyncExternalStore(e.subscribe,e.getSnapshot),l=D.useRef(null),[u,k]=D.useState(0),[s,d]=D.useState(!1),m=e.getFilteredEntries(),j=m[i.selectedIndex]??null,f=o>=Ve,x=Math.max(0,c-5),$=D.useCallback(g=>{n(g)},[n]);return me((g,w)=>{if(s){g==="y"||g==="Y"?$():d(!1);return}if(i.filterActive){w.escape?(e.setFilterActive(!1),e.setFilterText("")):w.return?e.setFilterActive(!1):w.backspace||w.delete?e.setFilterText(i.filterText.slice(0,-1)):g&&!w.ctrl&&!w.meta&&e.setFilterText(i.filterText+g);return}if(g==="q"){!r&&i.checkedEntries.size>0?d(!0):$();return}if(g==="/"){e.setFilterActive(!0);return}if(Y[g]){e.setFilter(Y[g]);return}if(w.tab){e.setFocusedPanel(i.focusedPanel==="list"?"detail":"list");return}if(i.focusedPanel==="list")if(w.upArrow||g==="k"){const b=Math.max(0,i.selectedIndex-1);e.select(b),b<u&&k(b)}else if(w.downArrow||g==="j"){const b=Math.min(m.length-1,i.selectedIndex+1);e.select(b),b>=u+x&&k(b-x+1)}else g===" "?j&&e.toggleCheck(j.packageName):g==="a"?e.toggleAll():w.return&&!r&&i.checkedEntries.size>0&&$(e.getCheckedEntries());else i.focusedPanel==="detail"&&(w.upArrow||g==="k"?l.current?.scrollBy(-1):(w.downArrow||g==="j")&&l.current?.scrollBy(1))},{isActive:i.phase==="browsing"}),c<W?t.jsx(h,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",W," ","rows."]})}):t.jsxs(h,{flexDirection:"column",height:c,width:o,children:[t.jsxs(h,{flexDirection:f?"row":"column",flexGrow:1,children:[t.jsx(h,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(Ke,{checkedEntries:i.checkedEntries,entries:m,filterActive:i.filterActive,filterText:i.filterText,filterType:i.filterType,focused:i.focusedPanel==="list",isDryRun:r,scrollOffset:u,selectedIndex:i.selectedIndex,totalEntries:i.entries.length,viewportHeight:x})}),t.jsx(h,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(Je,{entry:j,focused:i.focusedPanel==="detail",scrollRef:l})})]}),t.jsx(h,{flexShrink:0,paddingX:1,children:t.jsxs(a,{dimColor:!0,children:[r?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),t.jsx(ge,{autoExitSeconds:3,onCancel:()=>{d(!1)},visible:s})]})},U=(r,e)=>{const n=new Set;try{const o=Q(r),c=e?[o.dependencies,o.optionalDependencies]:[o.dependencies,o.devDependencies,o.peerDependencies,o.optionalDependencies];for(const i of c)if(i)for(const l of Object.keys(i))n.add(l)}catch{}return n},re=r=>{const e=je(r);if(e)return J(r,e);const n=O(r,"package.json");if(!z(n))return[];try{const o=Q(n),c=Array.isArray(o.workspaces)?o.workspaces:o.workspaces?.packages;return c?J(r,c):[]}catch{return[]}},Ye="https://github.com/es-tooling/module-replacements/blob/main/docs/modules",Ze=r=>`${Ye}/${r}.md`,Qe=r=>{if(r.type==="simple"&&r.replacement)return r.replacement;if(r.type==="native"){const e=r.nodeVersion?` (Node ${r.nodeVersion}+)`:"";return r.replacement?`${r.replacement}${e}`:`Native API${e}`}return r.type==="documented"&&r.docPath?"see migration guide":""},te=r=>{const e=[],n=(o,c)=>{const i=o.moduleReplacements;if(Array.isArray(i))for(const l of i)r.has(l.moduleName)&&e.push({category:c,docUrl:l.type==="documented"&&l.docPath?Ze(l.docPath):void 0,hasCodemod:!1,overrideSpec:void 0,packageName:l.moduleName,replacement:Qe(l)})};return n(ve,"native"),n($e,"preferred"),n(we,"micro-utility"),e},ne=(r,e,n,o)=>{const c=Le.getManifestData("npm")??[],i=[];for(const[,l]of c){if(l.deprecated)continue;const u=r.has(l.package),k=e?Me(e,l.package,n.name):!1;if(!u&&!k)continue;const s=Z.coerce(l.version)?.major;if(s===void 0)continue;const d=o?`npm:${l.name}@${l.version}`:`npm:${l.name}@^${String(s)}`;i.push({category:"socket",hasCodemod:!1,overrideSpec:d,packageName:l.package,replacement:l.name})}return i};let G;const oe=async()=>{if(G)return G;try{return G=(await import("module-replacements-codemods")).codemods,G}catch{return{}}},se=async r=>{try{const e=await oe();for(const n of r)n.category!=="socket"&&e[n.packageName]&&(n.hasCodemod=!0)}catch{}},ie=async(r,e,n)=>{let o=0;try{const c=(await oe())[n];if(!c)return{filesChanged:0,packageName:n};const i=c({}),l=await er(e);for(const u of l){const k=A(u);if(k.includes(n))try{const s=await i.transform({file:{filename:u,source:k}});s!==k&&(await r.writeFile(u,s,"utf8"),o++)}catch(s){process.stderr.write(`warn: codemod transform failed for ${u}: ${s instanceof Error?s.message:String(s)}
|
|
13
|
-
`)}}}catch{}return{filesChanged:o,packageName:n}},er=async r=>Se("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:r,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),rr=async({fs:r,logger:e,options:n,visConfig:o,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=be(c),l=!!n.dryRun,u=!!n.prod,k=!!n.pin;y.info(`Detected ${i.name} v${i.version}.`);const s=U(O(c,"package.json"),u),d=re(c),m=new Set(s);for(const p of d){const R=U(O(ae(c,p),"package.json"),u);for(const E of R)m.add(E)}d.length>0&&y.info(`Scanned ${String(d.length)} workspace package${d.length===1?"":"s"}.`),y.info(`Scanning dependencies...
|
|
14
|
-
`);const j=Fe(c,i.name),f=te(m),x=ne(m,j,i,k),$=new Set(f.map(p=>p.packageName)),g=x.filter(p=>!$.has(p.packageName)),w=[...f,...g];if(await se(w),w.length===0){y.info("No optimizations found for your dependencies.");return}const b=!!process.stdout.isTTY&&!ke,T=n.format==="json"||!!n.json;if(b&&!l&&!T){const p=new Be(w),R=await xe(ye.createElement(We,{isDryRun:!1,store:p}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),E=Array.isArray(R)?R:[];if(E.length===0){y.info("No optimizations selected.");return}const I=E.filter(v=>v.category!=="socket"&&v.hasCodemod),F=E.filter(v=>v.category!=="socket"&&!v.hasCodemod),L=E.filter(v=>v.category==="socket");if(I.length>0){y.info(`
|
|
15
|
-
Running ${String(I.length)} codemod${I.length===1?"":"s"}...
|
|
16
|
-
`);for(const v of I){const S=await ie(r,c,v.packageName);S.filesChanged>0?y.success(` ${v.packageName}: ${String(S.filesChanged)} file${S.filesChanged===1?"":"s"} updated`):y.info(` ${v.packageName}: no files changed`)}}if(F.length>0){y.warn(`
|
|
17
|
-
${String(F.length)} selected replacement${F.length===1?"":"s"} require manual migration (no codemod available):`);for(const v of F)y.info(` ${v.packageName} → ${v.replacement}`);y.notice(" Replace usage in your source code, then remove from dependencies.")}if(L.length>0){const v=L.filter(M=>M.overrideSpec).map(M=>({original:M.packageName,spec:M.overrideSpec})),S=Ie(c,O(c,"package.json"),v,i,o?.editorconfig??!0);S.added.length>0&&y.success(`
|
|
18
|
-
Added ${String(S.added.length)} override${S.added.length===1?"":"s"}.`),S.updated.length>0&&y.success(`Updated ${String(S.updated.length)} override${S.updated.length===1?"":"s"}.`)}if(L.length>0&&n.install!==!1){y.info(`
|
|
19
|
-
Running ${i.name} install to update lockfile...`);const v=Ce(i,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},c,e);v!==0&&y.warn(`${i.name} install exited with code ${String(v)}. Run it manually.`)}y.info(""),y.success("Optimization complete.");return}if(T){process.stdout.write(`${JSON.stringify({e18e:f.map(p=>({category:p.category,hasCodemod:p.hasCodemod,packageName:p.packageName,replacement:p.replacement})),packageManager:i.name,socket:g.map(p=>({overrideSpec:p.overrideSpec,packageName:p.packageName,replacement:p.replacement})),total:w.length,workspaces:d.length},void 0,2)}
|
|
20
|
-
`);return}const N=f.filter(p=>p.category==="native"),P=f.filter(p=>p.category==="preferred"),C=f.filter(p=>p.category==="micro-utility");if(N.length>0){y.info(`Native replacements (${String(N.length)}):`);for(const p of N)y.info(` ${p.hasCodemod?"⚙":" "} ${p.packageName} → ${p.replacement}`)}if(P.length>0){y.info(`
|
|
21
|
-
Preferred alternatives (${String(P.length)}):`);for(const p of P)y.info(` ${p.hasCodemod?"⚙":" "} ${p.packageName} → ${p.replacement}`)}if(C.length>0){y.info(`
|
|
22
|
-
Micro-utilities (${String(C.length)}):`);for(const p of C)y.info(` ${p.hasCodemod?"⚙":" "} ${p.packageName} → ${p.replacement}`)}if(g.length>0){y.info(`
|
|
23
|
-
Socket.dev overrides (${String(g.length)}):`);for(const p of g)y.info(` ${p.packageName} → ${p.overrideSpec}`)}y.info(`
|
|
24
|
-
Total: ${String(w.length)} optimizations available (⚙ = codemod available).`),l&&y.notice("Run without --dry-run for interactive selection.")},hr=Object.defineProperty({__proto__:null,buildE18eEntries:te,buildSocketEntries:ne,collectDepsFromPkgJson:U,default:rr,discoverWorkspacePackages:re,markCodemodAvailability:se,runCodemod:ie},Symbol.toStringTag,{value:"Module"});export{re as A,te as F,ie as I,Fe as N,ne as T,se as U,Ie as a,hr as h,U as x};
|
|
1
|
+
import{b as m}from"./orchestrator.js";const u=a=>a==="major"||a==="minor"||a==="patch"||a==="none",d=async({logger:a,options:i,workspaceRoot:p})=>{const l=p??process.cwd();let r;try{r=await m({channel:i.channel,cwd:l,skipRegistryLookup:!0})}catch(e){a.error(`Failed to load release context: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}const{printConfigIfRequested:c}=await import("./print-config.js");if(c(i,r,a))return;let{releases:o}=r.plan;if(i.bump){const e=i.bump.split(",").map(n=>n.trim()).filter(u);e.length>0&&(o=o.filter(n=>e.includes(n.type)))}if(i.filter){const e=(await import("./index.js")).default;o=o.filter(n=>e(i.filter,n.name))}if(i.json){const e={branch:r.branch,channel:r.channel,consumedChangeFiles:r.plan.consumedChangeFiles.map(n=>n.path),releases:o.map(n=>({isCascadeBump:n.isCascadeBump,isDependencyBump:n.isDependencyBump,isGroupBump:n.isGroupBump,name:n.name,newVersion:n.newVersion,oldVersion:n.oldVersion,reasons:n.reasons,type:n.type})),warnings:r.plan.warnings};process.stdout.write(`${JSON.stringify(e,null,2)}
|
|
2
|
+
`),o.length===0&&(process.exitCode=1);return}if(o.length===0){if(a.info("No pending releases."),r.plan.warnings.length>0){a.warn(`${r.plan.warnings.length} warning(s):`);for(const e of r.plan.warnings)a.warn(` - ${e}`)}process.exitCode=1;return}r.channel&&a.info(`Channel: ${r.channel.tag}${r.channel.prerelease?` (preid: ${r.channel.prerelease})`:""} | mode: ${r.channel.mode}`),a.info(`${o.length} package(s) pending release:`),a.info("");const t={major:[],minor:[],none:[],patch:[]};for(const e of o)t[e.type].push(e);for(const e of["major","minor","patch"])if(t[e].length!==0){a.info(` ${e.toUpperCase()}:`);for(const n of t[e]){const s=[];n.isCascadeBump&&s.push("cascade"),n.isGroupBump&&s.push("group"),n.isDependencyBump&&!n.isCascadeBump&&s.push("dep-bump");const f=s.length>0?` [${s.join(", ")}]`:"";a.info(` ${n.name}: ${n.oldVersion} → ${n.newVersion}${f}`)}}if(r.plan.warnings.length>0){a.info(""),a.warn(`${r.plan.warnings.length} warning(s):`);for(const e of r.plan.warnings)a.warn(` - ${e}`)}};export{d as default};
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)?`\r
|
|
3
|
-
`:`
|
|
4
|
-
`,n=a.filter(d=>d.catalogName==="default").sort((d,g)=>d.depName.localeCompare(g.depName));if(n.length===0)return;const s=t.length>0?t.split(r):[],i=s.findIndex(d=>/^catalog\s*:\s*$/.test(d));if(i===-1){const d=["catalog:"];for(const y of n)d.push(` ${y.depName}: "${y.specifier}"`);let g=0;for(;g<s.length&&(s[g]??"").trim().length===0;)g+=1;const h=[...s.slice(0,g),...d,"",...s.slice(g)].join(r);return z(o,h.endsWith(r)?h:`${h}${r}`),o}let p=s.length;const c=new Set;for(let d=i+1;d<s.length;d+=1){const g=s[d]??"",h=g.trimStart();if(g.length===0)continue;if(g.length-h.length===0&&h.length>0&&!h.startsWith("#")){p=d;break}const y=/^([\w./@-]+)\s*:/.exec(h);y?.[1]&&c.add(y[1])}const f=[];for(const d of n)c.has(d.depName)||f.push(` ${d.depName}: "${d.specifier}"`);if(f.length===0)return;const m=[...s.slice(0,p),...f,...s.slice(p)].join(r);return z(o,m.endsWith(r)?m:`${m}${r}`),o},De=(e,a)=>{if(a.length===0)return"";const o=j(e,"pnpm-workspace.yaml"),t=A(o)?H(o,"utf8"):"",r=[...a].sort((i,p)=>i.depName.localeCompare(p.depName)),n=["--- pnpm-workspace.yaml","+++ pnpm-workspace.yaml"],s=t.includes(`\r
|
|
5
|
-
`)?`\r
|
|
6
|
-
`:`
|
|
7
|
-
`;if((t.length>0?t.split(s):[]).findIndex(i=>/^catalog\s*:\s*$/.test(i))===-1){n.push("@@ +1 @@","+catalog:");for(const i of r)n.push(`+ ${i.depName}: "${i.specifier}"`)}else{n.push("@@ catalog: @@");for(const i of r)n.push(`+ ${i.depName}: "${i.specifier}"`)}return n.join(s)},ve=e=>{const a=[],o=oe(e);if(o){const r=j(e,"pnpm-workspace.yaml");for(const n of o)n.startsWith("!")||L(e,[n]).length===0&&a.push({pattern:n,source:"pnpm-workspace.yaml",sourcePath:r})}const t=j(e,"package.json");if(A(t)){const r=S(t).workspaces,n=Array.isArray(r)?r:r?.packages;if(n)for(const s of n)typeof s!="string"||s.startsWith("!")||L(e,[s]).length===0&&a.push({pattern:s,source:"package.json",sourcePath:t})}return a},Ne=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.sourcePath);s?s.push(n):t.set(n.sourcePath,[n])}const r=[];for(const[n,s]of t){const i=new Set(s.map(f=>f.pattern));if(n.endsWith(".yaml")||n.endsWith(".yml")){const f=ee(n).split(`
|
|
8
|
-
`).filter(m=>{const d=m.trim();if(!d.startsWith("- "))return!0;const g=d.slice(2).replaceAll(/^['"]|['"]$/g,"");return!i.has(g)}).join(`
|
|
9
|
-
`);te(n,f,{overwrite:!0}),r.push(n);continue}const p=S(n),c=p.workspaces;Array.isArray(c)?p.workspaces=c.filter(f=>typeof f!="string"||!i.has(f)):c&&Array.isArray(c.packages)&&(c.packages=c.packages.filter(f=>typeof f!="string"||!i.has(f))),R(n,p,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},be=["dependencies","devDependencies","peerDependencies","optionalDependencies"],xe=(e,a={})=>{const o=new Set(a.ignoreBlocks),t=se(e),r=[];for(const n of t){const s=j(e,n,"package.json"),i=C(s);if(!i)continue;const p=typeof i.name=="string"?i.name:void 0;for(const c of be){if(o.has(c))continue;const f=i[c];typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).length===0&&r.push({depType:c,packageDir:n,packageJsonPath:s,packageName:p})}}return r},Je=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.packageJsonPath);s?s.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,s]of t){const i=S(n);for(const p of s){const c=i[p.depType];typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.keys(c).length===0&&Reflect.deleteProperty(i,p.depType)}R(n,i,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},Te=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Se=(e,a={})=>{const o=new Set(a.depTypes??Te),t=new Set(a.ignoreDeps),r=new Map;for(const s of e)s.packageDir!=="."||!o.has(s.depType)||r.set(s.depName,{depType:s.depType,specifier:s.specifier});if(r.size===0)return[];const n=[];for(const s of e){if(s.packageDir==="."||!o.has(s.depType)||t.has(s.depName))continue;const i=r.get(s.depName);i&&n.push({childSpecifier:s.specifier,depName:s.depName,depType:s.depType,packageDir:s.packageDir,packageJsonPath:s.packageJsonPath,packageName:s.packageName,rootDepType:i.depType,rootSpecifier:i.specifier})}return n},Me=(e,a)=>{if(!a)return[];const o=j(e,"package.json"),t=C(o);if(!t)return[];if(t.private!==!0)return[];const r=t.dependencies;if(typeof r!="object"||r===null||Array.isArray(r))return[];const n=Object.keys(r);return n.length===0?[]:[{depNames:n,packageJsonPath:o}]},je=(e,a={})=>{const{useEditorconfig:o}=a,t=[];for(const r of e){const n=S(r.packageJsonPath),s=n.dependencies;if(typeof s!="object"||s===null)continue;const i=s;n.devDependencies??={};const p=n.devDependencies;for(const c of r.depNames){const f=i[c];typeof f=="string"&&(c in p||(p[c]=f),Reflect.deleteProperty(i,c))}Object.keys(i).length===0&&Reflect.deleteProperty(n,"dependencies"),R(r.packageJsonPath,n,{indent:E(r.packageJsonPath,{useEditorconfig:o}),overwrite:!0}),t.push(r.packageJsonPath)}return t},We=/^[a-z][\w-]*@\S+$/i,Re=(e,a,o={})=>{if(!a)return[];const t=j(e,"package.json"),r=C(t);if(!r)return[];const n=r.packageManager;return typeof n=="string"&&We.test(n)?[]:[{packageJsonPath:t,suggested:o.suggested}]},Ee=(e,a={})=>{const{useEditorconfig:o}=a,t=[];for(const r of e){if(!r.suggested)continue;const n=S(r.packageJsonPath);n.packageManager=r.suggested,R(r.packageJsonPath,n,{indent:E(r.packageJsonPath,{useEditorconfig:o}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ie=(e,a)=>{if(!a)return[];const o=j(e,"package.json"),t=C(o);return t?t.private===!0?[]:[{packageJsonPath:o,rawValue:t.private}]:[]},Fe=(e,a={})=>{const{useEditorconfig:o}=a,t=[];for(const r of e){const n=S(r.packageJsonPath);let s=n;if("private"in n)n.private=!0;else{const{name:i,version:p,...c}=n,f={};i!==void 0&&(f.name=i),p!==void 0&&(f.version=p),f.private=!0;for(const[m,d]of Object.entries(c))f[m]=d;s=f}R(r.packageJsonPath,s,{indent:E(r.packageJsonPath,{useEditorconfig:o}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ve=[{id:"react",label:"React",members:["react","react-dom","react-test-renderer"]},{id:"next",label:"Next.js",members:["next","@next/font","@next/bundle-analyzer","@next/mdx","@next/third-parties","@next/eslint-plugin-next","eslint-config-next"]},{id:"babel",label:"Babel",prefixes:["@babel/"]},{id:"storybook",label:"Storybook",members:["storybook","sb"],prefixes:["@storybook/"]},{id:"vitest",label:"Vitest",members:["vitest"],prefixes:["@vitest/"]},{id:"playwright",label:"Playwright",members:["playwright","@playwright/test"]},{id:"trpc",label:"tRPC",prefixes:["@trpc/"]},{id:"prisma",label:"Prisma",members:["prisma"],prefixes:["@prisma/"]},{id:"turborepo",label:"Turborepo",members:["turbo","turbo-ignore","@turbo/gen","eslint-config-turbo","eslint-plugin-turbo"]},{id:"typescript-eslint",label:"typescript-eslint",members:["typescript-eslint"],prefixes:["@typescript-eslint/"]},{id:"eslint-stylistic",label:"ESLint Stylistic",prefixes:["@stylistic/"]},{id:"lexical",label:"Lexical",members:["lexical"],prefixes:["@lexical/"]},{id:"nx",label:"Nx",prefixes:["@nx/","@nrwl/"]}],Ae=new Set(["dependencies","devDependencies","peerDependencies"]),Ce=(e,a)=>{for(const o of e)if(o.members?.includes(a)||o.prefixes?.some(t=>a.startsWith(t)))return o},_e=e=>e.startsWith("workspace:")||e.startsWith("catalog:"),Oe=(e,a={})=>{const o=new Set(a.ignoreFamilies),t=new Map;for(const i of Ve)t.set(i.id,i);for(const i of a.extraFamilies??[])t.set(i.id,i);const r=[...t.values()],n=new Map;for(const i of e){if(i.isInternal||!Ae.has(i.depType)||_e(i.specifier))continue;const p=Ce(r,i.depName);if(!p||o.has(p.id))continue;const c=n.get(p.id),f={depName:i.depName,depType:i.depType,packageDir:i.packageDir,packageJsonPath:i.packageJsonPath,packageName:i.packageName,specifier:i.specifier};c?c.push(f):n.set(p.id,[f])}const s=[];for(const[i,p]of n){const c=[...new Set(p.map(m=>m.specifier))];if(c.length<2)continue;const f=t.get(i);f&&s.push({family:i,familyLabel:f.label??i,members:p,specifiers:c})}return s},ze=e=>e.startsWith("@types/"),Le=(e,a={})=>{const o=new Set(a.ignoreDeps),t=new Map,r=s=>{const i=t.get(s);if(i!==void 0)return i;try{const p=S(s).private===!0;return t.set(s,p),p}catch{return t.set(s,!1),!1}},n=[];for(const s of e)s.depType==="dependencies"&&ze(s.depName)&&(o.has(s.depName)||r(s.packageJsonPath)&&n.push({childSpecifier:s.specifier,depName:s.depName,packageDir:s.packageDir,packageJsonPath:s.packageJsonPath,packageName:s.packageName}));return n},Be=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.packageJsonPath);s?s.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,s]of t){const i=S(n),p=i.dependencies;if(typeof p!="object"||p===null)continue;const c=p;i.devDependencies??={};const f=i.devDependencies;for(const m of s){const d=c[m.depName];typeof d=="string"&&(m.depName in f||(f[m.depName]=d),Reflect.deleteProperty(c,m.depName))}Object.keys(c).length===0&&Reflect.deleteProperty(i,"dependencies"),R(n,i,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},qe=e=>e.startsWith("workspace:"),Ue=(e,a={})=>{const o=a.fixSpecifier??"workspace:*",t=[];for(const r of e)r.isInternal&&(qe(r.specifier)||t.push({depName:r.depName,depType:r.depType,fix:o,packageDir:r.packageDir,packageJsonPath:r.packageJsonPath,packageName:r.packageName,specifier:r.specifier}));return t},Ye=(e,a,o,t)=>{const r=a.split(".");let n=e;for(let p=0;p<r.length-1;p+=1){const c=r[p],f=n[c];(typeof f!="object"||f===null)&&(n[c]={}),n=n[c]}const s=r.at(-1);let i=n[s];(typeof i!="object"||i===null)&&(i={},n[s]=i),i[o]=t},Ge=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.packageJsonPath);s?s.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,s]of t){const i=S(n);for(const p of s)if(p.depType.includes("."))Ye(i,p.depType,p.depName,p.fix);else{const c=i[p.depType];typeof c=="object"&&c!==null&&(c[p.depName]=p.fix)}R(n,i,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},He=new Set(["dependencies","devDependencies","peerDependencies"]),Ke=e=>e.startsWith("catalog:"),Qe=e=>e.startsWith("workspace:"),Xe=e=>{if(!e.startsWith("catalog:"))return;const a=e.slice(8);return a===""?"default":a},Ze=(e,a)=>{if(e.get("default")?.has(a))return"default";const o=[...e.keys()].filter(t=>t!=="default").sort();for(const t of o)if(e.get(t)?.has(a))return t},et=e=>e==="default"?"catalog:":`catalog:${e}`,tt=(e,a)=>{const o=[...e].sort((r,n)=>(r.packageName??r.packageDir).localeCompare(n.packageName??n.packageDir));let t;for(const r of o){const n=B(r.specifier);if(!n)continue;if(!t){t=r;continue}const s=B(t.specifier);if(!s){t=r;continue}const i=q(s,n),p=q(n,s);(a==="highest"&&i||a==="lowest"&&p)&&(t=r)}if(t)return{canonical:t,canonicalSource:t.packageName??t.packageDir}},ot=(e,a={})=>{const o=a.resolve??"highest",t=new Set(a.ignoreDeps),r=[],n=e.filter(i=>i.isInternal||!He.has(i.depType)||Qe(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),s=new Map;for(const i of n){const p=s.get(i.depName);p?p.push(i):s.set(i.depName,[i])}for(const[i,p]of s){const c=a.pinned?.get(i);if(c!==void 0){for(const g of p)g.specifier!==c&&r.push({canonicalSource:"cli:--pin",depName:i,depType:g.depType,fix:c,packageDir:g.packageDir,packageJsonPath:g.packageJsonPath,packageName:g.packageName,specifier:g.specifier});continue}if(o==="catalog"){const{catalogs:g}=a;if(!g)continue;const h=Ze(g,i);if(!h)continue;const y=et(h);for(const x of p)Xe(x.specifier)!==h&&r.push({canonicalSource:`catalog:${h}`,depName:i,depType:x.depType,fix:y,packageDir:x.packageDir,packageJsonPath:x.packageJsonPath,packageName:x.packageName,specifier:x.specifier});continue}const f=p.filter(g=>!Ke(g.specifier));if(f.length<2||new Set(f.map(g=>g.specifier)).size<=1)continue;const m=tt(f,o);if(!m)continue;const d=m.canonical.specifier;for(const g of f)g.specifier!==d&&r.push({canonicalSource:m.canonicalSource,depName:i,depType:g.depType,fix:d,packageDir:g.packageDir,packageJsonPath:g.packageJsonPath,packageName:g.packageName,specifier:g.specifier})}return r},st=(e,a={})=>{const{useEditorconfig:o}=a,t=new Map;for(const n of e){const s=t.get(n.packageJsonPath);s?s.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,s]of t){const i=S(n);for(const p of s){const c=i[p.depType];typeof c=="object"&&c!==null&&(c[p.depName]=p.fix)}R(n,i,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},nt=e=>{if(A(j(e,"pnpm-workspace.yaml")))return!0;const a=j(e,"package.json");if(!A(a))return!1;try{return S(a).workspaces!==void 0}catch{return!1}},I=(e,a)=>{const o=new Map;for(const t of e){const r=a(t),n=o.get(r);n?n.push(t):o.set(r,[t])}return o},at=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ workspace-protocol: no violations"));return}const r=o?"Fixed":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} workspace-protocol violation${e.length===1?"":"s"}`)));for(const[s,i]of I(e,p=>p.packageName??p.packageJsonPath)){const p=$(a,i[0].packageJsonPath);t.info(` ${P(s)} ${u(`(${p})`)}`);for(const c of i){const f=o?T("→"):v("→");t.info(` ${u(c.depType)} ${c.depName}: ${D(c.specifier)} ${f} ${w(c.fix)}`)}}o||t.info(u(" Run with --fix to rewrite specifiers in place."))},rt=(e,a,o)=>{if(e.length===0){o.info(w("✓ redefine-root: no violations"));return}o.info(v(P(`Found ${String(e.length)} dep${e.length===1?"":"s"} re-declared from root`)));for(const[t,r]of I(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);o.info(` ${P(t)} ${u(`(${n})`)}`);for(const s of r)o.info(` ${u(s.depType)} ${s.depName}: ${D(s.childSpecifier)} ${u(`(root ${s.rootDepType}: ${s.rootSpecifier})`)}`)}o.info(u(" Remove these from child package.json files — root pin will resolve."))},it=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ workspace-versions: no drift"));return}const r=o?"Fixed":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} workspace-version drift${e.length===1?"":"s"}`)));for(const[s,i]of I(e,p=>p.depName)){const p=i[0].fix,c=i[0].canonicalSource;t.info(` ${P(s)} ${u(`canonical: ${p} (from ${c})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),d=f.packageName??m,g=o?T("→"):v("→");t.info(` ${d} ${u(`(${m})`)} ${u(f.depType)}: ${D(f.specifier)} ${g} ${w(f.fix)}`)}}o||t.info(u(" Run with --fix to align drifting specifiers."))},pt=(e,a,o)=>{if(e.length===0){o.info(w("✓ banned-deps: no violations"));return}o.info(D(P(`Found ${String(e.length)} banned dep${e.length===1?"":"s"}`)));for(const[t,r]of I(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);o.info(` ${P(t)} ${u(`(${n})`)}`);for(const s of r){const i=s.replacement?` ${u("→")} ${w(s.replacement)}`:"";o.info(` ${u(s.depType)} ${D(s.depName)}${i}`),o.info(` ${u(s.reason)}`)}}},ct=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ catalog-proposals: nothing worth promoting"));return}const r=o?"Added":"Would add",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} catalog entr${e.length===1?"y":"ies"}`)));for(const s of e)t.info(` ${P(s.depName)}: ${w(s.specifier)} ${u(`(${String(s.instanceCount)} packages agree)`)}`);if(!o){const s=De(a,e);if(s){t.info(""),t.info(u("Proposed pnpm-workspace.yaml changes:"));for(const i of s.split(`
|
|
10
|
-
`))i.startsWith("+")?t.info(w(i)):i.startsWith("-")?t.info(D(i)):t.info(u(i))}t.info(u(" Run with --fix to write these entries to pnpm-workspace.yaml."))}},ft=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ custom-types: no engines / packageManager / volta drift"));return}const r=o?"Fixed":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} custom-type drift${e.length===1?"":"s"}`)));for(const[s,i]of I(e,p=>`${p.customType} ${p.depName}`)){const p=i[0].fix,c=i[0].canonicalSource;t.info(` ${P(s)} ${u(`canonical: ${p} (from ${c})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),d=f.packageName??m,g=o?T("→"):v("→");t.info(` ${d} ${u(`(${m})`)}: ${D(f.specifier)} ${g} ${w(f.fix)}`)}}o||t.info(u(" Run with --fix to align engines/packageManager/volta versions."))},lt=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ empty-deps: no empty dependency blocks"));return}const r=o?"Removed":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} empty dependency block${e.length===1?"":"s"}`)));for(const[s,i]of I(e,p=>p.packageName??p.packageJsonPath)){const p=$(a,i[0].packageJsonPath);t.info(` ${P(s)} ${u(`(${p})`)}`);for(const c of i)t.info(` ${u(c.depType)}: ${D("{}")}`)}o||t.info(u(" Run with --fix to drop empty blocks."))},gt=(e,a,o,t)=>{if(e.length===0){t.info(w('✓ root-private: root package.json is "private": true'));return}const r=o?"Set":"Missing",n=o?T:D;for(const s of e){const i=$(a,s.packageJsonPath);if(t.info(n(P(`${r} "private": true on root ${u(`(${i})`)}`))),!o){const p=s.rawValue===void 0?"absent":JSON.stringify(s.rawValue);t.info(` ${u("current:")} ${D(p)}`)}}o||t.info(u(' Run with --fix to set "private": true.'))},dt=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ root-package-manager: packageManager field present"));return}const r=o?"Set":"Missing",n=o?T:D;for(const s of e){const i=$(a,s.packageJsonPath);t.info(n(P(`${r} packageManager on root ${u(`(${i})`)}`))),!o&&!s.suggested&&t.info(u(" no canonical specifier configured (set policy.rootPackageManager.suggested to enable --fix)"))}o||t.info(u(' e.g. "packageManager": "pnpm@10.32.1"'))},ut=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ root-deps: no runtime dependencies on private root"));return}const r=o?"Moved":"Found",n=o?T:v;for(const s of e){const i=$(a,s.packageJsonPath);t.info(n(P(`${r} ${String(s.depNames.length)} runtime dep${s.depNames.length===1?"":"s"} on private root ${u(`(${i})`)}`)));for(const p of s.depNames)t.info(` ${D(p)}`)}o||t.info(u(" Run with --fix to move them to devDependencies."))},mt=(e,a)=>{if(e.length===0){a.info(w("✓ missing-package-json: every workspace dir has a package.json"));return}a.info(v(P(`Found ${String(e.length)} workspace dir${e.length===1?"":"s"} without a package.json`)));for(const o of e)a.info(` ${D(o.packageDir)}`);a.info(u(" Either delete the directory or scaffold a package.json (vis create)."))},ht=(e,a,o)=>{if(e.length===0){o.info(w("✓ dead-workspace-pattern: every workspace pattern matches at least one package"));return}const t=a?"Removed":"Found",r=a?T:v;o.info(r(P(`${t} ${String(e.length)} unmatched workspace pattern${e.length===1?"":"s"}`)));for(const[n,s]of I(e,i=>i.source)){o.info(` ${P(n)}`);for(const i of s)o.info(` ${D(i.pattern)}`)}a||o.info(u(" Run with --fix to drop dead patterns."))},kt=(e,a,o,t)=>{if(e.length===0){t.info(w("✓ types-in-deps: no @types/* in dependencies of private packages"));return}const r=o?"Moved":"Found",n=o?T:v;t.info(n(P(`${r} ${String(e.length)} @types/* dep${e.length===1?"":"s"} in dependencies`)));for(const[s,i]of I(e,p=>p.packageName??p.packageJsonPath)){const p=$(a,i[0].packageJsonPath);t.info(` ${P(s)} ${u(`(${p})`)}`);for(const c of i)t.info(` ${D(c.depName)} ${u(c.childSpecifier)}`)}o||t.info(u(" Run with --fix to move them to devDependencies."))},yt=(e,a,o)=>{if(e.length===0){o.info(w("✓ similar-deps: every related dep family is in sync"));return}o.info(v(P(`Found ${String(e.length)} family${e.length===1?"":" families"} with version drift`)));for(const t of e){o.info(` ${P(t.familyLabel)} ${u(`(${t.specifiers.join(", ")})`)}`);for(const r of t.members){const n=$(a,r.packageJsonPath),s=r.packageName??n;o.info(` ${s} ${u(`(${n})`)} ${u(r.depType)}: ${D(r.depName)}@${v(r.specifier)}`)}}o.info(u(" Pick a single specifier per family and align by hand — auto-fix is unsafe across name boundaries."))},$t=(e,a,o,t,r)=>{let n=!0;const s=i=>{n||r.info(""),n=!1,i()};t.workspaceProtocol&&s(()=>{at(e.workspaceProtocol??[],a,o.workspaceProtocol,r)}),t.redefineRoot&&s(()=>{rt(e.redefineRoot??[],a,r)}),t.workspaceVersions&&s(()=>{it(e.workspaceVersions??[],a,o.workspaceVersions,r)}),t.customTypes&&s(()=>{ft(e.customTypes??[],a,o.customTypes,r)}),e.catalogProposals!==void 0&&s(()=>{ct(e.catalogProposals??[],a,o.catalogProposals,r)}),t.bannedDeps&&s(()=>{pt(e.bannedDeps??[],a,r)}),t.emptyDeps&&s(()=>{lt(e.emptyDeps??[],a,o.emptyDeps,r)}),t.rootPrivate&&s(()=>{gt(e.rootPrivate??[],a,o.rootPrivate,r)}),t.rootPackageManager&&s(()=>{dt(e.rootPackageManager??[],a,o.rootPackageManager,r)}),t.rootDeps&&s(()=>{ut(e.rootDeps??[],a,o.rootDeps,r)}),t.missingPackageJson&&s(()=>{mt(e.missingPackageJson??[],r)}),t.deadWorkspacePatterns&&s(()=>{ht(e.deadWorkspacePatterns??[],o.deadWorkspacePatterns,r)}),t.typesInDeps&&s(()=>{kt(e.typesInDeps??[],a,o.typesInDeps,r)}),t.similarDeps&&s(()=>{yt(e.similarDeps??[],a,r)})},Pt=(e,a)=>{for(const o of e.workspaceProtocol??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`workspace-protocol ${t} ${o.depType} ${o.depName} ${o.specifier} → ${o.fix}
|
|
11
|
-
`)}for(const o of e.redefineRoot??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`redefine-root ${t} ${o.depType} ${o.depName} ${o.childSpecifier}
|
|
12
|
-
`)}for(const o of e.workspaceVersions??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`workspace-versions ${t} ${o.depType} ${o.depName} ${o.specifier} → ${o.fix}
|
|
13
|
-
`)}for(const o of e.customTypes??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`custom-types ${t} ${o.customType} ${o.depName} ${o.specifier} → ${o.fix}
|
|
14
|
-
`)}for(const o of e.bannedDeps??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`banned-deps ${t} ${o.depType} ${o.depName} ${o.reason}
|
|
15
|
-
`)}for(const o of e.catalogProposals??[])process.stdout.write(`catalog-proposal ${o.catalogName} ${o.depName} ${o.specifier} ${String(o.instanceCount)}
|
|
16
|
-
`);for(const o of e.emptyDeps??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`empty-deps ${t} ${o.depType}
|
|
17
|
-
`)}for(const o of e.rootPrivate??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`root-private ${t}
|
|
18
|
-
`)}for(const o of e.rootPackageManager??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`root-package-manager ${t} ${o.suggested??""}
|
|
19
|
-
`)}for(const o of e.rootDeps??[]){const t=$(a,o.packageJsonPath);for(const r of o.depNames)process.stdout.write(`root-deps ${t} ${r}
|
|
20
|
-
`)}for(const o of e.missingPackageJson??[])process.stdout.write(`missing-package-json ${o.packageDir}
|
|
21
|
-
`);for(const o of e.deadWorkspacePatterns??[])process.stdout.write(`dead-workspace-pattern ${o.source} ${o.pattern}
|
|
22
|
-
`);for(const o of e.typesInDeps??[]){const t=$(a,o.packageJsonPath);process.stdout.write(`types-in-deps ${t} ${o.depName} ${o.childSpecifier}
|
|
23
|
-
`)}for(const o of e.similarDeps??[])for(const t of o.members){const r=$(a,t.packageJsonPath);process.stdout.write(`similar-deps ${o.family} ${r} ${t.depType} ${t.depName} ${t.specifier}
|
|
24
|
-
`)}},wt=(e,a,o,t)=>{const r=s=>({...s,packageJsonPath:$(a,s.packageJsonPath)}),n={fixed:o};if(t.workspaceProtocol){const s=(e.workspaceProtocol??[]).map(i=>r(i));n.workspaceProtocol={issues:s,total:s.length}}if(t.redefineRoot){const s=(e.redefineRoot??[]).map(i=>r(i));n.redefineRoot={issues:s,total:s.length}}if(t.workspaceVersions){const s=(e.workspaceVersions??[]).map(i=>r(i));n.workspaceVersions={issues:s,total:s.length}}if(t.customTypes){const s=(e.customTypes??[]).map(i=>r(i));n.customTypes={issues:s,total:s.length}}if(t.bannedDeps){const s=(e.bannedDeps??[]).map(i=>r(i));n.bannedDeps={issues:s,total:s.length}}if(e.catalogProposals!==void 0){const s=e.catalogProposals;n.catalogProposals={proposals:s,total:s.length}}if(t.emptyDeps){const s=(e.emptyDeps??[]).map(i=>r(i));n.emptyDeps={issues:s,total:s.length}}if(t.rootPrivate){const s=(e.rootPrivate??[]).map(i=>r(i));n.rootPrivate={issues:s,total:s.length}}if(t.rootPackageManager){const s=(e.rootPackageManager??[]).map(i=>r(i));n.rootPackageManager={issues:s,total:s.length}}if(t.rootDeps){const s=(e.rootDeps??[]).map(i=>r(i));n.rootDeps={issues:s,total:s.length}}if(t.missingPackageJson){const s=e.missingPackageJson??[];n.missingPackageJson={issues:s,total:s.length}}if(t.deadWorkspacePatterns){const s=e.deadWorkspacePatterns??[];n.deadWorkspacePatterns={issues:s,total:s.length}}if(t.typesInDeps){const s=(e.typesInDeps??[]).map(i=>r(i));n.typesInDeps={issues:s,total:s.length}}if(t.similarDeps){const s=(e.similarDeps??[]).map(i=>({...i,members:i.members.map(p=>({...p,packageJsonPath:$(a,p.packageJsonPath)}))}));n.similarDeps={issues:s,total:s.length}}process.stdout.write(`${JSON.stringify(n,void 0,2)}
|
|
25
|
-
`)},J=(e,a,o)=>{const t=e[a];return typeof t=="boolean"?t:e[o]===!0},Dt=e=>{const a=e,o=(e.ban?.length??0)>0,t=(e.pin?.length??0)>0,r=J(a,"workspaceProtocol","workspace-protocol"),n=J(a,"redefineRoot","redefine-root"),s=J(a,"bannedDeps","banned-deps"),i=J(a,"workspaceVersions","workspace-versions"),p=J(a,"customTypes","custom-types"),c=J(a,"emptyDeps","empty-deps"),f=J(a,"rootPrivate","root-private"),m=J(a,"rootPackageManager","root-package-manager"),d=J(a,"rootDeps","root-deps"),g=J(a,"missingPackageJson","missing-package-json"),h=J(a,"deadWorkspacePatterns","dead-workspace-patterns"),y=J(a,"typesInDeps","types-in-deps"),x=J(a,"similarDeps","similar-deps");return r||n||s||i||p||c||f||m||d||g||h||y||x||o||t?{bannedDeps:s||o,customTypes:p,deadWorkspacePatterns:h,emptyDeps:c,missingPackageJson:g,redefineRoot:n,rootDeps:d,rootPackageManager:m,rootPrivate:f,similarDeps:x,typesInDeps:y,workspaceProtocol:r,workspaceVersions:i||t}:{bannedDeps:!0,customTypes:!0,deadWorkspacePatterns:!0,emptyDeps:!0,missingPackageJson:!0,redefineRoot:!0,rootDeps:!0,rootPackageManager:!0,rootPrivate:!0,similarDeps:!0,typesInDeps:!0,workspaceProtocol:!0,workspaceVersions:!0}},vt=e=>{const a=new Map;for(const o of e??[]){const t=o.lastIndexOf("@");if(t<=0||t===o.length-1)throw new Error(`Invalid --pin "${o}". Use: name@<specifier> (e.g. react@^18.2.0).`);const r=o.slice(0,t),n=o.slice(t+1);a.set(r,n)}return a},Nt=new Set(["catalog","highest","lowest"]),bt=e=>{if(e===void 0)return"highest";if(!Nt.has(e))throw new Error(`Invalid --resolve "${e}". Use: highest, lowest, or catalog.`);return e},W=(e,a)=>e?a===void 0||a===!0:!1,xt={"custom-types":"policy.customTypes.autofix","workspace-protocol":"policy.workspaceProtocol.autofix","workspace-versions":"policy.workspaceVersions.autofix"},O=(e,a,o,t)=>{const r=xt[a],n=o==="prompt"?`${r} = "prompt" (interactive mode not yet implemented; report-only)`:`${r} = false`,s=`Set "${r}": true (or remove it) to enable rewrites.`;e.warn(`${a}: ${String(t)} issue${t===1?"":"s"} not rewritten — ${n}. ${s}`)},Et=async({logger:e,options:a,visConfig:o,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const r=t,n=a.fix??!1,s=a.format??"human",i=a.quiet??!1;if(!["human","json","minimal"].includes(s))throw new Error(`Invalid --format "${s}". Use: human, json, or minimal.`);const p=Dt(a),c=o?.policy??{},f=o?.editorconfig??!0,m=vt(a.pin),d=a.ban??[];(a.dep!==void 0||a.resolve!==void 0)&&!p.workspaceVersions&&!i&&e.warn("--dep / --resolve only apply to --workspace-versions; ignored.");const g=ne(r),h={},y={catalogProposals:!1,customTypes:!1,deadWorkspacePatterns:!1,emptyDeps:!1,rootDeps:!1,rootPackageManager:!1,rootPrivate:!1,typesInDeps:!1,workspaceProtocol:!1,workspaceVersions:!1},x=nt(r);let N=0;if(p.workspaceProtocol){const l=Ue(g,{fixSpecifier:a.fixSpecifier}),k=W(n,c.workspaceProtocol?.autofix);k&&l.length>0&&(Ge(l,{useEditorconfig:f}),y.workspaceProtocol=!0),h.workspaceProtocol=l,k||(N+=l.length),n&&!k&&l.length>0&&!i&&O(e,"workspace-protocol",c.workspaceProtocol?.autofix,l.length)}if(p.redefineRoot){const l=Se(g,{ignoreDeps:c.redefineRoot?.ignore});h.redefineRoot=l,N+=l.length}if(p.workspaceVersions){const l=bt(a.resolve??c.workspaceVersions?.resolve),k=l==="catalog"?ae(r):void 0;l==="catalog"&&(!k||k.size===0)&&!i&&e.warn("--resolve catalog: no catalog found in pnpm-workspace.yaml or root package.json — nothing to align.");const b=ot(g,{catalogs:k,dep:a.dep,ignoreDeps:c.workspaceVersions?.ignore,pinned:m.size>0?m:void 0,resolve:l}),F=W(n,c.workspaceVersions?.autofix);if(F&&b.length>0&&(st(b,{useEditorconfig:f}),y.workspaceVersions=!0),h.workspaceVersions=b,F||(N+=b.length),n&&!F&&b.length>0&&!i&&O(e,"workspace-versions",c.workspaceVersions?.autofix,b.length),a.proposeMin!==void 0){if(l!=="catalog"&&!i)e.warn("--propose-min only runs under --resolve catalog; ignored.");else if(l==="catalog"){const M=Pe(g,{catalogs:k,ignoreDeps:c.workspaceVersions?.ignore,min:a.proposeMin});F&&M.length>0&&(we(r,M),y.catalogProposals=!0),h.catalogProposals=M}}}if(p.customTypes){const l=c.customTypes?.extraTypes,k=re(l);if(k.length>0){for(const K of k)e.error(`policy.customTypes.${K}`);process.exitCode=1;return}const b=ie(r,l),F=(a.resolve??c.customTypes?.resolve)==="lowest"?"lowest":"highest",M=pe(b,{dep:a.dep,ignoreDeps:c.customTypes?.ignore,resolve:F}),_=W(n,c.customTypes?.autofix);_&&M.length>0&&(ce(M,{useEditorconfig:f}),y.customTypes=!0),h.customTypes=M,_||(N+=M.length),n&&!_&&M.length>0&&!i&&O(e,"custom-types",c.customTypes?.autofix,M.length)}if(p.bannedDeps){const l={...c.bannedDeps};for(const b of d)l[b]={reason:"banned via --ban CLI flag"};Object.keys(l).length===0&&a.bannedDeps&&!i&&e.warn("--banned-deps: no policy.bannedDeps in vis config, nothing to check.");const k=me(g,l);h.bannedDeps=k,N+=k.length}if(p.emptyDeps){const l=xe(r,{ignoreBlocks:c.emptyDeps?.ignoreBlocks}),k=W(n,c.emptyDeps?.autofix);k&&l.length>0&&(Je(l,{useEditorconfig:f}),y.emptyDeps=!0),h.emptyDeps=l,k||(N+=l.length)}if(p.rootPrivate){const l=Ie(r,x),k=W(n,c.rootPrivate?.autofix);k&&l.length>0&&(Fe(l,{useEditorconfig:f}),y.rootPrivate=!0),h.rootPrivate=l,k||(N+=l.length)}if(p.rootPackageManager){const l=Re(r,x,{suggested:c.rootPackageManager?.suggested}),k=W(n,c.rootPackageManager?.autofix);k&&l.some(b=>b.suggested!==void 0)&&(Ee(l,{useEditorconfig:f}),y.rootPackageManager=!0),h.rootPackageManager=l,(!k||!y.rootPackageManager)&&(N+=l.filter(b=>b.suggested===void 0||!y.rootPackageManager).length)}if(p.rootDeps){const l=Me(r,x),k=W(n,c.rootDeps?.autofix);k&&l.length>0&&(je(l,{useEditorconfig:f}),y.rootDeps=!0),h.rootDeps=l,k||(N+=l.length)}if(p.missingPackageJson){const l=fe(r);h.missingPackageJson=l,N+=l.length}if(p.deadWorkspacePatterns){const l=ve(r),k=W(n,c.deadWorkspacePatterns?.autofix);k&&l.length>0&&(Ne(l,{useEditorconfig:f}),y.deadWorkspacePatterns=!0),h.deadWorkspacePatterns=l,k||(N+=l.length)}if(p.typesInDeps){const l=Le(g,{ignoreDeps:c.typesInDeps?.ignore}),k=W(n,c.typesInDeps?.autofix);k&&l.length>0&&(Be(l,{useEditorconfig:f}),y.typesInDeps=!0),h.typesInDeps=l,k||(N+=l.length)}if(p.similarDeps){const l=Oe(g,{extraFamilies:c.similarDeps?.extraFamilies,ignoreFamilies:c.similarDeps?.ignoreFamilies});h.similarDeps=l,N+=l.length}i||(s==="json"?wt(h,r,y,p):s==="minimal"?Pt(h,r):$t(h,r,y,p,e)),N>0&&(process.exitCode=1)};export{Et as default};
|
|
1
|
+
import{DEFAULT_CHANGES_DIR as l}from"./DEFAULT_CLEAN_KEEP.js";import{stageAndCommitFile as g}from"./git.js";import{b as d}from"./orchestrator.js";import{readPreMode as m,buildEnterFile as w,writePreMode as u,preModeFilePath as $}from"./pre-mode.js";import{createShellRunner as h}from"./shell-runner.js";import{VisReleaseError as x}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const v=["enter","exit","status"],k=t=>t===void 0||t===""?"status":v.includes(t)?t:void 0,C=async(t,i,r)=>{const e=i.tag?.[0];if(!e){r.error("`pre enter` requires a tag, e.g.: vis release pre enter alpha"),process.exitCode=1;return}const o=await d({cwd:t,skipRegistryLookup:!0}),s=o.config.changesDir??l,p=await m(t,s);if(p){r.error(`Already in pre-mode (tag "${p.tag}", mode "${p.mode}"). Run \`vis release pre exit\` first if you want to switch tags.`),process.exitCode=1;return}const a=w(e,o.packages.map(c=>({name:c.name,version:c.version}))),n=await u(t,s,a);if(r.info(`Entered pre-mode with tag "${e}". ${Object.keys(a.initialVersions).length} package version(s) snapshot.`),i.commit===!1)r.info(`Run \`git add ${n} && git commit -m 'chore(release): enter pre-mode (${e}) [skip ci]'\` so CI sees the state.`);else{const c=h();try{await g({cwd:t,runner:c},n,`chore(release): enter pre-mode (${e}) [skip ci]`,{author:o.config.gitUser,push:i.push!==!1,sign:o.config.gitSignCommits===!0}),r.info(`Committed ${n}${i.push===!1?"":" + pushed"}.`)}catch(f){r.warn(`Could not commit ${n}: ${f.message}`)}}},y=async(t,i,r)=>{const e=await d({cwd:t,skipRegistryLookup:!0}),o=e.config.changesDir??l,s=await m(t,o);if(!s){r.error("Not in pre-mode. Nothing to exit."),process.exitCode=1;return}if(s.mode==="exit-pending"){r.info("Pre-mode already in `exit-pending` state. Run `vis release version` to consolidate.");return}if(e.channel?.prerelease!==void 0)throw new x({code:"CONFIG_INVALID",hint:`Switch to a non-prerelease branch (one whose channel has no \`prerelease\` set) before running \`vis release pre exit\`, or stay in pre-mode by skipping the exit. Current channel "${e.channel.tag}" pins prerelease "${e.channel.prerelease}".`,message:`Refusing to exit pre-mode: the active channel "${e.channel.tag}" has its own prerelease identifier "${e.channel.prerelease}". Exiting would create an unrecoverable state — the next \`vis release version\` would still produce a prerelease via the channel, but the cleanup would delete pre.json making retry impossible.`});const p={...s,mode:"exit-pending"},a=await u(t,o,p);if(r.info("Pre-mode flagged for exit. The next `vis release version` will consolidate the prereleases and delete pre.json."),i.commit!==!1){const n=h();try{await g({cwd:t,runner:n},a,`chore(release): exit pre-mode (was ${s.tag}) [skip ci]`,{author:e.config.gitUser,push:i.push!==!1,sign:e.config.gitSignCommits===!0}),r.info(`Committed ${a}${i.push===!1?"":" + pushed"}.`)}catch(c){r.warn(`Could not commit ${a}: ${c.message}`)}}},b=async(t,i)=>{const r=(await d({cwd:t,skipRegistryLookup:!0})).config.changesDir??l,e=await m(t,r);if(!e){i.info("Pre-mode: off.");return}i.info(`Pre-mode: ${e.mode==="pre"?"ACTIVE":"EXIT-PENDING"} (tag "${e.tag}", entered ${e.enteredAt})`),i.info(` → ${$(t,r)}`),i.info(` → ${Object.keys(e.initialVersions).length} package version(s) snapshot at enter time.`)},N=async({logger:t,options:i,workspaceRoot:r})=>{const e=r??process.cwd(),o=k(i.action);if(o===void 0){t.error(`Unknown action "${i.action}". Expected one of: enter, exit, status.`),process.exitCode=1;return}if(o==="enter"){await C(e,i,t);return}if(o==="exit"){await y(e,i,t);return}await b(e,t)};export{N as default};
|