jsrepo 1.47.1 → 2.0.1
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/README.md +5 -1
- package/dist/api/index.d.ts +19 -4
- package/dist/api/index.js +1 -1
- package/dist/chunk-KTZ3UFRE.js +34 -0
- package/dist/chunk-KTZ3UFRE.js.map +1 -0
- package/dist/index.js +60 -60
- package/dist/index.js.map +1 -1
- package/package.json +17 -14
- package/schemas/registry-config.json +17 -0
- package/dist/chunk-BTOL2FRL.js +0 -32
- package/dist/chunk-BTOL2FRL.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
</a>
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
|
-
**jsrepo** is a CLI to build and distribute your code.
|
|
16
|
+
**jsrepo** is a CLI to build and distribute your code. It takes inspiration from the way that [shadcn/ui](https://ui.shadcn.com/) allows you install portable blocks of code.
|
|
17
|
+
|
|
18
|
+
The goal of jsrepo is to make this method of distributing code easier and more maintainable.
|
|
19
|
+
|
|
20
|
+
It does this by unifying the tooling it takes to build a registry, with the tooling it takes to distribute it. As well as providing a rich feature set to make maintaining that code much easier.
|
|
17
21
|
|
|
18
22
|
## Getting Started
|
|
19
23
|
|
package/dist/api/index.d.ts
CHANGED
|
@@ -63,6 +63,8 @@ declare const manifestConfigFileSchema: v.ObjectSchema<{
|
|
|
63
63
|
readonly optional: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
64
64
|
}, undefined>;
|
|
65
65
|
declare const manifestSchema: v.ObjectSchema<{
|
|
66
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
67
|
+
readonly version: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
66
68
|
readonly meta: v.OptionalSchema<v.ObjectSchema<{
|
|
67
69
|
readonly authors: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
68
70
|
readonly bugs: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -733,7 +735,7 @@ type ParseResult = {
|
|
|
733
735
|
};
|
|
734
736
|
type StateOptions = {
|
|
735
737
|
token?: string;
|
|
736
|
-
/** Override the fetch method.
|
|
738
|
+
/** Override the fetch method. */
|
|
737
739
|
fetch?: typeof fetch;
|
|
738
740
|
};
|
|
739
741
|
/** Pass this to the `.provider` property of this to access the methods for this provider */
|
|
@@ -776,7 +778,6 @@ declare const bitbucket: RegistryProvider;
|
|
|
776
778
|
interface GitHubProviderState extends RegistryProviderState {
|
|
777
779
|
owner: string;
|
|
778
780
|
repoName: string;
|
|
779
|
-
refs: 'tags' | 'heads';
|
|
780
781
|
ref: string;
|
|
781
782
|
}
|
|
782
783
|
/** Valid paths
|
|
@@ -817,15 +818,29 @@ declare const gitlab: RegistryProvider;
|
|
|
817
818
|
*/
|
|
818
819
|
declare const http: RegistryProvider;
|
|
819
820
|
|
|
821
|
+
interface JsrepoProviderState extends RegistryProviderState {
|
|
822
|
+
scope: string;
|
|
823
|
+
registryName: string;
|
|
824
|
+
version: string;
|
|
825
|
+
}
|
|
826
|
+
/** Valid paths
|
|
827
|
+
*
|
|
828
|
+
* `@ieedan/std`
|
|
829
|
+
* `@ieedan/std@latest`
|
|
830
|
+
* `@ieedan/std@1.0.0`
|
|
831
|
+
* `@ieedan/std@1.0.0/ts/math`
|
|
832
|
+
*/
|
|
833
|
+
declare const jsrepo: RegistryProvider;
|
|
834
|
+
|
|
820
835
|
declare const providers: RegistryProvider[];
|
|
821
836
|
declare function selectProvider(url: string): RegistryProvider | undefined;
|
|
822
837
|
type FetchOptions = {
|
|
823
838
|
token: string;
|
|
824
|
-
/** Override the fetch method.
|
|
839
|
+
/** Override the fetch method. */
|
|
825
840
|
fetch?: typeof fetch;
|
|
826
841
|
verbose: (str: string) => void;
|
|
827
842
|
};
|
|
828
843
|
declare function fetchRaw(state: RegistryProviderState, resourcePath: string, { verbose, fetch: f, token }?: Partial<FetchOptions>): Promise<Result<string, string>>;
|
|
829
844
|
declare function fetchManifest(state: RegistryProviderState, { fetch: f, ...rest }?: Partial<FetchOptions>): Promise<Result<Manifest, string>>;
|
|
830
845
|
|
|
831
|
-
export { type AzureProviderState, type BitBucketProviderState, type Block, CONFIG_FILE, type Category, type ConfigFile, type FetchOptions, type GitHubProviderState, type GitLabProviderState, MANIFEST_FILE, type Manifest, type Meta, type ParseOptions, type ParseResult, type PeerDependency, type RegistryProvider, type RegistryProviderState, type StateOptions, azure, bitbucket, blockSchema, categorySchema, configFileSchema, fetchManifest, fetchRaw, github, gitlab, http, manifestConfigFileSchema, manifestMeta, manifestSchema, peerDependencySchema, providers, selectProvider };
|
|
846
|
+
export { type AzureProviderState, type BitBucketProviderState, type Block, CONFIG_FILE, type Category, type ConfigFile, type FetchOptions, type GitHubProviderState, type GitLabProviderState, type JsrepoProviderState, MANIFEST_FILE, type Manifest, type Meta, type ParseOptions, type ParseResult, type PeerDependency, type RegistryProvider, type RegistryProviderState, type StateOptions, azure, bitbucket, blockSchema, categorySchema, configFileSchema, fetchManifest, fetchRaw, github, gitlab, http, jsrepo, manifestConfigFileSchema, manifestMeta, manifestSchema, peerDependencySchema, providers, selectProvider };
|
package/dist/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{m as CONFIG_FILE,l as MANIFEST_FILE,
|
|
1
|
+
export{m as CONFIG_FILE,l as MANIFEST_FILE,p as azure,q as bitbucket,d as blockSchema,e as categorySchema,h as configFileSchema,A as fetchManifest,z as fetchRaw,r as github,s as gitlab,t as http,w as jsrepo,i as manifestConfigFileSchema,f as manifestMeta,j as manifestSchema,g as peerDependencySchema,x as providers,y as selectProvider}from'../chunk-KTZ3UFRE.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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())}),T=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()))}),F=o.object({name:o.optional(o.string()),version:o.optional(o.string()),meta:o.optional(J),peerDependencies:o.optional(q),configFiles:o.optional(o.array(V)),categories:o.array(T)});var _="jsrepo-manifest.json",ne="jsrepo.json";var X="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:n,refs:s}=O(r,{fullyQualified:false});return {owner:t,repoName:a,ref:n,refs:s,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:n,refs:s}=r,p=s==="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=${n}&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
|
+
|
|
3
|
+
${y.bold("This may be for one of the following reasons:")}
|
|
4
|
+
1. Either \`${y.bold(e)}\` or the containing repository doesn't exist
|
|
5
|
+
2. Your repository path is incorrect (wrong branch, wrong tag)
|
|
6
|
+
3. You are using an expired access token or a token that doesn't have access to this repository
|
|
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,...s]=t.split("/"),p;e&&(p=s.slice(s.length-2).join("/"),s=s.slice(0,s.length-2));let c=X,l="heads";return ["tags","heads"].includes(s[0])&&(l=s[0],s[1]&&s[1]!==""&&(c=s[1])),{url:`azure/${i}/${a}/${n}${c?`/${l}/${c}`:""}`,owner:i,repoName:n,project:a,ref:c,refs:l,specifier:p}}function h(r,e){for(let t of e)if(r.startsWith(t))return true;return false}function le(r,e){for(let t of e)if(r.endsWith(t))return true;return false}var z="master",m={name:"bitbucket",matches:r=>h(r.toLowerCase(),["bitbucket","https://bitbucket.org"]),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:n,ref:s}=j(r,{fullyQualified:false});if(s===void 0)try{let p=new Headers;if(e!==void 0){let[l,d]=m.authHeader(e);p.append(l,d);}let c=await t(`https://api.bitbucket.org/2.0/repositories/${a}/${n}`,{headers:p});c.ok?s=(await c.json()).mainbranch.name:s=z;}catch{s=z;}return {owner:a,ref:s,repoName:n,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
|
+
|
|
10
|
+
${y.bold("This may be for one of the following reasons:")}
|
|
11
|
+
1. Either \`${y.bold(e)}\` or the containing repository doesn't exist
|
|
12
|
+
2. Your repository path is incorrect (wrong branch, wrong tag)
|
|
13
|
+
3. You are using an expired access token or a token that doesn't have access to this repository
|
|
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,...n]=t.split("/"),s;e&&(s=n.slice(n.length-2).join("/"),n=n.slice(0,n.length-2));let p;return n[0]==="src"&&(p=n[1]),{url:`bitbucket/${i}/${a}${p?`/src/${p}`:""}`,specifier:s,owner:i,repoName:a,ref:p}}var B="main",E={name:"github",matches:r=>h(r.toLowerCase(),["github","https://github.com"]),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:n}=k(r,{fullyQualified:false});if(n===void 0)try{let s=await fetch(`https://api.github.com/repos/${i}/${a}`,{headers:{Authorization:`Bearer ${e}`}});s.ok?n=(await s.json()).default_branch:n=B;}catch{n=B;}return {owner:i,ref:n,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
|
+
|
|
17
|
+
${y.bold("This may be for one of the following reasons:")}
|
|
18
|
+
1. Either \`${y.bold(e)}\` or the containing repository doesn't exist
|
|
19
|
+
2. Your repository path is incorrect (wrong branch, wrong tag)
|
|
20
|
+
3. You are using an expired access token or a token that doesn't have access to this repository
|
|
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,...n]=t.split("/"),s;e&&(s=n.slice(n.length-2).join("/"),n=n.slice(0,n.length-2));let p;return n.length>0&&n[0]==="tree"&&(p=n[1]),{url:`github/${i}/${a}${p?`/tree/${p}`:""}`,specifier:s,owner:i,repoName:a,ref:p}}function f(...r){return r.map(e=>Z(e)).filter(Boolean).join("/")}function Z(r){let e=ee(r);return re(e)}function ee(r){let e=r;return e.startsWith("/")&&(e=e.slice(1)),e}function re(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"]),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:n,repoName:s,ref:p}=U(r,{fullyQualified:false});if(p===void 0)try{let c=new Headers;if(e!==void 0){let[d,G]=v.authHeader(e);c.append(d,G);}let l=await t(f(i,`api/v4/projects/${encodeURIComponent(`${n}/${s}`)}`),{headers:c});l.ok?p=(await l.json()).default_branch:p=I;}catch{p=I;}return {owner:n,repoName:s,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:n}=r;return new URL(f(t,`api/v4/projects/${encodeURIComponent(`${i}/${a}`)}`,`repository/files/${encodeURIComponent(e)}/raw?ref=${n}`))},authHeader:r=>["PRIVATE-TOKEN",r],formatFetchError:(r,e,t)=>`There was an error fetching \`${y.bold(e)}\` from ${y.bold(r.url)}: ${t}.
|
|
23
|
+
|
|
24
|
+
${y.bold("This may be for one of the following reasons:")}
|
|
25
|
+
1. Either \`${y.bold(e)}\` or the containing repository doesn't exist
|
|
26
|
+
2. Your repository path is incorrect (wrong branch, wrong tag)
|
|
27
|
+
3. You are using an expired access token or a token that doesn't have access to this repository
|
|
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,...s]=i.split("/"),p;e&&(p=s.slice(s.length-2).join("/"),s=s.slice(0,s.length-2));let c;if(s[0]==="-"&&s[1]==="tree")if(s[2].includes("?")){let[d]=s[2].split("?");c=d;}else c=s[2];return {url:f(t!==M?`gitlab:${t}`:t,`${a}/${n}${c?`/-/tree/${c}`:""}`),baseUrl:t,owner:a,repoName:n,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
|
+
|
|
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 Se=/^(?![-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:n}=r;return `There was an error fetching ${e} from ${i}/${a}@${n}
|
|
32
|
+
|
|
33
|
+
${y.bold(t)}`}};function L(r,{fullyQualified:e}){let[t,i,...a]=r.split("/"),[n,s]=i.split("@"),p;return e&&(p=a.slice(a.length-2).join("/")),{url:`${t}/${i}`,specifier:p,scope:t,registryName:n,version:s??"latest"}}var A=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=>g(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=>g(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 g(r){return new A({ok:true,val:r})}function u(r){return new A({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(T),e);return i.success?g({private:false,categories:i.output}):u(`Error parsing categories (array-based config) ${i.issues.join(" ")}`)}let t=o.safeParse(F,e);return t.success?g(t.output):u(`Error parsing manifest ${t.issues.join(" ")}`)}function Oe(r,e,t){return {name:t.name,version:t.version,meta:t.meta,peerDependencies:t.peerDependencies,configFiles:e,categories:r}}var oe=[R,E,v,m,b,S];function He(r){return oe.find(t=>t.matches(r))}async function ie(r,e,{verbose:t,fetch:i=fetch,token:a}={}){let n=await r.provider.resolveRaw(r,e);t?.(`Trying to fetch from ${n}`);try{let s={};if(a!==void 0&&r.provider.authHeader){let[c,l]=r.provider.authHeader(a);s[c]=l;}let p=await i(n.toString(),{headers:s});return t?.(`Got a response from ${n} ${p.status} ${p.statusText}`),p.ok?g(await p.text()):u(r.provider.formatFetchError(r,e,`${p.status} ${p.statusText}`))}catch(s){return u(r.provider.formatFetchError(r,e,s))}}async function Ie(r,{fetch:e=fetch,...t}={}){let i=await ie(r,_,{fetch:e,...t});return i.isErr()?u(i.unwrapErr()):Y(i.unwrap())}export{Ie as A,g as a,u as b,f as c,Q as d,T as e,J as f,q as g,K as h,V as i,F as j,le as k,_ as l,ne as m,Y as n,Oe as o,b as p,m as q,E as r,v as s,S as t,Se as u,W as v,R as w,oe as x,He as y,ie as z};//# sourceMappingURL=chunk-KTZ3UFRE.js.map
|
|
34
|
+
//# sourceMappingURL=chunk-KTZ3UFRE.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","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,UACR,CAAA,QAAA,CAAY,UACZ,CAAA,iBAAA,CAAqB,QAAQ,CAAO,CAAA,MAAA,EAAC,EACrC,YAAgB,CAAA,CAAA,CAAA,KAAA,CAAQ,CAAO,CAAA,MAAA,EAAC,CAChC,CAAA,eAAA,CAAmB,QAAQ,CAAO,CAAA,MAAA,EAAC,EACnC,KAAS,CAAA,CAAA,CAAA,OAAA,GACT,IAAQ,CAAA,CAAA,CAAA,QAAA,CAAW,WAAW,CAAA,IAAI,EAElC,SAAa,CAAA,CAAA,CAAA,MAAA,GACb,YAAgB,CAAA,CAAA,CAAA,OAAA,GAChB,KAAS,CAAA,CAAA,CAAA,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AAAA,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-KTZ3UFRE.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 manifestSchema = v.object({\n\tname: v.optional(v.string()),\n\tversion: v.optional(v.string()),\n\tmeta: v.optional(manifestMeta),\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 github/ieedan/std\n*/\n\n/** Returns true if `str` starts with one of the provided `strings`.\n *\n * @param str\n * @param strings\n * @returns\n *\n * ## Usage\n * ```ts\n * startsWithOneOf('ab', 'a', 'c'); // true\n * startsWithOneOf('cc', 'a', 'b'); // false\n * ```\n */\nexport function startsWithOneOf(str: string, strings: string[]): boolean {\n\tfor (const s of strings) {\n\t\tif (str.startsWith(s)) return true;\n\t}\n\n\treturn false;\n}\n\n/** Returns true if `str` starts with one of the provided `strings`.\n *\n * @param str\n * @param strings\n * @returns\n *\n * ## Usage\n * ```ts\n * endsWithOneOf('cb', 'a', 'b'); // true\n * endsWithOneOf('cc', 'a', 'b'); // false\n * ```\n */\nexport function endsWithOneOf(str: string, strings: string[]): boolean {\n\tfor (const s of strings) {\n\t\tif (str.endsWith(s)) return true;\n\t}\n\n\treturn false;\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) => startsWithOneOf(url.toLowerCase(), ['bitbucket', 'https://bitbucket.org']),\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) => startsWithOneOf(url.toLowerCase(), ['github', 'https://github.com']),\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\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\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"]}
|