@forinda/kickjs-cli 6.2.0-alpha.0 → 6.2.0-alpha.2
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/{agent-docs-B65qHJup.mjs → agent-docs-BHxKWIf4.mjs} +3 -3
- package/dist/{agent-docs-B65qHJup.mjs.map → agent-docs-BHxKWIf4.mjs.map} +1 -1
- package/dist/{build-C8B6v3iF.mjs → build-DH7RVYT6.mjs} +3 -3
- package/dist/{build-C8B6v3iF.mjs.map → build-DH7RVYT6.mjs.map} +1 -1
- package/dist/{builtins-D4DM7SWf.mjs → builtins-B9jAir23.mjs} +2 -2
- package/dist/cli.mjs +153 -114
- package/dist/{config-MpY5O0Uv.mjs → config-DOnwtASE.mjs} +3 -3
- package/dist/{config-MpY5O0Uv.mjs.map → config-DOnwtASE.mjs.map} +1 -1
- package/dist/{doctor-Da_WPc4H.mjs → doctor-CUR55xM0.mjs} +40 -40
- package/dist/doctor-CUR55xM0.mjs.map +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{plugin-1LpIVE1p.mjs → plugin-DiLjdUhB.mjs} +3 -3
- package/dist/{plugin-1LpIVE1p.mjs.map → plugin-DiLjdUhB.mjs.map} +1 -1
- package/dist/{project-docs-DdHhz2vw.mjs → project-docs-M1yY0Jfu.mjs} +44 -5
- package/dist/project-docs-M1yY0Jfu.mjs.map +1 -0
- package/dist/{project-root-DEufQPY3.mjs → project-root-t0bXso9G.mjs} +3 -3
- package/dist/{project-root-DEufQPY3.mjs.map → project-root-t0bXso9G.mjs.map} +1 -1
- package/dist/{rolldown-runtime-DT7Ktfzg.mjs → rolldown-runtime-DM9iduxt.mjs} +1 -1
- package/dist/{run-plugins-DtHMyrXU.mjs → run-plugins-DujFeVh4.mjs} +4 -4
- package/dist/{run-plugins-DtHMyrXU.mjs.map → run-plugins-DujFeVh4.mjs.map} +1 -1
- package/dist/{typegen-BaE5TxzH.mjs → typegen-6pW2cOTw.mjs} +5 -5
- package/dist/{typegen-BaE5TxzH.mjs.map → typegen-6pW2cOTw.mjs.map} +1 -1
- package/dist/{types-Btg3O9XP.mjs → types-D34YF7B6.mjs} +1 -1
- package/package.json +2 -2
- package/dist/doctor-Da_WPc4H.mjs.map +0 -1
- package/dist/project-docs-DdHhz2vw.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v6.2.0-alpha.
|
|
2
|
+
* @forinda/kickjs-cli v6.2.0-alpha.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{_ as e,b as t,c as n,d as r,f as i,g as a,h as o,l as s,m as c,p as l,s as u,u as d,v as f,y as p}from"./project-docs-
|
|
11
|
+
import{_ as e,b as t,c as n,d as r,f as i,g as a,h as o,l as s,m as c,p as l,s as u,u as d,v as f,y as p}from"./project-docs-M1yY0Jfu.mjs";import{A as m,C as h,D as g,E as _,F as v,I as y,L as b,M as ee,N as x,O as S,P as C,R as w,S as te,T as ne,_ as re,a as ie,b as ae,c as oe,f as se,g as ce,h as le,i as ue,j as de,k as fe,l as pe,m as me,o as he,p as ge,r as _e,s as ve,v as ye,w as be,x as xe,y as Se}from"./doctor-CUR55xM0.mjs";import{a as T,i as E,o as Ce,s as we}from"./config-DOnwtASE.mjs";import{t as Te}from"./project-root-t0bXso9G.mjs";import{n as D}from"./types-D34YF7B6.mjs";import{t as Ee}from"./build-DH7RVYT6.mjs";import{n as De}from"./agent-docs-BHxKWIf4.mjs";import{n as Oe}from"./plugin-DiLjdUhB.mjs";import{a as ke,c as Ae,d as je,f as Me,g as Ne,h as Pe,i as Fe,l as Ie,m as Le,o as Re,p as ze,r as Be,s as Ve,t as He,u as Ue}from"./typegen-6pW2cOTw.mjs";import O,{basename as We,dirname as k,join as A,relative as j,resolve as M,sep as N}from"node:path";import{cpSync as Ge,existsSync as P,mkdirSync as Ke,readFileSync as F,readdirSync as qe,rmSync as Je,writeFileSync as Ye}from"node:fs";import{copyFile as Xe,mkdir as I,readFile as L,readdir as Ze,rm as Qe,stat as $e,writeFile as R}from"node:fs/promises";import{fork as et,spawn as tt,spawnSync as nt}from"node:child_process";import{fileURLToPath as rt,pathToFileURL as z}from"node:url";import{arch as it,platform as at,release as ot}from"node:os";const st=[{value:`swagger`,label:`Swagger`,hint:`OpenAPI docs`},{value:`ws`,label:`WebSocket`,hint:`rooms, heartbeat`},{value:`queue`,label:`Queue`,hint:`BullMQ/RabbitMQ/Kafka`},{value:`devtools`,label:`DevTools`,hint:`debug dashboard`}];function ct(e){e.command(`new [name]`).alias(`init`).description(`Create a new KickJS project (use "." for current directory)`).option(`-d, --directory <dir>`,`Target directory (defaults to project name)`).option(`--pm <manager>`,`Package manager: pnpm | npm | yarn | bun`).option(`--git`,`Initialize git repository`).option(`--no-git`,`Skip git initialization`).option(`--install`,`Install dependencies after scaffolding`).option(`--no-install`,`Skip dependency installation`).option(`-f, --force`,`Remove existing files without prompting`).option(`-t, --template <type>`,`Project template: rest | minimal`).option(`--runtime <engine>`,`HTTP runtime: express | fastify | h3`).option(`-r, --repo <type>`,`Repository name (inmemory, or any DB name e.g. postgres)`).option(`-s, --schema <lib>`,`Schema library for env / DTOs: zod | valibot | yup (default: zod)`).option(`--packages <packages>`,`Comma-separated packages to include (e.g. auth,swagger,ws,queue)`).option(`-y, --yes`,`Pick safe defaults for every prompt (template=minimal, repo=inmemory, no extras, git+install on)`).option(`--non-interactive`,`alias for --yes`).action(async(e,t)=>{n(`KickJS — Create a new project`);let o=!!(t.yes||t.nonInteractive);e||=o?`my-api`:await c({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let l;if(e===`.`?(l=M(`.`),e=We(l)):l=M(t.directory||e),P(l)){let n=qe(l);if(n.length>0){if(t.force)s.warn(`Clearing existing files in ${l}`);else if(o){s.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),r(`Aborted.`);return}else{s.warn(`Directory "${e}" is not empty:`);let t=n.slice(0,5);for(let e of t)s.message(` - ${e}`);if(n.length>5&&s.message(` ... and ${n.length-5} more`),!await u({message:a.red(`Remove all existing files and proceed?`),initialValue:!1})){r(`Aborted.`);return}}for(let e of n)Je(M(l,e),{recursive:!0,force:!0})}}let f=t.template;f||=o?`minimal`:await i({message:`Project template`,options:[{value:`rest`,label:`REST API`,hint:`Express + Swagger`},{value:`minimal`,label:`Minimal`,hint:`bare Express`}]});let p=t.runtime;p||=o?`express`:await i({message:`HTTP runtime`,options:[{value:`express`,label:`Express`,hint:`default, zero-config`},{value:`fastify`,label:`Fastify`,hint:`fastify + @fastify/middie`},{value:`h3`,label:`h3`,hint:`Nitro / Nuxt engine`}]});let m=t.pm;m||=o?await ve(void 0):await i({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let h=t.repo;h||=o?`inmemory`:await c({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),we(h);let g=t.schema;g||=o?`zod`:await i({message:`Schema library (env + DTO validation)`,options:[{value:`zod`,label:`Zod`,hint:`default — broad ecosystem`},{value:`valibot`,label:`Valibot`,hint:`smaller bundle`},{value:`yup`,label:`Yup`,hint:`classic API`}]}),[`zod`,`valibot`,`yup`].includes(g)||(s.warn(`Unknown --schema "${g}", falling back to zod.`),g=`zod`);let _;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();_=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else _=o?[]:await d({message:`Select packages to include`,options:[...st],required:!1});let v;v=t.git===void 0?o?!0:await u({message:`Initialize git repository?`,initialValue:!0}):t.git;let y;y=t.install===void 0?o?!0:await u({message:`Install dependencies?`,initialValue:!0}):t.install,await me({name:e,directory:l,packageManager:m,initGit:v,installDeps:y,template:f,defaultRepo:h,packages:_,schemaLib:g,runtime:p}),r(`Done! Next steps: ${a.cyan(`cd ${e} && ${m} dev`)}`)})}async function lt(e){let{name:n,outDir:r}=e,i=b(n),a=w(n),o=[],s=A(r,`${i}.plugin.ts`);return await t(s,`import {
|
|
12
12
|
definePlugin,
|
|
13
13
|
type AppAdapter,
|
|
14
14
|
type AppModuleEntry,
|
|
@@ -538,7 +538,7 @@ server.on('exit', () => {
|
|
|
538
538
|
Cancelled.
|
|
539
539
|
`);return}await Qe(l,{recursive:!0,force:!0}),console.log(` Deleted: ${l}`);let d=A(n,`index.ts`);if(await f(d)){let e=await L(d,`utf-8`),t=e,n=RegExp(`^import\\s*\\{\\s*${x(s)}Module\\s*\\}\\s*from\\s*['"][^'"]*${x(c)}(?:/[^'"]*)?['"].*\\n?`,`gm`);e=e.replace(n,``),e=Rn(e,s),e=e.replace(/\n{3,}/g,`
|
|
540
540
|
|
|
541
|
-
`),e!==t&&(await R(d,e,`utf-8`),console.log(` Unregistered: ${s}Module from ${d}`))}console.log(`\n Module '${c}' removed.\n`)}function Bn(e){e.command(`remove`).alias(`rm`).description(`Remove generated code`).command(`module <names...>`).description(`Remove one or more modules (e.g. kick rm module user task)`).option(`--modules-dir <dir>`,`Modules directory`).option(`--no-pluralize`,`Use singular module name`).option(`-f, --force`,`Skip confirmation prompt`).action(async(e,t)=>{let n=T(await E(process.cwd())),r=t.modulesDir??n.dir??`src/modules`,i=t.pluralize===!1?!1:n.pluralize??!0;for(let n of e)await zn({name:n,modulesDir:M(r),force:t.force,pluralize:i})})}function Vn(e){if(e!==void 0){if(e===`false`||e===`off`||e===`none`)return!1;if(e===`zod`)return`zod`;if(e===`kickjs-schema`||e===`schema`)return`kickjs-schema`;console.warn(` kick typegen: unknown --schema-validator '${e}' (supported: 'zod', 'kickjs-schema', 'false'). Falling back to project config.`)}}function Hn(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function Un(e){e.command(`typegen`).description(`Generate type-safe DI registry and module types into .kickjs/types/`).option(`-w, --watch`,`Watch source files and regenerate on change`).option(`-s, --src <dir>`,`Source directory to scan`,`src`).option(`-o, --out <dir>`,`Output directory`,`.kickjs/types`).option(`--silent`,`Suppress output`).option(`--allow-duplicates`,`Auto-namespace duplicate class names instead of failing (use with caution)`).option(`--schema-validator <name>`,`Schema validator for body/query/params typing (currently 'zod' or 'false')`).option(`--env-file <path>`,`Path to env schema file for KickEnv typing (default 'src/env.ts'; pass 'false' to disable)`).option(`--check`,`CI gate: fail on plugin-typegen drift instead of writing`).option(`--list`,"List every registered typegen plugin id (use to populate `typegen.disable`)").option(`--no-cache`,`Disable the persistent scan cache; re-read + re-extract every file from cold`).action(async e=>{let t=Te(process.cwd()),n=await E(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-
|
|
541
|
+
`),e!==t&&(await R(d,e,`utf-8`),console.log(` Unregistered: ${s}Module from ${d}`))}console.log(`\n Module '${c}' removed.\n`)}function Bn(e){e.command(`remove`).alias(`rm`).description(`Remove generated code`).command(`module <names...>`).description(`Remove one or more modules (e.g. kick rm module user task)`).option(`--modules-dir <dir>`,`Modules directory`).option(`--no-pluralize`,`Use singular module name`).option(`-f, --force`,`Skip confirmation prompt`).action(async(e,t)=>{let n=T(await E(process.cwd())),r=t.modulesDir??n.dir??`src/modules`,i=t.pluralize===!1?!1:n.pluralize??!0;for(let n of e)await zn({name:n,modulesDir:M(r),force:t.force,pluralize:i})})}function Vn(e){if(e!==void 0){if(e===`false`||e===`off`||e===`none`)return!1;if(e===`zod`)return`zod`;if(e===`kickjs-schema`||e===`schema`)return`kickjs-schema`;console.warn(` kick typegen: unknown --schema-validator '${e}' (supported: 'zod', 'kickjs-schema', 'false'). Falling back to project config.`)}}function Hn(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function Un(e){e.command(`typegen`).description(`Generate type-safe DI registry and module types into .kickjs/types/`).option(`-w, --watch`,`Watch source files and regenerate on change`).option(`-s, --src <dir>`,`Source directory to scan`,`src`).option(`-o, --out <dir>`,`Output directory`,`.kickjs/types`).option(`--silent`,`Suppress output`).option(`--allow-duplicates`,`Auto-namespace duplicate class names instead of failing (use with caution)`).option(`--schema-validator <name>`,`Schema validator for body/query/params typing (currently 'zod' or 'false')`).option(`--env-file <path>`,`Path to env schema file for KickEnv typing (default 'src/env.ts'; pass 'false' to disable)`).option(`--check`,`CI gate: fail on plugin-typegen drift instead of writing`).option(`--list`,"List every registered typegen plugin id (use to populate `typegen.disable`)").option(`--no-cache`,`Disable the persistent scan cache; re-read + re-extract every file from cold`).action(async e=>{let t=Te(process.cwd()),n=await E(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-DiLjdUhB.mjs`).then(e=>e.t),{builtinCliPlugins:t}=await import(`./builtins-B9jAir23.mjs`),r=e([...t,...n?.plugins??[]],n?.commands??[]),i=new Set(n?.typegen?.disable??[]);if(r.typegens.length===0){console.log(` No typegen plugins registered.`);return}let a=Math.max(...r.typegens.map(e=>e.id.length));console.log(`
|
|
542
542
|
Registered typegen plugins:
|
|
543
543
|
`);for(let e of r.typegens){let t=i.has(e.id)?` (disabled)`:``;console.log(` ${e.id.padEnd(a+2)}inputs: ${e.inputs.join(`, `)||`(none)`}${t}`)}console.log();return}let r=Vn(e.schemaValidator)??n?.typegen?.schemaValidator??`zod`,i=Hn(e.envFile)??n?.typegen?.envFile,a={cwd:t,srcDir:e.src??n?.typegen?.srcDir,outDir:e.out??n?.typegen?.outDir,silent:e.silent,allowDuplicates:e.allowDuplicates,noCache:e.cache===!1,schemaValidator:r,envFile:i,assetMap:n?.assetMap,runPlugins:!1};try{if(e.watch){let t=await Be(a);e.silent||console.log(` kick typegen: watching for changes (Ctrl-C to exit)`);let n=()=>{t(),process.exit(0)};process.on(`SIGINT`,n),process.on(`SIGTERM`,n),await new Promise(()=>{})}else{await He(a);let r=await Gt({cwd:t,config:n??null,silent:e.silent,check:e.check});e.check&&r.some(e=>e.status===`written`)&&process.exit(1),e.check||await Fe(M(t,e.out??n?.typegen?.outDir??`.kickjs/types`),r,e.silent??!1)}}catch(e){e instanceof Ve?console.error(`
|
|
544
544
|
`+e.message+`
|
|
@@ -618,4 +618,4 @@ declare global {
|
|
|
618
618
|
export {}
|
|
619
619
|
`}const gr=()=>({id:`kick/env`,outExtension:`.ts`,inputs:[`src/env.ts`,`src/**/env.ts`,`src/**/*.env.ts`],async generate(e){let t=vr(e);if(t===!1)return null;let n=await e.getScanResult({root:_r(e),cwd:e.cwd,envFile:t});if(!n.env)return null;let r=e.config?.typegen?.schemaValidator??`zod`,i=O.resolve(e.cwd,`.kickjs/types/kick__env.ts`);return hr(n.env,i,r)}});function _r(e){return O.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function vr(e){return e.config?.typegen?.envFile}function yr(e){return O.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function br(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}function $(e){return{root:yr(e),cwd:e.cwd,envFile:br(e)}}const xr=()=>({id:`kick/registry`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=O.resolve(e.cwd,`.kickjs/types/kick__registry.d.ts`),r=new Set(t.collisions.map(e=>e.className));return ze(t.classes,n,r)}}),Sr=()=>({id:`kick/services`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=new Set(t.collisions.map(e=>e.className));return Le(`ServiceToken`,Ie(t.classes,t.tokens,t.injects,n),"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)")}}),Cr=()=>({id:`kick/modules`,inputs:[`src/**/*.ts`],async generate(e){return Le(`ModuleToken`,Ae((await e.getScanResult($(e))).classes),"(no @Module classes discovered — `kick g module <name>` to add one)")}}),wr=()=>({id:`kick/plugins`,inputs:[`src/**/*.ts`],async generate(e){return Me((await e.getScanResult($(e))).pluginsAndAdapters)}}),Tr=()=>({id:`kick/augmentations`,inputs:[`src/**/*.ts`],async generate(e){return Ue((await e.getScanResult($(e))).augmentations)}}),Er=()=>({id:`kick/context`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return t.contextKeys.length===0?null:je(t.contextKeys)}}),Dr={fastify:{subpath:`@forinda/kickjs/fastify`,typeName:`FastifyRuntimeTypes`},h3:{subpath:`@forinda/kickjs/h3`,typeName:`H3RuntimeTypes`}},Or=[D({name:`kick/init`,register:ct}),D({name:`kick/generate`,register:Rt}),D({name:`kick/run`,register:Zt}),D({name:`kick/info`,register:nn}),D({name:`kick/inspect`,register:dn}),D({name:`kick/add`,register:ie}),D({name:`kick/list`,register:he}),D({name:`kick/explain`,register:xn}),D({name:`kick/mcp`,register:An}),D({name:`kick/tinker`,register:Pn}),D({name:`kick/remove`,register:Bn}),D({name:`kick/typegen`,register:Un}),D({name:`kick/check`,register:tr}),D({name:`kick/doctor`,register:_e}),D({name:`kick/codemod`,register:rr}),D({name:`kick/registry`,typegens:[xr()]}),D({name:`kick/services`,typegens:[Sr()]}),D({name:`kick/modules`,typegens:[Cr()]}),D({name:`kick/plugins`,typegens:[wr()]}),D({name:`kick/augmentations`,typegens:[Tr()]}),D({name:`kick/context`,typegens:[Er()]}),D({name:`kick/assets`,typegens:[ir()]}),D({name:`kick/routes`,typegens:[fr()]}),D({name:`kick/env`,typegens:[gr()]}),D({name:`kick/runtime`,typegens:[{id:`kick/runtime`,outExtension:`.ts`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`],async generate(e){let t=e.config?.runtime;if(t!==`fastify`&&t!==`h3`)return null;let{subpath:n,typeName:r}=Dr[t];return[`// Runtime escape-hatch types for the '${t}' engine (kick.config runtime).`,`declare module '@forinda/kickjs' {`,` interface KickRuntimeRegister {`,` runtime: import('${n}').${r}`,` }`,`}`,``,`export {}`,``].join(`
|
|
620
620
|
`)}}]})];export{Ut as applyDisableFilter,Gt as runAllPluginTypegens,Or as t};
|
|
621
|
-
//# sourceMappingURL=run-plugins-
|
|
621
|
+
//# sourceMappingURL=run-plugins-DujFeVh4.mjs.map
|