@visulima/vis 1.0.0-alpha.41 → 1.0.0-alpha.42
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 +14 -0
- package/LICENSE.md +265 -35
- package/dist/bin.js +1 -1
- package/dist/binx.js +2 -2
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +1 -1
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/cli-exec.js +1 -0
- package/dist/packem_chunks/{bin.js → cli-main.js} +282 -274
- package/dist/packem_chunks/config.js +8 -11
- package/dist/packem_chunks/devtools.js +1 -78
- package/dist/packem_chunks/dispatch.js +4 -0
- package/dist/packem_chunks/doctor-probe.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +3 -3
- 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/handler2.js +1 -4
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler22.js +2 -2
- package/dist/packem_chunks/handler23.js +5 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler26.js +1 -5
- package/dist/packem_chunks/handler27.js +5 -1
- package/dist/packem_chunks/handler28.js +1 -3
- package/dist/packem_chunks/handler29.js +3 -1
- package/dist/packem_chunks/handler3.js +1 -4
- package/dist/packem_chunks/handler30.js +1 -1
- package/dist/packem_chunks/handler31.js +1 -2
- package/dist/packem_chunks/handler32.js +2 -2
- package/dist/packem_chunks/handler33.js +2 -2
- package/dist/packem_chunks/handler34.js +2 -3
- package/dist/packem_chunks/handler35.js +3 -6
- package/dist/packem_chunks/handler36.js +6 -1
- package/dist/packem_chunks/handler37.js +1 -42
- package/dist/packem_chunks/handler38.js +42 -8
- package/dist/packem_chunks/handler39.js +8 -9
- package/dist/packem_chunks/handler4.js +4 -6
- package/dist/packem_chunks/handler40.js +9 -75
- package/dist/packem_chunks/handler41.js +75 -5
- package/dist/packem_chunks/handler42.js +5 -4
- package/dist/packem_chunks/handler43.js +4 -3
- package/dist/packem_chunks/handler44.js +3 -2
- package/dist/packem_chunks/handler45.js +2 -1
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler47.js +1 -1
- package/dist/packem_chunks/handler48.js +1 -3
- package/dist/packem_chunks/handler49.js +3 -1
- package/dist/packem_chunks/handler5.js +4 -8
- package/dist/packem_chunks/handler50.js +1 -7
- package/dist/packem_chunks/handler51.js +6 -32
- package/dist/packem_chunks/handler52.js +33 -3
- package/dist/packem_chunks/handler53.js +3 -8
- package/dist/packem_chunks/handler54.js +6 -2
- package/dist/packem_chunks/handler55.js +4 -1
- package/dist/packem_chunks/handler56.js +1 -12
- package/dist/packem_chunks/handler57.js +11 -6
- package/dist/packem_chunks/handler58.js +3 -3
- package/dist/packem_chunks/handler59.js +5 -5
- package/dist/packem_chunks/handler6.js +6 -1
- package/dist/packem_chunks/handler60.js +2 -2
- package/dist/packem_chunks/handler61.js +1 -1
- package/dist/packem_chunks/handler62.js +4 -4
- package/dist/packem_chunks/handler63.js +3 -3
- package/dist/packem_chunks/handler64.js +4 -4
- package/dist/packem_chunks/handler65.js +9 -708
- package/dist/packem_chunks/handler66.js +6 -6
- package/dist/packem_chunks/handler67.js +4 -4
- package/dist/packem_chunks/handler68.js +1 -1
- package/dist/packem_chunks/handler69.js +5 -5
- package/dist/packem_chunks/handler7.js +8 -1
- package/dist/packem_chunks/handler70.js +6 -6
- package/dist/packem_chunks/handler71.js +9 -9
- package/dist/packem_chunks/handler72.js +708 -48
- package/dist/packem_chunks/handler73.js +48 -27
- package/dist/packem_chunks/handler74.js +27 -3
- package/dist/packem_chunks/handler75.js +3 -190
- package/dist/packem_chunks/handler76.js +189 -37
- package/dist/packem_chunks/handler77.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 +4 -4
- package/dist/packem_chunks/index2.js +1 -1
- package/dist/packem_chunks/index3.js +135 -0
- package/dist/packem_chunks/index4.js +74 -0
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/lean.js +4 -0
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/loader2.js +1 -1
- package/dist/packem_chunks/orchestrator.js +3 -3
- package/dist/packem_chunks/prompts.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/registry.js +2 -2
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/shell-runner.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tar.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/ts-loader.js +2 -0
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_chunks/version-resolver.js +2 -2
- package/dist/packem_shared/CONFIG_FILES-MsOntfYT.js +1 -0
- package/dist/packem_shared/{Table-CcVkyULl-B_ef6zfS.js → Table-CcVkyULl-DLWu6XHL.js} +25 -26
- package/dist/packem_shared/{advisories-DLeO5KMN.js → advisories-aiDtubZQ.js} +1 -1
- package/dist/packem_shared/{affected-shas-cVnX8-zs.js → affected-shas-C1XuRlvo.js} +1 -1
- package/dist/packem_shared/{ai-analysis-BUeX2J2H.js → ai-analysis-CubpCxZJ.js} +4 -4
- package/dist/packem_shared/{ai-fix-9Vzlp6XU.js → ai-fix-Btd5AnSr.js} +2 -2
- package/dist/packem_shared/augment-8fIWWGSc.js +3 -0
- package/dist/packem_shared/bin-CnDBuLh3.js +2 -0
- package/dist/packem_shared/build-scripts-Doxce2VM.js +1 -0
- package/dist/packem_shared/command-runtime-RiCMa2C8.js +1 -0
- package/dist/packem_shared/compile-cache-B_Vf_WxT.js +3 -0
- package/dist/packem_shared/{cyclonedx-Cadls41z.js → cyclonedx-NUJ9R2GQ.js} +1 -1
- package/dist/packem_shared/dependency-scan-B0HV_qeB.js +1 -0
- package/dist/packem_shared/{docker-BMLrNtWm.js → docker-DKlF-gk3.js} +1 -1
- package/dist/packem_shared/failure-log-C7r6UZLP.js +2 -0
- package/dist/packem_shared/{giget-DHY1sQZC.js → giget-DVTFJlbR.js} +2 -2
- package/dist/packem_shared/glob-fqg4KepW-7Bs2kZuM.js +1 -0
- package/dist/packem_shared/index-BKFEWXU_.js +1 -0
- package/dist/packem_shared/index-CPhv-r4c.js +28 -0
- package/dist/packem_shared/{index-DGSsjmpV.js → index-Cb4x6lWY.js} +1 -1
- package/dist/packem_shared/index-DjTWo3sH.js +1 -0
- package/dist/packem_shared/{index-BDmTbWX1.js → index-OQZQyN5R.js} +1 -1
- package/dist/packem_shared/index.server-J83sowC4.js +2 -0
- package/dist/packem_shared/{lifecycle-4z9hHE5b.js → lifecycle-D5roTh0a.js} +2 -2
- package/dist/packem_shared/{lockfile-C8Q1_4KK.js → lockfile-DIGyLfmF.js} +1 -1
- package/dist/packem_shared/main-B3juSU5z.js +1 -0
- package/dist/packem_shared/manifests-pLwnVmCN.js +1 -0
- package/dist/packem_shared/{min-release-age-D1alDE3K.js → min-release-age-pUAqTiv3.js} +3 -3
- package/dist/packem_shared/missing-package-json-DhYzuKhD.js +1 -0
- package/dist/packem_shared/{native-config-sync-BEkJW7g3.js → native-config-sync-4K9wWTj5.js} +1 -1
- package/dist/packem_shared/{osv-bloom-B03tUWf3.js → osv-bloom-OuTfu_LE.js} +1 -1
- package/dist/packem_shared/{pm-runner-BKZQo7Ts.js → pm-runner-Dws_Bw1y.js} +1 -1
- package/dist/packem_shared/provenance-C0P-UYOM.js +1 -0
- package/dist/packem_shared/readJsonSync-CvkZyKmL-CY7PZob_.js +4 -0
- package/dist/packem_shared/registry-keys-D4chF-Wj.js +1 -0
- package/dist/packem_shared/{resolve-explicit-C6WM-I2u.js → resolve-explicit-Cgheka3B.js} +3 -3
- package/dist/packem_shared/resolve-runtime-CJSWV-K8.js +1 -0
- package/dist/packem_shared/run-file-B4TqKa0X.js +1 -0
- package/dist/packem_shared/runtime-check-0lUJvgKt.js +1 -0
- package/dist/packem_shared/runtime-process-Dmz0vCJy-DUwTvH1J.js +1 -0
- package/dist/packem_shared/s1ngularity-Du1NnSFP.js +1 -0
- package/dist/packem_shared/scan-progress-CN9ONR0y.js +2 -0
- package/dist/packem_shared/{selectors-GCJIe342.js → selectors-UmnAuc26.js} +1 -1
- package/dist/packem_shared/{signatures-Xpd6HjG_.js → signatures-BOUhghTv.js} +1 -1
- package/dist/packem_shared/{spinner-CV3WVJLv.js → spinner-lhXugSx3.js} +1 -1
- package/dist/packem_shared/tabs-DTiU3usb.js +1 -0
- package/dist/packem_shared/target-options-ChWcK60i.js +1 -0
- package/dist/packem_shared/toolchain-DyCKnGch.js +5 -0
- package/dist/packem_shared/typosquats-DBOvXwph.js +1 -0
- package/dist/packem_shared/use-measured-height-CK2Co3XI.js +1 -0
- package/dist/packem_shared/verify-CVPYlUrF.js +1 -0
- package/dist/packem_shared/vis-update-app-DtHkwBca.js +1 -0
- package/dist/packem_shared/watch-Bkp_AAbc.js +1 -0
- package/dist/packem_shared/watch-loop-D9zbXzRd.js +11 -0
- package/dist/runtime/preload.d.ts +1 -0
- package/dist/runtime/preload.js +1 -0
- package/index.d.ts +215 -201
- package/index.js +28 -27
- package/package.json +17 -26
- package/dist/packem_shared/CONFIG_FILES-BfaR0jKT.js +0 -1
- package/dist/packem_shared/build-scripts-CCCi8U66.js +0 -1
- package/dist/packem_shared/command-runtime-CR70qSUM.js +0 -1
- package/dist/packem_shared/dependency-scan-DnTgYleU.js +0 -1
- package/dist/packem_shared/failure-log-CEWP3bP0.js +0 -2
- package/dist/packem_shared/glob-fqg4KepW-B7EjLRvw.js +0 -1
- package/dist/packem_shared/index-3jMNqQom.js +0 -1
- package/dist/packem_shared/index-Bt521H5J.js +0 -30
- package/dist/packem_shared/manifests-Dj3pRKBT.js +0 -1
- package/dist/packem_shared/missing-package-json-8vNHwbqw.js +0 -1
- package/dist/packem_shared/provenance-BFEwKgI3.js +0 -1
- package/dist/packem_shared/registry-keys-BfFto6vI.js +0 -1
- package/dist/packem_shared/runtime-check-Stc9AI78.js +0 -1
- package/dist/packem_shared/s1ngularity-DCPmPE5M.js +0 -1
- package/dist/packem_shared/scan-progress-CFhc0CMj.js +0 -2
- package/dist/packem_shared/tabs-BuTy5gPV.js +0 -1
- package/dist/packem_shared/toolchain-pR7AJ-tB.js +0 -5
- package/dist/packem_shared/typosquats-DN78xx1x.js +0 -1
- package/dist/packem_shared/use-measured-height-_eVGWtWt.js +0 -1
- package/dist/packem_shared/verify-6WCmFmy8.js +0 -1
- package/dist/packem_shared/vis-update-app-k3fDxech.js +0 -1
- package/dist/packem_shared/watch-BvIwLG4N.js +0 -1
- package/dist/packem_shared/watch-loop-DWkvv2tK.js +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as D}from"node:module";import{E as L}from"../packem_chunks/config.js";import{advisoriesQuery as M,
|
|
1
|
+
import{createRequire as D}from"node:module";import{E as L}from"../packem_chunks/config.js";import{advisoriesQuery as M,advisoriesIngest as W,advisoriesStatus as E,NATIVE_BINDING_VERSION as f}from"#native";const R=D(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,c=s=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[e,t]=l.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return l.getBuiltinModule(s)}return R(s)},{randomUUID:I}=c("node:crypto"),{existsSync:$,createWriteStream:T}=c("node:fs"),{mkdir:O,unlink:P,stat:U}=c("node:fs/promises"),{join:g,dirname:k}=c("node:path"),{Readable:x}=c("node:stream"),{pipeline:C}=c("node:stream/promises"),w=6;if(f!==w)throw new Error(`vis native binding ABI mismatch in advisories: expected ${w}, got ${f}. Rebuild via \`pnpm --filter @visulima/vis run build:native\` or reinstall the platform binding package.`);const Q="https://osv-vulnerabilities.storage.googleapis.com",j=new Set(["osv-vulnerabilities.storage.googleapis.com"]);class q extends Error{cause="DB_NOT_FOUND";constructor(e){super(`No local advisory DB at ${e}. Run 'vis advisories sync' first.`),this.name="AdvisoryDbNotFoundError"}}class p extends Error{cause="SOURCE_NOT_ALLOWED";constructor(e){super(`Advisory source host '${e}' is not in the built-in allowlist. Add it to \`security.audit.advisories.allowedHosts\` if intentional.`),this.name="AdvisorySourceNotAllowedError"}}class A extends Error{cause="SYNC_NETWORK";constructor(e,t){super(`Advisory sync failed for ${e}: ${t}. Check connectivity, proxy env vars, or --source.`),this.name="AdvisorySyncNetworkError"}}const y=s=>{const e=L("vis",{create:!0,cwd:s})??g(s,"node_modules",".cache","vis");return g(e,"advisories","db.sqlite")},B=(s,e)=>{let t;try{t=new URL(s)}catch{throw new p(s)}if(t.protocol!=="https:")throw new p(`${t.protocol}//${t.host}`);if(!new Set([...j,...e??[]]).has(t.host))throw new p(t.host);return t},J=async s=>{const e=s.dbPath??y(s.workspaceRoot);await O(k(e),{recursive:!0});const t=B(s.source,s.allowedHosts),d=new URL(`${s.ecosystem}/all.zip`,z(t.toString())),u=await V(e,s.ecosystem);let r=null;if(!s.force){const i=await b(d,{method:"HEAD"});if(i.ok&&(r=i.headers.get("etag"),r&&u&&r===u))return{advisoriesIngested:0,dbPath:e,durationMs:0,upToDate:!0}}const n=`${e}.${s.ecosystem}.${process.pid}.${I()}.zip.tmp`,o=await b(d,{method:"GET"});if(!o.ok||!o.body)throw new A(d.toString(),o.status);r||(r=o.headers.get("etag"));const v=o.headers.get("content-length"),a=v?Number.parseInt(v,10):null;let m=0;const _=T(n),h=x.fromWeb(o.body);s.onProgress&&a&&h.on("data",i=>{m+=i.byteLength,s.onProgress?.(m,a,"download")}),await C(h,_);try{const i=await W({dbPath:e,ecosystem:s.ecosystem,manifestEtag:r??void 0,zipPath:n},(S,N)=>s.onProgress?.(S,N,"ingest"));return{advisoriesIngested:i.advisoriesIngested,dbPath:e,durationMs:i.durationMs,upToDate:!1}}finally{await P(n).catch(()=>{})}},X=(s,e)=>{if(s.length===0)return new Map;const t=e.dbPath??y(e.workspaceRoot),d=e.ecosystem??"npm";if(!$(t))throw new q(t);const u=s.map(o=>({ecosystem:d,name:o.name,version:o.version})),r=M(t,u),n=new Map;for(const[o,v]of s.entries()){const a=r[o];!a||a.vulnerabilities.length===0||n.set(v.name,a.vulnerabilities.map(m=>H(m)))}return n},Z=async(s,e)=>{const t=e??y(s);return E(t)},V=async(s,e)=>{try{await U(s)}catch{return null}return E(s).ecosystems.find(t=>t.name===e)?.manifestEtag??null},H=s=>({aliases:s.aliases.length>0?s.aliases:void 0,cvssScore:s.cvssScore??void 0,fixedVersions:s.fixedVersions,id:s.id,severity:F(s.severity),summary:s.summary}),F=s=>{const e=s.toUpperCase();return e==="CRITICAL"||e==="HIGH"||e==="MODERATE"||e==="LOW"?e:"UNKNOWN"},z=s=>s.endsWith("/")?s:`${s}/`,b=async(s,e)=>{try{return await fetch(s,e)}catch(t){throw new A(s.toString(),t instanceof Error?t.message:String(t))}};export{q as A,Q as D,Z as g,X as q,y as r,J as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as l}from"node:module";import{f as g,v as h}from"./index-
|
|
1
|
+
import{createRequire as l}from"node:module";import{f as g,v as h}from"./index-OQZQyN5R.js";const E=l(import.meta.url),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=e=>{if(typeof _<"u"&&_.versions&&_.versions.node){const[s,t]=_.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return _.getBuiltinModule(e)}return E(e)},{spawnSync:p}=d("node:child_process"),b="0000000000000000000000000000000000000000",A=e=>{if(g(e))try{const s=h(e);return JSON.parse(s)}catch{return}},I=(e,s)=>{const t=p("git",e,{cwd:s,encoding:"utf8"});if(!(t.error||typeof t.status!="number"||t.status!==0))return typeof t.stdout=="string"?t.stdout.trim():void 0},c=e=>typeof e=="string"&&e.length>0&&e!==b,f=(e,s,t)=>{const r=[],o=e.GITHUB_BASE_REF,i=e.GITHUB_SHA??"HEAD";if(o&&o.length>0)return r.push(`pull_request: $GITHUB_BASE_REF=${o}`),{base:`origin/${o}`,head:i,notes:r,provider:"github"};const a=e.GITHUB_EVENT_PATH,n=a?t(a):void 0;if(n){const u=typeof n.before=="string"?n.before:void 0;if(c(u))return r.push(`push: event.before=${u}`),{base:u,head:i,notes:r,provider:"github"}}return r.push(`fallback: origin/${s}`),{base:`origin/${s}`,head:i,notes:r,provider:"github"}},R=(e,s)=>{const t=[],r=e.CI_COMMIT_SHA??"HEAD";if(e.CI_PIPELINE_SOURCE==="merge_request_event"){const a=e.CI_MERGE_REQUEST_DIFF_BASE_SHA;if(c(a))return t.push(`merge_request: $CI_MERGE_REQUEST_DIFF_BASE_SHA=${a}`),{base:a,head:r,notes:t,provider:"gitlab"};const n=e.CI_MERGE_REQUEST_TARGET_BRANCH_NAME;if(n&&n.length>0)return t.push(`merge_request: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME=${n}`),{base:`origin/${n}`,head:r,notes:t,provider:"gitlab"}}const o=e.CI_COMMIT_BEFORE_SHA;if(c(o))return t.push(`push: $CI_COMMIT_BEFORE_SHA=${o}`),{base:o,head:r,notes:t,provider:"gitlab"};const i=e.CI_DEFAULT_BRANCH??s;return t.push(`fallback: origin/${i}`),{base:`origin/${i}`,head:r,notes:t,provider:"gitlab"}},C=(e,s)=>{const t=[],r=e.BUILDKITE_COMMIT??"HEAD",o=e.BUILDKITE_PULL_REQUEST_BASE_BRANCH;return o&&o.length>0?(t.push(`pull_request: $BUILDKITE_PULL_REQUEST_BASE_BRANCH=${o}`),{base:`origin/${o}`,head:r,notes:t,provider:"buildkite"}):(t.push(`fallback: origin/${s} (buildkite has no canonical previous-build SHA env)`),{base:`origin/${s}`,head:r,notes:t,provider:"buildkite"})},v=(e,s)=>{const t=[],r=e.CIRCLE_SHA1??"HEAD",o=e.CIRCLE_PR_BASE_BRANCH;return o&&o.length>0?(t.push(`pull_request: $CIRCLE_PR_BASE_BRANCH=${o}`),{base:`origin/${o}`,head:r,notes:t,provider:"circleci"}):(t.push(`fallback: origin/${s} (circleci has no canonical previous-build SHA env)`),{base:`origin/${s}`,head:r,notes:t,provider:"circleci"})},T=(e,s,t)=>{const r=[],o=s(["merge-base","HEAD",`origin/${e}`],t);return o&&o.length>0?(r.push(`local: git merge-base HEAD origin/${e}=${o}`),{base:o,head:"HEAD",notes:r,provider:"local"}):(r.push(`local fallback: origin/${e} (no merge-base available)`),{base:`origin/${e}`,head:"HEAD",notes:r,provider:"local"})},$=e=>{const s=e?.env??process.env,t=e?.defaultBase??"main",r=e?.readEventPayload??A,o=e?.runGit??I,i=e?.workspaceRoot??process.cwd();return s.GITHUB_ACTIONS==="true"?f(s,t,r):s.GITLAB_CI==="true"?R(s,t):s.BUILDKITE==="true"?C(s,t):s.CIRCLECI==="true"?v(s,t):T(t,o,i)};export{$ as r};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{createRequire as G}from"node:module";import{
|
|
2
|
-
`)[0]?.trim();return a&&a.length>0?a:void 0}catch{return}},$e=e=>{const a=P();if(T){const t=process.env.APPDATA??"",r=process.env.LOCALAPPDATA??"",s=process.env.ProgramFiles??"";return[h(t,"npm",`${e}.cmd`),h(t,"npm",e),h(r,"Programs",e,`${e}.exe`),h(s,e,`${e}.exe`),h(a,".npm-global","bin",`${e}.cmd`)]}return[`/opt/homebrew/bin/${e}`,`/usr/local/bin/${e}`,h(a,".npm-global","bin",e),h(a,".local","bin",e),h(a,".cargo","bin",e)]},Te=e=>{try{const a=N(e,["--version"],{encoding:"utf8",shell:D(e),stdio:["pipe","pipe","pipe"],timeout:ce}),t=ie.exec(a);return t?t[1]:void 0}catch{return}},F=(e,a={})=>{const t=V[e],r={available:!1,name:e},s=a.version!==!1,o=i=>{if(s)return Te(i)},n=process.env[t.envVariable];if(n&&_(O(n))){const i=O(n);return{...r,available:!0,detectionMethod:"envvar",path:i,version:o(i)}}const c=[t.command,...t.alternateCommands];for(const i of c){const u=
|
|
1
|
+
import{createRequire as G}from"node:module";import{aw as ee,ax as te,ay as re,h as ae,d as f,a2 as se,m as k,e as oe,az as ne}from"../packem_chunks/cli-main.js";import"./bin-CnDBuLh3.js";const K=G(import.meta.url),M=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,S=e=>{if(typeof M<"u"&&M.versions&&M.versions.node){const[a,t]=M.versions.node.split(".").map(Number);if(a>22||a===22&&t>=3||a===20&&t>=16)return M.getBuiltinModule(e)}return K(e)},{spawn:Y,execFileSync:N,execFile:X}=S("node:child_process"),{existsSync:_}=S("node:fs"),{platform:Z,homedir:P}=S("node:os"),{join:h}=S("node:path"),{promisify:Q}=S("node:util"),ie=/v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/,ue=5e3,ce=1e4,de=3e5,le=4096,T=Z()==="win32",q=["amp","claude","codex","copilot","crush","cursor","droid","gemini","kimi","opencode","qwen"];class w extends Error{exitCode;durationMs;provider;stderr;stdout;timedOut;aborted;constructor(a,t){super(a),this.name="AiRunError",this.provider=t.provider,this.exitCode=t.exitCode??null,this.durationMs=t.durationMs,this.stdout=t.stdout??"",this.stderr=t.stderr??"",this.timedOut=t.timedOut??!1,this.aborted=t.aborted??!1}}const pe={alternateCommands:[],buildArgs:(e,{dangerous:a})=>{const t=["-x",e];return a&&t.push("--dangerously-allow-all"),t},command:"amp",defaultModel:"",envVariable:"AMP_PATH",supportsMaxTokens:!1,supportsModel:!1},me={alternateCommands:[],buildArgs:(e,{dangerous:a,model:t})=>{const r=[];return a&&r.push("--dangerously-skip-permissions"),t&&r.push("--model",t),r.push("--output-format","text","-p",e),r},command:"claude",defaultModel:"",envVariable:"CLAUDE_PATH",supportsMaxTokens:!1,supportsModel:!0},ge={alternateCommands:["openai-codex"],buildArgs:(e,{dangerous:a,model:t})=>{const r=["exec"];return t&&r.push("--model",t),a&&r.push("--dangerously-bypass-approvals-and-sandbox"),r.push(e),r},command:"codex",defaultModel:"",envVariable:"CODEX_PATH",supportsMaxTokens:!1,supportsModel:!0},he={alternateCommands:[],buildArgs:(e,{dangerous:a,model:t})=>{const r=["-p",e];return a&&r.push("--allow-all-tools"),t&&r.push("--model",t),r},command:"copilot",defaultModel:"",envVariable:"COPILOT_PATH",supportsMaxTokens:!1,supportsModel:!0},fe={alternateCommands:[],buildArgs:(e,{dangerous:a,model:t})=>{const r=["run"];return a&&r.push("--yolo"),t&&r.push("-m",t),r.push(e),r},command:"crush",defaultModel:"",envVariable:"CRUSH_PATH",supportsMaxTokens:!1,supportsModel:!0},ye={alternateCommands:["cursor"],buildArgs:(e,{dangerous:a,model:t})=>{const r=["-p"];return a&&r.push("--force"),r.push("--output-format","text"),t&&r.push("--model",t),r.push(e),r},command:"agent",defaultModel:"",envVariable:"CURSOR_PATH",supportsMaxTokens:!1,supportsModel:!0},ve={alternateCommands:[],buildArgs:(e,{dangerous:a,model:t})=>{const r=[e];return a&&r.push("--skip-permissions-unsafe"),r.push("-o","text"),t&&r.push("-m",t),r},command:"droid",defaultModel:"",envVariable:"DROID_PATH",supportsMaxTokens:!1,supportsModel:!0},be={alternateCommands:["gemini-cli"],buildArgs:(e,{dangerous:a,maxTokens:t,model:r})=>{const s=[];return a||s.push("--sandbox"),r&&s.push("--model",r),s.push("--max-output-tokens",String(t),"-p",e),s},command:"gemini",defaultModel:"gemini-2.5-pro",envVariable:"GEMINI_PATH",supportsMaxTokens:!0,supportsModel:!0},ke={alternateCommands:[],buildArgs:(e,{model:a})=>{const t=["--quiet","-p",e];return a&&t.push("-m",a),t},command:"kimi",defaultModel:"",envVariable:"KIMI_PATH",supportsMaxTokens:!1,supportsModel:!0},we={alternateCommands:[],buildArgs:(e,{model:a})=>{const t=["run",e];return a&&t.push("-m",a),t},command:"opencode",defaultModel:"",envVariable:"OPENCODE_PATH",supportsMaxTokens:!1,supportsModel:!0},Me={alternateCommands:["qwen-code"],buildArgs:(e,{dangerous:a,model:t})=>{const r=["-p",e];return a&&r.push("--yolo"),r.push("-o","text"),t&&r.push("-m",t),r},command:"qwen",defaultModel:"",envVariable:"QWEN_PATH",supportsMaxTokens:!1,supportsModel:!0};Q(X);const V={amp:pe,claude:me,codex:ge,copilot:he,crush:fe,cursor:ye,droid:ve,gemini:be,kimi:ke,opencode:we,qwen:Me},Se=/\.(?:bat|cmd)$/i,D=e=>T&&Se.test(e),L=e=>`"${e.replaceAll('"','""')}"`,O=e=>e==="~"||e.startsWith("~/")||T&&e.startsWith("~\\")?h(P(),e.slice(2)):e,Ae=e=>{try{const a=N(T?"where":"which",[e],{encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:ue}).trim().split(`
|
|
2
|
+
`)[0]?.trim();return a&&a.length>0?a:void 0}catch{return}},$e=e=>{const a=P();if(T){const t=process.env.APPDATA??"",r=process.env.LOCALAPPDATA??"",s=process.env.ProgramFiles??"";return[h(t,"npm",`${e}.cmd`),h(t,"npm",e),h(r,"Programs",e,`${e}.exe`),h(s,e,`${e}.exe`),h(a,".npm-global","bin",`${e}.cmd`)]}return[`/opt/homebrew/bin/${e}`,`/usr/local/bin/${e}`,h(a,".npm-global","bin",e),h(a,".local","bin",e),h(a,".cargo","bin",e)]},Te=e=>{try{const a=N(e,["--version"],{encoding:"utf8",shell:D(e),stdio:["pipe","pipe","pipe"],timeout:ce}),t=ie.exec(a);return t?t[1]:void 0}catch{return}},F=(e,a={})=>{const t=V[e],r={available:!1,name:e},s=a.version!==!1,o=i=>{if(s)return Te(i)},n=process.env[t.envVariable];if(n&&_(O(n))){const i=O(n);return{...r,available:!0,detectionMethod:"envvar",path:i,version:o(i)}}const c=[t.command,...t.alternateCommands];for(const i of c){const u=Ae(i);if(u)return{...r,available:!0,detectionMethod:"which",path:u,version:o(u)}}for(const i of c)for(const u of $e(i))if(_(u))return{...r,available:!0,detectionMethod:"known-path",path:u,version:o(u)};return r},xe=(e={})=>q.map(a=>F(a,e)),Ce=(e={})=>xe(e).filter(a=>a.available),Ee=(e,a,t={})=>{const r=V[e],s=t.model??r.defaultModel,o=t.maxTokens!==void 0&&Number.isFinite(t.maxTokens)?t.maxTokens:le;return r.buildArgs(a,{dangerous:t.dangerous===!0,maxTokens:o,model:s})},Re=async(e,a,t={})=>{if(!e.available||!e.path)throw new w(`AI provider "${e.name}" is not available.`,{durationMs:0,provider:e.name});const r=Ee(e.name,a,t),s=t.timeoutMs!==void 0&&Number.isFinite(t.timeoutMs)?t.timeoutMs:de,o=e.path,n=D(o),c=Date.now();if(t.signal?.aborted)throw new w(`${e.name} CLI run was aborted.`,{aborted:!0,durationMs:0,provider:e.name});return new Promise((i,u)=>{const m={cwd:t.cwd,env:{...process.env,...t.env,FORCE_COLOR:"0",NO_COLOR:"1"},shell:n,stdio:["pipe","pipe","pipe"]},l=n?r.map(d=>L(d)):r,g=Y(n?L(o):o,l,m);g.stdin?.end();let y="",v="",b=!1,E,R,A;const x=()=>{clearTimeout(R),clearTimeout(E),A&&t.signal?.removeEventListener("abort",A)},J=()=>{g.kill("SIGKILL")},I=d=>{if(b)return;b=!0,g.kill("SIGTERM"),E=setTimeout(J,5e3),x();const p=Date.now()-c,W=d?new w(`${e.name} CLI run was aborted.`,{aborted:!0,durationMs:p,provider:e.name,stderr:v,stdout:y}):new w(`${e.name} CLI timed out after ${String(s)}ms`,{durationMs:p,provider:e.name,stderr:v,stdout:y,timedOut:!0});u(W)};R=setTimeout(I,s,!1),A=()=>{I(!0)},t.signal?.addEventListener("abort",A,{once:!0}),g.stdout?.on("data",d=>{const p=d.toString("utf8");y+=p,t.onStdout?.(p)}),g.stderr?.on("data",d=>{const p=d.toString("utf8");v+=p,t.onStderr?.(p)}),g.on("close",d=>{if(b)return;b=!0,x();const p=Date.now()-c;d===0?i({durationMs:p,exitCode:d,provider:e.name,stderr:v,stdout:y}):u(new w(`${e.name} CLI exited with code ${String(d)}: ${v||y}`,{durationMs:p,exitCode:d,provider:e.name,stderr:v,stdout:y}))}),g.on("error",d=>{b||(b=!0,x(),u(new w(`Failed to spawn ${e.name} CLI: ${d.message}`,{durationMs:Date.now()-c,provider:e.name,stderr:v,stdout:y})))})})},Ie=12e4,_e=2,Le=1e3,Oe=e=>new Promise(a=>{setTimeout(a,e)}),H=async(e,a,t=_e)=>{let r;for(let s=0;s<=t;s+=1)try{return(await Re(e,a,{timeoutMs:Ie})).stdout}catch(o){if(r=o instanceof Error?o:new Error(String(o)),r.message.includes("timed out"))throw r;if(s<t){const n=Le*2**s;await Oe(n)}}throw r??new Error("AI request failed after retries")},je={amp:30,claude:80,codex:60,copilot:50,crush:35,cursor:40,droid:20,gemini:100,kimi:25,opencode:35,qwen:30},Ne=e=>{if(e?.provider){if(!q.includes(e.provider))return;const r=F(e.provider);return r.available?r:void 0}const a=Ce();if(a.length===0)return;const t={...je,...e?.priority};return a.toSorted((r,s)=>(t[s.name]??0)-(t[r.name]??0))[0]},Pe=new Set(["defer","review","skip","update"]),qe=new Set(["critical","high","low","medium"]),Ve=new Set(["high","low","medium"]),De=50,C=30,Fe=e=>e.map(a=>{const t=a.vulnerabilities&&a.vulnerabilities.length>0?` [VULNERABILITIES: ${a.vulnerabilities.map(s=>`${s.severity} ${s.id}`).join(", ")}]`:"";let r="";if(a.socketReport){const s=Math.round(a.socketReport.score.overall*100),o=[`score:${String(s)}%`];if(a.socketReport.alerts.length>0){const n={};for(const i of a.socketReport.alerts)n[i.severity]=(n[i.severity]??0)+1;const c=Object.entries(n).map(([i,u])=>`${String(u)} ${i}`).join(", ");o.push(`alerts: ${c}`)}o.push(`supply-chain:${String(Math.round(a.socketReport.score.supplyChain*100))}%`),o.push(`quality:${String(Math.round(a.socketReport.score.quality*100))}%`),r=` [SOCKET.DEV: ${o.join(", ")}]`}return`- ${a.packageName}: ${a.currentRange} → ${a.newRange} (${a.updateType})${t}${r}`}).join(`
|
|
3
3
|
`),$=`Respond ONLY with valid JSON in this exact structure:
|
|
4
4
|
{
|
|
5
5
|
"summary": "Brief overall summary",
|
|
@@ -60,9 +60,9 @@ For each package:
|
|
|
60
60
|
5. Flag any packages where skipping the update poses security risk
|
|
61
61
|
6. If Socket.dev scores are provided, factor in supply chain and quality scores — low scores indicate higher risk
|
|
62
62
|
|
|
63
|
-
${$}`},Be=new Set(["compatibility","impact","recommend","security"]),
|
|
63
|
+
${$}`},Be=new Set(["compatibility","impact","recommend","security"]),tt=e=>Be.has(e)?e:"impact",B=(e,a="impact")=>{const t=Fe(e);return He[a](t)},Ue=/```(?:json)?\s*([\s\S]*?)```/,ze=/\{[\s\S]*\}/,Je=e=>{try{return JSON.parse(e)}catch{}const a=Ue.exec(e);if(a?.[1])try{return JSON.parse(a[1])}catch{}const t=ze.exec(e);if(t?.[0])try{return JSON.parse(t[0])}catch{}},We=e=>({action:Pe.has(e.action)?e.action:"review",breakingChanges:Array.isArray(e.breakingChanges)?e.breakingChanges:[],effort:Ve.has(e.effort)?e.effort:"medium",package:typeof e.package=="string"?e.package:"",reason:typeof e.reason=="string"?e.reason:"",riskLevel:qe.has(e.riskLevel)?e.riskLevel:"medium"}),U=(e,a,t)=>{const r=Je(e);if(!r||typeof r!="object")return{analysisType:t,provider:a,recommendations:[],summary:"Failed to parse AI response.",warnings:["AI response was not valid JSON."]};const s=r,o=Array.isArray(s.recommendations)?s.recommendations:[];return{analysisType:t,provider:a,recommendations:o.map(n=>We(n)),summary:typeof s.summary=="string"?s.summary:"",warnings:Array.isArray(s.warnings)?s.warnings:[]}},Ge={eslint:["ESLint 9.0: Flat config required","ESLint 8.0+: New rule formats"],next:["Next.js 13+: App router changes","Next.js 14+: Server components default"],react:["React 17 to 18: Concurrent features","React 18+: Strict mode changes"],typescript:["TypeScript 5.0: New decorators","TypeScript 4.7+: ESM changes"],vite:["Vite 5: Node.js 18+ required"],vue:["Vue 3: Composition API","Vue 3: Breaking template changes"],webpack:["Webpack 5: Node.js polyfills removed"]},Ke=new Set(["bcrypt","cors","crypto-js","express-session","helmet","jose","jsonwebtoken","node-forge","oauth","passport"]),j=(e,a)=>{const t=e.map(r=>{const s=r.vulnerabilities&&r.vulnerabilities.length>0,o=Ke.has(r.packageName),n=Ge[r.packageName]??[];let c="low",i="update",u="low",m="Patch/minor update, safe to apply.";return r.updateType==="major"?(c="high",i=n.length>0?"review":"update",u="medium",m=n.length>0?`Major update with known breaking changes: ${n[0]}`:"Major version update, review changelog before applying."):r.updateType==="minor"&&(c="medium",m="Minor update, generally safe."),s&&(c="high",i="update",m="Security update — current version has known vulnerabilities."),o&&r.updateType==="major"&&(i="review",m="Security-sensitive package with major update, careful review needed.",u="high"),{action:i,breakingChanges:n,effort:u,package:r.packageName,reason:m,riskLevel:c}});return{analysisType:a,provider:"rule-engine",recommendations:t,summary:`Rule-based ${a} analysis for ${String(e.length)} packages.`,warnings:["No AI provider available — using built-in rule engine."]}},Ye=async(e,a,t)=>{const r=B(a,t),s=await H(e,r);return U(s,e.name,t)},Xe=(e,a,t)=>{const r=[],s=[],o=[];for(const n of e)r.push(...n.recommendations),s.push(...n.warnings),n.summary&&o.push(n.summary);return{analysisType:t,provider:a,recommendations:r,summary:o.length===1?o[0]??"":`Analyzed ${String(r.length)} packages in ${String(e.length)} batches.`,warnings:[...new Set(s)]}},z={compatibility:"Compatibility",impact:"Impact",recommend:"Recommendations",security:"Security"},rt=e=>{const a=`${z[e.analysisType]??e.analysisType} Analysis (${e.provider})`,t=e.recommendations.flatMap(s=>{const o=[{action:s.action,effort:s.effort,package:s.package,reason:s.reason,risk:s.riskLevel}];return s.breakingChanges.length>0&&o.push({action:"",effort:"",package:"",reason:`Breaking: ${s.breakingChanges.join("; ")}`,risk:""}),o}),r=process.stdout.columns||80;return ae(f.createElement(se,{borderStyle:"round",flexDirection:"column",paddingLeft:1,paddingRight:1},f.createElement(k,{bold:!0},a),f.createElement(k,null,""),f.createElement(k,null,e.summary),f.createElement(k,null,""),f.createElement(oe,{borderStyle:"none",data:t}),...e.warnings.length>0?[f.createElement(k,null,""),...e.warnings.map((s,o)=>f.createElement(k,{dimColor:!0,key:String(o)},` ${s}`))]:[]),{columns:r})},at=async(e,a,t,r="impact")=>{const s=Ne(t);if(!s)return a.info(`No AI CLI tool found, using rule-based analysis.
|
|
64
64
|
`),j(e,r);const o=ee(s.name,r,e),n=te(o);if(n)return a.info(`Using cached ${r} analysis from ${n.provider}.
|
|
65
65
|
`),n;const c=z[r]??r;a.info(`Running ${c.toLowerCase()} analysis with ${s.name}...
|
|
66
66
|
`);try{let i;if(e.length>De){a.info(`Splitting ${String(e.length)} packages into batches of ${String(C)}...
|
|
67
67
|
`);const u=[];for(let l=0;l<e.length;l+=C)u.push(e.slice(l,l+C));const m=[];for(let l=0;l<u.length;l+=1){a.info(` Batch ${String(l+1)}/${String(u.length)}...`);const g=u[l];g&&m.push(await Ye(s,g,r))}i=Xe(m,s.name,r)}else{const u=await H(s,B(e,r));i=U(u,s.name,r)}return re(o,i,ne(r,t?.cacheTtl)),i}catch(i){const u=i instanceof Error?i.message:String(i);return a.warn(`AI analysis failed (${u}), falling back to rule engine.
|
|
68
|
-
`),j(e,r)}};export{
|
|
68
|
+
`),j(e,r)}};export{tt as K,xe as N,Ne as R,je as S,rt as W,at as Z,Je as b,Re as h,H as r};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as b}from"node:module";import{readLastRunSummary as O}from"@visulima/task-runner";import{a as T}from"./failure-log-
|
|
1
|
+
import{createRequire as b}from"node:module";import{readLastRunSummary as O}from"@visulima/task-runner";import{a as T}from"./failure-log-C7r6UZLP.js";import{a5 as w,a6 as j,a7 as k,y as C,z as D,a8 as P,a9 as F,aa as N}from"../packem_chunks/cli-main.js";import{A as y,B as v,m as A,y as B}from"./index-OQZQyN5R.js";import{R as E,r as M,b as q}from"./ai-analysis-CubpCxZJ.js";const $=b(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=t=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[e,a]=d.versions.node.split(".").map(Number);if(e>22||e===22&&a>=3||e===20&&a>=16)return d.getBuiltinModule(t)}return $(t)},{readFile:_,writeFile:R}=I("node:fs/promises"),H=32*1024,W=(t,e)=>{if(t.length<=e)return t;const a=t.slice(-e),o=t.length-a.length;return`[…${String(o)} bytes truncated from head…]
|
|
2
2
|
${a}`},L=async(t,e)=>e===void 0?O(t,{dataDirectory:C(t)}):D(t,e),ut=async(t,e,a={})=>{const o=a.terminalOutputLimit??H,[s,n]=await Promise.all([T(t,e),L(t,a.runId)]),i=n?w(n,e):void 0;if(!s&&!i)return;let r,c;if(n&&i){const h=await j(t,n.id),p=h?w(h,e):void 0;r=k(i.hashDetails,p?.hashDetails),c=h?.id}const u=s?.terminalOutput??"";return{command:s?.command??void 0,cwd:s?.cwd??void 0,dependencies:i?.dependencies??[],duration:i?.duration,exitCode:s?.exitCode??i?.exitCode,hash:i?.hash??s?.hash,hashDetails:i?.hashDetails,hashDiff:r,previousRunId:c,project:i?.target.project,runId:n?.id??s?.runId,status:s?.status??(i?Y(i):void 0),target:i?.target.target,taskId:e,terminalOutput:W(u,o),terminalOutputCaptured:!!s,timestamp:s?.timestamp??i?.endTime??i?.startTime}},Y=t=>{if(t.exitCode!==void 0&&t.exitCode!==0)return"failure";switch(t.cacheStatus){case"HIT":return"local-cache";case"REMOTE_HIT":return"remote-cache";case"SKIPPED":return"skipped";default:return t.exitCode===0?"success":void 0}},J=3600*1e3,x=80,K=new Set(["high","low","medium"]),U=()=>`You are an expert software engineer helping fix a failing build/test/lint task.
|
|
3
3
|
|
|
4
4
|
You will be given:
|
|
@@ -40,4 +40,4 @@ ${G(t)}`,Q=(t,e)=>{const a=Array.isArray(t.patches)?t.patches:[],o=[];for(const
|
|
|
40
40
|
`);return}const s=a.cache!==!1,n=Z(o.name,t);if(s){const i=P(n);if(i)return e.info(`Using cached fix proposal from ${i.provider}.
|
|
41
41
|
`),i}e.info(`Generating fix proposal with ${o.name}...
|
|
42
42
|
`);try{const i=await M(o,V(t)),r=X(i,o.name);return s&&r.patches.length>0&&!r.cannotFix&&F(n,r,J),r}catch(i){const r=i instanceof Error?i.message:String(i);e.warn(`AI fix proposal failed (${r}).
|
|
43
|
-
`);return}},tt=(t,e,a)=>y(a)?v(a):v(
|
|
43
|
+
`);return}},tt=(t,e,a)=>y(a)?v(a):v(A(e??t,a)),et=(t,e)=>{const a=B(t,e);return a===""?!0:!a.startsWith("..")&&!y(a)},at=(t,e,a)=>{const o=t.indexOf(e),s=Math.max(0,o-x),n=Math.min(t.length,o+e.length+x),i=t.slice(s,n);return{previewAfter:`${t.slice(s,o)}${a}${t.slice(o+e.length,n)}`,previewBefore:i}},dt=async(t,e,a,o={})=>{const s=o.dryRun===!0,n=new Map,i=[];for(const r of a.patches){const c=tt(t,e,r.file);if(!et(t,c)){i.push({absolutePath:c,patch:r,status:"outside-workspace"});continue}let u=n.get(c);if(u===void 0){try{u=await _(c,"utf8")}catch(l){const g=l.code;i.push({absolutePath:c,error:g==="ENOENT"?void 0:l.message,patch:r,status:g==="ENOENT"?"missing-file":"error"});continue}n.set(c,u)}const h=u.indexOf(r.oldString);if(h===-1){i.push({absolutePath:c,patch:r,status:"no-match"});continue}if(u.indexOf(r.oldString,h+r.oldString.length)!==-1){i.push({absolutePath:c,patch:r,status:"ambiguous-match"});continue}const{previewAfter:p,previewBefore:S}=at(u,r.oldString,r.newString),m=`${u.slice(0,h)}${r.newString}${u.slice(h+r.oldString.length)}`;if(!s)try{await R(c,m,"utf8")}catch(l){n.delete(c),i.push({absolutePath:c,error:l.message,patch:r,status:"error"});continue}n.set(c,m),i.push({absolutePath:c,patch:r,previewAfter:p,previewBefore:S,status:"applied"})}return i};export{ut as a,dt as b,tt as c,ht as r};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{createRequire as a}from"node:module";import{l as c}from"./target-options-ChWcK60i.js";import{m as d}from"./index-OQZQyN5R.js";const p=a(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,i=r=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[e,t]=o.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return o.getBuiltinModule(r)}return p(r)},{createRequire:u}=i("node:module"),{pathToFileURL:m}=i("node:url"),s=["temporal","urlpattern"],f=r=>{const e=r.trim().toLowerCase();return e===""||e==="all"||e==="1"||e==="true"?s:e.split(",").map(t=>t.trim()).filter(t=>s.includes(t))},l=async(r,e)=>{try{const t=u(d(e,"__vis_polyfill_resolver__.js")).resolve(r);return await import(m(t).href)}catch{return}},_=async r=>{if(globalThis.Temporal!==void 0)return;const e=await l("@js-temporal/polyfill",r);e?.Temporal===void 0?process.stderr.write(`vis: --polyfill temporal requested but @js-temporal/polyfill is not installed in this project.
|
|
2
|
+
`):globalThis.Temporal=e.Temporal},v=async r=>{if(globalThis.URLPattern!==void 0)return;const e=await l("urlpattern-polyfill",r);e?.URLPattern===void 0?process.stderr.write(`vis: --polyfill urlpattern requested but urlpattern-polyfill is not installed in this project.
|
|
3
|
+
`):globalThis.URLPattern=e.URLPattern},y=async(r,e=process.cwd())=>{const t=f(r);await Promise.all(t.map(async n=>{await(n==="temporal"?_(e):v(e))}))},b=async r=>{for(const[e,t]of Object.entries(c(r,!0)))process.env[e]===void 0&&(process.env[e]=t);process.env.VIS_POLYFILL!==void 0&&await y(process.env.VIS_POLYFILL,r)};export{b as p};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRequire as M}from"node:module";import{c as j}from"./compile-cache-B_Vf_WxT.js";import{i as Z,h as G,t as U,p as y,c as k}from"./runtime-process-Dmz0vCJy-DUwTvH1J.js";import"./index.server-J83sowC4.js";import"./index-OQZQyN5R.js";import{a as F}from"./readJsonSync-CvkZyKmL-CY7PZob_.js";const B=M(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,X=e=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[t,r]=a.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return a.getBuiltinModule(e)}return B(e)},{createRequire:g}=X("node:module"),{env:T}=a,H=g(import.meta.url),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=e=>{if(typeof _<"u"&&_.versions&&_.versions.node){const[t,r]=_.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return _.getBuiltinModule(e)}return H(e)},{execFileSync:V}=A("node:child_process"),{totalmem:Y}=A("node:os"),z=/--max-old-space-size=(\d+)/,q=/--max-semi-space-size=(\d+)/,Q=e=>Math.floor(Y()/1024/1024*e),K=e=>e<=512?4:e<=1024?8:e<=2048?16:e<=4096?32:e<=8192?64:Math.floor(Math.log2(e))*8,$=(e,t)=>{for(const r of t){const o=e.exec(r);if(o)return Number.parseInt(o[1],10)}},J=e=>{const r=[...k()],o=[...Z()],n=$(z,r),i=$(q,r);if(n!==void 0&&i!==void 0)return;const s=n??Q(.75),l=i??K(s),I=[];if(n===void 0&&I.push(`--max-old-space-size=${String(s)}`),i===void 0&&I.push(`--max-semi-space-size=${String(l)}`),I.length!==0)try{V(G(),[...I,...r,...o.slice(1)],{env:U(),stdio:"inherit"}),y(0)}catch(C){const W=C.status;y(typeof W=="number"?W:1)}},c="\x1B[",x=";";g(import.meta.url);const ee=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=ee,te=(e,t,r,o)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;const n=Object.getOwnPropertyDescriptor(e,r),i=Object.getOwnPropertyDescriptor(t,r);!re(n,i)&&o||Object.defineProperty(e,r,i)},re=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},oe=(e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},ne=(e,t)=>`/* Wrapped ${e}*/
|
|
2
|
+
${t}`,ie=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),se=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),ce=(e,t,r)=>{const o=r===""?"":`with ${r.trim()}() `,n=ne.bind(null,o,t.toString());Object.defineProperty(n,"name",se);const{writable:i,enumerable:s,configurable:l}=ie;Object.defineProperty(e,"toString",{value:n,writable:i,enumerable:s,configurable:l})};function le(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:o}=e;for(const n of Reflect.ownKeys(t))te(e,t,n,r);return oe(e,t),ce(e,t,o),e}const S=new WeakMap,D=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,o=0;const n=e.displayName||e.name||"<anonymous>",i=function(...s){if(S.set(i,++o),o===1)r=e.apply(this,s),e=void 0;else if(t.throw===!0)throw new Error(`Function \`${n}\` can only be called once`);return r};return le(i,e),S.set(i,o),i};D.callCount=e=>{if(!S.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return S.get(e)};const u=[];u.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&u.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&u.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const d=e=>!!e&&!0&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",E=Symbol.for("signal-exit emitter"),R=globalThis,ae=Object.defineProperty.bind(Object);let ue=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(R[E])return R[E];ae(R,E,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,r){this.listeners[t].push(r)}removeListener(t,r){const o=this.listeners[t],n=o.indexOf(r);n!==-1&&(n===0&&o.length===1?o.length=0:o.splice(n,1))}emit(t,r,o){if(this.emitted[t])return!1;this.emitted[t]=!0;let n=!1;for(const i of this.listeners[t])n=i(r,o)===!0||n;return t==="exit"&&(n=this.emit("afterExit",r,o)||n),n}};class L{}const _e=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}});let pe=class extends L{onExit(){return()=>{}}load(){}unload(){}},fe=class extends L{#s=m.platform==="win32"?"SIGINT":"SIGHUP";#t=new ue;#e;#n;#i;#o={};#r=!1;constructor(t){super(),this.#e=t,this.#o={};for(const r of u)this.#o[r]=()=>{const o=this.#e.listeners(r);let{count:n}=this.#t;const i=t;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(n+=i.__signal_exit_emitter__.count),o.length===n){this.unload();const s=this.#t.emit("exit",null,r),l=r==="SIGHUP"?this.#s:r;s||t.kill(t.pid,l)}};this.#i=t.reallyExit,this.#n=t.emit}onExit(t,r){if(!d(this.#e))return()=>{};this.#r===!1&&this.load();const o=r?.alwaysLast?"afterExit":"exit";return this.#t.on(o,t),()=>{this.#t.removeListener(o,t),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#r){this.#r=!0,this.#t.count+=1;for(const t of u)try{const r=this.#o[t];r&&this.#e.on(t,r)}catch{}this.#e.emit=(t,...r)=>this.#l(t,...r),this.#e.reallyExit=t=>this.#c(t)}}unload(){this.#r&&(this.#r=!1,u.forEach(t=>{const r=this.#o[t];if(!r)throw new Error("Listener not defined for signal: "+t);try{this.#e.removeListener(t,r)}catch{}}),this.#e.emit=this.#n,this.#e.reallyExit=this.#i,this.#t.count-=1)}#c(t){return d(this.#e)?(this.#e.exitCode=t||0,this.#t.emit("exit",this.#e.exitCode,null),this.#i.call(this.#e,this.#e.exitCode)):0}#l(t,...r){const o=this.#n;if(t==="exit"&&d(this.#e)){typeof r[0]=="number"&&(this.#e.exitCode=r[0]);const n=o.call(this.#e,t,...r);return this.#t.emit("exit",this.#e.exitCode,null),n}else return o.call(this.#e,t,...r)}};const m=globalThis.process,{onExit:Ie}=_e(d(m)?new fe(m):new pe),b=h.stderr.isTTY?h.stderr:h.stdout.isTTY?h.stdout:void 0;b&&D(()=>{Ie(()=>{b.write("\x1B[?25h")},{alwaysLast:!0})});const Ye=(e=1)=>`${c}${String(e)}B`,ze=`${c}?25l`,he=`${c}G`,de=(e=1)=>`${c}${String(e)}G`,qe=(e=1)=>`${c}${String(e)}E`,Qe=`${c}?25h`,Ke=(e,t)=>t===void 0?de(e+1):`${c}${String(t+1)}${x}${String(e+1)}H`,Se=(e=1)=>`${c}${String(e)}A`;var Oe=(e=>(e[e.Default=0]="Default",e[e.BlinkingBlock=1]="BlinkingBlock",e[e.SteadyBlock=2]="SteadyBlock",e[e.BlinkingUnderline=3]="BlinkingUnderline",e[e.SteadyUnderline=4]="SteadyUnderline",e[e.BlinkingBar=5]="BlinkingBar",e[e.SteadyBar=6]="SteadyBar",e))(Oe||{});const Je=e=>`${c}${String(e)} q`;var Te=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(Te||{});const et=e=>{const t=e>=0&&e<=3?e:0;return`${c}${t===0?"":String(t)}J`};var Ee=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(Ee||{});const v=e=>{const t=e>=0&&e<=2?e:0;return`${c}${t===0?"":String(t)}K`},Re=v(2),tt=v(0),rt=e=>{if(e<=0)return"";let t="";for(let r=0;r<e;r+=1)t+=Re,r<e-1&&(t+=Se());return t+=he,t},me=g(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ge=e=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[t,r]=p.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return p.getBuiltinModule(e)}return me(e)};ge("node:buffer");class Ne{code;isDecMode=!0;constructor(t){this.code=t}}const w=(e,...t)=>{if(t.length===0)return"";const r=e?"l":"h";if(t.length===1){const s=t[0];let l=c;return s.isDecMode&&(l+="?"),l+String(s.code)+r}const o=t.filter(s=>!s.isDecMode).map(s=>s.code),n=t.filter(s=>s.isDecMode).map(s=>s.code);let i="";return o.length>0&&(i+=`${c}${o.join(";")}${r}`),n.length>0&&(i+=`${c}?${n.join(";")}${r}`),i};var We=(e=>(e[e.NotRecognized=0]="NotRecognized",e[e.Set=1]="Set",e[e.Reset=2]="Reset",e[e.PermanentlySet=3]="PermanentlySet",e[e.PermanentlyReset=4]="PermanentlyReset",e))(We||{});const ye=e=>new Ne(e),ot=(...e)=>w(!1,...e),nt=(...e)=>w(!0,...e),it=ye(2004);class $e{constructor(t){this.reportCode=t}reportCode;isDecReport=!1}class be{constructor(t){this.reportCode=t}reportCode;isDecReport=!0}const Pe=e=>new $e(e),N=e=>new be(e),O=(...e)=>{if(e.length===0)return"";const t=e.some(n=>n.isDecReport),r=e.map(n=>n.reportCode.toString());let o=c;return t&&(o+="?"),`${o}${r.join(x)}n`},Ae=Pe(5);O(Ae);const xe=N(15);O(xe);const De=N(25);O(De);const Le=N(26);O(Le);var ve=(e=>(e[e.DEICONIFY_WINDOW=1]="DEICONIFY_WINDOW",e[e.ICONIFY_WINDOW=2]="ICONIFY_WINDOW",e[e.MOVE_WINDOW=3]="MOVE_WINDOW",e[e.RESIZE_TEXT_AREA_CHARS=4]="RESIZE_TEXT_AREA_CHARS",e[e.RAISE_WINDOW=5]="RAISE_WINDOW",e[e.LOWER_WINDOW=6]="LOWER_WINDOW",e[e.REFRESH_WINDOW=7]="REFRESH_WINDOW",e[e.RESIZE_TEXT_AREA_PIXELS=8]="RESIZE_TEXT_AREA_PIXELS",e[e.RESTORE_MAXIMIZED_WINDOW=9]="RESTORE_MAXIMIZED_WINDOW",e[e.MAXIMIZE_WINDOW=10]="MAXIMIZE_WINDOW",e[e.MAXIMIZE_WINDOW_VERTICALLY=10.1]="MAXIMIZE_WINDOW_VERTICALLY",e[e.MAXIMIZE_WINDOW_HORIZONTALLY=10.2]="MAXIMIZE_WINDOW_HORIZONTALLY",e[e.UNDO_FULL_SCREEN_MODE=10.3]="UNDO_FULL_SCREEN_MODE",e[e.REPORT_WINDOW_STATE=11]="REPORT_WINDOW_STATE",e[e.REPORT_WINDOW_POSITION=13]="REPORT_WINDOW_POSITION",e[e.REPORT_TEXT_AREA_SIZE_CHARS=14]="REPORT_TEXT_AREA_SIZE_CHARS",e[e.REQUEST_WINDOW_SIZE_WIN_OP_COMPAT=14]="REQUEST_WINDOW_SIZE_WIN_OP_COMPAT",e[e.REPORT_CELL_SIZE_PIXELS=16]="REPORT_CELL_SIZE_PIXELS",e[e.REPORT_TEXT_AREA_SIZE_PIXELS=18]="REPORT_TEXT_AREA_SIZE_PIXELS",e[e.REPORT_ICON_LABEL=19]="REPORT_ICON_LABEL",e[e.REPORT_WINDOW_TITLE=21]="REPORT_WINDOW_TITLE",e[e.PUSH_WINDOW_TITLE=22]="PUSH_WINDOW_TITLE",e[e.POP_WINDOW_TITLE=23]="POP_WINDOW_TITLE",e[e.RESIZE_SCREEN_AND_TEXT_AREA=24]="RESIZE_SCREEN_AND_TEXT_AREA",e))(ve||{});const P=e=>e in T&&T[e]!=="0"&&T[e]!=="false",we=P("CI")||P("CONTINUOUS_INTEGRATION"),Ce=()=>{if(process.env.VIS_VERSION)return process.env.VIS_VERSION;try{const e=new URL("../../package.json",import.meta.url);return F(e).version}catch{return"0.0.0"}},Me=()=>{process.env.VIS_VERSION=Ce()},st=e=>{!process.stdout.isTTY||we||process.env.TERM==="dumb"||process.stdout.write(`\x1B]0;${e}\x07`)},Be=new Set(["","--help","--version","-h","-v","completion","dlx","exec","x"]),f=process.argv[2]??"";!Be.has(f)&&!process.argv.includes("--help")&&!process.argv.includes("-h")&&J();process.argv.includes("--no-color")&&(process.env.NO_COLOR="1",process.env.FORCE_COLOR="0");Me();j();(async()=>{if(f==="__pm-shim"){const{dispatchShim:t}=await import("../packem_chunks/dispatch.js");t(process.argv[3]??"",process.argv.slice(4));return}if(f==="x"){const{runLeanX:t}=await import("../packem_chunks/lean.js");await t(process.argv.slice(3));return}if(f==="exec"||f==="dlx"){const{runExecCli:t}=await import("../packem_chunks/cli-exec.js");await t();return}const{runCli:e}=await import("../packem_chunks/cli-main.js").then(t=>t.br);await e()})();export{ze as A,Qe as H,we as I,rt as L,Ke as P,it as Q,nt as S,Se as _,ye as a,ot as c,tt as d,et as e,qe as h,Je as j,Te as o,st as s,Ye as v,c as x};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as j}from"node:module";import{m as h,f as y}from"./index-OQZQyN5R.js";import{a as q}from"./readJsonSync-CvkZyKmL-CY7PZob_.js";const $=j(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,n]=g.versions.node.split(".").map(Number);if(s>22||s===22&&n>=3||s===20&&n>=16)return g.getBuiltinModule(e)}return $(e)},{readdirSync:_,statSync:M}=k("node:fs"),w=["preinstall","install","postinstall","prepare"],x=e=>{const s=h(e,"node_modules");if(!y(s))return[];const n=new Map,o=(l,p="")=>{let u;try{u=_(l)}catch{return}for(const r of u){const i=h(l,r);if(r.startsWith("@")){o(i,`${r}/`);continue}if(r===".pnpm"&&p===""){let f;try{f=_(i)}catch{continue}for(const a of f){const c=h(i,a,"node_modules");y(c)&&o(c)}continue}if(r.startsWith("."))continue;const m=p+r,t=h(i,"package.json");try{if(!M(i).isDirectory()||!y(t))continue;const f=q(t),a=f.scripts??{},c=w.filter(v=>a[v]);!a.preinstall&&!a.install&&!a.postinstall&&y(h(i,"binding.gyp"))&&c.push("install (binding.gyp)"),c.length>0&&!n.has(m)&&n.set(m,{directory:i,hooks:c,name:m,version:typeof f.version=="string"?f.version:void 0});const d=h(i,"node_modules");y(d)&&o(d)}catch{}}};return o(s),[...n.values()]},W=e=>{const s=e.startsWith("@"),n=e.indexOf("@",s?1:0);return n===-1?{name:e}:{name:e.slice(0,n),version:e.slice(n+1)}},B=(e,s,n)=>{for(const[o,l]of Object.entries(s)){if(!l)continue;if(o.endsWith("@*")){if(o.slice(0,-2)===e.name)return!0;continue}if(o.endsWith("*")){if(e.name.startsWith(o.slice(0,-1)))return!0;continue}const{name:p,version:u}=W(o);if(p===e.name&&(!n||u===void 0||e.version===u))return!0}return!1},O=(e,s,n={})=>{const o=n.pinVersions===!0,l=x(e),p=[],u=[],r=new Map(l.map(t=>[t.name,t]));for(const t of l)B(t,s,o)?u.push(t):p.push(t);const i=[],m=[];for(const[t,f]of Object.entries(s)){if(!f)continue;if(t.endsWith("@*")){const v=t.slice(0,-2);r.has(v)||i.push(t);continue}if(t.endsWith("*")){const v=t.slice(0,-1);[...r.keys()].some(b=>b.startsWith(v))||i.push(t);continue}const{name:a,version:c}=W(t),d=r.get(a);if(!d){i.push(t);continue}o&&c!==void 0&&c!=="*"&&d.version&&d.version!==c&&m.push({from:t,to:`${a}@${d.version}`})}return{excess:i,installed:u,unapproved:p,versionDrift:m}},S=(e,s)=>O(e,s).unapproved.map(n=>`${n.name} (${n.hooks.join(", ")})`);export{O as W,S as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as o}from"./resolve-runtime-CJSWV-K8.js";const i=e=>{if(e!==null&&typeof e=="object"&&"runtime"in e){const r=e.runtime;if(typeof r=="string")return r}},s=(e,r)=>{const t=o(r,{config:e.visConfig?.runtime,flag:i(e.options)});return t.deferredNotice!==void 0&&e.logger?.warn?.(t.deferredNotice),t},u=e=>e.runtime==="bun"?"bun":void 0;export{u as a,s as r};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
3
|
+
const c=()=>{try{const e=require("node:module");if(typeof e.enableCompileCache=="function"){e.enableCompileCache();return}}catch{}try{require("v8-compile-cache")}catch{}};export{c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as ie}from"node:module";import{m as E,v as ue}from"./index-
|
|
1
|
+
import{createRequire as ie}from"node:module";import{m as E,v as ue}from"./index-OQZQyN5R.js";import{r as le}from"./docker-DKlF-gk3.js";import{a as oe}from"./readJsonSync-CvkZyKmL-CY7PZob_.js";import{e as fe}from"./license-t5KnNX6v.js";import{D as de}from"../packem_chunks/cli-main.js";import"./public-api-WqUCiyIe.js";import{u as he}from"./index-Cb4x6lWY.js";const ae=ie(import.meta.url),P=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=e=>{if(typeof P<"u"&&P.versions&&P.versions.node){const[n,t]=P.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return P.getBuiltinModule(e)}return ae(e)},{randomUUID:pe}=se("node:crypto"),{readdirSync:me}=se("node:fs"),X=e=>e.replaceAll(/[^\w.~-]/g,n=>`%${(n.codePointAt(0)??0).toString(16).toUpperCase().padStart(2,"0")}`),C=(e,n)=>{const t=e.toLowerCase();if(t.startsWith("@")){const s=t.indexOf("/");if(s>0){const r=t.slice(0,s),p=t.slice(s+1);return`pkg:npm/${X(r)}/${X(p)}@${X(n)}`}}return`pkg:npm/${X(t)}@${X(n)}`},m={ARRAY:"array",BOOLEAN:"boolean",DATE:"date",FUNCTION:"function",JSTOXML_OBJECT:"jstoxml-object",NULL:"null",NUMBER:"number",OBJECT:"object",STRING:"string"},_e=[m.STRING,m.NUMBER,m.BOOLEAN],ge='<?xml version="1.0" encoding="UTF-8"?>',ee=["_selfCloseTag","_attrs"],ye=(e="",n=0)=>e.repeat(n),Y=e=>Array.isArray(e)&&m.ARRAY||typeof e===m.OBJECT&&e!==null&&e._name&&m.JSTOXML_OBJECT||e instanceof Date&&m.DATE||e===null&&m.NULL||typeof e,re=e=>e.startsWith("<![CDATA["),ce=(e="",n={},t)=>{let s=e;if(typeof e===m.STRING){if(re(e))return e;const r=new RegExp(`(${Object.keys(n).join("|")})(?!(\\w|#)*;)`,"g");s=String(e).replace(r,(p,h)=>n[h]||"")}return typeof t=="function"?t(s):s},be=(e={},n,t,s)=>(Array.isArray(e)?e:Object.entries(e).map(([r,p])=>({[r]:p}))).reduce((r,p)=>{const h=Object.keys(p)[0],_=p[h];if(typeof t===m.FUNCTION&&t(h,_))return r;const y=n?ce(_,n):_,$=!s&&y===!0?"":`="${y}"`;return r.push(`${h}${$}`),r},[]),$e=(e={},n,t,s)=>{const r=be(e,n,t,s);return r.length===0?"":` ${r.join(" ")}`},Oe=(e={})=>Object.keys(e).map(n=>({_name:n,_content:e[n]})),ve=e=>_e.includes(Y(e)),je=e=>!e.match("<"),ke=({header:e,isOutputStart:n})=>e&&n?typeof e===m.BOOLEAN?ge:e:"",ne={"<":"<",">":">","&":"&",'"':"""},U=(e={},n={})=>{const{depth:t=0,indent:s,_isFirstItem:r,_isOutputStart:p=!0,header:h,attributeReplacements:_={},attributeFilter:y,attributeExplicitTrue:$=!1,contentReplacements:F={},contentMap:M,selfCloseTags:B=!0}=n,J=typeof _=="boolean"&&!_?{}:{...ne,..._},G=typeof F=="boolean"&&!F?{}:{...ne,...F},D=typeof s=="string",k=ye(s,t),W=Y(e),L=ke({header:h,isOutputStart:p}),N=p&&!L&&r&&t===0,R=D&&!N?`
|
|
2
2
|
`:"";let b="";switch(W){case m.JSTOXML_OBJECT:{const{_name:f,_content:u}=e;if(u===null&&typeof M!="function"){b=`${R}${k}${f}`;break}if(Array.isArray(u)&&u.every(ve))return u.map(j=>U({_name:f,_content:j},{...n,depth:t,_isOutputStart:!1})).join("");if(ee.includes(f))break;const g=U(u,{...n,depth:t+1,_isOutputStart:N}),w=Y(g),O=je(g),v=re(g),x=`${R}${k}`;if(f==="_comment"){b+=`${x}<!-- ${u} -->`;break}const H=w==="undefined"||g==="",c=B,o=e._selfCloseTag,a=typeof o===m.BOOLEAN?H&&o:H&&c,i=a?"/":"",l=$e(e._attrs,J,y,$),d=`<${f}${l}${i}>`,T=D&&!O&&!v?`
|
|
3
3
|
${k}`:"",S=a?"":`${g}${T}</${f}>`;b+=`${x}${d}${S}`;break}case m.OBJECT:{const f=Object.keys(e);b=f.map((u,g)=>{const w={...n,_isFirstItem:g===0,_isLastItem:g+1===f.length,_isOutputStart:N},O={_name:u};if(Y(e[u])===m.OBJECT&&(ee.forEach(v=>{const x=e[u][v];typeof x<"u"&&(O[v]=x,delete e[u][v])}),typeof e[u]._content<"u"&&Object.keys(e[u]).length>1)){const v=Object.assign({},e[u]);delete v._content,O._content=[...Oe(v),e[u]._content]}return typeof O._content>"u"&&(O._content=e[u]),U(O,w)},n).join("");break}case m.FUNCTION:{const f=e(n);b=U(f,n);break}case m.ARRAY:{b=e.map((f,u)=>{const g={...n,_isFirstItem:u===0,_isLastItem:u+1===e.length,_isOutputStart:N};return U(f,g)}).join("");break}default:{b=ce(e,G,M);break}}return`${L}${b}`},Q=e=>{try{return oe(e)}catch{return}},Te=e=>{if(e.length===0||e.includes("..")||e.startsWith(".")||e.includes("\0")||e.includes("\\"))return!1;if(e.startsWith("@")){const n=e.indexOf("/");return n>1&&!e.includes("/",n+1)}return!e.includes("/")},Se=e=>e.length>0&&!e.includes("/")&&!e.includes("\\")&&!e.includes("..")&&!e.includes("\0"),Ae=(e,n,t)=>{const s=`${n.replaceAll("/","+")}@${t}`,r=E(e,"node_modules",".pnpm"),p=Q(E(r,s,"node_modules",n,"package.json"));if(p)return p;let h;try{h=me(r)}catch{return}const _=`${s}_`;for(const y of h){if(!y.startsWith(_))continue;const $=Q(E(r,y,"node_modules",n,"package.json"));if($)return $}},we=(e,n,t)=>{const s=Q(E(e,"node_modules",n,"package.json"));return s?.version===t?s:void 0},xe=(e,n,t)=>{if(!(!Te(n)||!Se(t)))return Ae(e,n,t)??we(e,n,t)},De={sha256:"SHA-256",sha384:"SHA-384",sha512:"SHA-512"},Ne={sha256:64,sha384:96,sha512:128},Re=e=>{const n={name:e.name,version:e.version},{integrity:t}=e;return t&&t.hex.length===Ne[t.algorithm]&&(n.hash={alg:De[t.algorithm],content:t.hex}),e.dependencies&&(n.dependencies=e.dependencies),e.peerDependencies&&(n.peerDependencies=e.peerDependencies),e.optionalDependencies&&(n.optionalDependencies=e.optionalDependencies),n},Ce=[{file:"pnpm-lock.yaml",type:"pnpm"},{file:"npm-shrinkwrap.json",type:"npm"},{file:"package-lock.json",type:"npm"},{file:"yarn.lock",type:"yarn"},{file:"bun.lock",type:"bun"}],Ee=e=>{for(const{file:n,type:t}of Ce){let s;try{s=ue(E(e,n))}catch{continue}const r=new Map;for(const p of de(s,t))r.set(`${p.name}@${p.version}`,Re(p));return{packages:r,type:t}}},Me=e=>{const n=e.indexOf(":");return n<=0?e:e.slice(0,n)==="npm"?e.slice(n+1):e},V=(e,n,t)=>{const s=t.get(e);if(!s||s.size===0)return;if(s.has(n))return n;const r=Me(n);if(r!==n&&s.has(r))return r;const p=[...s];return he.maxSatisfying(p,r,{includePrerelease:!0})||p[0]},Be="1.7",Le="CycloneDX",Ie="http://cyclonedx.org/schema/bom-1.7.schema.json",Ue="@visulima/vis",te=e=>{try{return oe(e)}catch{return}},Fe=e=>{if(e){if(typeof e=="string")return e;if(typeof e=="object"&&e.name)return e.email?`${e.name} <${e.email}>`:e.name}},Je=e=>{if(e)return typeof e=="string"?e:e.url},qe=e=>{if(e)return typeof e=="string"?e:e.url},Pe=e=>{const n=[];e.homepage&&n.push({type:"website",url:e.homepage});const t=Je(e.repository);t&&n.push({type:"vcs",url:t});const s=qe(e.bugs);return s&&n.push({type:"issue-tracker",url:s}),n.length>0?n:void 0},Xe=e=>e==="application"||e==="service"||e==="tool"?"application":"library",K=(e,n)=>{if(!n)return;n.description&&(e.description=n.description);const t=Fe(n.author);t&&(e.author=t);const s=fe(n);s&&(e.licenses=s);const r=Pe(n);r&&(e.externalReferences=r)},tn=e=>{const{focus:n,generatorVersion:t,includeDev:s=!1,now:r=new Date,projectGraph:p,serialNumber:h,workspace:_,workspaceRoot:y}=e,$=n&&n.length>0?[...le(n,p)].sort():Object.keys(_.projects).sort(),F=new Set($),M=new Map;for(const c of $){const o=_.projects[c];o&&M.set(c,te(E(y,o.root,"package.json")))}const B=[],J=new Map;for(const c of $){const o=_.projects[c];if(!o)continue;const a=M.get(c),i=a?.version??"0.0.0",l=C(c,i);J.set(c,l);const d={"bom-ref":l,name:c,purl:l,type:Xe(o.projectType),version:i};K(d,a),B.push(d)}const G=Ee(y),D=new Map,k=new Map;if(G)for(const c of G.packages.values()){D.set(`${c.name}@${c.version}`,c);let o=k.get(c.name);o||(o=new Set,k.set(c.name,o)),o.add(c.version)}const W=[],L=[],N=new Map;for(const c of $){const o=M.get(c);if(!o)continue;const a=[o.dependencies,o.peerDependencies];s&&a.push(o.devDependencies);const i=new Set,l=(d,T)=>{if(T)for(const[S,j]of Object.entries(T)){if(F.has(S)){const I=J.get(S);I&&i.add(I);continue}const A=V(S,j,k);A&&(i.add(C(S,A)),d.push(`${S}@${A}`))}};for(const d of a)l(W,d);l(L,o.optionalDependencies),N.set(c,i)}const R=new Map,b=new Map,f=(c,o)=>{const a=[...c];for(;a.length>0;){const i=a.pop(),l=R.get(i);if(l==="required"||l==="optional"&&o==="optional")continue;R.set(i,o);const d=D.get(i);if(!d)continue;const T=b.get(i)??new Set,S=[d.dependencies,d.peerDependencies];for(const j of S)if(j)for(const[A,I]of Object.entries(j))for(const q of I){const z=V(A,q,k);z&&(T.add(C(A,z)),a.push(`${A}@${z}`))}if(d.optionalDependencies)for(const[j,A]of Object.entries(d.optionalDependencies))for(const I of A){const q=V(j,I,k);q&&(T.add(C(j,q)),L.push(`${j}@${q}`))}T.size>0&&b.set(i,T)}};f(W,"required"),f(L,"optional");const u=[],g=[...R.keys()].sort();for(const c of g){const o=D.get(c);if(!o)continue;const a=C(o.name,o.version),i={"bom-ref":a,name:o.name,purl:a,scope:R.get(c)??"required",type:"library",version:o.version};o.hash&&(i.hashes=[o.hash]),K(i,xe(y,o.name,o.version)),u.push(i)}const w=[];for(const[c,o]of N){const a=J.get(c);if(!a)continue;const i=[...o].sort();w.push(i.length>0?{dependsOn:i,ref:a}:{ref:a})}for(const c of g){const o=D.get(c);if(!o)continue;const a=C(o.name,o.version),i=b.get(c),l=i?[...i].sort():[];w.push(l.length>0?{dependsOn:l,ref:a}:{ref:a})}w.sort((c,o)=>c.ref.localeCompare(o.ref));const O=te(E(y,"package.json")),v=(()=>{if(n?.length===1){const l=B.find(d=>d.name===n[0]);if(l)return{"bom-ref":l["bom-ref"],name:l.name,purl:l.purl,type:l.type,version:l.version}}const c=O?.name??"workspace",o=O?.version??"0.0.0",a=C(c,o),i={"bom-ref":a,name:c,purl:a,type:"application",version:o};return K(i,O),i})(),x=v["bom-ref"],H=x?B.filter(c=>c["bom-ref"]!==x):B;return{$schema:Ie,bomFormat:Le,components:[...H,...u],dependencies:w,metadata:{component:v,lifecycles:[{phase:"build"}],timestamp:r.toISOString(),tools:{components:[{name:Ue,type:"application",...t?{version:t}:{}}]}},serialNumber:h??`urn:uuid:${pe()}`,specVersion:Be,version:1}},sn=e=>{const n={version:e.version??1,xmlns:"http://cyclonedx.org/schema/bom/1.7"};e.serialNumber&&(n.serialNumber=e.serialNumber);const t=[];return e.metadata&&t.push(Ge(e.metadata)),e.components&&e.components.length>0&&t.push({_content:e.components.map(s=>Z(s)),_name:"components"}),e.dependencies&&e.dependencies.length>0&&t.push({_content:e.dependencies.map(s=>He(s)),_name:"dependencies"}),`${U({_attrs:n,_content:t,_name:"bom"},{header:!0,indent:" ",selfCloseTags:!0})}
|
|
4
4
|
`},Ge=e=>{const n=[];return e.timestamp&&n.push({timestamp:e.timestamp}),e.lifecycles&&e.lifecycles.length>0&&n.push({_content:e.lifecycles.map(t=>{const s=[];return t.phase&&s.push({phase:t.phase}),t.name&&s.push({name:t.name}),t.description&&s.push({description:t.description}),{_content:s,_name:"lifecycle"}}),_name:"lifecycles"}),e.tools?.components&&n.push({_content:[{_content:e.tools.components.map(t=>Z(t)),_name:"components"}],_name:"tools"}),e.component&&n.push(Z(e.component)),{_content:n,_name:"metadata"}},Z=e=>{const n={type:e.type};e["bom-ref"]&&(n["bom-ref"]=e["bom-ref"]);const t=[];e.group&&t.push({group:e.group}),t.push({name:e.name}),e.version&&t.push({version:e.version}),e.description&&t.push({description:e.description}),e.author&&t.push({author:e.author}),e.hashes&&e.hashes.length>0&&t.push({_content:e.hashes.map(r=>({_attrs:{alg:r.alg},_content:r.content,_name:"hash"})),_name:"hashes"});const s=We(e.licenses);return s&&t.push(s),e.purl&&t.push({purl:e.purl}),e.scope&&t.push({scope:e.scope}),e.externalReferences&&e.externalReferences.length>0&&t.push({_content:e.externalReferences.map(r=>({_attrs:{type:r.type},_content:[{url:r.url}],_name:"reference"})),_name:"externalReferences"}),{_attrs:n,_content:t,_name:"component"}},We=e=>{if(!e||e.length===0)return;const n=[];for(const t of e){if("expression"in t){n.push({expression:t.expression});continue}const s=[];"id"in t.license&&t.license.id?s.push({id:t.license.id}):"name"in t.license&&t.license.name&&s.push({name:t.license.name}),n.push({_content:s,_name:"license"})}return{_content:n,_name:"licenses"}},He=e=>e.dependsOn&&e.dependsOn.length>0?{_attrs:{ref:e.ref},_content:e.dependsOn.map(n=>({_attrs:{ref:n},_name:"dependency"})),_name:"dependency"}:{_attrs:{ref:e.ref},_name:"dependency"};export{tn as b,sn as s,C as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{v as u,m as l,f as g}from"./index-OQZQyN5R.js";import{D as d,i as D,W as v}from"../packem_chunks/cli-main.js";import"./public-api-WqUCiyIe.js";const w={bun:{file:"bun.lock",type:"bun"},npm:{aliases:["npm-shrinkwrap.json"],file:"package-lock.json",type:"npm"},pnpm:{file:"pnpm-lock.yaml",type:"pnpm"},yarn:{file:"yarn.lock",type:"yarn"}},j=o=>{const t=w[o];return t?[...t.aliases??[],t.file].map(e=>({file:e,type:t.type})):[]},m=(o,t)=>{const e=j(t);if(e.length!==0)return e.find(r=>g(l(o,r.file)))??e[e.length-1]},k=o=>{try{return JSON.parse(u(o))}catch{return}},y=o=>{const t=[],e=k(l(o,"package.json"));e&&t.push(e);const r=D(o);let c;if(r?c=r:e?.workspaces&&(Array.isArray(e.workspaces)?c=e.workspaces:e.workspaces.packages&&(c=e.workspaces.packages)),!c)return t;const a=v(o,c);for(const s of a){const n=k(l(o,s,"package.json"));n&&t.push(n)}return t},b=(o,t)=>{const e=new Set,r=[],c=new Map;for(const s of t){const n=c.get(s.name);n?n.push(s):c.set(s.name,[s])}const a=s=>{if(s)for(const n of Object.keys(s))e.has(n)||(e.add(n),r.push(n))};for(const s of y(o))a(s.dependencies),a(s.peerDependencies),a(s.optionalDependencies);for(;r.length>0;){const s=r.shift(),n=c.get(s);if(n){for(const i of n)for(const p of[i.dependencies,i.peerDependencies,i.optionalDependencies])if(p)for(const f of Object.keys(p))e.has(f)||(e.add(f),r.push(f))}}return e},$=(o,t,e={})=>{const r=m(o,t);if(!r)return[];let c;try{c=u(l(o,r.file))}catch{return[]}const a=d(c,r.type);if(a.length===0)return[];const s=e.includeDev??!0?void 0:b(o,a),n=new Set,i=[];for(const p of a){if(s&&!s.has(p.name))continue;const f=`${p.name}@${p.version}`;n.has(f)||(n.add(f),i.push({isDev:!1,name:p.name,version:p.version}))}return i},A=(o,t)=>{const e=m(o,t);if(!e)return[];let r;try{r=u(l(o,e.file))}catch{return[]}const c=d(r,e.type);if(c.length===0)return[];const a=new Map;for(const n of c)a.has(n.name)||a.set(n.name,new Set),a.get(n.name).add(n.version);const s=[];for(const[n,i]of a)i.size<=1||s.push({name:n,versions:[...i]});return s.sort((n,i)=>n.name.localeCompare(i.name))},E=(o,t)=>{const e=m(o,t);if(!e)return;let r;try{r=u(l(o,e.file))}catch{return}const c=d(r,e.type);if(c.length===0)return;const a=[],s=new Set;for(const n of y(o))for(const i of[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies])if(i)for(const[p,f]of Object.entries(i)){const h=`${p}@${f}`;s.has(h)||(s.add(h),a.push({name:p,version:f}))}return{entries:c,roots:a}};export{w as L,E as a,A as f,$ as l,m as r};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as Qo}from"node:module";import{m as Ie,f as ia,y as oa,H as jn,T as fi,a as aa}from"./index-
|
|
1
|
+
import{createRequire as Qo}from"node:module";import{m as Ie,f as ia,y as oa,H as jn,T as fi,a as aa}from"./index-OQZQyN5R.js";import{h as sa,L as ua}from"./public-api-WqUCiyIe.js";import{a as ro}from"./readJsonSync-CvkZyKmL-CY7PZob_.js";const ea=Qo(import.meta.url),zt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ta=l=>{if(typeof zt<"u"&&zt.versions&&zt.versions.node){const[d,A]=zt.versions.node.split(".").map(Number);if(d>22||d===22&&A>=3||d===20&&A>=16)return zt.getBuiltinModule(l)}return ea(l)},{rmSync:_n,existsSync:eo,readFileSync:li,cpSync:to,lstatSync:ra,readdirSync:na}=ta("node:fs");class et extends Error{constructor(d){super(d),this.name="LockfilePruneError"}}const no=l=>{let d=l.startsWith("/")?l.slice(1):l;const A=d.indexOf("(");return A!==-1&&(d=d.slice(0,A)),d},ca=(l,d)=>{if(!(d.startsWith("link:")||d.startsWith("file:")||d.startsWith("workspace:")))return`${l}@${d}`},la=l=>{const d=[];for(const A of[l.dependencies,l.devDependencies,l.optionalDependencies])if(A)for(const[o,h]of Object.entries(A))h?.version&&d.push({name:o,version:h.version});return d},pi=l=>{const d=[];for(const A of[l.dependencies,l.optionalDependencies])if(A)for(const[o,h]of Object.entries(A))typeof h=="string"&&d.push({name:o,version:h});return d},hi=l=>{const d=new Map;if(!l)return d;for(const A of Object.keys(l)){const o=no(A),h=d.get(o);h?h.push(A):d.set(o,[A])}return d},io=l=>{const d=l.displayName??"pnpm-lock.yaml",A=typeof l.lockfileContent=="string"?l.lockfileContent:l.lockfileContent.toString("utf8");let o;try{o=sa(A)}catch(Z){throw new et(`${d}: parse failed — ${Z.message}`)}const h=Z=>Z.packages?Object.keys(Z.packages).length:0;let e;for(const Z of o){const[te]=Z.errors;if(te)throw new et(`${d}: parse failed — ${te.message}`);const q=Z.toJS();if(!q||typeof q!="object")continue;const ue=q;(e===void 0||h(ue)>h(e))&&(e=ue)}if(e===void 0)throw new et(`${d}: top-level value is not an object`);const g=e.importers??{},C=hi(e.packages),m=hi(e.snapshots),S=new Set(["."]);for(const Z of l.closure)S.add(Z.relativeRoot===""?".":Z.relativeRoot);const E={};for(const[Z,te]of Object.entries(g))S.has(Z)&&(E[Z]=te);const Y=new Set,y=new Set,b=[];for(const Z of Object.values(E))for(const te of la(Z))b.push(te);for(;b.length>0;){const{name:Z,version:te}=b.shift(),q=ca(Z,te);if(!q)continue;const ue=no(q),Ce=m.get(ue)??m.get(q)??[];for(const Ae of Ce){if(y.has(Ae))continue;y.add(Ae);const Ee=e.snapshots?.[Ae];if(Ee)for(const Oe of pi(Ee))b.push(Oe)}const ge=C.get(ue)??C.get(q)??[];for(const Ae of ge){if(Y.has(Ae))continue;Y.add(Ae);const Ee=e.packages?.[Ae];if(Ee&&!e.snapshots)for(const Oe of pi(Ee))b.push(Oe)}}const v={lockfileVersion:e.lockfileVersion};for(const Z of["settings","overrides","patchedDependencies","catalogs"])e[Z]!==void 0&&(v[Z]=e[Z]);if(v.importers=E,e.packages){const Z={};for(const te of Object.keys(e.packages))Y.has(te)&&(Z[te]=e.packages[te]);v.packages=Z}if(e.snapshots){const Z={};for(const te of Object.keys(e.snapshots))y.has(te)&&(Z[te]=e.snapshots[te]);v.snapshots=Z}const M=Object.keys(e.packages??{}).length,re=Object.keys(v.packages??{}).length,ae=M-re,x=Object.keys(g).length-Object.keys(E).length;return{content:ua(v,{lineWidth:0}),message:`${d}: kept ${re}/${M} packages and ${Object.keys(E).length} importers (dropped ${ae} packages, ${x} importers)`,status:"pruned"}},fa=l=>io({...l,displayName:l.displayName??"aube-lock.yaml"}),pa=l=>{let d="",A=!1,o=!1,h=!1;for(let e=0;e<l.length;e+=1){const g=l[e],C=l[e+1];if(o){g===`
|
|
2
2
|
`&&(o=!1,d+=g);continue}if(h){g==="*"&&C==="/"&&(h=!1,e+=1);continue}if(A){if(g==="\\"){d+=g,C!==void 0&&(d+=C,e+=1);continue}g==='"'&&(A=!1),d+=g;continue}if(g==='"'){A=!0,d+=g;continue}if(g==="/"&&C==="/"){o=!0,e+=1;continue}if(g==="/"&&C==="*"){h=!0,e+=1;continue}d+=g}return d},ha=l=>{const d=[];for(const A of[l.dependencies,l.devDependencies,l.optionalDependencies,l.peerDependencies])if(A)for(const[o,h]of Object.entries(A))typeof h=="string"&&d.push({name:o,spec:h});return d},da=l=>{for(const d of l)if(typeof d=="object"&&!Array.isArray(d))return d},ga=l=>{if(!l)return[];const d=[];for(const A of["dependencies","optionalDependencies","peerDependencies"]){const o=l[A];o!==null&&typeof o=="object"&&!Array.isArray(o)&&d.push(...Object.keys(o))}return d},ma=l=>{if(Buffer.isBuffer(l.lockfileContent))return{message:"bun.lockb is binary; run `bun install --save-text-lockfile` to regenerate as bun.lock, then rerun `vis docker scaffold`.",status:"skipped"};const d=pa(l.lockfileContent);let A;try{A=JSON.parse(d)}catch(M){throw new et(`bun.lock: parse failed — ${M.message}`)}if(!A||typeof A!="object")throw new et("bun.lock: top-level value is not an object");const o=A.workspaces??{},h=A.packages??{},e=new Set([""]);for(const M of l.closure)e.add(M.relativeRoot===""?"":M.relativeRoot);const g={},C=[];for(const[M,re]of Object.entries(o))e.has(M)&&(g[M]=re,C.push(...ha(re)));const m=new Set;for(const{name:M}of C)m.add(M);const S=[...m];for(;S.length>0;){const M=S.shift();for(const re of Object.keys(h)){if(re.split("/")[0]!==M&&re!==M)continue;const ae=da(h[re]);for(const x of ga(ae))m.has(x)||(m.add(x),S.push(x))}}const E={};for(const[M,re]of Object.entries(h)){const ae=M.split("/")[0];(m.has(ae)||m.has(M))&&(E[M]=re)}const Y={...A,packages:E,workspaces:g},y=Object.keys(h).length,b=Object.keys(E).length,v=y-b;return{content:`${JSON.stringify(Y,null,2)}
|
|
3
3
|
`,message:`bun.lock: kept ${b}/${y} packages (dropped ${v})`,status:"pruned"}},Vr="node_modules/",ya=(l,d,A)=>{let o=d;for(;;){const h=o===""?`${Vr}${A}`:`${o}/${Vr}${A}`;if(l[h]!==void 0)return h;if(o==="")return;const e=o.lastIndexOf(`/${Vr.slice(0,-1)}/`);o=e===-1?"":o.slice(0,e)}},va=l=>{const d=[];for(const A of[l.dependencies,l.devDependencies,l.optionalDependencies,l.peerDependencies])if(A)for(const o of Object.keys(A))d.push(o);return d},Aa=l=>{const d=l.displayName??"package-lock.json",A=typeof l.lockfileContent=="string"?l.lockfileContent:l.lockfileContent.toString("utf8");let o;try{o=JSON.parse(A)}catch(v){throw new et(`${d}: parse failed — ${v.message}`)}if(!o||typeof o!="object")throw new et(`${d}: top-level value is not an object`);const h=o.packages??{},e=new Set([""]);for(const v of l.closure)v.relativeRoot!==""&&e.add(v.relativeRoot);const g=new Set,C=[];for(const v of Object.keys(h))e.has(v)&&(g.add(v),C.push(v));for(const[v,M]of Object.entries(h))M.link===!0&&typeof M.resolved=="string"&&e.has(M.resolved)&&g.add(v);for(;C.length>0;){const v=C.shift(),M=h[v];if(M)for(const re of va(M)){const ae=ya(h,v,re);if(!ae||g.has(ae))continue;g.add(ae);const x=h[ae];x.link===!0&&typeof x.resolved=="string"&&h[x.resolved]!==void 0&&!g.has(x.resolved)?(g.add(x.resolved),C.push(x.resolved)):C.push(ae)}}const m={};for(const v of Object.keys(h))g.has(v)&&(m[v]=h[v]);const S=m[""];S&&Array.isArray(S.workspaces)&&(S.workspaces=S.workspaces.filter(v=>{if(typeof v!="string")return!1;const M=v.replace(/\/?\*+$/,"").replace(/\/$/,"");if(M===""||M==="*")return!0;for(const re of e)if(re===v||re===M||re.startsWith(`${M}/`))return!0;return!1}));const E={...o,packages:m};delete E.dependencies;const Y=Object.keys(h).length,y=Object.keys(m).length,b=Y-y;return{content:`${JSON.stringify(E,null,2)}
|
|
4
4
|
`,message:`${d}: kept ${y}/${Y} entries (dropped ${b})`,status:"pruned"}};var Kr={},xe={},Zr,di;function ba(){if(di)return Zr;di=1;function l(o,h){function e(){this.constructor=o}e.prototype=h.prototype,o.prototype=new e}function d(o,h,e,g){this.message=o,this.expected=h,this.found=e,this.location=g,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,d)}l(d,Error),d.buildMessage=function(o,h){var e={literal:function(y){return'"'+C(y.text)+'"'},class:function(y){var b="",v;for(v=0;v<y.parts.length;v++)b+=y.parts[v]instanceof Array?m(y.parts[v][0])+"-"+m(y.parts[v][1]):m(y.parts[v]);return"["+(y.inverted?"^":"")+b+"]"},any:function(y){return"any character"},end:function(y){return"end of input"},other:function(y){return y.description}};function g(y){return y.charCodeAt(0).toString(16).toUpperCase()}function C(y){return y.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(b){return"\\x0"+g(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+g(b)})}function m(y){return y.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(b){return"\\x0"+g(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+g(b)})}function S(y){return e[y.type](y)}function E(y){var b=new Array(y.length),v,M;for(v=0;v<y.length;v++)b[v]=S(y[v]);if(b.sort(),b.length>0){for(v=1,M=1;v<b.length;v++)b[v-1]!==b[v]&&(b[M]=b[v],M++);b.length=M}switch(b.length){case 1:return b[0];case 2:return b[0]+" or "+b[1];default:return b.slice(0,-1).join(", ")+", or "+b[b.length-1]}}function Y(y){return y?'"'+C(y)+'"':"end of input"}return"Expected "+E(o)+" but "+Y(h)+" found."};function A(o,h){h=h!==void 0?h:{};var e={},g={Start:Jn},C=Jn,m=function(t){return t||[]},S=function(t,i,a){return[{command:t,type:i}].concat(a||[])},E=function(t,i){return[{command:t,type:i||";"}]},Y=function(t){return t},y=";",b=ce(";",!1),v="&",M=ce("&",!1),re=function(t,i){return i?{chain:t,then:i}:{chain:t}},ae=function(t,i){return{type:t,line:i}},x="&&",Z=ce("&&",!1),te="||",q=ce("||",!1),ue=function(t,i){return i?{...t,then:i}:t},Ce=function(t,i){return{type:t,chain:i}},ge="|&",Ae=ce("|&",!1),Ee="|",Oe=ce("|",!1),Fe="=",Ue=ce("=",!1),ye=function(t,i){return{name:t,args:[i]}},Me=function(t){return{name:t,args:[]}},Ze="(",$e=ce("(",!1),ee=")",Ne=ce(")",!1),De=function(t,i){return{type:"subshell",subshell:t,args:i}},Re="{",qe=ce("{",!1),we="}",W=ce("}",!1),U=function(t,i){return{type:"group",group:t,args:i}},ie=function(t,i){return{type:"command",args:i,envs:t}},ve=function(t){return{type:"envs",envs:t}},Je=function(t){return t},ze=function(t){return t},Pe=/^[0-9]/,Ye=We([["0","9"]],!1,!1),tt=function(t,i,a){return{type:"redirection",subtype:i,fd:t!==null?parseInt(t):null,args:[a]}},rt=">>",Ct=ce(">>",!1),st=">&",ut=ce(">&",!1),wt=">",He=ce(">",!1),ht="<<<",Xe=ce("<<<",!1),Ve="<&",dt=ce("<&",!1),St="<",gt=ce("<",!1),r=function(t){return{type:"argument",segments:[].concat(...t)}},$=function(t){return t},j="$'",K=ce("$'",!1),P="'",u=ce("'",!1),w=function(t){return[{type:"text",text:t}]},O='""',R=ce('""',!1),N=function(){return{type:"text",text:""}},H='"',T=ce('"',!1),z=function(t){return t},G=function(t){return{type:"arithmetic",arithmetic:t,quoted:!0}},ne=function(t){return{type:"shell",shell:t,quoted:!0}},de=function(t){return{type:"variable",...t,quoted:!0}},le=function(t){return{type:"text",text:t}},_e=function(t){return{type:"arithmetic",arithmetic:t,quoted:!1}},kr=function(t){return{type:"shell",shell:t,quoted:!1}},Er=function(t){return{type:"variable",...t,quoted:!1}},nr=function(t){return{type:"glob",pattern:t}},Tt=/^[^']/,Lt=We(["'"],!0,!1),mt=function(t){return t.join("")},ir=/^[^$"]/,or=We(["$",'"'],!0,!1),Ht=`\\
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRequire as m}from"node:module";import{m as _}from"./index-OQZQyN5R.js";import{a as F}from"../packem_chunks/cli-main.js";const p=m(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,c=r=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,e]=o.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return o.getBuiltinModule(r)}return p(r)},{mkdirSync:f,writeFileSync:h,readdirSync:g}=c("node:fs"),{readFile:y}=c("node:fs/promises"),n=r=>F(r),a=(r,t)=>_(n(r),`${encodeURIComponent(t)}.json`);class S{#t;#e;constructor(t,e){this.#t=t,this.#e=e}printTaskTerminalOutput(t,e,s){if(e!=="failure")return;const i=n(this.#t);try{f(i,{recursive:!0})}catch{return}const u=t.overrides.command,d=t.projectRoot,l={command:u,cwd:d,exitCode:void 0,hash:t.hash,runId:this.#e,status:e,taskId:t.id,terminalOutput:s,timestamp:new Date().toISOString()};try{h(a(this.#t,t.id),`${JSON.stringify(l,void 0,2)}
|
|
2
|
+
`,"utf8")}catch{}}}const I=async(r,t)=>{const e=a(r,t);try{const s=await y(e,"utf8");return JSON.parse(s)}catch{return}},O=r=>{const t=n(r);let e;try{e=g(t)}catch{return[]}const s=[];for(const i of e)if(i.endsWith(".json"))try{s.push(decodeURIComponent(i.slice(0,-5)))}catch{}return s};export{S as F,I as a,O as l};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as ce}from"node:module";const le=ce(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=r=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[e,t]=y.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return y.getBuiltinModule(r)}return le(r)},{existsSync:m,openSync:ue,readSync:de,closeSync:pe,statSync:he,createWriteStream:X,readdirSync:fe,renameSync:me}=w("node:fs"),{readFile:q,mkdir:S,rm:x,writeFile:ge,mkdtemp:we}=w("node:fs/promises"),{PassThrough:
|
|
2
|
-
`):""}`)}async function Ve(r={}){let e=r.cwd||process.cwd(),t={...process.env,...r.env},n=(typeof r.packageManager=="string"?v.find(o=>o.name===r.packageManager):r.packageManager)||await ie(r.cwd||process.cwd());if(!n)throw Error("No package manager auto-detected.");return{cwd:e,env:t,silent:r.silent??!1,packageManager:n,dev:r.dev??!1,workspace:r.workspace,global:r.global??!1,dry:r.dry??!1,corepack:r.corepack??!0}}function Ye(r){let[e,t]=(r||"").split("@"),[n,o]=t?.split("+")||[];if(e&&e!=="-"&&/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(e))return{name:e,version:n,buildMeta:o};let s=(e||"").replace(/\W+/g,"");return{name:s,version:n,buildMeta:o,warnings:[`Abnormal characters found in \`packageManager\` field, sanitizing from \`${e}\` to \`${s}\``]}}const v=[{name:"npm",command:"npm",lockFile:"package-lock.json"},{name:"pnpm",command:"pnpm",lockFile:"pnpm-lock.yaml",files:["pnpm-workspace.yaml"]},{name:"bun",command:"bun",lockFile:["bun.lockb","bun.lock"]},{name:"yarn",command:"yarn",lockFile:"yarn.lock",files:[".yarnrc.yml"]},{name:"deno",command:"deno",lockFile:"deno.lock",files:["deno.json"]}];async function ie(r,e={}){let t=await We(f(r||"."),async n=>{if(!e.ignorePackageJSON){let o=M(n,"package.json");if(m(o)){let s=JSON.parse(await q(o,"utf8"));if(s?.packageManager){let{name:i,version:a="0.0.0",buildMeta:c,warnings:d}=Ye(s.packageManager);if(i){let l=a.split(".")[0],h=v.find(p=>p.name===i&&p.majorVersion===l)||v.find(p=>p.name===i);return{name:i,command:i,version:a,majorVersion:l,buildMeta:c,warnings:d,files:h?.files,lockFile:h?.lockFile}}}}if(m(M(n,"deno.json")))return v.find(s=>s.name==="deno")}if(!e.ignoreLockFile){for(let o of v)if([o.lockFile,o.files].flat().filter(Boolean).some(s=>m(f(n,s))))return{...o}}},{includeParentDirs:e.includeParentDirs??!0});if(!t&&!e.ignoreArgv){let n=process.argv[1];if(n){for(let o of v)if(RegExp(`[/\\\\]\\.?${o.command}`).test(n))return o}}return t}async function Ze(r={}){let e=await Ve(r),t=r.frozenLockFile?{npm:["ci"],yarn:["install","--immutable"],bun:["install","--frozen-lockfile"],pnpm:["install","--frozen-lockfile"],deno:["install","--frozen"]}[e.packageManager.name]:["install"];return r.ignoreWorkspace&&e.packageManager.name==="pnpm"&&t.push("--ignore-workspace"),e.dry||await Je(e.packageManager.command,t,{cwd:e.cwd,silent:e.silent,corepack:e.corepack}),{exec:{command:e.packageManager.command,args:t}}}const Ke=Object.defineProperty({__proto__:null,basename:oe,dirname:ne,dist_exports:Le,resolve:f},Symbol.toStringTag,{value:"Module"});async function Qe(r,e,t={}){const n=e+".json",o=JSON.parse(await q(n,"utf8").catch(()=>"{}")),s=(await E(r,{method:"HEAD",headers:t.headers}).catch(()=>{}))?.headers.get("etag");if(o.etag===s&&m(e))return;typeof s=="string"&&(o.etag=s);const i=await E(r,{headers:t.headers});if(i.status>=400)throw new Error(`Failed to download ${r}: ${i.status} ${i.statusText}`);const a=X(e);await ke($e)(i.body,a),await ge(n,JSON.stringify(o),"utf8")}const et=/^(?<repo>[-\w.]+\/[-\w.]+)(?<subdir>[^#]+)?(?<ref>#[-\w./@]+)?/,tt=/^(?<repo>[-\w.]+(?:\/[-\w.]+)+?)(?:::(?<subdir>[^#]*))?(?<ref>#[-\w./@]+)?$/;function O(r,e){const t=e?.expandRepo||r.includes("::"),n=r.match(t?tt:et)?.groups||{},o=t?n.subdir?"/"+n.subdir:"/":n.subdir||"/";return{repo:n.repo||"",subdir:o,ref:n.ref?n.ref.slice(1):"main"}}function $(...r){process.env.DEBUG&&console.debug("[giget]",...r)}async function E(r,e={}){e.headers?.["sec-fetch-mode"]&&(e.mode=e.headers["sec-fetch-mode"]);const t=await fetch(r,{...e,headers:ae(e.headers)}).catch(n=>{throw new Error(`Failed to download ${r}: ${n}`,{cause:n})});if(e.validateStatus&&t.status>=400)throw new Error(`Failed to fetch ${r}: ${t.status} ${t.statusText}`);return t}function rt(){const r=process.env.XDG_CACHE_HOME?f(process.env.XDG_CACHE_HOME,"giget"):f(ye(),".cache/giget");if(process.platform==="win32"){const e=f(Q(),"giget");if(!m(e)&&m(r))try{me(r,e)}catch{}return e}return r}function ae(r={}){const e={};for(const[t,n]of Object.entries(r))n&&(e[t.toLowerCase()]=n);return e}const nt=(r,e)=>{const t=ot(r);return{name:t.name,version:t.subdir?`${t.version||"default"}-${t.subdir.replaceAll("/","-")}`:t.version,tar:({auth:n}={})=>st(t,n??e.auth)}};function ot(r,e={}){const t=e.cwd??process.cwd();let n=r.replace(/#.*$/,""),o;if(/^[./]/.test(r))n=f(t,n);else if(/^https?:\/\//.test(n)){const l=/^(https?:\/\/[^/]+)\/([\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(n);if(l){const[,h,p,g]=l;n=`${h}/${p}`,g&&(o=g)}}else if(n.includes("@")){const l=/^(.*?:[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(n);if(l){const[,h,p]=l;n=h,p&&(o=p)}}else{const l={"github:":"https://github.com/","gh:":"https://github.com/","gitlab:":"https://gitlab.com/","bitbucket:":"https://bitbucket.org/","sourcehut:":"https://git.sr.ht/~"},h=/^(.+?:)/.exec(n)?.at(1);h&&l[h]?n=n.replace(h,l[h]):h||(n=`${(process.env.GIGET_GIT_HOST||"https://github.com/").replace(/\/$/,"")}/${n}`);const p=/^(https?:\/\/[^/]+\/~?[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(n);if(p){const[,g,u]=p;n=g,u&&(o=u)}}const s=n.replace(/^https?:\/\//,"").replace(/^.+@/,"").replace(/(\.git)?(#.*)?$/,"").replace(/^\W+/,"").replaceAll(/[:/]/g,"-"),[i,a]=/#(.+)$/.exec(r)?.at(1)?.split(":")??[],c=i||void 0,d=a||o;return{uri:n,name:s,...c&&{version:c},...d&&{subdir:d}}}async function st(r,e){const t=await we(I(Q(),"giget-git-"));if(e&&/[\r\n]/.test(e))throw new Error("Auth token must not contain newline characters");const n={...process.env,GIT_TERMINAL_PROMPT:"0"};e&&(n.GIT_CONFIG_COUNT="1",n.GIT_CONFIG_KEY_0="http.extraHeader",n.GIT_CONFIG_VALUE_0=`Authorization: Bearer ${e}`);const o={env:n,timeout:6e4},s=it(),i=c=>R(c,o,s),a=c=>R(c,{...o,cwd:t},s);try{const c=["clone","--progress","--depth","1"];r.subdir&&c.push("--filter=blob:none","--sparse","--no-checkout"),r.version&&c.push("--branch",r.version),c.push("--",r.uri,t);try{s.update("Cloning..."),await i(c),s.update("Cloned.")}catch(u){if(!r.version)throw u;$("Shallow clone failed, falling back to full clone:",u),s.update("Shallow clone failed, cloning..."),await x(t,{recursive:!0,force:!0}),await S(t,{recursive:!0}),await a(["init"]),await a(["remote","add","origin",r.uri]),await a(["fetch","origin"]),await a(["checkout",r.version]),s.update("Fetched.")}r.subdir&&(s.update(`Sparse checkout ${r.subdir}...`),await a(["sparse-checkout","set",r.subdir]),await a(["checkout"])),s.update("Packing...");const d=r.subdir?I(t,r.subdir):t,{create:l}=await import("../packem_chunks/tar.js").then(u=>u.index_min_exports);s.done();const h=l({gzip:!0,cwd:d,filter:u=>!u.startsWith(".git/")&&u!==".git"&&!u.startsWith("./.git/")&&u!=="./.git"},["."]).pipe(new J);let p=!1;const g=()=>{p||(p=!0,x(t,{recursive:!0,force:!0}))};return h.on("end",g),h.on("error",g),h.on("close",g),h}catch(c){throw s.done(),await x(t,{recursive:!0,force:!0}),c}}const N=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function R(r,e,t){return new Promise((n,o)=>{const s=Y("git",r,{...e,stdio:["ignore","pipe","pipe"]});s.stdout.resume();let i="";s.stderr?.on("data",a=>{const c=a.toString();for(const d of c.split(/[\r\n]/)){const l=d.trim();l&&(i=l)}t&&t.update(i)}),s.on("close",a=>{a===0?n(i):o(new Error(`git ${r[0]} exited with code ${a}. Is git installed?`))}),s.on("error",a=>{a.code==="ENOENT"?o(new Error("git is not installed or not found in PATH")):o(a)})})}function it(){if(!process.stderr.isTTY)return{update(o){},done(){}};let r="",e=0;const t=()=>{const o=N[e%N.length];e++,process.stderr.write(`\x1B[2K\r\x1B[2m${o} ${r}\x1B[0m`)},n=setInterval(t,80);return{update(o){r=o,t()},done(){clearInterval(n),process.stderr.write("\x1B[2K\r")}}}const U=async(r,e)=>{if(r.endsWith(".json"))return await L(r,e);const t=new URL(r);let n=oe(t.pathname);try{const o=await E(t.href,{method:"HEAD",validateStatus:!0,headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0}});if((o.headers.get("content-type")||"").includes("application/json"))return await L(r,e);const s=o.headers.get("content-disposition")?.match(/filename="?(.+)"?/)?.[1];s&&(n=s.split(".")[0])}catch(o){$(`Failed to fetch HEAD for ${t.href}:`,o)}return{name:`${n}-${t.href.slice(0,8)}`,version:"",subdir:"",tar:t.href,defaultDir:n,headers:{Authorization:e.auth?`Bearer ${e.auth}`:void 0}}},L=async(r,e)=>{const t=await(await E(r,{validateStatus:!0,headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0}})).json();if(!t.tar||!t.name)throw new Error(`Invalid template info from ${r}. name or tar fields are missing!`);return t},W=(r,e)=>{const t=O(r),n=process.env.GIGET_GITHUB_URL||"https://api.github.com";return{name:t.repo.replace("/","-"),version:t.ref,subdir:t.subdir,headers:{Authorization:e.auth?`Bearer ${e.auth}`:void 0,Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},url:`${n.replace("api.github.com","github.com")}/${t.repo}/tree/${t.ref}${t.subdir}`,tar:`${n}/repos/${t.repo}/tarball/${t.ref}`}},at=(r,e)=>{const t=O(r,{expandRepo:!0}),n=process.env.GIGET_GITLAB_URL||"https://gitlab.com";return{name:t.repo.replace("/","-"),version:t.ref,subdir:t.subdir,headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0,"sec-fetch-mode":"same-origin"},url:`${n}/${t.repo}/tree/${t.ref}${t.subdir}`,tar:`${n}/${t.repo}/-/archive/${t.ref}.tar.gz`}},ct=(r,e)=>{const t=O(r);return{name:t.repo.replace("/","-"),version:t.ref,subdir:t.subdir,headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0},url:`https://bitbucket.com/${t.repo}/src/${t.ref}${t.subdir}`,tar:`https://bitbucket.org/${t.repo}/get/${t.ref}.tar.gz`}},lt=(r,e)=>{const t=O(r);return{name:t.repo.replace("/","-"),version:t.ref,subdir:t.subdir,headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0},url:`https://git.sr.ht/~${t.repo}/tree/${t.ref}/item${t.subdir}`,tar:`https://git.sr.ht/~${t.repo}/archive/${t.ref}.tar.gz`}},ut={http:U,https:U,git:nt,github:W,gh:W,gitlab:at,bitbucket:ct,sourcehut:lt},dt="https://raw.githubusercontent.com/unjs/giget/main/templates",pt=(r=dt,e={})=>(async t=>{const n=Date.now(),o=`${r}/${t}.json`,s=await E(o,{headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0}});if(s.status>=400)throw new Error(`Failed to download ${t} template info from ${o}: ${s.status} ${s.statusText}`);const i=await s.json();if(!i.tar||!i.name)throw new Error(`Invalid template info from ${o}. name or tar fields are missing!`);return $(`Fetched ${t} template info from ${o} in ${Date.now()-n}ms`),i}),ht=/^([\w+-.]+):/;function ft(r){if(!r)return;if(typeof r=="function")return r;const e=globalThis.process.getBuiltinModule?.("node:path")?.matchesGlob;if(typeof e!="function")throw new TypeError("Ignore patterns require `path.matchesGlob` which is supported in Node.js v22.5.0, v20.17.0 or later.");return t=>r.some(n=>e(t,n))}async function $t(r,e={}){const t=ft(e.ignore);e.registry=process.env.GIGET_REGISTRY??e.registry,e.auth=process.env.GIGET_AUTH??e.auth;const n=e.registry===!1?void 0:pt(e.registry,{auth:e.auth});let o=e.provider||(n?"registry":"github"),s=r;const i=r.match(ht);i&&(o=i[1],s=r.slice(i[0].length),(o==="http"||o==="https")&&(s=r)),o.endsWith("+git")&&(s=`${o.slice(0,-4)}:${s}`,o="git");const a=e.providers?.[o]||ut[o]||n;if(!a)throw new Error(`Unsupported provider: ${o}`);const c=await Promise.resolve().then(()=>a(s,{auth:e.auth})).catch(u=>{throw new Error(`Failed to download template from ${o}: ${u.message}`)});if(!c)throw new Error(`Failed to resolve template from ${o}`);c.name=(c.name||"template").replace(/[^\da-z-]/gi,"-"),c.defaultDir=(c.defaultDir||c.name).replace(/[^\da-z-]/gi,"-");const d=f(f(rt(),o,c.name),(c.version||c.name)+".tar.gz");if(e.preferOffline&&m(d)&&(e.offline=!0),!e.offline){await S(ne(d),{recursive:!0});const u=Date.now();if(typeof c.tar=="function"){const b=c.tar;await(async()=>{const _=await b({auth:e.auth});await V(_ instanceof z?_:z.fromWeb(_),X(d))})().catch(_=>{if(!m(d))throw _;$("Download error. Using cached version:",_),e.offline=!0})}else await Qe(c.tar,d,{headers:{Authorization:e.auth?`Bearer ${e.auth}`:void 0,...ae(c.headers)}}).catch(b=>{if(!m(d))throw b;$("Download error. Using cached version:",b),e.offline=!0});$(`Downloaded to ${d} in ${Date.now()-u}ms`)}if(!m(d))throw new Error(`Tarball not found: ${d} (offline: ${e.offline})`);const l=f(f(e.cwd||"."),e.dir||c.defaultDir);if(e.forceClean&&await x(l,{recursive:!0,force:!0}),!e.force&&m(l)&&fe(l).length>0)throw new Error(`Destination ${l} already exists.`);await S(l,{recursive:!0});const h=Date.now(),p=c.subdir?.replace(/^\//,"")||"",{extract:g}=await import("../packem_chunks/tar.js").then(u=>u.index_min_exports);if(await g({file:d,cwd:l,onReadEntry(u){u.path=u.path.split("/").splice(1).join("/"),p&&(u.path.startsWith(p+"/")?u.path=u.path.slice(p.length):u.path=""),t&&u.path&&t(u.path.replace(/^\//,""))&&(u.path="")}}),$(`Extracted to ${l} in ${Date.now()-h}ms`),e.install){$("Installing dependencies...");const{installDependencies:u}=await Promise.resolve().then(()=>Ke).then(b=>b.dist_exports);await u({cwd:l,silent:e.silent,...typeof e.install=="object"?e.install:{}})}return{...c,source:s,dir:l}}export{$t as f,Ee as l};
|
|
1
|
+
import{createRequire as ce}from"node:module";const le=ce(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=r=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[e,t]=y.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return y.getBuiltinModule(r)}return le(r)},{existsSync:m,openSync:ue,readSync:de,closeSync:pe,statSync:he,createWriteStream:X,readdirSync:fe,renameSync:me}=w("node:fs"),{readFile:q,mkdir:S,rm:x,writeFile:ge,mkdtemp:we}=w("node:fs/promises"),{PassThrough:V,Readable:z,pipeline:$e}=w("node:stream"),{pipeline:J}=w("node:stream/promises"),{spawn:Y}=w("node:child_process"),{basename:ve,normalize:be,delimiter:C,resolve:Z,dirname:F,join:I}=w("node:path"),{cwd:K}=y,_e=w("node:readline"),{homedir:ye,tmpdir:Q}=w("node:os"),{promisify:ke}=w("node:util");var G=Object.defineProperty,Ee=(r,e)=>{let t={};for(var n in r)G(t,n,{get:r[n],enumerable:!0});return G(t,Symbol.toStringTag,{value:"Module"}),t};const xe=/^[A-Za-z]:\//;function T(r=""){return r&&r.replace(/\\/g,"/").replace(xe,e=>e.toUpperCase())}const Ce=/^[/\\]{2}/,Te=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,ee=/^[A-Za-z]:$/,te=function(r){if(r.length===0)return".";r=T(r);let e=r.match(Ce),t=k(r),n=r[r.length-1]==="/";return r=re(r,!t),r.length===0?t?"/":n?"./":".":(n&&(r+="/"),ee.test(r)&&(r+="/"),e?t?`//${r}`:`//./${r}`:t&&!k(r)?`/${r}`:r)},M=function(...r){let e="";for(let t of r)if(t)if(e.length>0){let n=e[e.length-1]==="/",o=t[0]==="/";n&&o?e+=t.slice(1):e+=n||o?t:`/${t}`}else e+=t;return te(e)};function Oe(){return typeof process.cwd=="function"?process.cwd().replace(/\\/g,"/"):"/"}const f=function(...r){r=r.map(n=>T(n));let e="",t=!1;for(let n=r.length-1;n>=-1&&!t;n--){let o=n>=0?r[n]:Oe();!o||o.length===0||(e=`${o}/${e}`,t=k(o))}return e=re(e,!t),t&&!k(e)?`/${e}`:e.length>0?e:"."};function re(r,e){let t="",n=0,o=-1,s=0,i=null;for(let a=0;a<=r.length;++a){if(a<r.length)i=r[a];else{if(i==="/")break;i="/"}if(i==="/"){if(!(o===a-1||s===1))if(s===2){if(t.length<2||n!==2||t[t.length-1]!=="."||t[t.length-2]!=="."){if(t.length>2){let c=t.lastIndexOf("/");c===-1?(t="",n=0):(t=t.slice(0,c),n=t.length-1-t.lastIndexOf("/")),o=a,s=0;continue}else if(t.length>0){t="",n=0,o=a,s=0;continue}}e&&(t+=t.length>0?"/..":"..",n=2)}else t.length>0?t+=`/${r.slice(o+1,a)}`:t=r.slice(o+1,a),n=a-o-1;o=a,s=0}else i==="."&&s!==-1?++s:s=-1}return t}const k=function(r){return Te.test(r)},ne=function(r){let e=T(r).replace(/\/$/,"").split("/").slice(0,-1);return e.length===1&&ee.test(e[0])&&(e[0]+="/"),e.join("/")||(k(r)?"/":".")},oe=function(r,e){let t=T(r).split("/"),n="";for(let o=t.length-1;o>=0;o--){let s=t[o];if(s){n=s;break}}return n},Ae=/^path$/i,D={key:"PATH",value:""};function se(r){for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e)||!Ae.test(e))continue;let t=r[e];return t?{key:e,value:t}:D}return D}function Se(r,e){let t=e.value.split(C),n=[],o=r,s;do n.push(Z(o,"node_modules",".bin")),s=o,o=F(o);while(o!==s);n.push(F(process.execPath));let i=n.concat(t).join(C);return{key:e.key,value:i}}function je(r,e,t=!0){let n={...process.env,...e};if(!t)return n;let o=Se(r,se(n));return n[o.key]=o.value,n}const ze=r=>{let e=r.length,t=new V,n=()=>{--e===0&&t.end()};for(let o of r)J(o,t,{end:!1}).then(n).catch(n);return t},A=/([()\][%!^"`<>&|;, *?])/g,Fe=/^#!\s*(.+)/,Ie=/\.(?:com|exe)$/i,Ge=/node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/i,Me=process.platform==="win32",De=[".EXE",".CMD",".BAT",".COM"];function Pe(r,e=[],t={}){if(t.shell===!0||!Me)return{command:r,args:e,options:t};let n=P(r,t),o=null;if(n!==null){let s=Buffer.alloc(150),i=null;try{i=ue(n,"r"),de(i,s,0,150,0)}catch{}finally{i!==null&&pe(i)}let a=s.toString().match(Fe);if(a!==null){let c=a[1].trim(),d=c.indexOf(" "),l=d===-1?c:c.slice(0,d),h=d===-1?"":c.slice(d+1),p=ve(l);o=p==="env"?h||null:p}}if(o!==null&&n!==null&&(e=[n,...e],r=o,n=P(r,t)),n===null||!Ie.test(n)){let s=n!==null&&Ge.test(n);r=be(r),r=r.replace(A,"^$1"),e=e.map(i=>(i=i.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),i=i.replace(/(?=(\\+?)?)\1$/,"$1$1"),i=`"${i}"`,i=i.replace(A,"^$1"),s&&(i=i.replace(A,"^$1")),i)),e=["/d","/s","/c",`"${[r,...e].join(" ")}"`],r=t.env?.comspec??"cmd.exe",t={...t,windowsVerbatimArguments:!0}}return{command:r,args:e,options:t}}function P(r,e){let t=(e.cwd??K()).toString(),n=e.env??process.env,o=se(n).value,s=r.includes("/")||r.includes("\\")?[""]:[t,...o.split(C)],i=n.PATHEXT?n.PATHEXT.split(C):De;r.includes(".")&&i[0]!==""&&i.unshift("");for(let a of s){let c=Z(t,a.startsWith('"')&&a.endsWith('"')&&a.length>1?a.slice(1,-1):a,r);for(let d of i){let l=c+d;try{if(he(l).isFile())return l}catch{}}}return null}var B=class extends Error{result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,t){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=t}};const Be={timeout:void 0,persist:!1},He={windowsHide:!0};function Ne(r){let e=new AbortController;for(let t of r){if(t.aborted)return e.abort(),t;t.addEventListener("abort",()=>{e.abort(t.reason)},{signal:e.signal})}return e.signal}async function H(r){let e="";try{for await(let t of r)e+=t.toString()}catch{}return e}var Re=class{_process;_aborted=!1;_options;_command;_args;_resolveClose;_processClosed;_thrownError;get process(){return this._process}get pid(){return this._process?.pid}get exitCode(){if(this._process&&this._process.exitCode!==null)return this._process.exitCode}constructor(e,t,n){this._options={...Be,...n},this._command=e,this._args=t??[],this._processClosed=new Promise(o=>{this._resolveClose=o})}kill(e){return this._process?.kill(e)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(e,t,n){return Ue(e,t,{...n,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let t=[];this._streamErr&&t.push(this._streamErr),this._streamOut&&t.push(this._streamOut);let n=ze(t),o=_e.createInterface({input:n});for await(let s of o)yield s.toString();if(await this._processClosed,e.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new B(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error("No process was started");let[t,n]=await Promise.all([this._streamOut?H(this._streamOut):"",this._streamErr?H(this._streamErr):""]);await this._processClosed;let{stdin:o}=this._options;if(o&&typeof o!="string"&&await o,e.removeAllListeners(),this._thrownError)throw this._thrownError;let s={stderr:n,stdout:t,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new B(this,s);return s}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=K(),t=this._options,n={...He,...t.nodeOptions},o=[];this._resetState(),t.timeout!==void 0&&o.push(AbortSignal.timeout(t.timeout)),t.signal!==void 0&&o.push(t.signal),t.persist===!0&&(n.detached=!0),o.length>0&&(n.signal=Ne(o)),n.env=je(e,n.env,t.nodePath);let s=Pe(this._command,this._args,n),i=Y(s.command,s.args,s.options);if(i.stderr&&(this._streamErr=i.stderr),i.stdout&&(this._streamOut=i.stdout),this._process=i,i.once("error",this._onError),i.once("close",this._onClose),i.stdin){let{stdin:a}=t;typeof a=="string"?i.stdin.end(a):a?.process?.stdout?.pipe(i.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(e=>{this._resolveClose=e}),this._thrownError=void 0}_onError=e=>{if(e.name==="AbortError"&&(!(e.cause instanceof Error)||e.cause.name!=="TimeoutError")){this._aborted=!0;return}this._thrownError=e};_onClose=()=>{this._resolveClose&&this._resolveClose()}};const j=(r,e,t)=>{let n=new Re(r,e,t);return n.spawn(),n},Ue=j;var Le=Ee({detectPackageManager:()=>ie,installDependencies:()=>Ze,packageManagers:()=>v});async function We(r,e,t={}){let n=te(r).split("/");for(;n.length>0;){let o=await e(n.join("/")||"/");if(o||!t.includeParentDirs)return o;n.pop()}}function Xe(r){let e;return()=>(e===void 0&&(e=r().then(t=>(e=t,e))),e)}const qe=Xe(async()=>{if(globalThis.process?.versions?.webcontainer)return!1;try{let{exitCode:r}=await j("corepack",["--version"]);return r===0}catch{return!1}});async function Ve(r,e,t={}){let n=r!=="npm"&&r!=="bun"&&r!=="deno"&&t.corepack!==!1&&await qe()?["corepack",[r,...e]]:[r,e],{exitCode:o,stdout:s,stderr:i}=await j(n[0],n[1],{nodeOptions:{cwd:f(t.cwd||process.cwd()),env:t.env,stdio:t.silent?"pipe":"inherit"}});if(o!==0)throw Error(`\`${n.flat().join(" ")}\` failed.${t.silent?["",s,i].join(`
|
|
2
|
+
`):""}`)}async function Je(r={}){let e=r.cwd||process.cwd(),t={...process.env,...r.env},n=(typeof r.packageManager=="string"?v.find(o=>o.name===r.packageManager):r.packageManager)||await ie(r.cwd||process.cwd());if(!n)throw Error("No package manager auto-detected.");return{cwd:e,env:t,silent:r.silent??!1,packageManager:n,dev:r.dev??!1,workspace:r.workspace,global:r.global??!1,dry:r.dry??!1,corepack:r.corepack??!0}}function Ye(r){let[e,t]=(r||"").split("@"),[n,o]=t?.split("+")||[];if(e&&e!=="-"&&/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(e))return{name:e,version:n,buildMeta:o};let s=(e||"").replace(/\W+/g,"");return{name:s,version:n,buildMeta:o,warnings:[`Abnormal characters found in \`packageManager\` field, sanitizing from \`${e}\` to \`${s}\``]}}const v=[{name:"npm",command:"npm",lockFile:"package-lock.json"},{name:"pnpm",command:"pnpm",lockFile:"pnpm-lock.yaml",files:["pnpm-workspace.yaml"]},{name:"bun",command:"bun",lockFile:["bun.lockb","bun.lock"]},{name:"yarn",command:"yarn",lockFile:"yarn.lock",files:[".yarnrc.yml"]},{name:"deno",command:"deno",lockFile:"deno.lock",files:["deno.json"]}];async function ie(r,e={}){let t=await We(f(r||"."),async n=>{if(!e.ignorePackageJSON){let o=M(n,"package.json");if(m(o)){let s=JSON.parse(await q(o,"utf8"));if(s?.packageManager){let{name:i,version:a="0.0.0",buildMeta:c,warnings:d}=Ye(s.packageManager);if(i){let l=a.split(".")[0],h=v.find(p=>p.name===i&&p.majorVersion===l)||v.find(p=>p.name===i);return{name:i,command:i,version:a,majorVersion:l,buildMeta:c,warnings:d,files:h?.files,lockFile:h?.lockFile}}}}if(m(M(n,"deno.json")))return v.find(s=>s.name==="deno")}if(!e.ignoreLockFile){for(let o of v)if([o.lockFile,o.files].flat().filter(Boolean).some(s=>m(f(n,s))))return{...o}}},{includeParentDirs:e.includeParentDirs??!0});if(!t&&!e.ignoreArgv){let n=process.argv[1];if(n){for(let o of v)if(RegExp(`[/\\\\]\\.?${o.command}`).test(n))return o}}return t}async function Ze(r={}){let e=await Je(r),t=r.frozenLockFile?{npm:["ci"],yarn:["install","--immutable"],bun:["install","--frozen-lockfile"],pnpm:["install","--frozen-lockfile"],deno:["install","--frozen"]}[e.packageManager.name]:["install"];return r.ignoreWorkspace&&e.packageManager.name==="pnpm"&&t.push("--ignore-workspace"),e.dry||await Ve(e.packageManager.command,t,{cwd:e.cwd,silent:e.silent,corepack:e.corepack}),{exec:{command:e.packageManager.command,args:t}}}const Ke=Object.defineProperty({__proto__:null,basename:oe,dirname:ne,dist_exports:Le,resolve:f},Symbol.toStringTag,{value:"Module"});async function Qe(r,e,t={}){const n=e+".json",o=JSON.parse(await q(n,"utf8").catch(()=>"{}")),s=(await E(r,{method:"HEAD",headers:t.headers}).catch(()=>{}))?.headers.get("etag");if(o.etag===s&&m(e))return;typeof s=="string"&&(o.etag=s);const i=await E(r,{headers:t.headers});if(i.status>=400)throw new Error(`Failed to download ${r}: ${i.status} ${i.statusText}`);const a=X(e);await ke($e)(i.body,a),await ge(n,JSON.stringify(o),"utf8")}const et=/^(?<repo>[-\w.]+\/[-\w.]+)(?<subdir>[^#]+)?(?<ref>#[-\w./@]+)?/,tt=/^(?<repo>[-\w.]+(?:\/[-\w.]+)+?)(?:::(?<subdir>[^#]*))?(?<ref>#[-\w./@]+)?$/;function O(r,e){const t=e?.expandRepo||r.includes("::"),n=r.match(t?tt:et)?.groups||{},o=t?n.subdir?"/"+n.subdir:"/":n.subdir||"/";return{repo:n.repo||"",subdir:o,ref:n.ref?n.ref.slice(1):"main"}}function $(...r){process.env.DEBUG&&console.debug("[giget]",...r)}async function E(r,e={}){e.headers?.["sec-fetch-mode"]&&(e.mode=e.headers["sec-fetch-mode"]);const t=await fetch(r,{...e,headers:ae(e.headers)}).catch(n=>{throw new Error(`Failed to download ${r}: ${n}`,{cause:n})});if(e.validateStatus&&t.status>=400)throw new Error(`Failed to fetch ${r}: ${t.status} ${t.statusText}`);return t}function rt(){const r=process.env.XDG_CACHE_HOME?f(process.env.XDG_CACHE_HOME,"giget"):f(ye(),".cache/giget");if(process.platform==="win32"){const e=f(Q(),"giget");if(!m(e)&&m(r))try{me(r,e)}catch{}return e}return r}function ae(r={}){const e={};for(const[t,n]of Object.entries(r))n&&(e[t.toLowerCase()]=n);return e}const nt=(r,e)=>{const t=ot(r);return{name:t.name,version:t.subdir?`${t.version||"default"}-${t.subdir.replaceAll("/","-")}`:t.version,tar:({auth:n}={})=>st(t,n??e.auth)}};function ot(r,e={}){const t=e.cwd??process.cwd();let n=r.replace(/#.*$/,""),o;if(/^[./]/.test(r))n=f(t,n);else if(/^https?:\/\//.test(n)){const l=/^(https?:\/\/[^/]+)\/([\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(n);if(l){const[,h,p,g]=l;n=`${h}/${p}`,g&&(o=g)}}else if(n.includes("@")){const l=/^(.*?:[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(n);if(l){const[,h,p]=l;n=h,p&&(o=p)}}else{const l={"github:":"https://github.com/","gh:":"https://github.com/","gitlab:":"https://gitlab.com/","bitbucket:":"https://bitbucket.org/","sourcehut:":"https://git.sr.ht/~"},h=/^(.+?:)/.exec(n)?.at(1);h&&l[h]?n=n.replace(h,l[h]):h||(n=`${(process.env.GIGET_GIT_HOST||"https://github.com/").replace(/\/$/,"")}/${n}`);const p=/^(https?:\/\/[^/]+\/~?[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(n);if(p){const[,g,u]=p;n=g,u&&(o=u)}}const s=n.replace(/^https?:\/\//,"").replace(/^.+@/,"").replace(/(\.git)?(#.*)?$/,"").replace(/^\W+/,"").replaceAll(/[:/]/g,"-"),[i,a]=/#(.+)$/.exec(r)?.at(1)?.split(":")??[],c=i||void 0,d=a||o;return{uri:n,name:s,...c&&{version:c},...d&&{subdir:d}}}async function st(r,e){const t=await we(I(Q(),"giget-git-"));if(e&&/[\r\n]/.test(e))throw new Error("Auth token must not contain newline characters");const n={...process.env,GIT_TERMINAL_PROMPT:"0"};e&&(n.GIT_CONFIG_COUNT="1",n.GIT_CONFIG_KEY_0="http.extraHeader",n.GIT_CONFIG_VALUE_0=`Authorization: Bearer ${e}`);const o={env:n,timeout:6e4},s=it(),i=c=>R(c,o,s),a=c=>R(c,{...o,cwd:t},s);try{const c=["clone","--progress","--depth","1"];r.subdir&&c.push("--filter=blob:none","--sparse","--no-checkout"),r.version&&c.push("--branch",r.version),c.push("--",r.uri,t);try{s.update("Cloning..."),await i(c),s.update("Cloned.")}catch(u){if(!r.version)throw u;$("Shallow clone failed, falling back to full clone:",u),s.update("Shallow clone failed, cloning..."),await x(t,{recursive:!0,force:!0}),await S(t,{recursive:!0}),await a(["init"]),await a(["remote","add","origin",r.uri]),await a(["fetch","origin"]),await a(["checkout",r.version]),s.update("Fetched.")}r.subdir&&(s.update(`Sparse checkout ${r.subdir}...`),await a(["sparse-checkout","set",r.subdir]),await a(["checkout"])),s.update("Packing...");const d=r.subdir?I(t,r.subdir):t,{create:l}=await import("../packem_chunks/tar.js").then(u=>u.index_min_exports);s.done();const h=l({gzip:!0,cwd:d,filter:u=>!u.startsWith(".git/")&&u!==".git"&&!u.startsWith("./.git/")&&u!=="./.git"},["."]).pipe(new V);let p=!1;const g=()=>{p||(p=!0,x(t,{recursive:!0,force:!0}))};return h.on("end",g),h.on("error",g),h.on("close",g),h}catch(c){throw s.done(),await x(t,{recursive:!0,force:!0}),c}}const N=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function R(r,e,t){return new Promise((n,o)=>{const s=Y("git",r,{...e,stdio:["ignore","pipe","pipe"]});s.stdout.resume();let i="";s.stderr?.on("data",a=>{const c=a.toString();for(const d of c.split(/[\r\n]/)){const l=d.trim();l&&(i=l)}t&&t.update(i)}),s.on("close",a=>{a===0?n(i):o(new Error(`git ${r[0]} exited with code ${a}. Is git installed?`))}),s.on("error",a=>{a.code==="ENOENT"?o(new Error("git is not installed or not found in PATH")):o(a)})})}function it(){if(!process.stderr.isTTY)return{update(o){},done(){}};let r="",e=0;const t=()=>{const o=N[e%N.length];e++,process.stderr.write(`\x1B[2K\r\x1B[2m${o} ${r}\x1B[0m`)},n=setInterval(t,80);return{update(o){r=o,t()},done(){clearInterval(n),process.stderr.write("\x1B[2K\r")}}}const U=async(r,e)=>{if(r.endsWith(".json"))return await L(r,e);const t=new URL(r);let n=oe(t.pathname);try{const o=await E(t.href,{method:"HEAD",validateStatus:!0,headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0}});if((o.headers.get("content-type")||"").includes("application/json"))return await L(r,e);const s=o.headers.get("content-disposition")?.match(/filename="?(.+)"?/)?.[1];s&&(n=s.split(".")[0])}catch(o){$(`Failed to fetch HEAD for ${t.href}:`,o)}return{name:`${n}-${t.href.slice(0,8)}`,version:"",subdir:"",tar:t.href,defaultDir:n,headers:{Authorization:e.auth?`Bearer ${e.auth}`:void 0}}},L=async(r,e)=>{const t=await(await E(r,{validateStatus:!0,headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0}})).json();if(!t.tar||!t.name)throw new Error(`Invalid template info from ${r}. name or tar fields are missing!`);return t},W=(r,e)=>{const t=O(r),n=process.env.GIGET_GITHUB_URL||"https://api.github.com";return{name:t.repo.replace("/","-"),version:t.ref,subdir:t.subdir,headers:{Authorization:e.auth?`Bearer ${e.auth}`:void 0,Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},url:`${n.replace("api.github.com","github.com")}/${t.repo}/tree/${t.ref}${t.subdir}`,tar:`${n}/repos/${t.repo}/tarball/${t.ref}`}},at=(r,e)=>{const t=O(r,{expandRepo:!0}),n=process.env.GIGET_GITLAB_URL||"https://gitlab.com";return{name:t.repo.replace("/","-"),version:t.ref,subdir:t.subdir,headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0,"sec-fetch-mode":"same-origin"},url:`${n}/${t.repo}/tree/${t.ref}${t.subdir}`,tar:`${n}/${t.repo}/-/archive/${t.ref}.tar.gz`}},ct=(r,e)=>{const t=O(r);return{name:t.repo.replace("/","-"),version:t.ref,subdir:t.subdir,headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0},url:`https://bitbucket.com/${t.repo}/src/${t.ref}${t.subdir}`,tar:`https://bitbucket.org/${t.repo}/get/${t.ref}.tar.gz`}},lt=(r,e)=>{const t=O(r);return{name:t.repo.replace("/","-"),version:t.ref,subdir:t.subdir,headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0},url:`https://git.sr.ht/~${t.repo}/tree/${t.ref}/item${t.subdir}`,tar:`https://git.sr.ht/~${t.repo}/archive/${t.ref}.tar.gz`}},ut={http:U,https:U,git:nt,github:W,gh:W,gitlab:at,bitbucket:ct,sourcehut:lt},dt="https://raw.githubusercontent.com/unjs/giget/main/templates",pt=(r=dt,e={})=>(async t=>{const n=Date.now(),o=`${r}/${t}.json`,s=await E(o,{headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0}});if(s.status>=400)throw new Error(`Failed to download ${t} template info from ${o}: ${s.status} ${s.statusText}`);const i=await s.json();if(!i.tar||!i.name)throw new Error(`Invalid template info from ${o}. name or tar fields are missing!`);return $(`Fetched ${t} template info from ${o} in ${Date.now()-n}ms`),i}),ht=/^([\w+-.]+):/;function ft(r){if(!r)return;if(typeof r=="function")return r;const e=globalThis.process.getBuiltinModule?.("node:path")?.matchesGlob;if(typeof e!="function")throw new TypeError("Ignore patterns require `path.matchesGlob` which is supported in Node.js v22.5.0, v20.17.0 or later.");return t=>r.some(n=>e(t,n))}async function $t(r,e={}){const t=ft(e.ignore);e.registry=process.env.GIGET_REGISTRY??e.registry,e.auth=process.env.GIGET_AUTH??e.auth;const n=e.registry===!1?void 0:pt(e.registry,{auth:e.auth});let o=e.provider||(n?"registry":"github"),s=r;const i=r.match(ht);i&&(o=i[1],s=r.slice(i[0].length),(o==="http"||o==="https")&&(s=r)),o.endsWith("+git")&&(s=`${o.slice(0,-4)}:${s}`,o="git");const a=e.providers?.[o]||ut[o]||n;if(!a)throw new Error(`Unsupported provider: ${o}`);const c=await Promise.resolve().then(()=>a(s,{auth:e.auth})).catch(u=>{throw new Error(`Failed to download template from ${o}: ${u.message}`)});if(!c)throw new Error(`Failed to resolve template from ${o}`);c.name=(c.name||"template").replace(/[^\da-z-]/gi,"-"),c.defaultDir=(c.defaultDir||c.name).replace(/[^\da-z-]/gi,"-");const d=f(f(rt(),o,c.name),(c.version||c.name)+".tar.gz");if(e.preferOffline&&m(d)&&(e.offline=!0),!e.offline){await S(ne(d),{recursive:!0});const u=Date.now();if(typeof c.tar=="function"){const b=c.tar;await(async()=>{const _=await b({auth:e.auth});await J(_ instanceof z?_:z.fromWeb(_),X(d))})().catch(_=>{if(!m(d))throw _;$("Download error. Using cached version:",_),e.offline=!0})}else await Qe(c.tar,d,{headers:{Authorization:e.auth?`Bearer ${e.auth}`:void 0,...ae(c.headers)}}).catch(b=>{if(!m(d))throw b;$("Download error. Using cached version:",b),e.offline=!0});$(`Downloaded to ${d} in ${Date.now()-u}ms`)}if(!m(d))throw new Error(`Tarball not found: ${d} (offline: ${e.offline})`);const l=f(f(e.cwd||"."),e.dir||c.defaultDir);if(e.forceClean&&await x(l,{recursive:!0,force:!0}),!e.force&&m(l)&&fe(l).length>0)throw new Error(`Destination ${l} already exists.`);await S(l,{recursive:!0});const h=Date.now(),p=c.subdir?.replace(/^\//,"")||"",{extract:g}=await import("../packem_chunks/tar.js").then(u=>u.index_min_exports);if(await g({file:d,cwd:l,onReadEntry(u){u.path=u.path.split("/").splice(1).join("/"),p&&(u.path.startsWith(p+"/")?u.path=u.path.slice(p.length):u.path=""),t&&u.path&&t(u.path.replace(/^\//,""))&&(u.path="")}}),$(`Extracted to ${l} in ${Date.now()-h}ms`),e.install){$("Installing dependencies...");const{installDependencies:u}=await Promise.resolve().then(()=>Ke).then(b=>b.dist_exports);await u({cwd:l,silent:e.silent,...typeof e.install=="object"?e.install:{}})}return{...c,source:s,dir:l}}export{$t as f,Ee as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{W as o}from"./index-OQZQyN5R.js";const r=async(s,a)=>await o(s,a);export{r as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{m as h,g as k,D as $,f as C}from"./provenance-C0P-UYOM.js";import{S as d,D as N}from"../packem_chunks/cli-main.js";import{W as R}from"./build-scripts-Doxce2VM.js";import{n as v}from"./license-t5KnNX6v.js";import{A as L,B as D,v as A}from"./index-OQZQyN5R.js";import"./public-api-WqUCiyIe.js";import{L as w}from"./dependency-scan-B0HV_qeB.js";const m={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},se=(t,e)=>{const n=m[(t.vulnerability.severity??"UNKNOWN").toUpperCase()]??4,s=m[(e.vulnerability.severity??"UNKNOWN").toUpperCase()]??4;return n-s||t.packageName.localeCompare(e.packageName)||t.packageVersion.localeCompare(e.packageVersion)},P=(t,e)=>{const n=m[e.toUpperCase()]??2;return(m[t.toUpperCase()]??4)<=n},b=["firstSeen","installScripts","license","malware","publisherChange","score","unexpectedDeps","vulnerability"],g=6e4,W=(t,e,n)=>{for(const s of n)if(s===t||s===`${t}@${e}`||s.endsWith("*")&&t.startsWith(s.slice(0,-1)))return!0;return!1},x=async(t,e)=>{const n=e.security?.policies?.firstSeen;if(n?.minutes===void 0||n.minutes<=0)return[];const{minutes:s}=n,a=n.exclude??[],r=e.security?.acceptedRisks,c=s*g,i=Date.now();return(await h(t.packages,$,async o=>{if(W(o.name,o.version,a))return;const l=await k(o.name,{workspaceRoot:t.workspaceRoot});if(l===void 0)return;const p=l.time?.[o.version];if(p===void 0)return;const u=Date.parse(p);if(Number.isNaN(u))return;const f=i-u;if(f>=c)return;const y=Math.max(0,Math.floor(f/g));return{acceptedRisk:d(o.name,o.version,r,"firstSeen"),data:{ageMinutes:y,minimumMinutes:s,publishedAt:p},packageName:o.name,policy:"firstSeen",reason:`${o.name}@${o.version} was published ${String(y)} min ago — below the ${String(s)} min firstSeen cooldown.`,severity:"block",version:o.version}})).filter(o=>o!==void 0)},O=(t,e)=>{const n=e.security?.policies?.installScripts;if(!n)return[];const s=n.allow??{},a=n.strict===!0;if(!a&&Object.keys(s).length===0)return[];const r=R(t.workspaceRoot,s,{pinVersions:e.security?.pinVersions===!0});if(r.unapproved.length===0)return[];const c=e.security?.acceptedRisks,i=a?"block":"warn";return r.unapproved.map(o=>({acceptedRisk:d(o.name,o.version??"*",c,"installScripts"),data:{hooks:o.hooks},packageName:o.name,policy:"installScripts",reason:`${o.name}${o.version?`@${o.version}`:""} declares unapproved build script(s): ${o.hooks.join(", ")}`,severity:i,version:o.version??"*"}))},U=new Set(["AND","OR"]),E=t=>{const e=t.replaceAll("("," ").replaceAll(")"," ").split(/\s+/).map(a=>a.trim()).filter(a=>a.length>0),n=[];let s=!1;for(const a of e){const r=a.toUpperCase();if(s){s=!1;continue}if(r==="WITH"){s=!0;continue}if(U.has(r))continue;const c=a.endsWith("+"),i=c?a.slice(0,-1):a,o=v(i)??i;n.push(o),c&&n.push(`${o}-or-later`)}return n},F=t=>{if(typeof t.license=="string"){const e=t.license.trim();return e.length>0?e:void 0}if(t.license&&typeof t.license=="object"&&typeof t.license.type=="string"){const e=t.license.type.trim();if(e.length>0)return e}if(Array.isArray(t.licenses)&&t.licenses.length>0){const e=t.licenses.map(n=>n&&typeof n.type=="string"?n.type.trim():"").filter(n=>n.length>0);if(e.length>0)return e.length===1?e[0]:`(${e.join(" OR ")})`}},I=(t,e)=>{if(e.length===0)return;const n=new Set(e.map(s=>v(s)??s).map(s=>s.toLowerCase()));for(const s of t)if(n.has(s.toLowerCase()))return s},M=(t,e)=>{if(e.length===0)return;const n=new Set(e.map(s=>v(s)??s).map(s=>s.toLowerCase()));for(const s of t)if(!n.has(s.toLowerCase()))return s},V=(t,e)=>{const n=e.security?.policies?.license;if(!n)return[];const s=n.allow??[],a=n.deny??[];if(s.length===0&&a.length===0)return[];const r=e.security?.acceptedRisks,c=[];for(const i of t.packages){const o=t.manifestData?.get(`${i.name}@${i.version}`),l=o?F(o):void 0;if(!l){s.length>0&&c.push({acceptedRisk:d(i.name,i.version,r,"license"),data:{declaredLicense:null},packageName:i.name,policy:"license",reason:`${i.name}@${i.version} declares no license; allow-list mode requires one of: ${s.join(", ")}`,severity:"block",version:i.version});continue}const p=E(l),u=I(p,a);if(u){c.push({acceptedRisk:d(i.name,i.version,r,"license"),data:{declaredLicense:l,deniedLicense:u},packageName:i.name,policy:"license",reason:`${i.name}@${i.version} uses denied license '${u}' (declared: ${l})`,severity:"block",version:i.version});continue}const f=M(p,s);f&&c.push({acceptedRisk:d(i.name,i.version,r,"license"),data:{allowList:s,declaredLicense:l,unallowedLicense:f},packageName:i.name,policy:"license",reason:`${i.name}@${i.version} uses license '${f}' which is not on the allow-list (declared: ${l})`,severity:"block",version:i.version})}return c},j=6e4,_=(t,e,n)=>{for(const s of n)if(s===t||s===`${t}@${e}`||s.endsWith("*")&&t.startsWith(s.slice(0,-1)))return!0;return!1},H=async(t,e)=>{const n=e.security?.policies?.publisherChange;if(n?.mode!=="no-downgrade")return[];const s=n.exclude??[],a=typeof n.ignoreAfter=="number"?n.ignoreAfter*j:void 0,r=e.security?.acceptedRisks,c=Date.now();return(await h(t.packages,$,async i=>{if(_(i.name,i.version,s))return;const o=await k(i.name,{workspaceRoot:t.workspaceRoot});if(o===void 0)return;if(a!==void 0){const p=o.time?.[i.version],u=p===void 0?Number.NaN:Date.parse(p);if(!Number.isNaN(u)&&c-u>a)return}if(o.versions[i.version]?.dist?.attestations?.provenance!==void 0)return;const l=C(o,i.version);if(l!==void 0)return{acceptedRisk:d(i.name,i.version,r,"publisherChange"),data:{priorVersionWithProvenance:l},packageName:i.name,policy:"publisherChange",reason:`${i.name}@${i.version} dropped the provenance attestation that ${i.name}@${l} carried — publisher trust downgrade.`,severity:"block",version:i.version}})).filter(i=>i!==void 0)},T=t=>{for(const e of Object.values(w))for(const n of[e.file,...e.aliases??[]])if(t===n||t.endsWith(`/${n}`)||t.endsWith(`.${n}`))return e.type},K=(t,e,n)=>{const s=L(e)?e:D(t,e);let a;try{a=A(s)}catch{return}const r=T(s)??w[n]?.type;if(!r)return;const c=N(a,r);if(c.length===0)return;const i=new Set;for(const o of c)i.add(`${o.name}@${o.version}`);return i},z=(t,e)=>{for(const n of e)if(n===t||n.endsWith("*")&&t.startsWith(n.slice(0,-1)))return!0;return!1},Y=(t,e)=>{const n=e.security?.policies?.unexpectedDeps;if(!n)return[];const s=n.allow??[],a=n.baselineLockfile;if(s.length===0&&!a)return[];const r=a?K(t.workspaceRoot,a,t.packageManager):void 0,c=e.security?.acceptedRisks,i=[];for(const o of t.packages){const l=s.length===0||z(o.name,s),p=r?r.has(`${o.name}@${o.version}`):!0;if(l&&p)continue;const u=[],f={};l||(u.push(`not on allow-list (${s.length} entr${s.length===1?"y":"ies"})`),f.allowList=s),!p&&r&&(u.push(`not present in baseline lockfile (${a})`),f.baselineLockfile=a),i.push({acceptedRisk:d(o.name,o.version,c,"unexpectedDeps"),data:f,packageName:o.name,policy:"unexpectedDeps",reason:`${o.name}@${o.version} is unexpected: ${u.join("; ")}`,severity:"block",version:o.version})}return i},q=(t,e)=>{if(!t.osvFindings||t.osvFindings.size===0)return[];const n=e.security?.policies?.vulnerability?.failOn,s=e.security?.acceptedRisks,a=[];for(const r of t.packages){const c=t.osvFindings.get(r.name);if(!(!c||c.length===0))for(const i of c){const o=n?P(i.severity,n)?"block":"warn":"info";a.push({acceptedRisk:d(r.name,r.version,s,"vulnerability"),data:{advisoryId:i.id,aliases:i.aliases??[],cvssScore:i.cvssScore,fixedVersions:i.fixedVersions,severity:i.severity,summary:i.summary},packageName:r.name,policy:"vulnerability",reason:`${i.severity} ${i.id} affects ${r.name}@${r.version}: ${i.summary}`,severity:o,version:r.version})}}return a},S=[{evaluate:q,isConfigured:t=>t.security?.policies?.vulnerability!==void 0,name:"vulnerability",offlineSupported:!0,surfaces:["audit","doctor"]},{evaluate:V,isConfigured:t=>{const e=t.security?.policies?.license;return!!(e&&(e.allow&&e.allow.length>0||e.deny&&e.deny.length>0))},name:"license",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:O,isConfigured:t=>{const e=t.security?.policies?.installScripts;return!!(e&&(e.allow&&Object.keys(e.allow).length>0||e.strict===!0))},name:"installScripts",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:Y,isConfigured:t=>{const e=t.security?.policies?.unexpectedDeps;return!!(e&&(e.allow&&e.allow.length>0||typeof e.baselineLockfile=="string"))},name:"unexpectedDeps",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:x,isConfigured:t=>{const e=t.security?.policies?.firstSeen?.minutes;return typeof e=="number"&&e>0},name:"firstSeen",offlineSupported:!1,surfaces:["audit","doctor","install"]},{evaluate:H,isConfigured:t=>t.security?.policies?.publisherChange?.mode==="no-downgrade",name:"publisherChange",offlineSupported:!1,surfaces:["audit","doctor","install"]}],B=(t,e,n)=>S.filter(s=>s.surfaces.includes(t)?n!==void 0?n.has(s.name):s.isConfigured(e):!1),ie=async(t,e,n)=>{const s=B(e,n.visConfig,n.enabledPolicies),a=[];for(const r of s){if(t.offline&&!r.offlineSupported){a.push({packageName:"*",policy:r.name,reason:`policy.${r.name} skipped: requires network (--offline)`,severity:"info",version:"*"});continue}try{const c=await r.evaluate(t,n.visConfig);a.push(...c)}catch(c){const i=c instanceof Error?c.message:String(c);a.push({packageName:"*",policy:r.name,reason:`policy.${r.name} failed: ${i}`,severity:"info",version:"*"})}}return a},G=(()=>{const t=new Map;for(const e of b)t.set(e.toLowerCase(),e);return t})(),oe=()=>S.map(t=>t.name),re=(t,e)=>{if(t===void 0)return;const n=t.trim().toLowerCase();if(n===""||n==="none")return new Set;if(n==="all")return new Set(b);const s=new Set;for(const a of t.split(",").map(r=>r.trim()).filter(r=>r.length>0)){const r=a.replace(/^_+/,"").replaceAll(/_+([a-z])/g,(i,o)=>o.toUpperCase()),c=G.get(r.toLowerCase());c===void 0?e?.(a):s.add(c)}return s};export{se as c,ie as e,oe as g,re as p,P as s};
|