command-code 0.0.1 → 0.0.3
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 +54 -0
- package/dist/index.cjs +2 -0
- package/package.json +27 -10
- package/dist/commands/config.d.ts +0 -3
- package/dist/commands/config.d.ts.map +0 -1
- package/dist/commands/config.js +0 -72
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/greet.d.ts +0 -3
- package/dist/commands/greet.d.ts.map +0 -1
- package/dist/commands/greet.js +0 -22
- package/dist/commands/greet.js.map +0 -1
- package/dist/commands/info.d.ts +0 -3
- package/dist/commands/info.d.ts.map +0 -1
- package/dist/commands/info.js +0 -37
- package/dist/commands/info.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -23
- package/dist/index.js.map +0 -1
- package/src/commands/config.ts +0 -82
- package/src/commands/greet.ts +0 -25
- package/src/commands/info.ts +0 -42
- package/src/index.ts +0 -26
- package/tsconfig.json +0 -11
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Command Code CLI
|
|
2
|
+
|
|
3
|
+
A powerful command-line interface for code generation and management.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g command-code
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
After installation, you can use any of the following commands:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
command-code [options]
|
|
17
|
+
cmd [options]
|
|
18
|
+
cmnd [options]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Development
|
|
22
|
+
|
|
23
|
+
### Prerequisites
|
|
24
|
+
|
|
25
|
+
- Node.js 18+
|
|
26
|
+
- pnpm
|
|
27
|
+
|
|
28
|
+
### Setup
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Install dependencies
|
|
32
|
+
pnpm install
|
|
33
|
+
|
|
34
|
+
# Build the project
|
|
35
|
+
pnpm build
|
|
36
|
+
|
|
37
|
+
# Run in development mode
|
|
38
|
+
pnpm dev
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Scripts
|
|
42
|
+
|
|
43
|
+
- `pnpm build` - Build the project using tsup
|
|
44
|
+
- `pnpm dev` - Run in development mode with tsx
|
|
45
|
+
- `pnpm typecheck` - Check TypeScript types
|
|
46
|
+
- `pnpm start` - Run the built application
|
|
47
|
+
|
|
48
|
+
## Author
|
|
49
|
+
|
|
50
|
+
Ahmad Awais <me@AhmadAwais.com> (https://twitter.com/MrAhmadAwais)
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
UNLICENSED
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";var t=require("os"),i=require("fs/promises"),s=require("path");function e(t){if(t&&t.t)return t;var i=Object.create(null);return t&&Object.keys(t).forEach(function(s){if("default"!==s){var e=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(i,s,e.get?e:{enumerable:!0,get:function(){return t[s]}})}}),i.default=t,Object.freeze(i)}var n,r,o=e(t),h=e(i),a=e(s),u=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,m=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,f=(t=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(t,{get:(t,i)=>("undefined"!=typeof require?require:t)[i]}):t)(function(t){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),g=(t,i)=>function(){return i||(0,t[d(t)[0]])((i={exports:{}}).exports,i),i.exports},v=g({"../../node_modules/.pnpm/commander@14.0.0/node_modules/commander/lib/error.js"(t){var i=class extends Error{constructor(t,i,s){super(s),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=i,this.exitCode=t,this.nestedError=void 0}};t.CommanderError=i,t.InvalidArgumentError=class extends i{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}}}),$=g({"../../node_modules/.pnpm/commander@14.0.0/node_modules/commander/lib/argument.js"(t){var{InvalidArgumentError:i}=v();t.Argument=class{constructor(t,i){switch(this.description=i||"",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.i=t.slice(1,-1);break;case"[":this.required=!1,this.i=t.slice(1,-1);break;default:this.required=!0,this.i=t}this.i.length>3&&"..."===this.i.slice(-3)&&(this.variadic=!0,this.i=this.i.slice(0,-3))}name(){return this.i}o(t,i){return i!==this.defaultValue&&Array.isArray(i)?i.concat(t):[t]}default(t,i){return this.defaultValue=t,this.defaultValueDescription=i,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,s)=>{if(!this.argChoices.includes(t))throw new i(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this.o(t,s):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},t.humanReadableArgName=function(t){const i=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+i+">":"["+i+"]"}}}),w=g({"../../node_modules/.pnpm/commander@14.0.0/node_modules/commander/lib/help.js"(t){var{humanReadableArgName:i}=$();function s(t){return t.replace(/\x1b\[\d*(;\d*)*m/g,"")}t.Help=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){const i=t.commands.filter(t=>!t.h),s=t.u();return s&&!s.h&&i.push(s),this.sortSubcommands&&i.sort((t,i)=>t.name().localeCompare(i.name())),i}compareOptions(t,i){const s=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return s(t).localeCompare(s(i))}visibleOptions(t){const i=t.options.filter(t=>!t.hidden),s=t.l();if(s&&!s.hidden){const e=s.short&&t.m(s.short),n=s.long&&t.m(s.long);e||n?s.long&&!n?i.push(t.createOption(s.long,s.description)):s.short&&!e&&i.push(t.createOption(s.short,s.description)):i.push(s)}return this.sortOptions&&i.sort(this.compareOptions),i}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const i=[];for(let s=t.parent;s;s=s.parent){const t=s.options.filter(t=>!t.hidden);i.push(...t)}return this.sortOptions&&i.sort(this.compareOptions),i}visibleArguments(t){return t.p&&t.registeredArguments.forEach(i=>{i.description=i.description||t.p[i.name()]||""}),t.registeredArguments.find(t=>t.description)?t.registeredArguments:[]}subcommandTerm(t){const s=t.registeredArguments.map(t=>i(t)).join(" ");return t.i+(t.v[0]?"|"+t.v[0]:"")+(t.options.length?" [options]":"")+(s?" "+s:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,i){return i.visibleCommands(t).reduce((t,s)=>Math.max(t,this.displayWidth(i.styleSubcommandTerm(i.subcommandTerm(s)))),0)}longestOptionTermLength(t,i){return i.visibleOptions(t).reduce((t,s)=>Math.max(t,this.displayWidth(i.styleOptionTerm(i.optionTerm(s)))),0)}longestGlobalOptionTermLength(t,i){return i.visibleGlobalOptions(t).reduce((t,s)=>Math.max(t,this.displayWidth(i.styleOptionTerm(i.optionTerm(s)))),0)}longestArgumentTermLength(t,i){return i.visibleArguments(t).reduce((t,s)=>Math.max(t,this.displayWidth(i.styleArgumentTerm(i.argumentTerm(s)))),0)}commandUsage(t){let i=t.i;t.v[0]&&(i=i+"|"+t.v[0]);let s="";for(let i=t.parent;i;i=i.parent)s=i.name()+" "+s;return s+i+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const i=[];if(t.argChoices&&i.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue&&(t.required||t.optional||t.isBoolean()&&"boolean"==typeof t.defaultValue)&&i.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),void 0!==t.presetArg&&t.optional&&i.push(`preset: ${JSON.stringify(t.presetArg)}`),void 0!==t.envVar&&i.push(`env: ${t.envVar}`),i.length>0){const s=`(${i.join(", ")})`;return t.description?`${t.description} ${s}`:s}return t.description}argumentDescription(t){const i=[];if(t.argChoices&&i.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue&&i.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),i.length>0){const s=`(${i.join(", ")})`;return t.description?`${t.description} ${s}`:s}return t.description}formatItemList(t,i,s){return 0===i.length?[]:[s.styleTitle(t),...i,""]}groupItems(t,i,s){const e=new Map;return t.forEach(t=>{const i=s(t);e.has(i)||e.set(i,[])}),i.forEach(t=>{const i=s(t);e.has(i)||e.set(i,[]),e.get(i).push(t)}),e}formatHelp(t,i){const s=i.padWidth(t,i),e=i.helpWidth??80;function n(t,e){return i.formatItem(t,s,e,i)}let r=[`${i.styleTitle("Usage:")} ${i.styleUsage(i.commandUsage(t))}`,""];const o=i.commandDescription(t);o.length>0&&(r=r.concat([i.boxWrap(i.styleCommandDescription(o),e),""]));const h=i.visibleArguments(t).map(t=>n(i.styleArgumentTerm(i.argumentTerm(t)),i.styleArgumentDescription(i.argumentDescription(t))));if(r=r.concat(this.formatItemList("Arguments:",h,i)),this.groupItems(t.options,i.visibleOptions(t),t=>t.helpGroupHeading??"Options:").forEach((t,s)=>{const e=t.map(t=>n(i.styleOptionTerm(i.optionTerm(t)),i.styleOptionDescription(i.optionDescription(t))));r=r.concat(this.formatItemList(s,e,i))}),i.showGlobalOptions){const s=i.visibleGlobalOptions(t).map(t=>n(i.styleOptionTerm(i.optionTerm(t)),i.styleOptionDescription(i.optionDescription(t))));r=r.concat(this.formatItemList("Global Options:",s,i))}return this.groupItems(t.commands,i.visibleCommands(t),t=>t.helpGroup()||"Commands:").forEach((t,s)=>{const e=t.map(t=>n(i.styleSubcommandTerm(i.subcommandTerm(t)),i.styleSubcommandDescription(i.subcommandDescription(t))));r=r.concat(this.formatItemList(s,e,i))}),r.join("\n")}displayWidth(t){return s(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(t=>"[options]"===t?this.styleOptionText(t):"[command]"===t?this.styleSubcommandText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(t=>"[options]"===t?this.styleOptionText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,i){return Math.max(i.longestOptionTermLength(t,i),i.longestGlobalOptionTermLength(t,i),i.longestSubcommandTermLength(t,i),i.longestArgumentTermLength(t,i))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,i,s,e){const n=" ".repeat(2);if(!s)return n+t;const r=t.padEnd(i+t.length-e.displayWidth(t)),o=(this.helpWidth??80)-i-2-2;let h;return h=o<this.minWidthToWrap||e.preformatted(s)?s:e.boxWrap(s,o).replace(/\n/g,"\n"+" ".repeat(i+2)),n+r+" ".repeat(2)+h.replace(/\n/g,`\n${n}`)}boxWrap(t,i){if(i<this.minWidthToWrap)return t;const s=t.split(/\r\n|\n/),e=/[\s]*[^\s]+/g,n=[];return s.forEach(t=>{const s=t.match(e);if(null===s)return void n.push("");let r=[s.shift()],o=this.displayWidth(r[0]);s.forEach(t=>{const s=this.displayWidth(t);if(o+s<=i)return r.push(t),void(o+=s);n.push(r.join(""));const e=t.trimStart();r=[e],o=this.displayWidth(e)}),n.push(r.join(""))}),n.join("\n")}},t.stripColor=s}}),b=g({"../../node_modules/.pnpm/commander@14.0.0/node_modules/commander/lib/option.js"(t){var{InvalidArgumentError:i}=v();function s(t){return t.split("-").reduce((t,i)=>t+i[0].toUpperCase()+i.slice(1))}t.Option=class{constructor(t,i){this.flags=t,this.description=i||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;const s=function(t){let i,s;const e=/^-[^-]$/,n=/^--[^-]/,r=t.split(/[ |,]+/).concat("guard");if(e.test(r[0])&&(i=r.shift()),n.test(r[0])&&(s=r.shift()),!i&&e.test(r[0])&&(i=r.shift()),!i&&n.test(r[0])&&(i=s,s=r.shift()),r[0].startsWith("-")){const i=r[0],s=`option creation failed due to '${i}' in option flags '${t}'`;if(/^-[^-][^-]/.test(i))throw new Error(`${s}\n- a short flag is a single dash and a single character\n - either use a single dash and a single character (for a short flag)\n - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(e.test(i))throw new Error(`${s}\n- too many short flags`);if(n.test(i))throw new Error(`${s}\n- too many long flags`);throw new Error(`${s}\n- unrecognised flag format`)}if(void 0===i&&void 0===s)throw new Error(`option creation failed due to no flags found in '${t}'.`);return{shortFlag:i,longFlag:s}}(t);this.short=s.shortFlag,this.long=s.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(t,i){return this.defaultValue=t,this.defaultValueDescription=i,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let i=t;return"string"==typeof t&&(i={[t]:!0}),this.implied=Object.assign(this.implied||{},i),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}o(t,i){return i!==this.defaultValue&&Array.isArray(i)?i.concat(t):[t]}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,s)=>{if(!this.argChoices.includes(t))throw new i(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this.o(t,s):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?s(this.name().replace(/^no-/,"")):s(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},t.DualOptions=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(t,i){const s=i.attributeName();if(!this.dualOptions.has(s))return!0;const e=this.negativeOptions.get(s).presetArg,n=void 0!==e&&e;return i.negate===(n===t)}}}}),y=g({"../../node_modules/.pnpm/commander@14.0.0/node_modules/commander/lib/suggestSimilar.js"(t){t.suggestSimilar=function(t,i){if(!i||0===i.length)return"";i=Array.from(new Set(i));const s=t.startsWith("--");s&&(t=t.slice(2),i=i.map(t=>t.slice(2)));let e=[],n=3;return i.forEach(i=>{if(i.length<=1)return;const s=function(t,i){if(Math.abs(t.length-i.length)>3)return Math.max(t.length,i.length);const s=[];for(let i=0;i<=t.length;i++)s[i]=[i];for(let t=0;t<=i.length;t++)s[0][t]=t;for(let e=1;e<=i.length;e++)for(let n=1;n<=t.length;n++){let r=1;r=t[n-1]===i[e-1]?0:1,s[n][e]=Math.min(s[n-1][e]+1,s[n][e-1]+1,s[n-1][e-1]+r),n>1&&e>1&&t[n-1]===i[e-2]&&t[n-2]===i[e-1]&&(s[n][e]=Math.min(s[n][e],s[n-2][e-2]+1))}return s[t.length][i.length]}(t,i),r=Math.max(t.length,i.length);(r-s)/r>.4&&(s<n?(n=s,e=[i]):s===n&&e.push(i))}),e.sort((t,i)=>t.localeCompare(i)),s&&(e=e.map(t=>`--${t}`)),e.length>1?`\n(Did you mean one of ${e.join(", ")}?)`:1===e.length?`\n(Did you mean ${e[0]}?)`:""}}}),O=g({"../../node_modules/.pnpm/commander@14.0.0/node_modules/commander/lib/command.js"(t){var i=f("events").EventEmitter,s=f("child_process"),e=f("path"),n=f("fs"),r=f("process"),{Argument:o,humanReadableArgName:h}=$(),{CommanderError:a}=v(),{Help:u,stripColor:c}=w(),{Option:l,DualOptions:d}=b(),{suggestSimilar:m}=y();function p(t){return t.map(t=>{if(!t.startsWith("--inspect"))return t;let i,s,e="127.0.0.1",n="9229";return null!==(s=t.match(/^(--inspect(-brk)?)$/))?i=s[1]:null!==(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(i=s[1],/^\d+$/.test(s[3])?n=s[3]:e=s[3]):null!==(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(i=s[1],e=s[3],n=s[4]),i&&"0"!==n?`${i}=${e}:${parseInt(n)+1}`:t})}function g(){return!r.env.NO_COLOR&&"0"!==r.env.FORCE_COLOR&&"false"!==r.env.FORCE_COLOR&&(!(!r.env.FORCE_COLOR&&void 0===r.env.CLICOLOR_FORCE)||void 0)}t.Command=class t extends i{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this.$=!1,this.O=!1,this.registeredArguments=[],this.C=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this.A=null,this.i=t||"",this._={},this.S={},this.k=!1,this.j=null,this.H=!1,this.I=null,this.T=null,this.M=null,this.N=null,this.v=[],this.D=!0,this.P="",this.G="",this.p=void 0,this.q=!1,this.F=!1,this.U={},this.V=!1,this.W=!0,this.J=null,this.L={writeOut:t=>r.stdout.write(t),writeErr:t=>r.stderr.write(t),outputError:(t,i)=>i(t),getOutHelpWidth:()=>r.stdout.isTTY?r.stdout.columns:void 0,getErrHelpWidth:()=>r.stderr.isTTY?r.stderr.columns:void 0,getOutHasColors:()=>g()??(r.stdout.isTTY&&r.stdout.hasColors?.()),getErrHasColors:()=>g()??(r.stderr.isTTY&&r.stderr.hasColors?.()),stripColor:t=>c(t)},this.h=!1,this.R=void 0,this.B=void 0,this.K=void 0,this.X={},this.Y=void 0,this.Z=void 0,this.tt=void 0}copyInheritedSettings(t){return this.L=t.L,this.R=t.R,this.K=t.K,this.X=t.X,this.N=t.N,this.k=t.k,this.D=t.D,this.O=t.O,this.q=t.q,this.V=t.V,this.W=t.W,this}it(){const t=[];for(let i=this;i;i=i.parent)t.push(i);return t}command(t,i,s){let e=i,n=s;"object"==typeof e&&null!==e&&(n=e,e=null),n=n||{};const[,r,o]=t.match(/([^ ]+) *(.*)/),h=this.createCommand(r);return e&&(h.description(e),h.H=!0),n.isDefault&&(this.M=h.i),h.h=!(!n.noHelp&&!n.hidden),h.I=n.executableFile||null,o&&h.arguments(o),this.st(h),h.parent=this,h.copyInheritedSettings(this),e?this:h}createCommand(i){return new t(i)}createHelp(){return Object.assign(new u,this.configureHelp())}configureHelp(t){return void 0===t?this.X:(this.X=t,this)}configureOutput(t){return void 0===t?this.L:(this.L=Object.assign({},this.L,t),this)}showHelpAfterError(t=!0){return"string"!=typeof t&&(t=!!t),this.V=t,this}showSuggestionAfterError(t=!0){return this.W=!!t,this}addCommand(t,i){if(!t.i)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(i=i||{}).isDefault&&(this.M=t.i),(i.noHelp||i.hidden)&&(t.h=!0),this.st(t),t.parent=this,t.et(),this}createArgument(t,i){return new o(t,i)}argument(t,i,s,e){const n=this.createArgument(t,i);return"function"==typeof s?n.default(e).argParser(s):n.default(s),this.addArgument(n),this}arguments(t){return t.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(t){const i=this.registeredArguments.slice(-1)[0];if(i&&i.variadic)throw new Error(`only the last argument can be variadic '${i.name()}'`);if(t.required&&void 0!==t.defaultValue&&void 0===t.parseArg)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,i){if("boolean"==typeof t)return this.B=t,t&&this.Z&&this.nt(this.u()),this;const s=t??"help [command]",[,e,n]=s.match(/([^ ]+) *(.*)/),r=i??"display help for command",o=this.createCommand(e);return o.helpOption(!1),n&&o.arguments(n),r&&o.description(r),this.B=!0,this.K=o,(t||i)&&this.nt(o),this}addHelpCommand(t,i){return"object"!=typeof t?(this.helpCommand(t,i),this):(this.B=!0,this.K=t,this.nt(t),this)}u(){return this.B??(this.commands.length&&!this.j&&!this.rt("help"))?(void 0===this.K&&this.helpCommand(void 0,void 0),this.K):null}hook(t,i){const s=["preSubcommand","preAction","postAction"];if(!s.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${s.join("', '")}'`);return this.U[t]?this.U[t].push(i):this.U[t]=[i],this}exitOverride(t){return this.N=t||(t=>{if("commander.executeSubCommandAsync"!==t.code)throw t}),this}ot(t,i,s){this.N&&this.N(new a(t,i,s)),r.exit(t)}action(t){return this.j=i=>{const s=this.registeredArguments.length,e=i.slice(0,s);return this.k?e[s]=this:e[s]=this.opts(),e.push(this),t.apply(this,e)},this}createOption(t,i){return new l(t,i)}ht(t,i,s,e){try{return t.parseArg(i,s)}catch(t){if("commander.invalidArgument"===t.code){const i=`${e} ${t.message}`;this.error(i,{exitCode:t.exitCode,code:t.code})}throw t}}ut(t){const i=t.short&&this.m(t.short)||t.long&&this.m(t.long);if(i){const s=t.long&&this.m(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this.i&&` to command '${this.i}'`} due to conflicting flag '${s}'\n- already used by option '${i.flags}'`)}this.ct(t),this.options.push(t)}st(t){const i=t=>[t.name()].concat(t.aliases()),s=i(t).find(t=>this.rt(t));if(s){const e=i(this.rt(s)).join("|"),n=i(t).join("|");throw new Error(`cannot add command '${n}' as already have command '${e}'`)}this.nt(t),this.commands.push(t)}addOption(t){this.ut(t);const i=t.name(),s=t.attributeName();if(t.negate){const i=t.long.replace(/^--no-/,"--");this.m(i)||this.setOptionValueWithSource(s,void 0===t.defaultValue||t.defaultValue,"default")}else void 0!==t.defaultValue&&this.setOptionValueWithSource(s,t.defaultValue,"default");const e=(i,e,n)=>{null==i&&void 0!==t.presetArg&&(i=t.presetArg);const r=this.getOptionValue(s);null!==i&&t.parseArg?i=this.ht(t,i,r,e):null!==i&&t.variadic&&(i=t.o(i,r)),null==i&&(i=!t.negate&&(!(!t.isBoolean()&&!t.optional)||"")),this.setOptionValueWithSource(s,i,n)};return this.on("option:"+i,i=>{const s=`error: option '${t.flags}' argument '${i}' is invalid.`;e(i,s,"cli")}),t.envVar&&this.on("optionEnv:"+i,i=>{const s=`error: option '${t.flags}' value '${i}' from env '${t.envVar}' is invalid.`;e(i,s,"env")}),this}lt(t,i,s,e,n){if("object"==typeof i&&i instanceof l)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const r=this.createOption(i,s);if(r.makeOptionMandatory(!!t.mandatory),"function"==typeof e)r.default(n).argParser(e);else if(e instanceof RegExp){const t=e;e=(i,s)=>{const e=t.exec(i);return e?e[0]:s},r.default(n).argParser(e)}else r.default(e);return this.addOption(r)}option(t,i,s,e){return this.lt({},t,i,s,e)}requiredOption(t,i,s,e){return this.lt({mandatory:!0},t,i,s,e)}combineFlagAndOptionalValue(t=!0){return this.D=!!t,this}allowUnknownOption(t=!0){return this.$=!!t,this}allowExcessArguments(t=!0){return this.O=!!t,this}enablePositionalOptions(t=!0){return this.q=!!t,this}passThroughOptions(t=!0){return this.F=!!t,this.et(),this}et(){if(this.parent&&this.F&&!this.parent.q)throw new Error(`passThroughOptions cannot be used for '${this.i}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this.k=!!t,this}getOptionValue(t){return this.k?this[t]:this._[t]}setOptionValue(t,i){return this.setOptionValueWithSource(t,i,void 0)}setOptionValueWithSource(t,i,s){return this.k?this[t]=i:this._[t]=i,this.S[t]=s,this}getOptionValueSource(t){return this.S[t]}getOptionValueSourceWithGlobals(t){let i;return this.it().forEach(s=>{void 0!==s.getOptionValueSource(t)&&(i=s.getOptionValueSource(t))}),i}dt(t,i){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(i=i||{},void 0===t&&void 0===i.from){r.versions?.electron&&(i.from="electron");const t=r.execArgv??[];(t.includes("-e")||t.includes("--eval")||t.includes("-p")||t.includes("--print"))&&(i.from="eval")}let s;switch(void 0===t&&(t=r.argv),this.rawArgs=t.slice(),i.from){case void 0:case"node":this.A=t[1],s=t.slice(2);break;case"electron":r.defaultApp?(this.A=t[1],s=t.slice(2)):s=t.slice(1);break;case"user":s=t.slice(0);break;case"eval":s=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${i.from}' }`)}return!this.i&&this.A&&this.nameFromFilename(this.A),this.i=this.i||"program",s}parse(t,i){this.ft();const s=this.dt(t,i);return this.gt([],s),this}async parseAsync(t,i){this.ft();const s=this.dt(t,i);return await this.gt([],s),this}ft(){null===this.J?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this.J={i:this.i,_:{...this._},S:{...this.S}}}restoreStateBeforeParse(){if(this.k)throw new Error("Can not call parse again when storeOptionsAsProperties is true.\n- either make a new Command for each call to parse, or stop storing options as properties");this.i=this.J.i,this.A=null,this.rawArgs=[],this._={...this.J._},this.S={...this.J.S},this.args=[],this.processedArgs=[]}vt(t,i,s){if(!n.existsSync(t))throw new Error(`'${t}' does not exist\n - if '${s}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${i?`searched for local subcommand relative to directory '${i}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory"}`)}$t(t,i){i=i.slice();let o=!1;const h=[".js",".ts",".tsx",".mjs",".cjs"];function u(t,i){const s=e.resolve(t,i);if(n.existsSync(s))return s;if(h.includes(e.extname(i)))return;const r=h.find(t=>n.existsSync(`${s}${t}`));return r?`${s}${r}`:void 0}this.wt(),this.bt();let c,l=t.I||`${this.i}-${t.i}`,d=this.T||"";if(this.A){let t;try{t=n.realpathSync(this.A)}catch{t=this.A}d=e.resolve(e.dirname(t),d)}if(d){let i=u(d,l);if(!i&&!t.I&&this.A){const s=e.basename(this.A,e.extname(this.A));s!==this.i&&(i=u(d,`${s}-${t.i}`))}l=i||l}o=h.includes(e.extname(l)),"win32"!==r.platform?o?(i.unshift(l),i=p(r.execArgv).concat(i),c=s.spawn(r.argv[0],i,{stdio:"inherit"})):c=s.spawn(l,i,{stdio:"inherit"}):(this.vt(l,d,t.i),i.unshift(l),i=p(r.execArgv).concat(i),c=s.spawn(r.execPath,i,{stdio:"inherit"})),c.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(t=>{r.on(t,()=>{!1===c.killed&&null===c.exitCode&&c.kill(t)})});const m=this.N;c.on("close",t=>{t=t??1,m?m(new a(t,"commander.executeSubCommandAsync","(close)")):r.exit(t)}),c.on("error",i=>{if("ENOENT"===i.code)this.vt(l,d,t.i);else if("EACCES"===i.code)throw new Error(`'${l}' not executable`);if(m){const t=new a(1,"commander.executeSubCommandAsync","(error)");t.nestedError=i,m(t)}else r.exit(1)}),this.runningCommand=c}yt(t,i,s){const e=this.rt(t);let n;return e||this.help({error:!0}),e.ft(),n=this.Ot(n,e,"preSubcommand"),n=this.Ct(n,()=>{if(!e.H)return e.gt(i,s);this.$t(e,i.concat(s))}),n}At(t){t||this.help();const i=this.rt(t);return i&&!i.H&&i.help(),this.yt(t,[],[this.l()?.long??this.l()?.short??"--help"])}Et(){this.registeredArguments.forEach((t,i)=>{t.required&&null==this.args[i]&&this.missingArgument(t.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._t(this.args)}xt(){const t=(t,i,s)=>{let e=i;if(null!==i&&t.parseArg){const n=`error: command-argument value '${i}' is invalid for argument '${t.name()}'.`;e=this.ht(t,i,s,n)}return e};this.Et();const i=[];this.registeredArguments.forEach((s,e)=>{let n=s.defaultValue;s.variadic?e<this.args.length?(n=this.args.slice(e),s.parseArg&&(n=n.reduce((i,e)=>t(s,e,i),s.defaultValue))):void 0===n&&(n=[]):e<this.args.length&&(n=this.args[e],s.parseArg&&(n=t(s,n,s.defaultValue))),i[e]=n}),this.processedArgs=i}Ct(t,i){return t&&t.then&&"function"==typeof t.then?t.then(()=>i()):i()}St(t,i){let s=t;const e=[];return this.it().reverse().filter(t=>void 0!==t.U[i]).forEach(t=>{t.U[i].forEach(i=>{e.push({hookedCommand:t,callback:i})})}),"postAction"===i&&e.reverse(),e.forEach(t=>{s=this.Ct(s,()=>t.callback(t.hookedCommand,this))}),s}Ot(t,i,s){let e=t;return void 0!==this.U[s]&&this.U[s].forEach(t=>{e=this.Ct(e,()=>t(this,i))}),e}gt(t,i){const s=this.parseOptions(i);if(this.kt(),this.jt(),t=t.concat(s.operands),i=s.unknown,this.args=t.concat(i),t&&this.rt(t[0]))return this.yt(t[0],t.slice(1),i);if(this.u()&&t[0]===this.u().name())return this.At(t[1]);if(this.M)return this.Ht(i),this.yt(this.M,t,i);!this.commands.length||0!==this.args.length||this.j||this.M||this.help({error:!0}),this.Ht(s.unknown),this.wt(),this.bt();const e=()=>{s.unknown.length>0&&this.unknownOption(s.unknown[0])},n=`command:${this.name()}`;if(this.j){let s;return e(),this.xt(),s=this.St(s,"preAction"),s=this.Ct(s,()=>this.j(this.processedArgs)),this.parent&&(s=this.Ct(s,()=>{this.parent.emit(n,t,i)})),s=this.St(s,"postAction"),s}if(this.parent&&this.parent.listenerCount(n))e(),this.xt(),this.parent.emit(n,t,i);else if(t.length){if(this.rt("*"))return this.yt("*",t,i);this.listenerCount("command:*")?this.emit("command:*",t,i):this.commands.length?this.unknownCommand():(e(),this.xt())}else this.commands.length?(e(),this.help({error:!0})):(e(),this.xt())}rt(t){if(t)return this.commands.find(i=>i.i===t||i.v.includes(t))}m(t){return this.options.find(i=>i.is(t))}wt(){this.it().forEach(t=>{t.options.forEach(i=>{i.mandatory&&void 0===t.getOptionValue(i.attributeName())&&t.missingMandatoryOptionValue(i)})})}It(){const t=this.options.filter(t=>{const i=t.attributeName();return void 0!==this.getOptionValue(i)&&"default"!==this.getOptionValueSource(i)});t.filter(t=>t.conflictsWith.length>0).forEach(i=>{const s=t.find(t=>i.conflictsWith.includes(t.attributeName()));s&&this.Tt(i,s)})}bt(){this.it().forEach(t=>{t.It()})}parseOptions(t){const i=[],s=[];let e=i;const n=t.slice();function r(t){return t.length>1&&"-"===t[0]}const o=t=>!!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(t)&&!this.it().some(t=>t.options.map(t=>t.short).some(t=>/^-\d$/.test(t)));let h=null;for(;n.length;){const t=n.shift();if("--"===t){e===s&&e.push(t),e.push(...n);break}if(!h||r(t)&&!o(t)){if(h=null,r(t)){const i=this.m(t);if(i){if(i.required){const t=n.shift();void 0===t&&this.optionMissingArgument(i),this.emit(`option:${i.name()}`,t)}else if(i.optional){let t=null;n.length>0&&(!r(n[0])||o(n[0]))&&(t=n.shift()),this.emit(`option:${i.name()}`,t)}else this.emit(`option:${i.name()}`);h=i.variadic?i:null;continue}}if(t.length>2&&"-"===t[0]&&"-"!==t[1]){const i=this.m(`-${t[1]}`);if(i){i.required||i.optional&&this.D?this.emit(`option:${i.name()}`,t.slice(2)):(this.emit(`option:${i.name()}`),n.unshift(`-${t.slice(2)}`));continue}}if(/^--[^=]+=/.test(t)){const i=t.indexOf("="),s=this.m(t.slice(0,i));if(s&&(s.required||s.optional)){this.emit(`option:${s.name()}`,t.slice(i+1));continue}}if(e!==i||!r(t)||0===this.commands.length&&o(t)||(e=s),(this.q||this.F)&&0===i.length&&0===s.length){if(this.rt(t)){i.push(t),n.length>0&&s.push(...n);break}if(this.u()&&t===this.u().name()){i.push(t),n.length>0&&i.push(...n);break}if(this.M){s.push(t),n.length>0&&s.push(...n);break}}if(this.F){e.push(t),n.length>0&&e.push(...n);break}e.push(t)}else this.emit(`option:${h.name()}`,t)}return{operands:i,unknown:s}}opts(){if(this.k){const t={},i=this.options.length;for(let s=0;s<i;s++){const i=this.options[s].attributeName();t[i]=i===this.Mt?this.Nt:this[i]}return t}return this._}optsWithGlobals(){return this.it().reduce((t,i)=>Object.assign(t,i.opts()),{})}error(t,i){this.L.outputError(`${t}\n`,this.L.writeErr),"string"==typeof this.V?this.L.writeErr(`${this.V}\n`):this.V&&(this.L.writeErr("\n"),this.outputHelp({error:!0}));const s=i||{},e=s.exitCode||1,n=s.code||"commander.error";this.ot(e,n,t)}kt(){this.options.forEach(t=>{if(t.envVar&&t.envVar in r.env){const i=t.attributeName();(void 0===this.getOptionValue(i)||["default","config","env"].includes(this.getOptionValueSource(i)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,r.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}jt(){const t=new d(this.options),i=t=>void 0!==this.getOptionValue(t)&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter(s=>void 0!==s.implied&&i(s.attributeName())&&t.valueFromOption(this.getOptionValue(s.attributeName()),s)).forEach(t=>{Object.keys(t.implied).filter(t=>!i(t)).forEach(i=>{this.setOptionValueWithSource(i,t.implied[i],"implied")})})}missingArgument(t){const i=`error: missing required argument '${t}'`;this.error(i,{code:"commander.missingArgument"})}optionMissingArgument(t){const i=`error: option '${t.flags}' argument missing`;this.error(i,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const i=`error: required option '${t.flags}' not specified`;this.error(i,{code:"commander.missingMandatoryOptionValue"})}Tt(t,i){const s=t=>{const i=t.attributeName(),s=this.getOptionValue(i),e=this.options.find(t=>t.negate&&i===t.attributeName()),n=this.options.find(t=>!t.negate&&i===t.attributeName());return e&&(void 0===e.presetArg&&!1===s||void 0!==e.presetArg&&s===e.presetArg)?e:n||t},e=t=>{const i=s(t),e=i.attributeName();return"env"===this.getOptionValueSource(e)?`environment variable '${i.envVar}'`:`option '${i.flags}'`},n=`error: ${e(t)} cannot be used with ${e(i)}`;this.error(n,{code:"commander.conflictingOption"})}unknownOption(t){if(this.$)return;let i="";if(t.startsWith("--")&&this.W){let s=[],e=this;do{const t=e.createHelp().visibleOptions(e).filter(t=>t.long).map(t=>t.long);s=s.concat(t),e=e.parent}while(e&&!e.q);i=m(t,s)}const s=`error: unknown option '${t}'${i}`;this.error(s,{code:"commander.unknownOption"})}_t(t){if(this.O)return;const i=this.registeredArguments.length,s=1===i?"":"s",e=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${i} argument${s} but got ${t.length}.`;this.error(e,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let i="";if(this.W){const s=[];this.createHelp().visibleCommands(this).forEach(t=>{s.push(t.name()),t.alias()&&s.push(t.alias())}),i=m(t,s)}const s=`error: unknown command '${t}'${i}`;this.error(s,{code:"commander.unknownCommand"})}version(t,i,s){if(void 0===t)return this.Nt;this.Nt=t,i=i||"-V, --version",s=s||"output the version number";const e=this.createOption(i,s);return this.Mt=e.attributeName(),this.ut(e),this.on("option:"+e.name(),()=>{this.L.writeOut(`${t}\n`),this.ot(0,"commander.version",t)}),this}description(t,i){return void 0===t&&void 0===i?this.P:(this.P=t,i&&(this.p=i),this)}summary(t){return void 0===t?this.G:(this.G=t,this)}alias(t){if(void 0===t)return this.v[0];let i=this;if(0!==this.commands.length&&this.commands[this.commands.length-1].H&&(i=this.commands[this.commands.length-1]),t===i.i)throw new Error("Command alias can't be the same as its name");const s=this.parent?.rt(t);if(s){const i=[s.name()].concat(s.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${i}'`)}return i.v.push(t),this}aliases(t){return void 0===t?this.v:(t.forEach(t=>this.alias(t)),this)}usage(t){if(void 0===t){if(this.Dt)return this.Dt;const t=this.registeredArguments.map(t=>h(t));return[].concat(this.options.length||null!==this.R?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this.Dt=t,this}name(t){return void 0===t?this.i:(this.i=t,this)}helpGroup(t){return void 0===t?this.Y??"":(this.Y=t,this)}commandsGroup(t){return void 0===t?this.Z??"":(this.Z=t,this)}optionsGroup(t){return void 0===t?this.tt??"":(this.tt=t,this)}ct(t){this.tt&&!t.helpGroupHeading&&t.helpGroup(this.tt)}nt(t){this.Z&&!t.helpGroup()&&t.helpGroup(this.Z)}nameFromFilename(t){return this.i=e.basename(t,e.extname(t)),this}executableDir(t){return void 0===t?this.T:(this.T=t,this)}helpInformation(t){const i=this.createHelp(),s=this.Pt(t);i.prepareContext({error:s.error,helpWidth:s.helpWidth,outputHasColors:s.hasColors});const e=i.formatHelp(this,i);return s.hasColors?e:this.L.stripColor(e)}Pt(t){const i=!!(t=t||{}).error;let s,e,n;return i?(s=t=>this.L.writeErr(t),e=this.L.getErrHasColors(),n=this.L.getErrHelpWidth()):(s=t=>this.L.writeOut(t),e=this.L.getOutHasColors(),n=this.L.getOutHelpWidth()),{error:i,write:t=>(e||(t=this.L.stripColor(t)),s(t)),hasColors:e,helpWidth:n}}outputHelp(t){let i;"function"==typeof t&&(i=t,t=void 0);const s=this.Pt(t),e={error:s.error,write:s.write,command:this};this.it().reverse().forEach(t=>t.emit("beforeAllHelp",e)),this.emit("beforeHelp",e);let n=this.helpInformation({error:s.error});if(i&&(n=i(n),"string"!=typeof n&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");s.write(n),this.l()?.long&&this.emit(this.l().long),this.emit("afterHelp",e),this.it().forEach(t=>t.emit("afterAllHelp",e))}helpOption(t,i){return"boolean"==typeof t?(t?(null===this.R&&(this.R=void 0),this.tt&&this.ct(this.l())):this.R=null,this):(this.R=this.createOption(t??"-h, --help",i??"display help for command"),(t||i)&&this.ct(this.R),this)}l(){return void 0===this.R&&this.helpOption(void 0,void 0),this.R}addHelpOption(t){return this.R=t,this.ct(t),this}help(t){this.outputHelp(t);let i=Number(r.exitCode??0);0===i&&t&&"function"!=typeof t&&t.error&&(i=1),this.ot(i,"commander.help","(outputHelp)")}addHelpText(t,i){const s=["beforeAll","before","after","afterAll"];if(!s.includes(t))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${s.join("', '")}'`);const e=`${t}Help`;return this.on(e,t=>{let s;s="function"==typeof i?i({error:t.error,command:t.command}):i,s&&t.write(`${s}\n`)}),this}Ht(t){const i=this.l();i&&t.find(t=>i.is(t))&&(this.outputHelp(),this.ot(0,"commander.helpDisplayed","(outputHelp)"))}},t.useColor=g}}),C=(r=null!=(n=g({"../../node_modules/.pnpm/commander@14.0.0/node_modules/commander/index.js"(t){var{Argument:i}=$(),{Command:s}=O(),{CommanderError:e,InvalidArgumentError:n}=v(),{Help:r}=w(),{Option:o}=b();t.program=new s,t.createCommand=t=>new s(t),t.createOption=(t,i)=>new o(t,i),t.createArgument=(t,s)=>new i(t,s),t.Command=s,t.Option=o,t.Argument=i,t.Help=r,t.CommanderError=e,t.InvalidArgumentError=n,t.InvalidOptionArgumentError=n}})())?u(m(n)):{},((t,i,s,e)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let s of d(i))p.call(t,s)||undefined===s||c(t,s,{get:()=>i[s],enumerable:!(e=l(i,s))||e.enumerable});return t})(c(r,"default",{value:n,enumerable:!0}),n)),{program:A,createCommand:E,createArgument:_,createOption:x,CommanderError:S,InvalidArgumentError:k,InvalidOptionArgumentError:j,Command:H,Argument:I,Option:T,Help:M}=C.default,N=class{prefix;constructor(t="CLI"){this.prefix=t}info(t){console.log(`[${this.prefix}] ℹ️ ${t}`)}success(t){console.log(`[${this.prefix}] ✅ ${t}`)}error(t){console.error(`[${this.prefix}] ❌ ${t}`)}warn(t){console.warn(`[${this.prefix}] ⚠️ ${t}`)}debug(t){process.env.DEBUG&&console.log(`[${this.prefix}] 🐛 ${t}`)}},D=new N("Greet"),P=new H("greet").description("Greet a user").argument("[name]","Name to greet","World").option("-u, --uppercase","Convert to uppercase").option("-e, --excited","Add excitement").action((t,i)=>{let s=`Hello, ${e=t,e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}`;var e;i.uppercase&&(s=s.toUpperCase()),i.excited?s+="!!!":s+="!",D.success(s)}),G=new N("Info"),q=new H("info").description("Display system information").option("-v, --verbose","Show verbose output").action(t=>{if(G.info("System Information:"),console.log("-------------------"),console.log(`📅 Date: ${function(t=new Date){return t.toISOString().split("T")[0]}()}`),console.log(`💻 Platform: ${o.platform()}`),console.log(`🏗️ Architecture: ${o.arch()}`),console.log(`🧮 CPUs: ${o.cpus().length}`),console.log(`💾 Memory: ${Math.round(o.totalmem()/1024/1024/1024)} GB`),console.log(`📁 Home Directory: ${o.homedir()}`),t.verbose){console.log("\nDetailed CPU Information:"),o.cpus().forEach((t,i)=>{console.log(` CPU ${i}: ${t.model} @ ${t.speed} MHz`)}),console.log("\nNetwork Interfaces:");const t=o.networkInterfaces();Object.keys(t).forEach(i=>{const s=t[i];s&&s.forEach(t=>{"IPv4"!==t.family||t.internal||console.log(` ${i}: ${t.address}`)})})}G.success("Information displayed successfully!")}),F=new N("Config"),U=a.join(o.homedir(),".command-code-config.json");async function V(){try{return function(t){try{return JSON.parse(t)}catch{return null}}(await h.readFile(U,"utf-8"))||{}}catch{return{}}}async function W(t){await h.writeFile(U,JSON.stringify(t,null,2))}var J=new H("config").description("Manage CLI configuration").addCommand(new H("get").description("Get a configuration value").argument("<key>","Configuration key").action(async t=>{const i=(await V())[t];void 0!==i?F.info(`${t}: ${JSON.stringify(i)}`):F.warn(`Key "${t}" not found in configuration`)})).addCommand(new H("set").description("Set a configuration value").argument("<key>","Configuration key").argument("<value>","Configuration value").action(async(t,i)=>{const s=await V();let e=i;"true"===i?e=!0:"false"===i?e=!1:isNaN(Number(i))||(e=Number(i)),s[t]=e,await W(s),F.success(`Set ${t} = ${JSON.stringify(e)}`)})).addCommand(new H("list").description("List all configuration values").action(async()=>{const t=await V();0===Object.keys(t).length?F.info("No configuration values set"):(F.info("Current configuration:"),Object.entries(t).forEach(([t,i])=>{console.log(` ${t}: ${JSON.stringify(i)}`)}))})).addCommand(new H("reset").description("Reset all configuration").action(async()=>{await W({}),F.success("Configuration reset successfully")})),L=new N("CommandCode"),R=new H;R.name("command-code").description("A TypeScript CLI with Commander.js").version("1.0.0"),R.addCommand(P),R.addCommand(q),R.addCommand(J),R.hook("preAction",()=>{L.debug("Command starting...")}),R.hook("postAction",()=>{L.debug("Command completed.")}),R.parse();
|
package/package.json
CHANGED
|
@@ -1,30 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "command-code",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/index.
|
|
6
|
-
"type": "module",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Command Code CLI",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
7
6
|
"bin": {
|
|
8
|
-
"command-code": "
|
|
9
|
-
"cmd": "
|
|
10
|
-
"cmnd": "
|
|
7
|
+
"command-code": "dist/index.cjs",
|
|
8
|
+
"cmd": "dist/index.cjs",
|
|
9
|
+
"cmnd": "dist/index.cjs"
|
|
11
10
|
},
|
|
12
11
|
"scripts": {
|
|
13
|
-
"build": "
|
|
12
|
+
"build": "tsup",
|
|
13
|
+
"build:obfuscated": "tsup --config tsup.config.obfuscated.ts",
|
|
14
|
+
"build:balanced": "tsup --config tsup.config.balanced.ts",
|
|
15
|
+
"build:bun": "bun run build.bun.js",
|
|
16
|
+
"build:bun:exe": "bun build ./src/index.ts --compile --outfile dist/command-code",
|
|
17
|
+
"build:pkg": "pnpm build && pkg dist/index.cjs -t node18-macos-x64,node18-linux-x64,node18-win-x64 --out-path dist/binaries",
|
|
14
18
|
"dev": "tsx src/index.ts",
|
|
15
19
|
"typecheck": "tsc --noEmit",
|
|
16
|
-
"start": "node dist/index.js"
|
|
20
|
+
"start": "node dist/index.js",
|
|
21
|
+
"prepublishOnly": "pnpm run build",
|
|
22
|
+
"publish:prod": "pnpm run build && npm publish --access public"
|
|
17
23
|
},
|
|
18
24
|
"keywords": [],
|
|
19
25
|
"author": "Ahmad Awais <me@AhmadAwais.com> (https://twitter.com/MrAhmadAwais)",
|
|
26
|
+
"private": false,
|
|
20
27
|
"license": "UNLICENSED",
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
21
34
|
"packageManager": "pnpm@10.8.1",
|
|
22
35
|
"dependencies": {
|
|
23
|
-
"@command-code/shared": "workspace:^",
|
|
24
36
|
"commander": "^14.0.0"
|
|
25
37
|
},
|
|
26
38
|
"devDependencies": {
|
|
27
39
|
"@types/node": "^24.2.0",
|
|
40
|
+
"javascript-obfuscator": "^4.1.1",
|
|
41
|
+
"pkg": "^5.8.1",
|
|
42
|
+
"rollup-plugin-obfuscator": "^1.1.0",
|
|
43
|
+
"terser": "^5.43.1",
|
|
44
|
+
"tsup": "^8.5.0",
|
|
28
45
|
"tsx": "^4.20.3"
|
|
29
46
|
}
|
|
30
47
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0BpC,eAAO,MAAM,aAAa,SA2DvB,CAAC"}
|
package/dist/commands/config.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { Logger, parseJSON } from '@command-code/shared';
|
|
3
|
-
import * as fs from 'fs/promises';
|
|
4
|
-
import * as path from 'path';
|
|
5
|
-
import * as os from 'os';
|
|
6
|
-
const logger = new Logger('Config');
|
|
7
|
-
const configPath = path.join(os.homedir(), '.command-code-config.json');
|
|
8
|
-
async function loadConfig() {
|
|
9
|
-
try {
|
|
10
|
-
const data = await fs.readFile(configPath, 'utf-8');
|
|
11
|
-
return parseJSON(data) || {};
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return {};
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
async function saveConfig(config) {
|
|
18
|
-
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
|
19
|
-
}
|
|
20
|
-
export const configCommand = new Command('config')
|
|
21
|
-
.description('Manage CLI configuration')
|
|
22
|
-
.addCommand(new Command('get')
|
|
23
|
-
.description('Get a configuration value')
|
|
24
|
-
.argument('<key>', 'Configuration key')
|
|
25
|
-
.action(async (key) => {
|
|
26
|
-
const config = await loadConfig();
|
|
27
|
-
const value = config[key];
|
|
28
|
-
if (value !== undefined) {
|
|
29
|
-
logger.info(`${key}: ${JSON.stringify(value)}`);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
logger.warn(`Key "${key}" not found in configuration`);
|
|
33
|
-
}
|
|
34
|
-
}))
|
|
35
|
-
.addCommand(new Command('set')
|
|
36
|
-
.description('Set a configuration value')
|
|
37
|
-
.argument('<key>', 'Configuration key')
|
|
38
|
-
.argument('<value>', 'Configuration value')
|
|
39
|
-
.action(async (key, value) => {
|
|
40
|
-
const config = await loadConfig();
|
|
41
|
-
let parsedValue = value;
|
|
42
|
-
if (value === 'true')
|
|
43
|
-
parsedValue = true;
|
|
44
|
-
else if (value === 'false')
|
|
45
|
-
parsedValue = false;
|
|
46
|
-
else if (!isNaN(Number(value)))
|
|
47
|
-
parsedValue = Number(value);
|
|
48
|
-
config[key] = parsedValue;
|
|
49
|
-
await saveConfig(config);
|
|
50
|
-
logger.success(`Set ${key} = ${JSON.stringify(parsedValue)}`);
|
|
51
|
-
}))
|
|
52
|
-
.addCommand(new Command('list')
|
|
53
|
-
.description('List all configuration values')
|
|
54
|
-
.action(async () => {
|
|
55
|
-
const config = await loadConfig();
|
|
56
|
-
if (Object.keys(config).length === 0) {
|
|
57
|
-
logger.info('No configuration values set');
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
logger.info('Current configuration:');
|
|
61
|
-
Object.entries(config).forEach(([key, value]) => {
|
|
62
|
-
console.log(` ${key}: ${JSON.stringify(value)}`);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}))
|
|
66
|
-
.addCommand(new Command('reset')
|
|
67
|
-
.description('Reset all configuration')
|
|
68
|
-
.action(async () => {
|
|
69
|
-
await saveConfig({});
|
|
70
|
-
logger.success('Configuration reset successfully');
|
|
71
|
-
}));
|
|
72
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"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"}
|
package/dist/commands/greet.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"greet.d.ts","sourceRoot":"","sources":["../../src/commands/greet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,YAAY,SAmBrB,CAAC"}
|
package/dist/commands/greet.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { Logger, capitalize } from '@command-code/shared';
|
|
3
|
-
const logger = new Logger('Greet');
|
|
4
|
-
export const greetCommand = new Command('greet')
|
|
5
|
-
.description('Greet a user')
|
|
6
|
-
.argument('[name]', 'Name to greet', 'World')
|
|
7
|
-
.option('-u, --uppercase', 'Convert to uppercase')
|
|
8
|
-
.option('-e, --excited', 'Add excitement')
|
|
9
|
-
.action((name, options) => {
|
|
10
|
-
let greeting = `Hello, ${capitalize(name)}`;
|
|
11
|
-
if (options.uppercase) {
|
|
12
|
-
greeting = greeting.toUpperCase();
|
|
13
|
-
}
|
|
14
|
-
if (options.excited) {
|
|
15
|
-
greeting += '!!!';
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
greeting += '!';
|
|
19
|
-
}
|
|
20
|
-
logger.success(greeting);
|
|
21
|
-
});
|
|
22
|
-
//# sourceMappingURL=greet.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"greet.js","sourceRoot":"","sources":["../../src/commands/greet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KAC7C,WAAW,CAAC,cAAc,CAAC;KAC3B,QAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,CAAC;KAC5C,MAAM,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;KACjD,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC;KACzC,MAAM,CAAC,CAAC,IAAY,EAAE,OAAmD,EAAE,EAAE;IAC5E,IAAI,QAAQ,GAAG,UAAU,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;IAE5C,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACpC,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,QAAQ,IAAI,KAAK,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,QAAQ,IAAI,GAAG,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC"}
|
package/dist/commands/info.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../src/commands/info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,eAAO,MAAM,WAAW,SAkCpB,CAAC"}
|
package/dist/commands/info.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { Logger, formatDate } from '@command-code/shared';
|
|
3
|
-
import * as os from 'os';
|
|
4
|
-
const logger = new Logger('Info');
|
|
5
|
-
export const infoCommand = new Command('info')
|
|
6
|
-
.description('Display system information')
|
|
7
|
-
.option('-v, --verbose', 'Show verbose output')
|
|
8
|
-
.action((options) => {
|
|
9
|
-
logger.info('System Information:');
|
|
10
|
-
console.log('-------------------');
|
|
11
|
-
console.log(`📅 Date: ${formatDate()}`);
|
|
12
|
-
console.log(`💻 Platform: ${os.platform()}`);
|
|
13
|
-
console.log(`🏗️ Architecture: ${os.arch()}`);
|
|
14
|
-
console.log(`🧮 CPUs: ${os.cpus().length}`);
|
|
15
|
-
console.log(`💾 Memory: ${Math.round(os.totalmem() / 1024 / 1024 / 1024)} GB`);
|
|
16
|
-
console.log(`📁 Home Directory: ${os.homedir()}`);
|
|
17
|
-
if (options.verbose) {
|
|
18
|
-
console.log('\nDetailed CPU Information:');
|
|
19
|
-
os.cpus().forEach((cpu, index) => {
|
|
20
|
-
console.log(` CPU ${index}: ${cpu.model} @ ${cpu.speed} MHz`);
|
|
21
|
-
});
|
|
22
|
-
console.log('\nNetwork Interfaces:');
|
|
23
|
-
const networkInterfaces = os.networkInterfaces();
|
|
24
|
-
Object.keys(networkInterfaces).forEach((iface) => {
|
|
25
|
-
const addresses = networkInterfaces[iface];
|
|
26
|
-
if (addresses) {
|
|
27
|
-
addresses.forEach((addr) => {
|
|
28
|
-
if (addr.family === 'IPv4' && !addr.internal) {
|
|
29
|
-
console.log(` ${iface}: ${addr.address}`);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
logger.success('Information displayed successfully!');
|
|
36
|
-
});
|
|
37
|
-
//# sourceMappingURL=info.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../src/commands/info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,4BAA4B,CAAC;KACzC,MAAM,CAAC,eAAe,EAAE,qBAAqB,CAAC;KAC9C,MAAM,CAAC,CAAC,OAA8B,EAAE,EAAE;IACzC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,YAAY,UAAU,EAAE,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/E,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAElD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QAC3C,EAAE,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YAC/B,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,KAAK,GAAG,CAAC,KAAK,MAAM,GAAG,CAAC,KAAK,MAAM,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QACrC,MAAM,iBAAiB,GAAG,EAAE,CAAC,iBAAiB,EAAE,CAAC;QACjD,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC/C,MAAM,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC3C,IAAI,SAAS,EAAE,CAAC;gBACd,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;oBACzB,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;wBAC7C,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;oBAC7C,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACxD,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
import { Logger } from '@command-code/shared';
|
|
4
|
-
import { greetCommand } from './commands/greet.js';
|
|
5
|
-
import { infoCommand } from './commands/info.js';
|
|
6
|
-
import { configCommand } from './commands/config.js';
|
|
7
|
-
const logger = new Logger('CommandCode');
|
|
8
|
-
const program = new Command();
|
|
9
|
-
program
|
|
10
|
-
.name('command-code')
|
|
11
|
-
.description('A TypeScript CLI with Commander.js')
|
|
12
|
-
.version('1.0.0');
|
|
13
|
-
program.addCommand(greetCommand);
|
|
14
|
-
program.addCommand(infoCommand);
|
|
15
|
-
program.addCommand(configCommand);
|
|
16
|
-
program.hook('preAction', () => {
|
|
17
|
-
logger.debug('Command starting...');
|
|
18
|
-
});
|
|
19
|
-
program.hook('postAction', () => {
|
|
20
|
-
logger.debug('Command completed.');
|
|
21
|
-
});
|
|
22
|
-
program.parse();
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC;AACzC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,cAAc,CAAC;KACpB,WAAW,CAAC,oCAAoC,CAAC;KACjD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACjC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAElC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;IAC7B,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE;IAC9B,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/src/commands/config.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { Logger, parseJSON } from '@command-code/shared';
|
|
3
|
-
import * as fs from 'fs/promises';
|
|
4
|
-
import * as path from 'path';
|
|
5
|
-
import * as os from 'os';
|
|
6
|
-
|
|
7
|
-
const logger = new Logger('Config');
|
|
8
|
-
const configPath = path.join(os.homedir(), '.command-code-config.json');
|
|
9
|
-
|
|
10
|
-
interface Config {
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async function loadConfig(): Promise<Config> {
|
|
15
|
-
try {
|
|
16
|
-
const data = await fs.readFile(configPath, 'utf-8');
|
|
17
|
-
return parseJSON<Config>(data) || {};
|
|
18
|
-
} catch {
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function saveConfig(config: Config): Promise<void> {
|
|
24
|
-
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const configCommand = new Command('config')
|
|
28
|
-
.description('Manage CLI configuration')
|
|
29
|
-
.addCommand(
|
|
30
|
-
new Command('get')
|
|
31
|
-
.description('Get a configuration value')
|
|
32
|
-
.argument('<key>', 'Configuration key')
|
|
33
|
-
.action(async (key: string) => {
|
|
34
|
-
const config = await loadConfig();
|
|
35
|
-
const value = config[key];
|
|
36
|
-
|
|
37
|
-
if (value !== undefined) {
|
|
38
|
-
logger.info(`${key}: ${JSON.stringify(value)}`);
|
|
39
|
-
} else {
|
|
40
|
-
logger.warn(`Key "${key}" not found in configuration`);
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
)
|
|
44
|
-
.addCommand(
|
|
45
|
-
new Command('set')
|
|
46
|
-
.description('Set a configuration value')
|
|
47
|
-
.argument('<key>', 'Configuration key')
|
|
48
|
-
.argument('<value>', 'Configuration value')
|
|
49
|
-
.action(async (key: string, value: string) => {
|
|
50
|
-
const config = await loadConfig();
|
|
51
|
-
|
|
52
|
-
let parsedValue: any = value;
|
|
53
|
-
if (value === 'true') parsedValue = true;
|
|
54
|
-
else if (value === 'false') parsedValue = false;
|
|
55
|
-
else if (!isNaN(Number(value))) parsedValue = Number(value);
|
|
56
|
-
|
|
57
|
-
config[key] = parsedValue;
|
|
58
|
-
await saveConfig(config);
|
|
59
|
-
|
|
60
|
-
logger.success(`Set ${key} = ${JSON.stringify(parsedValue)}`);
|
|
61
|
-
})
|
|
62
|
-
)
|
|
63
|
-
.addCommand(
|
|
64
|
-
new Command('list').description('List all configuration values').action(async () => {
|
|
65
|
-
const config = await loadConfig();
|
|
66
|
-
|
|
67
|
-
if (Object.keys(config).length === 0) {
|
|
68
|
-
logger.info('No configuration values set');
|
|
69
|
-
} else {
|
|
70
|
-
logger.info('Current configuration:');
|
|
71
|
-
Object.entries(config).forEach(([key, value]) => {
|
|
72
|
-
console.log(` ${key}: ${JSON.stringify(value)}`);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
)
|
|
77
|
-
.addCommand(
|
|
78
|
-
new Command('reset').description('Reset all configuration').action(async () => {
|
|
79
|
-
await saveConfig({});
|
|
80
|
-
logger.success('Configuration reset successfully');
|
|
81
|
-
})
|
|
82
|
-
);
|
package/src/commands/greet.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { Logger, capitalize } from '@command-code/shared';
|
|
3
|
-
|
|
4
|
-
const logger = new Logger('Greet');
|
|
5
|
-
|
|
6
|
-
export const greetCommand = new Command('greet')
|
|
7
|
-
.description('Greet a user')
|
|
8
|
-
.argument('[name]', 'Name to greet', 'World')
|
|
9
|
-
.option('-u, --uppercase', 'Convert to uppercase')
|
|
10
|
-
.option('-e, --excited', 'Add excitement')
|
|
11
|
-
.action((name: string, options: { uppercase?: boolean; excited?: boolean }) => {
|
|
12
|
-
let greeting = `Hello, ${capitalize(name)}`;
|
|
13
|
-
|
|
14
|
-
if (options.uppercase) {
|
|
15
|
-
greeting = greeting.toUpperCase();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (options.excited) {
|
|
19
|
-
greeting += '!!!';
|
|
20
|
-
} else {
|
|
21
|
-
greeting += '!';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
logger.success(greeting);
|
|
25
|
-
});
|
package/src/commands/info.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { Logger, formatDate } from '@command-code/shared';
|
|
3
|
-
import * as os from 'os';
|
|
4
|
-
import * as path from 'path';
|
|
5
|
-
|
|
6
|
-
const logger = new Logger('Info');
|
|
7
|
-
|
|
8
|
-
export const infoCommand = new Command('info')
|
|
9
|
-
.description('Display system information')
|
|
10
|
-
.option('-v, --verbose', 'Show verbose output')
|
|
11
|
-
.action((options: { verbose?: boolean }) => {
|
|
12
|
-
logger.info('System Information:');
|
|
13
|
-
console.log('-------------------');
|
|
14
|
-
console.log(`📅 Date: ${formatDate()}`);
|
|
15
|
-
console.log(`💻 Platform: ${os.platform()}`);
|
|
16
|
-
console.log(`🏗️ Architecture: ${os.arch()}`);
|
|
17
|
-
console.log(`🧮 CPUs: ${os.cpus().length}`);
|
|
18
|
-
console.log(`💾 Memory: ${Math.round(os.totalmem() / 1024 / 1024 / 1024)} GB`);
|
|
19
|
-
console.log(`📁 Home Directory: ${os.homedir()}`);
|
|
20
|
-
|
|
21
|
-
if (options.verbose) {
|
|
22
|
-
console.log('\nDetailed CPU Information:');
|
|
23
|
-
os.cpus().forEach((cpu, index) => {
|
|
24
|
-
console.log(` CPU ${index}: ${cpu.model} @ ${cpu.speed} MHz`);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
console.log('\nNetwork Interfaces:');
|
|
28
|
-
const networkInterfaces = os.networkInterfaces();
|
|
29
|
-
Object.keys(networkInterfaces).forEach((iface) => {
|
|
30
|
-
const addresses = networkInterfaces[iface];
|
|
31
|
-
if (addresses) {
|
|
32
|
-
addresses.forEach((addr) => {
|
|
33
|
-
if (addr.family === 'IPv4' && !addr.internal) {
|
|
34
|
-
console.log(` ${iface}: ${addr.address}`);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
logger.success('Information displayed successfully!');
|
|
42
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import { Logger } from '@command-code/shared';
|
|
5
|
-
import { greetCommand } from './commands/greet.js';
|
|
6
|
-
import { infoCommand } from './commands/info.js';
|
|
7
|
-
import { configCommand } from './commands/config.js';
|
|
8
|
-
|
|
9
|
-
const logger = new Logger('CommandCode');
|
|
10
|
-
const program = new Command();
|
|
11
|
-
|
|
12
|
-
program.name('command-code').description('A TypeScript CLI with Commander.js').version('1.0.0');
|
|
13
|
-
|
|
14
|
-
program.addCommand(greetCommand);
|
|
15
|
-
program.addCommand(infoCommand);
|
|
16
|
-
program.addCommand(configCommand);
|
|
17
|
-
|
|
18
|
-
program.hook('preAction', () => {
|
|
19
|
-
logger.debug('Command starting...');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
program.hook('postAction', () => {
|
|
23
|
-
logger.debug('Command completed.');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
program.parse();
|
package/tsconfig.json
DELETED