jsrepo 2.2.1 → 2.2.2
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/dist/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{n as CONFIG_FILE,m as MANIFEST_FILE,j as accessLevel,q as azure,r as bitbucket,d as blockSchema,e as categorySchema,h as configFileSchema,B as fetchManifest,A as fetchRaw,s as github,t as gitlab,u as http,x as jsrepo,i as manifestConfigFileSchema,f as manifestMeta,k as manifestSchema,g as peerDependencySchema,y as providers,z as selectProvider}from'../chunk-
|
|
1
|
+
export{n as CONFIG_FILE,m as MANIFEST_FILE,j as accessLevel,q as azure,r as bitbucket,d as blockSchema,e as categorySchema,h as configFileSchema,B as fetchManifest,A as fetchRaw,s as github,t as gitlab,u as http,x as jsrepo,i as manifestConfigFileSchema,f as manifestMeta,k as manifestSchema,g as peerDependencySchema,y as providers,z as selectProvider}from'../chunk-SWGNQXLV.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import*as o from'valibot';import y from'chalk';var Q=o.object({name:o.string(),category:o.string(),localDependencies:o.array(o.string()),dependencies:o.array(o.string()),devDependencies:o.array(o.string()),tests:o.boolean(),list:o.optional(o.boolean(),true),directory:o.string(),subdirectory:o.boolean(),files:o.array(o.string()),_imports_:o.record(o.string(),o.string())}),
|
|
1
|
+
import*as o from'valibot';import y from'chalk';var Q=o.object({name:o.string(),category:o.string(),localDependencies:o.array(o.string()),dependencies:o.array(o.string()),devDependencies:o.array(o.string()),tests:o.boolean(),list:o.optional(o.boolean(),true),directory:o.string(),subdirectory:o.boolean(),files:o.array(o.string()),_imports_:o.record(o.string(),o.string())}),A=o.object({name:o.string(),blocks:o.array(Q)}),J=o.object({authors:o.optional(o.array(o.string())),bugs:o.optional(o.string()),description:o.optional(o.string()),homepage:o.optional(o.string()),repository:o.optional(o.string()),tags:o.optional(o.array(o.string()))}),q=o.record(o.string(),o.union([o.string(),o.object({version:o.string(),message:o.string()})])),K=o.object({name:o.string(),path:o.string(),expectedPath:o.optional(o.string()),optional:o.optional(o.boolean(),false)}),V=o.object({...K.entries,dependencies:o.optional(o.array(o.string())),devDependencies:o.optional(o.array(o.string()))}),X=o.union([o.literal("public"),o.literal("private"),o.literal("marketplace")]),F=o.object({name:o.optional(o.string()),version:o.optional(o.string()),meta:o.optional(J),access:o.optional(X),peerDependencies:o.optional(q),configFiles:o.optional(o.array(V)),categories:o.array(A)});var _="jsrepo-manifest.json",ae="jsrepo.json";var Z="main",b={name:"azure",matches:r=>r.toLowerCase().startsWith("azure"),parse:(r,e)=>{let t=O(r,e);return {url:t.url,specifier:t.specifier}},baseUrl:r=>{let{owner:e,repoName:t}=O(r,{fullyQualified:false});return `https://dev.azure.com/${e}/_git/${t}`},state:async r=>{let{url:e,owner:t,project:i,repoName:a,ref:s,refs:n}=O(r,{fullyQualified:false});return {owner:t,repoName:a,ref:s,refs:n,project:i,url:e,provider:b}},resolveRaw:async(r,e)=>{if(r.provider.name!==b.name)throw new Error(`You passed the incorrect state object (${r.provider.name}) to the ${b.name} provider.`);let{owner:t,repoName:i,project:a,ref:s,refs:n}=r,p=n==="tags"?"tag":"branch";return new URL(`https://dev.azure.com/${t}/${a}/_apis/git/repositories/${i}/items?path=${e}&api-version=7.2-preview.1&versionDescriptor.version=${s}&versionDescriptor.versionType=${p}`)},authHeader:r=>["Authorization",`Bearer ${r}`],formatFetchError:(r,e)=>`There was an error fetching \`${y.bold(e)}\` from ${y.bold(r.url)}.
|
|
2
2
|
|
|
3
3
|
${y.bold("This may be for one of the following reasons:")}
|
|
4
4
|
1. Either \`${y.bold(e)}\` or the containing repository doesn't exist
|
|
5
5
|
2. Your repository path is incorrect (wrong branch, wrong tag)
|
|
6
6
|
3. You are using an expired access token or a token that doesn't have access to this repository
|
|
7
7
|
4. The cached state for this git provider is incorrect (try using ${y.bold("--no-cache")})
|
|
8
|
-
`};function O(r,{fullyQualified:e}){let t=r.replaceAll(/(azure\/)/g,""),[i,a,n
|
|
8
|
+
`};function O(r,{fullyQualified:e}){let t=r.replaceAll(/(azure\/)/g,""),[i,a,s,...n]=t.split("/"),p;e&&(p=n.slice(n.length-2).join("/"),n=n.slice(0,n.length-2));let c=Z,l="heads";return ["tags","heads"].includes(n[0])&&(l=n[0],n[1]&&n[1]!==""&&(c=n[1])),{url:`azure/${i}/${a}/${s}${c?`/${l}/${c}`:""}`,owner:i,repoName:s,project:a,ref:c,refs:l,specifier:p}}function h(r,e){for(let t of e)if(r.startsWith(t))return t}function ue(r,e){for(let t of e)if(r.endsWith(t))return t}var z="master",m={name:"bitbucket",matches:r=>h(r.toLowerCase(),["bitbucket","https://bitbucket.org"])!==void 0,parse:(r,e)=>{let t=j(r,e);return {url:t.url,specifier:t.specifier}},baseUrl:r=>{let{owner:e,repoName:t}=j(r,{fullyQualified:false});return `https://bitbucket.org/${e}/${t}`},state:async(r,{token:e,fetch:t=fetch}={})=>{let{url:i,owner:a,repoName:s,ref:n}=j(r,{fullyQualified:false});if(n===void 0)try{let p=new Headers;if(e!==void 0){let[l,g]=m.authHeader(e);p.append(l,g);}let c=await t(`https://api.bitbucket.org/2.0/repositories/${a}/${s}`,{headers:p});c.ok?n=(await c.json()).mainbranch.name:n=z;}catch{n=z;}return {owner:a,ref:n,repoName:s,url:i,provider:m}},resolveRaw:async(r,e)=>{if(r.provider.name!==m.name)throw new Error(`You passed the incorrect state object (${r.provider.name}) to the ${m.name} provider.`);let{owner:t,repoName:i,ref:a}=r;return new URL(e,`https://api.bitbucket.org/2.0/repositories/${t}/${i}/src/${a}/`)},authHeader:r=>["Authorization",`Bearer ${r}`],formatFetchError:(r,e)=>`There was an error fetching \`${y.bold(e)}\` from ${y.bold(r.url)}.
|
|
9
9
|
|
|
10
10
|
${y.bold("This may be for one of the following reasons:")}
|
|
11
11
|
1. Either \`${y.bold(e)}\` or the containing repository doesn't exist
|
|
12
12
|
2. Your repository path is incorrect (wrong branch, wrong tag)
|
|
13
13
|
3. You are using an expired access token or a token that doesn't have access to this repository
|
|
14
14
|
4. The cached state for this git provider is incorrect (try using ${y.bold("--no-cache")})
|
|
15
|
-
`};function j(r,{fullyQualified:e=false}){let t=r.replaceAll(/(https:\/\/bitbucket.org\/)|(bitbucket\/)/g,""),[i,a,...
|
|
15
|
+
`};function j(r,{fullyQualified:e=false}){let t=r.replaceAll(/(https:\/\/bitbucket.org\/)|(bitbucket\/)/g,""),[i,a,...s]=t.split("/"),n;e&&(n=s.slice(s.length-2).join("/"),s=s.slice(0,s.length-2));let p;return s[0]==="src"&&(p=s[1]),{url:`bitbucket/${i}/${a}${p?`/src/${p}`:""}`,specifier:n,owner:i,repoName:a,ref:p}}var B="main",E={name:"github",matches:r=>h(r.toLowerCase(),["github","https://github.com"])!==void 0,parse:(r,e)=>{let t=k(r,e);return {url:t.url,specifier:t.specifier}},baseUrl:r=>{let{owner:e,repoName:t}=k(r,{fullyQualified:false});return `https://github.com/${e}/${t}`},state:async(r,{token:e}={})=>{let{url:t,owner:i,repoName:a,ref:s}=k(r,{fullyQualified:false});if(s===void 0)try{let n=await fetch(`https://api.github.com/repos/${i}/${a}`,{headers:{Authorization:`Bearer ${e}`}});n.ok?s=(await n.json()).default_branch:s=B;}catch{s=B;}return {owner:i,ref:s,repoName:a,url:t,provider:E}},resolveRaw:async(r,e)=>{if(r.provider.name!==E.name)throw new Error(`You passed the incorrect state object (${r.provider.name}) to the ${E.name} provider.`);let{owner:t,repoName:i,ref:a}=r;return new URL(e,`https://ungh.cc/repos/${t}/${i}/files/${a}/`)},authHeader:r=>["Authorization",`token ${r}`],formatFetchError:(r,e)=>`There was an error fetching \`${y.bold(e)}\` from ${y.bold(r.url)}.
|
|
16
16
|
|
|
17
17
|
${y.bold("This may be for one of the following reasons:")}
|
|
18
18
|
1. Either \`${y.bold(e)}\` or the containing repository doesn't exist
|
|
19
19
|
2. Your repository path is incorrect (wrong branch, wrong tag)
|
|
20
20
|
3. You are using an expired access token or a token that doesn't have access to this repository
|
|
21
21
|
4. The cached state for this git provider is incorrect (try using ${y.bold("--no-cache")})
|
|
22
|
-
`};function k(r,{fullyQualified:e=false}){let t=r.replaceAll(/(https:\/\/github.com\/)|(github\/)/g,""),[i,a,...
|
|
22
|
+
`};function k(r,{fullyQualified:e=false}){let t=r.replaceAll(/(https:\/\/github.com\/)|(github\/)/g,""),[i,a,...s]=t.split("/"),n;e&&(n=s.slice(s.length-2).join("/"),s=s.slice(0,s.length-2));let p;return s.length>0&&s[0]==="tree"&&(p=s[1]),{url:`github/${i}/${a}${p?`/tree/${p}`:""}`,specifier:n,owner:i,repoName:a,ref:p}}function f(...r){return r.map(e=>ee(e)).filter(Boolean).join("/")}function ee(r){let e=re(r);return te(e)}function re(r){let e=r;return e.startsWith("/")&&(e=e.slice(1)),e}function te(r){let e=r;return e.endsWith("/")&&(e=e.slice(0,e.length-1)),e}function C(r){let e=r;return e.endsWith("/")||(e=`${e}/`),e}var I="main",M="https://gitlab.com",v={name:"gitlab",matches:r=>h(r.toLowerCase(),["gitlab/","gitlab:","https://gitlab.com"])!==void 0,parse:(r,e)=>{let t=U(r,e);return {url:t.url,specifier:t.specifier}},baseUrl:r=>{let{baseUrl:e,owner:t,repoName:i}=U(r,{fullyQualified:false});return f(e,t,i)},state:async(r,{token:e,fetch:t=fetch}={})=>{let{baseUrl:i,url:a,owner:s,repoName:n,ref:p}=U(r,{fullyQualified:false});if(p===void 0)try{let c=new Headers;if(e!==void 0){let[g,G]=v.authHeader(e);c.append(g,G);}let l=await t(f(i,`api/v4/projects/${encodeURIComponent(`${s}/${n}`)}`),{headers:c});l.ok?p=(await l.json()).default_branch:p=I;}catch{p=I;}return {owner:s,repoName:n,ref:p,baseUrl:i,url:a,provider:v}},resolveRaw:async(r,e)=>{if(r.provider.name!==v.name)throw new Error(`You passed the incorrect state object (${r.provider.name}) to the ${v.name} provider.`);let{baseUrl:t,owner:i,repoName:a,ref:s}=r;return new URL(f(t,`api/v4/projects/${encodeURIComponent(`${i}/${a}`)}`,`repository/files/${encodeURIComponent(e)}/raw?ref=${s}`))},authHeader:r=>["PRIVATE-TOKEN",r],formatFetchError:(r,e,t)=>`There was an error fetching \`${y.bold(e)}\` from ${y.bold(r.url)}: ${t}.
|
|
23
23
|
|
|
24
24
|
${y.bold("This may be for one of the following reasons:")}
|
|
25
25
|
1. Either \`${y.bold(e)}\` or the containing repository doesn't exist
|
|
26
26
|
2. Your repository path is incorrect (wrong branch, wrong tag)
|
|
27
27
|
3. You are using an expired access token or a token that doesn't have access to this repository
|
|
28
28
|
4. The cached state for this git provider is incorrect (try using ${y.bold("--no-cache")})
|
|
29
|
-
`};function U(r,{fullyQualified:e}){let t=M;r.startsWith("gitlab:")&&(t=new URL(r.slice(7)).origin);let i=r.replaceAll(/gitlab\/|https:\/\/gitlab\.com\/|gitlab:https?:\/\/[^/]+\//g,""),[a,n
|
|
29
|
+
`};function U(r,{fullyQualified:e}){let t=M;r.startsWith("gitlab:")&&(t=new URL(r.slice(7)).origin);let i=r.replaceAll(/gitlab\/|https:\/\/gitlab\.com\/|gitlab:https?:\/\/[^/]+\//g,""),[a,s,...n]=i.split("/"),p;e&&(p=n.slice(n.length-2).join("/"),n=n.slice(0,n.length-2));let c;if(n[0]==="-"&&n[1]==="tree")if(n[2].includes("?")){let[g]=n[2].split("?");c=g;}else c=n[2];return {url:f(t!==M?`gitlab:${t}`:t,`${a}/${s}${c?`/-/tree/${c}`:""}`),baseUrl:t,owner:a,repoName:s,ref:c,specifier:p}}var S={name:"http",matches:r=>{try{return new URL(r),!0}catch{return false}},parse:(r,e)=>{let t=N(r,e);return {url:t.url,specifier:t.specifier}},baseUrl:r=>{let{url:e}=N(r,{fullyQualified:false});return new URL(e).origin},state:async r=>{let{url:e}=N(r,{fullyQualified:false});return {url:e,provider:S}},resolveRaw:async(r,e)=>{if(r.provider.name!==S.name)throw new Error(`You passed the incorrect state object (${r.provider.name}) to the ${S.name} provider.`);return new URL(e,r.url)},authHeader:r=>["Authorization",`Bearer ${r}`],formatFetchError:(r,e,t)=>`There was an error fetching ${y.bold(new URL(e,r.url).toString())}
|
|
30
30
|
|
|
31
|
-
${y.bold(t)}`};function N(r,{fullyQualified:e}){let t=new URL(r),i=t.pathname.split("/"),a;return e&&(a=i.slice(i.length-2).join("/"),i=i.slice(0,i.length-2)),{url:C(f(t.origin,...i)),specifier:a}}var Re=/^(?![-0-9])(?!.*--)[a-z0-9]*(?:-[a-z0-9]+)*$/gi,W="https://www.jsrepo.com",R={name:"jsrepo",matches:r=>r.startsWith("@"),parse:(r,e)=>{let t=L(r,e);return {url:t.url,specifier:t.specifier}},baseUrl:r=>{let{scope:e,registryName:t,version:i}=L(r,{fullyQualified:false});return `${W}/${e}/${t}/v/${i}`},state:async r=>({...L(r,{fullyQualified:false}),provider:R}),resolveRaw:async(r,e)=>{if(r.provider.name!==R.name)throw new Error(`You passed the incorrect state object (${r.provider.name}) to the ${R.name} provider.`);let{scope:t,registryName:i,version:a}=r;return new URL(`${W}/api/scopes/${t}/${i}/v/${a}/files/${e}`)},authHeader:r=>["x-api-key",r],formatFetchError:(r,e,t)=>{let{scope:i,registryName:a,version:
|
|
31
|
+
${y.bold(t)}`};function N(r,{fullyQualified:e}){let t=new URL(r),i=t.pathname.split("/"),a;return e&&(a=i.slice(i.length-2).join("/"),i=i.slice(0,i.length-2)),{url:C(f(t.origin,...i)),specifier:a}}var Re=/^(?![-0-9])(?!.*--)[a-z0-9]*(?:-[a-z0-9]+)*$/gi,W="https://www.jsrepo.com",R={name:"jsrepo",matches:r=>r.startsWith("@"),parse:(r,e)=>{let t=L(r,e);return {url:t.url,specifier:t.specifier}},baseUrl:r=>{let{scope:e,registryName:t,version:i}=L(r,{fullyQualified:false});return `${W}/${e}/${t}/v/${i}`},state:async r=>({...L(r,{fullyQualified:false}),provider:R}),resolveRaw:async(r,e)=>{if(r.provider.name!==R.name)throw new Error(`You passed the incorrect state object (${r.provider.name}) to the ${R.name} provider.`);let{scope:t,registryName:i,version:a}=r;return new URL(`${W}/api/scopes/${t}/${i}/v/${a}/files/${e}`)},authHeader:r=>["x-api-key",r],formatFetchError:(r,e,t)=>{let{scope:i,registryName:a,version:s}=r;return `There was an error fetching ${e} from ${i}/${a}@${s}
|
|
32
32
|
|
|
33
|
-
${y.bold(t)}`}};function L(r,{fullyQualified:e}){let[t,i,...a]=r.split("/"),[n
|
|
34
|
-
//# sourceMappingURL=chunk-
|
|
33
|
+
${y.bold(t)}`}};function L(r,{fullyQualified:e}){let[t,i,...a]=r.split("/"),[s,n]=i.split("@"),p;return e&&(p=a.slice(a.length-2).join("/")),{url:`${t}/${i}`,specifier:p,scope:t,registryName:s,version:n??"latest"}}var T=class{_result;constructor(e){this._result=e;}match(e,t){return this._result.ok?e(this._result.val):t(this._result.err)}map(e){return this.match(t=>d(e(t)),t=>u(t))}mapOr(e,t){return this.match(i=>t(i),i=>e)}mapOrElse(e,t){return this.match(i=>t(i),i=>e(i))}mapErr(e){return this.match(t=>d(t),t=>u(e(t)))}mapErrOr(e,t){return this.match(i=>e,i=>t(i))}mapErrOrElse(e,t){return this.match(i=>e(i),i=>t(i))}isOk(){return this.match(()=>true,()=>false)}isErr(){return this.match(()=>false,()=>true)}unwrap(){return this.match(e=>e,()=>{throw new Error("Attempted to call `.unwrap()` on a non `Ok` value.")})}unwrapErr(){return this.match(()=>{throw new Error("Attempted to call `.unwrapErr()` on a non `Err` value.")},e=>e)}unwrapOr(e){return this.match(t=>t,t=>e)}unwrapErrOr(e){return this.match(()=>e,t=>t)}unwrapOrElse(e){return this.match(t=>t,t=>e(t))}unwrapErrOrElse(e){return this.match(t=>e(t),t=>t)}expect(e){return this.match(t=>t,()=>{throw new Error(e)})}expectErr(e){return this.match(()=>{throw new Error(e)},t=>t)}};function d(r){return new T({ok:true,val:r})}function u(r){return new T({ok:false,err:r})}function Y(r){let e;try{e=JSON.parse(r);}catch(i){return u(`Error parsing manifest json ${i}`)}if(Array.isArray(e)){let i=o.safeParse(o.array(A),e);return i.success?d({private:false,categories:i.output}):u(`Error parsing categories (array-based config) ${i.issues.join(" ")}`)}let t=o.safeParse(F,e);return t.success?d(t.output):u(`Error parsing manifest ${t.issues.join(" ")}`)}function je(r,e,t){return {name:t.name,version:t.version,meta:t.meta,access:t.access,peerDependencies:t.peerDependencies,configFiles:e,categories:r}}var ie=[R,E,v,m,b,S];function Ie(r){return ie.find(t=>t.matches(r))}async function ne(r,e,{verbose:t,fetch:i=fetch,token:a}={}){let s=await r.provider.resolveRaw(r,e);t?.(`Trying to fetch from ${s}`);try{let n={};if(a!==void 0&&r.provider.authHeader){let[c,l]=r.provider.authHeader(a);n[c]=l;}let p=await i(s.toString(),{headers:n});return t?.(`Got a response from ${s} ${p.status} ${p.statusText}`),p.ok?d(await p.text()):u(r.provider.formatFetchError(r,e,`${p.status} ${p.statusText}`))}catch(n){return u(r.provider.formatFetchError(r,e,n))}}async function Me(r,{fetch:e=fetch,...t}={}){let i=await ne(r,_,{fetch:e,...t});return i.isErr()?u(i.unwrapErr()):Y(i.unwrap())}export{ne as A,Me as B,d as a,u as b,f as c,Q as d,A as e,J as f,q as g,K as h,V as i,X as j,F as k,ue as l,_ as m,ae as n,Y as o,je as p,b as q,m as r,E as s,v as t,S as u,Re as v,W as w,R as x,ie as y,Ie as z};//# sourceMappingURL=chunk-SWGNQXLV.js.map
|
|
34
|
+
//# sourceMappingURL=chunk-SWGNQXLV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts","../src/constants.ts","../src/utils/registry-providers/azure.ts","../src/utils/blocks/ts/strings.ts","../src/utils/registry-providers/bitbucket.ts","../src/utils/registry-providers/github.ts","../src/utils/blocks/ts/url.ts","../src/utils/registry-providers/gitlab.ts","../src/utils/registry-providers/http.ts","../src/utils/registry-providers/jsrepo.ts","../src/utils/blocks/ts/result.ts","../src/utils/manifest.ts","../src/utils/registry-providers/index.ts"],"names":["blockSchema","categorySchema","manifestMeta","peerDependencySchema","configFileSchema","manifestConfigFileSchema","accessLevel","manifestSchema","MANIFEST_FILE","CONFIG_FILE","DEFAULT_BRANCH","azure","url","opts","parsed","parseUrl","owner","repoName","normalizedUrl","project","ref","refs","state","resourcePath","versionType","token","filePath","color","fullyQualified","repo","rest","specifier","startsWithOneOf","str","strings","s","endsWithOneOf","bitbucket","f","headers","key","value","response","github","join","segments","removeLeadingAndTrailingSlash","segment","newSegment","removeLeadingSlash","removeTrailingSlash","addTrailingSlash","BASE_URL","gitlab","baseUrl","error","tempRef","http","u","parsedUrl","NAME_REGEX","jsrepo","scope","registryName","version","name","Result","result","success","failure","fn","val","Ok","err","Err","defaultVal","_","def","message","parseManifest","json","validated","P","createManifest","categories","configFiles","config","providers","selectProvider","p","fetchRaw","verbose","fetchManifest","manifest"],"mappings":"+CAEaA,IAAAA,CAAAA,CAAgB,SAAO,CACnC,IAAA,CAAQ,CAAO,CAAA,MAAA,EAAA,CACf,QAAY,CAAA,CAAA,CAAA,MAAA,GACZ,iBAAqB,CAAA,CAAA,CAAA,KAAA,CAAQ,UAAQ,CAAA,CACrC,aAAgB,CAAQ,CAAA,KAAA,CAAA,CAAA,CAAA,MAAA,EAAQ,CAAA,CAChC,eAAmB,CAAA,CAAA,CAAA,KAAA,CAAQ,UAAQ,CAAA,CACnC,MAAS,CAAQ,CAAA,OAAA,EAAA,CACjB,KAAQ,CAAW,CAAA,QAAA,CAAA,CAAA,CAAA,OAAA,EAAW,CAAA,IAAI,CAElC,CAAA,SAAA,CAAa,UACb,CAAA,YAAA,CAAgB,WAChB,CAAA,KAAA,CAAS,QAAQ,CAAO,CAAA,MAAA,EAAC,CACzB,CAAA,SAAA,CAAa,CAAS,CAAA,MAAA,CAAA,CAAA,CAAA,MAAA,GAAY,CAAO,CAAA,MAAA,EAAC,CAC3C,CAAC,CAAA,CAEYC,EAAmB,CAAO,CAAA,MAAA,CAAA,CACtC,IAAQ,CAAA,CAAA,CAAA,MAAA,EACR,CAA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AS,UAAU,CAAA,CAC1C,CACD,CAIF,OAAS+B,CAAK,CAAA,CACb,OAAOC,CAAAA,CAAIpD,EAAM,QAAS,CAAA,gBAAA,CAAiBA,EAAOC,CAAckD,CAAAA,CAAG,CAAC,CACrE,CACD,CAEA,eAAsBmB,GACrBtE,CACA,CAAA,CAAE,KAAOgB,CAAAA,CAAAA,CAAI,MAAO,GAAGR,CAAK,CAA2B,CAAA,GACnB,CACpC,IAAM+D,EAAW,MAAMH,EAAAA,CAASpE,EAAOd,CAAe,CAAA,CAAE,KAAO8B,CAAAA,CAAAA,CAAG,GAAGR,CAAK,CAAC,CAE3E,CAAA,OAAI+D,EAAS,KAAM,EAAA,CAAUnB,CAAImB,CAAAA,CAAAA,CAAS,WAAW,CAAA,CAE9Cd,EAAcc,CAAS,CAAA,MAAA,EAAQ,CACvC","file":"chunk-SWGNQXLV.js","sourcesContent":["import * as v from 'valibot';\n\nexport const blockSchema = v.object({\n\tname: v.string(),\n\tcategory: v.string(),\n\tlocalDependencies: v.array(v.string()),\n\tdependencies: v.array(v.string()),\n\tdevDependencies: v.array(v.string()),\n\ttests: v.boolean(),\n\tlist: v.optional(v.boolean(), true),\n\t/** Where to find the block relative to root */\n\tdirectory: v.string(),\n\tsubdirectory: v.boolean(),\n\tfiles: v.array(v.string()),\n\t_imports_: v.record(v.string(), v.string()),\n});\n\nexport const categorySchema = v.object({\n\tname: v.string(),\n\tblocks: v.array(blockSchema),\n});\n\nexport const manifestMeta = v.object({\n\tauthors: v.optional(v.array(v.string())),\n\tbugs: v.optional(v.string()),\n\tdescription: v.optional(v.string()),\n\thomepage: v.optional(v.string()),\n\trepository: v.optional(v.string()),\n\ttags: v.optional(v.array(v.string())),\n});\n\nexport const peerDependencySchema = v.record(\n\tv.string(),\n\tv.union([\n\t\tv.string(),\n\t\tv.object({\n\t\t\tversion: v.string(),\n\t\t\tmessage: v.string(),\n\t\t}),\n\t])\n);\n\nexport type PeerDependency = v.InferOutput<typeof peerDependencySchema>;\n\nexport const configFileSchema = v.object({\n\tname: v.string(),\n\tpath: v.string(),\n\texpectedPath: v.optional(v.string()),\n\toptional: v.optional(v.boolean(), false),\n});\n\nexport type ConfigFile = v.InferOutput<typeof configFileSchema>;\n\nexport const manifestConfigFileSchema = v.object({\n\t...configFileSchema.entries,\n\tdependencies: v.optional(v.array(v.string())),\n\tdevDependencies: v.optional(v.array(v.string())),\n});\n\nexport const accessLevel = v.union([\n\tv.literal('public'),\n\tv.literal('private'),\n\tv.literal('marketplace'),\n]);\n\nexport const manifestSchema = v.object({\n\tname: v.optional(v.string()),\n\tversion: v.optional(v.string()),\n\tmeta: v.optional(manifestMeta),\n\taccess: v.optional(accessLevel),\n\tpeerDependencies: v.optional(peerDependencySchema),\n\tconfigFiles: v.optional(v.array(manifestConfigFileSchema)),\n\tcategories: v.array(categorySchema),\n});\n\nexport type Meta = v.InferOutput<typeof manifestMeta>;\n\nexport type Category = v.InferOutput<typeof categorySchema>;\n\nexport type Block = v.InferOutput<typeof blockSchema>;\n\nexport type Manifest = v.InferOutput<typeof manifestSchema>;\n","export const MANIFEST_FILE = 'jsrepo-manifest.json';\nexport const CONFIG_FILE = 'jsrepo.json';\n","import color from 'chalk';\nimport type { ParseOptions, RegistryProvider, RegistryProviderState } from './types';\n\nconst DEFAULT_BRANCH = 'main';\n\nexport interface AzureProviderState extends RegistryProviderState {\n\towner: string;\n\trepoName: string;\n\tproject: string;\n\trefs: 'heads' | 'tags';\n\tref: string;\n}\n\n/** Valid paths\n *\n * `azure/<org>/<project>/<repo>/(tags|heads)/<ref>`\n */\nexport const azure: RegistryProvider = {\n\tname: 'azure',\n\n\tmatches: (url) => url.toLowerCase().startsWith('azure'),\n\n\tparse: (url, opts) => {\n\t\tconst parsed = parseUrl(url, opts);\n\n\t\treturn {\n\t\t\turl: parsed.url,\n\t\t\tspecifier: parsed.specifier,\n\t\t};\n\t},\n\n\tbaseUrl: (url) => {\n\t\tconst { owner, repoName } = parseUrl(url, { fullyQualified: false });\n\n\t\treturn `https://dev.azure.com/${owner}/_git/${repoName}`;\n\t},\n\n\tstate: async (url) => {\n\t\tconst {\n\t\t\turl: normalizedUrl,\n\t\t\towner,\n\t\t\tproject,\n\t\t\trepoName,\n\t\t\tref,\n\t\t\trefs,\n\t\t} = parseUrl(url, { fullyQualified: false });\n\n\t\treturn {\n\t\t\towner,\n\t\t\trepoName,\n\t\t\tref,\n\t\t\trefs,\n\t\t\tproject,\n\t\t\turl: normalizedUrl,\n\t\t\tprovider: azure,\n\t\t} satisfies AzureProviderState;\n\t},\n\n\tresolveRaw: async (state, resourcePath) => {\n\t\t// essentially assert that we are using the correct state\n\t\tif (state.provider.name !== azure.name) {\n\t\t\tthrow new Error(\n\t\t\t\t`You passed the incorrect state object (${state.provider.name}) to the ${azure.name} provider.`\n\t\t\t);\n\t\t}\n\n\t\tconst { owner, repoName, project, ref, refs } = state as AzureProviderState;\n\n\t\tconst versionType = refs === 'tags' ? 'tag' : 'branch';\n\n\t\treturn new URL(\n\t\t\t`https://dev.azure.com/${owner}/${project}/_apis/git/repositories/${repoName}/items?path=${resourcePath}&api-version=7.2-preview.1&versionDescriptor.version=${ref}&versionDescriptor.versionType=${versionType}`\n\t\t);\n\t},\n\n\tauthHeader: (token) => ['Authorization', `Bearer ${token}`],\n\n\tformatFetchError: (state, filePath) => {\n\t\treturn `There was an error fetching \\`${color.bold(filePath)}\\` from ${color.bold(state.url)}.\n\n${color.bold('This may be for one of the following reasons:')}\n1. Either \\`${color.bold(filePath)}\\` or the containing repository doesn't exist\n2. Your repository path is incorrect (wrong branch, wrong tag)\n3. You are using an expired access token or a token that doesn't have access to this repository\n4. The cached state for this git provider is incorrect (try using ${color.bold('--no-cache')})\n`;\n\t},\n};\n\nfunction parseUrl(\n\turl: string,\n\t{ fullyQualified }: ParseOptions\n): {\n\turl: string;\n\towner: string;\n\tproject: string;\n\trepoName: string;\n\tref: string;\n\trefs: 'tags' | 'heads';\n\tspecifier?: string;\n} {\n\tconst repo = url.replaceAll(/(azure\\/)/g, '');\n\n\tlet [owner, project, repoName, ...rest] = repo.split('/');\n\n\tlet specifier: string | undefined = undefined;\n\n\tif (fullyQualified) {\n\t\tspecifier = rest.slice(rest.length - 2).join('/');\n\n\t\trest = rest.slice(0, rest.length - 2);\n\t}\n\n\tlet ref: string = DEFAULT_BRANCH;\n\n\t// checks if the type of the ref is tags or heads\n\tlet refs: 'heads' | 'tags' = 'heads';\n\n\tif (['tags', 'heads'].includes(rest[0])) {\n\t\trefs = rest[0] as 'heads' | 'tags';\n\n\t\tif (rest[1] && rest[1] !== '') {\n\t\t\tref = rest[1];\n\t\t}\n\t}\n\n\treturn {\n\t\turl: `azure/${owner}/${project}/${repoName}${ref ? `/${refs}/${ref}` : ''}`,\n\t\towner: owner,\n\t\trepoName: repoName,\n\t\tproject,\n\t\tref,\n\t\trefs,\n\t\tspecifier,\n\t};\n}\n","/*\n\tInstalled from @ieedan/std\n*/\n\n/** Returns the string that matches the string (if it exits). Great for matching string union types.\n *\n * @param str\n * @param strings\n * @returns\n *\n * ## Usage\n * ```ts\n * const methods = ['GET', 'PUT', 'POST', 'PATCH', 'DELETE'] as const;\n *\n * const methodStr: string = 'GET';\n *\n * const method = equalsOneOf(methodStr, methods);\n *\n * if (method) {\n * // if method was just a string this would be a type error\n * \tmethods.includes(method)\n * }\n * ```\n */\nexport function equalsOneOf<T extends string>(str: string, strings: readonly T[]): T | undefined {\n\tfor (const s of strings) {\n\t\tif (s === str) return s;\n\t}\n\n\treturn undefined;\n}\n\n/** Returns the matched prefix for the string (if it exists). Great for matching string union types.\n *\n * @param str\n * @param strings\n * @returns\n *\n * ## Usage\n * ```ts\n * startsWithOneOf('ab', 'a', 'c'); // 'a'\n * startsWithOneOf('cc', 'a', 'b'); // undefined\n * ```\n */\nexport function startsWithOneOf<T extends string>(\n\tstr: string,\n\tstrings: readonly T[]\n): T | undefined {\n\tfor (const s of strings) {\n\t\tif (str.startsWith(s)) return s;\n\t}\n\n\treturn undefined;\n}\n\n/** Returns the matched suffix for the string (if it exists). Great for matching string union types.\n *\n * @param str\n * @param strings\n * @returns\n *\n * ## Usage\n * ```ts\n * endsWithOneOf('cb', 'a', 'b'); // 'b'\n * endsWithOneOf('cc', 'a', 'b'); // undefined\n * ```\n */\nexport function endsWithOneOf<T extends string>(str: string, strings: readonly T[]): T | undefined {\n\tfor (const s of strings) {\n\t\tif (str.endsWith(s)) return s;\n\t}\n\n\treturn undefined;\n}\n\n/** Case insensitive equality. Returns true if `left.toLowerCase()` and `right.toLowerCase()` are equal.\n *\n * @param left\n * @param right\n * @returns\n *\n * ## Usage\n * ```ts\n * iEqual('Hello, World!', 'hello, World!'); // true\n * ```\n */\nexport function iEqual(left: string, right: string): boolean {\n\treturn left.toLowerCase() === right.toLowerCase();\n}\n","import color from 'chalk';\nimport { startsWithOneOf } from '../blocks/ts/strings';\nimport type { ParseOptions, RegistryProvider, RegistryProviderState } from './types';\n\nconst DEFAULT_BRANCH = 'master';\n\nexport interface BitBucketProviderState extends RegistryProviderState {\n\towner: string;\n\trepoName: string;\n\tref: string;\n}\n\n/** Valid paths\n *\n * `bitbucket/ieedan/std`\n *\n * `https://bitbucket.org/ieedan/std/src/main/`\n *\n * `https://bitbucket.org/ieedan/std/src/next/`\n *\n * `https://bitbucket.org/ieedan/std/src/v2.0.0/`\n *\n */\nexport const bitbucket: RegistryProvider = {\n\tname: 'bitbucket',\n\n\tmatches: (url) =>\n\t\tstartsWithOneOf(url.toLowerCase(), ['bitbucket', 'https://bitbucket.org']) !== undefined,\n\n\tparse: (url, opts) => {\n\t\tconst parsed = parseUrl(url, opts);\n\n\t\treturn {\n\t\t\turl: parsed.url,\n\t\t\tspecifier: parsed.specifier,\n\t\t};\n\t},\n\n\tbaseUrl: (url) => {\n\t\tconst { owner, repoName } = parseUrl(url, { fullyQualified: false });\n\n\t\treturn `https://bitbucket.org/${owner}/${repoName}`;\n\t},\n\n\tstate: async (url, { token, fetch: f = fetch } = {}) => {\n\t\tlet { url: normalizedUrl, owner, repoName, ref } = parseUrl(url, { fullyQualified: false });\n\n\t\t// fetch default branch if ref was not provided\n\t\tif (ref === undefined) {\n\t\t\ttry {\n\t\t\t\tconst headers = new Headers();\n\n\t\t\t\tif (token !== undefined) {\n\t\t\t\t\tconst [key, value] = bitbucket.authHeader!(token);\n\n\t\t\t\t\theaders.append(key, value);\n\t\t\t\t}\n\n\t\t\t\tconst response = await f(\n\t\t\t\t\t`https://api.bitbucket.org/2.0/repositories/${owner}/${repoName}`,\n\t\t\t\t\t{\n\t\t\t\t\t\theaders,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif (response.ok) {\n\t\t\t\t\tconst data = await response.json();\n\n\t\t\t\t\t// @ts-ignore yes but we know\n\t\t\t\t\tref = data.mainbranch.name as string;\n\t\t\t\t} else {\n\t\t\t\t\tref = DEFAULT_BRANCH;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// well find out it isn't correct later with a better error\n\t\t\t\tref = DEFAULT_BRANCH;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\towner,\n\t\t\tref,\n\t\t\trepoName,\n\t\t\turl: normalizedUrl,\n\t\t\tprovider: bitbucket,\n\t\t} satisfies BitBucketProviderState;\n\t},\n\n\tresolveRaw: async (state, resourcePath) => {\n\t\t// essentially assert that we are using the correct state\n\t\tif (state.provider.name !== bitbucket.name) {\n\t\t\tthrow new Error(\n\t\t\t\t`You passed the incorrect state object (${state.provider.name}) to the ${bitbucket.name} provider.`\n\t\t\t);\n\t\t}\n\n\t\tconst { owner, repoName, ref } = state as BitBucketProviderState;\n\n\t\treturn new URL(\n\t\t\tresourcePath,\n\t\t\t`https://api.bitbucket.org/2.0/repositories/${owner}/${repoName}/src/${ref}/`\n\t\t);\n\t},\n\n\tauthHeader: (token) => ['Authorization', `Bearer ${token}`],\n\n\tformatFetchError: (state, filePath) => {\n\t\treturn `There was an error fetching \\`${color.bold(filePath)}\\` from ${color.bold(state.url)}.\n\n${color.bold('This may be for one of the following reasons:')}\n1. Either \\`${color.bold(filePath)}\\` or the containing repository doesn't exist\n2. Your repository path is incorrect (wrong branch, wrong tag)\n3. You are using an expired access token or a token that doesn't have access to this repository\n4. The cached state for this git provider is incorrect (try using ${color.bold('--no-cache')})\n`;\n\t},\n};\n\nfunction parseUrl(\n\turl: string,\n\t{ fullyQualified = false }: ParseOptions\n): { url: string; owner: string; repoName: string; ref?: string; specifier?: string } {\n\tconst repo = url.replaceAll(/(https:\\/\\/bitbucket.org\\/)|(bitbucket\\/)/g, '');\n\n\tlet [owner, repoName, ...rest] = repo.split('/');\n\n\tlet specifier: string | undefined;\n\n\tif (fullyQualified) {\n\t\tspecifier = rest.slice(rest.length - 2).join('/');\n\n\t\trest = rest.slice(0, rest.length - 2);\n\t}\n\n\tlet ref: string | undefined;\n\n\tif (rest[0] === 'src') {\n\t\tref = rest[1];\n\t}\n\n\treturn {\n\t\turl: `bitbucket/${owner}/${repoName}${ref ? `/src/${ref}` : ''}`,\n\t\tspecifier,\n\t\towner,\n\t\trepoName: repoName,\n\t\tref,\n\t};\n}\n","import color from 'chalk';\nimport { startsWithOneOf } from '../blocks/ts/strings';\nimport type { ParseOptions, RegistryProvider, RegistryProviderState } from './types';\n\nconst DEFAULT_BRANCH = 'main';\n\nexport interface GitHubProviderState extends RegistryProviderState {\n\towner: string;\n\trepoName: string;\n\tref: string;\n}\n\n/** Valid paths\n *\n * `https://github.com/<owner>/<repo>`\n *\n * `github/<owner>/<repo>`\n *\n * `github/<owner>/<repo>/tree/<ref>`\n */\nexport const github: RegistryProvider = {\n\tname: 'github',\n\n\tmatches: (url) =>\n\t\tstartsWithOneOf(url.toLowerCase(), ['github', 'https://github.com']) !== undefined,\n\n\tparse: (url, opts) => {\n\t\tconst parsed = parseUrl(url, opts);\n\n\t\treturn {\n\t\t\turl: parsed.url,\n\t\t\tspecifier: parsed.specifier,\n\t\t};\n\t},\n\n\tbaseUrl: (url) => {\n\t\tconst { owner, repoName } = parseUrl(url, { fullyQualified: false });\n\n\t\treturn `https://github.com/${owner}/${repoName}`;\n\t},\n\n\tstate: async (url, { token } = {}) => {\n\t\tlet { url: normalizedUrl, owner, repoName, ref } = parseUrl(url, { fullyQualified: false });\n\n\t\t// fetch default branch if ref was not provided\n\t\tif (ref === undefined) {\n\t\t\ttry {\n\t\t\t\tconst response = await fetch(`https://api.github.com/repos/${owner}/${repoName}`, {\n\t\t\t\t\theaders: { Authorization: `Bearer ${token}` },\n\t\t\t\t});\n\n\t\t\t\tif (response.ok) {\n\t\t\t\t\tconst res = await response.json();\n\n\t\t\t\t\tref = res.default_branch as string;\n\t\t\t\t} else {\n\t\t\t\t\tref = DEFAULT_BRANCH;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// we just want to continue on blissfully unaware the user will get an error later\n\t\t\t\tref = DEFAULT_BRANCH;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\towner,\n\t\t\tref,\n\t\t\trepoName,\n\t\t\turl: normalizedUrl,\n\t\t\tprovider: github,\n\t\t} satisfies GitHubProviderState;\n\t},\n\n\tresolveRaw: async (state, resourcePath) => {\n\t\t// essentially assert that we are using the correct state\n\t\tif (state.provider.name !== github.name) {\n\t\t\tthrow new Error(\n\t\t\t\t`You passed the incorrect state object (${state.provider.name}) to the ${github.name} provider.`\n\t\t\t);\n\t\t}\n\n\t\tconst { owner, repoName, ref } = state as GitHubProviderState;\n\n\t\treturn new URL(resourcePath, `https://ungh.cc/repos/${owner}/${repoName}/files/${ref}/`);\n\t},\n\n\tauthHeader: (token) => ['Authorization', `token ${token}`],\n\n\tformatFetchError: (state, filePath) => {\n\t\treturn `There was an error fetching \\`${color.bold(filePath)}\\` from ${color.bold(state.url)}.\n\n${color.bold('This may be for one of the following reasons:')}\n1. Either \\`${color.bold(filePath)}\\` or the containing repository doesn't exist\n2. Your repository path is incorrect (wrong branch, wrong tag)\n3. You are using an expired access token or a token that doesn't have access to this repository\n4. The cached state for this git provider is incorrect (try using ${color.bold('--no-cache')})\n`;\n\t},\n};\n\nfunction parseUrl(\n\turl: string,\n\t{ fullyQualified = false }: ParseOptions\n): { url: string; owner: string; repoName: string; ref?: string; specifier?: string } {\n\tconst repo = url.replaceAll(/(https:\\/\\/github.com\\/)|(github\\/)/g, '');\n\n\tlet [owner, repoName, ...rest] = repo.split('/');\n\n\tlet specifier: string | undefined;\n\n\tif (fullyQualified) {\n\t\tspecifier = rest.slice(rest.length - 2).join('/');\n\n\t\trest = rest.slice(0, rest.length - 2);\n\t}\n\n\tlet ref: string | undefined;\n\n\tif (rest.length > 0) {\n\t\tif (rest[0] === 'tree') {\n\t\t\tref = rest[1];\n\t\t}\n\t}\n\n\treturn {\n\t\turl: `github/${owner}/${repoName}${ref ? `/tree/${ref}` : ''}`,\n\t\tspecifier,\n\t\towner,\n\t\trepoName: repoName,\n\t\tref,\n\t};\n}\n","/*\n\tInstalled from github/ieedan/std\n*/\n\n/** Joins the segments into a single url correctly handling leading and trailing slashes in each segment.\n *\n * @param segments\n * @returns\n *\n * ## Usage\n * ```ts\n * const url = join('https://example.com', '', 'api/', '/examples/');\n *\n * console.log(url); // https://example.com/api/examples\n * ```\n */\nexport function join(...segments: string[]): string {\n\treturn segments\n\t\t.map((s) => removeLeadingAndTrailingSlash(s))\n\t\t.filter(Boolean)\n\t\t.join('/');\n}\n\n/** Removes the leading and trailing slash from the segment (if they exist)\n *\n * @param segment\n * @returns\n *\n * ## Usage\n * ```ts\n * const segment = removeLeadingAndTrailingSlash('/example/');\n *\n * console.log(segment); // 'example'\n * ```\n */\nexport function removeLeadingAndTrailingSlash(segment: string): string {\n\tconst newSegment = removeLeadingSlash(segment);\n\treturn removeTrailingSlash(newSegment);\n}\n\n/** Adds a leading and trailing to the beginning and end of the segment (if it doesn't already exist)\n *\n * @param segment\n * @returns\n *\n * ## Usage\n * ```ts\n * const segment = addLeadingAndTrailingSlash('example');\n *\n * console.log(segment); // '/example/'\n * ```\n */\nexport function addLeadingAndTrailingSlash(segment: string): string {\n\t// this is a weird case so feel free to handle it however you think it makes the most sense\n\tif (segment === '') return '//';\n\n\tconst newSegment = addLeadingSlash(segment);\n\treturn addTrailingSlash(newSegment);\n}\n\n/** Removes the leading slash from the beginning of the segment (if it exists)\n *\n * @param segment\n * @returns\n *\n * ## Usage\n * ```ts\n * const segment = removeLeadingSlash('/example');\n *\n * console.log(segment); // 'example'\n * ```\n */\nexport function removeLeadingSlash(segment: string): string {\n\tlet newSegment = segment;\n\tif (newSegment.startsWith('/')) {\n\t\tnewSegment = newSegment.slice(1);\n\t}\n\n\treturn newSegment;\n}\n\n/** Adds a leading slash to the beginning of the segment (if it doesn't already exist)\n *\n * @param segment\n * @returns\n *\n * ## Usage\n * ```ts\n * const segment = addLeadingSlash('example');\n *\n * console.log(segment); // '/example'\n * ```\n */\nexport function addLeadingSlash(segment: string): string {\n\tlet newSegment = segment;\n\tif (!newSegment.startsWith('/')) {\n\t\tnewSegment = `/${newSegment}`;\n\t}\n\n\treturn newSegment;\n}\n\n/** Removes the trailing slash from the end of the segment (if it exists)\n *\n * @param segment\n * @returns\n *\n * ## Usage\n * ```ts\n * const segment = removeTrailingSlash('example/');\n *\n * console.log(segment); // 'example'\n * ```\n */\nexport function removeTrailingSlash(segment: string): string {\n\tlet newSegment = segment;\n\tif (newSegment.endsWith('/')) {\n\t\tnewSegment = newSegment.slice(0, newSegment.length - 1);\n\t}\n\n\treturn newSegment;\n}\n\n/** Adds a trailing slash to the end of the segment (if it doesn't already exist)\n *\n * @param segment\n * @returns\n *\n * ## Usage\n * ```ts\n * const segment = addTrailingSlash('example');\n *\n * console.log(segment); // 'example/'\n * ```\n */\nexport function addTrailingSlash(segment: string): string {\n\tlet newSegment = segment;\n\tif (!newSegment.endsWith('/')) {\n\t\tnewSegment = `${newSegment}/`;\n\t}\n\n\treturn newSegment;\n}\n\n/** Removes the last segment of the url.\n *\n * @param url\n *\n * ## Usage\n * ```ts\n * const url = upOneLevel('/first/second');\n *\n * console.log(url); // '/first'\n * ```\n */\nexport function upOneLevel(url: string): string {\n\tif (url === '/') return url;\n\n\tconst lastIndex = removeTrailingSlash(url).lastIndexOf('/');\n\n\treturn url.slice(0, url.length - lastIndex - 1);\n}\n","import color from 'chalk';\nimport { startsWithOneOf } from '../blocks/ts/strings';\nimport * as u from '../blocks/ts/url';\nimport type { ParseOptions, RegistryProvider, RegistryProviderState } from './types';\n\nconst DEFAULT_BRANCH = 'main';\nconst BASE_URL = 'https://gitlab.com';\n\nexport interface GitLabProviderState extends RegistryProviderState {\n\tbaseUrl: string;\n\towner: string;\n\trepoName: string;\n\tref: string;\n}\n\n/** Valid paths\n *\n * `https://gitlab.com/ieedan/std`\n *\n * `https://gitlab.com/ieedan/std/-/tree/next`\n *\n * `https://gitlab.com/ieedan/std/-/tree/v2.0.0`\n *\n * `https://gitlab.com/ieedan/std/-/tree/v2.0.0?ref_type=tags`\n *\n * Self hosted:\n *\n * `gitlab:https://example.com/ieedan/std`\n */\nexport const gitlab: RegistryProvider = {\n\tname: 'gitlab',\n\n\tmatches: (url) =>\n\t\tstartsWithOneOf(url.toLowerCase(), ['gitlab/', 'gitlab:', 'https://gitlab.com']) !==\n\t\tundefined,\n\n\tparse: (url, opts) => {\n\t\tconst parsed = parseUrl(url, opts);\n\n\t\treturn {\n\t\t\turl: parsed.url,\n\t\t\tspecifier: parsed.specifier,\n\t\t};\n\t},\n\n\tbaseUrl: (url) => {\n\t\tconst { baseUrl, owner, repoName } = parseUrl(url, { fullyQualified: false });\n\n\t\treturn u.join(baseUrl, owner, repoName);\n\t},\n\n\tstate: async (url, { token, fetch: f = fetch } = {}) => {\n\t\tlet {\n\t\t\tbaseUrl,\n\t\t\turl: normalizedUrl,\n\t\t\towner,\n\t\t\trepoName,\n\t\t\tref,\n\t\t} = parseUrl(url, { fullyQualified: false });\n\n\t\t// fetch default branch if ref was not provided\n\t\tif (ref === undefined) {\n\t\t\ttry {\n\t\t\t\tconst headers = new Headers();\n\n\t\t\t\tif (token !== undefined) {\n\t\t\t\t\tconst [key, value] = gitlab.authHeader!(token);\n\n\t\t\t\t\theaders.append(key, value);\n\t\t\t\t}\n\n\t\t\t\tconst response = await f(\n\t\t\t\t\tu.join(\n\t\t\t\t\t\tbaseUrl,\n\t\t\t\t\t\t`api/v4/projects/${encodeURIComponent(`${owner}/${repoName}`)}`\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\theaders,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif (response.ok) {\n\t\t\t\t\tconst data = await response.json();\n\n\t\t\t\t\t// @ts-ignore yes but we know\n\t\t\t\t\tref = data.default_branch as string;\n\t\t\t\t} else {\n\t\t\t\t\tref = DEFAULT_BRANCH;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// well find out it isn't correct later with a better error\n\t\t\t\tref = DEFAULT_BRANCH;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\towner,\n\t\t\trepoName,\n\t\t\tref,\n\t\t\tbaseUrl,\n\t\t\turl: normalizedUrl,\n\t\t\tprovider: gitlab,\n\t\t} satisfies GitLabProviderState;\n\t},\n\n\tresolveRaw: async (state, resourcePath) => {\n\t\t// essentially assert that we are using the correct state\n\t\tif (state.provider.name !== gitlab.name) {\n\t\t\tthrow new Error(\n\t\t\t\t`You passed the incorrect state object (${state.provider.name}) to the ${gitlab.name} provider.`\n\t\t\t);\n\t\t}\n\n\t\tconst { baseUrl, owner, repoName, ref } = state as GitLabProviderState;\n\n\t\treturn new URL(\n\t\t\tu.join(\n\t\t\t\tbaseUrl,\n\t\t\t\t`api/v4/projects/${encodeURIComponent(`${owner}/${repoName}`)}`,\n\t\t\t\t`repository/files/${encodeURIComponent(resourcePath)}/raw?ref=${ref}`\n\t\t\t)\n\t\t);\n\t},\n\n\tauthHeader: (token) => ['PRIVATE-TOKEN', token],\n\n\tformatFetchError: (state, filePath, error) => {\n\t\treturn `There was an error fetching \\`${color.bold(filePath)}\\` from ${color.bold(state.url)}: ${error}.\n\n${color.bold('This may be for one of the following reasons:')}\n1. Either \\`${color.bold(filePath)}\\` or the containing repository doesn't exist\n2. Your repository path is incorrect (wrong branch, wrong tag)\n3. You are using an expired access token or a token that doesn't have access to this repository\n4. The cached state for this git provider is incorrect (try using ${color.bold('--no-cache')})\n`;\n\t},\n};\n\nfunction parseUrl(\n\turl: string,\n\t{ fullyQualified }: ParseOptions\n): {\n\turl: string;\n\tbaseUrl: string;\n\towner: string;\n\trepoName: string;\n\tref?: string;\n\tspecifier?: string;\n} {\n\tlet baseUrl = BASE_URL;\n\n\tif (url.startsWith('gitlab:')) {\n\t\tbaseUrl = new URL(url.slice(7)).origin;\n\t}\n\n\tconst repo = url.replaceAll(/gitlab\\/|https:\\/\\/gitlab\\.com\\/|gitlab:https?:\\/\\/[^/]+\\//g, '');\n\n\tlet [owner, repoName, ...rest] = repo.split('/');\n\n\tlet specifier: string | undefined;\n\n\tif (fullyQualified) {\n\t\tspecifier = rest.slice(rest.length - 2).join('/');\n\n\t\trest = rest.slice(0, rest.length - 2);\n\t}\n\n\tlet ref: string | undefined;\n\n\tif (rest[0] === '-' && rest[1] === 'tree') {\n\t\tif (rest[2].includes('?')) {\n\t\t\tconst [tempRef] = rest[2].split('?');\n\n\t\t\tref = tempRef;\n\t\t} else {\n\t\t\tref = rest[2];\n\t\t}\n\t}\n\n\tconst isCustom = baseUrl !== BASE_URL;\n\n\treturn {\n\t\t// if the url is custom instance of gitlab we must append gitlab: so that the url can be parsed correctly\n\t\turl: u.join(\n\t\t\tisCustom ? `gitlab:${baseUrl}` : baseUrl,\n\t\t\t`${owner}/${repoName}${ref ? `/-/tree/${ref}` : ''}`\n\t\t),\n\t\tbaseUrl,\n\t\towner: owner,\n\t\trepoName: repoName,\n\t\tref,\n\t\tspecifier,\n\t};\n}\n","import color from 'chalk';\nimport * as u from '../blocks/ts/url';\nimport type { ParseOptions, RegistryProvider, RegistryProviderState } from './types';\n\nexport interface HttpProviderState extends RegistryProviderState {}\n\n/** Valid paths\n *\n * `(https|http)://example.com`\n */\nexport const http: RegistryProvider = {\n\tname: 'http',\n\n\tmatches: (url) => {\n\t\t// if parsing is a success then it's a match\n\t\ttry {\n\t\t\tnew URL(url);\n\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t},\n\n\tparse: (url, opts) => {\n\t\tconst parsed = parseUrl(url, opts);\n\n\t\treturn {\n\t\t\turl: parsed.url,\n\t\t\tspecifier: parsed.specifier,\n\t\t};\n\t},\n\n\tbaseUrl: (url) => {\n\t\tconst { url: u } = parseUrl(url, { fullyQualified: false });\n\n\t\treturn new URL(u).origin;\n\t},\n\n\tstate: async (url) => {\n\t\tconst { url: normalizedUrl } = parseUrl(url, { fullyQualified: false });\n\n\t\treturn {\n\t\t\turl: normalizedUrl,\n\t\t\tprovider: http,\n\t\t} satisfies HttpProviderState;\n\t},\n\n\tresolveRaw: async (state, resourcePath) => {\n\t\t// essentially assert that we are using the correct state\n\t\tif (state.provider.name !== http.name) {\n\t\t\tthrow new Error(\n\t\t\t\t`You passed the incorrect state object (${state.provider.name}) to the ${http.name} provider.`\n\t\t\t);\n\t\t}\n\n\t\treturn new URL(resourcePath, state.url);\n\t},\n\n\tauthHeader: (token) => ['Authorization', `Bearer ${token}`],\n\n\tformatFetchError: (state, filePath, error) => {\n\t\treturn `There was an error fetching ${color.bold(new URL(filePath, state.url).toString())}\n\t\n${color.bold(error)}`;\n\t},\n};\n\nfunction parseUrl(\n\turl: string,\n\t{ fullyQualified }: ParseOptions\n): {\n\turl: string;\n\tspecifier?: string;\n} {\n\tconst parsedUrl = new URL(url);\n\n\tlet segments = parsedUrl.pathname.split('/');\n\n\tlet specifier: string | undefined;\n\n\tif (fullyQualified) {\n\t\tspecifier = segments.slice(segments.length - 2).join('/');\n\n\t\tsegments = segments.slice(0, segments.length - 2);\n\t}\n\n\treturn {\n\t\turl: u.addTrailingSlash(u.join(parsedUrl.origin, ...segments)),\n\t\tspecifier,\n\t};\n}\n","import color from 'chalk';\nimport type { ParseOptions, RegistryProvider, RegistryProviderState } from './types';\n\n/** Regex for scopes and registry names.\n * Names that don't match this regex will be rejected.\n *\n * ### Valid\n * ```txt\n * console\n * console0\n * console-0\n * ```\n *\n * ### Invalid\n * ```txt\n * Console\n * 0console\n * -console\n * console-\n * console--0\n * ```\n */\nexport const NAME_REGEX = /^(?![-0-9])(?!.*--)[a-z0-9]*(?:-[a-z0-9]+)*$/gi;\n\nexport const BASE_URL = 'https://www.jsrepo.com';\n\nexport interface JsrepoProviderState extends RegistryProviderState {\n\tscope: string;\n\tregistryName: string;\n\tversion: string;\n}\n\n/** Valid paths\n *\n * `@ieedan/std`\n * `@ieedan/std@latest`\n * `@ieedan/std@1.0.0`\n * `@ieedan/std@1.0.0/ts/math`\n */\nexport const jsrepo: RegistryProvider = {\n\tname: 'jsrepo',\n\n\tmatches: (url) => url.startsWith('@'),\n\n\tparse: (url, opts) => {\n\t\tconst parsed = parseUrl(url, opts);\n\n\t\treturn {\n\t\t\turl: parsed.url,\n\t\t\tspecifier: parsed.specifier,\n\t\t};\n\t},\n\n\tbaseUrl: (url) => {\n\t\tconst { scope, registryName, version } = parseUrl(url, { fullyQualified: false });\n\n\t\treturn `${BASE_URL}/${scope}/${registryName}/v/${version}`;\n\t},\n\n\tstate: async (url) => {\n\t\tconst parsed = parseUrl(url, { fullyQualified: false });\n\n\t\treturn {\n\t\t\t...parsed,\n\t\t\tprovider: jsrepo,\n\t\t} satisfies JsrepoProviderState;\n\t},\n\n\tresolveRaw: async (state, resourcePath) => {\n\t\t// essentially assert that we are using the correct state\n\t\tif (state.provider.name !== jsrepo.name) {\n\t\t\tthrow new Error(\n\t\t\t\t`You passed the incorrect state object (${state.provider.name}) to the ${jsrepo.name} provider.`\n\t\t\t);\n\t\t}\n\n\t\tconst { scope, registryName, version } = state as JsrepoProviderState;\n\n\t\treturn new URL(\n\t\t\t`${BASE_URL}/api/scopes/${scope}/${registryName}/v/${version}/files/${resourcePath}`\n\t\t);\n\t},\n\n\tauthHeader: (token) => ['x-api-key', token],\n\n\tformatFetchError: (state, filePath, error) => {\n\t\tconst { scope, registryName, version } = state as JsrepoProviderState;\n\n\t\treturn `There was an error fetching ${filePath} from ${scope}/${registryName}@${version}\n\t\n${color.bold(error)}`;\n\t},\n};\n\nexport function parseUrl(\n\turl: string,\n\t{ fullyQualified }: ParseOptions\n): {\n\turl: string;\n\tspecifier?: string;\n\tscope: string;\n\tregistryName: string;\n\tversion: string;\n} {\n\tconst [scope, name, ...rest] = url.split('/');\n\n\tconst [registryName, version] = name.split('@');\n\n\tlet specifier: string | undefined = undefined;\n\n\tif (fullyQualified) {\n\t\tspecifier = rest.slice(rest.length - 2).join('/');\n\t}\n\n\tconst parsedUrl = `${scope}/${name}`;\n\n\treturn {\n\t\turl: parsedUrl,\n\t\tspecifier,\n\t\tscope,\n\t\tregistryName,\n\t\tversion: version ?? 'latest',\n\t};\n}\n","/*\n\tInstalled from github/ieedan/std\n*/\n\n/** This is just a helper type used only within this file */\ntype _Result<T, E> = { ok: true; val: T } | { ok: false; err: E };\n\n/** Result allows you to show to a consumer that a function might throw and force them to handle it.\n *\n * `T` Value type\n *\n * `E` Error type\n *\n * ## Usage\n *\n * ```ts\n * function functionThatMightFail(): Result<T, E>;\n * ```\n *\n * ## Usage\n *\n * ```ts\n * const functionThatMightFail = (): Result<string, string> => Ok(\"Hello, World!\");\n *\n * const result = functionThatMightFail();\n *\n * console.log(result.unwrap()); // \"Hello, World!\"\n * ```\n */\nclass Result<T, E> {\n\tprivate readonly _result: _Result<T, E>;\n\n\tconstructor(result: _Result<T, E>) {\n\t\tthis._result = result;\n\t}\n\n\t/** Allows you to run callbacks based on the result.\n\t *\n\t * @param success callback to be run when result is success\n\t * @param failure callback to be run when result is failure\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.match(\n\t * \t(val) => val,\n\t * \t() => {\n\t * \t\tthrow new Error('oops!')\n\t * \t}\n\t * );\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"Hello, World!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * const val = result.match(\n\t * \t(val) => val,\n\t * \t() => {\n\t * \t\tthrow new Error('oops!')\n\t * \t}\n\t * );\n\t *\n\t * console.log(val); // \"Hello, World!\"\n\t * ```\n\t */\n\tmatch<A, B = A>(success: (val: T) => A, failure: (err: E) => B): A | B {\n\t\tif (!this._result.ok) {\n\t\t\treturn failure(this._result.err);\n\t\t}\n\n\t\treturn success(this._result.val);\n\t}\n\n\t/** Maps `Result<T, E>` to `Result<A, E>` using the passed mapping function\n\t *\n\t * @param fn Mapping function\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.map((val) => val.length);\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"Hello, World!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * const hello = result.map((val) => val.slice(0, 5));\n\t *\n\t * console.log(hello.unwrap()); // \"Hello\"\n\t * ```\n\t */\n\tmap<A>(fn: (val: T) => A): Result<A, E> {\n\t\treturn this.match(\n\t\t\t(val) => Ok(fn(val)),\n\t\t\t(err) => Err(err)\n\t\t);\n\t}\n\n\t/** In the `Ok` case returns the mapped value using the function else returns `defaultVal`\n\t *\n\t * @param defaultVal Value to be returned when `Err`\n\t * @param fn Mapping function to map in case of `Ok`\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.mapOr(1, (val) => val.length);\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ### When `Ok`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"foo\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * const length = result.mapOr(1, (val) => val.length);\n\t *\n\t * console.log(length); // 3\n\t * ```\n\t *\n\t * ### When `Err`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(\"oops!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * const length = result.mapOr(1, (val) => val.length);\n\t *\n\t * console.log(length); // 1\n\t * ```\n\t */\n\tmapOr<A>(defaultVal: A, fn: (val: T) => A): A {\n\t\treturn this.match(\n\t\t\t(val) => fn(val),\n\t\t\t(_) => defaultVal\n\t\t);\n\t}\n\n\t/** In the `Ok` case returns the mapped value using `fn` else returns value of `def`\n\t *\n\t * @param def Mapping function called when `Err`\n\t * @param fn Mapping function called when `Ok`\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.mapOrElse(() => 1, (val) => val.length);\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ### When `Ok`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"foo\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * const length = result.mapOrElse(() => 1, (val) => val.length);\n\t *\n\t * console.log(length); // 3\n\t * ```\n\t *\n\t * ### When `Err`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(\"oops!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * const length = result.mapOr(() => 1, (val) => val.length);\n\t *\n\t * console.log(length); // 1\n\t * ```\n\t */\n\tmapOrElse<A>(def: (err: E) => A, fn: (val: T) => A): A {\n\t\treturn this.match(\n\t\t\t(val) => fn(val),\n\t\t\t(err) => def(err)\n\t\t);\n\t}\n\n\t/** Maps `Result<T, E>` to `Result<T, A>` using the passed mapping function\n\t *\n\t * @param fn Mapping function\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.mapErr((err) => getCodeMsg(err));\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(10);\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * const message = result.mapErr(() => \"Error\");\n\t *\n\t * console.log(message); // \"Error\"\n\t * ```\n\t */\n\tmapErr<A>(fn: (err: E) => A): Result<T, A> {\n\t\treturn this.match(\n\t\t\t(val) => Ok(val),\n\t\t\t(err) => Err(fn(err))\n\t\t);\n\t}\n\n\t/** In the `Err` case returns the mapped value using the function else returns `defaultVal`\n\t *\n\t * @param defaultVal Value to be returned when `Ok`\n\t * @param fn Mapping function to map in case of `Err`\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.mapErrOr(\"Should've been error\", (err) => getCodeMsg(err));\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ### When `Ok`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"foo\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * const message = result.mapErrOr(\"Should've been error\", () => \"Error\");\n\t *\n\t * console.log(message); // \"Should've been error\"\n\t * ```\n\t *\n\t * ### When `Err`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(10);\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * const message = result.mapErrOr(\"Should've been error\", () => \"Error\");\n\t *\n\t * console.log(message); // \"Error\"\n\t * ```\n\t */\n\tmapErrOr<A>(defaultVal: A, fn: (err: E) => A): A {\n\t\treturn this.match(\n\t\t\t(_) => defaultVal,\n\t\t\t(err) => fn(err)\n\t\t);\n\t}\n\n\t/** In the `Err` case returns the mapped value using the function else returns value of `def`\n\t *\n\t * @param def Mapping function called when `Ok`\n\t * @param fn Mapping function called when `Err`\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.mapErrOrElse(() => \"Value\", (_) => \"Error!\");\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ### When `Ok`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"foo\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * const length = result.mapErrOrElse(() => 1, (val) => val.length);\n\t *\n\t * console.log(length); // 1\n\t * ```\n\t *\n\t * ### When `Err`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(\"oops!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * const length = result.mapOr(() => 1, (val) => val.length);\n\t *\n\t * console.log(length); // 4\n\t * ```\n\t */\n\tmapErrOrElse<A>(def: (val: T) => A, fn: (err: E) => A): A {\n\t\treturn this.match(\n\t\t\t(val) => def(val),\n\t\t\t(err) => fn(err)\n\t\t);\n\t}\n\n\t/** Returns true if result is `Ok`\n\t *\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.isOk();\n\t * ```\n\t */\n\tisOk(): boolean {\n\t\treturn this.match(\n\t\t\t() => true,\n\t\t\t() => false\n\t\t);\n\t}\n\n\t/** Returns true if result is `Err`\n\t *\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.isErr();\n\t * ```\n\t */\n\tisErr(): boolean {\n\t\treturn this.match(\n\t\t\t() => false,\n\t\t\t() => true\n\t\t);\n\t}\n\n\t/** Tries to return value if value is `Err` throws generic error message.\n\t *\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.unwrap();\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ### When `Ok`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"Hello!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.unwrap()); // \"Hello!\"\n\t * ```\n\t *\n\t * ### When `Err`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(\"oops!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * result.unwrap(); // Error: Attempted to call `.unwrap()` on a non `Ok` value.\n\t * ```\n\t */\n\tunwrap(): T {\n\t\treturn this.match(\n\t\t\t(val) => val,\n\t\t\t() => {\n\t\t\t\tthrow new Error('Attempted to call `.unwrap()` on a non `Ok` value.');\n\t\t\t}\n\t\t);\n\t}\n\n\t/** Tries to return err if value is `Ok` throws generic error message.\n\t *\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.unwrapErr();\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ### When `Ok`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"Hello!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * result.unwrapErr(); // Error: Attempted to call `.unwrapErr()` on a non `Err` value.\n\t * ```\n\t *\n\t * ### When `Err`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(\"oops!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.unwrapErr()); // \"oops!\"\n\t * ```\n\t */\n\tunwrapErr(): E {\n\t\treturn this.match(\n\t\t\t() => {\n\t\t\t\tthrow new Error('Attempted to call `.unwrapErr()` on a non `Err` value.');\n\t\t\t},\n\t\t\t(err) => err\n\t\t);\n\t}\n\n\t/** Tries to unwrap the value if value is `Err` returns `defaultVal`\n\t *\n\t * @param defaultVal Value to be returned if `Err`\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.unwrapOr(7);\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ### When `Ok`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"Hello!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.unwrapOr(\"Yellow!\")); // \"Hello!\"\n\t * ```\n\t *\n\t * ### When `Err`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(\"oops!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.unwrapOr(\"Yellow!\")); // \"Yellow!\"\n\t * ```\n\t */\n\tunwrapOr(defaultVal: T): T {\n\t\treturn this.match(\n\t\t\t(val) => val,\n\t\t\t(_) => defaultVal\n\t\t);\n\t}\n\n\t/** Tries to unwrap the error if vale is `Ok` returns `defaultVal`\n\t *\n\t * @param defaultVal\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.unwrapErrOr(\"Error\");\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ### When `Ok`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"Hello!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.unwrapErrOr(\"Yellow!\")); // \"Yellow!\"\n\t * ```\n\t *\n\t * ### When `Err`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(\"oops!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.unwrapErrOr(\"Yellow!\")); // \"oops!\"\n\t * ```\n\t */\n\tunwrapErrOr(defaultVal: E): E {\n\t\treturn this.match(\n\t\t\t() => defaultVal,\n\t\t\t(err) => err\n\t\t);\n\t}\n\n\t/** Tries to return the value if value is `Err` calls `fn`\n\t *\n\t * @param fn Function called if `Err`\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.unwrapOrElse(() => \"Hello!\");\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ### When `Ok`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"Hello!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.unwrapOrElse(() => \"oops!\")); // \"Hello!\"\n\t * ```\n\t *\n\t * ### When `Err`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(\"oops!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.unwrapOrElse(() => \"Hello!\")); // \"Hello!\"\n\t * ```\n\t *\n\t */\n\tunwrapOrElse(fn: (err: E) => T): T {\n\t\treturn this.match(\n\t\t\t(val) => val,\n\t\t\t(err) => fn(err)\n\t\t);\n\t}\n\n\t/** Tries to return the error if value is `Ok` calls `fn`\n\t *\n\t * @param fn Function called if `Ok`\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.unwrapErrOrElse(() => \"Error!\");\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ### When `Ok`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"Hello!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.unwrapErrOrElse(() => \"oops!\")); // \"oops!\"\n\t * ```\n\t *\n\t * ### When `Err`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(\"oops!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.unwrapErrOrElse(() => \"Hello!\")); // \"oops!\"\n\t * ```\n\t *\n\t */\n\tunwrapErrOrElse(fn: (val: T) => E): E {\n\t\treturn this.match(\n\t\t\t(val) => fn(val),\n\t\t\t(err) => err\n\t\t);\n\t}\n\n\t/** Tries to return value if value is `Err` throws custom error message.\n\t *\n\t * @param message Message to show when value is `Err`\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.expect(\"Custom message\");\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ### When `Ok`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"Hello!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.expect(\"I failed!\")); // \"Hello!\"\n\t * ```\n\t *\n\t * ### When `Err`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(\"oops!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * result.expect(\"I failed!\"); // Error: I failed!\n\t * ```\n\t */\n\texpect(message: string): T {\n\t\treturn this.match(\n\t\t\t(val) => val,\n\t\t\t() => {\n\t\t\t\tthrow new Error(message);\n\t\t\t}\n\t\t);\n\t}\n\n\t/** Tries to return error value if value is `Ok` throws custom error message\n\t *\n\t * @param message\n\t * @returns\n\t *\n\t * ## Usage\n\t *\n\t * ```ts\n\t * result.expectErr(\"Custom message\");\n\t * ```\n\t *\n\t * ## Usage\n\t *\n\t * ### When `Ok`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Ok(\"Hello!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.expectErr(\"I failed!\")); // Error: I failed!\n\t * ```\n\t *\n\t * ### When `Err`\n\t *\n\t * ```ts\n\t * const functionThatMightFail = (): Result<string, string> => Err(\"oops!\");\n\t *\n\t * const result = functionThatMightFail();\n\t *\n\t * console.log(result.expectErr(\"I failed!\")); // \"oops!\"\n\t * ```\n\t */\n\texpectErr(message: string): E {\n\t\treturn this.match(\n\t\t\t() => {\n\t\t\t\tthrow new Error(message);\n\t\t\t},\n\t\t\t(err) => err\n\t\t);\n\t}\n}\n\n/** Returns a new `Ok` result type with the provided value\n *\n * @param val Value of the result\n * @returns\n *\n * ## Usage\n *\n * ```ts\n * Ok(true);\n * ```\n *\n * ## Usage\n *\n * ```ts\n * const functionThatCanFail = (condition) => {\n * \tif (condition) {\n * \t\tOk(\"Success\")\n * \t}\n *\n * \treturn Err(\"Failure\");\n * }\n * ```\n */\nexport function Ok<T>(val: T): Result<T, never> {\n\treturn new Result<T, never>({ ok: true, val });\n}\n\n/** Returns a new `Err` result type with the provided error\n *\n * @param err Error of the result\n * @returns\n *\n * ## Usage\n *\n * ```ts\n * Err(\"I failed!\");\n * ```\n *\n * ## Usage\n *\n * ```ts\n * const functionThatCanFail = (condition) => {\n * \tif (condition) {\n * \t\tOk(\"Success\")\n * \t}\n *\n * \treturn Err(\"Failure\");\n * }\n * ```\n */\nexport function Err<E>(err: E): Result<never, E> {\n\treturn new Result<never, E>({ ok: false, err });\n}\n\nexport type { Result };\n","import * as v from 'valibot';\nimport { type Category, type Manifest, categorySchema, manifestSchema } from '../types';\nimport { Err, Ok, type Result } from './blocks/ts/result';\nimport type { RegistryConfig } from './config';\n\n/** Parses the json string (if it can be) into a manifest.\n *\n * @param json\n */\nexport function parseManifest(json: string): Result<Manifest, string> {\n\tlet parsed: unknown;\n\n\ttry {\n\t\tparsed = JSON.parse(json);\n\t} catch (err) {\n\t\treturn Err(`Error parsing manifest json ${err}`);\n\t}\n\n\t// first gen array-based config\n\tif (Array.isArray(parsed)) {\n\t\tconst validated = v.safeParse(v.array(categorySchema), parsed);\n\n\t\tif (!validated.success) {\n\t\t\treturn Err(\n\t\t\t\t`Error parsing categories (array-based config) ${validated.issues.join(' ')}`\n\t\t\t);\n\t\t}\n\n\t\treturn Ok({\n\t\t\tprivate: false,\n\t\t\tcategories: validated.output,\n\t\t});\n\t}\n\n\tconst validated = v.safeParse(manifestSchema, parsed);\n\n\tif (!validated.success) {\n\t\treturn Err(`Error parsing manifest ${validated.issues.join(' ')}`);\n\t}\n\n\treturn Ok(validated.output);\n}\n\nexport function createManifest(\n\tcategories: Category[],\n\tconfigFiles: Manifest['configFiles'],\n\tconfig: RegistryConfig\n) {\n\tconst manifest: Manifest = {\n\t\tname: config.name,\n\t\tversion: config.version,\n\t\tmeta: config.meta,\n\t\taccess: config.access,\n\t\tpeerDependencies: config.peerDependencies,\n\t\tconfigFiles,\n\t\tcategories,\n\t};\n\n\treturn manifest;\n}\n","import { MANIFEST_FILE } from '../../constants';\nimport type { Manifest } from '../../types';\nimport { Err, Ok, type Result } from '../blocks/ts/result';\nimport { parseManifest } from '../manifest';\nimport { type AzureProviderState, azure } from './azure';\nimport { type BitBucketProviderState, bitbucket } from './bitbucket';\nimport { type GitHubProviderState, github } from './github';\nimport { type GitLabProviderState, gitlab } from './gitlab';\nimport { http } from './http';\nimport { type JsrepoProviderState, jsrepo } from './jsrepo';\nimport type { RegistryProvider, RegistryProviderState } from './types';\n\nexport const providers = [jsrepo, github, gitlab, bitbucket, azure, http];\n\nexport function selectProvider(url: string): RegistryProvider | undefined {\n\tconst provider = providers.find((p) => p.matches(url));\n\n\treturn provider;\n}\n\nexport type FetchOptions = {\n\ttoken: string;\n\t/** Override the fetch method. */\n\tfetch?: typeof fetch;\n\tverbose: (str: string) => void;\n};\n\nexport async function fetchRaw(\n\tstate: RegistryProviderState,\n\tresourcePath: string,\n\t{ verbose, fetch: f = fetch, token }: Partial<FetchOptions> = {}\n): Promise<Result<string, string>> {\n\tconst url = await state.provider.resolveRaw(state, resourcePath);\n\n\tverbose?.(`Trying to fetch from ${url}`);\n\n\ttry {\n\t\t// having headers as a record covers more fetch implementations\n\t\tconst headers: Record<string, string> = {};\n\n\t\tif (token !== undefined && state.provider.authHeader) {\n\t\t\tconst [key, value] = state.provider.authHeader(token);\n\n\t\t\theaders[key] = value;\n\t\t}\n\n\t\tconst response = await f(url.toString(), { headers });\n\n\t\tverbose?.(`Got a response from ${url} ${response.status} ${response.statusText}`);\n\n\t\tif (!response.ok) {\n\t\t\treturn Err(\n\t\t\t\tstate.provider.formatFetchError(\n\t\t\t\t\tstate,\n\t\t\t\t\tresourcePath,\n\t\t\t\t\t`${response.status} ${response.statusText}`\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn Ok(await response.text());\n\t} catch (err) {\n\t\treturn Err(state.provider.formatFetchError(state, resourcePath, err));\n\t}\n}\n\nexport async function fetchManifest(\n\tstate: RegistryProviderState,\n\t{ fetch: f = fetch, ...rest }: Partial<FetchOptions> = {}\n): Promise<Result<Manifest, string>> {\n\tconst manifest = await fetchRaw(state, MANIFEST_FILE, { fetch: f, ...rest });\n\n\tif (manifest.isErr()) return Err(manifest.unwrapErr());\n\n\treturn parseManifest(manifest.unwrap());\n}\n\nexport * from './types';\n\nexport {\n\tjsrepo,\n\tgithub,\n\tgitlab,\n\tbitbucket,\n\tazure,\n\thttp,\n\ttype JsrepoProviderState,\n\ttype AzureProviderState,\n\ttype GitHubProviderState,\n\ttype GitLabProviderState,\n\ttype BitBucketProviderState,\n};\n"]}
|