@mercurjs/cli 2.1.0-canary.6 → 2.1.0

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.0-canary.6"};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.0"};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]"