@mercurjs/cli 2.1.1 → 2.1.2-canary.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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import {Command}from'commander';import*as R from'path';import R__default,{join,basename}from'path';import $e from'prompts';import {z}from'zod';import Mt,{promises,existsSync,readFileSync,mkdirSync,writeFileSync,statSync}from'fs';import {cosmiconfig}from'cosmiconfig';import {loadConfig,createMatchPath}from'tsconfig-paths';import M from'fs-extra';import'typescript';import dt from'fast-glob';import {createHash}from'crypto';import mr from'deepmerge';import*as U from'fs/promises';import U__default,{writeFile,rm}from'fs/promises';import {homedir,tmpdir}from'os';import {Project,ScriptKind}from'ts-morph';import O from'kleur';import fi from'ora';import {execa}from'execa';import {detect}from'@antfu/ni';import {diffLines}from'diff';import {spawn,execSync}from'child_process';import {Readable}from'stream';import {pipeline}from'stream/promises';import Tt from'pg';import Ms from'open';import {x as x$1}from'tar';import Us from'terminal-link';import zs from'validate-npm-package-name';import Bs from'wait-on';import vn from'cross-spawn';import {packageDirectory}from'pkg-dir';import yn from'resolve-cwd';import {builtinModules}from'module';import {generatePluginEntryModule}from'@mercurjs/dashboard-sdk';var Ut={version:"2.1.1"};var zt="MISSING_DIR_OR_EMPTY_PROJECT",S="MISSING_CONFIG",B="BUILD_MISSING_REGISTRY_FILE";var So=z.enum(["registry:api","registry:vendor","registry:admin"]),Bt=z.object({path:z.string(),content:z.string().optional(),type:So,target:z.string().optional()}),Wt=z.object({$schema:z.string().optional(),name:z.string(),title:z.string().optional(),author:z.string().min(2).optional(),description:z.string().optional(),dependencies:z.array(z.string()).optional(),devDependencies:z.array(z.string()).optional(),registryDependencies:z.array(z.string()).optional(),meta:z.record(z.string(),z.any()).optional(),docs:z.string().optional(),categories:z.array(z.string()).optional()}),T=Wt.extend({files:z.array(Bt)}),Z=z.object({name:z.string(),homepage:z.string(),items:z.array(T)}),Hn=z.array(Wt),Gt=T.pick({dependencies:true,devDependencies:true,files:true,docs:true}),Co=z.union([z.string(),z.object({url:z.string(),params:z.record(z.string(),z.string()).optional(),headers:z.record(z.string(),z.string()).optional()})]),Vt=z.record(z.string().refine(e=>e.startsWith("@"),{message:"Registry names must start with @ (e.g., @mercurjs)"}),Co);var Me="https://registry.mercurjs.com/registry.json",Yt="https://registry.mercurjs.com/registry-item.json",ve=process.env.REGISTRY_URL??"https://raw.githubusercontent.com/mercurjs/mercur/canary/packages/registry/r",C={"@mercurjs":`${ve}/{name}.json`};var $={NOT_FOUND:"NOT_FOUND",UNAUTHORIZED:"UNAUTHORIZED",FORBIDDEN:"FORBIDDEN",FETCH_ERROR:"FETCH_ERROR",NOT_CONFIGURED:"NOT_CONFIGURED",INVALID_CONFIG:"INVALID_CONFIG",MISSING_ENV_VARS:"MISSING_ENV_VARS",LOCAL_FILE_ERROR:"LOCAL_FILE_ERROR",PARSE_ERROR:"PARSE_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",UNKNOWN_ERROR:"UNKNOWN_ERROR"},_=class extends Error{code;statusCode;context;suggestion;timestamp;cause;constructor(t,r={}){super(t),this.name="RegistryError",this.code=r.code||$.UNKNOWN_ERROR,this.statusCode=r.statusCode,this.cause=r.cause,this.context=r.context,this.suggestion=r.suggestion,this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor);}},de=class extends _{constructor(r,o){let i=`The item at ${r} was not found. It may not exist at the registry.`;super(i,{code:$.NOT_FOUND,statusCode:404,cause:o,context:{url:r},suggestion:"Check if the item name is correct and the registry URL is accessible."});this.url=r;this.name="RegistryNotFoundError";}},Le=class extends _{constructor(r,o){let i=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(i,{code:$.UNAUTHORIZED,statusCode:401,cause:o,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}},Ue=class extends _{constructor(r,o){let i=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(i,{code:$.FORBIDDEN,statusCode:403,cause:o,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}},ze=class extends _{constructor(r,o,i,s){let n=o?`Failed to fetch from registry (${o}): ${r}`:`Failed to fetch from registry: ${r}`,m=typeof s=="string"&&s?`${n} - ${s}`:n,p="Check your network connection and try again.";o===404?p="The requested resource was not found. Check the URL or item name.":o===500?p="The registry server encountered an error. Try again later.":o&&o>=400&&o<500&&(p="There was a client error. Check your request parameters.");super(m,{code:$.FETCH_ERROR,statusCode:o,cause:s,context:{url:r,responseBody:i},suggestion:p});this.url=r;this.responseBody=i;this.name="RegistryFetchError";}},Q=class extends _{constructor(r){let o=r?`Unknown registry "${r}". Make sure it is defined in agents.json as follows:
2
+ import {Command}from'commander';import*as R from'path';import R__default,{join,basename}from'path';import $e from'prompts';import {z}from'zod';import Mt,{promises,existsSync,readFileSync,mkdirSync,writeFileSync,statSync}from'fs';import {cosmiconfig}from'cosmiconfig';import {loadConfig,createMatchPath}from'tsconfig-paths';import M from'fs-extra';import'typescript';import dt from'fast-glob';import {createHash}from'crypto';import mr from'deepmerge';import*as U from'fs/promises';import U__default,{writeFile,rm}from'fs/promises';import {homedir,tmpdir}from'os';import {Project,ScriptKind}from'ts-morph';import O from'kleur';import fi from'ora';import {execa}from'execa';import {detect}from'@antfu/ni';import {diffLines}from'diff';import {spawn,execSync}from'child_process';import {Readable}from'stream';import {pipeline}from'stream/promises';import Tt from'pg';import Ms from'open';import {x as x$1}from'tar';import Us from'terminal-link';import zs from'validate-npm-package-name';import Bs from'wait-on';import vn from'cross-spawn';import {packageDirectory}from'pkg-dir';import yn from'resolve-cwd';import {builtinModules}from'module';import {generatePluginEntryModule}from'@mercurjs/dashboard-sdk';var Ut={version:"2.1.2-canary.1"};var zt="MISSING_DIR_OR_EMPTY_PROJECT",S="MISSING_CONFIG",B="BUILD_MISSING_REGISTRY_FILE";var So=z.enum(["registry:api","registry:vendor","registry:admin"]),Bt=z.object({path:z.string(),content:z.string().optional(),type:So,target:z.string().optional()}),Wt=z.object({$schema:z.string().optional(),name:z.string(),title:z.string().optional(),author:z.string().min(2).optional(),description:z.string().optional(),dependencies:z.array(z.string()).optional(),devDependencies:z.array(z.string()).optional(),registryDependencies:z.array(z.string()).optional(),meta:z.record(z.string(),z.any()).optional(),docs:z.string().optional(),categories:z.array(z.string()).optional()}),T=Wt.extend({files:z.array(Bt)}),Z=z.object({name:z.string(),homepage:z.string(),items:z.array(T)}),Hn=z.array(Wt),Gt=T.pick({dependencies:true,devDependencies:true,files:true,docs:true}),Co=z.union([z.string(),z.object({url:z.string(),params:z.record(z.string(),z.string()).optional(),headers:z.record(z.string(),z.string()).optional()})]),Vt=z.record(z.string().refine(e=>e.startsWith("@"),{message:"Registry names must start with @ (e.g., @mercurjs)"}),Co);var Me="https://registry.mercurjs.com/registry.json",Yt="https://registry.mercurjs.com/registry-item.json",ve=process.env.REGISTRY_URL??"https://raw.githubusercontent.com/mercurjs/mercur/canary/packages/registry/r",C={"@mercurjs":`${ve}/{name}.json`};var $={NOT_FOUND:"NOT_FOUND",UNAUTHORIZED:"UNAUTHORIZED",FORBIDDEN:"FORBIDDEN",FETCH_ERROR:"FETCH_ERROR",NOT_CONFIGURED:"NOT_CONFIGURED",INVALID_CONFIG:"INVALID_CONFIG",MISSING_ENV_VARS:"MISSING_ENV_VARS",LOCAL_FILE_ERROR:"LOCAL_FILE_ERROR",PARSE_ERROR:"PARSE_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",UNKNOWN_ERROR:"UNKNOWN_ERROR"},_=class extends Error{code;statusCode;context;suggestion;timestamp;cause;constructor(t,r={}){super(t),this.name="RegistryError",this.code=r.code||$.UNKNOWN_ERROR,this.statusCode=r.statusCode,this.cause=r.cause,this.context=r.context,this.suggestion=r.suggestion,this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor);}},de=class extends _{constructor(r,o){let i=`The item at ${r} was not found. It may not exist at the registry.`;super(i,{code:$.NOT_FOUND,statusCode:404,cause:o,context:{url:r},suggestion:"Check if the item name is correct and the registry URL is accessible."});this.url=r;this.name="RegistryNotFoundError";}},Le=class extends _{constructor(r,o){let i=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(i,{code:$.UNAUTHORIZED,statusCode:401,cause:o,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}},Ue=class extends _{constructor(r,o){let i=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(i,{code:$.FORBIDDEN,statusCode:403,cause:o,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}},ze=class extends _{constructor(r,o,i,s){let n=o?`Failed to fetch from registry (${o}): ${r}`:`Failed to fetch from registry: ${r}`,m=typeof s=="string"&&s?`${n} - ${s}`:n,p="Check your network connection and try again.";o===404?p="The requested resource was not found. Check the URL or item name.":o===500?p="The registry server encountered an error. Try again later.":o&&o>=400&&o<500&&(p="There was a client error. Check your request parameters.");super(m,{code:$.FETCH_ERROR,statusCode:o,cause:s,context:{url:r,responseBody:i},suggestion:p});this.url=r;this.responseBody=i;this.name="RegistryFetchError";}},Q=class extends _{constructor(r){let o=r?`Unknown registry "${r}". Make sure it is defined in agents.json as follows:
3
3
  {
4
4
  "registries": {
5
5
  "${r}": "[URL_TO_REGISTRY]"
@@ -25,7 +25,7 @@ File: ${l.info(y)}`),Oi(z);let{overwrite:Fe}=await $e({type:"confirm",name:"over
25
25
  `):r.includes("lines hidden")?process.stdout.write(`${l.info(r)}
26
26
  `):process.stdout.write(`${r}
27
27
  `);}async function wr(e,t,r){if(r={overwrite:false,silent:false,yes:false,...r},!e.length)return;let o=v("Checking registry.",{silent:r.silent})?.start(),i=await lt(e,pe(t));if(!i)return o?.fail(),w(new Error("Failed to fetch items from registry."));o?.succeed();let{filesCreated:s,filesUpdated:n}=await hr(i.files,t,{overwrite:r.overwrite,silent:r.silent,path:r.path,yes:r.yes});(s.length||n.length)&&await ur(i.dependencies,i.devDependencies,t,{silent:r.silent}),i.docs&&a.info(i.docs);}z.object({cwd:z.string(),yes:z.boolean(),defaults:z.boolean(),silent:z.boolean()});async function vr(e){let t={},r=R__default.resolve(e.cwd);existsSync(r)||(t.MISSING_DIR=true);let o=await k(r);return {errors:t,projectInfo:o}}var br=join(homedir(),".mercur"),gt=join(br,"config.json"),yt={telemetry_enabled:true,telemetry_email:null,notice_shown:false},ht=class{get(t){return this.read()[t]}set(t,r){let o=this.read();o[t]=r,this.write(o);}read(){try{if(!existsSync(gt))return {...yt};let t=readFileSync(gt,"utf-8"),r=JSON.parse(t);return {...yt,...r}}catch{return {...yt}}}write(t){try{mkdirSync(br,{recursive:!0}),writeFileSync(gt,JSON.stringify(t,null,2)+`
28
- `,{mode:384});}catch{}}},L=new ht;var fe=e=>Function("mm","return import(mm)")(e);function Bi(){let e=(...t)=>t.some(r=>!!process.env[r]);return e("MEDUSA_CLOUD_ENVIRONMENT_HANDLE","MEDUSA_CLOUD_SANDBOX_HANDLE","MEDUSA_CLOUD_API_KEY")?"medusa-cloud":e("RENDER","RENDER_URL","RENDER_INTERNAL_HOSTNAME","RENDER_SERVICE_ID")?"render":e("FLY_APP_NAME","FLY_REGION","FLY_ALLOC_ID")?"fly-io":e("RAILWAY_STATIC_URL","RAILWAY_ENVIRONMENT_NAME")?"railway":e("DYNO","HEROKU_APP_NAME")?"heroku":e("DO_DEPLOYMENT_ID","DO_APP_NAME","DIGITALOCEAN")?"digitalocean":e("KOYEB","KOYEB_DEPLOYMENT_ID","KOYEB_APP_NAME")?"koyeb":null}async function xr(){try{let e=await fe("os"),t=e.cpus();return {deploymentVendor:Bi(),systemPlatform:e.platform(),systemRelease:e.release(),systemArchitecture:e.arch(),cpuCount:t.length,cpuModel:t.length?t[0].model:null,cpuSpeed:t.length?t[0].speed:null,memory:e.totalmem(),isWSL:await Wi(),isDocker:await _r(),isTTY:typeof process<"u"&&process.stdout?process.stdout.isTTY:null}}catch{return {systemPlatform:null,systemRelease:null,systemArchitecture:null,cpuCount:null,cpuModel:null,cpuSpeed:null,memory:null,isWSL:null,isDocker:null,isTTY:null}}}async function Wi(){try{if(typeof process>"u"||process?.platform!=="linux")return !1;let e=await fe("fs");return (await fe("os")).release().toLowerCase().includes("microsoft")?!await Rr():e.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!await Rr():!1}catch{return false}}var Gi=async()=>{try{return (await fe("fs")).statSync("/run/.containerenv"),!0}catch{return false}};async function _r(){return await Vi()||await Yi()}async function Vi(){try{return (await fe("fs")).statSync("/.dockerenv"),!0}catch{return false}}async function Yi(){try{return (await fe("fs")).readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return false}}async function Rr(){return await Gi()||await _r()}var wt=e=>createHash("sha256").update(e).digest("base64");var Hi=process.env.MERCUR_TELEMETRY_PROXY_URL||"https://telemetry.mercurjs.com/api/v1/events",kr=e=>{L.set("telemetry_email",e);},Er=e=>{L.set("telemetry_enabled",e);},Qe="https://docs.mercurjs.com/v2/telemetry",H=()=>{L.get("notice_shown")||(L.set("notice_shown",true),process.env.MERCUR_DISABLE_TELEMETRY!=="true"&&console.error(["","Mercur collects anonymous usage data to improve the CLI experience.",`You can disable this at any time by running: ${l.info("mercurjs telemetry --disable")}`,`Or by setting ${l.info("MERCUR_DISABLE_TELEMETRY=true")}`,`Learn more: ${l.info(Qe)}`,""].join(`
28
+ `,{mode:384});}catch{}}},L=new ht;var fe=e=>Function("mm","return import(mm)")(e);function Bi(){let e=(...t)=>t.some(r=>!!process.env[r]);return e("MEDUSA_CLOUD_ENVIRONMENT_HANDLE","MEDUSA_CLOUD_SANDBOX_HANDLE","MEDUSA_CLOUD_API_KEY")?"medusa-cloud":e("RENDER","RENDER_URL","RENDER_INTERNAL_HOSTNAME","RENDER_SERVICE_ID")?"render":e("FLY_APP_NAME","FLY_REGION","FLY_ALLOC_ID")?"fly-io":e("RAILWAY_STATIC_URL","RAILWAY_ENVIRONMENT_NAME")?"railway":e("DYNO","HEROKU_APP_NAME")?"heroku":e("DO_DEPLOYMENT_ID","DO_APP_NAME","DIGITALOCEAN")?"digitalocean":e("KOYEB","KOYEB_DEPLOYMENT_ID","KOYEB_APP_NAME")?"koyeb":null}async function xr(){try{let e=await fe("os"),t=e.cpus();return {deploymentVendor:Bi(),systemPlatform:e.platform(),systemRelease:e.release(),systemArchitecture:e.arch(),cpuCount:t.length,cpuModel:t.length?t[0].model:null,cpuSpeed:t.length?t[0].speed:null,memory:e.totalmem(),isWSL:await Wi(),isDocker:await _r(),isTTY:typeof process<"u"&&process.stdout?process.stdout.isTTY:null}}catch{return {systemPlatform:null,systemRelease:null,systemArchitecture:null,cpuCount:null,cpuModel:null,cpuSpeed:null,memory:null,isWSL:null,isDocker:null,isTTY:null}}}async function Wi(){try{if(typeof process>"u"||process?.platform!=="linux")return !1;let e=await fe("fs");return (await fe("os")).release().toLowerCase().includes("microsoft")?!await Rr():e.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!await Rr():!1}catch{return false}}var Gi=async()=>{try{return (await fe("fs")).statSync("/run/.containerenv"),!0}catch{return false}};async function _r(){return await Vi()||await Yi()}async function Vi(){try{return (await fe("fs")).statSync("/.dockerenv"),!0}catch{return false}}async function Yi(){try{return (await fe("fs")).readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return false}}async function Rr(){return await Gi()||await _r()}var wt=e=>createHash("sha256").update(e).digest("base64");var Hi=process.env.MERCUR_TELEMETRY_PROXY_URL||"https://telemetry.mercurjs.com/api/v1/events",kr=e=>{L.set("telemetry_email",e);},Er=e=>{L.set("telemetry_enabled",e);},Qe="https://docs.mercurjs.com/telemetry",H=()=>{L.get("notice_shown")||(L.set("notice_shown",true),process.env.MERCUR_DISABLE_TELEMETRY!=="true"&&console.error(["","Mercur collects anonymous usage data to improve the CLI experience.",`You can disable this at any time by running: ${l.info("mercurjs telemetry --disable")}`,`Or by setting ${l.info("MERCUR_DISABLE_TELEMETRY=true")}`,`Learn more: ${l.info(Qe)}`,""].join(`
29
29
  `)));},Ki=()=>L.get("telemetry_enabled")&&process.env.MERCUR_DISABLE_TELEMETRY!=="true",P=async(e,t)=>{try{if(!Ki())return;let r=await k(t.cwd),{projectId:o}=Xi(r.packageJson),i={nodeEnv:Zi(),nodeVersion:process.version,mercurVersion:r.mercurVersion,medusaVersion:r.medusaVersion,isSrcDir:r.isSrcDir,aliasPrefix:r.aliasPrefix,config:await b(t.cwd),projectId:o,systemInfo:await xr(),packageManager:await A(t.cwd),email:es()};await fetch(Hi,{body:JSON.stringify({...i,...e}),headers:{"Content-Type":"application/json"},method:"post"});}catch{}};function Zi(){return process.env.NODE_ENV||"development"}var Qi=()=>{try{let e=execSync("git config --local --get remote.origin.url",{stdio:"pipe",timeout:1e3});return String(e).trim()}catch{return null}},Xi=e=>{let t=Qi();if(t)return {projectId:wt(t)};let r=process.cwd();return {projectId:wt(r)}},es=()=>L.get("telemetry_email")||void 0;var os=z.object({cwd:z.string(),yes:z.boolean(),defaults:z.boolean(),silent:z.boolean()}),Cr=new Command().name("init").description("initialize your project and install dependencies").option("-y, --yes","skip confirmation prompt.",true).option("-d, --defaults","use default configuration.",false).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-s, --silent","mute output.",false).action(async e=>{try{H();let t=os.parse({cwd:R__default.resolve(e.cwd),...e});await jt(t),a.log(`${l.success("Success!")} Project initialization completed.
30
30
  You may now add blocks.`),a.break(),await P({type:"init",payload:{outcome:"success"}},{cwd:t.cwd});}catch(t){a.break(),w(t);}finally{x();}});async function jt(e){await vr(e);let t=await b(e.cwd),r=t?await ss(t,e):await is(e);if(!e.yes){let{proceed:s}=await $e({type:"confirm",name:"proceed",message:`Write configuration to ${l.info("blocks.json")}. Proceed?`,initial:true});s||process.exit(0);}let o=v("Writing blocks.json.").start(),i=R__default.resolve(e.cwd,"blocks.json");return r.registries=Object.fromEntries(Object.entries(r.registries||{}).filter(([s])=>!Object.keys(C).includes(s))),await promises.writeFile(i,`${JSON.stringify(r,null,2)}
31
31
  `,"utf8"),o.succeed(),await at(e.cwd,r)}async function is(e){if(e.defaults)return W.parse({$schema:Me,aliases:{api:"packages/api/src",vendor:"apps/vendor/src",admin:"apps/admin/src"},registries:C});a.info("");let t=await $e([{type:"text",name:"api",message:`Configure the import alias for ${l.info("api")}:`,initial:"packages/api/src"},{type:"text",name:"vendor",message:`Configure the import alias for ${l.info("vendor")}:`,initial:"apps/vendor/src"},{type:"text",name:"admin",message:`Configure the import alias for ${l.info("admin")}:`,initial:"apps/admin/src"}],{onCancel:()=>{process.exit(0);}});return W.parse({$schema:Me,aliases:{api:t.api??"packages/api/src",vendor:t.vendor??"apps/vendor/src",admin:t.admin??"apps/admin/src"},registries:C})}async function ss(e,t){if(t.defaults)return W.parse({$schema:Me,aliases:{api:"packages/api/src",vendor:"apps/vendor/src",admin:"apps/admin/src"},registries:C});let r=await $e([{type:"text",name:"api",message:`Configure the import alias for ${l.info("api")}:`,initial:e.aliases.api},{type:"text",name:"vendor",message:`Configure the import alias for ${l.info("vendor")}:`,initial:e.aliases.vendor},{type:"text",name:"admin",message:`Configure the import alias for ${l.info("admin")}:`,initial:e.aliases.admin}],{onCancel:()=>{process.exit(0);}});return W.parse({$schema:e.$schema,aliases:{api:r.api??e.aliases.api,vendor:r.vendor??e.aliases.vendor,admin:r.admin??e.aliases.admin}})}var ms=z.object({blocks:z.array(z.string()).optional(),yes:z.boolean(),overwrite:z.boolean(),cwd:z.string(),silent:z.boolean()}),Ir=new Command().name("add").description("add blocks to your project").argument("[blocks...]","names of blocks to add").option("-y, --yes","skip confirmation prompt.",false).option("-o, --overwrite","overwrite existing files.",false).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-s, --silent","mute output.",false).action(async(e,t)=>{try{H();let r=ms.parse({blocks:e,cwd:R__default.resolve(t.cwd),...t}),o=await b(r.cwd);o||(o=G({resolvedPaths:{cwd:r.cwd}})),r.blocks?.length||(a.error("Please specify at least one item to add."),process.exit(1));let{errors:i}=await Kt(r);if(i[S]){let{proceed:s}=await $e({type:"confirm",name:"proceed",message:`You need to create a ${l.info("blocks.json")} file to add items. Proceed?`,initial:!0});s||(a.break(),process.exit(1)),o=await jt({cwd:r.cwd,yes:!0,defaults:!1,silent:r.silent});}if(!o)throw new Error(`Failed to read config at ${l.info(r.cwd)}.`);await wr(r.blocks,o,{overwrite:r.overwrite,silent:r.silent,yes:r.yes,path:r.cwd}),await P({type:"add",payload:{outcome:"success",blocks:r.blocks}},{cwd:r.cwd});}catch(r){a.break(),w(r);}finally{x();}});async function Pr(e){let t={},r={cwd:e.cwd,registryFile:R__default.resolve(e.cwd,e.registryFile),outputDir:R__default.resolve(e.cwd,e.outputDir)};if(!M.existsSync(r.registryFile))return t[B]=true,{errors:t,resolvePaths:null,config:null};if(!M.existsSync(R__default.resolve(e.cwd,"blocks.json")))return t[S]=true,{errors:t,resolvePaths:null,config:null};await M.mkdir(r.outputDir,{recursive:true});try{let o=await b(e.cwd);return {errors:t,config:o,resolvePaths:r}}catch{a.break(),a.error(`An invalid ${l.info("blocks.json")} file was found at ${l.info(e.cwd)}.
@@ -55,7 +55,7 @@ ${o("Create your first seller:")}
55
55
 
56
56
  ${o("Documentation:")}
57
57
 
58
- - ${Nt("Getting Started","https://docs.mercurjs.com/v2/welcome")}
58
+ - ${Nt("Getting Started","https://docs.mercurjs.com/welcome")}
59
59
  `}function qs(){let e=t=>O.bold(t);return `
60
60
  ${e("Your marketplace is running:")}
61
61