@visulima/vis 1.0.0-alpha.36 → 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 +13 -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-C0Vj3XF8.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 +53 -11
- 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 +1 @@
|
|
|
1
|
-
import{I as t,x as i}from"../packem_shared/pm-runner-
|
|
1
|
+
import{I as t,x as i}from"../packem_shared/pm-runner-OGResYrA.js";const l=async({logger:e,options:a,visConfig:o,workspaceRoot:n})=>{const c=n??process.cwd(),r=t(c,{configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),s=i(r,a.check||!1,c,e);s!==0&&(process.exitCode=s)};export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as f,$ as k}from"../packem_shared/pm-runner-
|
|
1
|
+
import{I as f,$ as k}from"../packem_shared/pm-runner-OGResYrA.js";const h=async({argument:n,logger:i,options:a,visConfig:s,workspaceRoot:r})=>{const e=n;if(!e||e.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[l,...g]=e,o=r??process.cwd(),t=f(o,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),p=a.package?Array.isArray(a.package)?a.package:[a.package]:[],c=k(t,{additionalPackages:p,args:g,package:l,shellMode:a.shellMode||!1,silent:a.silent||!1},o,i,{offline:a.offline||!1});c!==0&&(process.exitCode=c)};export{h as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as G}from"node:module";import{B as y,y as N}from"../packem_shared/index-BDmTbWX1.js";import{d as O,k as U,P as H,R as F,p as P}from"./heal.js";import{w as D,M as S}from"../packem_shared/pm-runner-
|
|
1
|
+
import{createRequire as G}from"node:module";import{B as y,y as N}from"../packem_shared/index-BDmTbWX1.js";import{d as O,k as U,P as H,R as F,p as P}from"./heal.js";import{w as D,M as S}from"../packem_shared/pm-runner-OGResYrA.js";import{p as a}from"./bin.js";const L=G(import.meta.url),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=e=>{if(typeof _<"u"&&_.versions&&_.versions.node){const[t,o]=_.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return _.getBuiltinModule(e)}return L(e)},{readFile:$}=x("node:fs/promises"),{createInterface:K}=x("node:readline"),j=()=>!!process.stdout.isTTY&&process.env.CI!=="true",V=e=>new Promise(t=>{const o=K({input:process.stdin,output:process.stderr});o.question(`${e} (Y/n) `,i=>{o.close();const s=i.trim().toLowerCase();t(s===""||s==="y"||s==="yes")})}),M=(e,t)=>{const o=D(t),i=S(o,{exact:!1,filter:[],global:!1,optional:!1,packages:[e],peer:!1,saveDev:!1,workspace:!1,workspaceRoot:!1},t,console);return Promise.resolve({exitCode:i})},R=e=>`pnpm add ${e}`,q=e=>e==="@gitbeaker/rest"?import("@gitbeaker/rest"):import("@octokit/rest"),B=async(e,t={})=>{const o=t.interactive??j(),i=t.prompt??V,s=t.runInstall??M,l=t.importImpl??q,d=t.workspaceRoot??process.cwd();try{return await l(e)}catch(n){const{code:p}=n;if(p!=="ERR_MODULE_NOT_FOUND"&&p!=="MODULE_NOT_FOUND")throw n}if(!o)throw new Error(`${e} is not installed. \`vis ai heal accept\` needs it to talk to the host. Install it in your repo first:
|
|
2
2
|
${R(e)}`);if(!await i(`${e} isn't installed. Install it now?`))throw new Error(`${e} install declined. Re-run \`vis ai heal accept\` after installing manually:
|
|
3
3
|
${R(e)}`);const r=await s(e,d);if(r.exitCode!==0)throw new Error(`Install of ${e} failed (exit ${String(r.exitCode)}). Install manually and retry:
|
|
4
4
|
${R(e)}`);return await l(e)},Y=e=>{const t=e.indexOf("/");if(t<=0||t===e.length-1)throw new Error(`Expected GITHUB_REPOSITORY in "owner/repo" form, got: ${e}`);return{owner:e.slice(0,t),repo:e.slice(t+1)}},J=async(e,t)=>{if(t.githubClient)return t.githubClient;const o=(await(t.loadSdk??B)("@octokit/rest")).Octokit;if(!o)throw new TypeError("Loaded `@octokit/rest` but no `Octokit` export was found. Reinstall the package or pin to a supported major.");return new o({auth:e})},W=async(e,t,o)=>{if(o.gitlabClient)return o.gitlabClient;const i=(await(o.loadSdk??B)("@gitbeaker/rest")).Gitlab;if(!i)throw new TypeError("Loaded `@gitbeaker/rest` but no `Gitlab` export was found. Reinstall the package or pin to a supported major.");return new i({host:t,token:e})},z=e=>e.replace(/\/api\/v\d+\/?$/,""),X=async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(w=>$(w,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitHub: GITHUB_REPOSITORY (owner/repo) is not set.");if(!o.token)throw new Error("Cannot commit on GitHub: GITHUB_TOKEN is not set. Grant the workflow `contents: write` and pass the token through.");const{owner:r,repo:n}=Y(o.repo),p=await J(o.token,e),u=(await p.rest.git.getRef({owner:r,ref:`heads/${t}`,repo:n})).data.object.sha,h=(await p.rest.git.getCommit({commit_sha:u,owner:r,repo:n})).data.tree.sha,m=await Promise.all(i.map(async w=>{const C=y(l,w),k=await d(C),b=await p.rest.git.createBlob({content:Buffer.from(k,"utf8").toString("base64"),encoding:"base64",owner:r,repo:n});return{mode:"100644",path:w,sha:b.data.sha,type:"blob"}})),f=await p.rest.git.createTree({base_tree:h,owner:r,repo:n,tree:m}),g=await p.rest.git.createCommit({message:s,owner:r,parents:[u],repo:n,tree:f.data.sha});return await p.rest.git.updateRef({owner:r,ref:`heads/${t}`,repo:n,sha:g.data.sha}),{sha:g.data.sha,url:g.data.html_url}},Q=async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(m=>$(m,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitLab: CI_PROJECT_ID / CI_PROJECT_PATH is not set.");if(!o.token)throw new Error("Cannot commit on GitLab: no token. CI_JOB_TOKEN cannot push commits — set GITLAB_TOKEN to a PAT/project-token with `api` scope.");if(!o.apiBaseUrl)throw new Error("Cannot commit on GitLab: CI_API_V4_URL is not set.");const r=z(o.apiBaseUrl),n=await W(o.token,r,e),p=await Promise.all(i.map(async m=>{const f=y(l,m);return{action:"update",content:await d(f),filePath:m}})),u=await n.Commits.create(o.repo,t,s,p),h=u.id??u.sha;if(!h)throw new Error("GitLab Commits.create returned no commit ID — cannot reference the new commit.");return{sha:h,url:u.web_url??u.webUrl}},Z=async e=>{if(e.files.length===0)throw new Error("Cannot commit: no files to include.");if(e.ciContext.provider==="github-actions")return await X(e);if(e.ciContext.provider==="gitlab-ci")return await Q(e);throw new Error(`Cannot commit: unsupported CI provider \`${e.ciContext.provider}\`. Run \`vis ai heal accept\` from a recognised CI environment.`)},v="/vis heal accept",ee=async e=>{if(!e)return;let t;try{t=await $(e,"utf8")}catch{return}const o=JSON.parse(t),i=o.comment?.body??"",s=o.comment?.user?.login??"",l=o.pull_request?.head?.repo?.full_name,d=o.pull_request?.base?.repo?.full_name??o.repository?.full_name,r=l!==void 0&&d!==void 0&&l!==d;return{actor:s,body:i,headRef:o.pull_request?.head?.ref,isFork:r}},te=e=>{const t=e.VIS_HEAL_TRIGGER_BODY,o=e.VIS_HEAL_TRIGGER_ACTOR;if(!(!t||!o))return{actor:o,body:t,headRef:e.VIS_HEAL_HEAD_REF,isFork:!1}},oe=e=>{const t=e.BUILDKITE_UNBLOCKER_EMAIL??e.BUILDKITE_UNBLOCKER;if(t)return{actor:t,body:v,headRef:e.BUILDKITE_BRANCH,isFork:!1}},re=async(e,t)=>{if(e.provider==="github-actions")return await ee(t.GITHUB_EVENT_PATH);if(e.provider==="gitlab-ci")return te(t);if(e.provider==="buildkite")return oe(t)},ie=(e,t)=>{const o=t.BUILDKITE_REPO;if(!o)return;const i=/(?:^|@|\/\/)github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(o);if(i&&t.GITHUB_TOKEN)return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:e.prNumber,provider:"github-actions",repo:`${i[1]}/${i[2]}`,sha:e.sha,token:t.GITHUB_TOKEN};const s=/\/\/([^/]*gitlab[^/]*)\/([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(o),l=s?null:/@([^/:]*gitlab[^/:]*):([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(o),d=s??l;if(d&&t.GITLAB_TOKEN){const r=d[1];return{apiBaseUrl:t.CI_API_V4_URL??`https://${r}/api/v4`,buildId:void 0,buildNumber:void 0,prNumber:e.prNumber,provider:"gitlab-ci",repo:`${d[2]}/${d[3]}`,sha:e.sha,token:t.GITLAB_TOKEN}}},ae=async e=>{const t=e.fetchImpl??globalThis.fetch,o=`${(e.apiBaseUrl??"https://api.github.com").replace(/\/+$/,"")}/repos/${e.repo}/pulls/${String(e.prNumber)}`;try{const i=await t(o,{headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${e.token}`,"X-GitHub-Api-Version":"2022-11-28"}});return i.ok?(await i.json()).head?.ref:void 0}catch{return}},ne=(e,t,o,i)=>{const s=t.map(l=>`- \`${l}\``).join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as S}from"node:module";import{s as B,j as U,E as I,V as P,I as L}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{y as A}from"../packem_shared/index-BDmTbWX1.js";import{readLastRunSummary as O}from"@visulima/task-runner";import{a as j,r as G,b as K,c as D}from"../packem_shared/ai-fix-
|
|
1
|
+
import{createRequire as S}from"node:module";import{s as B,j as U,E as I,V as P,I as L}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{y as A}from"../packem_shared/index-BDmTbWX1.js";import{readLastRunSummary as O}from"@visulima/task-runner";import{a as j,r as G,b as K,c as D}from"../packem_shared/ai-fix-BPrYoCk8.js";import{p as u,A as H}from"./bin.js";const R=S(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,o]=m.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return m.getBuiltinModule(e)}return R(e)},{spawn:h}=g("node:child_process"),{readFile:F}=g("node:fs/promises"),M=e=>{if(!e)return;const t=/^refs\/pull\/(\d+)\//.exec(e);return t?Number.parseInt(t[1],10):void 0},V=async e=>{if(!e)return{prNumber:void 0,sha:void 0};try{const t=await F(e,"utf8"),o=JSON.parse(t),r=o.pull_request?.number??o.issue?.number??o.number,i=o.pull_request?.head?.sha;return{prNumber:r,sha:i}}catch{return{prNumber:void 0,sha:void 0}}},J=async e=>{const t=M(e.GITHUB_REF),{prNumber:o,sha:r}=t===void 0?await V(e.GITHUB_EVENT_PATH):{prNumber:t,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:t??o,provider:"github-actions",repo:e.GITHUB_REPOSITORY,sha:r??e.GITHUB_SHA,token:e.GITHUB_TOKEN}},q=e=>{const t=e.CI_MERGE_REQUEST_IID,o=t!==void 0&&t!==""?Number.parseInt(t,10):void 0,r=e.CI_API_V4_URL,i=e.GITLAB_TOKEN??e.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:e.CI_PROJECT_ID??e.CI_PROJECT_PATH,sha:e.CI_COMMIT_SHA,token:i}},z=e=>{const t=e.BUILDKITE_PULL_REQUEST,o=t!==void 0&&t!==""&&t!=="false"?Number.parseInt(t,10):void 0,r=e.BUILDKITE_BUILD_NUMBER,i=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=e.BUILDKITE_ORGANIZATION_SLUG,a=e.BUILDKITE_PIPELINE_SLUG,s=n!==void 0&&n!==""&&a!==void 0&&a!==""?`${n}/${a}`:void 0;return{apiBaseUrl:(e.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:e.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(i)?i:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:s,sha:e.BUILDKITE_COMMIT,token:e.BUILDKITE_API_TOKEN}},Q=async(e=process.env)=>e.GITHUB_ACTIONS==="true"?await J(e):e.GITLAB_CI==="true"?q(e):e.BUILDKITE==="true"?z(e):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},Y=(e,t,o,r)=>new Promise(i=>{const n=["pr","comment",String(t),"--body-file","-"];r&&n.push("--repo",r);const a=h(e,n,{stdio:["pipe","ignore","pipe"]});let s="";a.stderr?.setEncoding("utf8"),a.stderr?.on("data",d=>{s+=d}),a.once("error",()=>{i({exitCode:127,stderr:s})}),a.once("close",d=>{i({exitCode:d??-1,stderr:s})}),a.stdin?.on("error",()=>{}),a.stdin?.end(o)}),Z=async(e,t,o,r,i)=>{const n=`https://api.github.com/repos/${t}/issues/${String(o)}/comments`;try{const a=await e(n,{body:JSON.stringify({body:r}),headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"},method:"POST"});if(!a.ok){const s=await a.text().catch(()=>"");return{error:`GitHub REST returned ${String(a.status)}: ${s.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(a){return{error:a instanceof Error?a.message:String(a),ok:!1}}},W=async(e,t,o,r,i,n)=>{const a=encodeURIComponent(o),s=`${t.replace(/\/+$/,"")}/projects/${a}/merge_requests/${String(r)}/notes`;try{const d=await e(s,{body:JSON.stringify({body:i}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const c=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${c.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},X=(e,t,o,r)=>new Promise(i=>{const n=h(e,["annotate","--style",o,"--context",r],{stdio:["pipe","ignore","pipe"]});let a="";n.stderr?.setEncoding("utf8"),n.stderr?.on("data",s=>{a+=s}),n.once("error",()=>{i({exitCode:127,stderr:a})}),n.once("close",s=>{i({exitCode:s??-1,stderr:a})}),n.stdin?.on("error",()=>{}),n.stdin?.end(t)}),tt=async(e,t,o,r,i,n,a,s)=>{const[d,c]=o.split("/",2);if(!d||!c)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const f=`${t}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(c)}/builds/${String(r)}/annotations`;try{const p=await e(f,{body:JSON.stringify({body:i,context:a,style:n}),headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},method:"POST"});if(!p.ok){const l=await p.text().catch(()=>"");return{error:`Buildkite REST returned ${String(p.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(p){return{error:p instanceof Error?p.message:String(p),ok:!1}}},et=async(e,t,o,r)=>{const i=t.buildId?`vis-ai-heal-${t.buildId}`:"vis-ai-heal",n="info",a=await X(o,e,n,i);if(a.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!t.apiBaseUrl||!t.repo||t.buildNumber===void 0||!t.token){const d=[];return t.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),t.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),t.token||d.push("BUILDKITE_API_TOKEN (with `write_build_annotations` scope)"),{error:`buildkite-agent annotate exited ${String(a.exitCode)} (${a.stderr.trim().slice(0,200)}); cannot fall back to REST without ${d.join(", ")}`,method:"buildkite-cli",posted:!1}}const s=await tt(r,t.apiBaseUrl,t.repo,t.buildNumber,e,n,i,t.token);return s.ok?{method:"rest",posted:!0}:{error:`buildkite-agent annotate exited ${String(a.exitCode)}; REST fallback also failed: ${s.error??"unknown"}`,method:"rest",posted:!1}},ot=async(e,t,o,r)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};const i=await Y(o,t.prNumber,e,t.repo);if(i.exitCode===0)return{method:"gh-cli",posted:!0};if(!t.repo||!t.token)return{error:`gh exited ${String(i.exitCode)} (${i.stderr.trim().slice(0,200)}); cannot fall back to REST without GITHUB_REPOSITORY + GITHUB_TOKEN`,method:"gh-cli",posted:!1};const n=await Z(r,t.repo,t.prNumber,e,t.token);return n.ok?{method:"rest",posted:!0}:{error:`gh exited ${String(i.exitCode)}; REST fallback also failed: ${n.error??"unknown"}`,method:"rest",posted:!1}},rt=async(e,t,o)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};if(!t.apiBaseUrl||!t.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!t.token)return{error:"GitLab CI context has no token. CI_JOB_TOKEN cannot post MR notes — set GITLAB_TOKEN to a personal/project access token with `api` scope.",method:"rest",posted:!1};const r=await W(o,t.apiBaseUrl,t.repo,t.prNumber,e,t.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},it=async e=>{const{body:t,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:i=globalThis.fetch,ghBin:n="gh"}=e;return r.provider==="github-actions"?await ot(t,r,n,i):r.provider==="gitlab-ci"?await rt(t,r,i):r.provider==="buildkite"?await et(t,r,o,i):{method:"skipped",posted:!1}},k=e=>{let t=0,o=0;for(const r of e)r.status==="applied"?t+=1:o+=1;return{applied:t,failed:o}},b=(e,t,o)=>{const r=D(e,t,o),i=A(e,r);return i===""||i.startsWith("..")?r:i},nt=(e,t,o,r)=>new Promise(i=>{const n=process.argv[1];if(!n){i({exitCode:-1,stderr:"Cannot locate vis bin (process.argv[1] missing).",stdout:""});return}const a=[n,"run",o,"--projects",t,"--no-cache","--summarize","--fail-fast"],s=h(process.execPath,a,{cwd:e,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",c="";const f=setTimeout(()=>{s.kill("SIGTERM"),setTimeout(()=>s.kill("SIGKILL"),2e3).unref()},r);s.stdout?.setEncoding("utf8"),s.stdout?.on("data",p=>{d+=p}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",p=>{c+=p}),s.once("error",p=>{clearTimeout(f),i({exitCode:-1,stderr:p.message,stdout:d})}),s.once("close",p=>{clearTimeout(f),i({exitCode:p??-1,stderr:c,stdout:d})})}),at=6e4,T=e=>{let t=0;const o=e.match(/`{3,}/g);if(o)for(const r of o)t=Math.max(t,r.length);return"`".repeat(Math.max(3,t+1))},v=(e,t,o)=>{if(e.patches.length===0)return"_No patches proposed._";const r=[];for(const[i,n]of e.patches.entries()){const a=b(t,o,n.file),s=[`**[${String(i+1)}] \`${a}\`**`];n.reason&&s.push(`_${n.reason}_`);const d=T(`${n.oldString}
|
|
2
2
|
${n.newString}`);s.push(`${d}diff`);for(const c of n.oldString.split(`
|
|
3
3
|
`))s.push(`- ${c}`);for(const c of n.newString.split(`
|
|
4
4
|
`))s.push(`+ ${c}`);s.push(d),r.push(s.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as nt}from"node:module";import{U as gt,$ as dt,N as Ke,j as tt,r as Oe,O as U,q as oe,I as mi,s as Ie}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{t as st,o as pe,p as We,L as Jo,b as ht,s as lt,i as vt,n as yt,d as ct,r as bt}from"../packem_shared/index-
|
|
1
|
+
import{createRequire as nt}from"node:module";import{U as gt,$ as dt,N as Ke,j as tt,r as Oe,O as U,q as oe,I as mi,s as Ie}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{t as st,o as pe,p as We,L as Jo,b as ht,s as lt,i as vt,n as yt,d as ct,r as bt}from"../packem_shared/index-D1_fbGbj.js";const at=nt(import.meta.url),be=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ut=i=>{if(typeof be<"u"&&be.versions&&be.versions.node){const[e,o]=be.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return be.getBuiltinModule(i)}return at(i)},{createRequire:rt}=ut("node:module"),pt=/^#?([a-f\d]{3}|[a-f\d]{6})$/i,Fo=i=>{let[,e]=pt.exec(i)??[];const o=e?e.length:0;if(o===3){const a=e.charAt(0),u=e.charAt(1),g=e.charAt(2);e=a+a+u+u+g+g}else if(o!==6)return globalThis.process?.env?.NODE_ENV!=="production"&&console.warn(`[@visulima/colorize] Invalid hex color "${i}"; expected a 3- or 6-digit hex string (e.g. "#96C" or "#E0115F"). Falling back to black.`),[0,0,0];const n=Number.parseInt(e,16);return[n>>16&255,n>>8&255,n&255]},ku=(i,e,o)=>i===e&&e===o?i<8?16:i>248?231:Math.round((i-8)/247*24)+232:16+36*Math.round(i/51)+6*Math.round(e/51)+Math.round(o/51),Ko=i=>{let e,o,n;if(i<8)return 30+i;if(i<16)return 90+(i-8);if(i>=232)e=o=n=((i-232)*10+8)/255;else{i-=16;const g=i%36;e=Math.floor(i/36)/5,o=Math.floor(g/6)/5,n=g%6/5}const a=Math.max(e,o,n)*2;if(a===0)return 30;const u=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(e));return a===2?u+60:u},na=(i,e,o)=>Ko(ku(i,e,o));function wt({onlyFirst:i=!1}={}){const e="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(e,i?void 0:"g")}const Mi=(i,e,o)=>e>i?e:Math.min(i,o),N=39,W=49,aa=10,ua={close:"",open:""},Lu=i=>{const e=i>0?(h,v)=>({close:`\x1B[${String(v)}m`,open:`\x1B[${String(h)}m`}):()=>ua,o=h=>(v,y,c)=>h(ku(Number(v),Number(y),Number(c))),n=h=>v=>{const[y,c,b]=Fo(v);return h(y,c,b)};let a=h=>e(`38;5;${String(h)}`,N),u=h=>e(`48;5;${String(h)}`,W),g=(h,v,y)=>e(`38;2;${String(h)};${String(v)};${String(y)}`,N),d=(h,v,y)=>e(`48;2;${String(h)};${String(v)};${String(y)}`,W);i===1?(a=h=>e(Ko(Number(h)),N),u=h=>e(Ko(Number(h))+aa,W),g=(h,v,y)=>e(na(Number(h),Number(v),Number(y)),N),d=(h,v,y)=>e(na(Number(h),Number(v),Number(y))+aa,W)):i===2&&(g=o(a),d=o(u));const r={bold:e(1,22),dim:e(2,22),hidden:e(8,28),inverse:e(7,27),italic:e(3,23),overline:e(53,55),reset:e(0,0),strike:e(9,29),strikethrough:e(9,29),underline:e(4,24),visible:ua},s={bgBlack:e(40,W),bgBlackBright:e(100,W),bgBlue:e(44,W),bgBlueBright:e(104,W),bgCyan:e(46,W),bgCyanBright:e(106,W),bgGray:e(100,W),bgGreen:e(42,W),bgGreenBright:e(102,W),bgGrey:e(100,W),bgMagenta:e(45,W),bgMagentaBright:e(105,W),bgRed:e(41,W),bgRedBright:e(101,W),bgWhite:e(47,W),bgWhiteBright:e(107,W),bgYellow:e(43,W),bgYellowBright:e(103,W),black:e(30,N),blackBright:e(90,N),blue:e(34,N),blueBright:e(94,N),cyan:e(36,N),cyanBright:e(96,N),gray:e(90,N),green:e(32,N),greenBright:e(92,N),grey:e(90,N),magenta:e(35,N),magentaBright:e(95,N),red:e(31,N),redBright:e(91,N),white:e(37,N),whiteBright:e(97,N),yellow:e(33,N),yellowBright:e(93,N)},l={bg:h=>u(Mi(h,0,255)),bgHex:n(d),bgRgb:(h,v,y)=>d(Mi(h,0,255),Mi(v,0,255),Mi(y,0,255)),fg:h=>a(Mi(h,0,255)),hex:n(g),rgb:(h,v,y)=>g(Mi(h,0,255),Mi(v,0,255),Mi(y,0,255))};return{baseColors:s,baseStyles:r,styleMethods:l}},Zu=gt();dt();Lu(Zu);const jt=(i,e,o)=>{if(e==="")return i;let n=i.indexOf(e);if(n<0)return i;const a=e.length;let u=0,g="";for(;~n;)g+=i.slice(u,n)+o,u=n+a,n=i.indexOf(e,u);return g+i.slice(u)},mt=(i,e,o)=>{if(!i)return"";let n;if(i.raw===void 0?n=String(i):n=String.raw(i,...e),n.includes("\x1B"))for(let a=o;a;a=a.props)n=jt(n,a.close,a.open);return n.includes(`
|
|
2
2
|
`)&&(n=n.replace(/(\r*\n)/g,`${o.closeStack}$1${o.openStack}`)),o.openStack+n+o.closeStack},ft=function(i){const e=i?.level??Zu,{baseColors:o,baseStyles:n,styleMethods:a}=Lu(e),u={};let g=null;const d=({props:s},{close:l,open:h})=>{const v=(s?.openStack??"")+h,y=l+(s?.closeStack??""),c=(b,...p)=>mt(b,p,c.props);return Object.setPrototypeOf(c,g),c.props={close:l,closeStack:y,open:h,openStack:v,props:s},c.open=v,c.close=y,c},r=s=>String(s);r.strip=s=>s.replaceAll(wt(),"");for(const s in o)u[s]={get(){const l=d(this,o[s]);return Object.defineProperty(this,s,{value:l}),l}};for(const s in n)u[s]={get(){const l=d(this,n[s]);return Object.defineProperty(this,s,{value:l}),l}};for(const s in a)u[s]={get(){return(...l)=>d(this,a[s](...l))}};return u.ansi256=u.fg,u.bgAnsi256=u.bg,g=Object.defineProperties({},u),Object.setPrototypeOf(r,g),r},Yt=i=>(e,...o)=>{if(!Array.isArray(e)||!Array.isArray(e.raw))throw new TypeError("A tagged template literal must be provided");const n=[e.raw[0]];for(let a=1;a<e.raw.length;a+=1)n.push(String(o[a-1]).replaceAll(/[{}\\]/g,String.raw`\$&`),String(e.raw[a]));return i(n.join(""))},kt=new Map([["0","\0"],["\\","\\"],["a","\x07"],["b","\b"],["e","\x1B"],["f","\f"],["n",`
|
|
3
3
|
`],["r","\r"],["t"," "],["v","\v"]]),Su=i=>{const e=i.startsWith("u"),o=i[1]==="{";return e&&!o&&i.length===5||i.startsWith("x")&&i.length===3?String.fromCodePoint(Number.parseInt(i.slice(1),16)):e&&o?String.fromCodePoint(Number.parseInt(i.slice(2,-1),16)):kt.get(i)??i},Lt=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi,ga=/(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi,Zt=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,St=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,Jt=/\s*,\s*/,Ct=(i,e)=>{const o=[],n=e.trim().split(Jt);let a;for(const u of n){const g=Number(u);if(!Number.isNaN(g))o.push(g);else if(a=Zt.exec(u))o.push(a[2].replaceAll(St,(d,r,s)=>r?Su(r):s));else throw new Error(`Invalid template style argument: ${u} (in style '${i}')`)}return o},Xt=i=>{ga.lastIndex=0;const e=[];let o;for(;(o=ga.exec(i))!==null;){const n=o[1];o[2]?e.push([n,...Ct(n,o[2])]):o[3]||o[4]?(o[3]&&e.push(["rgb",...Fo(o[3])]),o[4]&&e.push(["bgRgb",...Fo(o[4])])):e.push([n])}return e},da=(i,e)=>{const o={};for(const a of e)for(const u of a.styles)o[u[0]]=a.inverse?void 0:u.slice(1);let n=i;for(const[a,u]of Object.entries(o))if(Array.isArray(u)){if(!(a in n))throw new Error(`Unknown style: ${a}`);n=u.length>0?n[a](...u):n[a]}return n},Ht=i=>e=>{const o=[],n=[];let a=[];if(e.replaceAll(Lt,(u,g,d,r,s,l)=>{if(g)a.push(Su(g));else if(r){const h=a.join("");a=[],n.push(o.length===0?h:da(i,o)(h)),o.push({inverse:d,styles:Xt(r)})}else if(s){if(o.length===0)throw new Error("Found extraneous } in template literal");n.push(da(i,o)(a.join(""))),a=[],o.pop()}else a.push(l)}),n.push(a.join("")),o.length>0)throw new Error(`template literal is missing ${String(o.length)} closing bracket${o.length===1?"":"s"} (\`}\`)`);return n.join("")},Dt=new ft,Tt=Ht(Dt),Bt=Yt(Tt),Qt=rt(import.meta.url),Vi=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xe=i=>{if(typeof Vi<"u"&&Vi.versions&&Vi.versions.node){const[e,o]=Vi.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return Vi.getBuiltinModule(i)}return Qt(i)},{createRequire:Mt}=Xe("node:module"),Ri=Vi,{execFileSync:Gt}=Xe("node:child_process"),Ye=Xe("node:fs"),Nt=Xe("node:tty"),Wt=Xe("node:os"),xt=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Pt=12288,Ft=65510,Kt=[12288,12288,65281,65376,65504,65510],Ot=8361,At=65518,Rt=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],_t=32,zt=10630,Et=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],qt=4352,It=262141,Ju=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],He=(i,e)=>{let o=0,n=Math.floor(i.length/2)-1;for(;o<=n;){const a=Math.floor((o+n)/2),u=a*2;if(e<i[u])n=a-1;else if(e>i[u+1])o=a+1;else return!0}return!1},ta=19968,[Ut,$t]=Vt(Ju);function Vt(i){let e=i[0],o=i[1];for(let n=0;n<i.length;n+=2){const a=i[n],u=i[n+1];if(ta>=a&&ta<=u)return[a,u];u-a>o-e&&(e=a,o=u)}return[e,o]}const ir=i=>i<161||i>1114109?!1:He(xt,i),er=i=>i<Pt||i>Ft?!1:He(Kt,i),or=i=>i<Ot||i>At?!1:He(Rt,i),nr=i=>i<_t||i>zt?!1:He(Et,i),ar=i=>i>=Ut&&i<=$t?!0:i<qt||i>It?!1:He(Ju,i);function ur(i){return ir(i)?"ambiguous":er(i)?"fullwidth":or(i)?"halfwidth":nr(i)?"narrow":ar(i)?"wide":"neutral"}function gr(i){if(!Number.isSafeInteger(i))throw new TypeError(`Expected a code point, got \`${typeof i}\`.`)}function Cu(i){return gr(i),ur(i)}const ra=new Map,dr=i=>[i.ambiguousIsNarrow?1:0,i.control,i.fullWidth,i.regular,i.wide].join("|"),tr=i=>{const e=dr(i.width);let o=ra.get(e);return o||(o=new Map,ra.set(e,o)),o},xe=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Xu=i=>i>=32&&i<=126?"latin":i===8203||i===8204||i===8205||i===8288?"zero":i<=31||i>=127&&i<=159?"control":i>=160&&i<=255||i>=9472&&i<=9599?"latin":i>=4352&&i<=4607||i>=11904&&i<=40959||i>=44032&&i<=55215||i>=63744&&i<=64255||i>=65280&&i<=65519&&!(i>=65377&&i<=65439)||i>=12352&&i<=12543?"wide":i===8230?"latin":"other",rr=(i,e)=>{const o=tr(e),n=Math.floor(i/65536),a=i%65536;let u=o.get(n);if(u||(u=new Map,o.set(n,u)),u.has(a))return u.get(a);let g;switch(Xu(i)){case"control":{g=e.width.control;break}case"latin":{g=e.width.regular;break}case"wide":{g=e.width.wide;break}case"zero":{g=0;break}default:switch(Cu(i)){case"ambiguous":{g=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{g=e.width.fullWidth;break}case"wide":{g=e.width.wide;break}default:g=e.width.regular}}return u.set(a,g),g},sr=i=>i>=768&&i<=879||i>=6832&&i<=6911||i>=7616&&i<=7679||i>=8400&&i<=8447||i>=65056&&i<=65071||i>=917760&&i<=917999||i>=65024&&i<=65039||i>=3633&&i<=3642||i>=3655&&i<=3662||i>=3761&&i<=3769||i>=3771&&i<=3772||i>=3784&&i<=3789||i>=2304&&i<=2307||i>=2362&&i<=2383||i>=2385&&i<=2391||i>=2402&&i<=2403||i>=2433&&i<=2435||i>=2492&&i<=2500||i>=2509&&i<=2509||i>=2561&&i<=2563||i>=2620&&i<=2637||i>=1611&&i<=1631||i>=1648&&i<=1648||i>=1750&&i<=1773||i>=2276&&i<=2302||i>=1425&&i<=1469||i>=1471&&i<=1471||i>=1473&&i<=1474||i>=1476&&i<=1477||i>=1479&&i<=1479||i>=3893&&i<=3893||i>=3895&&i<=3895||i>=3897&&i<=3897||i>=3953&&i<=3966||i>=3968&&i<=3972||i>=3974&&i<=3975?!0:i>=768&&i<=777||i>=803&&i<=803,Oo=(i,e={})=>{if(!i||i.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const o={truncation:{countAnsiEscapeCodes:e.countAnsiEscapeCodes??!1,ellipsis:e.ellipsis??"",ellipsisWidth:e.ellipsisWidth??(e.ellipsis?Oo(e.ellipsis,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:e.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:e.ambiguousIsNarrow??!1,ansi:e.ansiWidth??0,control:e.controlWidth??0,emoji:e.emojiWidth??2,fullWidth:e.fullWidth??2,halfWidth:e.halfWidth??1,regular:e.regularWidth??1,tab:e.tabWidth??8,wide:e.wideWidth??2}},n=Math.max(0,o.truncation.limit-o.truncation.ellipsisWidth),{length:a}=i,u=a>1e4;let g=0,d=0,r=a,s=!1;const l=i.includes("\x1B")||i.includes("");for(;g<a;){if(l&&(i[g]==="\x1B"||i[g]==="")){if(i.startsWith("\x1B]8;;",g)){const p="\x1B]8;;\x07",j=p.length,L=i.indexOf("\x07",g+5);if(L!==-1){const R=i.indexOf(p,L+1);if(R!==-1){const _=R+j,q=i.slice(L+1,R).replace(pe,""),Q=Oo(q,{ambiguousIsNarrow:o.width.ambiguousIsNarrow,ansiWidth:o.width.ansi,controlWidth:o.width.control,countAnsiEscapeCodes:!1,ellipsis:o.truncation.ellipsis,ellipsisWidth:o.truncation.ellipsisWidth,emojiWidth:o.width.emoji,fullWidth:o.width.fullWidth,halfWidth:o.width.halfWidth,limit:Math.max(0,n-d),regularWidth:o.width.regular,tabWidth:o.width.tab,wideWidth:o.width.wide}),I=Q.width;if(Q.truncated)s=!0,r=Math.min(r,g);else if(d+I>n&&(r=Math.min(r,g),s=!0,d+I>o.truncation.limit))break;if(d+=I,g=_,s&&d>=o.truncation.limit)break;continue}}}if(pe.lastIndex=g,pe.test(i)){const p=pe.lastIndex-g,j=o.truncation.countAnsiEscapeCodes?p:o.width.ansi;if(d+j>n&&(r=Math.min(r,g),d+j>o.truncation.limit)){s=!0;break}d+=j,g=pe.lastIndex;continue}}const y=i.codePointAt(g);if(y===8203||y===65279||y>=8288&&y<=8292){g+=1;continue}if(y===9){if(d+o.width.tab>n&&(r=Math.min(r,g),d+o.width.tab>o.truncation.limit)){s=!0;break}d+=o.width.tab,g+=1;continue}if(xe.lastIndex=g,xe.test(i)){const p=(xe.lastIndex-g)*o.width.regular;if(d+p>n){const j=Math.floor((n-d)/o.width.regular);if(r=Math.min(r,g+j),d+p>o.truncation.limit){s=!0;break}}d+=p,g=xe.lastIndex;continue}if((y<=31||y>=127&&y<=159)&&(We.lastIndex=g,We.test(i))){const p=(We.lastIndex-g)*o.width.control;if(d+p>n&&(r=Math.min(r,g+Math.floor((n-d)/o.width.control)),d+p>o.truncation.limit)){s=!0;break}d+=p,g=We.lastIndex;continue}if(Jo.lastIndex=g,Jo.test(i)){if(d+o.width.emoji>n&&(r=Math.min(r,g),d+o.width.emoji>o.truncation.limit)){s=!0;break}d+=o.width.emoji,g=Jo.lastIndex;continue}const c=i.codePointAt(g)??0;if(sr(c)){g+=c>65535?2:1;continue}let b;if(u)b=rr(c,o);else switch(Xu(c)){case"control":{b=o.width.control;break}case"latin":{b=o.width.regular;break}case"wide":{b=o.width.wide;break}case"zero":{b=0;break}default:switch(Cu(c)){case"ambiguous":{b=o.width.ambiguousIsNarrow?o.width.regular:o.width.wide;break}case"fullwidth":{b=o.width.fullWidth;break}case"wide":{b=o.width.wide;break}default:b=o.width.regular}}if(d+b>n&&(r=Math.min(r,g),d+b>o.truncation.limit)){s=!0;break}d+=b,g+=c>65535?2:1}let h=d,v=!1;return s&&o.truncation.limit>=o.truncation.ellipsisWidth&&(h=o.truncation.limit,v=!0),{ellipsed:v,index:s?r:a,truncated:s,width:h}},hr=(i,e={})=>Oo(i,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,lr=Mt(import.meta.url),we=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,vr=i=>{if(typeof we<"u"&&we.versions&&we.versions.node){const[e,o]=we.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return we.getBuiltinModule(i)}return lr(i)};vr("node:util");function yr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Co,sa;function cr(){if(sa)return Co;sa=1,Co=e;function i(n){return n instanceof Buffer?Buffer.from(n):new n.constructor(n.buffer.slice(),n.byteOffset,n.length)}function e(n){if(n=n||{},n.circles)return o(n);const a=new Map;if(a.set(Date,s=>new Date(s)),a.set(Map,(s,l)=>new Map(g(Array.from(s),l))),a.set(Set,(s,l)=>new Set(g(Array.from(s),l))),n.constructorHandlers)for(const s of n.constructorHandlers)a.set(s[0],s[1]);let u=null;return n.proto?r:d;function g(s,l){const h=Object.keys(s),v=new Array(h.length);for(let y=0;y<h.length;y++){const c=h[y],b=s[c];typeof b!="object"||b===null?v[c]=b:b.constructor!==Object&&(u=a.get(b.constructor))?v[c]=u(b,l):ArrayBuffer.isView(b)?v[c]=i(b):v[c]=l(b)}return v}function d(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return g(s,d);if(s.constructor!==Object&&(u=a.get(s.constructor)))return u(s,d);const l={};for(const h in s){if(Object.hasOwnProperty.call(s,h)===!1)continue;const v=s[h];typeof v!="object"||v===null?l[h]=v:v.constructor!==Object&&(u=a.get(v.constructor))?l[h]=u(v,d):ArrayBuffer.isView(v)?l[h]=i(v):l[h]=d(v)}return l}function r(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return g(s,r);if(s.constructor!==Object&&(u=a.get(s.constructor)))return u(s,r);const l={};for(const h in s){const v=s[h];typeof v!="object"||v===null?l[h]=v:v.constructor!==Object&&(u=a.get(v.constructor))?l[h]=u(v,r):ArrayBuffer.isView(v)?l[h]=i(v):l[h]=r(v)}return l}}function o(n){const a=[],u=[],g=new Map;if(g.set(Date,h=>new Date(h)),g.set(Map,(h,v)=>new Map(r(Array.from(h),v))),g.set(Set,(h,v)=>new Set(r(Array.from(h),v))),n.constructorHandlers)for(const h of n.constructorHandlers)g.set(h[0],h[1]);let d=null;return n.proto?l:s;function r(h,v){const y=Object.keys(h),c=new Array(y.length);for(let b=0;b<y.length;b++){const p=y[b],j=h[p];if(typeof j!="object"||j===null)c[p]=j;else if(j.constructor!==Object&&(d=g.get(j.constructor)))c[p]=d(j,v);else if(ArrayBuffer.isView(j))c[p]=i(j);else{const L=a.indexOf(j);L!==-1?c[p]=u[L]:c[p]=v(j)}}return c}function s(h){if(typeof h!="object"||h===null)return h;if(Array.isArray(h))return r(h,s);if(h.constructor!==Object&&(d=g.get(h.constructor)))return d(h,s);const v={};a.push(h),u.push(v);for(const y in h){if(Object.hasOwnProperty.call(h,y)===!1)continue;const c=h[y];if(typeof c!="object"||c===null)v[y]=c;else if(c.constructor!==Object&&(d=g.get(c.constructor)))v[y]=d(c,s);else if(ArrayBuffer.isView(c))v[y]=i(c);else{const b=a.indexOf(c);b!==-1?v[y]=u[b]:v[y]=s(c)}}return a.pop(),u.pop(),v}function l(h){if(typeof h!="object"||h===null)return h;if(Array.isArray(h))return r(h,l);if(h.constructor!==Object&&(d=g.get(h.constructor)))return d(h,l);const v={};a.push(h),u.push(v);for(const y in h){const c=h[y];if(typeof c!="object"||c===null)v[y]=c;else if(c.constructor!==Object&&(d=g.get(c.constructor)))v[y]=d(c,l);else if(ArrayBuffer.isView(c))v[y]=i(c);else{const b=a.indexOf(c);b!==-1?v[y]=u[b]:v[y]=l(c)}}return a.pop(),u.pop(),v}}return Co}var br=cr();const Hu=yr(br);Hu();var Du=typeof global=="object"&&global&&global.Object===Object&&global,pr=typeof self=="object"&&self&&self.Object===Object&&self,O=Du||pr||Function("return this")(),E=O.Symbol,Tu=Object.prototype,wr=Tu.hasOwnProperty,jr=Tu.toString,je=E?E.toStringTag:void 0;function mr(i){var e=wr.call(i,je),o=i[je];try{i[je]=void 0;var n=!0}catch{}var a=jr.call(i);return n&&(e?i[je]=o:delete i[je]),a}var fr=Object.prototype,Yr=fr.toString;function kr(i){return Yr.call(i)}var Lr="[object Null]",Zr="[object Undefined]",ha=E?E.toStringTag:void 0;function V(i){return i==null?i===void 0?Zr:Lr:ha&&ha in Object(i)?mr(i):kr(i)}function x(i){return i!=null&&typeof i=="object"}var Sr="[object Symbol]";function ui(i){return typeof i=="symbol"||x(i)&&V(i)==Sr}var Jr=NaN;function la(i){return typeof i=="number"?i:ui(i)?Jr:+i}function M(i,e){for(var o=-1,n=i==null?0:i.length,a=Array(n);++o<n;)a[o]=e(i[o],o,i);return a}var k=Array.isArray,va=E?E.prototype:void 0,ya=va?va.toString:void 0;function gi(i){if(typeof i=="string")return i;if(k(i))return M(i,gi)+"";if(ui(i))return ya?ya.call(i):"";var e=i+"";return e=="0"&&1/i==-1/0?"-0":e}function eo(i,e){return function(o,n){var a;if(o===void 0&&n===void 0)return e;if(o!==void 0&&(a=o),n!==void 0){if(a===void 0)return n;typeof o=="string"||typeof n=="string"?(o=gi(o),n=gi(n)):(o=la(o),n=la(n)),a=i(o,n)}return a}}var Cr=eo(function(i,e){return i+e},0),Xr=/\s/;function Bu(i){for(var e=i.length;e--&&Xr.test(i.charAt(e)););return e}var Hr=/^\s+/;function Qu(i){return i&&i.slice(0,Bu(i)+1).replace(Hr,"")}function G(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var ca=NaN,Dr=/^[-+]0x[0-9a-f]+$/i,Tr=/^0b[01]+$/i,Br=/^0o[0-7]+$/i,Qr=parseInt;function si(i){if(typeof i=="number")return i;if(ui(i))return ca;if(G(i)){var e=typeof i.valueOf=="function"?i.valueOf():i;i=G(e)?e+"":e}if(typeof i!="string")return i===0?i:+i;i=Qu(i);var o=Tr.test(i);return o||Br.test(i)?Qr(i.slice(2),o?2:8):Dr.test(i)?ca:+i}var ba=1/0,Mr=17976931348623157e292;function Ci(i){if(!i)return i===0?i:0;if(i=si(i),i===ba||i===-ba){var e=i<0?-1:1;return e*Mr}return i===i?i:0}function Z(i){var e=Ci(i),o=e%1;return e===e?o?e-o:e:0}var Gr="Expected a function";function Nr(i,e){if(typeof e!="function")throw new TypeError(Gr);return i=Z(i),function(){if(--i<1)return e.apply(this,arguments)}}function oi(i){return i}var Wr="[object AsyncFunction]",xr="[object Function]",Pr="[object GeneratorFunction]",Fr="[object Proxy]";function Xi(i){if(!G(i))return!1;var e=V(i);return e==xr||e==Pr||e==Wr||e==Fr}var Ae=O["__core-js_shared__"],pa=(function(){var i=/[^.]+$/.exec(Ae&&Ae.keys&&Ae.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function Kr(i){return!!pa&&pa in i}var Or=Function.prototype,Ar=Or.toString;function qi(i){if(i!=null){try{return Ar.call(i)}catch{}try{return i+""}catch{}}return""}var Rr=/[\\^$.*+?()[\]{}|]/g,_r=/^\[object .+?Constructor\]$/,zr=Function.prototype,Er=Object.prototype,qr=zr.toString,Ir=Er.hasOwnProperty,Ur=RegExp("^"+qr.call(Ir).replace(Rr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Mu(i){if(!G(i)||Kr(i))return!1;var e=Xi(i)?Ur:_r;return e.test(qi(i))}function $r(i,e){return i?.[e]}function Ii(i,e){var o=$r(i,e);return Mu(o)?o:void 0}var Le=Ii(O,"WeakMap"),Ue=Le&&new Le,Gu=Ue?function(i,e){return Ue.set(i,e),i}:oi,wa=Object.create,de=(function(){function i(){}return function(e){if(!G(e))return{};if(wa)return wa(e);i.prototype=e;var o=new i;return i.prototype=void 0,o}})();function Ze(i){return function(){var e=arguments;switch(e.length){case 0:return new i;case 1:return new i(e[0]);case 2:return new i(e[0],e[1]);case 3:return new i(e[0],e[1],e[2]);case 4:return new i(e[0],e[1],e[2],e[3]);case 5:return new i(e[0],e[1],e[2],e[3],e[4]);case 6:return new i(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new i(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var o=de(i.prototype),n=i.apply(o,e);return G(n)?n:o}}var Vr=1;function is(i,e,o){var n=e&Vr,a=Ze(i);function u(){var g=this&&this!==O&&this instanceof u?a:i;return g.apply(n?o:this,arguments)}return u}function di(i,e,o){switch(o.length){case 0:return i.call(e);case 1:return i.call(e,o[0]);case 2:return i.call(e,o[0],o[1]);case 3:return i.call(e,o[0],o[1],o[2])}return i.apply(e,o)}var es=Math.max;function Nu(i,e,o,n){for(var a=-1,u=i.length,g=o.length,d=-1,r=e.length,s=es(u-g,0),l=Array(r+s),h=!n;++d<r;)l[d]=e[d];for(;++a<g;)(h||a<u)&&(l[o[a]]=i[a]);for(;s--;)l[d++]=i[a++];return l}var os=Math.max;function Wu(i,e,o,n){for(var a=-1,u=i.length,g=-1,d=o.length,r=-1,s=e.length,l=os(u-d,0),h=Array(l+s),v=!n;++a<l;)h[a]=i[a];for(var y=a;++r<s;)h[y+r]=e[r];for(;++g<d;)(v||a<u)&&(h[y+o[g]]=i[a++]);return h}function ns(i,e){for(var o=i.length,n=0;o--;)i[o]===e&&++n;return n}function oo(){}var as=4294967295;function J(i){this.__wrapped__=i,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=as,this.__views__=[]}J.prototype=de(oo.prototype);J.prototype.constructor=J;function gn(){}var dn=Ue?function(i){return Ue.get(i)}:gn,ne={},us=Object.prototype,gs=us.hasOwnProperty;function Re(i){for(var e=i.name+"",o=ne[e],n=gs.call(ne,e)?o.length:0;n--;){var a=o[n],u=a.func;if(u==null||u==i)return a.name}return e}function li(i,e){this.__wrapped__=i,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=void 0}li.prototype=de(oo.prototype);li.prototype.constructor=li;function ei(i,e){var o=-1,n=i.length;for(e||(e=Array(n));++o<n;)e[o]=i[o];return e}function xu(i){if(i instanceof J)return i.clone();var e=new li(i.__wrapped__,i.__chain__);return e.__actions__=ei(i.__actions__),e.__index__=i.__index__,e.__values__=i.__values__,e}var ds=Object.prototype,ts=ds.hasOwnProperty;function t(i){if(x(i)&&!k(i)&&!(i instanceof J)){if(i instanceof li)return i;if(ts.call(i,"__wrapped__"))return xu(i)}return new li(i)}t.prototype=oo.prototype;t.prototype.constructor=t;function Ao(i){var e=Re(i),o=t[e];if(typeof o!="function"||!(e in J.prototype))return!1;if(i===o)return!0;var n=dn(o);return!!n&&i===n[0]}var rs=800,ss=16,hs=Date.now;function Pu(i){var e=0,o=0;return function(){var n=hs(),a=ss-(n-o);if(o=n,a>0){if(++e>=rs)return arguments[0]}else e=0;return i.apply(void 0,arguments)}}var Fu=Pu(Gu),ls=/\{\n\/\* \[wrapped with (.+)\] \*/,vs=/,? & /;function ys(i){var e=i.match(ls);return e?e[1].split(vs):[]}var cs=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;function bs(i,e){var o=e.length;if(!o)return i;var n=o-1;return e[n]=(o>1?"& ":"")+e[n],e=e.join(o>2?", ":" "),i.replace(cs,`{
|
|
4
4
|
/* [wrapped with `+e+`] */
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
`)&&!e.startsWith(`---\r
|
|
3
|
-
`))return{body:e};const r=e.indexOf(`
|
|
4
|
-
---`,3);if(r===-1)return{body:e};let n=r+1+3;e[n]==="\r"&&(n+=1),e[n]===`
|
|
5
|
-
`&&(n+=1);const i=e.startsWith(`---\r
|
|
6
|
-
`)?5:4,o=e.slice(i,r).replaceAll("\r","");let s;try{s=t(o)}catch(l){const a=l instanceof Error?l.message:String(l);throw new Error(`Failed to parse frontmatter YAML: ${a}`,{cause:l})}if(s==null)return{body:e.slice(n)};if(typeof s!="object"||Array.isArray(s))throw new TypeError(`Frontmatter must be a YAML mapping, got ${Array.isArray(s)?"array":typeof s}`);return{body:e.slice(n),frontmatter:s}},ve=/\{\{-?(.+?)-?\}\}|\{%-?(.+?)-?%\}/gs,q=e=>{const t=[];let r=0,n=1;const i=o=>{for(const s of o)s===`
|
|
7
|
-
`&&(n+=1)};for(const o of e.matchAll(ve)){const s=o.index??0;if(s>r){const c=e.slice(r,s);t.push({line:n,type:"text",value:c}),i(c)}const l=n,a=o[0];a.startsWith("{{")?t.push({line:l,type:"expr",value:(o[1]??"").trim()}):t.push({line:l,type:"stmt",value:(o[2]??"").trim()}),i(a),r=s+a.length}if(r<e.length){const o=e.slice(r);t.push({line:n,type:"text",value:o})}return t},Ae=new Set(["block","endblock","endfilter","endmacro","extends","filter","import","macro","set"]),F=(e,t)=>{let r=0;const n=(o,s)=>{throw new Error(`${t}:${o}: ${s}`)},i=o=>{const s=[];for(;r<e.length;){const l=e[r];if(l.type==="text"){s.push({type:"text",value:l.value}),r+=1;continue}if(l.type==="expr"){s.push({expression:l.value,line:l.line,type:"expr"}),r+=1;continue}const a=l.value.split(/\s+/)[0]??"";if(o.includes(a))return s;if(Ae.has(a)&&n(l.line,`Tera feature "{% ${a} %}" is not supported. Supported: if/else/endif, for/endfor, include. Rewrite the template to avoid macros, set, extends, block, and import.`),a==="if"){r+=1;const c=l.value.slice(2).trim(),p=i(["else","endif"]);let f;r<e.length&&e[r].type==="stmt"&&e[r].value.split(/\s+/)[0]==="else"&&(r+=1,f=i(["endif"])),(r>=e.length||e[r].type!=="stmt"||e[r].value.split(/\s+/)[0]!=="endif")&&n(l.line,"Unterminated {% if %} — missing {% endif %}"),r+=1,s.push({alternate:f,condition:c,consequent:p,line:l.line,type:"if"});continue}if(a==="for"){r+=1;const c=l.value.slice(3).trim(),p=c.indexOf(" in ");p===-1&&n(l.line,"Malformed {% for %} — expected `for <name> in <collection>`");const f=c.slice(0,p).trim(),d=c.slice(p+4).trim();(!f||!d)&&n(l.line,"Malformed {% for %} — missing binding or collection");const u=i(["endfor"]);(r>=e.length||e[r].type!=="stmt"||e[r].value.split(/\s+/)[0]!=="endfor")&&n(l.line,"Unterminated {% for %} — missing {% endfor %}"),r+=1,s.push({binding:f,body:u,collection:d,line:l.line,type:"for"});continue}if(a==="include"){r+=1;const c=l.value.slice(7).trim(),p=G(c);p===void 0&&n(l.line,"Malformed {% include %} — expected a quoted partial name"),s.push({line:l.line,name:p,type:"include"});continue}n(l.line,`Unknown tag "{% ${a} %}". Supported: if, for, include.`)}return s};return i([])},G=e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1)},$e=e=>e==null?"":typeof e=="boolean"||typeof e=="number"?String(e):typeof e=="string"?e:JSON.stringify(e),je=e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:!0,B=(e,t,r,n,i=!0)=>{const o=e.split(".");if(i&&o.length>0&&!Object.hasOwn(t,o[0]))throw new Error(`${n}:${r}: Variable "${e}" is not defined`);let s=t;for(const l of o){if(s==null)return;if(typeof s!="object")throw new TypeError(`${n}:${r}: Cannot read "${l}" on non-object value`);s=s[l]}return s},xe=e=>{const t=[];let r=0,n=0,i;for(let o=0;o<e.length;o+=1){const s=e[o];if(i){s===i&&(i=void 0);continue}if(s==='"'||s==="'"){i=s;continue}s==="("?r+=1:s===")"?r-=1:s==="|"&&r===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t},ke=e=>{const t=e.trim(),r=t.indexOf("(");if(r===-1)return{args:[],name:t};if(!t.endsWith(")"))throw new Error(`Filter call "${e}" missing closing ")"`);const n=t.slice(0,r).trim(),i=t.slice(r+1,-1).trim();return i?{args:R(i).map(o=>o.trim()),name:n}:{args:[],name:n}},v=(e,t,r,n,i=!0)=>{const o=e.trim();if(o==="true")return!0;if(o==="false")return!1;if(o==="null"||o==="none")return null;const s=G(o);return s!==void 0?s:/^-?\d+(?:\.\d+)?$/.test(o)?Number(o):B(o,t,r,n,i)},Y=(e,t,r,n,i=!0)=>{const o=xe(e),s=o[0].trim();let l=v(s,t,r,n,i);for(let a=1;a<o.length;a+=1){const c=o[a].trim(),{args:p,name:f}=ke(c),d=p.map(u=>v(u,t,r,n,i));try{l=z(f,l,d)}catch(u){const y=u instanceof Error?u.message:String(u);throw new Error(`${n}:${r}: ${y}`,{cause:u})}}return l},D=(e,t)=>{let r,n=0;for(let i=0;i<=e.length-t.length;i+=1){const o=e[i];if(r){o===r&&(r=void 0);continue}if(o==='"'||o==="'"){r=o;continue}if(o==="("){n+=1;continue}if(o===")"){n-=1;continue}if(n===0&&e.slice(i,i+t.length)===t)return i}return-1},_=(e,t)=>{const r=[];let n=0,i=0;for(;i<=e.length-t.length;){const o=D(e.slice(i),t);if(o===-1)break;r.push(e.slice(n,i+o)),i+=o+t.length,n=i}return r.push(e.slice(n)),r},g=(e,t,r,n)=>{const i=e.trim();if(i==="")return!1;if(i.startsWith("(")&&i.endsWith(")")&&Se(i)===i.length-1)return g(i.slice(1,-1),t,r,n);const o=_(i," or ");if(o.length>1)return o.some(l=>g(l,t,r,n));const s=_(i," and ");if(s.length>1)return s.every(l=>g(l,t,r,n));if(i.startsWith("not "))return!g(i.slice(4),t,r,n);for(const l of["==","!="]){const a=D(i,l);if(a!==-1){const c=v(i.slice(0,a),t,n,r,!1),p=v(i.slice(a+l.length),t,n,r,!1),f=c===p;return l==="=="?f:!f}}return je(Y(i,t,n,r,!1))},Se=e=>{if(e[0]!=="(")return-1;let t=0,r,n=-1;for(const i of e){if(n+=1,r){i===r&&(r=void 0);continue}if(i==='"'||i==="'"){r=i;continue}if(i==="(")t+=1;else if(i===")"&&(t-=1,t===0))return n}return-1},E=(e,t)=>{let r="";for(const n of e){if(n.type==="text"){r+=n.value;continue}if(n.type==="expr"){r+=$e(Y(n.expression,t.scope,n.line,t.filename));continue}if(n.type==="if"){const i=g(n.condition,t.scope,t.filename,n.line)?n.consequent:n.alternate??[];r+=E(i,t);continue}if(n.type==="for"){const i=B(n.collection,t.scope,n.line,t.filename,!1);if(i==null)continue;if(!Array.isArray(i))throw new TypeError(`${t.filename}:${n.line}: {% for %} expected an array, got ${typeof i}`);for(const o of i){const s={...t.scope,[n.binding]:o};r+=E(n.body,{...t,scope:s})}continue}if(n.type==="include"){const i=t.partials?.get(n.name);if(!i)throw new Error(`${t.filename}:${n.line}: Partial "${n.name}" not found. Available: ${[...t.partials?.keys()??[]].join(", ")||"(none)"}`);const o=t.includeStack??new Set;if(o.has(n.name)){const s=[...o,n.name].join(" → ");throw new Error(`${t.filename}:${n.line}: Circular partial include detected: ${s}`)}o.add(n.name);try{r+=E(i,{...t,filename:`<partial:${n.name}>`,includeStack:o})}finally{o.delete(n.name)}}}return r},Ce=(e,t)=>F(q(e),t),j=(e,t)=>E(F(q(e),t.filename),t),L="template.yml",Oe=".raw",We=new Set([".cjs",".css",".env",".gitattributes",".gitignore",".graphql",".html",".ini",".js",".json",".json5",".jsonc",".jsx",".lock",".md",".mdx",".mjs",".prettierrc",".raw",".rs",".scss",".sh",".sql",".svg",".tera",".toml",".ts",".tsx",".twig",".txt",".vue",".xml",".yaml",".yml"]),Te=new Set(["Brewfile","CHANGELOG","CODEOWNERS","CONTRIBUTING","COPYING","Dockerfile","Gemfile","LICENCE","LICENSE","Makefile","NOTICE","Procfile","Rakefile","README","VERSION"]),_e=e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),r=t===-1?e:e.slice(t+1),n=r.lastIndexOf(".");return n===-1||n===0?"":r.slice(n).toLowerCase()},J=e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t===-1?e:e.slice(t+1)},Le=e=>{const t=_e(e);if(t!=="")return We.has(t);const r=J(e);return Te.has(r)},Me=e=>{const t={default:e.default,internal:e.internal,order:e.order,prompt:e.prompt,required:e.required};switch(e.type){case"array":return{...t,type:"array"};case"boolean":return{...t,default:typeof t.default=="boolean"?t.default:void 0,type:"boolean"};case"enum":return{...t,multiple:e.multiple,type:"enum",values:e.values??[]};case"number":return{...t,type:"number"};case"string":return{...t,type:"string"};default:throw new Error(`Unsupported variable type "${String(e.type)}"`)}},Ue=e=>e.replaceAll("\\","/").replace(/^\.\//,"").replaceAll(/\/+/g,"/"),Ie=(e,t,r)=>{const n=t.split("/").filter(Boolean);if(n.length===0)throw new Error("Empty destination path for value");let i=e;for(let o=0;o<n.length-1;o+=1){const s=n[o],l=i[s];if(l===void 0){const a={};i[s]=a,i=a}else if(typeof l=="object"&&!Buffer.isBuffer(l))i=l;else throw new TypeError(`Path conflict: "${n.slice(0,o+1).join("/")}" is both a file and a directory`)}i[n.at(-1)]=r},M=(e,t,r)=>{if(typeof e!="string")return Ne(e);const n=e.includes("{{")||e.includes("{%")?j(e,{filename:`${r}#frontmatter`,scope:t}):e;return g(n,t,`${r}#frontmatter`,1)},Ne=e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e!=="false"&&e!=="0":!0,qe=(e,t)=>{const r=I(e,L),n=Q(r);if(!n||typeof n!="object")throw new Error(`${r}: must contain a YAML mapping`);const i={};if(n.variables)for(const[a,c]of Object.entries(n.variables))i[a]=Me(c);const o=new Map,s=[];for(const a of K(e,{includeDirs:!1,includeSymlinks:!1})){if(a.path===r)continue;const c=U(e,a.path).replaceAll("\\","/");if(c===L)continue;if(be(c)){const f=b(a.path),d=Ce(f,c);for(const u of ze(c))o.has(u)&&o.get(u)!==d&&X.warn(`partial name "${u}" is declared by multiple files — last one wins. Use distinct names or fully-qualified includes.`),o.set(u,d);continue}if(c.endsWith(Oe)){const f=b(a.path);s.push({binary:null,isRaw:!0,rawText:f,relativePath:c});continue}if(Le(c)){const f=b(a.path);s.push({binary:null,isRaw:!1,rawText:f,relativePath:c});continue}const p=b(a.path,{buffer:!0});s.push({binary:p,isRaw:!1,rawText:null,relativePath:c})}const l=a=>{const c={...a.builtins,...a.options},p={},f={};for(const u of s){const y=u.relativePath;let w,C,O=!1;if(u.binary)w=u.binary;else if(u.isRaw)w=u.rawText??"";else{const V=u.rawText??"",h=Ee(V,H=>Z(H));if(h.frontmatter){if(h.frontmatter.skip!==void 0&&M(h.frontmatter.skip,c,y)||h.frontmatter.if!==void 0&&!M(h.frontmatter.if,c,y))continue;typeof h.frontmatter.to=="string"&&(C=j(h.frontmatter.to,{filename:`${y}#frontmatter.to`,partials:o,scope:c})),h.frontmatter.force===!0&&(O=!0)}w=j(h.body,{filename:y,partials:o,scope:c})}const W=Ue(C??ge(we(y),c));Ie(p,W,w),O&&(f[W]={force:!0})}const d={files:p};return Object.keys(f).length>0&&(d.filesMeta=f),d};return{about:{description:n.description??`Moon-format template at ${e}`,name:n.title??t},destination:n.destination,options:i,produce:l}},ze=e=>{const t=P(e),r=J(t),n=new Set([r,t]);if(r.startsWith("_")){n.add(r.replace(/^_+/,""));const i=t.slice(0,t.length-r.length);n.add(`${i}${r.replace(/^_+/,"")}`)}return[...n]};export{qe as loadMoonTemplate};
|
|
1
|
+
const b=t=>{const e=new Set,n=[t];for(let r=0;r<n.length;r++){const o=n[r];if(e.has(o))continue;e.add(o);const{children:s}=o;if(s?.length)for(let u=0,c=s.length;u<c;u++)n.push(s[u])}return Array.from(e)},tt=t=>{let e="";const n=b(t);for(let r=0,o=n.length;r<o;r++){const s=n[r];if(!s.regex)continue;const u=s.regex.flags;if(e||(e=u),e!==u)throw new Error(`Inconsistent RegExp flags used: "${e}" and "${u}"`)}return e},Z=(t,e,n)=>{const r=n.get(t);if(r!==void 0)return r;const o=t.partial??e;let s="";if(t.regex&&(s+=o?"(?:$|":"",s+=t.regex.source),t.children?.length){const u=nt(t.children.map(c=>Z(c,e,n)).filter(Boolean));if(u?.length){const c=t.children.some(M=>!M.regex||!(M.partial??e)),a=u.length>1||o&&(!s.length||c);s+=a?o?"(?:$|":"(?:":"",s+=u.join("|"),s+=a?")":""}}return t.regex&&(s+=o?")":""),n.set(t,s),s},et=(t,e)=>{const n=new Map,r=b(t);for(let o=r.length-1;o>=0;o--){const s=Z(r[o],e,n);if(!(o>0))return s}return""},nt=t=>Array.from(new Set(t)),j=(t,e,n)=>j.compile(t,n).test(e);j.compile=(t,e)=>{const n=e?.partial??!1,r=et(t,n),o=tt(t);return new RegExp(`^(?:${r})$`,o)};const rt=(t,e)=>{const n=j.compile(t,e),r=`${n.source.slice(0,-1)}[\\\\/]?$`,o=n.flags;return new RegExp(r,o)},ot=t=>{const e=t.map(r=>r.source).join("|")||"$^",n=t[0]?.flags;return new RegExp(e,n)},q=t=>Array.isArray(t),k=t=>typeof t=="function",st=t=>t.length===0,ut=(()=>{const{toString:t}=Function.prototype,e=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return n=>(n.length===0||n.length===1)&&e.test(t.call(n))})(),it=t=>typeof t=="number",ct=t=>typeof t=="object"&&t!==null,lt=t=>t instanceof RegExp,at=(()=>{const t=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return e=>t.test(e.source)})(),ft=(()=>{const t=/^[a-zA-Z0-9_-]+$/;return e=>t.test(e.source)&&!e.flags.includes("i")})(),O=t=>typeof t=="string",h=t=>t===void 0,pt=t=>{const e=new Map;return n=>{const r=e.get(n);if(r!==void 0)return r;const o=t(n);return e.set(n,o),o}},W=(t,e,n={})=>{const r={cache:{},input:t,index:0,indexBacktrackMax:0,options:n,output:[]},o=d(e)(r),s=Math.max(r.index,r.indexBacktrackMax);if(o&&r.index===t.length)return r.output;throw new Error(`Failed to parse at index ${s}`)},i=(t,e)=>q(t)?$t(t,e):O(t)?_(t,e):ht(t,e),$t=(t,e)=>{const n={};for(const r of t){if(r.length!==1)throw new Error(`Invalid character: "${r}"`);const o=r.charCodeAt(0);n[o]=!0}return r=>{const o=r.input;let s=r.index,u=s;for(;u<o.length&&o.charCodeAt(u)in n;)u+=1;if(u>s){if(!h(e)&&!r.options.silent){const c=o.slice(s,u),a=k(e)?e(c,o,`${s}`):e;h(a)||r.output.push(a)}r.index=u}return!0}},ht=(t,e)=>{if(ft(t))return _(t.source,e);{const n=t.source,r=t.flags.replace(/y|$/,"y"),o=new RegExp(n,r);return at(t)&&k(e)&&!ut(e)?dt(o,e):gt(o,e)}},dt=(t,e)=>n=>{const r=n.index,o=n.input;t.lastIndex=r;const s=t.exec(o);if(s){const u=t.lastIndex;if(!n.options.silent){const c=e(...s,o,`${r}`);h(c)||n.output.push(c)}return n.index=u,!0}else return!1},gt=(t,e)=>n=>{const r=n.index,o=n.input;if(t.lastIndex=r,t.test(o)){const s=t.lastIndex;if(!h(e)&&!n.options.silent){const u=k(e)?e(o.slice(r,s),o,`${r}`):e;h(u)||n.output.push(u)}return n.index=s,!0}else return!1},_=(t,e)=>n=>{const r=n.index,o=n.input;if(o.startsWith(t,r)){if(!h(e)&&!n.options.silent){const s=k(e)?e(t,o,`${r}`):e;h(s)||n.output.push(s)}return n.index+=t.length,!0}else return!1},v=(t,e,n,r)=>{const o=d(t),s=e>1;return R(z(L(u=>{let c=0;for(;c<n;){const a=u.index;if(!o(u)||(c+=1,u.index===a))break}return c>=e},s),r))},F=(t,e)=>v(t,0,1,e),E=(t,e)=>v(t,0,1/0,e),xt=(t,e)=>v(t,1,1/0,e),m=(t,e)=>{const n=t.map(d);return R(z(L(r=>{for(let o=0,s=n.length;o<s;o++)if(!n[o](r))return!1;return!0}),e))},p=(t,e)=>{const n=t.map(d);return R(z(r=>{for(let o=0,s=n.length;o<s;o++)if(n[o](r))return!0;return!1},e))},L=(t,e=!0,n=!1)=>{const r=d(t);return e?o=>{const s=o.index,u=o.output.length,c=r(o);return!c&&!n&&(o.indexBacktrackMax=Math.max(o.indexBacktrackMax,o.index)),(!c||n)&&(o.index=s,o.output.length!==u&&(o.output.length=u)),c}:r},z=(t,e)=>{const n=d(t);return e?r=>{if(r.options.silent)return n(r);const o=r.output.length;if(n(r)){const s=r.output.splice(o,1/0),u=e(s);return h(u)||r.output.push(u),!0}else return!1}:n},R=(()=>{let t=0;return e=>{const n=d(e),r=t+=1;return o=>{var s;if(o.options.memoization===!1)return n(o);const u=o.index,c=(s=o.cache)[r]||(s[r]={indexMax:-1,queue:[]}),a=c.queue;if(u<=c.indexMax){const y=c.store||(c.store=new Map);if(a.length){for(let x=0,P=a.length;x<P;x+=2){const Q=a[x*2],N=a[x*2+1];y.set(Q,N)}a.length=0}const f=y.get(u);if(f===!1)return!1;if(it(f))return o.index=f,!0;if(f)return o.index=f.index,f.output?.length&&o.output.push(...f.output),!0}const M=o.output.length,K=n(o);if(c.indexMax=Math.max(c.indexMax,u),K){const y=o.index,f=o.output.length;if(f>M){const x=o.output.slice(M,f);a.push(u,{index:y,output:x})}else a.push(u,y);return!0}else return a.push(u,!1),!1}}})(),U=t=>{let e;return n=>(e||(e=d(t())),e(n))},d=pt(t=>{if(k(t))return st(t)?U(t):t;if(O(t)||lt(t))return i(t);if(q(t))return m(t);if(ct(t))return p(Object.values(t));throw new Error("Invalid rule")}),g=t=>t,mt=t=>typeof t=="string",wt=t=>{const e=new WeakMap,n=new WeakMap;return(r,o)=>{const s=o?.partial?n:e,u=s.get(r);if(u!==void 0)return u;const c=t(r,o);return s.set(r,c),c}},Mt=t=>{const e={},n={};return(r,o)=>{const s=o?.partial?n:e;return s[r]??(s[r]=t(r,o))}},yt=i(/\\./,g),kt=i(/./,g),At=i(/\*\*\*+/,"*"),Et=i(/([^/{[(!])\*\*/,(t,e)=>`${e}*`),jt=i(/(^|.)\*\*(?=[^*/)\]}])/,(t,e)=>`${e}*`),vt=E(p([yt,At,Et,jt,kt])),zt=t=>W(t,vt,{memoization:!1}).join(""),J="abcdefghijklmnopqrstuvwxyz",Rt=t=>{let e="";for(;t>0;){const n=(t-1)%26;e=J[n]+e,t=Math.floor((t-1)/26)}return e},B=t=>{let e=0;for(let n=0,r=t.length;n<r;n++)e=e*26+J.indexOf(t[n])+1;return e},I=(t,e)=>{if(e<t)return I(e,t);const n=[];for(;t<=e;)n.push(t++);return n},It=(t,e,n)=>I(t,e).map(r=>String(r).padStart(n,"0")),T=(t,e)=>I(B(t),B(e)).map(Rt),l=t=>({partial:!1,regex:new RegExp(t,"s"),children:[]}),A=t=>({children:t}),w=(()=>{const t=(e,n,r)=>{if(r.has(e))return;r.add(e);const{children:o}=e;if(!o.length)o.push(n);else for(let s=0,u=o.length;s<u;s++)t(o[s],n,r)};return e=>{if(!e.length)return A([]);for(let n=e.length-1;n>=1;n--){const r=new Set,o=e[n-1],s=e[n];t(o,s,r)}return e[0]}})(),$=()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),St=i(/\\./,l),Bt=i(/[$.*+?^(){}[\]\|]/,t=>l(`\\${t}`)),Ct=i(/[\\\/]/,$),bt=i(/[^$.*+?^(){}[\]\|\\\/]+/,l),Zt=i(/^(?:!!)*!(.*)$/,(t,e)=>l(`(?!^${S.compile(e).source}$).*?`)),qt=i(/^(!!)+/),Ot=p([Zt,qt]),Wt=i(/\/(\*\*\/)+/,()=>A([w([$(),l(".+?"),$()]),$()])),_t=i(/^(\*\*\/)+/,()=>A([l("^"),w([l(".*?"),$()])])),Ft=i(/\/(\*\*)$/,()=>A([w([$(),l(".*?")]),l("$")])),Lt=i(/\*\*/,()=>l(".*?")),V=p([Wt,_t,Ft,Lt]),Ut=i(/\*\/(?!\*\*\/|\*$)/,()=>w([l("[^\\\\/]*?"),$()])),Jt=i(/\*/,()=>l("[^\\\\/]*")),X=p([Ut,Jt]),Y=i("?",()=>l("[^\\\\/]")),Tt=i("[",g),Vt=i("]",g),Xt=i(/[!^]/,"^\\\\/"),Yt=i(/[a-z]-[a-z]|[0-9]-[0-9]/i,g),Dt=i(/\\./,g),Gt=i(/[$.*+?^(){}[\|]/,t=>`\\${t}`),Ht=i(/[\\\/]/,"\\\\/"),Kt=i(/[^$.*+?^(){}[\]\|\\\/]+/,g),Pt=p([Dt,Gt,Ht,Yt,Kt]),D=m([Tt,F(Xt),E(Pt),Vt],t=>l(t.join(""))),Qt=i("{","(?:"),Nt=i("}",")"),te=i(/(\d+)\.\.(\d+)/,(t,e,n)=>It(+e,+n,Math.min(e.length,n.length)).join("|")),ee=i(/([a-z]+)\.\.([a-z]+)/,(t,e,n)=>T(e,n).join("|")),ne=i(/([A-Z]+)\.\.([A-Z]+)/,(t,e,n)=>T(e.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),re=p([te,ee,ne]),G=m([Qt,re,Nt],t=>l(t.join(""))),oe=i("{"),se=i("}"),ue=i(","),ie=i(/\\./,l),ce=i(/[$.*+?^(){[\]\|]/,t=>l(`\\${t}`)),le=i(/[\\\/]/,$),ae=i(/[^$.*+?^(){}[\]\|\\\/,]+/,l),fe=U(()=>H),pe=i("",()=>l("(?:)")),$e=xt(p([V,X,Y,D,G,fe,ie,ce,le,ae]),w),C=p([$e,pe]),H=m([oe,F(m([C,E(m([ue,C]))])),se],A),he=E(p([Ot,V,X,Y,D,G,H,St,Bt,Ct,bt]),w),de=t=>W(t,he,{memoization:!1})[0],S=(t,e,n)=>S.compile(t,n).test(e);S.compile=(()=>{const t=Mt((n,r)=>rt(de(zt(n)),r)),e=wt((n,r)=>ot(n.map(o=>t(o,r))));return(n,r)=>mt(n)?t(n,r):e(n,r)})();export{S as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{y as U,m as I,I as K,v as b}from"../packem_shared/index-BDmTbWX1.js";import{E as Q}from"../packem_shared/public-api-WqUCiyIe.js";import{b7 as N,b8 as A,b9 as x,u as X,p as Z}from"./bin.js";const ee=(e,t)=>typeof e!="string"||e===""?"":e[0].toLowerCase()+e.slice(1),k=(e,t)=>typeof e!="string"||e===""?"":(t?.locale?e[0].toLocaleUpperCase(t.locale):e[0].toUpperCase())+e.slice(1),te=(e,t)=>`${e}::${t?.joiner??""}::${t?.locale??""}::${t?.knownAcronyms?.join(",")??""}::${t?.normalize?"true":"false"}`,$=(e,t)=>{const{length:r}=e;if(r===0)return"";if(r===1)return e[0];const n=[];let i="",o="";for(let s=0;s<r;s++){const l=e[s];if(N.test(l)){i?(n.push(i+o+l),i="",o=""):(n.length>0&&n.push(t),i=l);continue}i?(o&&(o+=t),o+=l):(n.length>0&&n.push(t),n.push(l))}return n.join("")},ne=/(?<![a-zß])SS(?![a-z])/g,re=e=>e.replaceAll(ne,"ß"),ie=(e,t)=>{if(typeof e!="string"||!e)return"";let r=!0;return $(A(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(i=>{const o=i,s=o.toLowerCase();return r?(r=!1,ee(s)):k(s,t)}),"")},oe=new x(1e3),S=(e,t)=>{if(typeof e!="string")return"";const r=t?.cache??!1,n=t?.cacheStore??oe;let i;if(r&&(i=te(e,t)),r&&i&&n.has(i))return n.get(i);const o=A(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(l=>{if(t?.handleAnsi&&N.test(l))return l;if(t?.toUpperCase)return t.locale?l.toLocaleUpperCase(t.locale):l.toUpperCase();const a=t?.locale?.startsWith("de")?re(l):l;return t?.locale?a.toLocaleLowerCase(t.locale):a.toLowerCase()}),s=$(o,t?.joiner??"-");return r&&i&&n.set(i,s),s},se=new x(1e3),le=(e,t)=>S(e,{cacheStore:se,...t,joiner:"_",toUpperCase:!0}),ae=(e,t)=>typeof e!="string"||!e?"":$(A(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(n=>k(n.toLowerCase(),{locale:t?.locale})),""),ce=new x(1e3),fe=(e,t)=>S(e,{cacheStore:ce,...t,joiner:"_"}),ue=(e,t)=>typeof e!="string"?"":$(A(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(n=>k(n,{locale:t?.locale})),"-"),m=e=>e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):JSON.stringify(e),T={camel_case:e=>ie(m(e)),kebab_case:e=>S(m(e)),lower_case:e=>m(e).toLowerCase(),pascal_case:e=>ae(m(e)),path_join:(e,...t)=>{const r=[m(e),...t.map(n=>m(n))];return I(...r)},path_relative:(e,t)=>U(m(t),m(e)),snake_case:e=>fe(m(e)),upper_case:e=>m(e).toUpperCase(),upper_kebab_case:e=>ue(m(e)),upper_snake_case:e=>le(m(e))},z=(e,t,r=[])=>{const n=T[e];if(!n)throw new Error(`Unknown filter "${e}". Known filters: ${Object.keys(T).sort().join(", ")}.`);return n(t,...r)},R=e=>{const t=[];let r=0,n=0,i,o=-1;for(const s of e){if(o+=1,i){s===i&&(i=void 0);continue}if(s==='"'||s==="'"){i=s;continue}s==="("?r+=1:s===")"?r-=1:s===","&&r===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t},pe=e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1)},me=/\[([^\]]+)\]/g,de=e=>{const t=e.trim(),r=t.indexOf("(");if(r===-1)return{args:[],name:t};if(!t.endsWith(")"))throw new Error(`Filter call "${e}" missing closing ")"`);const n=t.slice(0,r).trim(),i=t.slice(r+1,-1).trim();return i===""?{args:[],name:n}:{args:R(i).map(o=>{const s=o.trim();return pe(s)??s}),name:n}},he=e=>{const t=e.split("|").map(n=>n.trim()),r=t[0]??"";if(!r)throw new Error(`Empty variable name in expression "${e}"`);return{filters:t.slice(1).map(n=>de(n)),name:r}},ye=e=>e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):JSON.stringify(e),ge=(e,t)=>{const r=e.replaceAll(me,(n,i)=>{const{filters:o,name:s}=he(i);if(!Object.hasOwn(t,s))throw new Error(`Variable "${s}" used in filename "${e}" but not defined`);let l=t[s];for(const a of o)l=z(a.name,l,a.args);return ye(l)});return P(r)},P=e=>e.split("/").map(t=>t.endsWith(".tera")||t.endsWith(".twig")?t.slice(0,-5):t).join("/"),we=e=>e.endsWith(".raw")?e.slice(0,-4):e,be=e=>{const t=e.split("/");return(t.at(-1)??"").startsWith("_")?!0:t.slice(0,-1).includes("partials")},Ee=(e,t)=>{if(!e.startsWith(`---
|
|
2
|
+
`)&&!e.startsWith(`---\r
|
|
3
|
+
`))return{body:e};const r=e.indexOf(`
|
|
4
|
+
---`,3);if(r===-1)return{body:e};let n=r+1+3;e[n]==="\r"&&(n+=1),e[n]===`
|
|
5
|
+
`&&(n+=1);const i=e.startsWith(`---\r
|
|
6
|
+
`)?5:4,o=e.slice(i,r).replaceAll("\r","");let s;try{s=t(o)}catch(l){const a=l instanceof Error?l.message:String(l);throw new Error(`Failed to parse frontmatter YAML: ${a}`,{cause:l})}if(s==null)return{body:e.slice(n)};if(typeof s!="object"||Array.isArray(s))throw new TypeError(`Frontmatter must be a YAML mapping, got ${Array.isArray(s)?"array":typeof s}`);return{body:e.slice(n),frontmatter:s}},ve=/\{\{-?(.+?)-?\}\}|\{%-?(.+?)-?%\}/gs,q=e=>{const t=[];let r=0,n=1;const i=o=>{for(const s of o)s===`
|
|
7
|
+
`&&(n+=1)};for(const o of e.matchAll(ve)){const s=o.index??0;if(s>r){const c=e.slice(r,s);t.push({line:n,type:"text",value:c}),i(c)}const l=n,a=o[0];a.startsWith("{{")?t.push({line:l,type:"expr",value:(o[1]??"").trim()}):t.push({line:l,type:"stmt",value:(o[2]??"").trim()}),i(a),r=s+a.length}if(r<e.length){const o=e.slice(r);t.push({line:n,type:"text",value:o})}return t},Ae=new Set(["block","endblock","endfilter","endmacro","extends","filter","import","macro","set"]),F=(e,t)=>{let r=0;const n=(o,s)=>{throw new Error(`${t}:${o}: ${s}`)},i=o=>{const s=[];for(;r<e.length;){const l=e[r];if(l.type==="text"){s.push({type:"text",value:l.value}),r+=1;continue}if(l.type==="expr"){s.push({expression:l.value,line:l.line,type:"expr"}),r+=1;continue}const a=l.value.split(/\s+/)[0]??"";if(o.includes(a))return s;if(Ae.has(a)&&n(l.line,`Tera feature "{% ${a} %}" is not supported. Supported: if/else/endif, for/endfor, include. Rewrite the template to avoid macros, set, extends, block, and import.`),a==="if"){r+=1;const c=l.value.slice(2).trim(),p=i(["else","endif"]);let f;r<e.length&&e[r].type==="stmt"&&e[r].value.split(/\s+/)[0]==="else"&&(r+=1,f=i(["endif"])),(r>=e.length||e[r].type!=="stmt"||e[r].value.split(/\s+/)[0]!=="endif")&&n(l.line,"Unterminated {% if %} — missing {% endif %}"),r+=1,s.push({alternate:f,condition:c,consequent:p,line:l.line,type:"if"});continue}if(a==="for"){r+=1;const c=l.value.slice(3).trim(),p=c.indexOf(" in ");p===-1&&n(l.line,"Malformed {% for %} — expected `for <name> in <collection>`");const f=c.slice(0,p).trim(),d=c.slice(p+4).trim();(!f||!d)&&n(l.line,"Malformed {% for %} — missing binding or collection");const u=i(["endfor"]);(r>=e.length||e[r].type!=="stmt"||e[r].value.split(/\s+/)[0]!=="endfor")&&n(l.line,"Unterminated {% for %} — missing {% endfor %}"),r+=1,s.push({binding:f,body:u,collection:d,line:l.line,type:"for"});continue}if(a==="include"){r+=1;const c=l.value.slice(7).trim(),p=G(c);p===void 0&&n(l.line,"Malformed {% include %} — expected a quoted partial name"),s.push({line:l.line,name:p,type:"include"});continue}n(l.line,`Unknown tag "{% ${a} %}". Supported: if, for, include.`)}return s};return i([])},G=e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1)},$e=e=>e==null?"":typeof e=="boolean"||typeof e=="number"?String(e):typeof e=="string"?e:JSON.stringify(e),je=e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:!0,B=(e,t,r,n,i=!0)=>{const o=e.split(".");if(i&&o.length>0&&!Object.hasOwn(t,o[0]))throw new Error(`${n}:${r}: Variable "${e}" is not defined`);let s=t;for(const l of o){if(s==null)return;if(typeof s!="object")throw new TypeError(`${n}:${r}: Cannot read "${l}" on non-object value`);s=s[l]}return s},xe=e=>{const t=[];let r=0,n=0,i;for(let o=0;o<e.length;o+=1){const s=e[o];if(i){s===i&&(i=void 0);continue}if(s==='"'||s==="'"){i=s;continue}s==="("?r+=1:s===")"?r-=1:s==="|"&&r===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t},ke=e=>{const t=e.trim(),r=t.indexOf("(");if(r===-1)return{args:[],name:t};if(!t.endsWith(")"))throw new Error(`Filter call "${e}" missing closing ")"`);const n=t.slice(0,r).trim(),i=t.slice(r+1,-1).trim();return i?{args:R(i).map(o=>o.trim()),name:n}:{args:[],name:n}},v=(e,t,r,n,i=!0)=>{const o=e.trim();if(o==="true")return!0;if(o==="false")return!1;if(o==="null"||o==="none")return null;const s=G(o);return s!==void 0?s:/^-?\d+(?:\.\d+)?$/.test(o)?Number(o):B(o,t,r,n,i)},D=(e,t,r,n,i=!0)=>{const o=xe(e),s=o[0].trim();let l=v(s,t,r,n,i);for(let a=1;a<o.length;a+=1){const c=o[a].trim(),{args:p,name:f}=ke(c),d=p.map(u=>v(u,t,r,n,i));try{l=z(f,l,d)}catch(u){const y=u instanceof Error?u.message:String(u);throw new Error(`${n}:${r}: ${y}`,{cause:u})}}return l},Y=(e,t)=>{let r,n=0;for(let i=0;i<=e.length-t.length;i+=1){const o=e[i];if(r){o===r&&(r=void 0);continue}if(o==='"'||o==="'"){r=o;continue}if(o==="("){n+=1;continue}if(o===")"){n-=1;continue}if(n===0&&e.slice(i,i+t.length)===t)return i}return-1},_=(e,t)=>{const r=[];let n=0,i=0;for(;i<=e.length-t.length;){const o=Y(e.slice(i),t);if(o===-1)break;r.push(e.slice(n,i+o)),i+=o+t.length,n=i}return r.push(e.slice(n)),r},g=(e,t,r,n)=>{const i=e.trim();if(i==="")return!1;if(i.startsWith("(")&&i.endsWith(")")&&Se(i)===i.length-1)return g(i.slice(1,-1),t,r,n);const o=_(i," or ");if(o.length>1)return o.some(l=>g(l,t,r,n));const s=_(i," and ");if(s.length>1)return s.every(l=>g(l,t,r,n));if(i.startsWith("not "))return!g(i.slice(4),t,r,n);for(const l of["==","!="]){const a=Y(i,l);if(a!==-1){const c=v(i.slice(0,a),t,n,r,!1),p=v(i.slice(a+l.length),t,n,r,!1),f=c===p;return l==="=="?f:!f}}return je(D(i,t,n,r,!1))},Se=e=>{if(e[0]!=="(")return-1;let t=0,r,n=-1;for(const i of e){if(n+=1,r){i===r&&(r=void 0);continue}if(i==='"'||i==="'"){r=i;continue}if(i==="(")t+=1;else if(i===")"&&(t-=1,t===0))return n}return-1},E=(e,t)=>{let r="";for(const n of e){if(n.type==="text"){r+=n.value;continue}if(n.type==="expr"){r+=$e(D(n.expression,t.scope,n.line,t.filename));continue}if(n.type==="if"){const i=g(n.condition,t.scope,t.filename,n.line)?n.consequent:n.alternate??[];r+=E(i,t);continue}if(n.type==="for"){const i=B(n.collection,t.scope,n.line,t.filename,!1);if(i==null)continue;if(!Array.isArray(i))throw new TypeError(`${t.filename}:${n.line}: {% for %} expected an array, got ${typeof i}`);for(const o of i){const s={...t.scope,[n.binding]:o};r+=E(n.body,{...t,scope:s})}continue}if(n.type==="include"){const i=t.partials?.get(n.name);if(!i)throw new Error(`${t.filename}:${n.line}: Partial "${n.name}" not found. Available: ${[...t.partials?.keys()??[]].join(", ")||"(none)"}`);const o=t.includeStack??new Set;if(o.has(n.name)){const s=[...o,n.name].join(" → ");throw new Error(`${t.filename}:${n.line}: Circular partial include detected: ${s}`)}o.add(n.name);try{r+=E(i,{...t,filename:`<partial:${n.name}>`,includeStack:o})}finally{o.delete(n.name)}}}return r},Ce=(e,t)=>F(q(e),t),j=(e,t)=>E(F(q(e),t.filename),t),L="template.yml",Oe=".raw",We=new Set([".cjs",".css",".env",".gitattributes",".gitignore",".graphql",".html",".ini",".js",".json",".json5",".jsonc",".jsx",".lock",".md",".mdx",".mjs",".prettierrc",".raw",".rs",".scss",".sh",".sql",".svg",".tera",".toml",".ts",".tsx",".twig",".txt",".vue",".xml",".yaml",".yml"]),Te=new Set(["Brewfile","CHANGELOG","CODEOWNERS","CONTRIBUTING","COPYING","Dockerfile","Gemfile","LICENCE","LICENSE","Makefile","NOTICE","Procfile","Rakefile","README","VERSION"]),_e=e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),r=t===-1?e:e.slice(t+1),n=r.lastIndexOf(".");return n===-1||n===0?"":r.slice(n).toLowerCase()},J=e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t===-1?e:e.slice(t+1)},Le=e=>{const t=_e(e);if(t!=="")return We.has(t);const r=J(e);return Te.has(r)},Me=e=>{const t={default:e.default,internal:e.internal,order:e.order,prompt:e.prompt,required:e.required};switch(e.type){case"array":return{...t,type:"array"};case"boolean":return{...t,default:typeof t.default=="boolean"?t.default:void 0,type:"boolean"};case"enum":return{...t,multiple:e.multiple,type:"enum",values:e.values??[]};case"number":return{...t,type:"number"};case"string":return{...t,type:"string"};default:throw new Error(`Unsupported variable type "${String(e.type)}"`)}},Ue=e=>e.replaceAll("\\","/").replace(/^\.\//,"").replaceAll(/\/+/g,"/"),Ie=(e,t,r)=>{const n=t.split("/").filter(Boolean);if(n.length===0)throw new Error("Empty destination path for value");let i=e;for(let o=0;o<n.length-1;o+=1){const s=n[o],l=i[s];if(l===void 0){const a={};i[s]=a,i=a}else if(typeof l=="object"&&!Buffer.isBuffer(l))i=l;else throw new TypeError(`Path conflict: "${n.slice(0,o+1).join("/")}" is both a file and a directory`)}i[n.at(-1)]=r},M=(e,t,r)=>{if(typeof e!="string")return Ne(e);const n=e.includes("{{")||e.includes("{%")?j(e,{filename:`${r}#frontmatter`,scope:t}):e;return g(n,t,`${r}#frontmatter`,1)},Ne=e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e!=="false"&&e!=="0":!0,Fe=(e,t)=>{const r=I(e,L),n=X(r);if(!n||typeof n!="object")throw new Error(`${r}: must contain a YAML mapping`);const i={};if(n.variables)for(const[a,c]of Object.entries(n.variables))i[a]=Me(c);const o=new Map,s=[];for(const a of K(e,{includeDirs:!1,includeSymlinks:!1})){if(a.path===r)continue;const c=U(e,a.path).replaceAll("\\","/");if(c===L)continue;if(be(c)){const f=b(a.path),d=Ce(f,c);for(const u of ze(c))o.has(u)&&o.get(u)!==d&&Z.warn(`partial name "${u}" is declared by multiple files — last one wins. Use distinct names or fully-qualified includes.`),o.set(u,d);continue}if(c.endsWith(Oe)){const f=b(a.path);s.push({binary:null,isRaw:!0,rawText:f,relativePath:c});continue}if(Le(c)){const f=b(a.path);s.push({binary:null,isRaw:!1,rawText:f,relativePath:c});continue}const p=b(a.path,{buffer:!0});s.push({binary:p,isRaw:!1,rawText:null,relativePath:c})}const l=a=>{const c={...a.builtins,...a.options},p={},f={};for(const u of s){const y=u.relativePath;let w,C,O=!1;if(u.binary)w=u.binary;else if(u.isRaw)w=u.rawText??"";else{const V=u.rawText??"",h=Ee(V,H=>Q(H));if(h.frontmatter){if(h.frontmatter.skip!==void 0&&M(h.frontmatter.skip,c,y)||h.frontmatter.if!==void 0&&!M(h.frontmatter.if,c,y))continue;typeof h.frontmatter.to=="string"&&(C=j(h.frontmatter.to,{filename:`${y}#frontmatter.to`,partials:o,scope:c})),h.frontmatter.force===!0&&(O=!0)}w=j(h.body,{filename:y,partials:o,scope:c})}const W=Ue(C??ge(we(y),c));Ie(p,W,w),O&&(f[W]={force:!0})}const d={files:p};return Object.keys(f).length>0&&(d.filesMeta=f),d};return{about:{description:n.description??`Moon-format template at ${e}`,name:n.title??t},destination:n.destination,options:i,produce:l}},ze=e=>{const t=P(e),r=J(t),n=new Set([r,t]);if(r.startsWith("_")){n.add(r.replace(/^_+/,""));const i=t.slice(0,t.length-r.length);n.add(`${i}${r.replace(/^_+/,"")}`)}return[...n]};export{Fe as loadMoonTemplate};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const u=e=>e==null?[]:Array.isArray(e)?e:[e],y=e=>e.length===0?!1:e.every(t=>/-/.test(t.version)),g=async(e,t,c)=>{const a=c??{warn:o=>process.stderr.write(`${o}
|
|
2
|
+
`)},n={failed:[],succeeded:[]};if(!e||t.published.length===0||(e.skipPrerelease??!0)&&y(t.published))return n;const i=[],{redactTokens:p}=await import("./security.js"),{SlackNotificationChannel:r}=await import("./slack.js");for(const o of u(e.slack))i.push(new r(o));const{DiscordNotificationChannel:l}=await import("./discord.js");for(const o of u(e.discord))i.push(new l(o));const{WebhookNotificationChannel:w}=await import("./webhook.js");for(const o of u(e.webhook))i.push(new w(o));for(const o of e.plugins??[])try{const s=await m(o);i.push(s)}catch(s){const f=typeof o=="string"?o:o[0],d=s.message,h=p(d);n.failed.push({error:`plugin load failed: ${h}`,id:f}),a.warn(`[notifications:${f}] could not load plugin: ${h}`)}return i.length===0||await Promise.all(i.map(async o=>{try{await o.send(t),n.succeeded.push(o.id)}catch(s){const f=s instanceof Error?s.message:String(s),d=p(f);n.failed.push({error:d,id:o.id}),a.warn(`[notifications:${o.id}] ${d}`)}})),n},m=async e=>{const[t,c]=Array.isArray(e)?e:[e,void 0],{pathToFileURL:a}=await import("node:url"),n=t.startsWith(".")?a(`${process.cwd()}/${t}`).href:t,{dynamicEsmImport:i}=await import("./dynamic-import.js"),p=await i(n),r=p.default??p;if(typeof r=="function"){const l=r(c);if(l&&typeof l=="object"&&typeof l.send=="function")return l}if(r&&typeof r=="object"&&typeof r.send=="function")return r;throw new TypeError(`Notification plugin at ${t} did not export a NotificationChannel (object with .send) or a factory returning one.`)},A=(e,t)=>{if(typeof e!="string")return String(e??"");const c=t.published[0];return e.replaceAll("{count}",String(t.published.length)).replaceAll("{packages}",t.published.map(a=>`${a.name}@${a.version}`).join(", ")).replaceAll("{firstName}",c?.name??"").replaceAll("{firstVersion}",c?.version??"").replaceAll("{channel}",t.channel??"").replaceAll("{repo}",t.repo??"").replaceAll("{date}",t.completedAt.slice(0,10))};export{g as dispatchNotifications,A as expandNotificationTemplate};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{p as r}from"./bin.js";import{c as i,f as a}from"../packem_shared/registry-keys-
|
|
1
|
+
import{p as r}from"./bin.js";import{c as i,f as a}from"../packem_shared/registry-keys-BfFto6vI.js";const n=async({options:s})=>{if(s.clear){const t=i();if(s.json){process.stdout.write(`${JSON.stringify({cleared:t,refetched:!1},void 0,2)}
|
|
2
2
|
`);return}r.success(t?"Cleared cached npm signing keys.":"No cached npm signing keys to clear.");return}const e=await a({forceRefresh:!0});if(e===void 0){if(s.json){process.stdout.write(`${JSON.stringify({cleared:!1,error:"fetch-failed",refetched:!1},void 0,2)}
|
|
3
3
|
`),process.exitCode=1;return}r.error("Failed to fetch npm signing keys (network error and no cached keys available)."),process.exitCode=1;return}if(s.json){process.stdout.write(`${JSON.stringify({cleared:!1,fromCache:e.fromCache,keyCount:e.keys.length,refetched:!e.fromCache,stale:e.stale??!1},void 0,2)}
|
|
4
4
|
`);return}if(e.fromCache&&e.stale===!0){r.warn(`Network fetch failed — falling back to expired cache (${String(e.keys.length)} keys).`);return}r.success(`Refreshed npm signing keys (${String(e.keys.length)} keys).`)};export{n as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createRequire as _}from"node:module";import{ag as x,p as o,ah as B}from"./bin.js";import{w as R}from"../packem_shared/pm-runner-
|
|
1
|
+
import{createRequire as _}from"node:module";import{ag as x,p as o,ah as B}from"./bin.js";import{w as R}from"../packem_shared/pm-runner-OGResYrA.js";import{W as V}from"../packem_shared/build-scripts-CCCi8U66.js";import{m as y,f as w}from"../packem_shared/index-BDmTbWX1.js";import{a as W}from"./config.js";const j=_(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=c=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[r,f]=v.versions.node.split(".").map(Number);if(r>22||r===22&&f>=3||r===20&&f>=16)return v.getBuiltinModule(c)}return j(c)},{readdirSync:S,statSync:M}=D("node:fs"),q=(c,r={})=>{const f=y(c,"node_modules");if(!w(f))return[];const l=new Map,p=new Set,$=(n,s,t)=>{const e=`${s}@${t}`;if(p.has(e))return;p.add(e);const i=t.startsWith(c)?t.slice(c.length+1):t;let u=l.get(n);u||(u=[],l.set(n,u)),u.some(b=>b.name===s)||u.push({name:s,relativePath:i})},d=(n,s="")=>{let t;try{t=S(n)}catch{return}for(const e of t){const i=y(n,e);if(e.startsWith("@")){d(i,`${e}/`);continue}if(e===".pnpm"&&s===""){let a;try{a=S(i)}catch{continue}for(const m of a){const h=y(i,m,"node_modules");w(h)&&d(h)}continue}if(e.startsWith("."))continue;const u=s+e,b=y(i,"package.json");try{if(!M(i).isDirectory()||!w(b))continue;const a=W(b),m=typeof a.name=="string"?a.name:u;if(typeof a.bin=="string"){const k=m.includes("/")?m.split("/").pop():m;$(k,m,i)}else if(a.bin&&typeof a.bin=="object")for(const k of Object.keys(a.bin))$(k,m,i);const h=y(i,"node_modules");w(h)&&d(h)}catch{}}};d(f);const g=[];for(const[n,s]of l)s.length<2||r[n]===!0||s.every(t=>r[`${t.name}#${n}`]===!0)||g.push({bin:n,packages:s});return g.sort((n,s)=>n.bin.localeCompare(s.bin))},C=new Set(["bun","npm","pnpm","yarn"]),J=({options:c,visConfig:r,workspaceRoot:f})=>{const l=f??process.cwd(),p=R(l),$=r?.security?.policies?.installScripts?.allow??{},d=r?.security?.allowBins??{},g=r?.security?.pinVersions===!0,n=V(l,$,{pinVersions:g}),s=q(l,d),t=r&&C.has(p.name)?x(r,p.name,l):void 0;if(c.json){process.stdout.write(`${JSON.stringify({binConflicts:s,drift:t,excess:n.excess,installed:n.installed.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),packageManager:p.name,pinVersions:g,unapproved:n.unapproved.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),versionDrift:n.versionDrift},void 0,2)}
|
|
2
2
|
`);return}if(o.info(`Build-script status (${p.name}):
|
|
3
3
|
`),n.installed.length===0&&n.unapproved.length===0&&o.success(" No installed packages declare lifecycle scripts."),n.installed.length>0){o.success(` Approved (${String(n.installed.length)}):`);for(const e of n.installed)o.info(` ✓ ${e.name} — ${e.hooks.join(", ")}`)}if(n.unapproved.length>0){o.info(""),o.warn(` Unapproved (${String(n.unapproved.length)}):`);for(const e of n.unapproved)o.info(` ✗ ${e.name} — ${e.hooks.join(", ")}`);o.notice(" Run 'vis approve-builds' to review.")}if(n.excess.length>0){o.info(""),o.warn(` Stale allowlist entries (${String(n.excess.length)}):`);for(const e of n.excess)o.info(` ! ${e}`);o.notice(" Remove these from vis.config.ts security.policies.installScripts.allow.")}if(n.versionDrift.length>0){o.info(""),o.warn(` Version drift (pinVersions: true) — ${String(n.versionDrift.length)} entr${n.versionDrift.length===1?"y":"ies"} point at outdated versions:`);for(const{from:e,to:i}of n.versionDrift)o.info(` ${e} → ${i}`);o.notice(" Update vis.config.ts security.policies.installScripts.allow keys to migrate.")}if(s.length>0){o.info(""),o.warn(` Bin conflicts (${String(s.length)}) — multiple packages expose the same bin name:`);for(const e of s)o.info(` ${e.bin} ← ${e.packages.map(i=>i.name).join(", ")}`);o.notice(" Add the bin (or 'pkg#bin') to vis.config.ts security.allowBins to silence this.")}if(t?.hasDrift){o.info("");for(const e of B(t))o.warn(e)}};export{J as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as m}from"node:module";import{w as d,M as _}from"../packem_shared/pm-runner-
|
|
1
|
+
import{createRequire as m}from"node:module";import{w as d,M as _}from"../packem_shared/pm-runner-OGResYrA.js";const w=m(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,r]=o.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return o.getBuiltinModule(e)}return w(e)},{createInterface:y}=g("node:readline"),s="sigstore",$=()=>!!process.stdout.isTTY&&process.env.CI!=="true",v=e=>new Promise(t=>{const r=y({input:process.stdin,output:process.stderr});r.question(`${e} (Y/n) `,i=>{r.close();const n=i.trim().toLowerCase();t(n===""||n==="y"||n==="yes")})}),h=e=>{const t=d(e),r=_(t,{exact:!1,filter:[],global:!1,optional:!1,packages:[s],peer:!1,saveDev:!0,workspace:!1,workspaceRoot:!1},e,console);return Promise.resolve({exitCode:r})},R=()=>{try{return import.meta.resolve(s),!0}catch{return!1}},I=e=>{let t="pnpm";try{t=d(e).name}catch{}switch(t){case"bun":return`bun add -d ${s}`;case"npm":return`npm install -D ${s}`;case"yarn":return`yarn add -D ${s}`;default:return`pnpm add -D ${s}`}},D=()=>import("sigstore"),T=async(e={})=>{const t=e.interactive??$(),r=e.prompt??v,i=e.runInstall??h,n=e.importImpl??D,l=e.workspaceRoot??process.cwd(),a=I(l);try{return await n()}catch(p){const{code:u,message:f}=p;if(!(u==="ERR_MODULE_NOT_FOUND"||u==="MODULE_NOT_FOUND")||!f.includes(s))throw p}if(!t)throw new Error(`${s} is not installed. \`vis attest\` needs it for keyless signing/verification. Install it in your repo first:
|
|
2
2
|
${a}`);if(!await r(`${s} isn't installed. Install it now?`))throw new Error(`${s} install declined. Re-run \`vis attest\` after installing manually:
|
|
3
3
|
${a}`);const c=await i(l);if(c.exitCode!==0)throw new Error(`Install of ${s} failed (exit ${String(c.exitCode)}). Install manually and retry:
|
|
4
4
|
${a}`);return await n()};export{I as installCommandFor,R as isSigstoreInstalled,T as loadOptionalSigstore};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import{createRequire as De}from"node:module";import{p as x}from"../packem_shared/index-CgcF6_wo.js";import{DEFAULT_CHANGES_DIR as q,DEFAULT_DEPENDENCY_BUMP_RULES as Oe,DEFAULT_CONFIG as Be}from"./DEFAULT_CLEAN_KEEP.js";import{VisReleaseError as R}from"../packem_shared/VisReleaseError-DMGRBTNO.js";import{e as Le,p as Te,c as xe}from"./registry.js";import{E as Ue}from"../packem_shared/public-api-WqUCiyIe.js";import{BUMP_LEVELS as le,maxBump as oe,bumpRank as Q,normaliseGroup as ge}from"../release/types.js";import Z from"./index.js";import{d as He,c as We}from"./detect.js";import{escapeMarkdown as Ye,assertValidPackageName as Je}from"./security.js";import{createShellRunner as J}from"./shell-runner.js";const Se=De(import.meta.url),W=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pe=e=>{if(typeof W<"u"&&W.versions&&W.versions.node){const[a,t]=W.versions.node.split(".").map(Number);if(a>22||a===22&&t>=3||a===20&&t>=16)return W.getBuiltinModule(e)}return Se(e)},{readdir:Ve,readFile:Ee,writeFile:Fe,unlink:_e}=pe("node:fs/promises"),{resolve:X,sep:K,join:Ge}=pe("node:path"),{realpathSync:ze}=pe("node:fs"),qe=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,Xe=e=>{const a=qe.exec(e);return a?{body:(a[2]??"").trim(),frontmatter:a[1]??""}:null},Ke=/^(?:@[a-z0-9-]+\/)?[\w.-]+$/i,Qe=214,Ze=e=>e.length===0||e.length>Qe||e.startsWith(".")||e.startsWith("_")||e.startsWith("-")?!1:Ke.test(e),ie=e=>typeof e=="string"&&le.includes(e),ea=/^\s*(pr|commit|author)\s*:\s*(.+?)\s*$/i,aa=e=>{const a=e.split(/\r?\n/),t={};let n=0;for(const c of a){if(c.trim()===""){n+=1;continue}const d=ea.exec(c);if(!d)break;const[,l="",i=""]=d;switch(l.toLowerCase()){case"author":{t.author=i.startsWith("@")?i:`@${i}`;break}case"commit":{t.commit=i;break}case"pr":{const r=Number.parseInt(i,10);!Number.isNaN(r)&&r>0&&(t.pr=r);break}}n+=1}const s=a.slice(n).join(`
|
|
2
|
+
`).trim();return{meta:Object.keys(t).length>0?t:void 0,remainder:s}},me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&"bump"in e,ta=(e,a,t)=>{if(!ie(a.bump))throw new R({code:"BUMP_FILE_INVALID",file:t,message:`Invalid bump level for "${e}": ${JSON.stringify(a.bump)}. Expected one of: ${le.join(", ")}`,packageName:e});const n={bump:a.bump,package:e};if(a.releaseAs!==void 0){if(typeof a.releaseAs!="string"||!/^\d+\.\d+\.\d+(?:[-+].*)?$/.test(a.releaseAs))throw new R({code:"BUMP_FILE_INVALID",file:t,message:`Invalid releaseAs for "${e}": ${JSON.stringify(a.releaseAs)}. Expected a semver string like "2.0.0" or "2.0.0-rc.1".`,packageName:e});n.releaseAs=a.releaseAs}if(a.cascade!==void 0){if(typeof a.cascade!="object"||a.cascade===null||Array.isArray(a.cascade))throw new R({code:"BUMP_FILE_INVALID",file:t,message:`Cascade block for "${e}" must be an object mapping package globs to bump levels.`,packageName:e});const s={};for(const[c,d]of Object.entries(a.cascade)){if(!ie(d))throw new R({code:"BUMP_FILE_INVALID",file:t,message:`Invalid cascade bump level for "${c}": ${JSON.stringify(d)}.`,packageName:e});s[c]=d}n.cascade=s}return n},ne=e=>e.replaceAll(/^.*[/\\]/g,"").replace(/\.md$/i,""),na=(e,a)=>{const t=Xe(e);if(!t)throw new R({code:"BUMP_FILE_INVALID",file:a,message:"Change file is missing YAML frontmatter (expected `---` delimiters)."});let n;try{n=Ue(t.frontmatter,{schema:"core",strict:!0})}catch(i){throw new R({cause:i,code:"BUMP_FILE_INVALID",file:a,message:`YAML parse failed: ${i.message}`})}if(n==null)return{body:t.body.trim(),id:ne(a),path:a,payload:{bumps:{}}};if(typeof n!="object"||Array.isArray(n))throw new R({code:"BUMP_FILE_INVALID",file:a,message:"Frontmatter must be a YAML object mapping package names to bump levels."});const s=Object.entries(n);if(s.length===0)return{body:t.body.trim(),id:ne(a),path:a,payload:{bumps:{}}};for(const[i]of s)if(!Ze(i))throw new R({code:"BUMP_FILE_INVALID",file:a,message:`Invalid package name: ${JSON.stringify(i)}.`,packageName:i});let c;if(s.length===1&&me(s[0][1])){const[i,r]=s[0];c=ta(i,r,a)}else{const i={};for(const[r,m]of s){if(me(m))throw new R({code:"BUMP_FILE_INVALID",file:a,message:`Mixed simple + nested entries are not allowed. Package "${r}" uses the nested shape but the file has multiple top-level entries.`,packageName:r});if(!ie(m))throw new R({code:"BUMP_FILE_INVALID",file:a,message:`Invalid bump level for "${r}": ${JSON.stringify(m)}. Expected one of: ${le.join(", ")}`,packageName:r});i[r]=m}c={bumps:i}}const{meta:d,remainder:l}=aa(t.body);return{body:l,id:ne(a),meta:d,path:a,payload:c}},Ya=(e,a)=>{let t;if("bumps"in e){const n=Object.entries(e.bumps).map(([s,c])=>`${se(s)}: ${c}`);t=n.length>0?n.join(`
|
|
3
|
+
`):"{}"}else{const n=[`${se(e.package)}:`,` bump: ${e.bump}`];if(e.releaseAs&&n.push(` releaseAs: ${e.releaseAs}`),e.cascade){n.push(" cascade:");for(const[s,c]of Object.entries(e.cascade))n.push(` ${se(s)}: ${c}`)}t=n.join(`
|
|
4
|
+
`)}return`---
|
|
5
|
+
${t}
|
|
6
|
+
---
|
|
7
|
+
${a.trim()===""?"":`${a.trim()}
|
|
8
|
+
`}`},se=e=>/^[a-z0-9-]/.test(e)?e:`"${e}"`,sa=e=>{const a=new Map,t=s=>s==="major"?3:s==="minor"?2:s==="patch"?1:0,n=(s,c)=>{const d=a.get(s);(d===void 0||t(c)>t(d))&&a.set(s,c)};for(const s of e)if("bumps"in s.payload)for(const[c,d]of Object.entries(s.payload.bumps))n(c,d);else n(s.payload.package,s.payload.bump);return a},ue=(e,a)=>a.filter(t=>"bumps"in t.payload?Object.hasOwn(t.payload.bumps,e):t.payload.package===e),ra=new Set(["README.md","readme.md"]),oa=async e=>{const a=e.changesDir??q,t=X(e.cwd),n=X(e.cwd,a),s=n,c=t.endsWith(K)?t:`${t}${K}`;if(n!==t&&!n.startsWith(c))throw new R({code:"CONFIG_INVALID",message:`changesDir resolves outside the workspace: ${n} (workspace: ${t}). Set release.changesDir to a path inside the repo.`});const d=[];let l;try{l=await Ve(s)}catch(r){if(r.code==="ENOENT")return{files:[],warnings:[]};throw new R({cause:r,code:"CONFIG_INVALID",message:`Cannot read change-files directory ${s}: ${r.message}`})}const i=l.filter(r=>!ra.has(r)&&r.endsWith(".md"));return{files:await Promise.all(i.map(async r=>{const m=Ge(s,r),o=await Ee(m,"utf8");return na(o,m)})),warnings:d}},ia=(e,a)=>{if(!a)return;if(Object.hasOwn(a,e)){const n=Object.keys(a).filter(s=>s!==e&&he(s)&&Z(s,e));return fe(e,a[e],n)}const t=[];for(const[n]of Object.entries(a))he(n)&&Z(n,e)&&t.push(n);if(t.length>0){const[n,...s]=t;return fe(e,a[n],s)}},fe=(e,a,t=[])=>{let{tag:n}=a;return n==="branch-name"&&(n=ca(e)),{branch:e,mode:a.mode??"auto-publish",...t.length>0?{overlapping:t}:{},prerelease:a.prerelease,range:a.range,tag:n}},ca=e=>e.toLowerCase().replaceAll(/[^a-z0-9.-]/g,"-").replaceAll(/^-+|-+$/g,"")||"branch",pa=/[!()*+?@[\]{|}]/,he=e=>pa.test(e),la=async(e,a)=>{try{const t=await a.run("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e,silent:!0});if(t.exitCode!==0)return;const n=t.stdout.trim();return n==="HEAD"||n===""?void 0:n}catch{return}},da=["dependencies","devDependencies","peerDependencies","optionalDependencies"];class ga{dependents;dependenciesByPackage;packagesByName;constructor(a){this.dependents=new Map,this.dependenciesByPackage=new Map,this.packagesByName=new Map;for(const t of a){if(this.packagesByName.has(t.name))throw new R({code:"DUPLICATE_PACKAGE_NAME",message:`Duplicate package name "${t.name}" — found at ${this.packagesByName.get(t.name).dir} and ${t.dir}.`,packageName:t.name});this.packagesByName.set(t.name,t),this.dependents.set(t.name,[]),this.dependenciesByPackage.set(t.name,[])}for(const t of a)for(const n of da){const s=t.manifest[n];if(!(!s||typeof s!="object"))for(const[c,d]of Object.entries(s))this.packagesByName.has(c)&&(this.dependents.get(c).push({kind:n,name:t.name,range:d}),this.dependenciesByPackage.get(t.name).push({kind:n,name:c,range:d}))}}getPackage(a){return this.packagesByName.get(a)}allPackages(){return[...this.packagesByName.values()]}isInternal(a){return this.packagesByName.has(a)}getDependents(a){return this.dependents.get(a)??[]}getDependencies(a){return this.dependenciesByPackage.get(a)??[]}topologicalSort(a){const t=a?new Set(a):new Set(this.packagesByName.keys()),n=new Set,s=new Set,c=[],d=(l,i)=>{if(!n.has(l)){if(s.has(l)){const r=i.indexOf(l),m=r===-1?[...i,l]:[...i.slice(r),l];throw new R({code:"CYCLIC_DEPENDENCY",message:`Cyclic dependency detected: ${m.join(" → ")}`})}s.add(l);for(const r of this.getDependencies(l))t.has(r.name)&&r.kind!=="devDependencies"&&d(r.name,[...i,l]);s.delete(l),n.add(l),c.push(l)}};for(const l of t)d(l,[]);return c}get size(){return this.packagesByName.size}}const ma=/\{(name|version|previousVersion|date|repo|contributors)\}/g,ua=(e,a)=>e.replaceAll(ma,(t,n)=>a[n]??""),fa=(e,a={})=>{const t=new Set;for(const c of a.internalAuthors??[]){const d=c.trim().toLowerCase().replace(/^@/,"");d.length>0&&t.add(d)}const n=new Set,s=[];for(const c of e){const d=c.meta?.author;if(d)for(const l of d.split(",")){const i=l.trim();if(!i)continue;const r=i.replace(/^@/,"");if(r.length===0)continue;const m=r.toLowerCase();n.has(m)||t.has(m)||(n.add(m),s.push(Ye(i)))}}return s.length===0?"":s.map(c=>`- ${c}`).join(`
|
|
9
|
+
`)},ee=e=>{const{current:a,prerelease:t}=e;let{bump:n}=e;if(!x.valid(a))throw new R({code:"CONFIG_INVALID",message:`Invalid current version: ${JSON.stringify(a)}`});const s=x.parse(a),c=s.prerelease[0],d=s.prerelease.length>0;if(s.major===0&&e.bumpMinorPreMajor&&(n==="major"&&(n="minor"),n==="minor"&&e.bumpPatchForMinorPreMajor&&(n="patch")),n==="none")return(c??void 0)===(t??void 0)?a:!d&&t?`${s.major}.${s.minor}.${s.patch}-${t}.0`:d&&!t?`${s.major}.${s.minor}.${s.patch}`:d&&t?`${s.major}.${s.minor}.${s.patch}-${t}.0`:a;if(d&&t&&c===t){const i=ha(s);if(we[n]<=we[i]){const o=x.inc(a,"prerelease",t);if(!o)throw new R({code:"CONFIG_INVALID",message:`semver.inc returned null for prerelease bump on ${a}`});return o}const r=`${s.major}.${s.minor}.${s.patch}`,m=x.inc(r,n);if(!m)throw new R({code:"CONFIG_INVALID",message:`semver.inc returned null for ${n} bump on ${r}`});return`${m}-${t}.0`}if(t){const i=`${s.major}.${s.minor}.${s.patch}`,r=x.inc(i,n);if(!r)throw new R({code:"CONFIG_INVALID",message:`semver.inc returned null for ${n} bump on ${i}`});return`${r}-${t}.0`}if(d){const i=`${s.major}.${s.minor}.${s.patch}`,r=x.inc(i,n);if(!r)throw new R({code:"CONFIG_INVALID",message:`semver.inc returned null for ${n} bump on ${i}`});return r}const l=x.inc(a,n);if(!l)throw new R({code:"CONFIG_INVALID",message:`semver.inc returned null for ${n} bump on ${a}`});return l},we={major:3,minor:2,patch:1},ha=e=>e.minor===0&&e.patch===0?"major":e.patch===0?"minor":"patch",wa=(e,a)=>{const t=ke(a);return t?x.satisfies(e,t,{includePrerelease:!0}):!0},ke=e=>{if(!e||e.startsWith("catalog:")||e==="*"||e==="workspace:*"||e==="workspace:^"||e==="workspace:~")return null;if(e.startsWith("workspace:")){const a=e.slice(10);return a==="*"||a==="^"||a==="~"?null:a}if(e.startsWith("npm:")){const a=e.lastIndexOf("@");return a>4?e.slice(a+1):null}return e},re=100,G=(e,a,t,n,{isCascadeBump:s=!1,isDependencyBump:c=!1,isGroupBump:d=!1,source:l}={})=>{const i=e.get(a);if(i){const r=i.type;return i.type=oe(i.type,t),i.reasons.add(n),c&&(i.isDependencyBump=!0),d&&(i.isGroupBump=!0),s&&(i.isCascadeBump=!0),l&&i.sources.set(l.name,{bumpType:l.bumpType,newVersion:l.newVersion}),i.type!==r}return e.set(a,{isCascadeBump:s,isDependencyBump:c,isGroupBump:d,name:a,proactiveSeen:!1,reasons:new Set([n]),sources:l?new Map([[l.name,{bumpType:l.bumpType,newVersion:l.newVersion}]]):new Map,type:t}),!0},ya=(e,a,t,n)=>{const s=t?.get(e)?.dependencyBumpRules?.[a];if(s!==void 0)return s;const c=n.dependencyBumpRules?.[a];return c!==void 0?c:Oe[a]??!1},ye=(e,a)=>Q(e)>=Q(a),be=(e,a)=>a==="match"?e:a,ba=(e,a)=>a===!0?!0:Array.isArray(a)?a.includes(e):!1,$a=10,va=(e,a,t,n,s,c,d)=>{let l=!1;for(const i of e.values()){const r=a.getPackage(i.name);if(!r)continue;const m=n.currentVersions?.get(i.name)??r.version,o=t.get(i.name)??ee({bump:i.type,bumpMinorPreMajor:n.bumpMinorPreMajor,bumpPatchForMinorPreMajor:n.bumpPatchForMinorPreMajor,current:m,prerelease:n.prerelease});t.set(i.name,o);for(const p of a.getDependents(i.name)){if(p.kind==="devDependencies"){if(!ba(i.name,c.bumpDevDependencies))continue;if(G(e,p.name,"patch","DEVDEPENDENCY_BUMPED",{isDependencyBump:!0,source:{bumpType:i.type,name:i.name,newVersion:o}})&&(l=!0,t.delete(p.name)),c.bumpDevDependencies===!0){let w=d.get(i.name);w||(w=new Set,d.set(i.name,w)),w.add(p.name)}continue}const h=ke(p.range);if(h===null||wa(o,h))continue;let u,k="DEPENDENCY_OUT_OF_RANGE";p.kind==="peerDependencies"?(u=i.type==="none"?"patch":i.type,k="PEER_DEP_MATCH",h.startsWith("^0.")&&u!=="patch"&&s.push(`^0.x peer dep "${i.name}" → "${p.name}" produced a ${u} bump. Consider widening the range manually.`)):u="patch",G(e,p.name,u,k,{isDependencyBump:!0,source:{bumpType:i.type,name:i.name,newVersion:o}})&&(l=!0,t.delete(p.name))}}return l},ka=(e,a,t)=>{let n=!1;for(const s of t.fixed??[]){const c=ge(s),d=ae(c.packages,a),l=d.filter(r=>e.has(r));if(l.length===0)continue;let i="none";for(const r of l)i=oe(i,e.get(r).type);for(const r of d)a.isInternal(r)&&G(e,r,i,"FIXED_GROUP",{isGroupBump:!0})&&(n=!0)}for(const s of t.linked??[]){const c=ge(s),d=ae(c.packages,a).filter(i=>e.has(i));if(d.length===0)continue;let l="none";for(const i of d)l=oe(l,e.get(i).type);for(const i of d)G(e,i,l,"LINKED_GROUP",{isGroupBump:!0})&&(n=!0)}return n},$e=new WeakMap,Pa=/[!()*+?@[\]{|}]/,ae=(e,a)=>{let t=$e.get(a);t||(t={allNames:a.allPackages().map(s=>s.name),matched:new Map},$e.set(a,t));const n=new Set;for(const s of e){if(!Pa.test(s)){n.add(s);continue}let c=t.matched.get(s);c||(c=t.allNames.filter(d=>Z(s,d)),t.matched.set(s,c));for(const d of c)n.add(d)}return[...n]},Ca=(e,a,t,n,s,c)=>{let d=!1;const l=n.updateInternalDependencies??"out-of-range",i=r=>{const m=c.get(r.name);if(m!==void 0)return m;const o=ee({bump:r.type,bumpMinorPreMajor:s.bumpMinorPreMajor,bumpPatchForMinorPreMajor:s.bumpPatchForMinorPreMajor,current:s.currentVersions?.get(r.name)??t.getPackage(r.name).version,prerelease:s.prerelease});return c.set(r.name,o),o};for(const r of a){if("bumps"in r.payload||!r.payload.cascade)continue;const m=e.get(r.payload.package);if(!m)continue;const o=c.get(m.name)??ee({bump:m.type,bumpMinorPreMajor:s.bumpMinorPreMajor,bumpPatchForMinorPreMajor:s.bumpPatchForMinorPreMajor,current:s.currentVersions?.get(m.name)??t.getPackage(m.name).version,prerelease:s.prerelease});c.set(m.name,o);for(const[p,h]of Object.entries(r.payload.cascade))for(const u of ae([p],t))t.isInternal(u)&&G(e,u,h,"CASCADE",{isCascadeBump:!0,source:{bumpType:m.type,name:m.name,newVersion:o}})&&(d=!0)}for(const r of e.values()){const m=s.perPackageConfig?.get(r.name)?.cascadeTo;if(m)for(const[o,p]of Object.entries(m)){if(!ye(r.type,p.trigger))continue;const h=be(r.type,p.bumpAs),u=i(r);for(const k of ae([o],t))t.isInternal(k)&&G(e,k,h,"CASCADE_TO",{isCascadeBump:!0,source:{bumpType:r.type,name:r.name,newVersion:u}})&&(d=!0)}}if(l==="out-of-range")return d;for(const r of e.values())if(!r.proactiveSeen&&!(l==="minor"&&Q(r.type)<Q("minor"))){for(const m of t.getDependents(r.name)){const o=ya(m.name,m.kind,s.perPackageConfig,n);if(o===!1||!ye(r.type,o.trigger))continue;const p=be(r.type,o.bumpAs);if(p==="none")continue;const h=i(r);G(e,m.name,p,"DEPENDENCY_BUMPED",{isDependencyBump:!0,source:{bumpType:r.type,name:r.name,newVersion:h}})&&(d=!0)}r.proactiveSeen=!0}return d},Na=(e,a,t,n={})=>{const s=new Map,c=[],d=new Map;for(const[o,p]of sa(e).entries()){if(!a.isInternal(o)){c.push(`Change file references non-workspace package "${o}" — ignored.`);continue}p!=="none"&&G(s,o,p,"EXPLICIT")}for(const o of n.catalogConsumers??[]){if(!a.isInternal(o.packageName))continue;const p=`catalog:${o.catalog}/${o.dep}`;G(s,o.packageName,"patch","CATALOG_CHANGED",{isDependencyBump:!0,source:{bumpType:"patch",name:p,newVersion:o.newVersion??""}})}const l=new Map,i=o=>{const p=ue(o,e).map(u=>"releaseAs"in u.payload?{file:u.path,version:u.payload.releaseAs}:void 0).filter(u=>u!==void 0&&typeof u.version=="string"),h=new Set(p.map(u=>u.version));if(h.size>1)throw new R({code:"BUMP_FILE_INVALID",message:`Conflicting releaseAs values for ${o}: ${[...h].join(", ")}. Found in: ${p.map(u=>u.file).join(", ")}. Consolidate the change files to a single override.`,packageName:o});return p[0]?.version},r=new Map;for(const o of s.values()){if(o.type==="none")continue;const p=i(o.name);p&&(r.set(o.name,p),d.set(o.name,p))}for(let o=0;o<re;o+=1){const p=va(s,a,d,n,c,t,l),h=ka(s,a,t),u=Ca(s,e,a,t,n,d);if(!p&&!h&&!u)break;o===re-1&&c.push(`Release plan did not converge after ${re} iterations — releasing the current best plan. This usually indicates a config bug (cyclic cascade?).`)}for(const[o,p]of l){const h=p.size;h>$a&&c.push(`bumpDevDependencies: true triggered ${h} patch-cascades to distinct dependents from a single devdep bump (${o}). Consider scoping with the array form ['only', 'these', 'sources'].`)}const m=[];for(const o of s.values()){if(o.type==="none")continue;const p=a.getPackage(o.name);if(!p)continue;const h=ue(o.name,e),u=r.get(o.name),k=n.currentVersions?.get(o.name)??p.version,w=u??d.get(o.name)??ee({bump:o.type,bumpMinorPreMajor:n.bumpMinorPreMajor,bumpPatchForMinorPreMajor:n.bumpPatchForMinorPreMajor,current:k,prerelease:n.prerelease});m.push({changeFiles:h,isCascadeBump:o.isCascadeBump,isDependencyBump:o.isDependencyBump,isGroupBump:o.isGroupBump,name:o.name,newVersion:w,oldVersion:k,reasons:[...o.reasons],sources:[...o.sources.entries()].map(([$,b])=>({name:$,...b})),type:o.type})}return m.sort((o,p)=>o.name.localeCompare(p.name)),{consumedChangeFiles:e,releases:m,warnings:c}},Pe=async(e,a,t={})=>{const n=await e.listPackages(),s=[],c=new Map,d=new Map,l=o=>{try{return ze(X(o))}catch{return X(o)}},i=t.cwd===void 0?void 0:l(t.cwd),r=o=>o.replaceAll("\\","/"),m=[];for(const{manifest:o,manifestPath:p}of n){const h=ce(typeof o.name=="string"?o.name:"",o,a);if(o.napi!==void 0||h.versionActions==="native-addon"){const u=r(p.replace(/[/\\]package\.json$/i,""));m.push(`${u}/npm/`)}}for(const{manifest:o,manifestPath:p}of n){if(typeof o.name!="string"||o.name==="")continue;const h=r(p.replace(/[/\\]package\.json$/i,""));if(m.some(w=>h.startsWith(w)))continue;if(Je(o.name),d.has(o.name))throw new R({code:"DUPLICATE_PACKAGE_NAME",message:`Duplicate package name "${o.name}" — at ${d.get(o.name)} and ${p}.`,packageName:o.name});if(d.set(o.name,p),i!==void 0){const w=l(p),$=i.endsWith(K)?i:`${i}${K}`;if(w!==i&&!w.startsWith($))throw new R({code:"CONFIG_INVALID",message:`Package manifest is outside the workspace: ${p} (workspace: ${i}).`,packageName:o.name})}const u=ce(o.name,o,a);if(!Ce(o.name,o,u,a))continue;const k=p.replace(/[/\\]package\.json$/i,"");s.push({dir:k,manifest:o,manifestPath:p,name:o.name,private:o.private===!0,version:typeof o.version=="string"?o.version:"0.0.0"}),c.set(o.name,u)}return{packages:s,perPackageConfig:c}},ce=(e,a,t)=>{const n=t.packages?.[e]??{},s=a["vis-release"]??{};return{...n,...s}},Ce=(e,a,t,n)=>t.managed===!1?!1:t.managed===!0?!0:ve(e,n.ignore??[])?!1:ve(e,n.include??[])?!0:a.private===!0&&!(n.privatePackages?.version??!1)?!1:n.defaultManaged??!1,ve=(e,a)=>a.some(t=>Z(t,e)),Ne=(e,a)=>a.versionActions!==void 0?a.versionActions:e.manifest.napi!==void 0?"native-addon":e.private?"private":"npm",Ja=Object.defineProperty({__proto__:null,discoverPackages:Pe,isPackageManaged:Ce,mergePerPackageConfig:ce,resolveVersionActionsId:Ne},Symbol.toStringTag,{value:"Module"}),za=async(e={})=>{const a=e.cwd??process.cwd(),t=J(),n=await He(a),s=We(n,t),c=await s.detectVersion(a);if(c&&!Ia(c,s.minVersion))throw new R({code:"PM_VERSION_TOO_LOW",hint:`pnpm install -g ${s.id}@latest (or your equivalent)`,message:`${s.id} version ${c} is below the required minimum ${s.minVersion}. Upgrade ${s.id} to enable release operations.`});let d={};try{const{loadVisConfig:A}=await import("../packem_shared/CONFIG_FILES-BfaR0jKT.js"),C=await A(a);C.release&&(d=C.release)}catch(A){const{code:C}=A,g=A.message??"";if(!(C==="ENOENT"||C==="MODULE_NOT_FOUND"||/cannot find module/i.test(g)))throw A}const l=Aa(d,e.config??{});!l.acknowledgeUnstable&&process.env.VIS_RELEASE_SUPPRESS_UNSTABLE!=="1"&&process.stderr.write("[vis release] ⚠ This subsystem is flagged unstable. Set `release.acknowledgeUnstable: true` in vis.config.ts to suppress this warning. (RFC §21.2)\n");const i=e.channel??await la(a,t),r=i?ia(i,l.channels):void 0,m=await import("node:fs/promises"),o={listPackages:async()=>{const A=await s.listWorkspacePackages(a);return(await Promise.all(A.map(async C=>{const g=`${C.path}/package.json`;try{const y=await m.readFile(g,"utf8");return{manifest:JSON.parse(y),manifestPath:g}}catch{return}}))).filter(C=>C!==void 0)}},{packages:p,perPackageConfig:h}=await Pe(o,l,{cwd:a}),u=new ga(p),{files:k}=await oa({changesDir:l.changesDir,cwd:a}),{readPreMode:w}=await import("./pre-mode.js"),$=await w(a,l.changesDir??".vis/release");let b;$?.mode==="pre"?b=$.tag:$?.mode==="exit-pending"?b=void 0:b=r?.prerelease;const P=e.firstRelease===!0,{resolveCurrentVersionsForWorkspace:v}=await import("./version-resolver.js"),{versions:L,warnings:V}=await v(p,u,l,h,{cwd:a,firstRelease:P,pm:s,runner:t,skipRegistryLookup:e.skipRegistryLookup===!0}),T=[],N=[];if(l.detectCatalogChanges===!0)try{const{detectCatalogChanges:A,findCatalogConsumers:C,parseCatalogs:g}=await import("./catalog-detector.js"),y=await s.readCatalogYaml(a),j=g(y);let B;try{const _=await t.run("git",["show","HEAD~1:pnpm-workspace.yaml"],{cwd:a,silent:!0});_.exitCode===0&&(B=_.stdout)}catch{}const S=g(B),D=A(S,j).filter(_=>_.oldVersion!==void 0&&_.newVersion!==void 0);if(D.length>0){const _=C(p,j);for(const M of D){const I=_.get(M.catalog)?.get(M.dep)??[];for(const f of I)T.push({catalog:M.catalog,dep:M.dep,newVersion:M.newVersion,oldVersion:M.oldVersion,packageName:f.packageName})}T.length>0&&N.push(`Catalog change-detection: ${D.length} catalog dep(s) moved; ${T.length} consumer-package patch bump(s) tagged CATALOG_CHANGED.`)}}catch(A){N.push(`Catalog change-detection skipped: ${A.message}.`)}const E=Na(k,u,l,{bumpMinorPreMajor:l.bumpMinorPreMajor,bumpPatchForMinorPreMajor:l.bumpPatchForMinorPreMajor,catalogConsumers:T,currentVersions:L,perPackageConfig:h,prerelease:b});if(N.length>0&&E.warnings.push(...N),V.length>0&&E.warnings.push(...V),P&&E.warnings.push('First-release mode: currentVersionResolver forced to "disk", remote tag-collision checks skipped. Drop --first-release after the initial wave lands.'),$?.mode==="pre"&&E.warnings.push(`Pre-mode is ACTIVE (tag "${$.tag}"); every version produces a prerelease. Exit with \`vis release pre exit\` when ready to ship stable.`),$?.mode==="exit-pending"&&E.warnings.push(`Pre-mode is EXIT-PENDING (was "${$.tag}"); the next \`vis release version\` will consolidate the prerelease and delete pre.json.`),r?.overlapping&&r.overlapping.length>0&&E.warnings.push(`Branch "${i}" matches multiple channel patterns: "${r.branch}" (active) plus ${r.overlapping.map(A=>`"${A}"`).join(", ")}. Reorder channels in vis.config.ts if this is unintentional.`),e.projects&&e.projects.length>0){const{default:A}=await import("./index.js"),C=e.projects;E.releases=E.releases.filter(g=>C.some(y=>g.name===y||A(y,g.name)))}return{branch:i,channel:r?{mode:r.mode,prerelease:r.prerelease,tag:r.tag}:void 0,config:l,cwd:a,depGraph:u,firstRelease:P,packages:p,perPackageConfig:h,plan:E,pm:s,preMode:$}},Aa=(...e)=>{let a={...Be};for(const t of e)a={...a,...t};return a},Ia=(e,a)=>{const t=x.coerce(e)?.version??e;try{return x.gte(t,a)}catch{return!0}},Y=async(e,a,t)=>{if(!a||a.trim()==="")return;const n=J(),s=process.platform==="win32",c=s?"cmd":"sh",d=s?["/c",a]:["-c",a],l=await n.run(c,d,{cwd:e,silent:!1});if(l.exitCode!==0)throw new Error(`${t} failed (exit ${l.exitCode}): ${a}`)},Ae=async(e,a,t,n={})=>{const{findConflictingPendingStages:s,readStagedRegistry:c,removePendingStages:d,writeStagedRegistry:l}=await import("./staged-registry.js"),i=e.config.changesDir??q;let r=t??await c(e.cwd,i);if(r.pending.length===0)return;const m=new Map(e.plan.releases.map(w=>[w.name,w.newVersion])),o=[...m.keys()];let p=s(r,o).filter(w=>m.get(w.name)!==w.version);if(p.length===0)return;let h=[];if(!n.skipSelfHeal){const w=n.runner??J();h=(await Promise.all(p.map(async $=>{const b=await w.run("npm",["view",`${$.name}@${$.version}`,"dist.tarball","--silent"],{cwd:e.cwd,silent:!0});return b.exitCode===0&&b.stdout.trim().length>0?$.id:void 0}))).filter($=>$!==void 0)}if(h.length>0){if(r=d(r,h),n.persistSelfHeal!==!1)try{await l(e.cwd,i,r)}catch{}if(p=s(r,o).filter(w=>m.get(w.name)!==w.version),p.length===0)return}const u=p.map(w=>` • ${w.name}@${w.version} — stage ${w.id} (${w.reason}, recorded ${w.stagedAt})`).join(`
|
|
10
|
+
`),k=a==="version"?"version":"publish";throw new R({code:"STAGE_PENDING",hint:"Resolve via `vis release stage approve <id>` / `--all` or `vis release stage reject <id>`, commit the updated staged.json, then retry.",message:`Refusing to ${k} — ${p.length} package(s) have a pending stage from a prior wave:
|
|
11
|
+
${u}`})},qa=async(e,a={})=>{if(e.plan.releases.length===0)return{changedFiles:[],deletedFiles:[],plan:e.plan};if(await Ae(e,"version",void 0,{persistSelfHeal:!1}),!a.dryRun&&e.config.preVersionCommand&&await Y(e.cwd,e.config.preVersionCommand,"preVersionCommand"),!a.dryRun&&e.config.groupPreVersionCommands){const{normaliseGroup:p}=await import("../release/types.js"),h=[...e.config.fixed??[],...e.config.linked??[]].map(k=>p(k)),{default:u}=await import("./index.js");for(const[k,w]of Object.entries(e.config.groupPreVersionCommands)){const $=Number.parseInt(k.replace(/^group-/,""),10),b=h[$];!b||!e.plan.releases.some(P=>b.packages.some(v=>P.name===v||u(v,P.name)))||await Y(e.cwd,w,`groupPreVersionCommand[${k}]`)}}const t=await import("node:fs/promises"),{readFileSync:n}=await import("node:fs"),{resolveFormatter:s}=await import("./resolveFormatter.js"),{resolveGroupChangelogRouting:c}=await import("./workspace.js"),d=await s(e.config.changelog,e.cwd),l=new Date().toISOString().slice(0,10),i=c(e.config,e.packages,e.cwd),r=await Le(e.plan,e.depGraph,{changelogPath:p=>i.get(p.name)??`${p.dir}/CHANGELOG.md`,readChangelog:p=>{try{return n(p,"utf8")}catch{return}},readManifest:p=>{try{return n(p,"utf8")}catch{return}},renderChangelogEntry:p=>d({changeFiles:p.changeFiles,date:l,release:p,target:"changelog"})}),m=[];{const{applyExtraFilesForRelease:p}=await import("./extra-files.js"),h=await Promise.all(e.plan.releases.map(async u=>{const k=e.depGraph.getPackage(u.name);if(!k)return{warnings:[],writes:[]};const w=e.perPackageConfig.get(u.name)?.extraFiles??[],$=e.config.publish?.extraFiles??[];return w.length===0&&$.length===0?{warnings:[],writes:[]}:p(e.cwd,k.dir,u.newVersion,u.name,$,w)}));for(const u of h){for(const k of u.writes)r.writes.push({content:k.content,path:k.path});m.push(...u.warnings)}m.length>0&&e.plan.warnings.push(...m)}if(a.dryRun)return{changedFiles:r.writes.map(p=>p.path),deletedFiles:r.deletions,plan:e.plan};await Promise.all([...r.writes.map(p=>Fe(p.path,p.content)),...r.deletions.map(async p=>{try{await _e(p)}catch{}})]);try{await e.pm.installLockfileOnly({cwd:e.cwd,silent:!0})}catch{}!a.dryRun&&e.config.formatChangedFiles&&await Ra(r.writes.map(p=>p.path),e.cwd);let o;if(a.commit){const{stageAndCommit:p}=await import("./git.js"),h=J(),u=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock","bun.lockb"],k=await import("node:path"),w=[];for(const b of u)try{await t.access(k.join(e.cwd,b)),w.push(k.join(e.cwd,b))}catch{}const $=e.config.aggregateRelease===!0||typeof e.config.aggregateRelease=="object"&&e.config.aggregateRelease.enabled;if(e.config.oneCommitPerPackage===!0&&!$&&e.plan.releases.length>0){const b=e.channel?.tag??e.branch??"main",P=r.writes.map(V=>V.path),v=new Set,{releases:L}=e.plan;for(let V=0;V<L.length;V+=1){const T=L[V],N=e.depGraph.getPackage(T.name),E=N?`${N.dir}${k.sep}`:void 0,A=E?P.filter(y=>y.startsWith(E)):[];for(const y of A)v.add(y);const C=V===L.length-1?[...P.filter(y=>!v.has(y)),...r.deletions,...w]:[],g=[...A,...C];g.length!==0&&(o=await p({cwd:e.cwd,runner:h},g,`release(${b}): ${T.name}@${T.newVersion} [skip ci]`,{author:e.config.gitUser}))}}else{const b=a.commitMessage??ja(e),P=[...r.writes.map(v=>v.path),...r.deletions,...w];o=await p({cwd:e.cwd,runner:h},P,b,{author:e.config.gitUser})}}if(!a.dryRun&&e.config.postVersionCommand&&await Y(e.cwd,e.config.postVersionCommand,"postVersionCommand"),!a.dryRun&&e.preMode?.mode==="exit-pending"){const{deletePreMode:p,preModeFilePath:h}=await import("./pre-mode.js"),u=e.config.changesDir??".vis/release";await p(e.cwd,u)&&e.plan.warnings.push(`Pre-mode exited: \`${h(e.cwd,u)}\` was deleted. Commit the deletion so the registry stays consistent across CI runs.`)}return{changedFiles:r.writes.map(p=>p.path),commitSha:o,deletedFiles:r.deletions,plan:e.plan}},Ra=async(e,a)=>{if(e.length===0)return;const{join:t}=await import("node:path");let n;try{const{createRequire:c}=await import("node:module"),{pathToFileURL:d}=await import("node:url"),l=c(t(a,"package.json"));n=await import(d(l.resolve("prettier")).href)}catch{return}const s=await import("node:fs/promises");for(const c of e)try{const d=await n.getFileInfo(c);if(d.ignored||!d.inferredParser)continue;const l=await s.readFile(c,"utf8"),i=await n.resolveConfig(c),r=await n.format(l,{...i,filepath:c});r!==l&&await s.writeFile(c,r)}catch{}},ja=e=>{const a=e.channel?.tag??e.branch??"main",{releases:t}=e.plan,n=t.length<=3?t.map(c=>`${c.name}@${c.newVersion}`).join(", "):`version ${t.length} packages`,s=t.map(c=>`- ${c.name}: ${c.oldVersion} → ${c.newVersion}`).join(`
|
|
12
|
+
`);return`release(${a}): ${n} [skip ci]
|
|
13
|
+
|
|
14
|
+
${s}`},Xa=async(e,a={})=>{const t={failed:[],published:[],skipped:[],tags:[],tagsPushed:!1},n=J();if(e.plan.releases.length===0)return t;if(!a.dryRun&&e.channel?.mode==="version-pr"){const{createRemoteClient:i,detectRemoteProvider:r}=await import("./detect2.js"),m=await r(e.cwd,n,e.config.provider),o=await i(m,{githubHost:e.config.githubHost,gitlabHost:e.config.gitlabHost,httpProxy:e.config.httpProxy}).detectRepoSlug(e.cwd,n),p=e.config.versionPr?.branch??"vis-release/version-packages";if(o)try{const h=await n.run("gh",["pr","list","--head",p,"--state","open","--json","number"],{cwd:e.cwd,silent:!0});if(h.exitCode===0&&h.stdout.trim()&&h.stdout.trim()!=="[]"){const u=JSON.parse(h.stdout);if(u[0])return t.failed.push({name:"_preflight",reason:`Open release PR #${u[0].number} exists. Merge or close it before publishing locally. (Override: --no-push then \`git push --tags\` manually.)`}),t}}catch{}}if(!a.dryRun&&e.config.prePublishCommand)try{await Y(e.cwd,e.config.prePublishCommand,"prePublishCommand")}catch(i){return t.failed.push({name:"_prePublishCommand",reason:i.message}),t}const s=e.config.changesDir??q,{acquireLock:c,releaseLock:d}=await import("./state.js");let l=!1;if(!a.dryRun)try{await c(e.cwd,s),l=!0}catch(i){return t.failed.push({name:"_lock",reason:i.message}),t}try{const{clearState:i,filterPlanByState:r,newState:m,readState:o,writeState:p}=await import("./state.js"),{readStagedRegistry:h,removePendingStages:u,upsertPendingStages:k,writeStagedRegistry:w}=await import("./staged-registry.js"),$=e.config.changesDir??q;let b=a.resume?await o(e.cwd,$):void 0,P=await h(e.cwd,$);await Ae(e,"publish",P,{runner:n}),P=await h(e.cwd,$);const v={pending:[...P.pending]};let{releases:L}=e.plan;b?L=r(L,b):(b=m(e.channel?.tag,e.plan.releases),a.dryRun||await p(e.cwd,$,b));const V=await e.pm.readCatalogYaml(e.cwd),T=Te(V),N=e.depGraph.topologicalSort(L.map(g=>g.name)),E=new Map(L.map(g=>[g.name,g])),A=new Set,C=new Map;for(const g of e.plan.releases){const y=e.depGraph.getPackage(g.name);y&&C.set(g.name,{...y.manifest,version:g.newVersion})}for(const g of N){const y=E.get(g);if(!y){t.skipped.push({name:g,reason:"topo-sort returned a name not in the release plan (internal bug)"});continue}const j=e.depGraph.getPackage(g);if(!j)continue;const B=[...new Set(e.depGraph.getDependencies(g).filter(f=>f.kind!=="devDependencies"&&A.has(f.name)).map(f=>f.name))];if(B.length>0){t.skipped.push({name:g,reason:`dependency-failed: not published because ${B.join(", ")} failed to publish (publishing would orphan this package's dependency range)`}),A.add(g);continue}const S=e.perPackageConfig.get(g)??{},D=Ne(j,S),_=a.publishActionsOverride??xe(D),M=a.tag??e.channel?.tag,I=P.pending.find(f=>f.name===g&&f.version===y.newVersion);try{const f=await _.publish({catalogs:T,cleanPackageJsonConfig:e.config.publish?.cleanPackageJson,dryRun:a.dryRun,otp:a.otp,perPackageConfig:S,pkg:j,pm:e.pm,provenance:Ea(e),registry:S.registry,release:y,resumeStageId:I?.id,tag:M,versionedManifestByName:C,workspaceConfig:e.config});if(f.published||f.alreadyPublished){const O=P.pending.filter(F=>F.name===g&&F.version===y.newVersion).map(F=>F.id);O.length>0&&(P=u(P,O))}if(f.published)t.published.push({name:g,stageId:f.stageId,tarball:f.tarball,version:y.newVersion}),b.published.push(`${g}@${y.newVersion}`);else if(f.alreadyPublished)t.skipped.push({name:g,reason:"already-published"}),b.published.push(`${g}@${y.newVersion}`);else if(t.skipped.push({name:g,reason:f.output??"skipped"}),f.stageId){const O=(f.output??"").startsWith("stage-rejected")?"rejected":"timeout";P=k(P,[{id:f.stageId,name:g,reason:O,stagedAt:new Date().toISOString(),tag:M??"latest",version:y.newVersion}])}a.dryRun||await p(e.cwd,$,b)}catch(f){t.failed.push({name:g,reason:f.message}),A.add(g)}}if(!a.dryRun&&!a.noTag&&t.published.length>0){const{createOrUpdateFloatingTag:g,createTag:y,defaultTagFor:j,pushTags:B,renderTagPattern:S}=await import("./git.js"),D=e.config.releaseTagPattern,_=e.channel?.tag,M=e.config.floatingMajorTag===!0,I=!!e.channel?.prerelease||!!e.preMode;for(const{name:f,version:O}of t.published){const F=e.perPackageConfig.get(f)?.releaseTagPattern??D,U=F?S(F,{channel:_,name:f,version:O}):j(f,O);try{await y({cwd:e.cwd,runner:n},U,`Release ${f}@${O}`,{signing:e.config.signing,skipRemoteCheck:e.firstRelease}),t.tags.push(U)}catch(H){e.firstRelease&&H instanceof R&&H.code==="TAG_COLLISION"?t.skipped.push({name:U,reason:"tag-creation: tag already exists (first-release — skipped)"}):t.skipped.push({name:U,reason:`tag-creation: ${H.message}`})}const z=e.depGraph.getPackage(f),Ie=e.perPackageConfig.get(f),Re=z?.manifest?.private===!0,je=Ie?.skipNpmPublish===!0;if(M&&!I&&!F?.includes("{major}")&&!Re&&!je){const H=O.split(/[-+]/,1)[0].split(".")[0];if(H!==void 0&&H!==""){const de=f.replace(/^@/,"").replaceAll("/","-");if(de!==""){const te=`${de}-v${H}`;try{await g({cwd:e.cwd,runner:n},te,{push:!a.noPush,signing:e.config.signing}),t.tags.push(te)}catch(Me){t.skipped.push({name:te,reason:`floating-major-tag: ${Me.message}`})}}}}}if(!a.noPush&&t.tags.length>0)try{await B({cwd:e.cwd,runner:n}),t.tagsPushed=!0}catch(f){t.tagsPushed=!1,t.failed.push({name:"_pushTags",reason:`git push --tags failed: ${f.message}. Retry with: git push --tags`})}b.tagged=[...t.tags],b.pushed=t.tagsPushed,a.dryRun||await p(e.cwd,$,b),t.failed.length===0&&t.published.length>0&&!a.dryRun&&await i(e.cwd,$)}if(!a.dryRun){const g=v.pending.length,y=P.pending.length,j=await w(e.cwd,$,P);if(j.changed){const{stageAndCommitFile:B}=await import("./git.js");let S;if(j.removed)S="chore(release): clear pending stage registry [skip ci]";else if(y>g){const D=y-g;S=`chore(release): record ${D} new pending stage${D===1?"":"s"} [skip ci]`}else if(y<g){const D=g-y;S=`chore(release): drain ${D} resolved stage${D===1?"":"s"} [skip ci]`}else S=`chore(release): update pending stage registry (${y} pending) [skip ci]`;try{await B({cwd:e.cwd,runner:n},j.path,S,{author:e.config.gitUser,push:!a.noPush,sign:e.config.gitSignCommits===!0})}catch(D){process.stderr.write(`[vis release] Warning: could not commit ${j.path}: ${D.message}
|
|
15
|
+
`)}}}if(!a.dryRun&&t.published.length>0&&e.config.workspaceChangelog!==!1){const g=e.config.workspaceChangelog,y=typeof g=="object"?g:void 0,j=typeof e.config.aggregateRelease=="object"?e.config.aggregateRelease.enabled:e.config.aggregateRelease===!0;if(y!==void 0||j)try{const{writeWorkspaceChangelogWave:B}=await import("./workspace.js"),S=new Set(t.published.map(M=>M.name)),D=e.plan.releases.filter(M=>S.has(M.name)),_=await B({changelogConfig:e.config.changelog,cwd:e.cwd,workspaceChangelog:e.config.workspaceChangelog},D);if(_)try{const{stageAndCommitFile:M}=await import("./git.js");await M({cwd:e.cwd,runner:n},_,"chore(release): record wave [skip ci]",{author:e.config.gitUser,push:!a.noPush,sign:e.config.gitSignCommits===!0})}catch(M){process.stderr.write(`[vis release] Warning: could not commit workspace CHANGELOG.md: ${M.message}
|
|
16
|
+
`)}}catch(B){process.stderr.write(`[vis release] Warning: could not write workspace CHANGELOG.md wave entry: ${B.message}
|
|
17
|
+
`)}}if(!a.dryRun&&t.published.length>0&&t.tagsPushed){e.config.publish?.noRelease!==!0&&await Va(e,t,n);try{const{walkSuccessfulRelease:g}=await import("./success-walk.js"),{createRemoteClient:y,detectRemoteProvider:j}=await import("./detect2.js"),{resolveFormatter:B}=await import("./resolveFormatter.js"),S=await j(e.cwd,n,e.config.provider),D=y(S,{githubHost:e.config.githubHost,gitlabHost:e.config.gitlabHost,httpProxy:e.config.httpProxy}),_=await D.detectRepoSlug(e.cwd,n),M=await B(e.config.changelog,e.cwd),{recordRecentlyWalked:I}=await import("./staged-registry.js"),f=new Set([...b.walked??[],...(P.recentlyWalked??[]).map(F=>F.key)]),O={...t,published:t.published.filter(F=>!f.has(`${F.name}@${F.version}`))};if(O.published.length>0){const F=await g(e,O,n,{client:D,formatter:M,repo:_}),U=O.published.map(z=>`${z.name}@${z.version}`);b.walked=[...b.walked??[],...U],await p(e.cwd,$,b),P=I(P,U),F.warnings.length>0&&e.plan.warnings.push(...F.warnings)}}catch(g){e.plan.warnings.push(`successWalk: could not run post-release walk: ${g.message}`)}if(e.config.notifications)try{const{dispatchNotifications:g}=await import("./interface.js"),{createRemoteClient:y,detectRemoteProvider:j}=await import("./detect2.js"),B=await j(e.cwd,n,e.config.provider),S=await y(B,{githubHost:e.config.githubHost,gitlabHost:e.config.gitlabHost,httpProxy:e.config.httpProxy}).detectRepoSlug(e.cwd,n);let D;try{const I=`${e.cwd}/package.json`,f=await import("node:fs/promises");D=JSON.parse(await f.readFile(I,"utf8")).name}catch{}const _=new Set([...b.notified??[],...(P.recentlyNotified??[]).map(I=>I.key)]),M=t.published.filter(I=>!_.has(`${I.name}@${I.version}`));if(M.length>0){const I=await g(e.config.notifications,{channel:e.channel?.tag,completedAt:new Date().toISOString(),...D===void 0?{}:{monorepoName:D},published:M.map(f=>({name:f.name,tag:e.channel?.tag,...f.url===void 0?{}:{url:f.url},version:f.version})),...S===void 0?{}:{repo:S},skipped:t.skipped.map(f=>({name:f.name,reason:f.reason}))},{warn:f=>e.plan.warnings.push(f)});if(I.succeeded.length>0){const f=M.map(F=>`${F.name}@${F.version}`);b.notified=[...b.notified??[],...f],await p(e.cwd,$,b);const{recordRecentlyNotified:O}=await import("./staged-registry.js");P=O(P,f)}if(I.failed.length>0||I.succeeded.length>0){const f=I.succeeded.length+I.failed.length;if(I.failed.length>0){e.plan.warnings.push(`[notifications] dispatched ${I.succeeded.length}/${f} channels${I.succeeded.length>0?` (succeeded: ${I.succeeded.join(", ")})`:""}; ${I.failed.length} failed.`);for(const O of I.failed)e.plan.warnings.push(`[notifications:${O.id}] ${O.error}`)}}}}catch(g){e.plan.warnings.push(`notifications: dispatch failed: ${g.message}`)}if(!a.dryRun)try{const g=await w(e.cwd,$,P);if(g.changed){const{stageAndCommitFile:y}=await import("./git.js");try{await y({cwd:e.cwd,runner:n},g.path,"chore(release): record cross-runner notify/walk dedupe [skip ci]",{author:e.config.gitUser,push:!a.noPush,sign:e.config.gitSignCommits===!0})}catch(j){process.stderr.write(`[vis release] Warning: could not commit ${g.path} (notify/walk dedupe): ${j.message}
|
|
18
|
+
`)}}}catch(g){process.stderr.write(`[vis release] Warning: could not update cross-runner dedupe registry: ${g.message}
|
|
19
|
+
`)}}if(!a.dryRun&&e.config.postPublishCommand)try{await Y(e.cwd,e.config.postPublishCommand,"postPublishCommand")}catch(g){t.failed.push({name:"_postPublishCommand",reason:g.message})}return t}finally{l&&await d(e.cwd,s)}},Ma=e=>e.length===0?"":`## Related releases
|
|
20
|
+
|
|
21
|
+
${e.map(a=>`- [${a.name}](${a.url})`).join(`
|
|
22
|
+
`)}`,Da=(e,a,t)=>{if(!a||!a.header&&!a.footer)return e;const n=c=>ua(c,{contributors:t.contributors??"",date:t.date,name:t.name,previousVersion:t.previousVersion,repo:t.repo,version:t.version}).replaceAll(/\n{3,}/g,`
|
|
23
|
+
|
|
24
|
+
`).replace(/\s+$/,""),s=[];if(a.header){const c=n(a.header);c.length>0&&s.push(c)}if(s.push(e),a.footer){const c=n(a.footer);c.length>0&&s.push(c)}return s.join(`
|
|
25
|
+
|
|
26
|
+
`)},Sa=e=>{if(!Array.isArray(e))return;const[a,t]=e;if(a!=="github"||typeof t!="object"||t===null)return;const{internalAuthors:n}=t;if(Array.isArray(n))return n.filter(s=>typeof s=="string")},Va=async(e,a,t)=>{const{createRemoteClient:n,detectRemoteProvider:s}=await import("./detect2.js"),c=await s(e.cwd,t,e.config.provider),d=n(c,{githubHost:e.config.githubHost,gitlabHost:e.config.gitlabHost,httpProxy:e.config.httpProxy}),l=await d.detectRepoSlug(e.cwd,t);if(!l)return;const i=typeof e.config.aggregateRelease=="object"?e.config.aggregateRelease:{enabled:e.config.aggregateRelease===!0},r=e.config.publish?.draftRelease===!0,m=e.config.publish?.discussionCategory,o=e.config.publish?.addReleases;if(i.enabled){const v=new Date().toISOString().slice(0,10),L=(i.title??"Release {date}").replaceAll("{date}",v),V=`release-${v}`,T=a.published.map(N=>`- \`${N.name}\` → ${N.version}`).join(`
|
|
27
|
+
`);try{const N=await d.createRelease(t,{body:T,cwd:e.cwd,discussionCategory:m,draft:r,repo:l,tag:V,title:L});if(N?.url)for(const E of a.published)E.url=N.url}catch{}return}const{defaultTagFor:p,renderTagPattern:h}=await import("./git.js"),u=e.config.releaseTagPattern,k=e.channel?.tag,w=e.config.publish?.releaseAssets??{},$=new Date().toISOString().slice(0,10),b=Sa(e.config.changelog),P=fa(e.plan.consumedChangeFiles??[],{internalAuthors:b});for(const v of a.published){const L=e.perPackageConfig.get(v.name)?.releaseTagPattern??u,V=L?h(L,{channel:k,name:v.name,version:v.version}):p(v.name,v.version),T=v.version.includes("-");let N=`Release of ${v.name}@${v.version}.`;if(v.stageId&&(N=`${N}
|
|
28
|
+
|
|
29
|
+
> ⏳ **Staged — not yet installable.** Approve via \`vis release stage approve ${v.stageId}\` or the npmjs.com web UI.`),w.stampHashes&&v.tarball&&(N=`${N}
|
|
30
|
+
|
|
31
|
+
### Tarball integrity
|
|
32
|
+
|
|
33
|
+
- size: \`${v.tarball.size}\` bytes
|
|
34
|
+
- sha256: \`${v.tarball.sha256}\`
|
|
35
|
+
- sha512: \`${v.tarball.sha512}\``),o!==void 0&&o!==!1)try{const C=V.lastIndexOf("@"),g=C>0?V.slice(0,C+1):"",y=await d.listRecentReleases(t,{cwd:e.cwd,excludeTag:V,limit:5,repo:l,tagPrefix:g}),j=Ma(y);j&&(N=o==="top"?`${j}
|
|
36
|
+
|
|
37
|
+
${N}`:`${N}
|
|
38
|
+
|
|
39
|
+
${j}`)}catch{}const{releaseNoteTemplate:E}=e.config;if(E){const C=e.plan.releases.find(g=>g.name===v.name)?.oldVersion??"";N=Da(N,E,{contributors:P,date:$,name:v.name,previousVersion:C,repo:l,version:v.version})}const A=[];w.uploadTarball&&v.tarball&&A.push(v.tarball.path);try{const C=await d.createRelease(t,{assets:A.length>0?A:void 0,body:N,cwd:e.cwd,discussionCategory:m,draft:r,prerelease:T,repo:l,tag:V,title:`${v.name} v${v.version}`});C?.url&&(v.url=C.url)}catch(C){console.warn(`createRelease failed for ${v.name}@${v.version} (tag ${V}): ${C.message}`)}}},Ea=e=>(e.config.publish?.publishArgs??[]).includes("--provenance")&&e.pm.id!=="bun";export{qa as a,za as b,sa as c,Ne as d,Ya as f,Xa as p,oa as r,Ja as w};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRequire as l}from"node:module";import{VisReleaseError as a}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const m=l(import.meta.url),n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,c=t=>{if(typeof n<"u"&&n.versions&&n.versions.node){const[r,e]=n.versions.node.split(".").map(Number);if(r>22||r===22&&e>=3||r===20&&e>=16)return n.getBuiltinModule(t)}return m(t)},{readFile:u,mkdir:f,writeFile:g,unlink:p}=c("node:fs/promises"),{dirname:_,join:T}=c("node:path"),d=(t,r)=>T(t,r,"pre.json"),E=async(t,r)=>{const e=d(t,r);let o;try{o=await u(e,"utf8")}catch(i){if(i.code==="ENOENT")return;throw new a({cause:i,code:"STATE_FILE_CORRUPT",message:`Failed to read pre-mode file at ${e}: ${i.message}`})}let s;try{s=JSON.parse(o)}catch(i){throw new a({cause:i,code:"STATE_FILE_CORRUPT",message:`Pre-mode file at ${e} is not valid JSON: ${i.message}.`})}if(s.version!==1)throw new a({code:"STATE_FILE_CORRUPT",message:`Pre-mode file at ${e} reports unknown version ${s.version}.`});if(s.mode!=="pre"&&s.mode!=="exit-pending")throw new a({code:"STATE_FILE_CORRUPT",message:`Pre-mode file at ${e} has invalid mode ${JSON.stringify(s.mode)}.`});if(typeof s.tag!="string"||s.tag.length===0)throw new a({code:"STATE_FILE_CORRUPT",message:`Pre-mode file at ${e} is missing a tag.`});return s},P=async(t,r,e)=>{const o=d(t,r);return await f(_(o),{recursive:!0}),await g(o,`${JSON.stringify(e,null,2)}
|
|
2
|
+
`),o},R=async(t,r)=>{const e=d(t,r);try{return await p(e),!0}catch(o){if(o.code==="ENOENT")return!1;throw o}},y=(t,r)=>{const e={};for(const o of r)e[o.name]=o.version;return{enteredAt:new Date().toISOString(),initialVersions:e,mode:"pre",tag:t,version:1}};export{y as buildEnterFile,R as deletePreMode,d as preModeFilePath,E as readPreMode,P as writePreMode};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{normaliseGroup as p}from"../release/types.js";const d=o=>o==="debug",m=o=>/[\\/]/.test(o)||/\.(?:pem|gpg|key|asc|p12|pfx)$/i.test(o)||o.length<8?"(key: configured)":`…${o.slice(-4)}`,i=o=>{try{const a=new URL(o);a.username="",a.password="";const s=a.pathname!==""&&a.pathname!=="/"?"/…REDACTED…":"";return`${a.origin}${s}`}catch{return o.replace(/(:\/\/)[^@/]+@/,"$1")||"[REDACTED]"}},h=o=>{if(!o)return o;const a={};for(const s of Object.keys(o))a[s]="[REDACTED]";return a},u=o=>{const a=structuredClone(o);if(a.signing?.key&&(a.signing={...a.signing,key:m(a.signing.key)}),a.httpProxy&&(a.httpProxy=i(a.httpProxy)),a.notifications){const s=a.notifications,n=r=>({...r,webhook:i(r.webhook)}),t=r=>({...r,webhook:i(r.webhook)}),e=r=>({...r,headers:h(r.headers),url:i(r.url)});s.slack&&(s.slack=Array.isArray(s.slack)?s.slack.map(r=>n(r)):n(s.slack)),s.discord&&(s.discord=Array.isArray(s.discord)?s.discord.map(r=>t(r)):t(s.discord)),s.webhook&&(s.webhook=Array.isArray(s.webhook)?s.webhook.map(r=>e(r)):e(s.webhook))}return a},g=o=>o&&o.map(a=>p(a)),b=(o,a,s)=>{const n=o.printConfig;if(n===void 0||n===!1||n==="")return!1;const t=d(n),e=u(a.config),r=e.gitUser?{...e.gitUser,email:e.gitUser.email?"[REDACTED]":e.gitUser.email}:e.gitUser,c={access:e.access,aggregateRelease:e.aggregateRelease,allowCustomCommands:e.allowCustomCommands,baseBranch:e.baseBranch,bumpDevDependencies:e.bumpDevDependencies,bumpMinorPreMajor:e.bumpMinorPreMajor,bumpPatchForMinorPreMajor:e.bumpPatchForMinorPreMajor,changelog:e.changelog,changesDir:e.changesDir,channels:e.channels,defaultManaged:e.defaultManaged,detectCatalogChanges:e.detectCatalogChanges,fixed:g(e.fixed),floatingMajorTag:e.floatingMajorTag,githubHost:e.githubHost,gitlabHost:e.gitlabHost,gitUser:r,httpProxy:e.httpProxy,ignore:e.ignore,include:e.include,linked:g(e.linked),notifications:e.notifications,postPublishCommand:e.postPublishCommand,postVersionCommand:e.postVersionCommand,prePublishCommand:e.prePublishCommand,preVersionCommand:e.preVersionCommand,privatePackages:e.privatePackages,provider:e.provider,publish:e.publish,releaseNoteTemplate:e.releaseNoteTemplate,releaseTagPattern:e.releaseTagPattern,signing:e.signing,snapshot:e.snapshot,successWalk:e.successWalk,updateInternalDependencies:e.updateInternalDependencies,versionPr:e.versionPr};return t&&(c.__resolved__={branch:a.branch,channel:a.channel,cwd:a.cwd,packageCount:a.packages.length,packageManager:a.pm.id,packageNames:a.packages.map(l=>l.name).sort(),perPackageConfigKeys:[...a.perPackageConfig.keys()].sort()}),process.stdout.write(`${JSON.stringify(c,null,2)}
|
|
2
|
+
`),!0};export{b as printConfigIfRequested};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{createRequire as l}from"node:module";import{E as n}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";const u=l(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=o=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[e,s]=i.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return i.getBuiltinModule(o)}return u(o)},{createInterface:c}=p("node:readline"),a=(o,e)=>new Promise(s=>{o.question(e,r=>{s(r.trim())})}),f=async(o,e=!0)=>{const s=c({input:process.stdin,output:process.stdout});try{const r=await a(s,`${o} ${n(e?"[Y/n]":"[y/N]")} `);return r===""?e:/^y(?:es)?$/i.test(r)}finally{s.close()}},w=async(o,e="")=>{const s=c({input:process.stdin,output:process.stdout});try{const r=e?` ${n(`(${e})`)}`:"",t=await a(s,`${o}${r} `);return t===""?e:t}finally{s.close()}},y=async(o,e)=>{if(e.length===0)throw new Error("selectPrompt called with no options.");const s=c({input:process.stdin,output:process.stdout});try{process.stdout.write(`${o}
|
|
2
|
+
`);for(const[r,t]of e.entries())process.stdout.write(` ${r+1}) ${t.label}
|
|
3
|
+
`);for(;;){const r=await a(s,n(` [1-${e.length}] `)),t=Number.parseInt(r,10);if(!Number.isNaN(t)&&t>=1&&t<=e.length)return e[t-1].value;process.stdout.write(n(` Please enter a number between 1 and ${e.length}.
|
|
4
|
+
`))}}finally{s.close()}},$=async(o,e)=>{if(e.length===0)throw new Error("multiSelectPrompt called with no options.");const s=c({input:process.stdin,output:process.stdout});try{process.stdout.write(`${o}
|
|
5
|
+
`);for(const[r,t]of e.entries())process.stdout.write(` ${r+1}) ${t.label}
|
|
6
|
+
`);for(;;){const r=(await a(s,n(" Comma-separated indices (e.g. 1,3,4): "))).split(",").map(t=>t.trim()).filter(Boolean).map(t=>Number.parseInt(t,10));if(r.every(t=>!Number.isNaN(t)&&t>=1&&t<=e.length))return r.map(t=>e[t-1].value);process.stdout.write(n(` Please enter comma-separated numbers between 1 and ${e.length}.
|
|
7
|
+
`))}}finally{s.close()}};export{f as confirmPrompt,$ as multiSelectPrompt,y as selectPrompt,w as textPrompt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as v}from"node:module";const _=v(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=t=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[e,s]=d.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return d.getBuiltinModule(t)}return _(t)},{createHash:S}=g("node:crypto"),{createReadStream:j}=g("node:fs"),{lstat:P,realpath:A,stat:D}=g("node:fs/promises"),{resolve:h,isAbsolute:E,join:x,sep:k}=g("node:path"),m=(t,e)=>{const s=h(t),i=h(e),r=s.endsWith(k)?s:`${s}${k}`;return i===s||i.startsWith(r)},C=t=>{const e=Array.isArray(t)?t[0]:t;if(e===null||typeof e!="object")return;const{files:s}=e;if(!Array.isArray(s))return;const i=[];for(const r of s)r&&typeof r.path=="string"&&i.push(r.path);return i},R=["**/*.test.*","**/__tests__/**","**/__fixtures__/**"],T=async t=>{const e=[];let s;try{({scanFiles:s}=await import("@visulima/secret-scanner"))}catch{return{findings:[{hint:"pnpm add -D @visulima/secret-scanner, or set publish.guards.packSecretScan: false.",id:"packSecretScan:dep-missing",message:"publish.guards.packSecretScan is enabled but @visulima/secret-scanner is not installed."}],gate:"packSecretScan",passed:!1}}const i=[];for(const a of t.files){const o=E(a)?a:x(t.pkgDir,a);m(t.pkgDir,o)&&i.push(o)}const r=t.ignore??R,n=await s(i,{walk:{excludePatterns:[...r]}});for(const a of n)e.push({hint:"Add the file to .npmignore / package.json#files, or rotate the credential.",id:`packSecretScan:${a.ruleId}:${a.file}`,message:`${a.ruleId} match in ${a.file} (line ${a.startLine}, ${a.confidence} confidence).`});return{findings:e,gate:"packSecretScan",passed:e.length===0}},F=t=>typeof t=="string",y=(t,e,s)=>{if(t!==null){if(F(t)){s.push({keyPath:e,target:t});return}if(Array.isArray(t)){for(const[i,r]of t.entries())y(r,`${e}[${i}]`,s);return}if(typeof t=="object")for(const[i,r]of Object.entries(t))y(r,e===""?i:`${e}.${i}`,s)}},L=async(t,e)=>{if(!e.startsWith("./"))return!0;const s=e.replace(/^\.\//,""),i=s.includes("*"),r=i?s.split("*",1)[0].replace(/\/$/,""):s,n=x(t,r);if(!m(t,n))return!1;try{const a=await P(n);if(a.isSymbolicLink()){const o=await A(n);if(!m(t,o))return!1;const c=await D(o);return i?c.isDirectory():!0}return i?a.isDirectory():!0}catch{return!1}},M=async(t,e)=>{const s=[],i=[];for(const r of["main","module","types","typings","browser"]){const n=e[r];typeof n=="string"&&i.push({keyPath:r,target:n})}if(typeof e.bin=="string")i.push({keyPath:"bin",target:e.bin});else if(e.bin&&typeof e.bin=="object")for(const[r,n]of Object.entries(e.bin))typeof n=="string"&&i.push({keyPath:`bin.${r}`,target:n});e.exports!==void 0&&y(e.exports,"exports",i);for(const{keyPath:r,target:n}of i)await L(t,n)||s.push({hint:"Run the build before publishing, or remove the dangling export.",id:`exportsExist:${r}:${n}`,message:`Manifest field \`${r}\` points at \`${n}\` which does not exist in the pack root.`});return{findings:s,gate:"exportsExist",passed:s.length===0}},O=["preinstall","install","postinstall"],q=t=>t===void 0||t==="off"?{allow:{},mode:"off"}:typeof t=="string"?{allow:{},mode:t}:{allow:t.allow??{},mode:t.mode},N=(t,e)=>{const s=[],i=q(e);if(i.mode==="off")return{findings:s,gate:"lifecycleScripts",passed:!0};const r=t.scripts??{};for(const n of O){const a=r[n];a===void 0||i.allow[n]===a||s.push({hint:`Add to publish.guards.lifecycleScripts.allow.${n}, or set the gate to "warn"/"off".`,id:`lifecycleScripts:${n}`,message:`Lifecycle script \`${n}\` is set to \`${a}\` but is not in the allow-list.`})}return{findings:s,gate:"lifecycleScripts",passed:s.length===0}},w={critical:4,high:3,low:1,moderate:2},$=9e4,W=async(t,e,s)=>{const i=[];if(s===void 0||s==="off")return{findings:i,gate:"audit",passed:!0};const r=w[s]??4,n=Symbol("audit-timeout");let a;const o=new Promise(u=>{a=setTimeout(u,$,n)});let c;try{const u=await Promise.race([e.run("npm",["audit","--omit=dev","--json"],{cwd:t,silent:!0}),o]);if(u===n)return{findings:[{hint:'Network or registry outage — re-run later, or set publish.guards.audit: "off".',id:"audit:timeout",message:`\`npm audit\` exceeded ${$}ms and was aborted.`}],gate:"audit",passed:!1};c=u}finally{a&&clearTimeout(a)}let p;try{p=JSON.parse(c.stdout)}catch{return{findings:[{hint:c.stderr.trim()||"Re-run npm audit manually to inspect.",id:"audit:parse",message:`Could not parse \`npm audit\` output for ${t}.`}],gate:"audit",passed:!1}}const l=p.metadata?.vulnerabilities??{};for(const[u,f]of Object.entries(l)){if(f<=0)continue;const b=w[u];b!==void 0&&b>=r&&i.push({hint:"npm audit fix --omit=dev, or raise the threshold via publish.guards.audit.",id:`audit:${u}`,message:`${f} runtime ${u}-severity advisory(s) reported by npm audit.`})}return{findings:i,gate:"audit",passed:i.length===0}},G=async t=>{const e=h(t),s=S("sha256"),i=S("sha512");let r=0;return await new Promise((n,a)=>{const o=j(e);o.on("data",c=>{s.update(c),i.update(c),r+=c.length}),o.on("end",()=>{n()}),o.on("error",a)}),{path:e,sha256:s.digest("hex"),sha512:i.digest("hex"),size:r}},I=async t=>{const e=t.config??{},s=[],i=(l,u)=>u.catch(f=>({findings:[{hint:"Re-run with --debug to capture the stack, or disable this gate.",id:`${l}:internal-error`,message:`Guard "${l}" threw: ${f instanceof Error?f.message:String(f)}`}],gate:l,passed:!1}));if(e.packSecretScan){const l=typeof e.packSecretScan=="object"?e.packSecretScan.ignore:void 0;s.push(i("packSecretScan",T({files:t.packFiles,ignore:l,pkgDir:t.pkgDir})))}e.exportsExist&&s.push(i("exportsExist",M(t.pkgDir,t.manifest))),e.audit&&e.audit!=="off"&&s.push(i("audit",W(t.pkgDir,t.runner,e.audit)));const r=await Promise.all(s),n=N(t.sourceManifest??t.manifest,e.lifecycleScripts),a=[...r];n.gate&&e.lifecycleScripts!==void 0&&e.lifecycleScripts!=="off"&&a.push(n);const o=typeof e.lifecycleScripts=="string"?e.lifecycleScripts:e.lifecycleScripts?.mode??"off",c=[],p=[];for(const l of a)l.passed||(l.gate==="lifecycleScripts"&&o==="warn"?p.push(l):c.push(l));return{blockers:c,results:a,warnings:p}};export{C as extractPackFilesFromRaw,G as hashTarball,M as runExportsExist,N as runLifecycleScripts,T as runPackSecretScan,I as runPublishGuards,W as runRuntimeAudit};
|