@visulima/vis 1.0.0-alpha.13 → 1.0.0-alpha.14
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 +28 -0
- package/LICENSE.md +7242 -385
- package/dist/bin.js +1 -1
- package/dist/config/index.d.ts +493 -1
- package/dist/config/index.js +1 -1
- package/dist/packem_chunks/applyDefaults.js +2 -2
- package/dist/packem_chunks/bin.js +1134 -199
- package/dist/packem_chunks/doctor-probe.js +2 -2
- package/dist/packem_chunks/fix.js +11 -11
- 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 +5 -5
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +20 -18
- package/dist/packem_chunks/handler15.js +1 -20
- 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 +5 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -5
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler22.js +5 -1
- package/dist/packem_chunks/handler23.js +1 -5
- package/dist/packem_chunks/handler24.js +3 -1
- package/dist/packem_chunks/handler25.js +1 -3
- package/dist/packem_chunks/handler26.js +1 -1
- package/dist/packem_chunks/handler27.js +7 -1
- package/dist/packem_chunks/handler28.js +22 -6
- package/dist/packem_chunks/handler29.js +3 -23
- package/dist/packem_chunks/handler3.js +4 -4
- package/dist/packem_chunks/handler30.js +18 -3
- package/dist/packem_chunks/handler31.js +1 -1
- package/dist/packem_chunks/handler32.js +2 -2
- package/dist/packem_chunks/handler33.js +24 -24
- package/dist/packem_chunks/handler34.js +2 -2
- package/dist/packem_chunks/handler35.js +2 -2
- package/dist/packem_chunks/handler36.js +20 -20
- package/dist/packem_chunks/handler37.js +2 -2
- package/dist/packem_chunks/handler38.js +6 -22
- package/dist/packem_chunks/handler39.js +11 -11
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler40.js +5 -22
- package/dist/packem_chunks/handler41.js +24 -6
- package/dist/packem_chunks/handler42.js +10 -5
- package/dist/packem_chunks/handler43.js +153 -10
- package/dist/packem_chunks/handler44.js +25 -153
- package/dist/packem_chunks/handler45.js +3 -25
- package/dist/packem_chunks/handler46.js +27 -3
- package/dist/packem_chunks/handler47.js +41 -26
- package/dist/packem_chunks/handler48.js +32 -40
- package/dist/packem_chunks/handler5.js +7 -7
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +4 -4
- package/dist/packem_chunks/heal.js +3 -3
- package/dist/packem_chunks/help-command.js +18 -0
- package/dist/packem_chunks/index.js +4 -4
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/tar.js +1 -1
- package/dist/packem_shared/ai-analysis-Dzs_nUwM.js +68 -0
- package/dist/packem_shared/ai-cache-Dtvmbsru.js +1 -0
- package/dist/packem_shared/{ai-fix-nn4zOE95.js → ai-fix-BmLM72GS.js} +4 -4
- package/dist/packem_shared/cache-directory-xASJia6M.js +1 -0
- package/dist/packem_shared/dependency-scan-DmwPKwLy.js +2 -0
- package/dist/packem_shared/docker-CA-scYu0.js +2 -0
- package/dist/packem_shared/failure-log-fD4DiFb1.js +2 -0
- package/dist/packem_shared/flakiness-BIg1rwvp.js +1 -0
- package/dist/packem_shared/{giget-CcEy_Elm.js → giget-BX2ixMoa.js} +2 -2
- package/dist/packem_shared/index-OlP7U_t5.js +6 -0
- package/dist/packem_shared/lockfile-BXylopgH.js +1 -0
- package/dist/packem_shared/otelPlugin-y5hoCw4b.js +1 -0
- package/dist/packem_shared/registry-BHqKXiLb.js +2 -0
- package/dist/packem_shared/run-summary-utils-D39XBHWW.js +1 -0
- package/dist/packem_shared/runtime-check-BaKni2y1.js +1 -0
- package/dist/packem_shared/selectors-BvtUXWGY.js +3 -0
- package/dist/packem_shared/toolchain-B7sIiJxK.js +5 -0
- package/dist/packem_shared/typosquats-XkC1CnOa.js +1 -0
- package/dist/packem_shared/verify-BVTcVfoW.js +1 -0
- package/dist/packem_shared/{vis-update-app-D1jl0UZZ.js → vis-update-app-DR8c4OfG.js} +1 -1
- package/package.json +15 -30
- package/dist/packem_shared/ai-analysis-hm8d2W7z.js +0 -67
- package/dist/packem_shared/ai-cache-DoiF80AR.js +0 -1
- package/dist/packem_shared/cache-directory-CwHlJhgx.js +0 -1
- package/dist/packem_shared/dependency-scan-COr5n63B.js +0 -2
- package/dist/packem_shared/docker-D6OGr5_S.js +0 -2
- package/dist/packem_shared/failure-log-iUVLf6ts.js +0 -2
- package/dist/packem_shared/flakiness-D9wf0t56.js +0 -1
- package/dist/packem_shared/otel-DxDUPJJH.js +0 -6
- package/dist/packem_shared/otelPlugin-CQq6poq8.js +0 -1
- package/dist/packem_shared/registry-CkubDdiY.js +0 -2
- package/dist/packem_shared/run-summary-utils-BfBvjzhY.js +0 -1
- package/dist/packem_shared/runtime-check-BXZ43CBW.js +0 -1
- package/dist/packem_shared/selectors-BylODRiM.js +0 -3
- package/dist/packem_shared/toolchain-BgBOUHII.js +0 -5
- package/dist/packem_shared/typosquats-CcZl99B1.js +0 -1
- package/dist/packem_shared/verify-Baj5mFJ7.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var C=Object.defineProperty;var m=(t,e)=>C(t,"name",{value:e,configurable:!0});import{createRequire as _}from"node:module";import{X as S}from"./xxh3-DrAUNq4n.js";import{ensureDirSync as A,isAccessibleSync as d,readJsonSync as v}from"@visulima/fs";import{M as c}from"./index-OlP7U_t5.js";import{n as J}from"../packem_chunks/bin.js";const M=_(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=m(t=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[e,r]=u.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return u.getBuiltinModule(t)}return M(t)},"__cjs_getBuiltinModule"),{rmSync:f,writeFileSync:p,readdirSync:h,statSync:D}=b("node:fs");var w=Object.defineProperty,n=m((t,e)=>w(t,"name",{value:e,configurable:!0}),"r");const a=n(()=>c(J(),"ai"),"getCacheDirectory"),B=3600*1e3,N=1800*1e3,j=n(()=>{A(a())},"ensureCacheDirectory"),q=n((t,e,r)=>{const s=r.map(i=>({currentRange:i.currentRange,name:i.packageName,targetVersion:i.targetVersion})).toSorted((i,y)=>i.name.localeCompare(y.name)),o=JSON.stringify({analysisType:e,packages:s,provider:t});return S(Buffer.from(o))},"buildCacheKey"),z=n(t=>{const e=c(a(),`${t}.json`);if(d(e))try{const r=v(e);if(Date.now()-r.createdAt>r.ttlMs){f(e,{force:!0});return}return r.result}catch{f(e,{force:!0});return}},"getCachedAnalysis"),V=n((t,e,r)=>{j();const s=a(),o={createdAt:Date.now(),result:e,ttlMs:r};p(c(s,`${t}.json`),JSON.stringify(o,void 0,2),"utf8")},"setCachedAnalysis"),F=n((t,e)=>e!==void 0&&e>0?e:t==="security"?N:B,"getTtlForAnalysisType"),K=n(()=>{const t=a();if(!d(t))return{entries:0,newestEntry:void 0,oldestEntry:void 0,totalSizeBytes:0};const e=h(t).filter(i=>i.endsWith(".json"));let r=0,s,o;for(const i of e){const y=c(t,i),g=D(y);r+=g.size;const{mtimeMs:l}=g;(s===void 0||l<s)&&(s=l),(o===void 0||l>o)&&(o=l)}return{entries:e.length,newestEntry:o,oldestEntry:s,totalSizeBytes:r}},"getCacheStats"),P=n(t=>S(Buffer.from(JSON.stringify(t))),"buildHashCacheKey"),W=n(t=>{const e=c(a(),`${t}.json`);if(d(e))try{const r=v(e);if(Date.now()-r.createdAt>r.ttlMs){f(e,{force:!0});return}return r.result}catch{f(e,{force:!0});return}},"getCachedJson"),x=n((t,e,r)=>{j();const s=a(),o={createdAt:Date.now(),result:e,ttlMs:r};p(c(s,`${t}.json`),JSON.stringify(o,void 0,2),"utf8")},"setCachedJson"),H=n(()=>{const t=a();if(!d(t))return 0;const e=h(t).filter(r=>r.endsWith(".json"));for(const r of e)f(c(t,r),{force:!0});return e.length},"clearCache");export{H as B,K as J,P as M,W as N,x as O,V as R,z as T,F as j,q as k};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
${a}`},"truncateHead"),
|
|
1
|
+
var O=Object.defineProperty;var f=(e,t)=>O(e,"name",{value:t,configurable:!0});import{createRequire as F}from"node:module";import{readLastRunSummary as T}from"@visulima/task-runner";import{a as j}from"./failure-log-fD4DiFb1.js";import{r as k,f as y,a as D,d as _}from"./run-summary-utils-D39XBHWW.js";import{O as $,C as b,M as R,z as A}from"./index-OlP7U_t5.js";import{w as E,b as B,r as H}from"./ai-analysis-Dzs_nUwM.js";import{M as q,N as W,O as L}from"./ai-cache-Dtvmbsru.js";const C=F(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=f(e=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[t,a]=d.versions.node.split(".").map(Number);if(t>22||t===22&&a>=3||t===20&&a>=16)return d.getBuiltinModule(e)}return C(e)},"__cjs_getBuiltinModule"),{readFile:N,writeFile:M}=I("node:fs/promises");var Y=Object.defineProperty,m=f((e,t)=>Y(e,"name",{value:t,configurable:!0}),"u");const z=32*1024,J=m((e,t)=>{if(e.length<=t)return e;const a=e.slice(-t),o=e.length-a.length;return`[…${String(o)} bytes truncated from head…]
|
|
2
|
+
${a}`},"truncateHead"),K=m(async(e,t)=>t===void 0?T(e):k(e,t),"loadSummary"),ge=m(async(e,t,a={})=>{const o=a.terminalOutputLimit??z,[r,n]=await Promise.all([j(e,t),K(e,a.runId)]),i=n?y(n,t):void 0;if(!r&&!i)return;let s,c;if(n&&i){const l=await D(e,n.id),g=l?y(l,t):void 0;s=_(i.hashDetails,g?.hashDetails),c=l?.id}const h=r?.terminalOutput??"";return{command:r?.command??void 0,cwd:r?.cwd??void 0,dependencies:i?.dependencies??[],duration:i?.duration,exitCode:r?.exitCode??i?.exitCode,hash:i?.hash??r?.hash,hashDetails:i?.hashDetails,hashDiff:s,previousRunId:c,project:i?.target.project,runId:n?.id??r?.runId,status:r?.status??(i?U(i):void 0),target:i?.target.target,taskId:t,terminalOutput:J(h,o),terminalOutputCaptured:!!r,timestamp:r?.timestamp??i?.endTime??i?.startTime}},"aggregateFailureContext"),U=m(e=>{if(e.exitCode!==void 0&&e.exitCode!==0)return"failure";switch(e.cacheStatus){case"HIT":return"local-cache";case"REMOTE_HIT":return"remote-cache";case"SKIPPED":return"skipped";default:return e.exitCode===0?"success":void 0}},"mapCacheStatusToTaskStatus");var G=Object.defineProperty,u=f((e,t)=>G(e,"name",{value:t,configurable:!0}),"a");const Q=3600*1e3,S=80,V=new Set(["high","low","medium"]),X=u(()=>`You are an expert software engineer helping fix a failing build/test/lint task.
|
|
3
3
|
|
|
4
4
|
You will be given:
|
|
5
5
|
- The terminal output (stdout/stderr) from the failed task.
|
|
@@ -36,8 +36,8 @@ ${a.join(`
|
|
|
36
36
|
`)},"buildHashDiffSummary"),ee=u(e=>{const t=[`Task: ${e.taskId}`];return e.project&&t.push(`Project: ${e.project}`),e.target&&t.push(`Target: ${e.target}`),e.command&&t.push(`Command: ${e.command}`),e.cwd&&t.push(`CWD: ${e.cwd}`),e.exitCode!==void 0&&t.push(`Exit code: ${String(e.exitCode)}`),e.hash&&t.push(`Task hash: ${e.hash}`),t.push("","Hash-diff since previous run:",Z(e),""),e.terminalOutputCaptured?t.push("Terminal output:","```",e.terminalOutput,"```"):t.push("Terminal output: <no failure log was captured for this task>",'Set "cannotFix" and tell the user to re-run with `vis run` so logs can be captured.'),t.join(`
|
|
37
37
|
`)},"buildUserPrompt"),te=u(e=>`${X()}
|
|
38
38
|
|
|
39
|
-
${ee(e)}`,"buildFixPrompt"),ae=u((e,t)=>{const a=Array.isArray(e.patches)?e.patches:[],o=[];for(const n of a)typeof n.file!="string"||n.file.length===0||typeof n.oldString!="string"||n.oldString.length===0||typeof n.newString=="string"&&o.push({file:n.file,newString:n.newString,oldString:n.oldString,reason:typeof n.reason=="string"&&n.reason.length>0?n.reason:void 0});const r=typeof e.cannotFix=="string"&&e.cannotFix.length>0?e.cannotFix:void 0;return{cannotFix:r,confidence:V.has(e.confidence)?e.confidence:"low",explanation:typeof e.explanation=="string"?e.explanation:"",patches:r?[]:o,provider:t}},"normalizeFixProposal"),ie=u((e,t)=>{const a=
|
|
39
|
+
${ee(e)}`,"buildFixPrompt"),ae=u((e,t)=>{const a=Array.isArray(e.patches)?e.patches:[],o=[];for(const n of a)typeof n.file!="string"||n.file.length===0||typeof n.oldString!="string"||n.oldString.length===0||typeof n.newString=="string"&&o.push({file:n.file,newString:n.newString,oldString:n.oldString,reason:typeof n.reason=="string"&&n.reason.length>0?n.reason:void 0});const r=typeof e.cannotFix=="string"&&e.cannotFix.length>0?e.cannotFix:void 0;return{cannotFix:r,confidence:V.has(e.confidence)?e.confidence:"low",explanation:typeof e.explanation=="string"?e.explanation:"",patches:r?[]:o,provider:t}},"normalizeFixProposal"),ie=u((e,t)=>{const a=E(e);return!a||typeof a!="object"?{cannotFix:"AI response was not valid JSON.",confidence:"low",explanation:"Failed to parse AI response.",patches:[],provider:t}:ae(a,t)},"parseFixResponse"),ne=u((e,t)=>q({cwd:t.cwd??null,flow:"ai-fix",hash:t.hash??null,provider:e,taskId:t.taskId,terminalOutput:t.terminalOutput,terminalOutputCaptured:t.terminalOutputCaptured}),"buildFixCacheKey"),ve=u(async(e,t,a={})=>{const o=B(a.config);if(!o){t.warn(`No AI provider available — install one of: claude, gemini, copilot, codex.
|
|
40
40
|
`);return}const r=a.cache!==!1,n=ne(o.name,e);if(r){const i=W(n);if(i)return t.info(`Using cached fix proposal from ${i.provider}.
|
|
41
41
|
`),i}t.info(`Generating fix proposal with ${o.name}...
|
|
42
42
|
`);try{const i=await H(o,te(e)),s=ie(i,o.name);return r&&s.patches.length>0&&!s.cannotFix&&L(n,s,Q),s}catch(i){const s=i instanceof Error?i.message:String(i);t.warn(`AI fix proposal failed (${s}).
|
|
43
|
-
`);return}},"runFixAnalysis"),re=u((e,t,a)
|
|
43
|
+
`);return}},"runFixAnalysis"),re=u((e,t,a)=>$(a)?b(a):b(R(t??e,a)),"resolvePatchPath"),se=u((e,t)=>{const a=A(e,t);return a===""?!0:!a.startsWith("..")&&!$(a)},"isInsideWorkspace"),oe=u((e,t,a)=>{const o=e.indexOf(t),r=Math.max(0,o-S),n=Math.min(e.length,o+t.length+S),i=e.slice(r,n);return{previewAfter:`${e.slice(r,o)}${a}${e.slice(o+t.length,n)}`,previewBefore:i}},"buildPreview"),xe=u(async(e,t,a,o={})=>{const r=o.dryRun===!0,n=new Map,i=[];for(const s of a.patches){const c=re(e,t,s.file);if(!se(e,c)){i.push({absolutePath:c,patch:s,status:"outside-workspace"});continue}let h=n.get(c);if(h===void 0){try{h=await N(c,"utf8")}catch(p){const w=p.code;i.push({absolutePath:c,error:w==="ENOENT"?void 0:p.message,patch:s,status:w==="ENOENT"?"missing-file":"error"});continue}n.set(c,h)}const l=h.indexOf(s.oldString);if(l===-1){i.push({absolutePath:c,patch:s,status:"no-match"});continue}if(h.indexOf(s.oldString,l+s.oldString.length)!==-1){i.push({absolutePath:c,patch:s,status:"ambiguous-match"});continue}const{previewAfter:g,previewBefore:P}=oe(h,s.oldString,s.newString),x=`${h.slice(0,l)}${s.newString}${h.slice(l+s.oldString.length)}`;if(!r)try{await M(c,x,"utf8")}catch(p){n.delete(c),i.push({absolutePath:c,error:p.message,patch:s,status:"error"});continue}n.set(c,x),i.push({absolutePath:c,patch:s,previewAfter:g,previewBefore:P,status:"applied"})}return i},"applyFixProposal");export{ge as a,ve as b,xe as c,re as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=Object.defineProperty;var l=(e,r)=>h(e,"name",{value:r,configurable:!0});import{createRequire as d}from"node:module";import{O as p,C as a,z as m}from"./index-OlP7U_t5.js";import{DEFAULT_CACHE_DIRECTORY_NAME as u,getMainWorktreeRoot as v}from"@visulima/task-runner";const f=d(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=l(e=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[r,t]=i.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return i.getBuiltinModule(e)}return f(e)},"__cjs_getBuiltinModule"),{execFileSync:_}=g("node:child_process");var C=Object.defineProperty,s=l((e,r)=>C(e,"name",{value:r,configurable:!0}),"s");const y=s((e,r,t)=>{const n=s(c=>p(c)?c:a(e,c),"normalize");if(r&&r.length>0)return n(r);if(t&&t.length>0)return n(t);const o=process.env.VIS_CACHE_DIRECTORY;return o&&o.length>0?n(o):a(e,u)},"resolveCacheDirectory"),E=s((e,r)=>r===!1?e:v(e)??e,"resolveSharedCacheRoot"),I=s((e,r,t,n)=>{const o=r??t??process.env.VIS_CACHE_DIRECTORY;if(o&&o.length>0)return y(e,r,t);const c=E(e,n);return a(c,u)},"resolveSharedCacheDirectory"),R=/[^\w.-]+/g,S=/^-+|-+$/g,b=s(e=>e.trim().replaceAll(R,"-").replaceAll(S,"").slice(0,64),"sanitizeBranchSegment"),A=s(e=>{try{const r=_("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return!r||r==="HEAD"?void 0:r}catch{return}},"detectGitBranch"),z=s((e,r,t)=>{if(t!==!0)return e;const n=A(r);if(!n)return e;const o=b(n);return o.length===0?e:a(e,"branches",o)},"applyBranchScope"),H=s((e,r)=>{const t=m(r,e);return t.length===0?!1:t!==".."&&!t.startsWith("../")&&!p(t)},"isCacheDirectoryInsideWorkspace");export{I as E,z as a,H as m};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var j=Object.defineProperty;var b=(t,e)=>j(t,"name",{value:e,configurable:!0});import{e as E,au as h,E as w,c as M,d as O,s as R}from"../packem_chunks/bin.js";import{Box as g,Text as d,Spinner as A,render as I}from"@visulima/tui";import k from"react";import{jsx as i,jsxs as v}from"react/jsx-runtime";import{D as S,W as Y,T as B,C as F}from"./symbols-CQmER5MT.js";import{readFileSync as $}from"@visulima/fs";import{F as D}from"./lockfile-BXylopgH.js";import{M as P}from"./index-OlP7U_t5.js";var G=Object.defineProperty,N=b((t,e)=>G(t,"name",{value:e,configurable:!0}),"l$1");const T=N(({rows:t})=>i(g,{flexDirection:"column",children:t.map(e=>{let r;switch(e.status){case"error":{r=i(d,{color:"red",children:F});break}case"ok":{r=i(d,{color:"green",children:B});break}case"running":{r=i(d,{color:"white",children:i(A,{type:"dots"})});break}case"warn":{r=i(d,{color:"yellow",children:Y});break}default:{r=i(d,{dimColor:!0,children:S});break}}return v(g,{children:[i(g,{width:3,children:r}),i(g,{flexGrow:1,children:i(d,{children:e.label})}),e.summary?i(g,{children:v(d,{dimColor:!0,children:[S," ",e.summary]})}):null]},e.id)})}),"ScanProgressApp");var W=Object.defineProperty,l=b((t,e)=>W(t,"name",{value:e,configurable:!0}),"e");const z={error:O(h.failure),ok:M(h.success),pending:w(h.dash),skip:w(h.dash),warn:E(h.warning)},H=l((t,e,r)=>{const m=r?`${t} ${w(`— ${r}`)}`:t;return` ${z[e]} ${m}
|
|
2
|
+
`},"formatStaticRow"),ee=l((t,e={})=>{const r=e.stream??process.stderr,m=typeof r.isTTY=="boolean"&&r.isTTY&&!R,p=e.live??m,n=new Map;for(const a of t)n.set(a.id,{id:a.id,label:a.label,status:"pending"});if(!p||t.length===0)return{finish:l((a,c,y)=>{const f=n.get(a);f&&(n.set(a,{...f,status:c,summary:y}),r.write(H(f.label,c,y)))},"finish"),start:l(a=>{const c=n.get(a);c&&n.set(a,{...c,status:"running"})},"start"),stop:l(()=>{},"stop")};const u=l(()=>t.map(a=>n.get(a.id)),"buildRows");let s=I(k.createElement(T,{rows:u()}),{interactive:!0,patchConsole:!1});const o=l(()=>{s?.rerender(k.createElement(T,{rows:u()}))},"rerender");return{finish:l((a,c,y)=>{const f=n.get(a);f&&(n.set(a,{...f,status:c,summary:y}),o())},"finish"),start:l(a=>{const c=n.get(a);c&&(n.set(a,{...c,status:"running"}),o())},"start"),stop:l(()=>{s&&(o(),s.unmount(),s=void 0)},"stop")}},"startScanProgress");var K=Object.defineProperty,x=b((t,e)=>K(t,"name",{value:e,configurable:!0}),"l");const C={bun:{file:"bun.lock",type:"bun"},npm:{file:"package-lock.json",type:"npm"},pnpm:{file:"pnpm-lock.yaml",type:"pnpm"},yarn:{file:"yarn.lock",type:"yarn"}},re=x((t,e)=>{const r=C[e];if(!r)return[];let m;try{m=$(P(t,r.file))}catch{return[]}const p=D(m,r.type);if(p.length===0)return[];const n=new Set,u=[];for(const s of p){const o=`${s.name}@${s.version}`;n.has(o)||(n.add(o),u.push({isDev:!1,name:s.name,version:s.version}))}return u},"lockedPackages"),te=x((t,e)=>{const r=C[e];if(!r)return[];let m;try{m=$(P(t,r.file))}catch{return[]}const p=D(m,r.type);if(p.length===0)return[];const n=new Map;for(const s of p)n.has(s.name)||n.set(s.name,new Set),n.get(s.name).add(s.version);const u=[];for(const[s,o]of n)o.size<=1||u.push({name:s,versions:[...o]});return u.sort((s,o)=>s.name.localeCompare(o.name))},"findDuplicateDependencies");export{te as f,re as l,ee as s};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var E=Object.defineProperty;var k=(e,o)=>E(e,"name",{value:o,configurable:!0});import{createRequire as D}from"node:module";import{ensureDirSync as R,writeFileSync as C,isAccessibleSync as M,readJsonSync as O}from"@visulima/fs";import{K as _,M as c,z as A}from"./index-OlP7U_t5.js";const T=D(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=k(e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[o,r]=m.versions.node.split(".").map(Number);if(o>22||o===22&&r>=3||o===20&&r>=16)return m.getBuiltinModule(e)}return T(e)},"__cjs_getBuiltinModule"),{cpSync:S,lstatSync:F,readdirSync:N,rmSync:v}=x("node:fs");var P=Object.defineProperty,l=k((e,o)=>P(e,"name",{value:o,configurable:!0}),"p");const $=l((e,o)=>{const r=new Set,s=[e],a=new Set([e]);for(;s.length>0;){const n=s.shift(),f=o.dependencies[n]??[];for(const i of f)a.has(i.target)||(a.add(i.target),r.add(i.target),s.push(i.target))}return r},"collectTransitiveProjectDeps"),g="vis-docker-manifest.json",I=["package.json","project.json"],q=["package.json","pnpm-workspace.yaml","pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock","bun.lockb",".npmrc","vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],L=l((e,o)=>{const r=new Set(e);for(const s of e){const a=$(s,o);for(const n of a)r.add(n)}return r},"resolveFocusProjects"),y=l(e=>{R(e)},"ensureDir"),h=l((e,o)=>{try{return y(_(o)),S(e,o),!0}catch(r){if(r.code==="ENOENT")return!1;throw r}},"copyFileIfExists"),b=l((e,o)=>{let r;try{r=F(e)}catch{return}if(!r.isSymbolicLink()){if(r.isFile()){y(_(o)),S(e,o);return}y(o);for(const s of N(e,{withFileTypes:!0}))s.name==="node_modules"||s.name===".git"||s.isSymbolicLink()||b(c(e,s.name),c(o,s.name))}},"copyTreeExcludingNodeModules"),G=l(e=>{const{focus:o,includeSources:r=!1,outDir:s,projectGraph:a,workspace:n,workspaceRoot:f}=e,i=o.filter(t=>n.projects[t]===void 0);if(i.length>0)throw new Error(`Unknown focus project(s): ${i.join(", ")}. Check project names in your workspace.`);const j=L(o,a),u=c(s,"workspace"),d=c(s,"sources");v(u,{force:!0,recursive:!0}),v(d,{force:!0,recursive:!0}),y(u);for(const t of q)h(c(f,t),c(u,t));for(const t of j){const p=n.projects[t];if(p?.root)for(const w of I)h(c(f,p.root,w),c(u,p.root,w))}if(r){y(d);for(const t of o){const p=n.projects[t];p?.root&&b(c(f,p.root),c(d,p.root))}}return C(c(s,g),`${JSON.stringify({focus:o,projects:[...j].sort()},null,2)}
|
|
2
|
+
`),{projects:[...j]}},"scaffoldDockerContext"),U=l(e=>{const{contextRoot:o,workspace:r,workspaceRoot:s}=e,a=c(o,g);if(!M(a))throw new Error(`No ${g} at ${o}. Run \`vis docker scaffold\` first.`);const n=O(a);if(!Array.isArray(n.projects))throw new TypeError(`Invalid ${g}: "projects" must be an array.`);const f=new Set(n.projects),i=[];for(const[j,u]of Object.entries(r.projects)){if(f.has(j)||!u.root)continue;const d=c(s,u.root),t=A(s,d);t===""||t==="."||t.startsWith("..")||(v(d,{force:!0,recursive:!0}),i.push(t))}return{removed:i}},"pruneDockerContext");export{U as p,L as r,G as s};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var h=Object.defineProperty;var a=(t,e)=>h(t,"name",{value:e,configurable:!0});import{createRequire as m}from"node:module";import{M as l}from"./index-OlP7U_t5.js";const y=m(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=a(t=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[e,r]=s.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return s.getBuiltinModule(t)}return y(t)},"__cjs_getBuiltinModule"),{mkdirSync:F,writeFileSync:L,readdirSync:_}=u("node:fs"),{readFile:v}=u("node:fs/promises");var j=Object.defineProperty,i=a((t,e)=>j(t,"name",{value:e,configurable:!0}),"i");const S="last-failures",c=i(t=>l(t,".task-runner",S),"getFailureLogDirectory"),d=i((t,e)=>l(c(t),`${encodeURIComponent(e)}.json`),"getFailureLogPath");class I{static{a(this,"FailureLogLifeCycle")}static{i(this,"FailureLogLifeCycle")}#e;#t;constructor(e,r){this.#e=e,this.#t=r}printTaskTerminalOutput(e,r,o){if(r!=="failure")return;const n=c(this.#e);try{F(n,{recursive:!0})}catch{return}const f=e.overrides.command,g=e.projectRoot,p={command:f,cwd:g,exitCode:void 0,hash:e.hash,runId:this.#t,status:r,taskId:e.id,terminalOutput:o,timestamp:new Date().toISOString()};try{L(d(this.#e,e.id),`${JSON.stringify(p,void 0,2)}
|
|
2
|
+
`,"utf8")}catch{}}}const R=i(async(t,e)=>{const r=d(t,e);try{const o=await v(r,"utf8");return JSON.parse(o)}catch{return}},"loadFailureLog"),T=i(t=>{const e=c(t);let r;try{r=_(e)}catch{return[]}const o=[];for(const n of r)if(n.endsWith(".json"))try{o.push(decodeURIComponent(n.slice(0,-5)))}catch{}return o},"listFailureLogs");export{I as F,R as a,T as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var k=Object.defineProperty;var f=(a,s)=>k(a,"name",{value:s,configurable:!0});import{createRequire as b}from"node:module";import{isAccessibleSync as S,readJsonSync as T}from"@visulima/fs";import{M as p}from"./index-OlP7U_t5.js";const R=b(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=f(a=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[s,n]=l.versions.node.split(".").map(Number);if(s>22||s===22&&n>=3||s===20&&n>=16)return l.getBuiltinModule(a)}return R(a)},"__cjs_getBuiltinModule"),{readdirSync:j}=y("node:fs");var v=Object.defineProperty,d=f((a,s)=>v(a,"name",{value:s,configurable:!0}),"i");const $=d((a,s)=>{let n=0,o=0,r=0;for(const[,t]of a)switch(t.status){case"failure":{r+=1;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{o+=1;break}case"success":{n+=1;break}}const i=[];n>0&&i.push(`${String(n)} succeeded`),o>0&&i.push(`${String(o)} cached`),r>0&&i.push(`${String(r)} failed`);const c=(s/1e3).toFixed(1);return i.push(`${c}s`),i.join(" · ")},"formatTimingSummary"),g=d(a=>{const s=p(a,".task-runner","runs");if(!S(s))return[];const n=j(s).filter(r=>r.endsWith(".json")),o=[];for(const r of n)try{o.push(T(p(s,r)))}catch{}return o},"loadRunSummaries"),P=d((a,s,n)=>{const o=n??g(a);if(o.length<2)return;let r=0,i=0;for(const e of o)typeof e.duration=="number"&&e.duration>0&&(r+=e.duration,i+=1);if(i<2)return;const c=r/i-s,t=Math.abs(c/1e3).toFixed(1);return Math.abs(c)<500?"(about average)":c>0?`(${t}s faster than avg)`:`(${t}s slower than avg)`},"compareDuration");var F=Object.defineProperty,m=f((a,s)=>F(a,"name",{value:s,configurable:!0}),"l");const E=m((a,s={},n)=>{const o=n??g(a);if(o.length===0)return[];const r=new Map;for(const t of o)if(!(s.since&&(t.startTime===void 0||t.startTime<s.since))&&Array.isArray(t.tasks))for(const e of t.tasks){if(e.cacheStatus==="HIT"||e.cacheStatus==="REMOTE_HIT"||e.cacheStatus==="SKIPPED")continue;const u=r.get(e.taskId)??{failures:0,project:e.target.project,successes:0,target:e.target.target,totalRuns:0};u.totalRuns+=1,e.exitCode!==void 0&&e.exitCode!==0?(u.failures+=1,u.lastFailure=e.startTime??t.startTime):u.successes+=1,r.set(e.taskId,u)}const i=s.minRuns??2,c=[];for(const[t,e]of r)e.totalRuns<i||e.failures!==0&&c.push({failures:e.failures,flakinessRate:e.failures/e.totalRuns,lastFailure:e.lastFailure,project:e.project,successes:e.successes,target:e.target,taskId:t,totalRuns:e.totalRuns});return c.sort((t,e)=>e.flakinessRate-t.flakinessRate),c},"analyzeFlakiness"),q=m(a=>{if(a.length===0)return["No flaky tasks detected."];const s=["Task","Runs","Failures","Rate","Last Failure"],n=a.map(t=>[t.taskId,String(t.totalRuns),String(t.failures),`${(t.flakinessRate*100).toFixed(1)}%`,t.lastFailure??"—"]),o=s.map((t,e)=>{let u=0;for(const h of n)u=Math.max(u,(h[e]??"").length);return Math.max(t.length,u)}),r=m((t,e)=>t.padEnd(e),"pad"),i=o.map(t=>"─".repeat(t)).join("──"),c=[s.map((t,e)=>r(t,o[e])).join(" "),i];for(const t of n)c.push(t.map((e,u)=>r(e,o[u])).join(" "));return c},"formatFlakinessTable");export{E as a,q as b,P as c,$ as f,g as l};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var De=Object.defineProperty;var f=(r,e)=>De(r,"name",{value:e,configurable:!0});import{createRequire as Fe}from"node:module";const Ne=Fe(import.meta.url),z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=f(r=>{if(typeof z<"u"&&z.versions&&z.versions.node){const[e,t]=z.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return z.getBuiltinModule(r)}return Ne(r)},"__cjs_getBuiltinModule"),{createRequire:Me}=k("node:module"),{existsSync:x,createWriteStream:se,readdirSync:Ge,renameSync:He}=k("node:fs"),{readFile:ie,mkdir:H,rm:M,writeFile:Be,mkdtemp:Le}=k("node:fs/promises"),{PassThrough:ae,Readable:q,pipeline:Re}=k("node:stream"),{spawn:ce,spawnSync:Ue}=k("node:child_process"),{delimiter:J,resolve:We,dirname:Xe,normalize:qe,join:Y}=k("node:path"),{cwd:Je}=z,Ye=k("node:readline"),{pipeline:Ze}=k("node:stream/promises"),{homedir:Ve,tmpdir:le}=k("node:os"),{promisify:Ke}=k("node:util");var Qe=Object.defineProperty,et=f((r,e)=>Qe(r,"name",{value:e,configurable:!0}),"a$1"),Z=Object.defineProperty,tt=et((r,e)=>{let t={};for(var n in r)Z(t,n,{get:r[n],enumerable:!0});return e||Z(t,Symbol.toStringTag,{value:"Module"}),t},"__exportAll"),rt=Object.defineProperty,p=f((r,e)=>rt(r,"name",{value:e,configurable:!0}),"a");const nt=/^[A-Za-z]:\//;function F(r=""){return r&&r.replace(/\\/g,"/").replace(nt,e=>e.toUpperCase())}f(F,"P");p(F,"p");const ot=/^[/\\]{2}/,st=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,ue=/^[A-Za-z]:$/,V=/^\/([A-Za-z]:)?$/,pe=p(function(r){if(r.length===0)return".";r=F(r);let e=r.match(ot),t=D(r),n=r[r.length-1]==="/";return r=R(r,!t),r.length===0?t?"/":n?"./":".":(n&&(r+="/"),ue.test(r)&&(r+="/"),e?t?`//${r}`:`//./${r}`:t&&!D(r)?`/${r}`:r)},"g"),K=p(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 pe(e)},"_");function de(){return typeof process.cwd=="function"?process.cwd().replace(/\\/g,"/"):"/"}f(de,"st");p(de,"v");const $=p(function(...r){r=r.map(n=>F(n));let e="",t=!1;for(let n=r.length-1;n>=-1&&!t;n--){let o=n>=0?r[n]:de();!o||o.length===0||(e=`${o}/${e}`,t=D(o))}return e=R(e,!t),t&&!D(e)?`/${e}`:e.length>0?e:"."},"y");function R(r,e){let t="",n=0,o=-1,i=0,c=null;for(let s=0;s<=r.length;++s){if(s<r.length)c=r[s];else{if(c==="/")break;c="/"}if(c==="/"){if(!(o===s-1||i===1))if(i===2){if(t.length<2||n!==2||t[t.length-1]!=="."||t[t.length-2]!=="."){if(t.length>2){let a=t.lastIndexOf("/");a===-1?(t="",n=0):(t=t.slice(0,a),n=t.length-1-t.lastIndexOf("/")),o=s,i=0;continue}else if(t.length>0){t="",n=0,o=s,i=0;continue}}e&&(t+=t.length>0?"/..":"..",n=2)}else t.length>0?t+=`/${r.slice(o+1,s)}`:t=r.slice(o+1,s),n=s-o-1;o=s,i=0}else c==="."&&i!==-1?++i:i=-1}return t}f(R,"W");p(R,"b");const D=p(function(r){return st.test(r)},"x"),he=p(function(r,e){let t=$(r).replace(V,"$1").split("/"),n=$(e).replace(V,"$1").split("/");if(n[0][1]===":"&&t[0][1]===":"&&t[0]!==n[0])return n.join("/");let o=[...t];for(let i of o){if(n[0]!==i)break;t.shift(),n.shift()}return[...t.map(()=>".."),...n].join("/")},"S"),fe=p(function(r){let e=F(r).replace(/\/$/,"").split("/").slice(0,-1);return e.length===1&&ue.test(e[0])&&(e[0]+="/"),e.join("/")||(D(r)?"/":".")},"C"),me=p(function(r,e){let t=F(r).split("/"),n="";for(let o=t.length-1;o>=0;o--){let i=t[o];if(i){n=i;break}}return e&&n.endsWith(e)?n.slice(0,-e.length):n},"ne");var _=p((r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),"w"),O=Me(import.meta.url);const it=/^path$/i,Q={key:"PATH",value:""};function ge(r){for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e)||!it.test(e))continue;let t=r[e];return t?{key:e,value:t}:Q}return Q}f(ge,"pt");p(ge,"D");function we(r,e){let t=e.value.split(J),n=[],o=r,i;do n.push(We(o,"node_modules",".bin")),i=o,o=Xe(o);while(o!==i);let c=n.concat(t).join(J);return{key:e.key,value:c}}f(we,"ut");p(we,"O");function ve(r,e){let t={...process.env,...e},n=we(r,ge(t));return t[n.key]=n.value,t}f(ve,"ft");p(ve,"k");const at=p(r=>{let e=r.length,t=new ae,n=p(()=>{--e===0&&t.emit("end")},"r");for(let o of r)o.pipe(t,{end:!1}),o.on("end",n);return t},"A");var ct=_(((r,e)=>{e.exports=i,i.sync=c;var t=O("fs");function n(s,a){var l=a.pathExt===void 0?process.env.PATHEXT:a.pathExt;if(!l||(l=l.split(";"),l.indexOf("")!==-1))return!0;for(var u=0;u<l.length;u++){var h=l[u].toLowerCase();if(h&&s.substr(-h.length).toLowerCase()===h)return!0}return!1}f(n,"n"),p(n,"r");function o(s,a,l){return!s.isSymbolicLink()&&!s.isFile()?!1:n(a,l)}f(o,"s"),p(o,"i");function i(s,a,l){t.stat(s,function(u,h){l(u,u?!1:o(h,s,a))})}f(i,"i"),p(i,"a");function c(s,a){return o(t.statSync(s),s,a)}f(c,"c"),p(c,"o")})),lt=_(((r,e)=>{e.exports=n,n.sync=o;var t=O("fs");function n(s,a,l){t.stat(s,function(u,h){l(u,u?!1:i(h,a))})}f(n,"n"),p(n,"r");function o(s,a){return i(t.statSync(s),a)}f(o,"s"),p(o,"i");function i(s,a){return s.isFile()&&c(s,a)}f(i,"i"),p(i,"a");function c(s,a){var l=s.mode,u=s.uid,h=s.gid,d=a.uid===void 0?process.getuid&&process.getuid():a.uid,m=a.gid===void 0?process.getgid&&process.getgid():a.gid,g=64,v=8,E=1,S=g|v;return l&E||l&v&&h===m||l&g&&u===d||l&S&&d===0}f(c,"c"),p(c,"o")})),ut=_(((r,e)=>{O("fs");var t=process.platform==="win32"||global.TESTING_WINDOWS?ct():lt();e.exports=n,n.sync=o;function n(i,c,s){if(typeof c=="function"&&(s=c,c={}),!s){if(typeof Promise!="function")throw TypeError("callback not provided");return new Promise(function(a,l){n(i,c||{},function(u,h){u?l(u):a(h)})})}t(i,c||{},function(a,l){a&&(a.code==="EACCES"||c&&c.ignoreErrors)&&(a=null,l=!1),s(a,l)})}f(n,"n"),p(n,"r");function o(i,c){try{return t.sync(i,c||{})}catch(s){if(c&&c.ignoreErrors||s.code==="EACCES")return!1;throw s}}f(o,"s"),p(o,"i")})),pt=_(((r,e)=>{let t=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",n=O("path"),o=t?";":":",i=ut(),c=p(l=>Object.assign(Error(`not found: ${l}`),{code:"ENOENT"}),"o"),s=p((l,u)=>{let h=u.colon||o,d=l.match(/\//)||t&&l.match(/\\/)?[""]:[...t?[process.cwd()]:[],...(u.path||process.env.PATH||"").split(h)],m=t?u.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",g=t?m.split(h):[""];return t&&l.indexOf(".")!==-1&&g[0]!==""&&g.unshift(""),{pathEnv:d,pathExt:g,pathExtExe:m}},"s"),a=p((l,u,h)=>{typeof u=="function"&&(h=u,u={}),u||={};let{pathEnv:d,pathExt:m,pathExtExe:g}=s(l,u),v=[],E=p(b=>new Promise((A,T)=>{if(b===d.length)return u.all&&v.length?A(v):T(c(l));let y=d[b],G=/^".*"$/.test(y)?y.slice(1,-1):y,P=n.join(G,l);A(S(!G&&/^\.[\\\/]/.test(l)?l.slice(0,2)+P:P,b,0))}),"d"),S=p((b,A,T)=>new Promise((y,G)=>{if(T===m.length)return y(E(A+1));let P=m[T];i(b+P,{pathExt:g},(ze,Ie)=>{if(!ze&&Ie)if(u.all)v.push(b+P);else return y(b+P);return y(S(b,A,T+1))})}),"f");return h?E(0).then(b=>h(null,b),h):E(0)},"c");e.exports=a,a.sync=(l,u)=>{u||={};let{pathEnv:h,pathExt:d,pathExtExe:m}=s(l,u),g=[];for(let v=0;v<h.length;v++){let E=h[v],S=/^".*"$/.test(E)?E.slice(1,-1):E,b=n.join(S,l),A=!S&&/^\.[\\\/]/.test(l)?l.slice(0,2)+b:b;for(let T=0;T<d.length;T++){let y=A+d[T];try{if(i.sync(y,{pathExt:m}))if(u.all)g.push(y);else return y}catch{}}}if(u.all&&g.length)return g;if(u.nothrow)return null;throw c(l)}})),dt=_(((r,e)=>{let t=p((n={})=>{let o=n.env||process.env;return(n.platform||process.platform)==="win32"?Object.keys(o).reverse().find(i=>i.toUpperCase()==="PATH")||"Path":"PATH"},"n");e.exports=t,e.exports.default=t})),ht=_(((r,e)=>{let t=O("path"),n=pt(),o=dt();function i(s,a){let l=s.options.env||process.env,u=process.cwd(),h=s.options.cwd!=null,d=h&&process.chdir!==void 0&&!process.chdir.disabled;if(d)try{process.chdir(s.options.cwd)}catch{}let m;try{m=n.sync(s.command,{path:l[o({env:l})],pathExt:a?t.delimiter:void 0})}catch{}finally{d&&process.chdir(u)}return m&&=t.resolve(h?s.options.cwd:"",m),m}f(i,"i"),p(i,"a");function c(s){return i(s)||i(s,!0)}f(c,"c"),p(c,"o"),e.exports=c})),ft=_(((r,e)=>{let t=/([()\][%!^"`<>&|;, *?])/g;function n(i){return i=i.replace(t,"^$1"),i}f(n,"n"),p(n,"r");function o(i,c){return i=`${i}`,i=i.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),i=i.replace(/(?=(\\+?)?)\1$/,"$1$1"),i=`"${i}"`,i=i.replace(t,"^$1"),c&&(i=i.replace(t,"^$1")),i}f(o,"s"),p(o,"i"),e.exports.command=n,e.exports.argument=o})),mt=_(((r,e)=>{e.exports=/^#!(.*)/})),gt=_(((r,e)=>{let t=mt();e.exports=(n="")=>{let o=n.match(t);if(!o)return null;let[i,c]=o[0].replace(/#! ?/,"").split(" "),s=i.split("/").pop();return s==="env"?c:c?`${s} ${c}`:s}})),wt=_(((r,e)=>{let t=O("fs"),n=gt();function o(i){let c=Buffer.alloc(150),s;try{s=t.openSync(i,"r"),t.readSync(s,c,0,150,0),t.closeSync(s)}catch{}return n(c.toString())}f(o,"s"),p(o,"i"),e.exports=o})),vt=_(((r,e)=>{let t=O("path"),n=ht(),o=ft(),i=wt(),c=process.platform==="win32",s=/\.(?:com|exe)$/i,a=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(d){d.file=n(d);let m=d.file&&i(d.file);return m?(d.args.unshift(d.file),d.command=m,n(d)):d.file}f(l,"p"),p(l,"l");function u(d){if(!c)return d;let m=l(d),g=!s.test(m);if(d.options.forceShell||g){let v=a.test(m);d.command=t.normalize(d.command),d.command=o.command(d.command),d.args=d.args.map(E=>o.argument(E,v)),d.args=["/d","/s","/c",`"${[d.command].concat(d.args).join(" ")}"`],d.command=process.env.comspec||"cmd.exe",d.options.windowsVerbatimArguments=!0}return d}f(u,"u"),p(u,"u");function h(d,m,g){m&&!Array.isArray(m)&&(g=m,m=null),m=m?m.slice(0):[],g=Object.assign({},g);let v={command:d,args:m,options:g,file:void 0,original:{command:d,args:m}};return g.shell?v:u(v)}f(h,"d"),p(h,"d"),e.exports=h})),$t=_(((r,e)=>{let t=process.platform==="win32";function n(s,a){return Object.assign(Error(`${a} ${s.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${a} ${s.command}`,path:s.command,spawnargs:s.args})}f(n,"n"),p(n,"r");function o(s,a){if(!t)return;let l=s.emit;s.emit=function(u,h){if(u==="exit"){let d=i(h,a);if(d)return l.call(s,"error",d)}return l.apply(s,arguments)}}f(o,"s"),p(o,"i");function i(s,a){return t&&s===1&&!a.file?n(a.original,"spawn"):null}f(i,"i"),p(i,"a");function c(s,a){return t&&s===1&&!a.file?n(a.original,"spawnSync"):null}f(c,"c"),p(c,"o"),e.exports={hookChildProcess:o,verifyENOENT:i,verifyENOENTSync:c,notFoundError:n}})),bt=_(((r,e)=>{let t=O("child_process"),n=vt(),o=$t();function i(s,a,l){let u=n(s,a,l),h=t.spawn(u.command,u.args,u.options);return o.hookChildProcess(h,u),h}f(i,"i"),p(i,"a");function c(s,a,l){let u=n(s,a,l),h=t.spawnSync(u.command,u.args,u.options);return h.error=h.error||o.verifyENOENTSync(h.status,u),h}f(c,"c"),p(c,"o"),e.exports=i,e.exports.spawn=i,e.exports.sync=c,e.exports._parse=n,e.exports._enoent=o}))(),ee=class extends Error{static{f(this,"L")}static{p(this,"U")}result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(r,e){super(`Process exited with non-zero status (${r.exitCode})`),this.result=r,this.output=e}};const _t={timeout:void 0,persist:!1},Et={windowsHide:!0};function $e(r,e){return{command:qe(r),args:e??[]}}f($e,"Pt");p($e,"K");function be(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}f(be,"Tt");p(be,"q");async function B(r){let e="";for await(let t of r)e+=t.toString();return e}f(B,"H");p(B,"J");var yt=class{static{f(this,"At")}static{p(this,"Y")}_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(r,e,t){this._options={..._t,...t},this._command=r,this._args=e??[],this._processClosed=new Promise(n=>{this._resolveClose=n})}kill(r){return this._process?.kill(r)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(r,e,t){return xt(r,e,{...t,stdin:this})}async*[Symbol.asyncIterator](){let r=this._process;if(!r)return;let e=[];this._streamErr&&e.push(this._streamErr),this._streamOut&&e.push(this._streamOut);let t=at(e),n=Ye.createInterface({input:t});for await(let o of n)yield o.toString();if(await this._processClosed,r.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new ee(this)}async _waitForOutput(){let r=this._process;if(!r)throw Error("No process was started");let[e,t]=await Promise.all([this._streamOut?B(this._streamOut):"",this._streamErr?B(this._streamErr):""]);if(await this._processClosed,this._options?.stdin&&await this._options.stdin,r.removeAllListeners(),this._thrownError)throw this._thrownError;let n={stderr:t,stdout:e,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new ee(this,n);return n}then(r,e){return this._waitForOutput().then(r,e)}_streamOut;_streamErr;spawn(){let r=Je(),e=this._options,t={...Et,...e.nodeOptions},n=[];this._resetState(),e.timeout!==void 0&&n.push(AbortSignal.timeout(e.timeout)),e.signal!==void 0&&n.push(e.signal),e.persist===!0&&(t.detached=!0),n.length>0&&(t.signal=be(n)),t.env=ve(r,t.env);let{command:o,args:i}=$e(this._command,this._args),c=(0,bt._parse)(o,i,t),s=ce(c.command,c.args,c.options);if(s.stderr&&(this._streamErr=s.stderr),s.stdout&&(this._streamOut=s.stdout),this._process=s,s.once("error",this._onError),s.once("close",this._onClose),e.stdin!==void 0&&s.stdin&&e.stdin.process){let{stdout:a}=e.stdin.process;a&&a.pipe(s.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(r=>{this._resolveClose=r}),this._thrownError=void 0}_onError=p(r=>{if(r.name==="AbortError"&&(!(r.cause instanceof Error)||r.cause.name!=="TimeoutError")){this._aborted=!0;return}this._thrownError=r},"_onError");_onClose=p(()=>{this._resolveClose&&this._resolveClose()},"_onClose")};const U=p((r,e,t)=>{let n=new yt(r,e,t);return n.spawn(),n},"X"),xt=U;var kt=tt({detectPackageManager:p(()=>W,"detectPackageManager"),installDependencies:p(()=>Te,"installDependencies"),packageManagers:p(()=>j,"packageManagers")});async function _e(r,e,t={}){let n=pe(r).split("/");for(;n.length>0;){let o=await e(n.join("/")||"/");if(o||!t.includeParentDirs)return o;n.pop()}}f(_e,"Mt");p(_e,"se");function Ee(r){let e;return()=>(e===void 0&&(e=r().then(t=>(e=t,e))),e)}f(Ee,"zt");p(Ee,"ce");const Tt=Ee(async()=>{if(globalThis.process?.versions?.webcontainer)return!1;try{let{exitCode:r}=await U("corepack",["--version"]);return r===0}catch{return!1}});async function ye(r,e,t={}){let n=r!=="npm"&&r!=="bun"&&r!=="deno"&&t.corepack!==!1&&await Tt()?["corepack",[r,...e]]:[r,e],{exitCode:o,stdout:i,stderr:c}=await U(n[0],n[1],{nodeOptions:{cwd:$(t.cwd||process.cwd()),env:t.env,stdio:t.silent?"pipe":"inherit"}});if(o!==0)throw Error(`\`${n.flat().join(" ")}\` failed.${t.silent?["",i,c].join(`
|
|
2
|
-
`):""}`)}f(ye,"Lt");p(ye,"le");async function xe(r={}){let e=r.cwd||process.cwd(),t={...process.env,...r.env},n=(typeof r.packageManager=="string"?j.find(o=>o.name===r.packageManager):r.packageManager)||await W(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}}f(xe,"Ht");p(xe,"ue");function ke(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 i=(e||"").replace(/\W+/g,"");return{name:i,version:n,buildMeta:o,warnings:[`Abnormal characters found in \`packageManager\` field, sanitizing from \`${e}\` to \`${i}\``]}}f(ke,"Dt");p(ke,"de");const j=[{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 W(r,e={}){let t=await _e($(r||"."),async n=>{if(!e.ignorePackageJSON){let o=K(n,"package.json");if(x(o)){let i=JSON.parse(await ie(o,"utf8"));if(i?.packageManager){let{name:c,version:s="0.0.0",buildMeta:a,warnings:l}=ke(i.packageManager);if(c){let u=s.split(".")[0],h=j.find(d=>d.name===c&&d.majorVersion===u)||j.find(d=>d.name===c);return{name:c,command:c,version:s,majorVersion:u,buildMeta:a,warnings:l,files:h?.files,lockFile:h?.lockFile}}}}if(x(K(n,"deno.json")))return j.find(i=>i.name==="deno")}if(!e.ignoreLockFile){for(let o of j)if([o.lockFile,o.files].flat().filter(Boolean).some(i=>x($(n,i))))return{...o}}},{includeParentDirs:e.includeParentDirs??!0});if(!t&&!e.ignoreArgv){let n=process.argv[1];if(n){for(let o of j)if(RegExp(`[/\\\\]\\.?${o.command}`).test(n))return o}}return t}f(W,"Z$1");p(W,"$");async function Te(r={}){let e=await xe(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 ye(e.packageManager.command,t,{cwd:e.cwd,silent:e.silent,corepack:e.corepack}),{exec:{command:e.packageManager.command,args:t}}}f(Te,"It");p(Te,"fe");const Ct=Object.defineProperty({__proto__:null,a:$,i:he,n:me,r:fe,t:kt},Symbol.toStringTag,{value:"Module"});var Ot=Object.defineProperty,w=f((r,e)=>Ot(r,"name",{value:e,configurable:!0}),"o");async function Ce(r,e,t={}){const n=e+".json",o=JSON.parse(await ie(n,"utf8").catch(()=>"{}")),i=(await I(r,{method:"HEAD",headers:t.headers}).catch(()=>{}))?.headers.get("etag");if(o.etag===i&&x(e))return;typeof i=="string"&&(o.etag=i);const c=await I(r,{headers:t.headers});if(c.status>=400)throw new Error(`Failed to download ${r}: ${c.status} ${c.statusText}`);const s=se(e);await Ke(Re)(c.body,s),await Be(n,JSON.stringify(o),"utf8")}f(Ce,"q");w(Ce,"download");const St=/^(?<repo>[-\w.]+\/[-\w.]+)(?<subdir>[^#]+)?(?<ref>#[-\w./@]+)?/,At=/^(?<repo>[-\w.]+(?:\/[-\w.]+)+?)(?:::(?<subdir>[^#]*))?(?<ref>#[-\w./@]+)?$/;function N(r,e){const t=e?.expandRepo||r.includes("::"),n=r.match(t?At:St)?.groups||{},o=t?n.subdir?"/"+n.subdir:"/":n.subdir||"/";return{repo:n.repo||"",subdir:o,ref:n.ref?n.ref.slice(1):"main"}}f(N,"x");w(N,"parseGitURI");function C(...r){process.env.DEBUG&&console.debug("[giget]",...r)}f(C,"$");w(C,"debug");async function I(r,e={}){e.headers?.["sec-fetch-mode"]&&(e.mode=e.headers["sec-fetch-mode"]);const t=await fetch(r,{...e,headers:X(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}f(I,"v");w(I,"sendFetch");function Oe(){const r=process.env.XDG_CACHE_HOME?$(process.env.XDG_CACHE_HOME,"giget"):$(Ve(),".cache/giget");if(process.platform==="win32"){const e=$(le(),"giget");if(!x(e)&&x(r))try{He(r,e)}catch{}return e}return r}f(Oe,"ee");w(Oe,"cacheDirectory");function X(r={}){const e={};for(const[t,n]of Object.entries(r))n&&(e[t.toLowerCase()]=n);return e}f(X,"F");w(X,"normalizeHeaders");function Se(){return process.env.SHELL?process.env.SHELL:process.platform==="win32"?"cmd.exe":"/bin/bash"}f(Se,"te");w(Se,"currentShell");function jt(r){r=$(r);const e=Se();console.info(`(experimental) Opening shell in ${he(process.cwd(),r)}...`),Ue(e,[],{cwd:r,shell:!0,stdio:"inherit"})}f(jt,"re");w(jt,"startShell");const Pt=w((r,e)=>{const t=Ae(r);return{name:t.name,version:t.subdir?`${t.version||"default"}-${t.subdir.replaceAll("/","-")}`:t.version,tar:w(({auth:n}={})=>je(t,n??e.auth),"tar")}},"git");function Ae(r,e={}){const t=e.cwd??process.cwd();let n=r.replace(/#.*$/,""),o;if(/^[./]/.test(r))n=$(t,n);else if(/^https?:\/\//.test(n)){const u=/^(https?:\/\/[^/]+)\/([\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(n);if(u){const[,h,d,m]=u;n=`${h}/${d}`,m&&(o=m)}}else if(n.includes("@")){const u=/^(.*?:[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(n);if(u){const[,h,d]=u;n=h,d&&(o=d)}}else{const u={"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&&u[h]?n=n.replace(h,u[h]):h||(n=`${(process.env.GIGET_GIT_HOST||"https://github.com/").replace(/\/$/,"")}/${n}`);const d=/^(https?:\/\/[^/]+\/~?[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(n);if(d){const[,m,g]=d;n=m,g&&(o=g)}}const i=n.replace(/^https?:\/\//,"").replace(/^.+@/,"").replace(/(\.git)?(#.*)?$/,"").replace(/^\W+/,"").replaceAll(/[:/]/g,"-"),[c,s]=/#(.+)$/.exec(r)?.at(1)?.split(":")??[],a=c||void 0,l=s||o;return{uri:n,name:i,...a&&{version:a},...l&&{subdir:l}}}f(Ae,"ie");w(Ae,"parseGitCloneURI");async function je(r,e){const t=await Le(Y(le(),"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},i=Pe(),c=w(a=>L(a,o,i),"gitExec"),s=w(a=>L(a,{...o,cwd:t},i),"gitExecIn");try{const a=["clone","--progress","--depth","1"];r.subdir&&a.push("--filter=blob:none","--sparse","--no-checkout"),r.version&&a.push("--branch",r.version),a.push("--",r.uri,t);try{i.update("Cloning..."),await c(a),i.update("Cloned.")}catch(g){if(!r.version)throw g;C("Shallow clone failed, falling back to full clone:",g),i.update("Shallow clone failed, cloning..."),await M(t,{recursive:!0,force:!0}),await H(t,{recursive:!0}),await s(["init"]),await s(["remote","add","origin",r.uri]),await s(["fetch","origin"]),await s(["checkout",r.version]),i.update("Fetched.")}r.subdir&&(i.update(`Sparse checkout ${r.subdir}...`),await s(["sparse-checkout","set",r.subdir]),await s(["checkout"])),i.update("Packing...");const l=r.subdir?Y(t,r.subdir):t,{create:u}=await import("../packem_chunks/tar.js").then(g=>g.t);i.done();const h=u({gzip:!0,cwd:l,filter:w(g=>!g.startsWith(".git/")&&g!==".git"&&!g.startsWith("./.git/")&&g!=="./.git","filter")},["."]).pipe(new ae);let d=!1;const m=w(()=>{d||(d=!0,M(t,{recursive:!0,force:!0}))},"cleanup");return h.on("end",m),h.on("error",m),h.on("close",m),h}catch(a){throw i.done(),await M(t,{recursive:!0,force:!0}),a}}f(je,"se");w(je,"_cloneAndTar");const te=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function L(r,e,t){return new Promise((n,o)=>{const i=ce("git",r,{...e,stdio:["ignore","pipe","pipe"]});i.stdout.resume();let c="";i.stderr?.on("data",s=>{const a=s.toString();for(const l of a.split(/[\r\n]/)){const u=l.trim();u&&(c=u)}t&&t.update(c)}),i.on("close",s=>{s===0?n(c):o(new Error(`git ${r[0]} exited with code ${s}. Is git installed?`))}),i.on("error",s=>{s.code==="ENOENT"?o(new Error("git is not installed or not found in PATH")):o(s)})})}f(L,"G");w(L,"_gitSpawn");function Pe(){if(!process.stderr.isTTY)return{update(o){},done(){}};let r="",e=0;const t=w(()=>{const o=te[e%te.length];e++,process.stderr.write(`\x1B[2K\r\x1B[2m${o} ${r}\x1B[0m`)},"render"),n=setInterval(t,80);return{update(o){r=o,t()},done(){clearInterval(n),process.stderr.write("\x1B[2K\r")}}}f(Pe,"ne");w(Pe,"_createStatus");const re=w(async(r,e)=>{if(r.endsWith(".json"))return await ne(r,e);const t=new URL(r);let n=me(t.pathname);try{const o=await I(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 ne(r,e);const i=o.headers.get("content-disposition")?.match(/filename="?(.+)"?/)?.[1];i&&(n=i.split(".")[0])}catch(o){C(`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}}},"http"),ne=w(async(r,e)=>{const t=await(await I(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},"_httpJSON"),oe=w((r,e)=>{const t=N(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}`}},"github"),zt=w((r,e)=>{const t=N(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`}},"gitlab"),It=w((r,e)=>{const t=N(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`}},"bitbucket"),Dt=w((r,e)=>{const t=N(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`}},"sourcehut"),Ft={http:re,https:re,git:Pt,github:oe,gh:oe,gitlab:zt,bitbucket:It,sourcehut:Dt},Nt="https://raw.githubusercontent.com/unjs/giget/main/templates",Mt=w((r=Nt,e={})=>(async t=>{const n=Date.now(),o=`${r}/${t}.json`,i=await I(o,{headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0}});if(i.status>=400)throw new Error(`Failed to download ${t} template info from ${o}: ${i.status} ${i.statusText}`);const c=await i.json();if(!c.tar||!c.name)throw new Error(`Invalid template info from ${o}. name or tar fields are missing!`);return C(`Fetched ${t} template info from ${o} in ${Date.now()-n}ms`),c}),"registryProvider"),Gt=/^([\w+-.]+):/;async function Ht(r,e={}){e.registry=process.env.GIGET_REGISTRY??e.registry,e.auth=process.env.GIGET_AUTH??e.auth;const t=e.registry===!1?void 0:Mt(e.registry,{auth:e.auth});let n=e.provider||(t?"registry":"github"),o=r;const i=r.match(Gt);i&&(n=i[1],o=r.slice(i[0].length),(n==="http"||n==="https")&&(o=r)),n.endsWith("+git")&&(o=`${n.slice(0,-4)}:${o}`,n="git");const c=e.providers?.[n]||Ft[n]||t;if(!c)throw new Error(`Unsupported provider: ${n}`);const s=await Promise.resolve().then(()=>c(o,{auth:e.auth})).catch(m=>{throw new Error(`Failed to download template from ${n}: ${m.message}`)});if(!s)throw new Error(`Failed to resolve template from ${n}`);s.name=(s.name||"template").replace(/[^\da-z-]/gi,"-"),s.defaultDir=(s.defaultDir||s.name).replace(/[^\da-z-]/gi,"-");const a=$($(Oe(),n,s.name),(s.version||s.name)+".tar.gz");if(e.preferOffline&&x(a)&&(e.offline=!0),!e.offline){await H(fe(a),{recursive:!0});const m=Date.now();if(typeof s.tar=="function"){const g=s.tar;await(async()=>{const v=await g({auth:e.auth});await Ze(v instanceof q?v:q.fromWeb(v),se(a))})().catch(v=>{if(!x(a))throw v;C("Download error. Using cached version:",v),e.offline=!0})}else await Ce(s.tar,a,{headers:{Authorization:e.auth?`Bearer ${e.auth}`:void 0,...X(s.headers)}}).catch(g=>{if(!x(a))throw g;C("Download error. Using cached version:",g),e.offline=!0});C(`Downloaded to ${a} in ${Date.now()-m}ms`)}if(!x(a))throw new Error(`Tarball not found: ${a} (offline: ${e.offline})`);const l=$($(e.cwd||"."),e.dir||s.defaultDir);if(e.forceClean&&await M(l,{recursive:!0,force:!0}),!e.force&&x(l)&&Ge(l).length>0)throw new Error(`Destination ${l} already exists.`);await H(l,{recursive:!0});const u=Date.now(),h=s.subdir?.replace(/^\//,"")||"",{extract:d}=await import("../packem_chunks/tar.js").then(m=>m.t);if(await d({file:a,cwd:l,onReadEntry(m){m.path=m.path.split("/").splice(1).join("/"),h&&(m.path.startsWith(h+"/")?m.path=m.path.slice(h.length):m.path="")}}),C(`Extracted to ${l} in ${Date.now()-u}ms`),e.install){C("Installing dependencies...");const{installDependencies:m}=await Promise.resolve().then(()=>Ct).then(g=>g.t);await m({cwd:l,silent:e.silent,...typeof e.install=="object"?e.install:{}})}return{...s,source:o,dir:l}}f(Ht,"fe");w(Ht,"downloadTemplate");export{Ht as f,tt as p};
|
|
1
|
+
var De=Object.defineProperty;var f=(r,e)=>De(r,"name",{value:e,configurable:!0});import{createRequire as Fe}from"node:module";const Ne=Fe(import.meta.url),z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=f(r=>{if(typeof z<"u"&&z.versions&&z.versions.node){const[e,t]=z.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return z.getBuiltinModule(r)}return Ne(r)},"__cjs_getBuiltinModule"),{createRequire:Me}=k("node:module"),{existsSync:x,createWriteStream:se,readdirSync:Ge,renameSync:He}=k("node:fs"),{readFile:ie,mkdir:H,rm:M,writeFile:Be,mkdtemp:Le}=k("node:fs/promises"),{PassThrough:ae,Readable:J,pipeline:Re}=k("node:stream"),{spawn:ce,spawnSync:Ue}=k("node:child_process"),{delimiter:q,resolve:We,dirname:Xe,normalize:Je,join:Y}=k("node:path"),{cwd:qe}=z,Ye=k("node:readline"),{pipeline:Ze}=k("node:stream/promises"),{homedir:Ve,tmpdir:le}=k("node:os"),{promisify:Ke}=k("node:util");var Qe=Object.defineProperty,et=f((r,e)=>Qe(r,"name",{value:e,configurable:!0}),"a$1"),Z=Object.defineProperty,tt=et((r,e)=>{let t={};for(var n in r)Z(t,n,{get:r[n],enumerable:!0});return e||Z(t,Symbol.toStringTag,{value:"Module"}),t},"__exportAll"),rt=Object.defineProperty,p=f((r,e)=>rt(r,"name",{value:e,configurable:!0}),"a");const nt=/^[A-Za-z]:\//;function F(r=""){return r&&r.replace(/\\/g,"/").replace(nt,e=>e.toUpperCase())}f(F,"P");p(F,"p");const ot=/^[/\\]{2}/,st=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,ue=/^[A-Za-z]:$/,V=/^\/([A-Za-z]:)?$/,pe=p(function(r){if(r.length===0)return".";r=F(r);let e=r.match(ot),t=D(r),n=r[r.length-1]==="/";return r=R(r,!t),r.length===0?t?"/":n?"./":".":(n&&(r+="/"),ue.test(r)&&(r+="/"),e?t?`//${r}`:`//./${r}`:t&&!D(r)?`/${r}`:r)},"g"),K=p(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 pe(e)},"_");function de(){return typeof process.cwd=="function"?process.cwd().replace(/\\/g,"/"):"/"}f(de,"st");p(de,"v");const $=p(function(...r){r=r.map(n=>F(n));let e="",t=!1;for(let n=r.length-1;n>=-1&&!t;n--){let o=n>=0?r[n]:de();!o||o.length===0||(e=`${o}/${e}`,t=D(o))}return e=R(e,!t),t&&!D(e)?`/${e}`:e.length>0?e:"."},"y");function R(r,e){let t="",n=0,o=-1,i=0,c=null;for(let s=0;s<=r.length;++s){if(s<r.length)c=r[s];else{if(c==="/")break;c="/"}if(c==="/"){if(!(o===s-1||i===1))if(i===2){if(t.length<2||n!==2||t[t.length-1]!=="."||t[t.length-2]!=="."){if(t.length>2){let a=t.lastIndexOf("/");a===-1?(t="",n=0):(t=t.slice(0,a),n=t.length-1-t.lastIndexOf("/")),o=s,i=0;continue}else if(t.length>0){t="",n=0,o=s,i=0;continue}}e&&(t+=t.length>0?"/..":"..",n=2)}else t.length>0?t+=`/${r.slice(o+1,s)}`:t=r.slice(o+1,s),n=s-o-1;o=s,i=0}else c==="."&&i!==-1?++i:i=-1}return t}f(R,"W");p(R,"b");const D=p(function(r){return st.test(r)},"x"),he=p(function(r,e){let t=$(r).replace(V,"$1").split("/"),n=$(e).replace(V,"$1").split("/");if(n[0][1]===":"&&t[0][1]===":"&&t[0]!==n[0])return n.join("/");let o=[...t];for(let i of o){if(n[0]!==i)break;t.shift(),n.shift()}return[...t.map(()=>".."),...n].join("/")},"S"),fe=p(function(r){let e=F(r).replace(/\/$/,"").split("/").slice(0,-1);return e.length===1&&ue.test(e[0])&&(e[0]+="/"),e.join("/")||(D(r)?"/":".")},"C"),me=p(function(r,e){let t=F(r).split("/"),n="";for(let o=t.length-1;o>=0;o--){let i=t[o];if(i){n=i;break}}return e&&n.endsWith(e)?n.slice(0,-e.length):n},"ne");var _=p((r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),"w"),O=Me(import.meta.url);const it=/^path$/i,Q={key:"PATH",value:""};function ge(r){for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e)||!it.test(e))continue;let t=r[e];return t?{key:e,value:t}:Q}return Q}f(ge,"pt");p(ge,"D");function we(r,e){let t=e.value.split(q),n=[],o=r,i;do n.push(We(o,"node_modules",".bin")),i=o,o=Xe(o);while(o!==i);let c=n.concat(t).join(q);return{key:e.key,value:c}}f(we,"ut");p(we,"O");function ve(r,e){let t={...process.env,...e},n=we(r,ge(t));return t[n.key]=n.value,t}f(ve,"ft");p(ve,"k");const at=p(r=>{let e=r.length,t=new ae,n=p(()=>{--e===0&&t.emit("end")},"r");for(let o of r)o.pipe(t,{end:!1}),o.on("end",n);return t},"A");var ct=_(((r,e)=>{e.exports=i,i.sync=c;var t=O("fs");function n(s,a){var l=a.pathExt===void 0?process.env.PATHEXT:a.pathExt;if(!l||(l=l.split(";"),l.indexOf("")!==-1))return!0;for(var u=0;u<l.length;u++){var h=l[u].toLowerCase();if(h&&s.substr(-h.length).toLowerCase()===h)return!0}return!1}f(n,"n"),p(n,"r");function o(s,a,l){return!s.isSymbolicLink()&&!s.isFile()?!1:n(a,l)}f(o,"s"),p(o,"i");function i(s,a,l){t.stat(s,function(u,h){l(u,u?!1:o(h,s,a))})}f(i,"i"),p(i,"a");function c(s,a){return o(t.statSync(s),s,a)}f(c,"c"),p(c,"o")})),lt=_(((r,e)=>{e.exports=n,n.sync=o;var t=O("fs");function n(s,a,l){t.stat(s,function(u,h){l(u,u?!1:i(h,a))})}f(n,"n"),p(n,"r");function o(s,a){return i(t.statSync(s),a)}f(o,"s"),p(o,"i");function i(s,a){return s.isFile()&&c(s,a)}f(i,"i"),p(i,"a");function c(s,a){var l=s.mode,u=s.uid,h=s.gid,d=a.uid===void 0?process.getuid&&process.getuid():a.uid,m=a.gid===void 0?process.getgid&&process.getgid():a.gid,g=64,v=8,E=1,S=g|v;return l&E||l&v&&h===m||l&g&&u===d||l&S&&d===0}f(c,"c"),p(c,"o")})),ut=_(((r,e)=>{O("fs");var t=process.platform==="win32"||global.TESTING_WINDOWS?ct():lt();e.exports=n,n.sync=o;function n(i,c,s){if(typeof c=="function"&&(s=c,c={}),!s){if(typeof Promise!="function")throw TypeError("callback not provided");return new Promise(function(a,l){n(i,c||{},function(u,h){u?l(u):a(h)})})}t(i,c||{},function(a,l){a&&(a.code==="EACCES"||c&&c.ignoreErrors)&&(a=null,l=!1),s(a,l)})}f(n,"n"),p(n,"r");function o(i,c){try{return t.sync(i,c||{})}catch(s){if(c&&c.ignoreErrors||s.code==="EACCES")return!1;throw s}}f(o,"s"),p(o,"i")})),pt=_(((r,e)=>{let t=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",n=O("path"),o=t?";":":",i=ut(),c=p(l=>Object.assign(Error(`not found: ${l}`),{code:"ENOENT"}),"o"),s=p((l,u)=>{let h=u.colon||o,d=l.match(/\//)||t&&l.match(/\\/)?[""]:[...t?[process.cwd()]:[],...(u.path||process.env.PATH||"").split(h)],m=t?u.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",g=t?m.split(h):[""];return t&&l.indexOf(".")!==-1&&g[0]!==""&&g.unshift(""),{pathEnv:d,pathExt:g,pathExtExe:m}},"s"),a=p((l,u,h)=>{typeof u=="function"&&(h=u,u={}),u||={};let{pathEnv:d,pathExt:m,pathExtExe:g}=s(l,u),v=[],E=p(b=>new Promise((A,T)=>{if(b===d.length)return u.all&&v.length?A(v):T(c(l));let y=d[b],G=/^".*"$/.test(y)?y.slice(1,-1):y,P=n.join(G,l);A(S(!G&&/^\.[\\\/]/.test(l)?l.slice(0,2)+P:P,b,0))}),"d"),S=p((b,A,T)=>new Promise((y,G)=>{if(T===m.length)return y(E(A+1));let P=m[T];i(b+P,{pathExt:g},(ze,Ie)=>{if(!ze&&Ie)if(u.all)v.push(b+P);else return y(b+P);return y(S(b,A,T+1))})}),"f");return h?E(0).then(b=>h(null,b),h):E(0)},"c");e.exports=a,a.sync=(l,u)=>{u||={};let{pathEnv:h,pathExt:d,pathExtExe:m}=s(l,u),g=[];for(let v=0;v<h.length;v++){let E=h[v],S=/^".*"$/.test(E)?E.slice(1,-1):E,b=n.join(S,l),A=!S&&/^\.[\\\/]/.test(l)?l.slice(0,2)+b:b;for(let T=0;T<d.length;T++){let y=A+d[T];try{if(i.sync(y,{pathExt:m}))if(u.all)g.push(y);else return y}catch{}}}if(u.all&&g.length)return g;if(u.nothrow)return null;throw c(l)}})),dt=_(((r,e)=>{let t=p((n={})=>{let o=n.env||process.env;return(n.platform||process.platform)==="win32"?Object.keys(o).reverse().find(i=>i.toUpperCase()==="PATH")||"Path":"PATH"},"n");e.exports=t,e.exports.default=t})),ht=_(((r,e)=>{let t=O("path"),n=pt(),o=dt();function i(s,a){let l=s.options.env||process.env,u=process.cwd(),h=s.options.cwd!=null,d=h&&process.chdir!==void 0&&!process.chdir.disabled;if(d)try{process.chdir(s.options.cwd)}catch{}let m;try{m=n.sync(s.command,{path:l[o({env:l})],pathExt:a?t.delimiter:void 0})}catch{}finally{d&&process.chdir(u)}return m&&=t.resolve(h?s.options.cwd:"",m),m}f(i,"i"),p(i,"a");function c(s){return i(s)||i(s,!0)}f(c,"c"),p(c,"o"),e.exports=c})),ft=_(((r,e)=>{let t=/([()\][%!^"`<>&|;, *?])/g;function n(i){return i=i.replace(t,"^$1"),i}f(n,"n"),p(n,"r");function o(i,c){return i=`${i}`,i=i.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),i=i.replace(/(?=(\\+?)?)\1$/,"$1$1"),i=`"${i}"`,i=i.replace(t,"^$1"),c&&(i=i.replace(t,"^$1")),i}f(o,"s"),p(o,"i"),e.exports.command=n,e.exports.argument=o})),mt=_(((r,e)=>{e.exports=/^#!(.*)/})),gt=_(((r,e)=>{let t=mt();e.exports=(n="")=>{let o=n.match(t);if(!o)return null;let[i,c]=o[0].replace(/#! ?/,"").split(" "),s=i.split("/").pop();return s==="env"?c:c?`${s} ${c}`:s}})),wt=_(((r,e)=>{let t=O("fs"),n=gt();function o(i){let c=Buffer.alloc(150),s;try{s=t.openSync(i,"r"),t.readSync(s,c,0,150,0),t.closeSync(s)}catch{}return n(c.toString())}f(o,"s"),p(o,"i"),e.exports=o})),vt=_(((r,e)=>{let t=O("path"),n=ht(),o=ft(),i=wt(),c=process.platform==="win32",s=/\.(?:com|exe)$/i,a=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(d){d.file=n(d);let m=d.file&&i(d.file);return m?(d.args.unshift(d.file),d.command=m,n(d)):d.file}f(l,"p"),p(l,"l");function u(d){if(!c)return d;let m=l(d),g=!s.test(m);if(d.options.forceShell||g){let v=a.test(m);d.command=t.normalize(d.command),d.command=o.command(d.command),d.args=d.args.map(E=>o.argument(E,v)),d.args=["/d","/s","/c",`"${[d.command].concat(d.args).join(" ")}"`],d.command=process.env.comspec||"cmd.exe",d.options.windowsVerbatimArguments=!0}return d}f(u,"u"),p(u,"u");function h(d,m,g){m&&!Array.isArray(m)&&(g=m,m=null),m=m?m.slice(0):[],g=Object.assign({},g);let v={command:d,args:m,options:g,file:void 0,original:{command:d,args:m}};return g.shell?v:u(v)}f(h,"d"),p(h,"d"),e.exports=h})),$t=_(((r,e)=>{let t=process.platform==="win32";function n(s,a){return Object.assign(Error(`${a} ${s.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${a} ${s.command}`,path:s.command,spawnargs:s.args})}f(n,"n"),p(n,"r");function o(s,a){if(!t)return;let l=s.emit;s.emit=function(u,h){if(u==="exit"){let d=i(h,a);if(d)return l.call(s,"error",d)}return l.apply(s,arguments)}}f(o,"s"),p(o,"i");function i(s,a){return t&&s===1&&!a.file?n(a.original,"spawn"):null}f(i,"i"),p(i,"a");function c(s,a){return t&&s===1&&!a.file?n(a.original,"spawnSync"):null}f(c,"c"),p(c,"o"),e.exports={hookChildProcess:o,verifyENOENT:i,verifyENOENTSync:c,notFoundError:n}})),bt=_(((r,e)=>{let t=O("child_process"),n=vt(),o=$t();function i(s,a,l){let u=n(s,a,l),h=t.spawn(u.command,u.args,u.options);return o.hookChildProcess(h,u),h}f(i,"i"),p(i,"a");function c(s,a,l){let u=n(s,a,l),h=t.spawnSync(u.command,u.args,u.options);return h.error=h.error||o.verifyENOENTSync(h.status,u),h}f(c,"c"),p(c,"o"),e.exports=i,e.exports.spawn=i,e.exports.sync=c,e.exports._parse=n,e.exports._enoent=o}))(),ee=class extends Error{static{f(this,"L")}static{p(this,"U")}result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(r,e){super(`Process exited with non-zero status (${r.exitCode})`),this.result=r,this.output=e}};const _t={timeout:void 0,persist:!1},Et={windowsHide:!0};function $e(r,e){return{command:Je(r),args:e??[]}}f($e,"Pt");p($e,"K");function be(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}f(be,"Tt");p(be,"q");async function B(r){let e="";for await(let t of r)e+=t.toString();return e}f(B,"H");p(B,"J");var yt=class{static{f(this,"At")}static{p(this,"Y")}_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(r,e,t){this._options={..._t,...t},this._command=r,this._args=e??[],this._processClosed=new Promise(n=>{this._resolveClose=n})}kill(r){return this._process?.kill(r)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(r,e,t){return xt(r,e,{...t,stdin:this})}async*[Symbol.asyncIterator](){let r=this._process;if(!r)return;let e=[];this._streamErr&&e.push(this._streamErr),this._streamOut&&e.push(this._streamOut);let t=at(e),n=Ye.createInterface({input:t});for await(let o of n)yield o.toString();if(await this._processClosed,r.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new ee(this)}async _waitForOutput(){let r=this._process;if(!r)throw Error("No process was started");let[e,t]=await Promise.all([this._streamOut?B(this._streamOut):"",this._streamErr?B(this._streamErr):""]);if(await this._processClosed,this._options?.stdin&&await this._options.stdin,r.removeAllListeners(),this._thrownError)throw this._thrownError;let n={stderr:t,stdout:e,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new ee(this,n);return n}then(r,e){return this._waitForOutput().then(r,e)}_streamOut;_streamErr;spawn(){let r=qe(),e=this._options,t={...Et,...e.nodeOptions},n=[];this._resetState(),e.timeout!==void 0&&n.push(AbortSignal.timeout(e.timeout)),e.signal!==void 0&&n.push(e.signal),e.persist===!0&&(t.detached=!0),n.length>0&&(t.signal=be(n)),t.env=ve(r,t.env);let{command:o,args:i}=$e(this._command,this._args),c=(0,bt._parse)(o,i,t),s=ce(c.command,c.args,c.options);if(s.stderr&&(this._streamErr=s.stderr),s.stdout&&(this._streamOut=s.stdout),this._process=s,s.once("error",this._onError),s.once("close",this._onClose),e.stdin!==void 0&&s.stdin&&e.stdin.process){let{stdout:a}=e.stdin.process;a&&a.pipe(s.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(r=>{this._resolveClose=r}),this._thrownError=void 0}_onError=p(r=>{if(r.name==="AbortError"&&(!(r.cause instanceof Error)||r.cause.name!=="TimeoutError")){this._aborted=!0;return}this._thrownError=r},"_onError");_onClose=p(()=>{this._resolveClose&&this._resolveClose()},"_onClose")};const U=p((r,e,t)=>{let n=new yt(r,e,t);return n.spawn(),n},"X"),xt=U;var kt=tt({detectPackageManager:p(()=>W,"detectPackageManager"),installDependencies:p(()=>Te,"installDependencies"),packageManagers:p(()=>j,"packageManagers")});async function _e(r,e,t={}){let n=pe(r).split("/");for(;n.length>0;){let o=await e(n.join("/")||"/");if(o||!t.includeParentDirs)return o;n.pop()}}f(_e,"Mt");p(_e,"se");function Ee(r){let e;return()=>(e===void 0&&(e=r().then(t=>(e=t,e))),e)}f(Ee,"zt");p(Ee,"ce");const Tt=Ee(async()=>{if(globalThis.process?.versions?.webcontainer)return!1;try{let{exitCode:r}=await U("corepack",["--version"]);return r===0}catch{return!1}});async function ye(r,e,t={}){let n=r!=="npm"&&r!=="bun"&&r!=="deno"&&t.corepack!==!1&&await Tt()?["corepack",[r,...e]]:[r,e],{exitCode:o,stdout:i,stderr:c}=await U(n[0],n[1],{nodeOptions:{cwd:$(t.cwd||process.cwd()),env:t.env,stdio:t.silent?"pipe":"inherit"}});if(o!==0)throw Error(`\`${n.flat().join(" ")}\` failed.${t.silent?["",i,c].join(`
|
|
2
|
+
`):""}`)}f(ye,"Lt");p(ye,"le");async function xe(r={}){let e=r.cwd||process.cwd(),t={...process.env,...r.env},n=(typeof r.packageManager=="string"?j.find(o=>o.name===r.packageManager):r.packageManager)||await W(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}}f(xe,"Ht");p(xe,"ue");function ke(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 i=(e||"").replace(/\W+/g,"");return{name:i,version:n,buildMeta:o,warnings:[`Abnormal characters found in \`packageManager\` field, sanitizing from \`${e}\` to \`${i}\``]}}f(ke,"Dt");p(ke,"de");const j=[{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 W(r,e={}){let t=await _e($(r||"."),async n=>{if(!e.ignorePackageJSON){let o=K(n,"package.json");if(x(o)){let i=JSON.parse(await ie(o,"utf8"));if(i?.packageManager){let{name:c,version:s="0.0.0",buildMeta:a,warnings:l}=ke(i.packageManager);if(c){let u=s.split(".")[0],h=j.find(d=>d.name===c&&d.majorVersion===u)||j.find(d=>d.name===c);return{name:c,command:c,version:s,majorVersion:u,buildMeta:a,warnings:l,files:h?.files,lockFile:h?.lockFile}}}}if(x(K(n,"deno.json")))return j.find(i=>i.name==="deno")}if(!e.ignoreLockFile){for(let o of j)if([o.lockFile,o.files].flat().filter(Boolean).some(i=>x($(n,i))))return{...o}}},{includeParentDirs:e.includeParentDirs??!0});if(!t&&!e.ignoreArgv){let n=process.argv[1];if(n){for(let o of j)if(RegExp(`[/\\\\]\\.?${o.command}`).test(n))return o}}return t}f(W,"Z$1");p(W,"$");async function Te(r={}){let e=await xe(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 ye(e.packageManager.command,t,{cwd:e.cwd,silent:e.silent,corepack:e.corepack}),{exec:{command:e.packageManager.command,args:t}}}f(Te,"It");p(Te,"fe");const Ct=Object.defineProperty({__proto__:null,a:$,i:he,n:me,r:fe,t:kt},Symbol.toStringTag,{value:"Module"});var Ot=Object.defineProperty,w=f((r,e)=>Ot(r,"name",{value:e,configurable:!0}),"o");async function Ce(r,e,t={}){const n=e+".json",o=JSON.parse(await ie(n,"utf8").catch(()=>"{}")),i=(await I(r,{method:"HEAD",headers:t.headers}).catch(()=>{}))?.headers.get("etag");if(o.etag===i&&x(e))return;typeof i=="string"&&(o.etag=i);const c=await I(r,{headers:t.headers});if(c.status>=400)throw new Error(`Failed to download ${r}: ${c.status} ${c.statusText}`);const s=se(e);await Ke(Re)(c.body,s),await Be(n,JSON.stringify(o),"utf8")}f(Ce,"q");w(Ce,"download");const St=/^(?<repo>[-\w.]+\/[-\w.]+)(?<subdir>[^#]+)?(?<ref>#[-\w./@]+)?/,At=/^(?<repo>[-\w.]+(?:\/[-\w.]+)+?)(?:::(?<subdir>[^#]*))?(?<ref>#[-\w./@]+)?$/;function N(r,e){const t=e?.expandRepo||r.includes("::"),n=r.match(t?At:St)?.groups||{},o=t?n.subdir?"/"+n.subdir:"/":n.subdir||"/";return{repo:n.repo||"",subdir:o,ref:n.ref?n.ref.slice(1):"main"}}f(N,"x");w(N,"parseGitURI");function C(...r){process.env.DEBUG&&console.debug("[giget]",...r)}f(C,"$");w(C,"debug");async function I(r,e={}){e.headers?.["sec-fetch-mode"]&&(e.mode=e.headers["sec-fetch-mode"]);const t=await fetch(r,{...e,headers:X(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}f(I,"v");w(I,"sendFetch");function Oe(){const r=process.env.XDG_CACHE_HOME?$(process.env.XDG_CACHE_HOME,"giget"):$(Ve(),".cache/giget");if(process.platform==="win32"){const e=$(le(),"giget");if(!x(e)&&x(r))try{He(r,e)}catch{}return e}return r}f(Oe,"ee");w(Oe,"cacheDirectory");function X(r={}){const e={};for(const[t,n]of Object.entries(r))n&&(e[t.toLowerCase()]=n);return e}f(X,"F");w(X,"normalizeHeaders");function Se(){return process.env.SHELL?process.env.SHELL:process.platform==="win32"?"cmd.exe":"/bin/bash"}f(Se,"te");w(Se,"currentShell");function jt(r){r=$(r);const e=Se();console.info(`(experimental) Opening shell in ${he(process.cwd(),r)}...`),Ue(e,[],{cwd:r,shell:!0,stdio:"inherit"})}f(jt,"re");w(jt,"startShell");const Pt=w((r,e)=>{const t=Ae(r);return{name:t.name,version:t.subdir?`${t.version||"default"}-${t.subdir.replaceAll("/","-")}`:t.version,tar:w(({auth:n}={})=>je(t,n??e.auth),"tar")}},"git");function Ae(r,e={}){const t=e.cwd??process.cwd();let n=r.replace(/#.*$/,""),o;if(/^[./]/.test(r))n=$(t,n);else if(/^https?:\/\//.test(n)){const u=/^(https?:\/\/[^/]+)\/([\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(n);if(u){const[,h,d,m]=u;n=`${h}/${d}`,m&&(o=m)}}else if(n.includes("@")){const u=/^(.*?:[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(n);if(u){const[,h,d]=u;n=h,d&&(o=d)}}else{const u={"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&&u[h]?n=n.replace(h,u[h]):h||(n=`${(process.env.GIGET_GIT_HOST||"https://github.com/").replace(/\/$/,"")}/${n}`);const d=/^(https?:\/\/[^/]+\/~?[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(n);if(d){const[,m,g]=d;n=m,g&&(o=g)}}const i=n.replace(/^https?:\/\//,"").replace(/^.+@/,"").replace(/(\.git)?(#.*)?$/,"").replace(/^\W+/,"").replaceAll(/[:/]/g,"-"),[c,s]=/#(.+)$/.exec(r)?.at(1)?.split(":")??[],a=c||void 0,l=s||o;return{uri:n,name:i,...a&&{version:a},...l&&{subdir:l}}}f(Ae,"ie");w(Ae,"parseGitCloneURI");async function je(r,e){const t=await Le(Y(le(),"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},i=Pe(),c=w(a=>L(a,o,i),"gitExec"),s=w(a=>L(a,{...o,cwd:t},i),"gitExecIn");try{const a=["clone","--progress","--depth","1"];r.subdir&&a.push("--filter=blob:none","--sparse","--no-checkout"),r.version&&a.push("--branch",r.version),a.push("--",r.uri,t);try{i.update("Cloning..."),await c(a),i.update("Cloned.")}catch(g){if(!r.version)throw g;C("Shallow clone failed, falling back to full clone:",g),i.update("Shallow clone failed, cloning..."),await M(t,{recursive:!0,force:!0}),await H(t,{recursive:!0}),await s(["init"]),await s(["remote","add","origin",r.uri]),await s(["fetch","origin"]),await s(["checkout",r.version]),i.update("Fetched.")}r.subdir&&(i.update(`Sparse checkout ${r.subdir}...`),await s(["sparse-checkout","set",r.subdir]),await s(["checkout"])),i.update("Packing...");const l=r.subdir?Y(t,r.subdir):t,{create:u}=await import("../packem_chunks/tar.js").then(g=>g.t);i.done();const h=u({gzip:!0,cwd:l,filter:w(g=>!g.startsWith(".git/")&&g!==".git"&&!g.startsWith("./.git/")&&g!=="./.git","filter")},["."]).pipe(new ae);let d=!1;const m=w(()=>{d||(d=!0,M(t,{recursive:!0,force:!0}))},"cleanup");return h.on("end",m),h.on("error",m),h.on("close",m),h}catch(a){throw i.done(),await M(t,{recursive:!0,force:!0}),a}}f(je,"se");w(je,"_cloneAndTar");const te=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function L(r,e,t){return new Promise((n,o)=>{const i=ce("git",r,{...e,stdio:["ignore","pipe","pipe"]});i.stdout.resume();let c="";i.stderr?.on("data",s=>{const a=s.toString();for(const l of a.split(/[\r\n]/)){const u=l.trim();u&&(c=u)}t&&t.update(c)}),i.on("close",s=>{s===0?n(c):o(new Error(`git ${r[0]} exited with code ${s}. Is git installed?`))}),i.on("error",s=>{s.code==="ENOENT"?o(new Error("git is not installed or not found in PATH")):o(s)})})}f(L,"G");w(L,"_gitSpawn");function Pe(){if(!process.stderr.isTTY)return{update(o){},done(){}};let r="",e=0;const t=w(()=>{const o=te[e%te.length];e++,process.stderr.write(`\x1B[2K\r\x1B[2m${o} ${r}\x1B[0m`)},"render"),n=setInterval(t,80);return{update(o){r=o,t()},done(){clearInterval(n),process.stderr.write("\x1B[2K\r")}}}f(Pe,"ne");w(Pe,"_createStatus");const re=w(async(r,e)=>{if(r.endsWith(".json"))return await ne(r,e);const t=new URL(r);let n=me(t.pathname);try{const o=await I(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 ne(r,e);const i=o.headers.get("content-disposition")?.match(/filename="?(.+)"?/)?.[1];i&&(n=i.split(".")[0])}catch(o){C(`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}}},"http"),ne=w(async(r,e)=>{const t=await(await I(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},"_httpJSON"),oe=w((r,e)=>{const t=N(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}`}},"github"),zt=w((r,e)=>{const t=N(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`}},"gitlab"),It=w((r,e)=>{const t=N(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`}},"bitbucket"),Dt=w((r,e)=>{const t=N(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`}},"sourcehut"),Ft={http:re,https:re,git:Pt,github:oe,gh:oe,gitlab:zt,bitbucket:It,sourcehut:Dt},Nt="https://raw.githubusercontent.com/unjs/giget/main/templates",Mt=w((r=Nt,e={})=>(async t=>{const n=Date.now(),o=`${r}/${t}.json`,i=await I(o,{headers:{authorization:e.auth?`Bearer ${e.auth}`:void 0}});if(i.status>=400)throw new Error(`Failed to download ${t} template info from ${o}: ${i.status} ${i.statusText}`);const c=await i.json();if(!c.tar||!c.name)throw new Error(`Invalid template info from ${o}. name or tar fields are missing!`);return C(`Fetched ${t} template info from ${o} in ${Date.now()-n}ms`),c}),"registryProvider"),Gt=/^([\w+-.]+):/;async function Ht(r,e={}){e.registry=process.env.GIGET_REGISTRY??e.registry,e.auth=process.env.GIGET_AUTH??e.auth;const t=e.registry===!1?void 0:Mt(e.registry,{auth:e.auth});let n=e.provider||(t?"registry":"github"),o=r;const i=r.match(Gt);i&&(n=i[1],o=r.slice(i[0].length),(n==="http"||n==="https")&&(o=r)),n.endsWith("+git")&&(o=`${n.slice(0,-4)}:${o}`,n="git");const c=e.providers?.[n]||Ft[n]||t;if(!c)throw new Error(`Unsupported provider: ${n}`);const s=await Promise.resolve().then(()=>c(o,{auth:e.auth})).catch(m=>{throw new Error(`Failed to download template from ${n}: ${m.message}`)});if(!s)throw new Error(`Failed to resolve template from ${n}`);s.name=(s.name||"template").replace(/[^\da-z-]/gi,"-"),s.defaultDir=(s.defaultDir||s.name).replace(/[^\da-z-]/gi,"-");const a=$($(Oe(),n,s.name),(s.version||s.name)+".tar.gz");if(e.preferOffline&&x(a)&&(e.offline=!0),!e.offline){await H(fe(a),{recursive:!0});const m=Date.now();if(typeof s.tar=="function"){const g=s.tar;await(async()=>{const v=await g({auth:e.auth});await Ze(v instanceof J?v:J.fromWeb(v),se(a))})().catch(v=>{if(!x(a))throw v;C("Download error. Using cached version:",v),e.offline=!0})}else await Ce(s.tar,a,{headers:{Authorization:e.auth?`Bearer ${e.auth}`:void 0,...X(s.headers)}}).catch(g=>{if(!x(a))throw g;C("Download error. Using cached version:",g),e.offline=!0});C(`Downloaded to ${a} in ${Date.now()-m}ms`)}if(!x(a))throw new Error(`Tarball not found: ${a} (offline: ${e.offline})`);const l=$($(e.cwd||"."),e.dir||s.defaultDir);if(e.forceClean&&await M(l,{recursive:!0,force:!0}),!e.force&&x(l)&&Ge(l).length>0)throw new Error(`Destination ${l} already exists.`);await H(l,{recursive:!0});const u=Date.now(),h=s.subdir?.replace(/^\//,"")||"",{extract:d}=await import("../packem_chunks/tar.js").then(m=>m.t);if(await d({file:a,cwd:l,onReadEntry(m){m.path=m.path.split("/").splice(1).join("/"),h&&(m.path.startsWith(h+"/")?m.path=m.path.slice(h.length):m.path="")}}),C(`Extracted to ${l} in ${Date.now()-u}ms`),e.install){C("Installing dependencies...");const{installDependencies:m}=await Promise.resolve().then(()=>Ct).then(g=>g.t);await m({cwd:l,silent:e.silent,...typeof e.install=="object"?e.install:{}})}return{...s,source:o,dir:l}}f(Ht,"fe");w(Ht,"downloadTemplate");export{Ht as f,tt as p};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var Xt=Object.defineProperty;var w=(r,a)=>Xt(r,"name",{value:a,configurable:!0});import{definePlugin as Yt}from"../packem_chunks/applyDefaults.js";var en=Object.defineProperty,tn=w((r,a)=>en(r,"name",{value:a,configurable:!0}),"$e"),nn=Object.defineProperty,H=tn((r,a)=>nn(r,"name",{value:a,configurable:!0}),"W"),rn=Object.defineProperty,l=H((r,a)=>rn(r,"name",{value:a,configurable:!0}),"u$1");let me=l(()=>{var r=(()=>{var a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,d=l((e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},"ne"),m=l((e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of u(t))!g.call(e,o)&&o!==n&&a(e,o,{get:l(()=>t[o],"get"),enumerable:!(s=i(t,o))||s.enumerable});return e},"ae"),x=l(e=>m(a({},"__esModule",{value:!0}),e),"oe"),I={};d(I,{zeptomatch:l(()=>xe,"zeptomatch")});var Q=l(e=>{const t=new Set,n=[e];for(let s=0;s<n.length;s++){const o=n[s];if(t.has(o))continue;t.add(o);const{children:c}=o;if(c?.length)for(let f=0,h=c.length;f<h;f++)n.push(c[f])}return Array.from(t)},"M"),Ee=l(e=>{let t="";const n=Q(e);for(let s=0,o=n.length;s<o;s++){const c=n[s];if(!c.regex)continue;const f=c.regex.flags;if(t||(t=f),t!==f)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${f}"`)}return t},"se"),X=l((e,t,n)=>{const s=n.get(e);if(s!==void 0)return s;const o=e.partial??t;let c="";if(e.regex&&(c+=o?"(?:$|":"",c+=e.regex.source),e.children?.length){const f=Ae(e.children.map(h=>X(h,t,n)).filter(Boolean));if(f?.length){const h=e.children.some(N=>!N.regex||!(N.partial??t)),v=f.length>1||o&&(!c.length||h);c+=v?o?"(?:$|":"(?:":"",c+=f.join("|"),c+=v?")":""}}return e.regex&&(c+=o?")":""),n.set(e,c),c},"O"),Oe=l((e,t)=>{const n=new Map,s=Q(e);for(let o=s.length-1;o>=0;o--){const c=X(s[o],t,n);if(!(o>0))return c}return""},"ie"),Ae=l(e=>Array.from(new Set(e)),"ue"),Z=l((e,t,n)=>Z.compile(e,n).test(t),"R");Z.compile=(e,t)=>{const n=t?.partial??!1,s=Oe(e,n),o=Ee(e);return new RegExp(`^(?:${s})$`,o)};var Re=Z,Ce=l((e,t)=>{const n=Re.compile(e,t),s=`${n.source.slice(0,-1)}[\\\\/]?$`,o=n.flags;return new RegExp(s,o)},"le"),Me=Ce,Se=l(e=>{const t=e.map(s=>s.source).join("|")||"$^",n=e[0]?.flags;return new RegExp(t,n)},"ve"),ze=Se,Y=l(e=>Array.isArray(e),"j"),_=l(e=>typeof e=="function","_"),Pe=l(e=>e.length===0,"he"),Ie=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return n=>(n.length===0||n.length===1)&&t.test(e.call(n))})(),_e=l(e=>typeof e=="number","de"),We=l(e=>typeof e=="object"&&e!==null,"xe"),Ne=l(e=>e instanceof RegExp,"me"),Ve=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),Be=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),ee=l(e=>typeof e=="string","A"),k=l(e=>e===void 0,"f"),Te=l(e=>{const t=new Map;return n=>{const s=t.get(n);if(s!==void 0)return s;const o=e(n);return t.set(n,o),o}},"ye"),te=l((e,t,n={})=>{const s={cache:{},input:e,index:0,indexBacktrackMax:0,options:n,output:[]},o=E(t)(s),c=Math.max(s.index,s.indexBacktrackMax);if(o&&s.index===e.length)return s.output;throw new Error(`Failed to parse at index ${c}`)},"I"),p=l((e,t)=>Y(e)?Ze(e,t):ee(e)?ne(e,t):Le(e,t),"i"),Ze=l((e,t)=>{const n={};for(const s of e){if(s.length!==1)throw new Error(`Invalid character: "${s}"`);const o=s.charCodeAt(0);n[o]=!0}return s=>{const o=s.input;let c=s.index,f=c;for(;f<o.length&&o.charCodeAt(f)in n;)f+=1;if(f>c){if(!k(t)&&!s.options.silent){const h=o.slice(c,f),v=_(t)?t(h,o,`${c}`):t;k(v)||s.output.push(v)}s.index=f}return!0}},"we"),Le=l((e,t)=>{if(Be(e))return ne(e.source,t);{const n=e.source,s=e.flags.replace(/y|$/,"y"),o=new RegExp(n,s);return Ve(e)&&_(t)&&!Ie(t)?Fe(o,t):qe(o,t)}},"$e"),Fe=l((e,t)=>n=>{const s=n.index,o=n.input;e.lastIndex=s;const c=e.exec(o);if(c){const f=e.lastIndex;if(!n.options.silent){const h=t(...c,o,`${s}`);k(h)||n.output.push(h)}return n.index=f,!0}else return!1},"Ee"),qe=l((e,t)=>n=>{const s=n.index,o=n.input;if(e.lastIndex=s,e.test(o)){const c=e.lastIndex;if(!k(t)&&!n.options.silent){const f=_(t)?t(o.slice(s,c),o,`${s}`):t;k(f)||n.output.push(f)}return n.index=c,!0}else return!1},"Ce"),ne=l((e,t)=>n=>{const s=n.index,o=n.input;if(o.startsWith(e,s)){if(!k(t)&&!n.options.silent){const c=_(t)?t(e,o,`${s}`):t;k(c)||n.output.push(c)}return n.index+=e.length,!0}else return!1},"F"),L=l((e,t,n,s)=>{const o=E(e),c=t>1;return q(F(oe(f=>{let h=0;for(;h<n;){const v=f.index;if(!o(f)||(h+=1,f.index===v))break}return h>=t},c),s))},"k"),re=l((e,t)=>L(e,0,1,t),"L"),T=l((e,t)=>L(e,0,1/0,t),"$"),Ue=l((e,t)=>L(e,1,1/0,t),"Re"),M=l((e,t)=>{const n=e.map(E);return q(F(oe(s=>{for(let o=0,c=n.length;o<c;o++)if(!n[o](s))return!1;return!0}),t))},"x"),y=l((e,t)=>{const n=e.map(E);return q(F(s=>{for(let o=0,c=n.length;o<c;o++)if(n[o](s))return!0;return!1},t))},"p"),oe=l((e,t=!0,n=!1)=>{const s=E(e);return t?o=>{const c=o.index,f=o.output.length,h=s(o);return!h&&!n&&(o.indexBacktrackMax=Math.max(o.indexBacktrackMax,o.index)),(!h||n)&&(o.index=c,o.output.length!==f&&(o.output.length=f)),h}:s},"q"),F=l((e,t)=>{const n=E(e);return t?s=>{if(s.options.silent)return n(s);const o=s.output.length;if(n(s)){const c=s.output.splice(o,1/0),f=t(c);return k(f)||s.output.push(f),!0}else return!1}:n},"B"),q=(()=>{let e=0;return t=>{const n=E(t),s=e+=1;return o=>{var c;if(o.options.memoization===!1)return n(o);const f=o.index,h=(c=o.cache)[s]||(c[s]={indexMax:-1,queue:[]}),v=h.queue;if(f<=h.indexMax){const V=h.store||(h.store=new Map);if(v.length){for(let z=0,Ht=v.length;z<Ht;z+=2){const Jt=v[z*2],Qt=v[z*2+1];V.set(Jt,Qt)}v.length=0}const j=V.get(f);if(j===!1)return!1;if(_e(j))return o.index=j,!0;if(j)return o.index=j.index,j.output?.length&&o.output.push(...j.output),!0}const N=o.output.length,Dt=n(o);if(h.indexMax=Math.max(h.indexMax,f),Dt){const V=o.index,j=o.output.length;if(j>N){const z=o.output.slice(N,j);v.push(f,{index:V,output:z})}else v.push(f,V);return!0}else return v.push(f,!1),!1}}})(),se=l(e=>{let t;return n=>(t||(t=E(e())),t(n))},"G"),E=Te(e=>{if(_(e))return Pe(e)?se(e):e;if(ee(e)||Ne(e))return p(e);if(Y(e))return M(e);if(We(e))return y(Object.values(e));throw new Error("Invalid rule")}),A=l(e=>e,"d"),Ke=l(e=>typeof e=="string","ke"),Ge=l(e=>{const t=new WeakMap,n=new WeakMap;return(s,o)=>{const c=o?.partial?n:t,f=c.get(s);if(f!==void 0)return f;const h=e(s,o);return c.set(s,h),h}},"Be"),De=l(e=>{const t={},n={};return(s,o)=>{const c=o?.partial?n:t;return c[s]??(c[s]=e(s,o))}},"Pe"),He=p(/\\./,A),Je=p(/./,A),Qe=p(/\*\*\*+/,"*"),Xe=p(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),Ye=p(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),et=T(y([He,Qe,Xe,Ye,Je])),tt=et,nt=l(e=>te(e,tt,{memoization:!1}).join(""),"Ie"),rt=nt,ae="abcdefghijklmnopqrstuvwxyz",ot=l(e=>{let t="";for(;e>0;){const n=(e-1)%26;t=ae[n]+t,e=Math.floor((e-1)/26)}return t},"Le"),ie=l(e=>{let t=0;for(let n=0,s=e.length;n<s;n++)t=t*26+ae.indexOf(e[n])+1;return t},"V"),U=l((e,t)=>{if(t<e)return U(t,e);const n=[];for(;e<=t;)n.push(e++);return n},"b"),st=l((e,t,n)=>U(e,t).map(s=>String(s).padStart(n,"0")),"qe"),ue=l((e,t)=>U(ie(e),ie(t)).map(ot),"W"),$=l(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),W=l(e=>({children:e}),"y"),S=(()=>{const e=l((t,n,s)=>{if(s.has(t))return;s.add(t);const{children:o}=t;if(!o.length)o.push(n);else for(let c=0,f=o.length;c<f;c++)e(o[c],n,s)},"e");return t=>{if(!t.length)return W([]);for(let n=t.length-1;n>=1;n--){const s=new Set,o=t[n-1],c=t[n];e(o,c,s)}return t[0]}})(),O=l(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),at=p(/\\./,$),it=p(/[$.*+?^(){}[\]\|]/,e=>$(`\\${e}`)),ut=p(/[\\\/]/,O),ct=p(/[^$.*+?^(){}[\]\|\\\/]+/,$),lt=p(/^(?:!!)*!(.*)$/,(e,t)=>$(`(?!^${xe.compile(t).source}$).*?`)),ft=p(/^(!!)+/),pt=y([lt,ft]),dt=p(/\/(\*\*\/)+/,()=>W([S([O(),$(".+?"),O()]),O()])),gt=p(/^(\*\*\/)+/,()=>W([$("^"),S([$(".*?"),O()])])),ht=p(/\/(\*\*)$/,()=>W([S([O(),$(".*?")]),$("$")])),xt=p(/\*\*/,()=>$(".*?")),ce=y([dt,gt,ht,xt]),mt=p(/\*\/(?!\*\*\/|\*$)/,()=>S([$("[^\\\\/]*?"),O()])),$t=p(/\*/,()=>$("[^\\\\/]*")),le=y([mt,$t]),fe=p("?",()=>$("[^\\\\/]")),vt=p("[",A),bt=p("]",A),wt=p(/[!^]/,"^\\\\/"),yt=p(/[a-z]-[a-z]|[0-9]-[0-9]/i,A),jt=p(/\\./,A),kt=p(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Et=p(/[\\\/]/,"\\\\/"),Ot=p(/[^$.*+?^(){}[\]\|\\\/]+/,A),At=y([jt,kt,Et,yt,Ot]),pe=M([vt,re(wt),T(At),bt],e=>$(e.join(""))),Rt=p("{","(?:"),Ct=p("}",")"),Mt=p(/(\d+)\.\.(\d+)/,(e,t,n)=>st(+t,+n,Math.min(t.length,n.length)).join("|")),St=p(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>ue(t,n).join("|")),zt=p(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>ue(t.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),Pt=y([Mt,St,zt]),de=M([Rt,Pt,Ct],e=>$(e.join(""))),It=p("{"),_t=p("}"),Wt=p(","),Nt=p(/\\./,$),Vt=p(/[$.*+?^(){[\]\|]/,e=>$(`\\${e}`)),Bt=p(/[\\\/]/,O),Tt=p(/[^$.*+?^(){}[\]\|\\\/,]+/,$),Zt=se(()=>he),Lt=p("",()=>$("(?:)")),Ft=Ue(y([ce,le,fe,pe,de,Zt,Nt,Vt,Bt,Tt]),S),ge=y([Ft,Lt]),he=M([It,re(M([ge,T(M([Wt,ge]))])),_t],W),qt=T(y([pt,ce,le,fe,pe,de,he,at,it,ut,ct]),S),Ut=qt,Kt=l(e=>te(e,Ut,{memoization:!1})[0],"kr"),Gt=Kt,K=l((e,t,n)=>K.compile(e,n).test(t),"N");K.compile=(()=>{const e=De((n,s)=>Me(Gt(rt(n)),s)),t=Ge((n,s)=>ze(n.map(o=>e(o,s))));return(n,s)=>Ke(n)?e(n,s):t(n,s)})();var xe=K;return x(I)})();return r.default||r},"_lazyMatch"),G;const on=l((r,a)=>(G||(G=me(),me=null),G(r,a)),"default");var sn=Object.defineProperty,an=H((r,a)=>sn(r,"name",{value:a,configurable:!0}),"t$1");const un=/^[A-Z]:\//i,C=an((r="")=>r&&r.replaceAll("\\","/").replace(un,a=>a.toUpperCase()),"normalizeWindowsPath");var cn=Object.defineProperty,b=H((r,a)=>cn(r,"name",{value:a,configurable:!0}),"r");const ln=/^[/\\]{2}/,fn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,be=/^[A-Z]:$/i,$e=/^\/([A-Z]:)?$/i,pn=/.(\.[^./]+)$/,dn=/^[/\\]|^[a-z]:[/\\]/i,gn=/\/$/,hn=/^win/i,xn=b(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),In="/",_n=hn.test(globalThis.process?.platform??"")?";":":",we=b((r,a)=>{let i="",u=0,g=-1,d=0,m;for(let x=0;x<=r.length;++x){if(x<r.length)m=r[x];else{if(m==="/")break;m="/"}if(m==="/"){if(!(g===x-1||d===1))if(d===2){if(i.length<2||u!==2||!i.endsWith(".")||i.at(-2)!=="."){if(i.length>2){const I=i.lastIndexOf("/");I===-1?(i="",u=0):(i=i.slice(0,I),u=i.length-1-i.lastIndexOf("/")),g=x,d=0;continue}else if(i.length>0){i="",u=0,g=x,d=0;continue}}a&&(i+=i.length>0?"/..":"..",u=2)}else i.length>0?i+=`/${r.slice(g+1,x)}`:i=r.slice(g+1,x),u=x-g-1;g=x,d=0}else m==="."&&d!==-1?++d:d=-1}return i},"normalizeString"),B=b(r=>fn.test(r),"isAbsolute"),ye=b(function(r){if(r.length===0)return".";r=C(r);const a=ln.exec(r),i=B(r),u=r.at(-1)==="/";return r=we(r,!i),r.length===0?i?"/":u?"./":".":(u&&(r+="/"),be.test(r)&&(r+="/"),a?i?`//${r}`:`//./${r}`:i&&!B(r)?`/${r}`:r)},"normalize"),Wn=b((...r)=>{let a="";for(const i of r)if(i)if(a.length>0){const u=a.at(-1)==="/",g=i[0]==="/";u&&g?a+=i.slice(1):a+=u||g?i:`/${i}`}else a+=i;return ye(a)},"join"),D=b(function(...r){r=r.map(u=>C(u));let a="",i=!1;for(let u=r.length-1;u>=-1&&!i;u--){const g=u>=0?r[u]:xn();!g||g.length===0||(a=`${g}/${a}`,i=B(g))}return a=we(a,!i),i&&!B(a)?`/${a}`:a.length>0?a:"."},"resolve");b(function(r){return C(r)},"toNamespacedPath");const mn=b(function(r){return pn.exec(C(r))?.[1]??""},"extname"),Nn=b(function(r,a){const i=D(r).replace($e,"$1").split("/"),u=D(a).replace($e,"$1").split("/");if(u[0][1]===":"&&i[0][1]===":"&&i[0]!==u[0])return u.join("/");const g=[...i];for(const d of g){if(u[0]!==d)break;i.shift(),u.shift()}return[...i.map(()=>".."),...u].join("/")},"relative"),$n=b(r=>{const a=C(r).replace(gn,"").split("/").slice(0,-1);return a.length===1&&be.test(a[0])&&(a[0]=`${a[0]}/`),a.join("/")||(B(r)?"/":".")},"dirname");b(function(r){const a=[r.root,r.dir,r.base??r.name+r.ext].filter(Boolean);return C(r.root?D(...a):a.join("/"))},"format");const vn=b((r,a)=>{const i=C(r).split("/").pop();return a&&i.endsWith(a)?i.slice(0,-a.length):i},"basename"),Vn=b(function(r){const a=dn.exec(r)?.[0]?.replaceAll("\\","/")??"",i=vn(r),u=mn(i);return{base:i,dir:$n(r),ext:u,name:i.slice(0,i.length-u.length),root:a}},"parse");b((r,a)=>on(a,ye(r)),"matchesGlob");var bn=Object.defineProperty,wn=w((r,a)=>bn(r,"name",{value:a,configurable:!0}),"s");class J extends Error{static{w(this,"VisConfigError")}static{wn(this,"VisConfigError")}chain;constructor(a,i,u){super(a,u),this.name=this.constructor.name,this.chain=i}}var yn=Object.defineProperty,jn=w((r,a)=>yn(r,"name",{value:a,configurable:!0}),"e");class Bn extends J{static{w(this,"VisConfigCycleError")}static{jn(this,"VisConfigCycleError")}constructor(a,i){const u=[...i,`${a} (re-enters)`].join(" → ");super(`Config cycle: ${u}`,i)}}var kn=Object.defineProperty,En=w((r,a)=>kn(r,"name",{value:a,configurable:!0}),"t$1");class Tn extends J{static{w(this,"VisConfigLoadError")}static{En(this,"VisConfigLoadError")}constructor(a,i,u){const g=u instanceof Error?u.message:String(u),d=i.length>0?`
|
|
2
|
+
Chain: ${i.join(" → ")}`:"";super(`Failed to load ${a}: ${g}${d}`,i,{cause:u})}}var On=Object.defineProperty,je=w((r,a)=>On(r,"name",{value:a,configurable:!0}),"t");const An=je(r=>r.join(" → "),"formatChain");class Zn extends J{static{w(this,"VisConfigNotFoundError")}static{je(this,"VisConfigNotFoundError")}constructor(a,i,u){const g=i.length>0?i[i.length-1]:"<unknown>",d=u.length>0?`
|
|
3
|
+
Tried:
|
|
4
|
+
${u.join(`
|
|
5
|
+
`)}`:"";super(`Cannot resolve "${a}" extended from ${g}.${d}
|
|
6
|
+
Chain: ${An(i)}`,i)}}var Rn=Object.defineProperty,ke=w((r,a)=>Rn(r,"name",{value:a,configurable:!0}),"i$1");const ve="@inherit",Cn=["aliases","dependsOn","inputs","outputs"],Mn=ke((r,a)=>{if(a===void 0)return r===void 0?void 0:[...r];if(!a.includes(ve))return[...a];const i=[];for(const u of a){if(u===ve){r!==void 0&&i.push(...r);continue}i.push(u)}return i},"mergeArrayWithInherit"),Ln=ke((r,a)=>{const i={...r,...a};for(const u of Cn){const g=r?.[u],d=a?.[u],m=Mn(g,d);m===void 0?delete i[u]:i[u]=m}return i},"mergeTargetWithInherit");var R;(function(r){r[r.UNSET=0]="UNSET",r[r.OK=1]="OK",r[r.ERROR=2]="ERROR"})(R||(R={}));var Sn=Object.defineProperty,P=w((r,a)=>Sn(r,"name",{value:a,configurable:!0}),"i");const Fn=P(r=>{const{renameSpan:a,tracer:i}=r;let u;const g=new Map;return Yt({hooks:{"run:after":P(d=>{if(!u)return;const m=[...d.values()].filter(x=>x.status==="failure").length;u.setAttribute("vis.run.tasks_total",d.size),u.setAttribute("vis.run.tasks_failed",m),m>0?u.setStatus({code:R.ERROR,message:`${String(m)} task(s) failed`}):u.setStatus({code:R.OK}),u.end(),u=void 0;for(const x of g.values())x.end();g.clear()},"run:after"),"run:before":P(d=>{u&&(u.setStatus({code:R.ERROR,message:"run:before fired while previous run was still active"}),u.end());for(const m of g.values())m.end();g.clear(),u=i.startSpan("vis.run",{attributes:{"vis.run.task_count":d.tasks.length,"vis.workspace_root":d.workspaceRoot}})},"run:before"),"task:after":P((d,m)=>{const x=g.get(d.id);x&&(x.setAttribute("vis.task.exit_code",m.code??0),x.setAttribute("vis.task.cache_status",m.status),x.end(),g.delete(d.id))},"task:after"),"task:before":P(d=>{const m=g.get(d.id);m&&(m.setStatus({code:R.ERROR,message:"retried — superseded by new attempt"}),m.end());const x=i.startSpan(a?a(d):d.id,{attributes:{"vis.task.id":d.id,"vis.task.project":d.target.project,"vis.task.target":d.target.target}});g.set(d.id,x)},"task:before"),"task:failure":P((d,m)=>{const x=g.get(d.id);x&&x.setStatus({code:R.ERROR,message:`Task failed with exit code ${String(m.code??-1)}`})},"task:failure")},name:"otel"})},"otelPlugin");export{D as C,$n as K,Wn as M,B as O,vn as Q,Bn as V,Tn as a,Zn as b,Vn as c,_n as j,Ln as m,Fn as o,In as y,Nn as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var T=Object.defineProperty;var j=(n,e)=>T(n,"name",{value:e,configurable:!0});import{createRequire as A}from"node:module";import{findUp as R,findUpSync as U}from"@visulima/fs";const B=A(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=j(n=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[e,t]=h.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return h.getBuiltinModule(n)}return B(n)},"__cjs_getBuiltinModule"),{createRequire:N}=q("node:module");var C=Object.defineProperty,z=j((n,e)=>C(n,"name",{value:e,configurable:!0}),"L"),I=Object.defineProperty,S=z((n,e)=>I(n,"name",{value:e,configurable:!0}),"F");const J=N(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=S(n=>{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(n)}return J(n)},"__cjs_getBuiltinModule"),{readFileSync:Y}=$("node:fs"),{readFile:Z}=$("node:fs/promises");var K=Object.defineProperty,l=S((n,e)=>K(n,"name",{value:e,configurable:!0}),"g");const G={sha256:"sha256",sha384:"sha384",sha512:"sha512"},H=1024,Q=/^[A-Z0-9+/]+={0,2}$/i,V=/.*node_modules\/((?:@[^/]+\/)?[^/]+)$/,k=/^['"]/,v=/['"]$/,X=/^[a-z][a-zA-Z0-9]*:\s*$/m,ee=/resolution:\s*\{[^}]*integrity:\s*([^,}\s]+)/,ne=/^["']?((?:@[^/@"']+\/)?[^@"'\n]+)@[^"'\n]+["']?:?[\t\v\f\r \u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*\n((?:[\t ][^\n]*\n?)+)/gm,te=/^\s+version:?\s+"?([^"\n]+)"?/m,se=/^\s+integrity[\s:]+"?([^"\s]+)"?/m,x=l(n=>{if(n.length>H)return;const e=n.indexOf("-");if(e<=0)return;const t=G[n.slice(0,e).toLowerCase()];if(!t)return;const s=n.slice(e+1);if(Q.test(s))try{const i=Buffer.from(s,"base64");return i.length===0?void 0:{algorithm:t,hex:i.toString("hex")}}catch{return}},"decodeSriIntegrity"),w=l((n,e,t)=>{const s=`${t.name}@${t.version}`;e.has(s)||(e.add(s),n.push(t))},"pushUniqueEntry"),m=l((n,e,t)=>{t&&Object.keys(t).length>0&&(n[e]={...t})},"copyDepMap"),g=l(n=>{if(!n)return;const e={};for(const[t,s]of Object.entries(n))e[t]=[s];return Object.keys(e).length>0?e:void 0},"liftDepMap"),re=l(n=>{const e=[],t=new Set;let s;try{s=JSON.parse(n)}catch{return e}if(!s.packages)return e;for(const[i,r]of Object.entries(s.packages)){if(!i||!r.version)continue;const p=V.exec(i);if(!p?.[1])continue;const c=r.name??p[1];if(c.startsWith("."))continue;const o={name:c,version:r.version};if(r.integrity){const a=x(r.integrity);a&&(o.integrity=a)}m(o,"dependencies",g(r.dependencies)),m(o,"peerDependencies",g(r.peerDependencies)),m(o,"optionalDependencies",g(r.optionalDependencies)),w(e,t,o)}return e},"parseNpmLockFile"),_=l(n=>{let e=n.trim();e.startsWith("/")&&(e=e.slice(1)),e=e.replace(k,"").replace(v,"");const t=e.indexOf("(");t>0&&(e=e.slice(0,t));const s=e.lastIndexOf("@");if(s<=0)return;const i=e.slice(0,s),r=e.slice(s+1);if(!(!i||!r||r.startsWith("link:")||r.startsWith("workspace:")||r.startsWith("file:")))return{name:i,version:r}},"splitPnpmPackageKey"),W=l((n,e)=>{const t=new RegExp(String.raw`^${e}:\s*$`,"m").exec(n);if(!t)return;const s=t.index+t[0].length,i=X.exec(n.slice(s));return n.slice(s,i?s+i.index:n.length)},"sliceTopLevelSection"),oe=l(n=>{const e=new Map,t=W(n,"snapshots");if(!t)return e;const s=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let i;for(;(i=s.exec(t)??void 0)!==void 0;){const r=_(i[1]);if(!r)continue;const p=`${r.name}@${r.version}`,c=i[2],o=e.get(p)??{};for(const a of["dependencies","peerDependencies","optionalDependencies"]){const u=b(c,a);if(!u)continue;const d=o[a]??{};for(const[f,P]of Object.entries(u)){const D=d[f]??[];for(const F of P)D.includes(F)||D.push(F);d[f]=D}o[a]=d}e.set(p,o)}return e},"parsePnpmSnapshotEdges"),ie=l(n=>{const e=[],t=new Set,s=W(n,"packages");if(!s)return e;const i=oe(n),r=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let p;for(;(p=r.exec(s)??void 0)!==void 0;){const c=_(p[1]);if(!c)continue;const o=p[2],a=ee.exec(o),u={name:c.name,version:c.version};if(a?.[1]){const f=x(a[1]);f&&(u.integrity=f)}const d=i.get(`${c.name}@${c.version}`);m(u,"dependencies",d?.dependencies??b(o,"dependencies")),m(u,"peerDependencies",d?.peerDependencies??b(o,"peerDependencies")),m(u,"optionalDependencies",d?.optionalDependencies??b(o,"optionalDependencies")),w(e,t,u)}return e},"parsePnpmLockFile"),b=l((n,e)=>{const t=new RegExp(String.raw`^ {4}${e}:\s*\n((?: {6,}[^\n]*\n?)+)`,"m").exec(n);if(!t?.[1])return;const s={},i=/^ {6}([^\s:]+):\s*([^\n]+)/gm;let r;for(;(r=i.exec(t[1])??void 0)!==void 0;){const p=r[1].replace(k,"").replace(v,"");let c=r[2].trim();c=c.replace(k,"").replace(v,"");const o=c.indexOf("(");if(o>0&&(c=c.slice(0,o).trim()),!p||!c)continue;const a=s[p]??[];a.includes(c)||a.push(c),s[p]=a}return Object.keys(s).length>0?s:void 0},"extractPnpmDependencyMap"),ce=l(n=>{const e=[],t=new Set,s=ne;s.lastIndex=0;let i;for(;(i=s.exec(n)??void 0)!==void 0;){const r=i[1].replace(k,"").replace(v,"");if(!r)continue;const p=i[2],c=te.exec(p);if(!c?.[1])continue;const o={name:r,version:c[1].trim()},a=se.exec(p);if(a?.[1]){const u=x(a[1]);u&&(o.integrity=u)}m(o,"dependencies",O(p,"dependencies")),m(o,"peerDependencies",O(p,"peerDependencies")),m(o,"optionalDependencies",O(p,"optionalDependencies")),w(e,t,o)}return e},"parseYarnLockFile"),O=l((n,e)=>{const t=new RegExp(String.raw`^ {2}${e}:\s*\n((?: {4,}[^\n]*\n?)+)`,"m").exec(n);if(!t?.[1])return;const s={},i=/^ {4}(['"]?[^\s:'"]+['"]?)\s*(?::\s*)?['"]([^'"\n]+)['"]/gm;let r;for(;(r=i.exec(t[1])??void 0)!==void 0;){const p=r[1].replace(k,"").replace(v,""),c=r[2];if(p&&c){const o=s[p]??[];o.includes(c)||o.push(c),s[p]=o}}return Object.keys(s).length>0?s:void 0},"extractYarnDependencyMap"),pe=/,(?=\s*[}\]])/g,ae=l(n=>{const e=[],t=new Set;let s;try{s=JSON.parse(n.replaceAll(pe,""))}catch{return e}if(!s.packages)return e;for(const i of Object.values(s.packages)){const r=i[0];if(typeof r!="string")continue;const p=r.indexOf("@",1);if(p<=0)continue;const c=r.slice(0,p),o=r.slice(p+1);if(!c||!o||o.startsWith("workspace:")||o.startsWith("link:")||o.startsWith("file:"))continue;const a={name:c,version:o},u=i[3];if(typeof u=="string"&&u.length>0){const f=x(u);f&&(a.integrity=f)}const d=i[2];if(d&&typeof d=="object"&&!Array.isArray(d)){const f=d;m(a,"dependencies",g(f.dependencies)),m(a,"peerDependencies",g(f.peerDependencies)),m(a,"optionalDependencies",g(f.optionalDependencies))}w(e,t,a)}return e},"parseBunLockFile"),E=l(n=>{if(n.endsWith("pnpm-lock.yaml"))return"pnpm";if(n.endsWith("package-lock.json"))return"npm";if(n.endsWith("yarn.lock"))return"yarn";if(n.endsWith("bun.lock"))return"bun"},"inferLockFileType"),L=l((n,e)=>{switch(e){case"bun":return ae(n);case"npm":return re(n);case"pnpm":return ie(n);case"yarn":return ce(n);default:return[]}},"parseLockFileContent"),M=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock"];l(async n=>{const e=await R(M,{type:"file",...n&&{cwd:n}});if(!e)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lock)");const t=E(e);if(!t)throw new Error(`Unsupported lock file: ${e}`);const s=await Z(e,"utf8");return{entries:L(s,t),path:e,type:t}},"parseLockFile");l(n=>{const e=U(M,{type:"file",...n&&{cwd:n}});if(!e)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lock)");const t=E(e);if(!t)throw new Error(`Unsupported lock file: ${e}`);return{entries:L(Y(e,"utf8"),t),path:e,type:t}},"parseLockFileSync");export{L as F};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../packem_chunks/applyDefaults.js";import{o as e}from"./index-OlP7U_t5.js";export{e as otelPlugin};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var b=Object.defineProperty;var c=(e,t)=>b(e,"name",{value:t,configurable:!0});import{createRequire as D}from"node:module";import{ensureDir as L,isAccessible as x,readJson as m}from"@visulima/fs";import{M as l}from"./index-OlP7U_t5.js";import{aj as I}from"../packem_chunks/bin.js";const R=D(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=c(e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[t,r]=u.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return u.getBuiltinModule(e)}return R(e)},"__cjs_getBuiltinModule"),{Socket:T}=p("node:net"),{randomBytes:k}=p("node:crypto"),{readdir:M,writeFile:$,rename:j,rm:d,open:P,readFile:A,stat:F,unlink:y}=p("node:fs/promises");var N=Object.defineProperty,o=c((e,t)=>N(e,"name",{value:t,configurable:!0}),"s");const O=3e4,v=100;class q extends Error{static{c(this,"ServiceReadinessError")}constructor(t,r){super(t),this.elapsedMs=r,this.name="ServiceReadinessError"}elapsedMs;static{o(this,"ServiceReadinessError")}}const C=o(async e=>{const t=e.host??"127.0.0.1",{port:r}=e,s=e.timeoutMs??O,i=Date.now();for(;Date.now()-i<s;){if(await B(t,r))return;await J(v)}throw new q(`Timed out waiting for ${t}:${String(r)} to accept TCP connections (${String(s)}ms)`,Date.now()-i)},"waitForTcp"),B=o((e,t)=>new Promise(r=>{const s=new T,i=o(n=>{s.removeAllListeners(),s.destroy(),r(n)},"onDone");s.once("connect",()=>{i(!0)}),s.once("error",()=>{i(!1)}),s.setTimeout(v,()=>{i(!1)});try{s.connect(t,e)}catch{i(!1)}}),"tryConnect"),J=o(e=>new Promise(t=>{setTimeout(t,e)}),"delay"),it=o(async(e,t)=>{const r=e.readiness??(e.port===void 0?void 0:{tcp:{port:e.port}});r&&await C({host:r.tcp.host,port:r.tcp.port,timeoutMs:t?.timeoutMs??r.tcp.timeoutMs})},"runReadiness");var W=Object.defineProperty,a=c((e,t)=>W(e,"name",{value:t,configurable:!0}),"o");const g=384,h=5e3,G=50,V=3e4,w=a(async e=>{const t=l(I(e),"services");try{await L(t)}catch(r){throw r.code==="ENOTDIR"?new Error(`Service registry path ${t} exists but is not a directory. Remove it or move the conflicting file before running \`vis service\`.`,{cause:r}):r}return t},"getRegistryDir"),E=a(e=>e.replaceAll("/","_").replaceAll(":","__"),"slugify"),f=a((e,t)=>l(e,`${E(t)}.json`),"entryPath"),X=a((e,t)=>l(e,`${E(t)}.lock`),"lockPath"),_=a(async(e,t)=>{const r=await w(e),s=f(r,t);if(await x(s))try{return await m(s)}catch{return}},"readEntry"),Y=a(async e=>{const t=await w(e);let r;try{r=await M(t)}catch{return[]}const s=[];for(const i of r)if(i.endsWith(".json"))try{const n=await m(l(t,i));s.push(n)}catch{}return s},"readAllEntries"),st=a(async(e,t)=>{const r=await w(e),s=f(r,t.id),i=l(r,`.${k(8).toString("hex")}.tmp`);await $(i,`${JSON.stringify(t,void 0,2)}
|
|
2
|
+
`,{mode:g});try{await j(i,s)}catch(n){throw await d(i,{force:!0}).catch(()=>{}),n}},"writeEntry"),z=a(async(e,t,r)=>{const s=await w(e),i=r??await _(e,t);await d(f(s,t),{force:!0}),i&&await d(i.logFile,{force:!0}).catch(()=>{})},"deleteEntry"),S=a(e=>{try{return process.kill(e,0),!0}catch{return!1}},"isAlive"),at=a(async e=>{const t=await Y(e),r=[],s=[];for(const i of t){if(S(i.pid)){s.push(i);continue}const n=await _(e,i.id);if(n&&n.pid!==i.pid){s.push(n);continue}await z(e,i.id,i).catch(()=>{}),r.push(i.id)}return{pruned:r,surviving:s}},"pruneDead"),H=a(e=>new Promise(t=>{setTimeout(t,e)}),"sleep"),K=a(async e=>{try{const t=await P(e,"wx",g);try{await t.writeFile(String(process.pid))}finally{await t.close().catch(()=>{})}return!0}catch(t){if(t.code==="EEXIST")return!1;throw t}},"tryClaimLock"),Q=a(async e=>{let t;try{const r=await A(e,"utf8"),s=Number.parseInt(r.trim(),10);t=Number.isFinite(s)?s:void 0}catch{return!0}if(t!==void 0&&!S(t))return!0;try{const r=await F(e);return Date.now()-r.mtimeMs>V}catch{return!0}},"isLockStale"),nt=a(async(e,t,r)=>{const s=await w(e),i=X(s,t),n=Date.now();for(;!await K(i);){if(await Q(i)){await y(i).catch(()=>{});continue}if(Date.now()-n>=h)throw new Error(`Could not acquire service lock for ${t} within ${String(h)}ms — another \`vis service\` invocation appears to be holding it.`);await H(G)}try{return await r()}finally{await y(i).catch(()=>{})}},"withServiceLock");export{g as R,q as S,st as a,it as b,Y as c,z as d,w as g,S as i,at as p,_ as r,E as s,nt as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var y=Object.defineProperty;var d=(e,s)=>y(e,"name",{value:s,configurable:!0});import{createRequire as j}from"node:module";import{M as m}from"./index-OlP7U_t5.js";const M=j(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=d(e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[s,t]=u.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return u.getBuiltinModule(e)}return M(e)},"__cjs_getBuiltinModule"),{readdir:p,stat:l,readFile:h}=_("node:fs/promises");var k=Object.defineProperty,c=d((e,s)=>k(e,"name",{value:s,configurable:!0}),"m");const b=c((e,s)=>e.tasks.find(t=>t.taskId===s),"findTaskInSummary"),f=c((e,s)=>{const t=e??{},i=s??{},n=[],r=[],a=[];for(const o of Object.keys(t))o in i?t[o]!==i[o]&&a.push(o):n.push(o);for(const o of Object.keys(i))o in t||r.push(o);return n.sort(),r.sort(),a.sort(),{added:n,changed:a,removed:r}},"diffHashBuckets"),R=c((e,s)=>({commandChanged:(e?.command??"")!==(s?.command??""),implicitDeps:f(e?.implicitDeps,s?.implicitDeps),nodes:f(e?.nodes,s?.nodes),runtime:f(e?.runtime,s?.runtime)}),"diffHashDetails"),w=c(async(e,s)=>{const t=m(e,".task-runner","runs",`${s}.json`);try{const i=await h(t,"utf8");return JSON.parse(i)}catch{return}},"readRunSummaryById"),B=c(async(e,s)=>{const t=m(e,".task-runner","runs");let i;try{i=await p(t)}catch{return}const n=[];for(const r of i){if(!r.endsWith(".json")||s!==void 0&&r===`${s}.json`)continue;const a=m(t,r);try{const o=await l(a);o.isFile()&&n.push({mtimeMs:o.mtimeMs,path:a})}catch{}}if(n.length!==0){n.sort((r,a)=>a.mtimeMs-r.mtimeMs);try{const r=await h(n[0].path,"utf8");return JSON.parse(r)}catch{return}}},"readPreviousRunSummary"),D=c(async e=>{const s=m(e,".task-runner","runs");let t;try{t=await p(s)}catch{return[]}const i=[];for(const n of t){if(!n.endsWith(".json"))continue;const r=m(s,n);try{const a=await l(r);a.isFile()&&i.push({id:n.slice(0,-5),mtimeMs:a.mtimeMs,path:r})}catch{}}return i.sort((n,r)=>r.mtimeMs-n.mtimeMs),i},"listRunSummaries");export{B as a,R as d,b as f,D as l,w as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var f=(t,s)=>d(t,"name",{value:s,configurable:!0});import{isAccessibleSync as h,readFileSync as k,readJsonSync as v}from"@visulima/fs";import{M as m}from"./index-OlP7U_t5.js";var y=Object.defineProperty,g=f((t,s)=>y(t,"name",{value:s,configurable:!0}),"p");const M=g(t=>{for(const s of[".nvmrc",".node-version"]){const i=m(t,s);if(h(i))try{return k(i).trim().replace(/^v/,"")}catch{}}},"readNodeVersionFile"),l=g((t,s)=>{const i=t.split(/[.\-+]/).map(r=>Number.parseInt(r,10)||0),c=s.split(/[.\-+]/).map(r=>Number.parseInt(r,10)||0),e=Math.max(i.length,c.length);for(let r=0;r<e;r++){const n=i[r]??0,a=c[r]??0;if(n!==a)return n-a}return 0},"compareVersions"),$=g((t,s)=>{const i=s.trim();if(i===""||i==="*")return!0;const c=i.split(/\s+/).filter(Boolean);for(const e of c)if(e.startsWith(">=")){if(l(t,e.slice(2).trim())<0)return!1}else if(e.startsWith("<=")){if(l(t,e.slice(2).trim())>0)return!1}else if(e.startsWith(">")){if(l(t,e.slice(1).trim())<=0)return!1}else if(e.startsWith("<")){if(l(t,e.slice(1).trim())>=0)return!1}else if(/^\d/.test(e)){const r=t.split("."),n=e.split(".");for(const[a,o]of n.entries())if(o!==r[a])return!1}return!0},"satisfiesRange"),N=g(t=>{const s=[],i=m(t,"package.json");let c;try{c=v(i)}catch{return s}const e=process.versions.node;if(c.engines?.node){const n=c.engines.node;$(e,n)||s.push({actual:e,expected:n,kind:"node",message:`package.json engines.node requires ${n}, but the current Node.js is ${e}.`,severity:"error"})}const r=M(t);if(r){const[n,a]=r.split("."),[o,p]=e.split(".");(n!==o||a!==void 0&&a!==p)&&s.push({actual:e,expected:r,kind:"node",message:`.nvmrc pins Node ${r} but the current Node.js is ${e}. Run \`nvm use\` or switch runtimes.`,severity:"warning"})}if(c.packageManager){const[n,a]=c.packageManager.split("@"),o=(process.env.npm_config_user_agent??"").split(" ")[0]??"",[p,u]=o.split("/");p&&n&&p!==n?s.push({actual:p,expected:n,kind:"packageManager",message:`package.json packageManager pins ${c.packageManager} but the current invocation is ${o}. Install the correct package manager.`,severity:"error"}):u&&a&&u!==a&&s.push({actual:u,expected:a,kind:"packageManager",message:`package.json packageManager pins ${n}@${a} but the current invocation uses ${n}@${u}.`,severity:"warning"})}return s},"checkRuntimeVersions");export{N as c};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var w=Object.defineProperty;var m=(e,t)=>w(e,"name",{value:t,configurable:!0});import{createRequire as v}from"node:module";import{z as b}from"./index-OlP7U_t5.js";const k=v(import.meta.url),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=m(e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,r]=j.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return j.getBuiltinModule(e)}return k(e)},"__cjs_getBuiltinModule"),{createInterface:$}=_("node:readline");var T=Object.defineProperty,f=m((e,t)=>T(e,"name",{value:t,configurable:!0}),"g");const q=/^#([\w\-/]+):(.+)$/,x=/^([@\w\-/]+):(.+)$/,P=f(e=>{if(e==="")return;if(e.startsWith(":"))return{kind:"all",target:e.slice(1)};if(e.startsWith("~:"))return{kind:"closest",target:e.slice(2)};const t=q.exec(e);if(t?.[1]&&t[2])return{kind:"tag",tag:t[1],target:t[2]};const r=x.exec(e);return r?.[1]&&r[2]&&(r[1].startsWith("@")||r[1].includes("/")||r[1].includes("-"))?{kind:"project",projects:[r[1]],target:r[2]}:{kind:"all",target:e}},"parseTargetSelector"),N=f(async(e,t,r,a)=>{const s=P(e);if(!s)throw new Error(`Invalid target selector: "${e}"`);const c=Object.keys(t.projects);if(s.kind==="all")return{projects:c,target:s.target};if(s.kind==="project")return{projects:s.projects??[],target:s.target};if(s.kind==="tag"){const o=s.tag;return{projects:c.filter(i=>t.projects[i]?.tags?.includes(o)??!1),target:s.target}}const n=b(a,r)||".";let p,l=-1;for(const[o,i]of Object.entries(t.projects)){const u=i.root;u&&(n===u||n.startsWith(`${u}/`))&&u.length>l&&(l=u.length,p=o)}if(!p){if(process.stdout.isTTY){const o=$({input:process.stdin,output:process.stderr}),i=Object.keys(t.projects).sort();process.stderr.write(`No project found at ${n}. Pick one:
|
|
2
|
+
`);for(const[d,h]of i.entries())process.stderr.write(` ${String(d+1)}) ${h}
|
|
3
|
+
`);const u=await new Promise(d=>{o.question("> ",d)});o.close();const g=Number.parseInt(u,10)-1;if(g>=0&&g<i.length)return{projects:[i[g]],target:s.target}}throw new Error(`No project found at or above ${n} for selector "${e}".`)}return{projects:[p],target:s.target}},"resolveSelector"),E=/^(\w+)\s*(!?=)\s*(.+)$/,Q=f(e=>{const t=e.trim();if(t==="")return;const r=t.split("&&").map(o=>o.trim()),a=t.split("||").map(o=>o.trim()),s=r.length>1,c=a.length>1;if(s&&c)throw new Error("Query language does not support mixed && / || — split into multiple --query flags or simplify.");const n=c?a:r,p=c?"||":"&&",l=[];for(const o of n){const i=E.exec(o);if(!i)throw new Error(`Invalid query clause: "${o}". Expected <field>=<value> or <field>!=<value>.`);const[,u,g,d]=i;l.push({field:u,op:g==="!="?"!=":"=",value:d.trim().replaceAll(/^["']|["']$/g,"")})}return{clauses:l,op:p}},"parseQuery"),y=f((e,t,r)=>{const{field:a,op:s,value:c}=e,n=f(l=>{const o=l===c;return s==="="?o:!o},"test"),p=f(l=>{const o=(l??[]).includes(c);return s==="="?o:!o},"testList");switch(a){case"id":case"project":return n(t);case"language":return n(r.language);case"layer":return n(r.layer);case"projectType":case"type":return n(r.projectType);case"stack":return n(r.stack);case"tag":case"tags":return p(r.tags);default:return!1}},"matchClause"),O=f((e,t,r)=>{if(!r||r.trim()==="")return e;const a=Q(r);return a?e.filter(s=>{const c=t.projects[s];return c?a.op==="&&"?a.clauses.every(n=>y(n,s,c)):a.clauses.some(n=>y(n,s,c)):!1}):e},"filterProjectsByQuery");export{O as f,P as p,N as r};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var N=Object.defineProperty;var x=(o,e)=>N(o,"name",{value:e,configurable:!0});import{createRequire as I}from"node:module";import{isAccessibleSync as d,readFileSync as k,readJsonSync as S}from"@visulima/fs";import{M as g,j as H,y as R}from"./index-OlP7U_t5.js";const B=I(import.meta.url),M=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=x(o=>{if(typeof M<"u"&&M.versions&&M.versions.node){const[e,n]=M.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return M.getBuiltinModule(o)}return B(o)},"__cjs_getBuiltinModule"),{execFileSync:w}=j("node:child_process"),{randomBytes:D}=j("node:crypto"),{writeFileSync:U,renameSync:q,unlinkSync:J}=j("node:fs");var z=Object.defineProperty,f=x((o,e)=>z(o,"name",{value:e,configurable:!0}),"f");const V=["proto","mise","fnm","volta","asdf","nvm","corepack"],Z={asdf:["bun","deno","go","node","npm","pnpm","python","ruby","rust","yarn"],corepack:["npm","pnpm","yarn"],fnm:["node"],mise:["bun","deno","go","node","npm","pnpm","python","ruby","rust","yarn"],nvm:["node"],proto:["bun","deno","go","node","npm","pnpm","python","ruby","rust","yarn"],volta:["node","npm","pnpm","yarn"]},X=["proto","mise","fnm","volta","asdf","nvm","corepack"],O={asdf:[".tool-versions"],corepack:[],fnm:[".nvmrc",".node-version"],mise:[".mise.toml",".config/mise.toml","mise.toml"],nvm:[".nvmrc"],proto:[".prototools"],volta:[]},$=new Map,y=f(o=>{const e=$.get(o);if(e!==void 0||$.has(o))return e;const n=process.env.PATH;if(!n){$.set(o,void 0);return}const t=process.platform==="win32"?["",...(process.env.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";")]:[""];for(const r of n.split(H)){const i=r.replaceAll(/^["']|["']$/g,"").trim();if(i!=="")for(const l of t){const s=`${i}${R}${o}${l}`;if(d(s))return $.set(o,s),s}}$.set(o,void 0)},"isOnPath"),W=f((o,e=["--version"])=>{try{const n=w(o,e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3}),t=/\d+\.\d+(?:\.\d+)?/.exec(n);return t?t[0]:n.trim()||void 0}catch{return}},"queryManagerVersion"),A=f((o,e)=>{const n=g(o,"package.json");if(!d(n))return[];try{const t=S(n)[e];if(e==="volta"&&typeof t=="object"&&t!==null&&Object.keys(t).length>0)return["package.json"];if(e==="packageManager"&&typeof t=="string"&&t.length>0)return["package.json"]}catch{}return[]},"pkgFieldConfigFiles"),G=f((o,e)=>o==="volta"?A(e,"volta"):o==="corepack"?A(e,"packageManager"):O[o].filter(n=>d(g(e,n))),"configFilesFor"),P=new Map,K=f(()=>{P.clear(),$.clear()},"clearToolchainCache"),_=f((o,e)=>{if(!e?.refresh){const i=P.get(o);if(i)return i}const n=[],t=!!y("pnpm")||!!y("yarn");for(const i of X){const l=i==="nvm"?void 0:y(i),s=i==="nvm"&&!!process.env.NVM_DIR,c=G(i,o),a=!!l||s;i==="corepack"&&!a&&(!(c.length>0)||t)||!a&&c.length===0||n.push({binPath:l,configFiles:c,installed:a,name:i,version:l?W(l):void 0})}const r=Object.freeze(n);return P.set(o,r),r},"findInstalledManagers"),be=f((o,e,n)=>{const t=n??_(o);return e?.preferredManager&&e.preferredManager!=="none"?t.find(r=>r.name===e.preferredManager)??{configFiles:[],installed:!1,name:e.preferredManager}:t.find(r=>r.installed&&r.configFiles.length>0)??t.find(r=>r.installed)??t.find(r=>r.configFiles.length>0)??{configFiles:[],installed:!1,name:"none"}},"pickPrimaryManager"),L=f((o,e)=>{for(const n of e){const t=g(o,n);if(d(t))try{const r=k(t).trim();if(r!=="")return{name:n,value:r.replace(/^v/,"")}}catch{}}},"readVersionFile"),Q=/^([a-z][\w-]*)\s*=\s*"?([^"\n#]+?)"?\s*(?:#.*)?$/i,Y=f(o=>{const e=g(o,".prototools");if(!d(e))return[];const n=k(e),t=[];let r=!1;for(const i of n.split(/\r?\n/)){const l=i.trim();if(l===""||l.startsWith("#"))continue;if(l.startsWith("[")){r=!0;continue}if(r)continue;const s=Q.exec(l);if(!s)continue;const[,c,a]=s,u=h(c);u&&t.push({source:".prototools",tool:u,version:a.trim()})}return t},"parsePrototools"),ee=/^\[tools\]\s*$/i,oe=/^([a-z][\w-]*)\s*=\s*"?([^"\n#]+?)"?\s*(?:#.*)?$/i,ne=f(o=>{for(const e of O.mise){const n=g(o,e);if(!d(n))continue;const t=[],r=k(n);let i=!1;for(const l of r.split(/\r?\n/)){const s=l.trim();if(s===""||s.startsWith("#"))continue;if(s.startsWith("[")){i=ee.test(s);continue}if(!i)continue;const c=oe.exec(s);if(!c)continue;const[,a,u]=c,m=h(a);m&&t.push({source:".mise.toml",tool:m,version:u.trim()})}if(t.length>0)return t}return[]},"parseMiseToml"),te=f(o=>{const e=g(o,".tool-versions");if(!d(e))return[];const n=k(e),t=[];for(const r of n.split(/\r?\n/)){const i=r.trim();if(i===""||i.startsWith("#"))continue;const l=i.split(/\s+/);if(l.length<2)continue;const[s,...c]=l,a=h(s);a&&c[0]&&t.push({source:".tool-versions",tool:a,version:c[0]})}return t},"parseToolVersions"),h=f(o=>{switch(o.toLowerCase()){case"bun":return"bun";case"deno":return"deno";case"go":case"golang":return"go";case"node":case"nodejs":return"node";case"npm":return"npm";case"pnpm":return"pnpm";case"python":case"python3":return"python";case"ruby":return"ruby";case"rust":case"rustc":return"rust";case"yarn":return"yarn";default:return}},"normalizeToolName"),re=f(o=>{const[e]=o.split("+",1),n=/^(pnpm|yarn|npm|bun)@(.+)$/.exec(e??"");if(!n)return;const t=h(n[1]);if(t)return{source:"packageManager",tool:t,version:n[2]}},"parsePackageManagerField"),se=f((o,e)=>{const n=new Map,t=f(s=>{n.set(s.tool,s)},"add"),r=g(o,"package.json");let i={};try{d(r)&&(i=S(r))}catch{}if(i.engines)for(const[s,c]of Object.entries(i.engines)){const a=h(s);a&&typeof c=="string"&&t({source:"engines",tool:a,version:c})}if(i.packageManager){const s=re(i.packageManager);s&&t(s)}if(i.volta)for(const[s,c]of Object.entries(i.volta)){const a=h(s);a&&typeof c=="string"&&t({source:"volta",tool:a,version:c})}const l=L(o,[".nvmrc",".node-version"]);l&&t({source:l.name===".nvmrc"?".nvmrc":".node-version",tool:"node",version:l.value});for(const s of te(o))t(s);for(const s of ne(o))t(s);for(const s of Y(o))t(s);if(e?.tools)for(const[s,c]of Object.entries(e.tools)){const a=h(s);a&&typeof c=="string"&&t({source:"vis.config.ts",tool:a,version:c})}return[...n.values()]},"parseExpectedTools"),F={bun:{args:["--version"],binaries:["bun"]},deno:{args:["--version"],binaries:["deno"]},go:{args:["version"],binaries:["go"]},node:{args:["--version"],binaries:["node"]},npm:{args:["--version"],binaries:["npm"]},pnpm:{args:["--version"],binaries:["pnpm"]},python:{args:["--version"],binaries:["python","python3"]},ruby:{args:["--version"],binaries:["ruby"]},rust:{args:["--version"],binaries:["rustc"]},yarn:{args:["--version"],binaries:["yarn"]}},ie=f(o=>{const e=F[o];for(const n of e.binaries){const t=y(n);if(t)return W(t,e.args)}if(o==="node")return process.versions.node},"queryToolVersion"),ae=f((o,e)=>{const n=e.trim();if(n===""||n==="*"||n==="latest")return!0;if(/^\d[\d.]*$/.test(n))return o===n||o.startsWith(`${n}.`);const t=f(s=>s.split(/[.\-+]/).map(c=>Number.parseInt(c,10)||0),"parse"),r=f((s,c)=>{const a=t(s),u=t(c),m=Math.max(a.length,u.length);for(let p=0;p<m;p++){const b=a[p]??0,v=u[p]??0;if(b!==v)return b-v}return 0},"compare"),i=f(s=>{for(const c of s)if(c.startsWith(">=")){if(r(o,c.slice(2).trim())<0)return!1}else if(c.startsWith("<=")){if(r(o,c.slice(2).trim())>0)return!1}else if(c.startsWith(">")){if(r(o,c.slice(1).trim())<=0)return!1}else if(c.startsWith("<")){if(r(o,c.slice(1).trim())>=0)return!1}else if(c.startsWith("^")||c.startsWith("~")){const a=c.slice(1).trim(),[u,m]=t(a),[p,b]=t(o);if(p!==u||c.startsWith("~")&&b!==m||r(o,a)<0)return!1}return!0},"matchesAll"),l=n.split("||").map(s=>s.trim().split(/\s+/).filter(Boolean)).filter(s=>s.length>0);return l.length===0?!0:l.some(s=>i(s))},"satisfies"),ce=f((o,e)=>{switch(o){case".mise.toml":return["mise"];case".node-version":case".nvmrc":return["fnm","nvm","volta","proto","mise","asdf"];case".prototools":return["proto"];case".tool-versions":return["asdf","mise"];case"packageManager":return e==="pnpm"||e==="yarn"?["self-activate","volta","proto","mise","corepack"]:e==="npm"?["volta","proto","mise","asdf","corepack"]:e==="bun"?["proto","mise","asdf"]:["volta","proto","mise"];case"volta":return["volta"];default:return["proto","mise","fnm","volta","asdf","nvm","corepack"]}},"preferenceFor"),le=f((o,e,n)=>{if(n?.preferredManager&&n.preferredManager!=="none"&&T(n.preferredManager,o.tool)){const r=e.find(i=>i.name===n.preferredManager);return r?{installed:r.installed,name:r.name}:{installed:!1,name:n.preferredManager,note:`${n.preferredManager} is the preferred manager but isn't on PATH`}}const t=ce(o.source,o.tool);for(const r of t){if(r==="self-activate"){if((o.tool==="pnpm"||o.tool==="yarn")&&y(o.tool))return{installed:!0,name:"self-activate",note:`${o.tool} will activate ${o.version} from the packageManager field on next invocation`};continue}if(T(r,o.tool)&&e.find(i=>i.name===r)?.installed)return{installed:!0,name:r}}for(const r of t)if(!(r==="self-activate"||!T(r,o.tool)))return{installed:!1,name:r,note:`${r} can install ${o.tool} — run \`vis toolchain install\` after adding it to PATH`};return{installed:!1,name:"none",note:"No manager knows how to install this tool"}},"resolveManagerFor"),T=f((o,e)=>o==="none"?!1:o==="self-activate"?e==="pnpm"||e==="yarn":Z[o].includes(e),"canHandle"),fe=f((o,e)=>{const n=_(o),t=se(o,e).map(r=>{const i=ie(r.tool),l=i!==void 0&&ae(i,r.version),s=le(r,n,e);return{actual:i,expected:r,manager:s,matches:l}});return{detected:n,tools:t}},"getToolchainStatus"),pe=f((o,e)=>{switch(o){case"asdf":return e?{args:["install",e.tool,e.version],bin:"asdf"}:void 0;case"corepack":return e?{args:["prepare",`${e.tool}@${e.version}`,"--activate"],bin:"corepack"}:{args:["prepare","--activate"],bin:"corepack",hint:"reads the packageManager field in package.json"};case"fnm":return e?.tool!=="node"?void 0:{args:["install",e.version],bin:"fnm"};case"mise":return e?{args:["install",`${e.tool}@${e.version}`],bin:"mise"}:void 0;case"none":return;case"nvm":return{args:[],bin:"nvm",hint:"nvm is a shell function — run `nvm install` / `nvm use` from your shell"};case"proto":return e?{args:["install",e.tool,e.version],bin:"proto"}:void 0;case"self-activate":return{args:[],bin:e?.tool??"pnpm",hint:`${e?.tool??"pnpm"} will self-activate on next invocation — no install needed`};case"volta":return e?{args:["install",`${e.tool}@${e.version}`],bin:"volta"}:{args:["install","node@lts"],bin:"volta",hint:"volta pins per-tool; specify <tool>@<version>"};default:{const n=o;throw new Error(`Unknown manager: ${n}`)}}},"buildInstallInvocation"),$e=f((o,e)=>{switch(o){case"asdf":return{args:["local",e.tool,e.version],bin:"asdf",configChange:{file:".tool-versions",hint:`Pins ${e.tool} ${e.version}`}};case"corepack":return e.tool!=="npm"&&e.tool!=="pnpm"&&e.tool!=="yarn"?void 0:{args:["use",`${e.tool}@${e.version}`],bin:"corepack",configChange:{file:"package.json",hint:`Writes packageManager: "${e.tool}@${e.version}"`}};case"fnm":return e.tool==="node"?{args:["use",e.version],bin:"fnm"}:void 0;case"mise":return{args:["use","--",`${e.tool}@${e.version}`],bin:"mise",configChange:{file:".mise.toml",hint:`Pins ${e.tool} ${e.version}`}};case"none":return;case"nvm":return e.tool==="node"?{args:[],bin:"nvm",configChange:{file:".nvmrc",hint:"Write version to .nvmrc manually (nvm doesn't persist)."}}:void 0;case"proto":return{args:["pin",e.tool,e.version],bin:"proto",configChange:{file:".prototools",hint:`Pins ${e.tool} ${e.version}`}};case"self-activate":return{args:[],bin:e.tool,configChange:{file:"package.json",hint:`Set packageManager: "${e.tool}@${e.version}" — ${e.tool} will self-activate on next invocation`}};case"volta":return{args:["pin",`${e.tool}@${e.version}`],bin:"volta",configChange:{file:"package.json",hint:`Writes volta.${e.tool}`}};default:{const n=o;throw new Error(`Unknown manager: ${n}`)}}},"buildUseInvocation"),ke=f(o=>{for(const e of F[o].binaries){const n=y(e);if(n)return n}},"findOnPathByAlias"),Me=f((o,e)=>{const n=F[e].binaries;if(o.installed&&o.binPath&&(o.name==="proto"||o.name==="mise"||o.name==="asdf"||o.name==="volta"||o.name==="fnm"))for(const t of n)try{const r=w(o.binPath,["which",t],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();if(r)return r}catch{}for(const t of n){const r=y(t);if(r)return r}},"resolveToolBinary"),E=f((o,e)=>{const n=`${o}.${process.pid}.${D(6).toString("hex")}.tmp`;U(n,e);try{q(n,o)}catch(t){try{J(n)}catch{}throw t}},"atomicWrite"),ue=f((o,e)=>{if("packageManager"in o)return o.packageManager=e,o;const n={};let t=!1;for(const[r,i]of Object.entries(o))!t&&(r==="dependencies"||r==="devDependencies"||r==="peerDependencies"||r==="optionalDependencies")&&(n.packageManager=e,t=!0),n[r]=i;return t||(n.packageManager=e),n},"insertPackageManagerKey"),we=f((o,e)=>{if(e.tool!=="pnpm"&&e.tool!=="yarn"&&e.tool!=="npm"&&e.tool!=="bun")return;const n=g(o,"package.json");if(!d(n))throw new Error(`Cannot pin ${e.tool}: ${n} does not exist.`);const t=k(n),r=/\n([ \t]+)/.exec(t)?.[1]??" ";let i;try{i=JSON.parse(t)}catch(a){throw new Error(`${n} is not valid JSON — fix it before running \`vis toolchain use\`. Underlying error: ${a.message}`,{cause:a})}const l=`${e.tool}@${e.version}`,s=ue(i,l),c=t.endsWith(`
|
|
2
|
+
`)?`
|
|
3
|
+
`:"";return E(n,`${JSON.stringify(s,void 0,r)}${c}`),l},"writePackageManagerField"),xe=f((o,e)=>{const n=g(o,"package.json");if(!d(n))return;const t=k(n);let r;try{r=JSON.parse(t)}catch(s){throw new Error(`${n} is not valid JSON — fix it before running \`vis toolchain use\`. Underlying error: ${s.message}`,{cause:s})}if(r.engines?.[e.tool]===void 0||r.engines[e.tool]===e.version)return;r.engines[e.tool]=e.version;const i=/\n([ \t]+)/.exec(t)?.[1]??" ",l=t.endsWith(`
|
|
4
|
+
`)?`
|
|
5
|
+
`:"";return E(n,`${JSON.stringify(r,void 0,i)}${l}`),e.version},"updateEnginesField"),Te=f(o=>{const e=/^([a-z][\w-]*)@(.+)$/i.exec(o.trim());if(!e)return;const n=h(e[1]);if(n)return{source:"vis.config.ts",tool:n,version:e[2]}},"parseUseArgument"),de=f(async(o,e,n)=>{const t=fe(o,e),r=t.tools.filter(a=>!a.matches);if(r.length===0)return{attempted:[],failed:[],upToDate:!0};const i=t.detected.some(a=>a.installed);if(!(e?.autoInstall??i))return{attempted:[],failed:[],upToDate:!1};const l=[],s=[],c=new Map;for(const a of r){const u=c.get(a.manager.name);u?u.push(a):c.set(a.manager.name,[a])}for(const[a,u]of c){if(a==="self-activate"){for(const{expected:p}of u)n.info(`toolchain: ${p.tool} ${p.version} will self-activate on next ${p.tool} invocation`),l.push(p);continue}if(a==="none"){for(const{expected:p}of u)s.push({error:`no manager can install ${p.tool} — install one of ${V.join(", ")}`,spec:p});continue}if(!t.detected.find(p=>p.name===a)?.installed){for(const{expected:p}of u)s.push({error:`${a} is not on PATH`,spec:p});continue}const m=u.map(p=>({invocation:pe(a,p.expected),tool:p})).filter(p=>p.invocation!==void 0);for(const{invocation:p,tool:b}of m){const{expected:v}=b;if(p.bin==="nvm"&&p.args.length===0){n.warn(`toolchain: nvm requires a shell-side activation for ${v.tool} ${v.version}. Run \`nvm install\` / \`nvm use\` manually.`),s.push({error:"nvm requires shell-side activation",spec:v});continue}n.info(`toolchain: $ ${p.bin} ${p.args.join(" ")}`);try{w(p.bin,p.args,{cwd:o,stdio:"inherit"}),l.push(v),a==="fnm"&&ge(p.bin,n)}catch(C){s.push({error:C.message,spec:v});break}}}return K(),{attempted:l,failed:s,upToDate:!1}},"ensureToolchain"),Pe=f(async(o,e,n,t=!1)=>{if(t)return;const r=await de(o,e,n);for(const i of r.failed)n.warn(`toolchain: ${i.spec.tool} ${i.spec.version} — ${i.error}`)},"runToolchainPreflight"),ge=f((o,e)=>{const n=process.platform==="win32"?"powershell":"bash";try{const t=w(o,["env","--shell",n],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3});for(const r of t.split(/\r?\n/)){const i=r.trim();if(i==="")continue;const l=/^\$env:([A-Z_]\w*)\s*=\s*(.+)$/i.exec(i);if(l){const[,a,u]=l;process.env[a]=u.replaceAll(/^["']|["']$/g,"");continue}const s=/^set\s+"?([A-Z_]\w*)=(.*?)"?$/i.exec(i);if(s){const[,a,u]=s;process.env[a]=u;continue}const c=/^(?:export\s+)?([A-Z_]\w*)=(.+)$/i.exec(i);if(c){const[,a,u]=c;process.env[a]=u.replaceAll(/^["']|["']$/g,"")}}}catch(t){e.warn(`toolchain: could not activate fnm env (${t.message}). Subsequent tasks may use the previous Node version.`)}},"activateFnmEnv");export{V as S,le as a,pe as b,$e as c,Me as d,ke as e,_ as f,fe as g,be as h,Te as p,Pe as r,xe as u,we as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var q=Object.defineProperty;var l=(e,s)=>q(e,"name",{value:s,configurable:!0});import{createRequire as $}from"node:module";import{az as M,p as i,d as b,e as k}from"../packem_chunks/bin.js";import{isAccessibleSync as A,readJsonSync as C}from"@visulima/fs";import{M as D}from"./index-OlP7U_t5.js";const z=$(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=l(e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[s,r]=m.versions.node.split(".").map(Number);if(s>22||s===22&&r>=3||s===20&&r>=16)return m.getBuiltinModule(e)}return z(e)},"__cjs_getBuiltinModule"),{createInterface:T}=_("node:readline");var O=["aj","aju","av","avj","ejv","jav","jv"],S=["angula","angular-node","angularjs"],F=["auto-prefixer"],N=["aaxios","aios","axio","axioos","axios-node","axioss","axis","axiso","axois","axos","axxios"],P=["abel","babbel","babe","babel-js","babel-node","babl","bable","bbael","bebel"],B=["bcrpyt","bcrypt-node","brcypt","crypt","dcrypt"],R=["bcryptjs-node","dcryptjs"],W=["bunan","bunya","bunyan-node","buynan"],L=["cai","cha","chaijs","chal","chi","chia","hai"],E=["cahlk","calk","cchalk","ch4lk","cha1k","chaalk","chaik","chak","chakl","chalk-node","chalkk","challk","chhalk","chlak","chlk","halk","hcalk"],J=["cheero","cherio"],U=["c0lor","ccolor","clor","colo","coloor","color-js","colorjs","colorr","colr","coolor","coolr"],V=["ccolors","colors-node","colorss","colorz","colrs","coolors"],I=["c0mmander","ccommander","cmmander","cmomander","co-mmander","comamnder","comander","comm4nder","commaander","commader","commadner","commamder","command3r","commandder","commande","commandeer","commander-js","commanderr","commandr","commandre","commanedr","commaner","commannder","commender","commmander","commnader","commnder","coommander","ocmmander","ommander"],Y=["cor","corss","cos","cosr","cros","crs","ors"],G=["days"],H=["d3bug","dbeug","dbug","ddebug","debbug","debg","debgu","debu","debu9","debug-js","debug-node","debugg","debugjs","debuug","deebug","deubg","deug","ebug","edbug"],K=["dot-env","dotenv-node","dotenvjs","dotevn"],Q=["3lectron","eectron","eelctron","eelectron","el3ctron","elcetron","elctron","elecctron","elecron","elecrton","electon","electorn","electr0n","electrn","electrno","electro","electrom","electron-node","electronn","electroon","electrron","electtron","eleectron","eletcron","eletron","ellectron","lectron","leectron"],X=["asbuild","ebuild","esbuild-node","esbuildjs","ezbuild","sbuild"],Z=["aslint","elint","eslint-js","eslint-node","eslit","ezlint","slint"],ee=["eexpress","epress","epxress","experss","expess","exppress","expreess","expres","express-node","expressjs","expresss","exprress","exprses","exprss","exress","exrpess","exxpress","xepress","xpress"],oe=["astify"],se=["firebasejs"],re=["form1dable"],ae=["glb","glo","glob-js","globjs","gob","golb","lob"],te=["go","goot","gotjs","gott","gt","gto","ogt","ot","qot"],ne=["helmetjs","helnet"],ce=["homo","hon","hoo","hoon","ohno","ono"],ie=["inquire","inquirer-js","nquirer"],de=["iredis"],me=["ejst","est","jast","jes","jestjs","jestt","jet","jets","jst"],le=["imp","jim","jip","jmp"],pe=["ji","jio","jo","joii","jol","oi","oji"],ue=["jdom","jsdm","jsdo","jsdom-js","jsdon","jsom","sdom"],ve=["jsonwebtoken-js","jsonwebtoken-node"],he=["ka","kao","ko","koaa","koajs","koe","oa","oka"],je=["1odash","iodash","l0dash","ldash","ldoash","llodash","lo-dash","loadsh","loash","lobash","lod4sh","lodaash","lodah","lodahs","lodas","lodash-node","lodashh","lodassh","loddash","lodesh","lodsah","lodsh","loodash","odash","oldash"],be=["luca","luci","lucie"],ke=["luon","luxo","luxon-js"],ge=["imcromatch","mciromatch","micormatch","micrmoatch","micro-match","microamtch","micromacth","micromathc","micromtach","mircomatch"],fe=["minimath"],ye=["mcha","mmocha","moca","moch","mocha-js","moha","nocha","ocha"],xe=["m0ment","mment","mmoent","mmoment","moemnt","moent","mom3nt","momeent","momemt","momen","momen7","momennt","moment-js","momentjs","momentt","momet","mometn","momment","momnet","momnt","monent","mooment","oment","omment"],we=["mognoose","mogoose","mongoos","mongose","monqoose","moongoose"],qe=["moran","organ"],$e=["muler","multer-js","muter"],ze=["mysql"],_e=["ext","mext","n3xt","naxt","net","netx","nex","next-js","next-node","nextjs","nxt"],Te=["node-mailer","nodemailer-js"],Me=["nodemo","nodemonjs","nodmeon"],Ae=["oar","or","ora-node","ore","ra","roa"],Ce=["arcel","parce","parceljs"],De=["passport-js"],Oe=["phase","phaser-node"],Se=["ino","pimo","pin","pino-node","pinojs","pio","pion"],Fe=["playright","playwright-js"],Ne=["postcss-js","postcss-node","potscss"],Pe=["pettier","pprettier","pretier","prettierjs","prettierr","prtetier"],Be=["prima","prism","prisma-js","prismajs","prizma"],Re=["pupeteer"],We=["rada","rama","ramd","randa"],Le=["eact","eract","r3act","raact","ract","raect","re4ct","reaact","reac","reac7","reacct","react-node","reactjs","reactt","reat","reatc","recat","rect","reeact","reect","rreact"],Ee=["erdis","radis","rdis","redi","redis-js","redis-node","rediss","rediz","reds","reis","rredis"],Je=["resen","rsend"],Ue=["ollup","rollup-js","rollup-node"],Ve=["ass","asss","sas","sass-node","sess","ssas","sss"],Ie=["emver","seemver","semver-node","semvre","senver","sever"],Ye=["sequelize-js","sequelize-node"],Ge=["harp","shap","shar","sharp-js","sharpjs"],He=["stipe","strip","stripe-node","tripe"],Ke=["supabase-js"],Qe=["suelte","svelt3","svelte-js","sveltejs","velte"],Xe=["tailwindcss-js"],Ze=["auri","taui"],eo=["hree","htree","thee","there","three-js","three-node","tree"],oo=["stx","sx","ts","tsxx","ttsx","tx","txs","tzx"],so=["ttypescript","typecript","typescipt","typescript-node","typescriptjs","typescrit","typescritp"],ro=["udnerscore","undercore","underscoer","underscore-node","underscroe","undersocre","undesrcore"],ao=["uid","uud","uudi","uui","uuid-js","uuid-node","uuidjs","vuid"],to=["ite","vie","vit","vita","vite-node","vitee","vlte","vte"],no=["itest","uitest","vitestjs","vitezt","vittest","vtest"],co=["ue","uue","uve","ve","veu","vu","vu3","vua","vue-node","vuee","vuejs","vuue","vve","vvue"],io=["web-pack","weback","webpac","webpack-node","webpackjs","webpak","weebpack","wepack","wepback"],mo=["winson","winston-js","winstoon"],lo=["up","uyp","yp","yu","yupjs","yupp"],po=["od","zd","zdo","zo","zob","zod-js","zodjs"];const uo={ajv:O,angular:S,autoprefixer:F,"aws-sdk":["awssdk","ews-sdk"],axios:N,babel:P,bcrypt:B,bcryptjs:R,"body-parser":["body-paresr","body-parse","body-parser-js","body_parser"],bunyan:W,chai:L,chalk:E,cheerio:J,color:U,colors:V,commander:I,"cookie-parser":["cookie-parse","cookieparser"],cors:Y,"cross-env":["crossenv"],"date-fns":["data-fns","date-fn"],dayjs:G,debug:H,dotenv:K,electron:Q,esbuild:X,eslint:Z,express:ee,fastify:oe,firebase:se,formidable:re,glob:ae,got:te,helmet:ne,hono:ce,inquirer:ie,ioredis:de,jest:me,jimp:le,joi:pe,jsdom:ue,jsonwebtoken:ve,koa:he,lodash:je,lucia:be,luxon:ke,micromatch:ge,minimatch:fe,mocha:ye,moment:xe,mongoose:we,morgan:qe,multer:$e,mysql2:ze,next:_e,"node-fetch":["node-fecth","node-fethc","node.fetch"],nodemailer:Te,nodemon:Me,ora:Ae,parcel:Ce,passport:De,phaser:Oe,pino:Se,playwright:Fe,postcss:Ne,prettier:Pe,prisma:Be,puppeteer:Re,ramda:We,react:Le,"react-dom":["eact-dom","eract-dom","r3act-dom","ract-dom","raect-dom","re4ct-dom","reaact-dom","reac-dom","reac7-dom","reacct-dom","react-bom","react-d0m","react-ddom","react-dm","react-dmo","react-do","react-domm","react-don","react-doom","react-odm","react-om","react.dom","reactdom","reactt-dom","reat-dom","reatc-dom","recat-dom","rect-dom","reeact-dom","rreact-dom"],redis:Ee,resend:Je,rollup:Ue,sass:Ve,semver:Ie,sequelize:Ye,sharp:Ge,"socket.io":["ocket.io","oscket.io","scket.io","scoket.io","soccket.io","socekt.io","socet.io","sock3t.io","socke.io","socke7.io","sockeet.io","socket.1o","socket.i","socket.iio","socket.ioo","socket.lo","socket.o","socket.oi","sockett.io","sockket.io","sockt.io","sockte.io","sokcet.io","soket.io","soocket.io","ssocket.io"],stripe:He,supabase:Ke,svelte:Qe,tailwindcss:Xe,tauri:Ze,three:eo,"ts-node":["tts-node"],tsx:oo,typescript:so,underscore:ro,uuid:ao,vite:to,vitest:no,vue:co,webpack:io,winston:mo,yup:lo,zod:po};var v,g;function vo(){return g||(g=1,v={"@tanstack/start":["start-tanstack-app","tanstack","tanstack-app","tanstack-start"]}),v}l(vo,"requireTyposquatsManual");var ho=vo();const jo=M(ho);var bo=Object.defineProperty,n=l((e,s)=>bo(e,"name",{value:s,configurable:!0}),"c");const ko={a:["4","e"],b:["d"],d:["b"],e:["3","a"],g:["9","q"],i:["1","l"],l:["1","i"],m:["n"],n:["m"],o:["0"],s:["5","z"],t:["7"],u:["v"],v:["u"]},go=["app","cli","core","kit","lib","pkg","sdk"],fo=n(e=>{const s=new Set;if(e.length<3)return s;for(let o=0;o<e.length;o++){const a=e[o],t=a==="-"||a==="."||a==="_";if(t||s.add(e.slice(0,o)+e.slice(o+1)),t||s.add(e.slice(0,o)+a+e.slice(o)),o<e.length-1&&e[o]!==e[o+1]){const u=e[o+1]==="-"||e[o+1]==="."||e[o+1]==="_";if(!t&&!u){const d=[...e];[d[o],d[o+1]]=[d[o+1],d[o]],s.add(d.join(""))}}const c=e[o].toLowerCase(),j=ko[c];if(j)for(const u of j)s.add(e.slice(0,o)+u+e.slice(o+1))}const r=/[-._]/g;if(r.test(e))s.add(e.replaceAll(r,"")),s.add(e.replaceAll(r,"-")),s.add(e.replaceAll(r,".")),s.add(e.replaceAll(r,"_"));else if(e.length>5)for(let o=2;o<e.length-2;o++)s.add(`${e.slice(0,o)}-${e.slice(o)}`),s.add(`${e.slice(0,o)}.${e.slice(o)}`),s.add(`${e.slice(0,o)}_${e.slice(o)}`);if(e.startsWith("@")||(s.add(`${e}-js`),s.add(`${e}js`),s.add(`${e}-node`)),e.startsWith("@")){const o=e.indexOf("/");if(o>1&&o<e.length-1){const a=e.slice(1,o),t=e.slice(o+1);a.length>=3&&s.add(a);for(const c of["","-",".","_"])s.add(`${a}${c}${t}`),s.add(`${t}${c}${a}`);for(const c of go)s.add(`${a}-${c}`),s.add(`${t}-${a}-${c}`),s.add(`${c}-${a}-${t}`)}}return s.delete(e),s},"generateVariants");let h,p;const f=n(()=>{if(!h){const e={};for(const s of[uo,jo])for(const[r,o]of Object.entries(s)){const a=e[r]??(e[r]=[]);for(const t of o)a.includes(t)||a.push(t)}h=e}return h},"loadBlocklist"),yo=n(()=>{if(!p){p=new Map;for(const[e,s]of Object.entries(f()))for(const r of s)p.set(r,e)}return p},"getReverseLookup"),xo=n(e=>e.startsWith("@")?e.split("/")[1]??e:e,"bareName"),wo=n(e=>{const s=xo(e),r=yo().get(s);if(r)return{input:e,legitimate:r,method:"blocklist"};for(const o of Object.keys(f()))if(fo(o).has(s))return{input:e,legitimate:o,method:"heuristic"}},"checkTyposquat"),y=n((e,s)=>{const r=s?new Set(s):void 0,o=[];for(const a of e){if(r?.has(a))continue;const t=wo(a);t&&o.push(t)}return o},"checkTyposquats"),x=n((e,s)=>{i.warn(""),i.warn(b(`Possible typosquat${e.length===1?"":"s"} ${s}:`));for(const r of e){const o=r.method==="blocklist"?"known typosquat":"similar name";i.warn(` ${k("⚠")} ${b(r.input)} — did you mean ${k(r.legitimate)}? (${o})`)}i.warn("")},"printTyposquatWarnings"),w=n(async e=>{if(!process.stdin.isTTY){i.warn("Aborting: potential typosquat detected in non-interactive mode. Use --no-typosquat-check to skip.");return}const s=T({input:process.stdin,output:process.stdout}),r=await new Promise(o=>{s.question(e,a=>{o(a.trim().toLowerCase())})});return s.close(),r},"askConfirmation"),Do=n(async(e,s)=>{const r=y(e,s);if(r.length===0)return{ok:!0,packages:e};x(r,"detected");const o=await w(`Use suggested package${r.length===1?"":"s"} instead? [S]uggested / [y]es, keep original / [N]o, abort (default: N) `);if(o===void 0)return{ok:!1,packages:e};if(o==="s"||o==="suggested"){const a=new Map(r.map(t=>[t.input,t.legitimate]));return{ok:!0,packages:e.map(t=>a.get(t)??t)}}return o==="y"||o==="yes"?{ok:!0,packages:e}:{ok:!1,packages:e}},"runTyposquatCheck"),qo=/^(?:npm|pnpm|yarn):(.+?)(?:@.*)?$/,$o=n(e=>qo.exec(e)?.[1],"parseAliasTarget"),zo=n(e=>{if(!A(e))return[];const s=C(e),r={...s.dependencies,...s.devDependencies,...s.optionalDependencies,...s.peerDependencies},o=new Set;for(const[a,t]of Object.entries(r)){o.add(a);const c=$o(t);c&&o.add(c)}return[...o]},"readDepsFromPackageJson"),Oo=n(async(e,s)=>{const r=D(e,"package.json"),o=zo(r);if(o.length===0)return!0;const a=y(o,s);if(a.length===0)return!0;x(a,"in package.json dependencies"),i.warn("Fix the package name in package.json before proceeding.");const t=await w("Continue anyway? [y/N] ");return t==="y"||t==="yes"},"scanDepsForTyposquats");export{Do as r,Oo as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=Object.defineProperty;var y=(n,s)=>u(n,"name",{value:s,configurable:!0});import{createRequire as m}from"node:module";import{isAccessibleSync as i,readFileSync as f}from"@visulima/fs";import{readYamlSync as $}from"@visulima/fs/yaml";import{M as a}from"./index-OlP7U_t5.js";const j=m(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=y(n=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[s,e]=k.versions.node.split(".").map(Number);if(s>22||s===22&&e>=3||s===20&&e>=16)return k.getBuiltinModule(n)}return j(n)},"__cjs_getBuiltinModule"),{readdirSync:v}=b("node:fs");var w=Object.defineProperty,l=y((n,s)=>w(n,"name",{value:s,configurable:!0}),"o");const S=[".husky/pre-commit",".vis-hooks/pre-commit",".git/hooks/pre-commit"],_=[".secretlintrc",".secretlintrc.json",".secretlintrc.js",".secretlintrc.mjs",".secretlintrc.cjs",".secretlintrc.yml",".secretlintrc.yaml"],D=[".syncpackrc",".syncpackrc.json",".syncpackrc.yaml",".syncpackrc.yml",".syncpackrc.cjs",".syncpackrc.js",".syncpackrc.mjs",".syncpackrc.ts","syncpack.config.cjs","syncpack.config.js","syncpack.config.mjs","syncpack.config.ts"],M=l(n=>{const s=a(n,"package.json");if(!i(s))return[];let e;try{e=JSON.parse(f(s))}catch{return[]}const o=[];if(e.scripts)for(const[t,c]of Object.entries(e.scripts))typeof c=="string"&&(/\bgitleaks\b/.test(c)&&o.push({detail:`Script "${t}" still invokes gitleaks: ${c}`,kind:"script",location:"package.json",tool:"gitleaks"}),/\bsecretlint\b/.test(c)&&o.push({detail:`Script "${t}" still invokes secretlint: ${c}`,kind:"script",location:"package.json",tool:"secretlint"}),/\bsyncpack\b/.test(c)&&o.push({detail:`Script "${t}" still invokes syncpack: ${c}`,kind:"script",location:"package.json",tool:"syncpack"}),/\bsherif\b/.test(c)&&o.push({detail:`Script "${t}" still invokes sherif: ${c}`,kind:"script",location:"package.json",tool:"sherif"}));if(e.devDependencies)for(const t of Object.keys(e.devDependencies))(t==="gitleaks"||t==="@gitleaks/cli")&&o.push({detail:`devDependency \`${t}\` is still installed`,kind:"devDep",location:"package.json",tool:"gitleaks"}),(t==="secretlint"||t.startsWith("@secretlint/"))&&o.push({detail:`devDependency \`${t}\` is still installed`,kind:"devDep",location:"package.json",tool:"secretlint"}),t==="syncpack"&&o.push({detail:`devDependency \`${t}\` is still installed`,kind:"devDep",location:"package.json",tool:"syncpack"}),t==="sherif"&&o.push({detail:`devDependency \`${t}\` is still installed`,kind:"devDep",location:"package.json",tool:"sherif"});return e.sherif&&o.push({detail:"`sherif` config block still present in package.json",kind:"config",location:"package.json",tool:"sherif"}),o},"scanPackageJson"),O=l(n=>{const s=[];for(const e of S){const o=a(n,e);if(!i(o))continue;const t=f(o);/\bgitleaks\b/.test(t)&&s.push({detail:"gitleaks invocation still present in hook",kind:"hook",location:e,tool:"gitleaks"}),/\bsecretlint\b/.test(t)&&s.push({detail:"secretlint invocation still present in hook",kind:"hook",location:e,tool:"secretlint"}),/\bsyncpack\b/.test(t)&&s.push({detail:"syncpack invocation still present in hook",kind:"hook",location:e,tool:"syncpack"}),/\bsherif\b/.test(t)&&s.push({detail:"sherif invocation still present in hook",kind:"hook",location:e,tool:"sherif"})}return s},"scanHooks"),C=l(n=>{const s=[];for(const e of _)i(a(n,e))&&s.push({detail:"secretlint config should be removed after migration",kind:"config",location:e,tool:"secretlint"});for(const e of D)i(a(n,e))&&s.push({detail:"syncpack config should be removed after migration",kind:"config",location:e,tool:"syncpack"});return s},"scanConfigs"),N=[".github/workflows",".gitlab-ci.yml",".circleci/config.yml",".woodpecker.yml",".drone.yml"],q=l(n=>{const s=[],e=l(o=>{const t=a(n,o);if(!i(t))return;const c=f(t);/\bsyncpack\b/.test(c)&&s.push({detail:"syncpack invocation still present in CI",kind:"ci",location:o,tool:"syncpack"}),/\bsherif\b/.test(c)&&s.push({detail:"sherif invocation still present in CI",kind:"ci",location:o,tool:"sherif"})},"scanFile");for(const o of N){const t=a(n,o);if(i(t)){if(o===".github/workflows"){try{for(const c of v(t))(c.endsWith(".yml")||c.endsWith(".yaml"))&&e(`.github/workflows/${c}`)}catch{}continue}e(o)}}return s},"scanCi"),A=l(n=>{const s=[],e=a(n,"pnpm-workspace.yaml");if(i(e)){let t;try{t=$(e)}catch{t=void 0}if(t&&typeof t=="object"){const c=t.catalog;c&&typeof c.syncpack=="string"&&s.push({detail:"`syncpack` still listed in pnpm-workspace.yaml#catalog",kind:"catalog",location:"pnpm-workspace.yaml",tool:"syncpack"});const r=t.catalogs;if(r&&typeof r=="object")for(const[d,p]of Object.entries(r))p&&typeof p.syncpack=="string"&&s.push({detail:`\`syncpack\` still listed in pnpm-workspace.yaml#catalogs.${d}`,kind:"catalog",location:"pnpm-workspace.yaml",tool:"syncpack"})}}const o=a(n,"package.json");if(i(o)){let t;try{t=JSON.parse(f(o))}catch{return s}const c=t.workspaces;if(c&&typeof c=="object"&&!Array.isArray(c)){const d=c.catalog;d&&typeof d.syncpack=="string"&&s.push({detail:"`syncpack` still listed in package.json#workspaces.catalog",kind:"catalog",location:"package.json",tool:"syncpack"});const p=c.catalogs;if(p&&typeof p=="object")for(const[h,g]of Object.entries(p))g&&typeof g.syncpack=="string"&&s.push({detail:`\`syncpack\` still listed in package.json#workspaces.catalogs.${h}`,kind:"catalog",location:"package.json",tool:"syncpack"})}const r=t.catalog;r&&typeof r.syncpack=="string"&&s.push({detail:"`syncpack` still listed in package.json#catalog",kind:"catalog",location:"package.json",tool:"syncpack"})}return s},"scanCatalogs"),F=l(n=>[...M(n),...O(n),...C(n),...q(n),...A(n)],"scanMigrationLeftovers"),B=l((n,s)=>{const e=F(n);if(e.length===0)return s.info("✓ No unmigrated gitleaks/secretlint/sherif/syncpack references found."),[];s.warn(`Found ${String(e.length)} unmigrated reference(s):`);for(const o of e)s.warn(` [${o.kind}] ${o.location} — ${o.detail}`);return e},"verifyMigration");export{F as s,B as v};
|