UNPKG

jsrepo

Version:

A CLI to add shared code from remote repositories.

2 lines 9.23 kB
import{i as e,t}from"./picocolors-DQPB0Sb5.mjs";var n=e(t(),1),r=class extends Error{suggestion;docsLink;constructor(e,t){super(e),this.suggestion=t.suggestion,this.docsLink=t.docsLink}toString(){return`${this.message} ${this.suggestion}${n.default.gray(this.docsLink?`\n See: ${this.docsLink}`:``)}`}},i=class extends r{constructor(){super(`No package.json found.`,{suggestion:`Please run create a package.json first before initializing a jsrepo project.`})}},a=class extends r{constructor(e){super(`Invalid registry: ${n.default.bold(e)} A provider for this registry was not found.`,{suggestion:`Maybe you need to add a provider for this registry?`,docsLink:`See: https://jsrepo.dev/docs/providers`})}},o=class extends r{constructor(e,t){super(`${n.default.bold(e)} not found in ${n.default.bold(t?`${t}`:`any registry`)}.`,{suggestion:t?`Run ${n.default.bold(`\`jsrepo list ${t}\``)} to list all items in this registry`:`Run ${n.default.bold("`jsrepo list`")} to list all available registry items.`})}},s=class extends r{resourcePath;originalMessage;constructor(e,t){super(`Error fetching ${t}: ${e}`,{suggestion:`Please try again.`}),this.resourcePath=t,this.originalMessage=e}},c=class e extends r{constructor(t){super(t instanceof s?`Error fetching manifest file from ${n.default.bold(t.resourcePath)}: ${t.originalMessage}`:t instanceof e?t.message:`Error fetching manifest file: ${t instanceof Error?t.message:String(t)}`,{suggestion:`Please try again.`})}},l=class extends r{constructor(e,t){super(e instanceof s?`Error fetching ${n.default.bold(`${t.registry}/${t.item}`)} from ${n.default.bold(e.resourcePath)}: ${e.originalMessage}`:`Error fetching ${t.registry}/${t.item}: ${e instanceof Error?e.message:String(e)}`,{suggestion:`Please try again.`})}},u=class extends r{constructor(e,t){super(`Error fetching ${n.default.bold(`${t.registry}/${t.item}`)}${t.resourcePath?` from ${n.default.bold(t.resourcePath)}`:``}: ${e}`,{suggestion:`Please try again.`})}},d=class extends r{constructor(){super(`No registry was provided.`,{suggestion:"Fully qualify blocks ex: (github/ieedan/std/math) or supply them in your config with the `registries` key."})}},f=class extends r{constructor(e,t){super(`${t.map((e,n)=>`${n===t.length-1?`and `:``}${e}`).join(`, `)} contain ${n.default.bold(e)}.`,{suggestion:`You will have to be more specific by providing the registry url like: ${n.default.bold(`\`${t[0]}/${e}\``)}.`})}},p=class extends r{constructor(){super(`Config already initialized.`,{suggestion:`To configure a new registry run ${n.default.bold("`jsrepo init <registry>`")}.`})}},m=class extends r{constructor(e){super(`Failed to load config: ${e instanceof Error?e.message:String(e)}`,{suggestion:`Please try again.`})}},h=class extends r{constructor(e){super(`Config not found at ${n.default.bold(e)}.`,{suggestion:"Please run `jsrepo init` to create a config file.",docsLink:`https://jsrepo.dev/docs/jsrepo-config`})}},g=class extends r{constructor(e){super(`Invalid options: ${e.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`, `)}`,{suggestion:`Please check the options and try again.`})}},_=class extends r{constructor(){super(`No registries were found in the config.`,{suggestion:"Please define at least one registry using the `registry` key."})}},v=class extends r{constructor({item:e,type:t}){super(`No path was provided for ${n.default.bold(e)} of type ${n.default.bold(t)}.`,{suggestion:"Please configure a path with the `paths` key.",docsLink:`https://jsrepo.dev/docs/jsrepo-config#paths`})}},y=class extends r{registryName;constructor(e,t){super(e,{suggestion:t.suggestion,docsLink:t.docsLink}),this.registryName=t.registryName}},b=class extends r{constructor(e,{fileName:t}){super(`Module referenced by ${n.default.bold(t)}: ${n.default.bold(e)} not found.`,{suggestion:`Please ensure the module exists.`})}},x=class extends y{constructor({registryName:e}){super(`No outputs were defined in the registry ${n.default.bold(e)}.`,{registryName:e,suggestion:"Please define at least one output using the `registry.outputs` key.",docsLink:`https://jsrepo.dev/docs/outputs`})}},S=class extends y{constructor({registryName:e}){super(`No items were listed in the registry ${n.default.bold(e)}.`,{registryName:e,suggestion:"Please list at least one item using the `items` key."})}},C=class extends y{constructor({name:e,registryName:t}){super(`Duplicate item name: ${n.default.bold(e)}.`,{registryName:t,suggestion:`Please ensure each item has a unique name.`})}},w=class extends y{constructor({name:e,registryName:t}){super(`Self reference: ${n.default.bold(e)}.`,{registryName:t,suggestion:`Please ensure each item does not reference itself.`})}},T=class extends y{constructor({name:e,registryName:t}){super(`No files were listed in the item ${n.default.bold(e)}.`,{registryName:t,suggestion:"Please list at least one file using the `files` key."})}},E=class extends y{constructor({name:e,registryName:t}){super(`Illegal item name: ${n.default.bold(e)}.`,{registryName:t,suggestion:`Please update the name of your item.`})}},D=class extends y{constructor({dependency:e,item:t,registryName:r}){super(`Invalid registry dependency: ${n.default.bold(e)} for item ${n.default.bold(t)}.`,{registryName:r,suggestion:`Please ensure the dependency is a valid item in the registry.`})}},O=class extends y{constructor({dependency:e,registryName:t,itemName:r}){super(`Invalid dependency: ${n.default.bold(e)} for ${n.default.bold(r)}.`,{registryName:t,suggestion:`Please ensure the dependency is a valid npm package name.`})}},k=class extends y{constructor({path:e,parent:t,duplicateParent:r,registryName:i}){super(`Duplicate file reference: ${n.default.bold(e)} is in both ${n.default.bold(`${t.type}/${t.name}`)} and ${n.default.bold(`${r.type}/${r.name}`)}.`,{registryName:i,suggestion:`Please ensure the file is not referenced multiple times.`})}},A=class extends y{constructor({path:e,parent:t,registryName:r}){super(`File not found: ${n.default.bold(e)} in ${n.default.bold(t.name)} of type ${n.default.bold(t.type)}.`,{registryName:r,suggestion:`Please ensure the file exists.`})}},j=class extends y{constructor({referencedFile:e,fileName:t,item:r,registryName:i}){super(`Imported file not resolved: ${n.default.bold(e)} in ${n.default.bold(t)} of item ${n.default.bold(r)}.`,{registryName:i,suggestion:`Make sure the file exists and is part of the registry.`})}},M=class extends r{constructor(e){super(`Invalid plugin name: ${n.default.bold(e)} is not a valid npm package name.`,{suggestion:`Double check the plugin name and try again.`})}},N=class extends r{constructor({key:e,type:t}){super(`The ${n.default.bold(e)} key in your config must be an ${n.default.bold(t)}.`,{suggestion:`Please check your config and try again.`})}},P=class extends r{constructor(){super(`We couldn't locate the config object in your config.`,{suggestion:`Please check your config and try again.`})}},F=class extends r{constructor(){super(`We couldn't find the jsrepo import in your config.`,{suggestion:`Please check your config and try again.`})}},I=class extends r{zodError;constructor(e){super(`Zod error: ${e.message}`,{suggestion:`Check the input schema and try again.`}),this.zodError=e}},L=class extends r{constructor(e){super(`Invalid JSON: ${e instanceof Error?e.stack??e.message:`${e}`}`,{suggestion:`Check the input JSON and try again.`})}},R=class extends y{constructor(e,t,r){super(`Error while parsing glob pattern ${n.default.bold(t)}: ${e instanceof Error?e.message:String(e)}`,{registryName:r,suggestion:`Please check the glob pattern and try again.`})}},z=class extends r{constructor(e){super(`No provider found for ${n.default.bold(e)}. Maybe you need to add it to your config?`,{suggestion:`Please check the provider name and try again.`})}},B=class extends r{constructor(){super(`We couldn't find any items to update.`,{suggestion:"Add items to your project using `jsrepo add` and then run `jsrepo update` to update them."})}},V=class extends r{constructor(e,t){super(`${n.default.bold(e)} is required for ${t} to work.`,{suggestion:`Please install it.`})}},H=class extends r{constructor(e){super(`Invalid registry name: ${n.default.bold(e)} is not a valid name. The name should be provided as ${n.default.bold("`@<scope>/<registry>`")}.`,{suggestion:`Please check the registry name and try again.`})}},U=class extends r{constructor(e,t){e===void 0?super(`No version was provided for ${n.default.bold(t)}.`,{suggestion:`Please provide a version using the ${n.default.bold("`version`")} key.`}):super(`Invalid version for ${n.default.bold(t)}: ${n.default.bold(e)} is not a valid version. The version should be provided as ${n.default.bold("`<major>.<minor>.<patch>`")}.`,{suggestion:`Please check the registry version and try again.`})}},W=class extends r{constructor(){super(`This code path should be unreachable.`,{suggestion:`This is a bug, please report it.`})}};export{x as A,w as B,c as C,T as D,f as E,s as F,I as H,u as I,l as L,v as M,z as N,B as O,_ as P,o as R,r as S,b as T,W as V,M as _,F as a,H as b,m as c,E as d,j as f,g,N as h,P as i,i as j,S as k,A as l,L as m,y as n,k as o,O as p,h as r,C as s,p as t,R as u,D as v,V as w,U as x,a as y,d as z}; //# sourceMappingURL=errors-ZO96VU6k.mjs.map