jsrepo 1.46.2 → 1.47.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 CHANGED
@@ -1,22 +1,27 @@
1
1
  <p align="center">
2
- <img src="https://github.com/user-attachments/assets/f1c70c20-3a4c-4d36-a21e-4d87cdf4f203">
2
+ <a href="https://jsrepo.dev">
3
+ <picture>
4
+ <img src="https://github.com/user-attachments/assets/fb4b84c3-8f81-4e1d-a049-ed909c3dae68">
5
+ </picture>
6
+ <h1 align="center">jsrepo</h1>
7
+ </a>
3
8
  </p>
4
9
 
5
- # jsrepo
10
+ <p align="center">
11
+ <a aria-label="jsrepo logo" href="https://jsrepo.dev">
12
+ <img alt="" src="https://jsrepo.dev/badges/jsrepo.svg">
13
+ </a>
14
+ </p>
6
15
 
7
- ```bash
8
- npm install jsrepo@latest -g
9
- ```
16
+ **jsrepo** is a CLI to build and distribute your code.
10
17
 
11
- CLI for [jsrepo](https://jsrepo.dev). Used to build and download code from registries that **YOU** own.
18
+ ## Getting Started
12
19
 
13
- Kinda like [shadcn-ui](https://ui.shadcn.com/) but bring-your-own registry!
20
+ - [Create a registry](https://jsrepo.dev/docs/registry)
21
+ - [Download your blocks](https://jsrepo.dev/docs/setup)
14
22
 
15
- 1. [Build your own registry](https://jsrepo.dev/docs/setup/registry)
16
- 2. [Download your blocks](https://jsrepo.dev/docs/setup/project)
23
+ ## Demos
17
24
 
18
- ## Example registries
19
- - [github/ieedan/std](https://github.com/ieedan/std)
20
- - [gitlab/ieedan/std](https://gitlab.com/ieedan/std)
21
- - [bitbucket/ieedan/std](https://bitbucket.org/ieedan/std)
22
-
25
+ - [Create your first registry](https://youtu.be/IyJQI3z8PWg)
26
+ - [Build your own shadcn-style library with jsrepo](https://youtu.be/zWfBt1vKb84)
27
+ - [Building the shadcn/ui registry with jsrepo](https://youtu.be/tj7BUE9V7fw)
@@ -126,7 +126,7 @@ type _Result<T, E> = {
126
126
  * function functionThatMightFail(): Result<T, E>;
127
127
  * ```
128
128
  *
129
- * ## Examples
129
+ * ## Usage
130
130
  *
131
131
  * ```ts
132
132
  * const functionThatMightFail = (): Result<string, string> => Ok("Hello, World!");
@@ -156,7 +156,7 @@ declare class Result<T, E> {
156
156
  * );
157
157
  * ```
158
158
  *
159
- * ## Examples
159
+ * ## Usage
160
160
  *
161
161
  * ```ts
162
162
  * const functionThatMightFail = (): Result<string, string> => Ok("Hello, World!");
@@ -185,7 +185,7 @@ declare class Result<T, E> {
185
185
  * result.map((val) => val.length);
186
186
  * ```
187
187
  *
188
- * ## Examples
188
+ * ## Usage
189
189
  *
190
190
  * ```ts
191
191
  * const functionThatMightFail = (): Result<string, string> => Ok("Hello, World!");
@@ -210,7 +210,7 @@ declare class Result<T, E> {
210
210
  * result.mapOr(1, (val) => val.length);
211
211
  * ```
212
212
  *
213
- * ## Examples
213
+ * ## Usage
214
214
  *
215
215
  * ### When `Ok`
216
216
  *
@@ -249,7 +249,7 @@ declare class Result<T, E> {
249
249
  * result.mapOrElse(() => 1, (val) => val.length);
250
250
  * ```
251
251
  *
252
- * ## Examples
252
+ * ## Usage
253
253
  *
254
254
  * ### When `Ok`
255
255
  *
@@ -287,7 +287,7 @@ declare class Result<T, E> {
287
287
  * result.mapErr((err) => getCodeMsg(err));
288
288
  * ```
289
289
  *
290
- * ## Examples
290
+ * ## Usage
291
291
  *
292
292
  * ```ts
293
293
  * const functionThatMightFail = (): Result<string, string> => Err(10);
@@ -312,7 +312,7 @@ declare class Result<T, E> {
312
312
  * result.mapErrOr("Should've been error", (err) => getCodeMsg(err));
313
313
  * ```
314
314
  *
315
- * ## Examples
315
+ * ## Usage
316
316
  *
317
317
  * ### When `Ok`
318
318
  *
@@ -351,7 +351,7 @@ declare class Result<T, E> {
351
351
  * result.mapErrOrElse(() => "Value", (_) => "Error!");
352
352
  * ```
353
353
  *
354
- * ## Examples
354
+ * ## Usage
355
355
  *
356
356
  * ### When `Ok`
357
357
  *
@@ -410,7 +410,7 @@ declare class Result<T, E> {
410
410
  * result.unwrap();
411
411
  * ```
412
412
  *
413
- * ## Examples
413
+ * ## Usage
414
414
  *
415
415
  * ### When `Ok`
416
416
  *
@@ -443,7 +443,7 @@ declare class Result<T, E> {
443
443
  * result.unwrapErr();
444
444
  * ```
445
445
  *
446
- * ## Examples
446
+ * ## Usage
447
447
  *
448
448
  * ### When `Ok`
449
449
  *
@@ -477,7 +477,7 @@ declare class Result<T, E> {
477
477
  * result.unwrapOr(7);
478
478
  * ```
479
479
  *
480
- * ## Examples
480
+ * ## Usage
481
481
  *
482
482
  * ### When `Ok`
483
483
  *
@@ -511,7 +511,7 @@ declare class Result<T, E> {
511
511
  * result.unwrapErrOr("Error");
512
512
  * ```
513
513
  *
514
- * ## Examples
514
+ * ## Usage
515
515
  *
516
516
  * ### When `Ok`
517
517
  *
@@ -544,7 +544,7 @@ declare class Result<T, E> {
544
544
  * result.unwrapOrElse(() => "Hello!");
545
545
  * ```
546
546
  *
547
- * ## Examples
547
+ * ## Usage
548
548
  *
549
549
  * ### When `Ok`
550
550
  *
@@ -578,7 +578,7 @@ declare class Result<T, E> {
578
578
  * result.unwrapErrOrElse(() => "Error!");
579
579
  * ```
580
580
  *
581
- * ## Examples
581
+ * ## Usage
582
582
  *
583
583
  * ### When `Ok`
584
584
  *
@@ -613,7 +613,7 @@ declare class Result<T, E> {
613
613
  * result.expect("Custom message");
614
614
  * ```
615
615
  *
616
- * ## Examples
616
+ * ## Usage
617
617
  *
618
618
  * ### When `Ok`
619
619
  *
@@ -647,7 +647,7 @@ declare class Result<T, E> {
647
647
  * result.expectErr("Custom message");
648
648
  * ```
649
649
  *
650
- * ## Examples
650
+ * ## Usage
651
651
  *
652
652
  * ### When `Ok`
653
653
  *
@@ -818,14 +818,14 @@ declare const gitlab: RegistryProvider;
818
818
  declare const http: RegistryProvider;
819
819
 
820
820
  declare const providers: RegistryProvider[];
821
- declare const selectProvider: (url: string) => RegistryProvider | undefined;
821
+ declare function selectProvider(url: string): RegistryProvider | undefined;
822
822
  type FetchOptions = {
823
823
  token: string;
824
824
  /** Override the fetch method. If you are using this in a node environment you will want to pass `node-fetch` */
825
825
  fetch?: typeof fetch;
826
826
  verbose: (str: string) => void;
827
827
  };
828
- declare const fetchRaw: (state: RegistryProviderState, resourcePath: string, { verbose, fetch: f, token }?: Partial<FetchOptions>) => Promise<Result<string, string>>;
829
- declare const fetchManifest: (state: RegistryProviderState, { fetch: f, ...rest }?: Partial<FetchOptions>) => Promise<Result<Manifest, string>>;
828
+ declare function fetchRaw(state: RegistryProviderState, resourcePath: string, { verbose, fetch: f, token }?: Partial<FetchOptions>): Promise<Result<string, string>>;
829
+ declare function fetchManifest(state: RegistryProviderState, { fetch: f, ...rest }?: Partial<FetchOptions>): Promise<Result<Manifest, string>>;
830
830
 
831
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 };
package/dist/api/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export{m as CONFIG_FILE,l as MANIFEST_FILE,o as azure,p as bitbucket,d as blockSchema,e as categorySchema,h as configFileSchema,w as fetchManifest,v as fetchRaw,q as github,r as gitlab,s as http,i as manifestConfigFileSchema,f as manifestMeta,j as manifestSchema,g as peerDependencySchema,t as providers,u as selectProvider}from'../chunk-6BJA5YI6.js';//# sourceMappingURL=index.js.map
1
+ export{m as CONFIG_FILE,l as MANIFEST_FILE,o as azure,p as bitbucket,d as blockSchema,e as categorySchema,h as configFileSchema,w as fetchManifest,v as fetchRaw,q as github,r as gitlab,s as http,i as manifestConfigFileSchema,f as manifestMeta,j as manifestSchema,g as peerDependencySchema,t as providers,u as selectProvider}from'../chunk-BTOL2FRL.js';//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,32 @@
1
+ import*as o from'valibot';import y from'chalk';import {Octokit}from'octokit';var W=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(W)}),Y=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()))}),G=o.record(o.string(),o.union([o.string(),o.object({version:o.string(),message:o.string()})])),Q=o.object({name:o.string(),path:o.string(),expectedPath:o.optional(o.string()),optional:o.optional(o.boolean(),false)}),q=o.object({...Q.entries,dependencies:o.optional(o.array(o.string())),devDependencies:o.optional(o.array(o.string()))}),N=o.object({meta:o.optional(Y),peerDependencies:o.optional(G),configFiles:o.optional(o.array(q)),categories:o.array(A)});var L="jsrepo-manifest.json",oe="jsrepo.json";var J="main",b={name:"azure",matches:r=>r.toLowerCase().startsWith("azure"),parse:(r,e)=>{let t=T(r,e);return {url:t.url,specifier:t.specifier}},baseUrl:r=>{let{owner:e,repoName:t}=T(r,{fullyQualified:false});return `https://dev.azure.com/${e}/_git/${t}`},state:async r=>{let{url:e,owner:t,project:i,repoName:p,ref:s,refs:n}=T(r,{fullyQualified:false});return {owner:t,repoName:p,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:p,ref:s,refs:n}=r,a=n==="tags"?"tag":"branch";return new URL(`https://dev.azure.com/${t}/${p}/_apis/git/repositories/${i}/items?path=${e}&api-version=7.2-preview.1&versionDescriptor.version=${s}&versionDescriptor.versionType=${a}`)},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 T(r,{fullyQualified:e}){let t=r.replaceAll(/(azure\/)/g,""),[i,p,s,...n]=t.split("/"),a;e&&(a=n.slice(n.length-2).join("/"),n=n.slice(0,n.length-2));let c=J,l="heads";return ["tags","heads"].includes(n[0])&&(l=n[0],n[1]&&n[1]!==""&&(c=n[1])),{url:`azure/${i}/${p}/${s}${c?`/${l}/${c}`:""}`,owner:i,repoName:s,project:p,ref:c,refs:l,specifier:a}}function h(r,e){for(let t of e)if(r.startsWith(t))return true;return false}function ae(r,e){for(let t of e)if(r.endsWith(t))return true;return false}var F="master",m={name:"bitbucket",matches:r=>h(r.toLowerCase(),["bitbucket","https://bitbucket.org"]),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://bitbucket.org/${e}/${t}`},state:async(r,{token:e,fetch:t=fetch}={})=>{let{url:i,owner:p,repoName:s,ref:n}=O(r,{fullyQualified:false});if(n===void 0)try{let a=new Headers;if(e!==void 0){let[l,d]=m.authHeader(e);a.append(l,d);}let c=await t(`https://api.bitbucket.org/2.0/repositories/${p}/${s}`,{headers:a});c.ok?n=(await c.json()).mainbranch.name:n=F;}catch{n=F;}return {owner:p,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:p}=r;return new URL(e,`https://api.bitbucket.org/2.0/repositories/${t}/${i}/src/${p}/`)},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 O(r,{fullyQualified:e=false}){let t=r.replaceAll(/(https:\/\/bitbucket.org\/)|(bitbucket\/)/g,""),[i,p,...s]=t.split("/"),n;e&&(n=s.slice(s.length-2).join("/"),s=s.slice(0,s.length-2));let a;return s[0]==="src"&&(a=s[1]),{url:`bitbucket/${i}/${p}${a?`/src/${a}`:""}`,specifier:n,owner:i,repoName:p,ref:a}}var _="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:p,ref:s}=k(r,{fullyQualified:false}),n=new Octokit({auth:e}),a="heads";if(s===void 0)try{let{data:c}=await n.rest.repos.get({owner:i,repo:p});s=c.default_branch;}catch{s=_;}else if(s!==_)try{let{data:c}=await n.rest.git.listMatchingRefs({owner:i,repo:p,ref:"tags"});c.some(l=>l.ref===`refs/tags/${s}`)&&(a="tags");}catch{a="heads";}return {owner:i,refs:a,ref:s,repoName:p,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,refs:p,ref:s}=r;return new URL(e,`https://raw.githubusercontent.com/${t}/${i}/refs/${p}/${s}/`)},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,p,...s]=t.split("/"),n;e&&(n=s.slice(s.length-2).join("/"),s=s.slice(0,s.length-2));let a;return s.length>0&&s[0]==="tree"&&(a=s[1]),{url:`github/${i}/${p}${a?`/tree/${a}`:""}`,specifier:n,owner:i,repoName:p,ref:a}}function f(...r){return r.map(e=>V(e)).filter(Boolean).join("/")}function V(r){let e=X(r);return Z(e)}function X(r){let e=r;return e.startsWith("/")&&(e=e.slice(1)),e}function Z(r){let e=r;return e.endsWith("/")&&(e=e.slice(0,e.length-1)),e}function B(r){let e=r;return e.endsWith("/")||(e=`${e}/`),e}var z="main",C="https://gitlab.com",v={name:"gitlab",matches:r=>h(r.toLowerCase(),["gitlab/","gitlab:","https://gitlab.com"]),parse:(r,e)=>{let t=j(r,e);return {url:t.url,specifier:t.specifier}},baseUrl:r=>{let{baseUrl:e,owner:t,repoName:i}=j(r,{fullyQualified:false});return f(e,t,i)},state:async(r,{token:e,fetch:t=fetch}={})=>{let{baseUrl:i,url:p,owner:s,repoName:n,ref:a}=j(r,{fullyQualified:false});if(a===void 0)try{let c=new Headers;if(e!==void 0){let[d,D]=v.authHeader(e);c.append(d,D);}let l=await t(f(i,`api/v4/projects/${encodeURIComponent(`${s}/${n}`)}`),{headers:c});l.ok?a=(await l.json()).default_branch:a=z;}catch{a=z;}return {owner:s,repoName:n,ref:a,baseUrl:i,url:p,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:p,ref:s}=r;return new URL(f(t,`api/v4/projects/${encodeURIComponent(`${i}/${p}`)}`,`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
+
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 j(r,{fullyQualified:e}){let t=C;r.startsWith("gitlab:")&&(t=new URL(r.slice(7)).origin);let i=r.replaceAll(/gitlab\/|https:\/\/gitlab\.com\/|gitlab:https?:\/\/[^/]+\//g,""),[p,s,...n]=i.split("/"),a;e&&(a=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[d]=n[2].split("?");c=d;}else c=n[2];return {url:f(t!==C?`gitlab:${t}`:t,`${p}/${s}${c?`/-/tree/${c}`:""}`),baseUrl:t,owner:p,repoName:s,ref:c,specifier:a}}var S={name:"http",matches:r=>{try{return new URL(r),!0}catch{return false}},parse:(r,e)=>{let t=U(r,e);return {url:t.url,specifier:t.specifier}},baseUrl:r=>{let{url:e}=U(r,{fullyQualified:false});return new URL(e).origin},state:async r=>{let{url:e}=U(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 U(r,{fullyQualified:e}){let t=new URL(r),i=t.pathname.split("/"),p;return e&&(p=i.slice(i.length-2).join("/"),i=i.slice(0,i.length-2)),{url:B(f(t.origin,...i)),specifier:p}}var P=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 P({ok:true,val:r})}function u(r){return new P({ok:false,err:r})}function M(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?g({categories:i.output}):u(`Error parsing categories (array-based config) ${i.issues.join(" ")}`)}let t=o.safeParse(N,e);return t.success?g(t.output):u(`Error parsing manifest ${t.issues.join(" ")}`)}var ee=[E,v,m,b,S];function Ne(r){return ee.find(t=>t.matches(r))}async function re(r,e,{verbose:t,fetch:i=fetch,token:p}={}){let s=await r.provider.resolveRaw(r,e);t?.(`Trying to fetch from ${s}`);try{let n=new Headers;if(p!==void 0&&r.provider.authHeader){let[c,l]=r.provider.authHeader(p);n.append(c,l);}let a=await i(s,{headers:n});return t?.(`Got a response from ${s} ${a.status} ${a.statusText}`),a.ok?g(await a.text()):u(r.provider.formatFetchError(r,e,`${a.status} ${a.statusText}`))}catch(n){return u(r.provider.formatFetchError(r,e,n))}}async function Le(r,{fetch:e=fetch,...t}={}){let i=await re(r,L,{fetch:e,...t});return i.isErr()?u(i.unwrapErr()):M(i.unwrap())}export{g as a,u as b,f as c,W as d,A as e,Y as f,G as g,Q as h,q as i,N as j,ae as k,L as l,oe as m,M as n,b as o,m as p,E as q,v as r,S as s,ee as t,Ne as u,re as v,Le as w};//# sourceMappingURL=chunk-BTOL2FRL.js.map
32
+ //# sourceMappingURL=chunk-BTOL2FRL.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/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","octokit","Octokit","tags","tag","join","segments","removeLeadingAndTrailingSlash","segment","newSegment","removeLeadingSlash","removeTrailingSlash","addTrailingSlash","BASE_URL","gitlab","baseUrl","error","tempRef","http","u","parsedUrl","Result","result","success","failure","fn","val","Ok","err","Err","defaultVal","_","def","message","parseManifest","json","validated","R","providers","selectProvider","p","fetchRaw","verbose","fetchManifest","manifest"],"mappings":"6EA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CATvB8B,CAAAA,CAAAA,CACNlD,CAAM,CAAA,QAAA,CAAS,iBACdA,CACAC,CAAAA,CAAAA,CACA,CAAGmB,EAAAA,CAAAA,CAAS,MAAM,CAAIA,CAAAA,EAAAA,CAAAA,CAAS,UAAU,CAAA,CAC1C,CACD,CAIF,CAAA,MAAS6B,CAAK,CAAA,CACb,OAAOC,CAAIlD,CAAAA,CAAAA,CAAM,QAAS,CAAA,gBAAA,CAAiBA,EAAOC,CAAcgD,CAAAA,CAAG,CAAC,CACrE,CACD,CAEA,eAAsBe,EACrBhE,CAAAA,CAAAA,CACA,CAAE,KAAOgB,CAAAA,CAAAA,CAAI,KAAO,CAAA,GAAGR,CAAK,CAA2B,CAAA,EACnB,CAAA,CACpC,IAAMyD,CAAW,CAAA,MAAMH,EAAS9D,CAAAA,CAAAA,CAAOd,EAAe,CAAE,KAAA,CAAO8B,CAAG,CAAA,GAAGR,CAAK,CAAC,CAAA,CAE3E,OAAIyD,CAAAA,CAAS,OAAgBf,CAAAA,CAAAA,CAAIe,CAAS,CAAA,SAAA,EAAW,CAE9CV,CAAAA,CAAAA,CAAcU,CAAS,CAAA,MAAA,EAAQ,CACvC","file":"chunk-BTOL2FRL.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\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 { Octokit } from 'octokit';\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\trefs: 'tags' | 'heads';\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\tconst octokit = new Octokit({ auth: token });\n\n\t\t// checks if the type of the ref is tags or heads\n\t\tlet refs: 'heads' | 'tags' = 'heads';\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 { data: repo } = await octokit.rest.repos.get({ owner, repo: repoName });\n\n\t\t\t\tref = repo.default_branch;\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} else {\n\t\t\t// no need to check if ref is main\n\n\t\t\t// this isn't a double case it's possible that DEFAULT_BRANCH and repo.default_branch are not equal\n\t\t\tif (ref !== DEFAULT_BRANCH) {\n\t\t\t\ttry {\n\t\t\t\t\tconst { data: tags } = await octokit.rest.git.listMatchingRefs({\n\t\t\t\t\t\towner,\n\t\t\t\t\t\trepo: repoName,\n\t\t\t\t\t\tref: 'tags',\n\t\t\t\t\t});\n\n\t\t\t\t\tif (tags.some((tag) => tag.ref === `refs/tags/${ref}`)) {\n\t\t\t\t\t\trefs = 'tags';\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\trefs = 'heads';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\towner,\n\t\t\trefs,\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, refs, ref } = state as GitHubProviderState;\n\n\t\treturn new URL(\n\t\t\tresourcePath,\n\t\t\t`https://raw.githubusercontent.com/${owner}/${repoName}/refs/${refs}/${ref}/`\n\t\t);\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","/*\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 Manifest, categorySchema, manifestSchema } from '../types';\nimport { Err, Ok, type Result } from './blocks/ts/result';\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\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","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 { RegistryProvider, RegistryProviderState } from './types';\n\nexport const providers = [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. If you are using this in a node environment you will want to pass `node-fetch` */\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\tconst headers = new Headers();\n\n\t\tif (token !== undefined && state.provider.authHeader) {\n\t\t\tconst [key, value] = state.provider.authHeader(token);\n\n\t\t\theaders.append(key, value);\n\t\t}\n\n\t\tconst response = await f(url, { 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\tgithub,\n\tgitlab,\n\tbitbucket,\n\tazure,\n\thttp,\n\ttype AzureProviderState,\n\ttype GitHubProviderState,\n\ttype GitLabProviderState,\n\ttype BitBucketProviderState,\n};\n"]}