pkgroll 2.7.0 → 2.8.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/cli.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
`:"")+(t?this.indentText({text:this.render(t),spaces:D}):"")}
|
|
20
20
|
`}table({tableData:e,tableOptions:t,tableBreakpoints:D}){return et(e.map(n=>n.map(r=>this.render(r))),D?rt(D):t)}flagParameter(e){return e===Boolean?"":e===String?"<string>":e===Number?"<number>":Array.isArray(e)?this.flagParameter(e[0]):"<value>"}flagOperator(e){return" "}flagName(e){const{flag:t,flagFormatted:D,aliasesEnabled:n,aliasFormatted:r}=e;let o="";if(r?o+=`${r}, `:n&&(o+=" "),o+=D,"placeholder"in t&&typeof t.placeholder=="string")o+=`${this.flagOperator(e)}${t.placeholder}`;else{const s=this.flagParameter("type"in t?t.type:t);s&&(o+=`${this.flagOperator(e)}${s}`)}return o}flagDefault(e){return JSON.stringify(e)}flagDescription({flag:e}){let t="description"in e?e.description??"":"";if("default"in e){let{default:D}=e;typeof D=="function"&&(D=D()),D&&(t+=` (default: ${this.flagDefault(D)})`)}return t}render(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>this.render(t)).join(`
|
|
21
21
|
`);if("type"in e&&this[e.type]){const t=this[e.type];if(typeof t=="function")return t.call(this,e.data)}throw new Error(`Invalid node type: ${JSON.stringify(e)}`)}};const lD=/^[\w.-]+$/,{stringify:T}=JSON,mt=/[|\\{}()[\]^$+*?.]/;function du(u){const e=[];let t,D;for(const n of u){if(D)throw new Error(`Invalid parameter: Spread parameter ${T(D)} must be last`);const r=n[0],o=n[n.length-1];let s;if(r==="<"&&o===">"&&(s=!0,t))throw new Error(`Invalid parameter: Required parameter ${T(n)} cannot come after optional parameter ${T(t)}`);if(r==="["&&o==="]"&&(s=!1,t=n),s===void 0)throw new Error(`Invalid parameter: ${T(n)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=n.slice(1,-1);const l=a.slice(-3)==="...";l&&(D=n,a=a.slice(0,-3));const p=a.match(mt);if(p)throw new Error(`Invalid parameter: ${T(n)}. Invalid character found ${T(p[0])}`);e.push({name:a,required:s,spread:l})}return e}i(du,"w$1");function Eu(u,e,t,D){for(let n=0;n<e.length;n+=1){const{name:r,required:o,spread:s}=e[n],a=ot(r);if(a in u)throw new Error(`Invalid parameter: ${T(r)} is used more than once.`);const l=s?t.slice(n):t[n];if(s&&(n=e.length),o&&(!l||s&&l.length===0))return console.error(`Error: Missing required parameter ${T(r)}
|
|
22
|
-
`),D(),process.exit(1);u[a]=l}}i(Eu,"b");function Bt(u){return u===void 0||u!==!1}i(Bt,"W$1");function cD(u,e,t,D){const n={...e.flags},r=e.version;r&&(n.version={type:Boolean,description:"Show version"});const{help:o}=e,s=Bt(o);s&&!("help"in n)&&(n.help={type:Boolean,alias:"h",description:"Show help"});const a=ye(n,D,{ignore:e.ignoreArgv}),l=i(()=>{console.log(e.version)},"f");if(r&&a.flags.version===!0)return l(),process.exit(0);const p=new gt,C=s&&o?.render?o.render:d=>p.render(d),c=i(d=>{const g=Et({...e,...d?{help:d}:{},flags:n});console.log(C(g,p))},"u");if(s&&a.flags.help===!0)return c(),process.exit(0);if(e.parameters){let{parameters:d}=e,g=a._;const y=d.indexOf("--"),j=d.slice(y+1),v=Object.create(null);if(y>-1&&j.length>0){d=d.slice(0,y);const f=a._["--"];g=g.slice(0,-f.length||void 0),Eu(v,du(d),g,c),Eu(v,du(j),f,c)}else Eu(v,du(d),g,c);Object.assign(a._,v)}const E={...a,showVersion:l,showHelp:c};return typeof t=="function"&&t(E),{command:u,...E}}i(cD,"x$1");function At(u,e){const t=new Map;for(const D of e){const n=[D.options.name],{alias:r}=D.options;r&&(Array.isArray(r)?n.push(...r):n.push(r));for(const o of n){if(t.has(o))throw new Error(`Duplicate command name found: ${T(o)}`);t.set(o,D)}}return t.get(u)}i(At,"z$1");function yt(u,e,t=process.argv.slice(2)){if(!u)throw new Error("Options is required");if("name"in u&&(!u.name||!lD.test(u.name)))throw new Error(`Invalid script name: ${T(u.name)}`);const D=t[0];if(u.commands&&lD.test(D)){const n=At(D,u.commands);if(n)return cD(n.options.name,{...n.options,parent:u},n.callback,t.slice(1))}return cD(void 0,u,e,t)}i(yt,"Z$1");var bt="2.
|
|
22
|
+
`),D(),process.exit(1);u[a]=l}}i(Eu,"b");function Bt(u){return u===void 0||u!==!1}i(Bt,"W$1");function cD(u,e,t,D){const n={...e.flags},r=e.version;r&&(n.version={type:Boolean,description:"Show version"});const{help:o}=e,s=Bt(o);s&&!("help"in n)&&(n.help={type:Boolean,alias:"h",description:"Show help"});const a=ye(n,D,{ignore:e.ignoreArgv}),l=i(()=>{console.log(e.version)},"f");if(r&&a.flags.version===!0)return l(),process.exit(0);const p=new gt,C=s&&o?.render?o.render:d=>p.render(d),c=i(d=>{const g=Et({...e,...d?{help:d}:{},flags:n});console.log(C(g,p))},"u");if(s&&a.flags.help===!0)return c(),process.exit(0);if(e.parameters){let{parameters:d}=e,g=a._;const y=d.indexOf("--"),j=d.slice(y+1),v=Object.create(null);if(y>-1&&j.length>0){d=d.slice(0,y);const f=a._["--"];g=g.slice(0,-f.length||void 0),Eu(v,du(d),g,c),Eu(v,du(j),f,c)}else Eu(v,du(d),g,c);Object.assign(a._,v)}const E={...a,showVersion:l,showHelp:c};return typeof t=="function"&&t(E),{command:u,...E}}i(cD,"x$1");function At(u,e){const t=new Map;for(const D of e){const n=[D.options.name],{alias:r}=D.options;r&&(Array.isArray(r)?n.push(...r):n.push(r));for(const o of n){if(t.has(o))throw new Error(`Duplicate command name found: ${T(o)}`);t.set(o,D)}}return t.get(u)}i(At,"z$1");function yt(u,e,t=process.argv.slice(2)){if(!u)throw new Error("Options is required");if("name"in u&&(!u.name||!lD.test(u.name)))throw new Error(`Invalid script name: ${T(u.name)}`);const D=t[0];if(u.commands&&lD.test(D)){const n=At(D,u.commands);if(n)return cD(n.options.name,{...n.options,parent:u},n.callback,t.slice(1))}return cD(void 0,u,e,t)}i(yt,"Z$1");var bt="2.8.0";const hu=i(u=>S.promises.access(u).then(()=>!0,()=>!1),"fsExists"),wt=i(async u=>{const e=h.join(u,"package.json");if(!await hu(e))throw new Error(`package.json not found at: ${e}`);const D=await S.promises.readFile(e,"utf8");try{return JSON.parse(D)}catch(n){throw new Error(`Cannot parse package.json: ${n.message}`)}},"readPackageJson"),$t=/^[/.]/,K=i((u,e)=>(!h.isAbsolute(u)&&!$t.test(u)&&(u=`./${u}`),e&&!u.endsWith("/")&&(u+="/"),u),"normalizePath"),vt=/^[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*$/u,xt=new Set(["do","if","in","for","int","new","try","var","byte","case","char","else","enum","goto","long","null","this","true","void","with","break","catch","class","const","false","final","float","short","super","throw","while","delete","double","export","import","native","public","return","static","switch","throws","typeof","boolean","default","extends","finally","package","private","abstract","continue","debugger","function","volatile","interface","protected","transient","implements","instanceof","synchronized"]),gu=i(u=>!vt.test(u)||xt.has(u),"propertyNeedsQuotes"),P=i(u=>{if(u.endsWith(".mjs"))return"module";if(u.endsWith(".cjs"))return"commonjs"},"getFileType"),FD=i(u=>u.startsWith("."),"isPath"),mu=i((u,e,t="exports")=>{if(u){if(typeof u=="string")return FD(u)?[{outputPath:u,type:P(u)||e,from:t}]:[];if(Array.isArray(u))return u.flatMap((D,n)=>{const r=`${t}[${n}]`;return typeof D=="string"?FD(D)?{outputPath:D,type:P(D)||e,from:r}:[]:mu(D,e,r)});if(typeof u=="object")return Object.entries(u).flatMap(([D,n])=>{if(typeof n=="string"){const o=gu(D)?`["${D}"]`:`.${D}`,s={outputPath:n,from:`${t}${o}`};if(D==="require")return{...s,type:"commonjs"};if(D==="import")return{...s,type:P(n)||e};if(D==="types")return{...s,type:"types"};if(D==="node")return{...s,type:P(n)||e,platform:"node"};if(D==="default")return{...s,type:P(n)||e}}const r=gu(D)?`["${D}"]`:`.${D}`;return mu(n,e,`${t}${r}`)})}return[]},"parseExportsMap"),M=i((u,e)=>{e.outputPath=K(e.outputPath);const{outputPath:t,type:D,platform:n}=e,r=u[t];if(r){if(r.type!==D)throw new Error(`Conflicting export types "${r.type}" & "${D}" found for ${t}`);if(r.platform!==n)throw new Error(`Conflicting export platforms "${r.platform}" & "${n}" found for ${t}`);Object.assign(r,e)}else u[t]=e},"addExportPath"),Ot=i(u=>{const e={},t=u.type??"commonjs";if(u.main){const D=u.main;M(e,{outputPath:D,type:P(D)??t,from:"main"})}if(u.module&&M(e,{outputPath:u.module,type:"module",from:"module"}),u.types&&M(e,{outputPath:u.types,type:"types",from:"types"}),u.bin){const{bin:D}=u;if(typeof D=="string")M(e,{outputPath:D,type:P(D)??t,isExecutable:!0,from:"bin"});else for(const[n,r]of Object.entries(D)){const o=gu(n)?`["${n}"]`:`.${n}`;M(e,{outputPath:r,type:P(r)??t,isExecutable:!0,from:`bin${o}`})}}if(u.exports){const D=mu(u.exports,t);for(const n of D)M(e,n)}return Object.values(e)},"getExportEntries"),jt=i(u=>{let e=!1;if(u.includes("=")){const[t,D]=u.split("=");u=D,e=t==="bin"||t==="binary"}return{outputPath:K(u),type:P(u),isExecutable:e,from:"cli"}},"parseCliInputFlag"),kt=i(({imports:u},e)=>{const t={};if(u)for(const D in u){if(D.startsWith("#"))continue;const n=u[D];typeof n=="string"&&(t[D]=h.join(e,n))}return t},"getAliases"),{stringify:Tt}=JSON,St=i(async(u,e)=>{for(const t of e){const D=u+t;if(await hu(D))return{extension:t,path:D}}},"tryExtensions"),CD={".d.ts":[".d.ts",".d.mts",".d.cts",".ts",".tsx",".mts",".cts"],".d.mts":[".d.mts",".d.ts",".d.cts",".ts",".tsx",".mts",".cts"],".d.cts":[".d.cts",".d.ts",".d.mts",".ts",".tsx",".mts",".cts"],".js":[".js",".ts",".tsx",".mts",".cts"],".mjs":[".mjs",".js",".cjs",".mts",".cts",".ts",".tsx"],".cjs":[".cjs",".js",".mjs",".mts",".cts",".ts",".tsx"]},Pt=Object.keys(CD),Nt=i(async(u,e,t)=>{const D=e+u.outputPath.slice(t.length);for(const n of Pt)if(u.outputPath.endsWith(n)){const r=await St(D.slice(0,-n.length),CD[n]);if(r)return{input:r.path,srcExtension:r.extension,distExtension:n}}throw new Error(`Could not find matching source file for export path ${Tt(u.outputPath)}`)},"getSourcePath"),Bu="pkgroll:create-require",pD=`IS_ESM${Math.random().toString(36).slice(2)}`,It=i(()=>({...ee({require:Bu}),name:"create-require",resolveId:i(u=>u===Bu?u:null,"resolveId"),load:i(u=>u!==Bu?null:`
|
|
23
23
|
import { createRequire } from 'module';
|
|
24
24
|
|
|
25
25
|
export default (
|