@stacksjs/dtsx 0.9.3 → 0.9.4
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/bin/cli.js +1 -1
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -6,4 +6,4 @@ import{r as _}from"../chunk-pppmq87w.js";import{resolve as b}from"path";import G
|
|
|
6
6
|
`)});if(i)o=i(o)||o;console.log(o.map((r)=>{return r.title?`${r.title}:
|
|
7
7
|
${r.body}`:r.body}).join(`
|
|
8
8
|
|
|
9
|
-
`))}outputVersion(){let{name:t}=this.cli,{versionNumber:e}=this.cli.globalCommand;if(e)console.log(`${t}/${e} ${H}`)}checkRequiredArgs(){let t=this.args.filter((e)=>e.required).length;if(this.cli.args.length<t)throw new g(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:t,globalCommand:e}=this.cli;if(!this.config.allowUnknownOptions){for(let s of Object.keys(t))if(s!=="--"&&!this.hasOption(s)&&!e.hasOption(s))throw new g(`Unknown option \`${s.length>1?`--${s}`:`-${s}`}\``)}}checkOptionValue(){let{options:t,globalCommand:e}=this.cli,s=[...e.options,...this.options];for(let n of s){let i=t[n.name.split(".")[0]];if(n.required){let o=s.some((l)=>l.negated&&l.names.includes(n.name));if(i===!0||i===!1&&!o)throw new g(`option \`${n.rawName}\` value is missing`)}}}}class C extends k{constructor(t){super("@@global@@","",{},t)}}var p=Object.assign;class w extends T{constructor(t=""){super();this.name=t,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new C(this),this.globalCommand.usage("<command> [options]")}usage(t){return this.globalCommand.usage(t),this}command(t,e,s){let n=new k(t,e||"",s,this);return n.globalCommand=this.globalCommand,this.commands.push(n),n}option(t,e,s){return this.globalCommand.option(t,e,s),this}help(t){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=t,this.showHelpOnExit=!0,this}version(t,e="-v, --version"){return this.globalCommand.version(t,e),this.showVersionOnExit=!0,this}example(t){return this.globalCommand.example(t),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:t,options:e},s,n){if(this.args=t,this.options=e,s)this.matchedCommand=s;if(n)this.matchedCommandName=n;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(t=U,{run:e=!0}={}){if(this.rawArgs=t,!this.name)this.name=t[1]?R(t[1]):"cli";let s=!0;for(let i of this.commands){let o=this.mri(t.slice(2),i),l=o.args[0];if(i.isMatched(l)){s=!1;let c=p(p({},o),{args:o.args.slice(1)});this.setParsedInfo(c,i,l),this.emit(`command:${l}`,i)}}if(s){for(let i of this.commands)if(i.name===""){s=!1;let o=this.mri(t.slice(2),i);this.setParsedInfo(o,i),this.emit("command:!",i)}}if(s){let i=this.mri(t.slice(2));this.setParsedInfo(i)}if(this.options.help&&this.showHelpOnExit)this.outputHelp(),e=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),e=!1,this.unsetMatchedCommand();let n={args:this.args,options:this.options};if(e)this.runMatchedCommand();if(!this.matchedCommand&&this.args[0])this.emit("command:*");return n}mri(t,e){let s=[...this.globalCommand.options,...e?e.options:[]],n=B(s),i=[],o=t.indexOf("--");if(o>-1)i=t.slice(o+1),t=t.slice(0,o);let l=V(t,n);l=Object.keys(l).reduce((h,d)=>{return p(p({},h),{[E(d)]:l[d]})},{_:[]});let c=l._,r={"--":i},a=e&&e.config.ignoreOptionDefaultValue?e.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,u=Object.create(null);for(let h of s){if(!a&&h.config.default!==void 0)for(let d of h.names)r[d]=h.config.default;if(Array.isArray(h.config.type)){if(u[h.name]===void 0)u[h.name]=Object.create(null),u[h.name].shouldTransform=!0,u[h.name].transformFunction=h.config.type[0]}}for(let h of Object.keys(l))if(h!=="_"){let d=h.split(".");I(r,d,l[h]),S(r,u)}return{args:c,options:r}}runMatchedCommand(){let{args:t,options:e,matchedCommand:s}=this;if(!s||!s.commandAction)return;s.checkUnknownOptions(),s.checkOptionValue(),s.checkRequiredArgs();let n=[];return s.args.forEach((i,o)=>{if(i.variadic)n.push(t.slice(o));else n.push(t[o])}),n.push(e),s.commandAction.apply(this,n)}}var O="0.9.
|
|
9
|
+
`))}outputVersion(){let{name:t}=this.cli,{versionNumber:e}=this.cli.globalCommand;if(e)console.log(`${t}/${e} ${H}`)}checkRequiredArgs(){let t=this.args.filter((e)=>e.required).length;if(this.cli.args.length<t)throw new g(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:t,globalCommand:e}=this.cli;if(!this.config.allowUnknownOptions){for(let s of Object.keys(t))if(s!=="--"&&!this.hasOption(s)&&!e.hasOption(s))throw new g(`Unknown option \`${s.length>1?`--${s}`:`-${s}`}\``)}}checkOptionValue(){let{options:t,globalCommand:e}=this.cli,s=[...e.options,...this.options];for(let n of s){let i=t[n.name.split(".")[0]];if(n.required){let o=s.some((l)=>l.negated&&l.names.includes(n.name));if(i===!0||i===!1&&!o)throw new g(`option \`${n.rawName}\` value is missing`)}}}}class C extends k{constructor(t){super("@@global@@","",{},t)}}var p=Object.assign;class w extends T{constructor(t=""){super();this.name=t,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new C(this),this.globalCommand.usage("<command> [options]")}usage(t){return this.globalCommand.usage(t),this}command(t,e,s){let n=new k(t,e||"",s,this);return n.globalCommand=this.globalCommand,this.commands.push(n),n}option(t,e,s){return this.globalCommand.option(t,e,s),this}help(t){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=t,this.showHelpOnExit=!0,this}version(t,e="-v, --version"){return this.globalCommand.version(t,e),this.showVersionOnExit=!0,this}example(t){return this.globalCommand.example(t),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:t,options:e},s,n){if(this.args=t,this.options=e,s)this.matchedCommand=s;if(n)this.matchedCommandName=n;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(t=U,{run:e=!0}={}){if(this.rawArgs=t,!this.name)this.name=t[1]?R(t[1]):"cli";let s=!0;for(let i of this.commands){let o=this.mri(t.slice(2),i),l=o.args[0];if(i.isMatched(l)){s=!1;let c=p(p({},o),{args:o.args.slice(1)});this.setParsedInfo(c,i,l),this.emit(`command:${l}`,i)}}if(s){for(let i of this.commands)if(i.name===""){s=!1;let o=this.mri(t.slice(2),i);this.setParsedInfo(o,i),this.emit("command:!",i)}}if(s){let i=this.mri(t.slice(2));this.setParsedInfo(i)}if(this.options.help&&this.showHelpOnExit)this.outputHelp(),e=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),e=!1,this.unsetMatchedCommand();let n={args:this.args,options:this.options};if(e)this.runMatchedCommand();if(!this.matchedCommand&&this.args[0])this.emit("command:*");return n}mri(t,e){let s=[...this.globalCommand.options,...e?e.options:[]],n=B(s),i=[],o=t.indexOf("--");if(o>-1)i=t.slice(o+1),t=t.slice(0,o);let l=V(t,n);l=Object.keys(l).reduce((h,d)=>{return p(p({},h),{[E(d)]:l[d]})},{_:[]});let c=l._,r={"--":i},a=e&&e.config.ignoreOptionDefaultValue?e.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,u=Object.create(null);for(let h of s){if(!a&&h.config.default!==void 0)for(let d of h.names)r[d]=h.config.default;if(Array.isArray(h.config.type)){if(u[h.name]===void 0)u[h.name]=Object.create(null),u[h.name].shouldTransform=!0,u[h.name].transformFunction=h.config.type[0]}}for(let h of Object.keys(l))if(h!=="_"){let d=h.split(".");I(r,d,l[h]),S(r,u)}return{args:c,options:r}}runMatchedCommand(){let{args:t,options:e,matchedCommand:s}=this;if(!s||!s.commandAction)return;s.checkUnknownOptions(),s.checkOptionValue(),s.checkRequiredArgs();let n=[];return s.args.forEach((i,o)=>{if(i.variadic)n.push(t.slice(o));else n.push(t[o])}),n.push(e),s.commandAction.apply(this,n)}}var O="0.9.4";var f=new w("dtsx"),m={cwd:G.cwd(),root:"./src",entrypoints:["**/*.ts"],outdir:"./dist",keepComments:!0,clean:!1,tsconfigPath:"tsconfig.json",verbose:!1};f.command("generate","Generate TypeScript declaration files").option("--cwd <path>","Current working directory",{default:m.cwd}).option("--root <path>","Root directory of the project",{default:m.root}).option("--entrypoints <files>","Entry point files (comma-separated)",{default:m.entrypoints?.join(","),type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:m.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:m.keepComments}).option("--clean","Clean output directory before generation",{default:m.clean}).option("--tsconfig <path>","Path to tsconfig.json",{default:m.tsconfigPath}).option("--verbose","Enable verbose logging",{default:m.verbose}).example("dtsx generate").example("dtsx generate --entrypoints src/index.ts,src/utils.ts --outdir dist/types").action(async(t)=>{try{let e={entrypoints:t.entrypoints?t.entrypoints:m.entrypoints,cwd:b(t.cwd||m.cwd),root:b(t.root||m.root),outdir:b(t.outdir||m.outdir),tsconfigPath:b(t.tsconfigPath||m.tsconfigPath),keepComments:t.keepComments||m.keepComments,clean:t.clean||m.clean,verbose:t.verbose||m.verbose};await _(e)}catch(e){console.error("Error generating .d.ts files:",e),G.exit(1)}});f.command("version","Show the version of dtsx").action(()=>{console.log(O)});f.version(O);f.help();f.parse();
|