@tsmodule/tsmodule 41.36.0 → 41.38.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/README.md CHANGED
@@ -101,20 +101,32 @@ tsmodule build [--bundle]
101
101
  - Bundle CSS by default
102
102
  - Use Tailwind by default
103
103
 
104
- ### Optimize NPM dependencies with `-b, --bundle`
104
+ ### Optimize NPM dependencies with `build --bundle`
105
105
 
106
106
  With `-b, --bundle` mode, all entry points are compiled "in-place" and runtime NPM dependencies will generally not be needed as they will be inlined. If you build in bundle mode, you can move your dependencies to devDependencies, as the only thing that will be needed to run any/all compiled-in-place entry point(s) in your module are the bundles themselves.
107
107
 
108
- TSModule itself builds with `-b, --bundle` flag, and requires only two runtime NPM dependencies:
108
+ TSModule itself builds with `-b, --bundle` flag, and requires only three runtime NPM dependencies:
109
109
 
110
110
  1. `esbuild`, which does the heavy lifting for the build process, does not allow itself to be bundled
111
111
  2. `typescript`, so TSModule can use the built `tsc` binary to generate `.d.ts`
112
112
  type declarations during builds
113
+ 3. `pkg`, for building binaries with `build --binary` (which implies `--bundle`
114
+ and `--standalone src/bin.ts`).
113
115
 
114
116
  <sub>Note: Bundling every entry point in place may not be what you want, i.e. if you
115
117
  only have a single entrypoint. In these cases, `tsmodule build -b src/index.ts`
116
118
  is more appropriate.</sub>
117
119
 
120
+ ### Build executable binaries with `build --binary`
121
+
122
+ Uses Vercel's [`pkg`](https://github.com/vercel/pkg) to build binaries from
123
+ `src/bin.ts`.
124
+
125
+ <sub>**IMPORTANT:** This requires coercing to CJS, which is not possible if your
126
+ program uses top-level await. For now, replace with async closures and monitor
127
+ [this issue](https://github.com/vercel/pkg/issues/1291) for updates on full ESM
128
+ support.</sub>
129
+
118
130
  ### Run TypeScript directly
119
131
 
120
132
  ```
package/dist/bin.js CHANGED
@@ -4,7 +4,7 @@
4
4
  if(typeof process<"u"){let{dirname:e}=await import("path"),{fileURLToPath:i}=await import("url");globalThis.__filename=i(import.meta.url),globalThis.__dirname=e(globalThis.__filename);let{default:a}=await import("module");globalThis.require=a.createRequire(import.meta.url)}
5
5
  /** __ESM_SHIM_END */
6
6
 
7
- import{a as f,b as R,c as U,d as B,f as G,h as J,i as z,j as K,k as Y,l as Q}from"./chunk-WPN6KKF5.js";import{a as E,b as A,c as ft}from"./chunk-UNZJKJGP.js";var x=A(F=>{var v=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}},k=class extends v{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};F.CommanderError=v;F.InvalidArgumentError=k});var $=A(N=>{var{InvalidArgumentError:gt}=x(),D=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:e.concat(t)}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,i)=>{if(!this.argChoices.includes(e))throw new gt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function _t(h){let t=h.name()+(h.variadic===!0?"...":"");return h.required?"<"+t+">":"["+t+"]"}N.Argument=D;N.humanReadableArgName=_t});var T=A(X=>{var{humanReadableArgName:Ot}=$(),P=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(t){let e=t.commands.filter(i=>!i._hidden);if(t._hasImplicitHelpCommand()){let[,i,n]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),s=t.createCommand(i).helpOption(!1);s.description(t._helpCommandDescription),n&&s.arguments(n),e.push(s)}return this.sortSubcommands&&e.sort((i,n)=>i.name().localeCompare(n.name())),e}compareOptions(t,e){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){let e=t.options.filter(s=>!s.hidden),i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag),n=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||n){let s;i?n?s=t.createOption(t._helpFlags,t._helpDescription):s=t.createOption(t._helpShortFlag,t._helpDescription):s=t.createOption(t._helpLongFlag,t._helpDescription),e.push(s)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let e=[];for(let i=t.parent;i;i=i.parent){let n=i.options.filter(s=>!s.hidden);e.push(...n)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t._args.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t._args.find(e=>e.description)?t._args:[]}subcommandTerm(t){let e=t._args.map(i=>Ot(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((i,n)=>Math.max(i,e.subcommandTerm(n).length),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((i,n)=>Math.max(i,e.optionTerm(n).length),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((i,n)=>Math.max(i,e.optionTerm(n).length),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((i,n)=>Math.max(i,e.argumentTerm(n).length),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let n=t.parent;n;n=n.parent)i=n.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let e=[];return t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&e.push(`env: ${t.envVar}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}argumentDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,e){let i=e.padWidth(t,e),n=e.helpWidth||80,s=2,r=2;function a(m,O){if(O){let H=`${m.padEnd(i+r)}${O}`;return e.wrap(H,n-s,i+r)}return m}function o(m){return m.join(`
7
+ import{a as f,b as R,c as B,d as U,f as G,h as J,i as z,j as K,k as Y,l as Q}from"./chunk-CJB3QE3J.js";import{a as E,b as A,c as ft}from"./chunk-UNZJKJGP.js";var x=A(F=>{var v=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}},k=class extends v{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};F.CommanderError=v;F.InvalidArgumentError=k});var $=A(N=>{var{InvalidArgumentError:gt}=x(),D=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:e.concat(t)}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,i)=>{if(!this.argChoices.includes(e))throw new gt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function _t(h){let t=h.name()+(h.variadic===!0?"...":"");return h.required?"<"+t+">":"["+t+"]"}N.Argument=D;N.humanReadableArgName=_t});var T=A(X=>{var{humanReadableArgName:Ot}=$(),P=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(t){let e=t.commands.filter(i=>!i._hidden);if(t._hasImplicitHelpCommand()){let[,i,n]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),s=t.createCommand(i).helpOption(!1);s.description(t._helpCommandDescription),n&&s.arguments(n),e.push(s)}return this.sortSubcommands&&e.sort((i,n)=>i.name().localeCompare(n.name())),e}compareOptions(t,e){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){let e=t.options.filter(s=>!s.hidden),i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag),n=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||n){let s;i?n?s=t.createOption(t._helpFlags,t._helpDescription):s=t.createOption(t._helpShortFlag,t._helpDescription):s=t.createOption(t._helpLongFlag,t._helpDescription),e.push(s)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let e=[];for(let i=t.parent;i;i=i.parent){let n=i.options.filter(s=>!s.hidden);e.push(...n)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t._args.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t._args.find(e=>e.description)?t._args:[]}subcommandTerm(t){let e=t._args.map(i=>Ot(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((i,n)=>Math.max(i,e.subcommandTerm(n).length),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((i,n)=>Math.max(i,e.optionTerm(n).length),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((i,n)=>Math.max(i,e.optionTerm(n).length),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((i,n)=>Math.max(i,e.argumentTerm(n).length),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let n=t.parent;n;n=n.parent)i=n.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let e=[];return t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&e.push(`env: ${t.envVar}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}argumentDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,e){let i=e.padWidth(t,e),n=e.helpWidth||80,s=2,r=2;function a(m,O){if(O){let H=`${m.padEnd(i+r)}${O}`;return e.wrap(H,n-s,i+r)}return m}function o(m){return m.join(`
8
8
  `).replace(/^/gm," ".repeat(s))}let l=[`Usage: ${e.commandUsage(t)}`,""],u=e.commandDescription(t);u.length>0&&(l=l.concat([e.wrap(u,n,0),""]));let c=e.visibleArguments(t).map(m=>a(e.argumentTerm(m),e.argumentDescription(m)));c.length>0&&(l=l.concat(["Arguments:",o(c),""]));let d=e.visibleOptions(t).map(m=>a(e.optionTerm(m),e.optionDescription(m)));if(d.length>0&&(l=l.concat(["Options:",o(d),""])),this.showGlobalOptions){let m=e.visibleGlobalOptions(t).map(O=>a(e.optionTerm(O),e.optionDescription(O)));m.length>0&&(l=l.concat(["Global Options:",o(m),""]))}let C=e.visibleCommands(t).map(m=>a(e.subcommandTerm(m),e.subcommandDescription(m)));return C.length>0&&(l=l.concat(["Commands:",o(C),""])),l.join(`
9
9
  `)}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,i,n=40){let s=" \\f\\t\\v   -    \uFEFF",r=new RegExp(`[\\n][${s}]+`);if(t.match(r))return t;let a=e-i;if(a<n)return t;let o=t.slice(0,i),l=t.slice(i).replace(`\r
10
10
  `,`
@@ -24,9 +24,9 @@ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._life
24
24
  `),this.outputHelp({error:!0}));let i=e||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in p.env){let e=t.attributeName();(this.getOptionValue(e)===void 0||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,p.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new $t(this.options),e=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!e(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(t){let e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){let e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){let i=r=>{let a=r.attributeName(),o=this.getOptionValue(a),l=this.options.find(c=>c.negate&&a===c.attributeName()),u=this.options.find(c=>!c.negate&&a===c.attributeName());return l&&(l.presetArg===void 0&&o===!1||l.presetArg!==void 0&&o===l.presetArg)?l:u||r},n=r=>{let a=i(r),o=a.attributeName();return this.getOptionValueSource(o)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},s=`error: ${n(t)} cannot be used with ${n(e)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let n=[],s=this;do{let r=s.createHelp().visibleOptions(s).filter(a=>a.long).map(a=>a.long);n=n.concat(r),s=s.parent}while(s&&!s._enablePositionalOptions);e=nt(t,n)}let i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let e=this._args.length,i=e===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${i} but got ${t.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],e="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(s=>{n.push(s.name()),s.alias()&&n.push(s.alias())}),e=nt(t,n)}let i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(t===void 0)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";let n=this.createOption(e,i);return this._versionOptionName=n.attributeName(),this.options.push(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}
25
25
  `),this._exit(0,"commander.version",t)}),this}description(t,e){return t===void 0&&e===void 0?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");return e._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(e=>this.alias(e)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let e=this._args.map(i=>yt(i));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?e:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=_.basename(t,_.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let e=this.createHelp();return e.helpWidth===void 0&&(e.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),e.formatHelp(this,e)}_getHelpContext(t){t=t||{};let e={error:!!t.error},i;return e.error?i=n=>this._outputConfiguration.writeErr(n):i=n=>this._outputConfiguration.writeOut(n),e.write=t.write||i,e.command=this,e}outputHelp(t){let e;typeof t=="function"&&(e=t,t=void 0);let i=this._getHelpContext(t);y(this).reverse().forEach(s=>s.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(e&&(n=e(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this.emit(this._helpLongFlag),this.emit("afterHelp",i),y(this).forEach(s=>s.emit("afterAllHelp",i))}helpOption(t,e){if(typeof t=="boolean")return this._hasHelpOption=t,this;this._helpFlags=t||this._helpFlags,this._helpDescription=e||this._helpDescription;let i=vt(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(t){this.outputHelp(t);let e=p.exitCode||0;e===0&&t&&typeof t!="function"&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.
26
26
  Expecting one of '${i.join("', '")}'`);let n=`${t}Help`;return this.on(n,s=>{let r;typeof e=="function"?r=e({error:s.error,command:s.command}):r=e,r&&s.write(`${r}
27
- `)}),this}};function st(h,t){h._hasHelpOption&&t.find(i=>i===h._helpLongFlag||i===h._helpShortFlag)&&(h.outputHelp(),h._exit(0,"commander.helpDisplayed","(outputHelp)"))}function rt(h){return h.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i="127.0.0.1",n="9229",s;return(s=t.match(/^(--inspect(-brk)?)$/))!==null?e=s[1]:(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(e=s[1],/^\d+$/.test(s[3])?n=s[3]:i=s[3]):(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(e=s[1],i=s[3],n=s[4]),e&&n!=="0"?`${e}=${i}:${parseInt(n)+1}`:t})}function y(h){let t=[];for(let e=h;e;e=e.parent)t.push(e);return t}ot.Command=S});var ct=A((g,ut)=>{var{Argument:Vt}=$(),{Command:lt}=at(),{CommanderError:Ht,InvalidArgumentError:ht}=x(),{Help:kt}=T(),{Option:Ft}=j();g=ut.exports=new lt;g.program=g;g.Argument=Vt;g.Command=lt;g.CommanderError=Ht;g.Help=kt;g.InvalidArgumentError=ht;g.InvalidOptionArgumentError=ht;g.Option=Ft});var pt=ft(ct(),1),{program:Mt,createCommand:Lt,createArgument:Rt,createOption:Ut,CommanderError:Bt,InvalidArgumentError:Gt,InvalidOptionArgumentError:Jt,Command:mt,Argument:zt,Option:Kt,Help:Yt}=pt.default;var dt=async()=>{let h="default";(await R())?.dependencies?.react&&(h="react"),await z({template:h,targetDir:process.cwd()})};var Dt=h=>{let t=h;return!(t.code===void 0||t.stdout==null||t.stderr==null)},w=h=>async(...e)=>{try{return await h(...e)}catch(i){B("Error"),Dt(i)?(i.stdout&&console.log(f.red(i.stdout)),i.stderr&&console.log(f.redBright(i.stderr))):console.log(f.redBright(JSON.stringify(i,null,2))),console.log()}};var{version:Nt}=await J(),b=new mt;b.name(f.white(f.bold("tsmodule"))).usage(f.white(f.bold("<file | command> [options]"))).description(f.blueBright(`A tool for building TypeScript modules.
27
+ `)}),this}};function st(h,t){h._hasHelpOption&&t.find(i=>i===h._helpLongFlag||i===h._helpShortFlag)&&(h.outputHelp(),h._exit(0,"commander.helpDisplayed","(outputHelp)"))}function rt(h){return h.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i="127.0.0.1",n="9229",s;return(s=t.match(/^(--inspect(-brk)?)$/))!==null?e=s[1]:(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(e=s[1],/^\d+$/.test(s[3])?n=s[3]:i=s[3]):(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(e=s[1],i=s[3],n=s[4]),e&&n!=="0"?`${e}=${i}:${parseInt(n)+1}`:t})}function y(h){let t=[];for(let e=h;e;e=e.parent)t.push(e);return t}ot.Command=S});var ct=A((g,ut)=>{var{Argument:Vt}=$(),{Command:lt}=at(),{CommanderError:Ht,InvalidArgumentError:ht}=x(),{Help:kt}=T(),{Option:Ft}=j();g=ut.exports=new lt;g.program=g;g.Argument=Vt;g.Command=lt;g.CommanderError=Ht;g.Help=kt;g.InvalidArgumentError=ht;g.InvalidOptionArgumentError=ht;g.Option=Ft});var pt=ft(ct(),1),{program:Mt,createCommand:Lt,createArgument:Rt,createOption:Bt,CommanderError:Ut,InvalidArgumentError:Gt,InvalidOptionArgumentError:Jt,Command:mt,Argument:zt,Option:Kt,Help:Yt}=pt.default;var dt=async()=>{let h="default";(await R())?.dependencies?.react&&(h="react"),await z({template:h,targetDir:process.cwd()})};var Dt=h=>{let t=h;return!(t.code===void 0||t.stdout==null||t.stderr==null)},w=h=>async(...e)=>{try{return await h(...e)}catch(i){U("Error"),Dt(i)?(i.stdout&&console.log(f.red(i.stdout)),i.stderr&&console.log(f.redBright(i.stderr))):console.log(f.redBright(JSON.stringify(i,null,2))),console.log()}};var{version:Nt}=await J(),b=new mt;b.name(f.white(f.bold("tsmodule"))).usage(f.white(f.bold("<file | command> [options]"))).description(f.blueBright(`A tool for building TypeScript modules.
28
28
 
29
29
  Run TS directly: ${f.bold("tsmodule src/index.ts")}
30
- Use a command: ${f.bold("tsmodule build")}`)).version(String(Nt));b.command("dev").description("Build and watch for changes.").option("-f, --format <format>","Output format (default: ESM).").action(w(Y));b.command("build").description("Builds TS files to output in dist/.").argument("[files]","Glob of entrypoints to compile.").option("-d, --dev","Build development runtime.").option("-t, --target <target>","ECMAScript featureset to target (default: ESNext).").option("-f, --format <format>","Output format (default: ESM).").option("-b, --bundle","Bundle external dependencies into entrypoints.").option("-t, --tsconfig","Specify a custom tsconfig.json file.","tsconfig.json").option("-e, --external <external...>","External dependencies to exclude from bundling.").option("--standalone","Bundle a standalone entry-points without any import statements.").option("-r, --runtime-only","Do not emit type declarations, only build JS runtime.").option("-j, --js-only","Do not build styles").option("-s, --styles <styles>","Specify stylesheet entrypoint.").option("--stdin [source]","Read from a string or stdin.").option("--stdin-file [file]","File path to mock for stdin.").option("--no-write",`Return code from build() rather than write to disk.
30
+ Use a command: ${f.bold("tsmodule build")}`)).version(String(Nt));b.command("dev").description("Build and watch for changes.").option("-f, --format <format>","Output format (default: ESM).").action(w(Y));b.command("build").description("Builds TS files to output in dist/.").argument("[files]","Glob of entrypoints to compile.").option("-d, --dev","Build development runtime.").option("-t, --target <target>","ECMAScript featureset to target (default: ESNext).").option("-f, --format <format>","Output format (default: ESM).").option("-b, --bundle","Bundle external dependencies into entrypoints.").option("-t, --tsconfig","Specify a custom tsconfig.json file.","tsconfig.json").option("-e, --external <external...>","External dependencies to exclude from bundling.").option("--binary","Build binary executables from src/bin.ts.").option("--standalone","Bundle a standalone entry-points without any import statements.").option("-r, --runtime-only","Do not emit type declarations, only build JS runtime.").option("-j, --js-only","Do not build styles").option("-s, --styles <styles>","Specify stylesheet entrypoint.").option("--stdin [source]","Read from a string or stdin.").option("--stdin-file [file]","File path to mock for stdin.").option("--no-write",`Return code from build() rather than write to disk.
31
31
  For programmatic use alongside { stdin: ... }.`).action(w(G));b.command("create <name>").option("--react","Create React component library with Next.js").description("Create a new project.").action(w(K));b.command("convert").description("Convert an existing project to a TS module.").action(w(dt));b.command("normalize [files]").description(`Rewrites import specifiers in files to ESM-compliant paths.
32
- (default: dist/**/*.js)`).action(w(async({files:h})=>{await U(h)}));b.command("execute",{isDefault:!0}).argument("<file>","The file to execute.").option("--d, --dev","Enable development mode").description("Run the given TS program, analogous to `node <file>`.").action(w(Q));b.parse(process.argv);
32
+ (default: dist/**/*.js)`).action(w(async({files:h})=>{await B(h)}));b.command("execute",{isDefault:!0}).argument("<file>","The file to execute.").option("--d, --dev","Enable development mode").description("Run the given TS program, analogous to `node <file>`.").action(w(Q));b.parse(process.argv);