@talos-org/cli 0.1.14 → 0.1.17

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/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import {Command}from'commander';var s=new Command("hello").description("Say hello to the user!").option("-n, --name <name>","Name to greet","World").action(e=>o(e));async function o(e){console.log(`Hello, ${e.name}`);}var t={version:"0.1.14"};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function a(){let e=new Command().name("talos").description("Manage everything.").version(t.version,"-v, --version","display the version number");e.addCommand(s),e.parse();}a();//# sourceMappingURL=index.js.map
2
+ import {Command}from'commander';import {select,input}from'@inquirer/prompts';import k from'cli-spinners';import {execa}from'execa';import {readFile}from'fs/promises';import $ from'ora';import F from'path';import a from'zod';import B from'os';var v=new Command("hello").description("Say hello to the user!").option("-n, --name <name>","Name to greet","World").action(n=>N(n));async function N(n){console.log(`Hello, ${n.name}`);}var b={version:"0.1.17"};var L=a.object({name:a.string(),options:a.array(a.string()),args:a.array(a.string()),action:a.string()}),R=a.object({version:a.string(),commands:a.array(L)}),w=a.object({name:a.string(),body:a.array(R)});var C=F.join(B.homedir(),"Documents","talos","commands");var A=new Command("e").description("Execute a command").argument("<name>","Name of the command").argument("[extras...]","Additional arguments and options").allowUnknownOption().passThroughOptions().action((n,r,i)=>q(n,i,r));async function q(n,r,i){let h=await select({message:"Where does Talos need to look for the command?",choices:[{name:"Local",value:"local"},{name:"Internet",value:"internet"}]});await U(n,h,{...r,extras:i});}async function U(n,r,i){r==="local"?await K(n,i):r==="internet"&&console.log(`Looking for ${n} on the internet...`);}async function K(n,r={}){let i=$({text:"Looking for command locally...",spinner:{frames:k.circleHalves.frames,interval:80}}).start();await new Promise(e=>setTimeout(e,1e3));let h=F.join(C,`${n}.json`),E=await readFile(h,"utf-8"),P=JSON.parse(E),m=w.parse(P);if(!m){i.fail("Command not found locally.");return}if(i.succeed("Command found locally."),m.body.length<=0){i.fail("No versions found for this command.");return}let l=m.body[0];m.body.length>1&&(l=await select({message:"Select a command version to execute:",choices:m.body.map(c=>({name:c.version,value:c}))})||l);let p=[],T=Array.isArray(r.extras)?r.extras:[],W=new Set(l.commands.flatMap(e=>e.options)),f=H(T,W),z=new Set(f.flags.map(e=>e.flag));for(let e of f.flags)p.push(e.flag),e.value!==null&&p.push(e.value);p.push(...f.unknownTokens),p.push(...f.positionals);for(let e of l.commands){let c=[],g=e.args.filter(o=>x(o)),d=e.args.filter(o=>!x(o));for(let o of g){let t=o.replace(/[\[\]<>]/g,"").trim()||"value",s=await input({message:`What argument are you gonna send? (${t})`});c.push(s);}c.unshift(...d);let u=[...p];if(e.options.length>0&&!e.options.some(t=>z.has(t))){let t=e.options[0],s=await input({message:`What do you want to use for "${t}" argument?`,default:""});s!==""&&u.push(t,s);}for(let o of l.commands){let t=$({text:`Executing command: ${o.name}...`,spinner:{frames:k.circleHalves.frames,interval:80}}).start();try{t.stop();let s=[...c,...u];console.log(`
3
+ $ ${o.action} ${s.join(" ")}
4
+ `),await execa(o.action,s,{stdio:"inherit"}),console.log(),t.succeed(`Executed command: ${o.name}`);}catch(s){t.fail(`Failed to execute command: ${o.name}`),s instanceof Error&&console.error(`Error: ${s.message}`);}}}function x(e){return /^<[^>]+>$/.test(e)||/^\[[^\]]+\]$/.test(e)}function H(e,c){let g=[],d=[],u=[];for(let o=0;o<e.length;o+=1){let t=e[o];if(t.startsWith("-")){let s=e[o+1],y=s!==void 0&&!s.startsWith("-"),I=y?s:null;c.has(t)?g.push({flag:t,value:I}):(d.push(t),y&&d.push(s)),y&&(o+=1);continue}u.push(t);}return {flags:g,unknownTokens:d,positionals:u}}}process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function X(){let n=new Command().name("talos").description("Manage everything.").version(b.version,"-v, --version","display the version number").enablePositionalOptions();n.addCommand(v),n.addCommand(A),n.parse();}X();//# sourceMappingURL=index.js.map
3
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/commands/hello.ts","../package.json","../src/index.ts"],"names":["helloCommand","Command","opts","helloHandler","options","package_default","main","program"],"mappings":";gCAEO,IAAMA,CAAAA,CAAe,IAAIC,OAAAA,CAAQ,OAAO,CAAA,CAC5C,WAAA,CAAY,wBAAwB,CAAA,CACpC,MAAA,CAAO,oBAAqB,eAAA,CAAiB,OAAO,CAAA,CACpD,MAAA,CAAQC,CAAAA,EAASC,CAAAA,CAAaD,CAAI,CAAC,CAAA,CAEtC,eAAsBC,CAAAA,CAAaC,CAAAA,CAA4B,CAC7D,OAAA,CAAQ,GAAA,CAAI,CAAA,OAAA,EAAUA,CAAAA,CAAQ,IAAI,CAAA,CAAE,EACtC,CCTA,IAAAC,EAAA,CAEE,OAAA,CAAW,QA6Db,CAAA,CCxDA,QAAQ,EAAA,CAAG,QAAA,CAAU,IAAM,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,CAAA,CAC1C,OAAA,CAAQ,GAAG,SAAA,CAAW,IAAM,QAAQ,IAAA,CAAK,CAAC,CAAC,CAAA,CAE3C,eAAeC,CAAAA,EAAO,CACpB,IAAMC,CAAAA,CAAU,IAAIN,OAAAA,EAAQ,CACzB,KAAK,OAAO,CAAA,CACZ,YAAY,oBAAoB,CAAA,CAChC,OAAA,CACCI,CAAAA,CAAY,OAAW,CACvB,gBACA,4BACF,CAAA,CAEFE,EAAQ,UAAA,CAAWP,CAAY,EAE/BO,CAAAA,CAAQ,KAAA,GACV,CAEAD,CAAAA,EAAK","file":"index.js","sourcesContent":["import { Command } from \"commander\";\n\nexport const helloCommand = new Command(\"hello\")\n .description(\"Say hello to the user!\")\n .option(\"-n, --name <name>\", \"Name to greet\", \"World\")\n .action((opts) => helloHandler(opts));\n\nexport async function helloHandler(options: { name?: string }) {\n console.log(`Hello, ${options.name}`);\n}\n","{\n \"name\": \"@talos-org/cli\",\n \"version\": \"0.1.14\",\n \"description\": \"\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"license\": \"MIT\",\n \"author\": {\n \"name\": \"sergiocortes-dll\",\n \"url\": \"https://x.com/sergiocortes-dll\"\n },\n \"files\": [\n \"dist\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/Vandlee/talos-cli.git\"\n },\n \"keywords\": [],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n }\n },\n \"bin\": {\n \"talos\": \"./dist/index.js\"\n },\n \"scripts\": {\n \"talos\": \"pnpm start:dev\",\n \"dev\": \"tsup --watch\",\n \"build\": \"tsup\",\n \"typecheck\": \"tsc --noEmit\",\n \"start\": \"node dist/index.js\",\n \"start:dev\": \"node dist/index.js\",\n \"pub:beta\": \"pnpm build && pnpm publish --no-git-checks --access public --tag beta\",\n \"pub:next\": \"pnpm build && pnpm publish --no-git-checks --access public --tag next\",\n \"pub:release\": \"pnpm build && pnpm publish --access public\",\n \"test\": \"vitest run\"\n },\n \"packageManager\": \"pnpm@10.28.2\",\n \"dependencies\": {\n \"chalk\": \"^5.6.2\",\n \"cli-spinners\": \"^3.4.0\",\n \"commander\": \"^14.0.3\",\n \"dotenv\": \"^17.2.4\",\n \"execa\": \"^9.6.1\",\n \"pino\": \"^10.3.0\",\n \"vite-tsconfig-paths\": \"^6.0.5\",\n \"zod\": \"^4.3.6\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^25.2.1\",\n \"eslint\": \"^10.0.0\",\n \"prettier\": \"^3.8.1\",\n \"tsconfig-paths\": \"^4.2.0\",\n \"tsx\": \"^4.21.0\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.18\"\n }\n}\n","#!/usr/bin/env node\n\nimport { Command } from \"commander\";\nimport { helloCommand } from \"./commands/hello\";\n\nimport packageJson from \"../package.json\";\n\nprocess.on(\"SIGINT\", () => process.exit(0));\nprocess.on(\"SIGTERM\", () => process.exit(0));\n\nasync function main() {\n const program = new Command()\n .name(\"talos\")\n .description(\"Manage everything.\")\n .version(\n packageJson.version || \"1.0.0\",\n \"-v, --version\",\n \"display the version number\",\n );\n\n program.addCommand(helloCommand);\n\n program.parse();\n}\n\nmain();\n"]}
1
+ {"version":3,"sources":["../src/commands/hello.ts","../package.json","../src/types/schema.ts","../src/utils/commandsPath.ts","../src/commands/e.ts","../src/index.ts"],"names":["helloCommand","Command","opts","helloHandler","options","package_default","CommandSchema","z","CommandBodySchema","RegistrySchema","commandsPath","path","os","executeCommand","name","extras","executeHandler","environment","select","findCommand","findLocalCommand","cliOptions","searchCommandSpinner","ora","cliSpinners","resolve","filePath","raw","readFile","parsedCommand","file","selectedVersion","cmd","baseCliArgs","knownOptions","parsed","parseExtras","existingFlags","item","filledArgs","placeholders","arg","isPlaceholder","defaults","placeholder","label","value","input","cmdCliArgs","option","primaryOption","commandSpinner","mergedArgs","execa","error","flags","unknownTokens","positionals","i","token","next","hasValue","main","program"],"mappings":";kPAEO,IAAMA,CAAAA,CAAe,IAAIC,OAAAA,CAAQ,OAAO,CAAA,CAC5C,WAAA,CAAY,wBAAwB,CAAA,CACpC,MAAA,CAAO,oBAAqB,eAAA,CAAiB,OAAO,CAAA,CACpD,MAAA,CAAQC,GAASC,CAAAA,CAAaD,CAAI,CAAC,CAAA,CAEtC,eAAsBC,EAAaC,CAAAA,CAA4B,CAC7D,OAAA,CAAQ,GAAA,CAAI,UAAUA,CAAAA,CAAQ,IAAI,EAAE,EACtC,CCTA,IAAAC,CAAAA,CAAA,CAEE,QAAW,QA+Db,EC/DO,IAAMC,CAAAA,CAAgBC,EAAE,MAAA,CAAO,CACpC,IAAA,CAAMA,CAAAA,CAAE,QAAO,CACf,OAAA,CAASA,EAAE,KAAA,CAAMA,CAAAA,CAAE,QAAQ,CAAA,CAC3B,IAAA,CAAMA,CAAAA,CAAE,MAAMA,CAAAA,CAAE,MAAA,EAA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QACF,CAEAD,CAAAA,CAAY,IAAA,CAAKE,CAAK,EACxB,CAEA,OAAO,CAAE,KAAA,CAAAJ,EAAO,aAAA,CAAAC,CAAAA,CAAe,YAAAC,CAAY,CAC7C,CACF,CCxMA,OAAA,CAAQ,EAAA,CAAG,SAAU,IAAM,OAAA,CAAQ,KAAK,CAAC,CAAC,EAC1C,OAAA,CAAQ,EAAA,CAAG,SAAA,CAAW,IAAM,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,CAAA,CAE3C,eAAeK,CAAAA,EAAO,CACpB,IAAMC,CAAAA,CAAU,IAAI9D,OAAAA,EAAQ,CACzB,IAAA,CAAK,OAAO,EACZ,WAAA,CAAY,oBAAoB,EAChC,OAAA,CACCI,CAAAA,CAAY,OAAW,CACvB,eAAA,CACA,4BACF,CAAA,CACC,uBAAA,EAAwB,CAE3B0D,EAAQ,UAAA,CAAW/D,CAAY,CAAA,CAC/B+D,CAAAA,CAAQ,UAAA,CAAWlD,CAAc,EAEjCkD,CAAAA,CAAQ,KAAA,GACV,CAEAD,CAAAA,EAAK","file":"index.js","sourcesContent":["import { Command } from \"commander\";\n\nexport const helloCommand = new Command(\"hello\")\n .description(\"Say hello to the user!\")\n .option(\"-n, --name <name>\", \"Name to greet\", \"World\")\n .action((opts) => helloHandler(opts));\n\nexport async function helloHandler(options: { name?: string }) {\n console.log(`Hello, ${options.name}`);\n}\n","{\n \"name\": \"@talos-org/cli\",\n \"version\": \"0.1.17\",\n \"description\": \"\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"license\": \"MIT\",\n \"author\": {\n \"name\": \"sergiocortes-dll\",\n \"url\": \"https://x.com/sergiocortes-dll\"\n },\n \"files\": [\n \"dist\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/Vandlee/talos-cli.git\"\n },\n \"keywords\": [],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n }\n },\n \"bin\": {\n \"talos\": \"./dist/index.js\"\n },\n \"scripts\": {\n \"talos\": \"pnpm start:dev\",\n \"dev\": \"tsup --watch\",\n \"build\": \"tsup\",\n \"typecheck\": \"tsc --noEmit\",\n \"start\": \"node dist/index.js\",\n \"start:dev\": \"node dist/index.js\",\n \"pub:beta\": \"pnpm build && pnpm publish --no-git-checks --access public --tag beta\",\n \"pub:next\": \"pnpm build && pnpm publish --no-git-checks --access public --tag next\",\n \"pub:release\": \"pnpm build && pnpm publish --access public\",\n \"test\": \"vitest run\"\n },\n \"packageManager\": \"pnpm@10.28.2\",\n \"dependencies\": {\n \"@inquirer/prompts\": \"^8.2.0\",\n \"chalk\": \"^5.6.2\",\n \"cli-spinners\": \"^3.4.0\",\n \"commander\": \"^14.0.3\",\n \"dotenv\": \"^17.2.4\",\n \"execa\": \"^9.6.1\",\n \"ora\": \"^9.3.0\",\n \"pino\": \"^10.3.0\",\n \"vite-tsconfig-paths\": \"^6.0.5\",\n \"zod\": \"^4.3.6\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^25.2.1\",\n \"eslint\": \"^10.0.0\",\n \"prettier\": \"^3.8.1\",\n \"tsconfig-paths\": \"^4.2.0\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.21.0\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.18\"\n }\n}\n","import z from \"zod\";\n\nexport const CommandSchema = z.object({\n name: z.string(),\n options: z.array(z.string()),\n args: z.array(z.string()),\n action: z.string(),\n});\n\nexport const CommandBodySchema = z.object({\n version: z.string(),\n commands: z.array(CommandSchema),\n});\n\nexport const RegistrySchema = z.object({\n name: z.string(),\n body: z.array(CommandBodySchema),\n});\n\nexport type Command = z.infer<typeof CommandSchema>;\nexport type CommandBody = z.infer<typeof CommandBodySchema>;\nexport type registrySchema = z.infer<typeof RegistrySchema>;\n","import os from \"os\";\nimport path from \"path\";\n\nexport const commandsPath = path.join(\n os.homedir(),\n \"Documents\",\n \"talos\",\n \"commands\",\n);\n","import { input, select } from \"@inquirer/prompts\";\nimport cliSpinners from \"cli-spinners\";\nimport { Command } from \"commander\";\nimport { execa } from \"execa\";\nimport { readFile } from \"fs/promises\";\nimport ora from \"ora\";\nimport path from \"path\";\nimport { RegistrySchema } from \"../types/schema\";\nimport { commandsPath } from \"../utils/commandsPath\";\n\nexport const executeCommand = new Command(\"e\")\n .description(\"Execute a command\")\n .argument(\"<name>\", \"Name of the command\")\n .argument(\"[extras...]\", \"Additional arguments and options\")\n .allowUnknownOption()\n .passThroughOptions()\n .action((name, extras, opts) => executeHandler(name, opts, extras));\n\nexport async function executeHandler(\n name: string,\n options: any,\n extras?: string[],\n) {\n const environment = await select({\n message: \"Where does Talos need to look for the command?\",\n choices: [\n { name: \"Local\", value: \"local\" },\n { name: \"Internet\", value: \"internet\" },\n ],\n });\n\n await findCommand(name, environment, { ...options, extras });\n}\n\nasync function findCommand(name: string, environment: string, options: any) {\n if (environment === \"local\") {\n await findLocalCommand(name, options);\n } else if (environment === \"internet\") {\n console.log(`Looking for ${name} on the internet...`);\n // Implement internet command lookup logic here\n }\n}\n\nasync function findLocalCommand(name: string, cliOptions: any = {}) {\n const searchCommandSpinner = ora({\n text: \"Looking for command locally...\",\n spinner: {\n frames: cliSpinners.circleHalves.frames,\n interval: 80,\n },\n }).start();\n\n await new Promise((resolve) => setTimeout(resolve, 1000)); // Simulate async operation\n\n const filePath = path.join(commandsPath, `${name}.json`);\n\n const raw = await readFile(filePath, \"utf-8\");\n const parsedCommand = JSON.parse(raw);\n\n const file = RegistrySchema.parse(parsedCommand);\n\n if (!file) {\n searchCommandSpinner.fail(\"Command not found locally.\");\n return;\n }\n\n searchCommandSpinner.succeed(\"Command found locally.\");\n\n if (file.body.length <= 0) {\n searchCommandSpinner.fail(\"No versions found for this command.\");\n return;\n }\n\n let selectedVersion = file.body[0]; // Default to the first version\n\n if (file.body.length > 1) {\n const version = await select({\n message: \"Select a command version to execute:\",\n choices: file.body.map((cmd) => ({ name: cmd.version, value: cmd })),\n });\n\n selectedVersion = version || selectedVersion;\n }\n\n // Build CLI args from extras while prompting for missing values defined in the registry.\n const baseCliArgs: string[] = [];\n const extras = Array.isArray(cliOptions.extras) ? cliOptions.extras : [];\n\n const knownOptions = new Set(\n selectedVersion.commands.flatMap((cmd) => cmd.options),\n );\n const parsed = parseExtras(extras, knownOptions);\n\n // Preserve provided flags, unknown flags, and positional args as-is.\n const existingFlags = new Set(parsed.flags.map((item) => item.flag));\n for (const item of parsed.flags) {\n baseCliArgs.push(item.flag);\n if (item.value !== null) {\n baseCliArgs.push(item.value);\n }\n }\n baseCliArgs.push(...parsed.unknownTokens);\n baseCliArgs.push(...parsed.positionals);\n\n for (const cmd of selectedVersion.commands) {\n // Prompt for missing positional args (placeholders like <host> or [host]).\n const filledArgs: string[] = [];\n const placeholders = cmd.args.filter((arg) => isPlaceholder(arg));\n const defaults = cmd.args.filter((arg) => !isPlaceholder(arg));\n\n for (const placeholder of placeholders) {\n const label = placeholder.replace(/[\\[\\]<>]/g, \"\").trim() || \"value\";\n const value = await input({\n message: `What argument are you gonna send? (${label})`,\n });\n filledArgs.push(value);\n }\n\n filledArgs.unshift(...defaults);\n\n // Prompt for known options that are missing in the CLI.\n const cmdCliArgs = [...baseCliArgs];\n\n if (cmd.options.length > 0) {\n const hasProvided = cmd.options.some((option) =>\n existingFlags.has(option),\n );\n if (!hasProvided) {\n const primaryOption = cmd.options[0];\n const value = await input({\n message: `What do you want to use for \"${primaryOption}\" argument?`,\n default: \"\",\n });\n\n if (value !== \"\") {\n cmdCliArgs.push(primaryOption, value);\n }\n }\n }\n\n for (const cmd of selectedVersion.commands) {\n const commandSpinner = ora({\n text: `Executing command: ${cmd.name}...`,\n spinner: {\n frames: cliSpinners.circleHalves.frames,\n interval: 80,\n },\n }).start();\n\n try {\n commandSpinner.stop();\n\n // Merge JSON args with CLI args\n const mergedArgs = [...filledArgs, ...cmdCliArgs];\n\n console.log(`\\n$ ${cmd.action} ${mergedArgs.join(\" \")}\\n`);\n\n await execa(cmd.action, mergedArgs, { stdio: \"inherit\" });\n\n console.log();\n commandSpinner.succeed(`Executed command: ${cmd.name}`);\n } catch (error) {\n commandSpinner.fail(`Failed to execute command: ${cmd.name}`);\n if (error instanceof Error) {\n console.error(`Error: ${error.message}`);\n }\n }\n }\n }\n\n function isPlaceholder(value: string) {\n return /^<[^>]+>$/.test(value) || /^\\[[^\\]]+\\]$/.test(value);\n }\n\n function parseExtras(extras: string[], knownOptions: Set<string>) {\n const flags: Array<{ flag: string; value: string | null }> = [];\n const unknownTokens: string[] = [];\n const positionals: string[] = [];\n\n for (let i = 0; i < extras.length; i += 1) {\n const token = extras[i];\n\n if (token.startsWith(\"-\")) {\n const next = extras[i + 1];\n const hasValue = next !== undefined && !next.startsWith(\"-\");\n const value = hasValue ? next : null;\n\n if (knownOptions.has(token)) {\n flags.push({ flag: token, value });\n } else {\n unknownTokens.push(token);\n if (hasValue) {\n unknownTokens.push(next);\n }\n }\n\n if (hasValue) {\n i += 1;\n }\n\n continue;\n }\n\n positionals.push(token);\n }\n\n return { flags, unknownTokens, positionals };\n }\n}\n","#!/usr/bin/env node\n\nimport { Command } from \"commander\";\nimport { helloCommand } from \"./commands/hello\";\n\nimport packageJson from \"../package.json\";\nimport { executeCommand } from \"./commands/e\";\n\nprocess.on(\"SIGINT\", () => process.exit(0));\nprocess.on(\"SIGTERM\", () => process.exit(0));\n\nasync function main() {\n const program = new Command()\n .name(\"talos\")\n .description(\"Manage everything.\")\n .version(\n packageJson.version || \"1.0.0\",\n \"-v, --version\",\n \"display the version number\",\n )\n .enablePositionalOptions();\n\n program.addCommand(helloCommand);\n program.addCommand(executeCommand);\n\n program.parse();\n}\n\nmain();\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talos-org/cli",
3
- "version": "0.1.14",
3
+ "version": "0.1.17",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -42,11 +42,13 @@
42
42
  },
43
43
  "packageManager": "pnpm@10.28.2",
44
44
  "dependencies": {
45
+ "@inquirer/prompts": "^8.2.0",
45
46
  "chalk": "^5.6.2",
46
47
  "cli-spinners": "^3.4.0",
47
48
  "commander": "^14.0.3",
48
49
  "dotenv": "^17.2.4",
49
50
  "execa": "^9.6.1",
51
+ "ora": "^9.3.0",
50
52
  "pino": "^10.3.0",
51
53
  "vite-tsconfig-paths": "^6.0.5",
52
54
  "zod": "^4.3.6"
@@ -56,8 +58,8 @@
56
58
  "eslint": "^10.0.0",
57
59
  "prettier": "^3.8.1",
58
60
  "tsconfig-paths": "^4.2.0",
59
- "tsx": "^4.21.0",
60
61
  "tsup": "^8.5.1",
62
+ "tsx": "^4.21.0",
61
63
  "typescript": "^5.9.3",
62
64
  "vitest": "^4.0.18"
63
65
  }