@mercurjs/cli 2.0.0-canary.71 → 2.0.0-canary.72

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 ut from'prompts';import {z as z$1}from'zod';import {promises,existsSync,statSync}from'fs';import {cosmiconfig}from'cosmiconfig';import {loadConfig,createMatchPath}from'tsconfig-paths';import N from'fs-extra';import'typescript';import ot from'fast-glob';import {createHash}from'crypto';import tr from'deepmerge';import*as A from'fs/promises';import A__default from'fs/promises';import co,{tmpdir,homedir}from'os';import {Project,ScriptKind}from'ts-morph';import le from'kleur';import Ui from'ora';import {execa}from'execa';import {detect}from'@antfu/ni';import {diffLines}from'diff';import {exec,execSync}from'child_process';import {Readable}from'stream';import {pipeline}from'stream/promises';import _t from'pg';import ds from'open';import {x as x$1}from'tar';import ms from'terminal-link';import cs from'validate-npm-package-name';import us from'wait-on';var $t={version:"2.0.0-canary.71"};var Dt="MISSING_DIR_OR_EMPTY_PROJECT",S="MISSING_CONFIG",z="BUILD_MISSING_REGISTRY_FILE";var ei=z$1.enum(["registry:api","registry:vendor","registry:admin"]),Ft=z$1.object({path:z$1.string(),content:z$1.string().optional(),type:ei,target:z$1.string().optional()}),Ot=z$1.object({$schema:z$1.string().optional(),name:z$1.string(),title:z$1.string().optional(),author:z$1.string().min(2).optional(),description:z$1.string().optional(),dependencies:z$1.array(z$1.string()).optional(),devDependencies:z$1.array(z$1.string()).optional(),registryDependencies:z$1.array(z$1.string()).optional(),meta:z$1.record(z$1.string(),z$1.any()).optional(),docs:z$1.string().optional(),categories:z$1.array(z$1.string()).optional()}),P=Ot.extend({files:z$1.array(Ft)}),H=z$1.object({name:z$1.string(),homepage:z$1.string(),items:z$1.array(P)}),Gs=z$1.array(Ot),Nt=P.pick({dependencies:true,devDependencies:true,files:true,docs:true}),ti=z$1.union([z$1.string(),z$1.object({url:z$1.string(),params:z$1.record(z$1.string(),z$1.string()).optional(),headers:z$1.record(z$1.string(),z$1.string()).optional()})]),At=z$1.record(z$1.string().refine(e=>e.startsWith("@"),{message:"Registry names must start with @ (e.g., @mercurjs)"}),ti);var $e="https://registry.mercurjs.com/registry.json",Lt="https://registry.mercurjs.com/registry-item.json",fe=process.env.REGISTRY_URL??"https://raw.githubusercontent.com/mercurjs/mercur/new/packages/registry/r",E={"@mercurjs":`${fe}/{name}.json`};var T={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||T.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);}},ie=class extends _{constructor(r,i){let o=`The item at ${r} was not found. It may not exist at the registry.`;super(o,{code:T.NOT_FOUND,statusCode:404,cause:i,context:{url:r},suggestion:"Check if the item name is correct and the registry URL is accessible."});this.url=r;this.name="RegistryNotFoundError";}},De=class extends _{constructor(r,i){let o=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(o,{code:T.UNAUTHORIZED,statusCode:401,cause:i,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}},Fe=class extends _{constructor(r,i){let o=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(o,{code:T.FORBIDDEN,statusCode:403,cause:i,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}},Oe=class extends _{constructor(r,i,o,s){let n=i?`Failed to fetch from registry (${i}): ${r}`:`Failed to fetch from registry: ${r}`,p=typeof s=="string"&&s?`${n} - ${s}`:n,m="Check your network connection and try again.";i===404?m="The requested resource was not found. Check the URL or item name.":i===500?m="The registry server encountered an error. Try again later.":i&&i>=400&&i<500&&(m="There was a client error. Check your request parameters.");super(p,{code:T.FETCH_ERROR,statusCode:i,cause:s,context:{url:r,responseBody:o},suggestion:m});this.url=r;this.responseBody=o;this.name="RegistryFetchError";}},Y=class extends _{constructor(r){let i=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 ut from'prompts';import {z as z$1}from'zod';import {promises,existsSync,statSync}from'fs';import {cosmiconfig}from'cosmiconfig';import {loadConfig,createMatchPath}from'tsconfig-paths';import N from'fs-extra';import'typescript';import ot from'fast-glob';import {createHash}from'crypto';import tr from'deepmerge';import*as A from'fs/promises';import A__default from'fs/promises';import co,{tmpdir,homedir}from'os';import {Project,ScriptKind}from'ts-morph';import le from'kleur';import Ui from'ora';import {execa}from'execa';import {detect}from'@antfu/ni';import {diffLines}from'diff';import {exec,execSync}from'child_process';import {Readable}from'stream';import {pipeline}from'stream/promises';import _t from'pg';import ds from'open';import {x as x$1}from'tar';import ms from'terminal-link';import cs from'validate-npm-package-name';import us from'wait-on';var $t={version:"2.0.0-canary.72"};var Dt="MISSING_DIR_OR_EMPTY_PROJECT",S="MISSING_CONFIG",z="BUILD_MISSING_REGISTRY_FILE";var ei=z$1.enum(["registry:api","registry:vendor","registry:admin"]),Ft=z$1.object({path:z$1.string(),content:z$1.string().optional(),type:ei,target:z$1.string().optional()}),Ot=z$1.object({$schema:z$1.string().optional(),name:z$1.string(),title:z$1.string().optional(),author:z$1.string().min(2).optional(),description:z$1.string().optional(),dependencies:z$1.array(z$1.string()).optional(),devDependencies:z$1.array(z$1.string()).optional(),registryDependencies:z$1.array(z$1.string()).optional(),meta:z$1.record(z$1.string(),z$1.any()).optional(),docs:z$1.string().optional(),categories:z$1.array(z$1.string()).optional()}),P=Ot.extend({files:z$1.array(Ft)}),H=z$1.object({name:z$1.string(),homepage:z$1.string(),items:z$1.array(P)}),Gs=z$1.array(Ot),Nt=P.pick({dependencies:true,devDependencies:true,files:true,docs:true}),ti=z$1.union([z$1.string(),z$1.object({url:z$1.string(),params:z$1.record(z$1.string(),z$1.string()).optional(),headers:z$1.record(z$1.string(),z$1.string()).optional()})]),At=z$1.record(z$1.string().refine(e=>e.startsWith("@"),{message:"Registry names must start with @ (e.g., @mercurjs)"}),ti);var $e="https://registry.mercurjs.com/registry.json",Lt="https://registry.mercurjs.com/registry-item.json",fe=process.env.REGISTRY_URL??"https://raw.githubusercontent.com/mercurjs/mercur/new/packages/registry/r",E={"@mercurjs":`${fe}/{name}.json`};var T={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||T.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);}},ie=class extends _{constructor(r,i){let o=`The item at ${r} was not found. It may not exist at the registry.`;super(o,{code:T.NOT_FOUND,statusCode:404,cause:i,context:{url:r},suggestion:"Check if the item name is correct and the registry URL is accessible."});this.url=r;this.name="RegistryNotFoundError";}},De=class extends _{constructor(r,i){let o=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(o,{code:T.UNAUTHORIZED,statusCode:401,cause:i,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}},Fe=class extends _{constructor(r,i){let o=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(o,{code:T.FORBIDDEN,statusCode:403,cause:i,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}},Oe=class extends _{constructor(r,i,o,s){let n=i?`Failed to fetch from registry (${i}): ${r}`:`Failed to fetch from registry: ${r}`,p=typeof s=="string"&&s?`${n} - ${s}`:n,m="Check your network connection and try again.";i===404?m="The requested resource was not found. Check the URL or item name.":i===500?m="The registry server encountered an error. Try again later.":i&&i>=400&&i<500&&(m="There was a client error. Check your request parameters.");super(p,{code:T.FETCH_ERROR,statusCode:i,cause:s,context:{url:r,responseBody:o},suggestion:m});this.url=r;this.responseBody=o;this.name="RegistryFetchError";}},Y=class extends _{constructor(r){let i=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]"