pkgroll 2.4.3 → 2.5.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 Ze(e.map(n=>n.map(r=>this.render(r))),D?Qe(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 i=this.flagParameter("type"in t?t.type:t);i&&(o+=`${this.flagOperator(e)}${i}`)}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 oD=/^[\w.-]+$/,{stringify:P}=JSON,Ct=/[|\\{}()[\]^$+*?.]/;function fu(u){const e=[];let t,D;for(const n of u){if(D)throw new Error(`Invalid parameter: Spread parameter ${P(D)} must be last`);const r=n[0],o=n[n.length-1];let i;if(r==="<"&&o===">"&&(i=!0,t))throw new Error(`Invalid parameter: Required parameter ${P(n)} cannot come after optional parameter ${P(t)}`);if(r==="["&&o==="]"&&(i=!1,t=n),i===void 0)throw new Error(`Invalid parameter: ${P(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 f=a.match(Ct);if(f)throw new Error(`Invalid parameter: ${P(n)}. Invalid character found ${P(f[0])}`);e.push({name:a,required:i,spread:l})}return e}s(fu,"w$1");function pu(u,e,t,D){for(let n=0;n<e.length;n+=1){const{name:r,required:o,spread:i}=e[n],a=Xe(r);if(a in u)throw new Error(`Invalid parameter: ${P(r)} is used more than once.`);const l=i?t.slice(n):t[n];if(i&&(n=e.length),o&&(!l||i&&l.length===0))return console.error(`Error: Missing required parameter ${P(r)}
|
|
22
|
-
`),D(),process.exit(1);u[a]=l}}s(pu,"b");function ft(u){return u===void 0||u!==!1}s(ft,"W");function sD(u,e,t,D){const n={...e.flags},r=e.version;r&&(n.version={type:Boolean,description:"Show version"});const{help:o}=e,i=ft(o);i&&!("help"in n)&&(n.help={type:Boolean,alias:"h",description:"Show help"});const a=Ee(n,D,{ignore:e.ignoreArgv}),l=s(()=>{console.log(e.version)},"f");if(r&&a.flags.version===!0)return l(),process.exit(0);const f=new Ft,F=i&&o?.render?o.render:p=>f.render(p),c=s(p=>{const g=lt({...e,...p?{help:p}:{},flags:n});console.log(F(g,f))},"u");if(i&&a.flags.help===!0)return c(),process.exit(0);if(e.parameters){let{parameters:p}=e,g=a._;const y=p.indexOf("--"),j=p.slice(y+1),v=Object.create(null);if(y>-1&&j.length>0){p=p.slice(0,y);const C=a._["--"];g=g.slice(0,-C.length||void 0),pu(v,fu(p),g,c),pu(v,fu(j),C,c)}else pu(v,fu(p),g,c);Object.assign(a._,v)}const E={...a,showVersion:l,showHelp:c};return typeof t=="function"&&t(E),{command:u,...E}}s(sD,"x$1");function pt(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: ${P(o)}`);t.set(o,D)}}return t.get(u)}s(pt,"z$1");function Et(u,e,t=process.argv.slice(2)){if(!u)throw new Error("Options is required");if("name"in u&&(!u.name||!oD.test(u.name)))throw new Error(`Invalid script name: ${P(u.name)}`);const D=t[0];if(u.commands&&oD.test(D)){const n=pt(D,u.commands);if(n)return sD(n.options.name,{...n.options,parent:u},n.callback,t.slice(1))}return sD(void 0,u,e,t)}s(Et,"Z$1");var dt="2.
|
|
22
|
+
`),D(),process.exit(1);u[a]=l}}s(pu,"b");function ft(u){return u===void 0||u!==!1}s(ft,"W");function sD(u,e,t,D){const n={...e.flags},r=e.version;r&&(n.version={type:Boolean,description:"Show version"});const{help:o}=e,i=ft(o);i&&!("help"in n)&&(n.help={type:Boolean,alias:"h",description:"Show help"});const a=Ee(n,D,{ignore:e.ignoreArgv}),l=s(()=>{console.log(e.version)},"f");if(r&&a.flags.version===!0)return l(),process.exit(0);const f=new Ft,F=i&&o?.render?o.render:p=>f.render(p),c=s(p=>{const g=lt({...e,...p?{help:p}:{},flags:n});console.log(F(g,f))},"u");if(i&&a.flags.help===!0)return c(),process.exit(0);if(e.parameters){let{parameters:p}=e,g=a._;const y=p.indexOf("--"),j=p.slice(y+1),v=Object.create(null);if(y>-1&&j.length>0){p=p.slice(0,y);const C=a._["--"];g=g.slice(0,-C.length||void 0),pu(v,fu(p),g,c),pu(v,fu(j),C,c)}else pu(v,fu(p),g,c);Object.assign(a._,v)}const E={...a,showVersion:l,showHelp:c};return typeof t=="function"&&t(E),{command:u,...E}}s(sD,"x$1");function pt(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: ${P(o)}`);t.set(o,D)}}return t.get(u)}s(pt,"z$1");function Et(u,e,t=process.argv.slice(2)){if(!u)throw new Error("Options is required");if("name"in u&&(!u.name||!oD.test(u.name)))throw new Error(`Invalid script name: ${P(u.name)}`);const D=t[0];if(u.commands&&oD.test(D)){const n=pt(D,u.commands);if(n)return sD(n.options.name,{...n.options,parent:u},n.callback,t.slice(1))}return sD(void 0,u,e,t)}s(Et,"Z$1");var dt="2.5.0";const Eu=s(u=>T.promises.access(u).then(()=>!0,()=>!1),"fsExists"),ht=s(async u=>{const e=h.join(u,"package.json");if(!await Eu(e))throw new Error(`package.json not found at: ${e}`);const D=await T.promises.readFile(e,"utf8");try{return JSON.parse(D)}catch(n){throw new Error(`Cannot parse package.json: ${n.message}`)}},"readPackageJson"),gt=/^[/.]/,Du=s((u,e)=>(!h.isAbsolute(u)&&!gt.test(u)&&(u=`./${u}`),e&&!u.endsWith("/")&&(u+="/"),u),"normalizePath"),S=s(u=>{if(u.endsWith(".mjs"))return"module";if(u.endsWith(".cjs"))return"commonjs"},"getFileType"),iD=s(u=>u.startsWith("."),"isPath"),du=s((u,e,t="exports")=>{if(u){if(typeof u=="string")return iD(u)?[{outputPath:u,type:S(u)||e,from:t}]:[];if(Array.isArray(u))return u.flatMap((D,n)=>{const r=`${t}[${n}]`;return typeof D=="string"?iD(D)?{outputPath:D,type:S(D)||e,from:r}:[]:du(D,e,r)});if(typeof u=="object")return Object.entries(u).flatMap(([D,n])=>{if(typeof n=="string"){const r={outputPath:n,from:`${t}.${D}`};if(D==="require")return{...r,type:"commonjs"};if(D==="import")return{...r,type:S(n)||e};if(D==="types")return{...r,type:"types"};if(D==="node")return{...r,type:S(n)||e,platform:"node"};if(D==="default")return{...r,type:S(n)||e}}return du(n,e,`${t}.${D}`)})}return[]},"parseExportsMap"),L=s((u,e)=>{e.outputPath=Du(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"),mt=s(u=>{const e={},t=u.type??"commonjs";if(u.main){const D=u.main;L(e,{outputPath:D,type:S(D)??t,from:"main"})}if(u.module&&L(e,{outputPath:u.module,type:"module",from:"module"}),u.types&&L(e,{outputPath:u.types,type:"types",from:"types"}),u.bin){const{bin:D}=u;if(typeof D=="string")L(e,{outputPath:D,type:S(D)??t,isExecutable:!0,from:"bin"});else for(const[n,r]of Object.entries(D))L(e,{outputPath:r,type:S(r)??t,isExecutable:!0,from:`bin.${n}`})}if(u.exports){const D=du(u.exports,t);for(const n of D)L(e,n)}return Object.values(e)},"getExportEntries"),Bt=s(({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:At}=JSON,yt=s(async(u,e)=>{for(const t of e){const D=u+t;if(await Eu(D))return{extension:t,path:D}}},"tryExtensions"),aD={".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"]},bt=Object.keys(aD),wt=s(async(u,e,t)=>{const D=e+u.outputPath.slice(t.length);for(const n of bt)if(u.outputPath.endsWith(n)){const r=await yt(D.slice(0,-n.length),aD[n]);if(r)return{input:r.path,srcExtension:r.extension,distExtension:n}}throw new Error(`Could not find matching source file for export path ${At(u.outputPath)}`)},"getSourcePath"),hu="pkgroll:create-require",lD=`IS_ESM${Math.random().toString(36).slice(2)}`,$t=s(()=>({...HD({require:hu}),name:"create-require",resolveId:s(u=>u===hu?u:null,"resolveId"),load:s(u=>u!==hu?null:`
|
|
23
23
|
import { createRequire } from 'module';
|
|
24
24
|
|
|
25
25
|
export default (
|