@forinda/kickjs-cli 6.8.0 → 6.9.1
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-B91ALPZR.mjs +11 -0
- package/dist/{agent-docs-fKQUJYgz.mjs → agent-docs-DvLtd3g5.mjs} +3 -3
- package/dist/{agent-docs-fKQUJYgz.mjs.map → agent-docs-DvLtd3g5.mjs.map} +1 -1
- package/dist/build-D-7xvnpW.mjs +12 -0
- package/dist/{build-BDx9kJD_.mjs → build-Dghtk24W.mjs} +3 -3
- package/dist/{build-BDx9kJD_.mjs.map → build-Dghtk24W.mjs.map} +1 -1
- package/dist/builtins-BjcrVIsO.mjs +1498 -0
- package/dist/{builtins-5XvbxXOT.mjs → builtins-CPF14ODX.mjs} +2 -2
- package/dist/cli.mjs +2 -2888
- package/dist/{config-13M-pdRz.mjs → config-CFAZrUmi.mjs} +3 -3
- package/dist/{config-13M-pdRz.mjs.map → config-CFAZrUmi.mjs.map} +1 -1
- package/dist/config-DzcY7KDb.mjs +12 -0
- package/dist/{doctor-ebixckGm.mjs → doctor-BRs6lrbi.mjs} +9 -8
- package/dist/doctor-BRs6lrbi.mjs.map +1 -0
- package/dist/{fullstack-1pSNtZTQ.mjs → fullstack-3TAOhXfk.mjs} +4 -4
- package/dist/{fullstack-1pSNtZTQ.mjs.map → fullstack-3TAOhXfk.mjs.map} +1 -1
- package/dist/{fullstack-DkQrZR8Y.mjs → fullstack-BlETTj51.mjs} +3 -3
- package/dist/index.d.mts +3 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/plugin-DSCSpumh.mjs +11 -0
- package/dist/{plugin-CYc-Ejd5.mjs → plugin-qwSg0kwT.mjs} +3 -3
- package/dist/{plugin-CYc-Ejd5.mjs.map → plugin-qwSg0kwT.mjs.map} +1 -1
- package/dist/project-BD_l6pkS.mjs +389 -0
- package/dist/{project-BX9P1ntp.mjs → project-BSSB5kBG.mjs} +6 -6
- package/dist/{project-BX9P1ntp.mjs.map → project-BSSB5kBG.mjs.map} +1 -1
- package/dist/project-docs-DG-aI5f_.mjs +928 -0
- package/dist/{project-docs-ZT5I_aDa.mjs → project-docs-Dlq_ipnh.mjs} +2 -2
- package/dist/{project-docs-ZT5I_aDa.mjs.map → project-docs-Dlq_ipnh.mjs.map} +1 -1
- package/dist/{project-root-DYE4IdOm.mjs → project-root-BNYhLr1o.mjs} +3 -3
- package/dist/{project-root-DYE4IdOm.mjs.map → project-root-BNYhLr1o.mjs.map} +1 -1
- package/dist/project-root-Dv1HfN0o.mjs +11 -0
- package/dist/{prompts-DWyN3rhd.mjs → prompts-D82t3FiY.mjs} +2 -2
- package/dist/{prompts-DWyN3rhd.mjs.map → prompts-D82t3FiY.mjs.map} +1 -1
- package/dist/{rolldown-runtime-BhiQ_pHx.mjs → rolldown-runtime-DnEcvn06.mjs} +1 -1
- package/dist/{run-plugins-EHBKYR0W.mjs → run-plugins-B49z_ywO.mjs} +50 -50
- package/dist/{run-plugins-EHBKYR0W.mjs.map → run-plugins-B49z_ywO.mjs.map} +1 -1
- package/dist/typegen-BZKiGXjW.mjs +113 -0
- package/dist/{typegen-BFMgqlSf.mjs → typegen-CdS37QWi.mjs} +5 -5
- package/dist/{typegen-BFMgqlSf.mjs.map → typegen-CdS37QWi.mjs.map} +1 -1
- package/dist/{types-BCWqa1Q6.mjs → types-Dfg3zods.mjs} +1 -1
- package/package.json +12 -12
- package/dist/doctor-ebixckGm.mjs.map +0 -1
- package/dist/plugin-CQ0NPO0o.mjs +0 -13
- package/dist/plugin-CQ0NPO0o.mjs.map +0 -1
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/commands/add.ts","../src/commands/doctor.ts","../src/plugin/types.ts","../src/config.ts","../src/generators/templates/types.ts","../src/generators/module.ts","../src/generators/adapter.ts","../src/generators/middleware.ts","../src/generators/guard.ts","../src/generators/service.ts","../src/generators/controller.ts","../src/generators/dto.ts","../src/generators/project.ts","../src/utils/project-root.ts","../src/typegen/scanner.ts","../src/typegen/plugin.ts","../src/typegen/token-conventions.ts","../src/typegen/index.ts","../src/typegen/run-plugins.ts","../src/asset-manager/build.ts","../src/typegen/dev-watcher.ts","../src/generator-extension/discover.ts","../src/generator-extension/context.ts","../src/utils/naming.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/commands/add.ts","../src/commands/doctor.ts","../src/plugin/types.ts","../src/config.ts","../src/generators/templates/types.ts","../src/generators/module.ts","../src/generators/adapter.ts","../src/generators/middleware.ts","../src/generators/guard.ts","../src/generators/service.ts","../src/generators/controller.ts","../src/generators/dto.ts","../src/generators/project.ts","../src/utils/project-root.ts","../src/typegen/scanner.ts","../src/typegen/plugin.ts","../src/typegen/token-conventions.ts","../src/typegen/index.ts","../src/typegen/run-plugins.ts","../src/asset-manager/build.ts","../src/typegen/dev-watcher.ts","../src/generator-extension/discover.ts","../src/generator-extension/context.ts","../src/utils/naming.ts"],"mappings":"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"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v6.
|
|
2
|
+
* @forinda/kickjs-cli v6.9.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{
|
|
11
|
+
import{F as e,N as t,P as n,c as r,d as i,f as a,g as o,h as s,j as c,l,m as u,n as d,o as f,p,s as m,t as h,v as g,x as _}from"./doctor-BRs6lrbi.mjs";import{t as v}from"./project-BSSB5kBG.mjs";import{i as y,r as b}from"./config-CFAZrUmi.mjs";import{t as x}from"./project-root-BNYhLr1o.mjs";import{n as S,t as C}from"./types-Dfg3zods.mjs";export{C as KickPluginConflictError,r as TYPEGEN_OWNER_KEY,f as buildGeneratorContext,l as createTypegenDevWatcher,S as defineCliPlugin,b as defineConfig,h as defineDoctorCheck,d as defineDoctorExtension,m as defineGenerator,i as defineTypegen,x as findProjectRoot,g as generateAdapter,p as generateController,a as generateDto,s as generateGuard,o as generateMiddleware,_ as generateModule,u as generateService,v as initProject,y as loadKickConfig,c as pluralize,t as toCamelCase,n as toKebabCase,e as toPascalCase};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs-cli v6.9.1
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Felix Orinda
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import{t as e}from"./rolldown-runtime-DnEcvn06.mjs";import{KickPluginConflictError as t,defineCliPlugin as n}from"@forinda/kickjs-cli-kit";function r(e,n=[]){let r=new Map;for(let n of e){let e=(r.get(n.name)??0)+1;if(r.set(n.name,e),e===2)throw new t(`plugin`,n.name,[n.name,n.name])}let i=new Map,a=[];for(let n of e)for(let e of n.commands??[]){let r=i.get(e.name);if(r)throw new t(`command`,e.name,[r,n.name]);i.set(e.name,n.name),a.push(e)}let o=new Set(n.map(e=>e.name)),s=[...a.filter(e=>!o.has(e.name)),...n],c=new Map,l=[];for(let n of e)for(let e of n.typegens??[]){let r=c.get(e.id);if(r)throw new t(`typegen`,e.id,[r,n.name]);c.set(e.id,n.name),l.push(e)}let u=new Map,d=[];for(let n of e)for(let e of n.generators??[]){let r=u.get(e.name);if(r)throw new t(`generator`,e.name,[r,n.name]);u.set(e.name,n.name),d.push({source:n.name,spec:e})}return{commands:s,typegens:l,generators:d,register:async(t,n)=>{let r;if(n)r={generators:d,...n};else{let{findProjectRoot:e}=await import(`./project-root-Dv1HfN0o.mjs`).then(e=>e.n),t=process.cwd();r={cwd:t,projectRoot:e(t),config:null,log:()=>{},generators:d}}for(let n of e)n.register&&await n.register(t,r)}}}var i=e({mergeCliPlugins:()=>r});export{r as n,n as r,i as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v6.
|
|
2
|
+
* @forinda/kickjs-cli v6.9.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as e}from"./rolldown-runtime-
|
|
12
|
-
//# sourceMappingURL=plugin-
|
|
11
|
+
import{t as e}from"./rolldown-runtime-DnEcvn06.mjs";import{t}from"./types-Dfg3zods.mjs";function n(e,n=[]){let r=new Map;for(let n of e){let e=(r.get(n.name)??0)+1;if(r.set(n.name,e),e===2)throw new t(`plugin`,n.name,[n.name,n.name])}let i=new Map,a=[];for(let n of e)for(let e of n.commands??[]){let r=i.get(e.name);if(r)throw new t(`command`,e.name,[r,n.name]);i.set(e.name,n.name),a.push(e)}let o=new Set(n.map(e=>e.name)),s=[...a.filter(e=>!o.has(e.name)),...n],c=new Map,l=[];for(let n of e)for(let e of n.typegens??[]){let r=c.get(e.id);if(r)throw new t(`typegen`,e.id,[r,n.name]);c.set(e.id,n.name),l.push(e)}let u=new Map,d=[];for(let n of e)for(let e of n.generators??[]){let r=u.get(e.name);if(r)throw new t(`generator`,e.name,[r,n.name]);u.set(e.name,n.name),d.push({source:n.name,spec:e})}return{commands:s,typegens:l,generators:d,register:async(t,n)=>{let r;if(n)r={generators:d,...n};else{let{findProjectRoot:e}=await import(`./project-root-BNYhLr1o.mjs`).then(e=>e.n),t=process.cwd();r={cwd:t,projectRoot:e(t),config:null,log:()=>{},generators:d}}for(let n of e)n.register&&await n.register(t,r)}}}var r=e({mergeCliPlugins:()=>n});export{n,r as t};
|
|
12
|
+
//# sourceMappingURL=plugin-qwSg0kwT.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-
|
|
1
|
+
{"version":3,"file":"plugin-qwSg0kwT.mjs","names":[],"sources":["../src/plugin/merge.ts","../src/plugin/index.ts"],"sourcesContent":["// Plugin → unified registry merge.\n//\n// Resolution rules (per the v1 spec + dogfood pivot):\n// - duplicate plugin `name` across the input array → conflict error.\n// Catches the double-install case (built-in shipped twice, or\n// adopter requiring the same plugin twice).\n// - plugin commands appear first in the merged list, then adopter\n// commands; adopter `commands` of the same name override the\n// plugin entry (filter pass).\n// - duplicate command name across two plugins → conflict error\n// listing both plugin names. Adopter overriding a plugin is\n// allowed and not an error.\n// - duplicate typegen id across two plugins → same error. Typegens\n// have no adopter override path; only plugins contribute them.\n// - register() functions are collected in input order; the caller\n// invokes each one against the same Command program. They have no\n// id-level conflict surface — owners are responsible for picking\n// non-colliding command names inside their own register().\n// - plugin order = array order. No implicit precedence rules.\n\nimport type { Command } from 'commander'\n\nimport type { KickCommandDefinition } from '../config'\nimport type { TypegenPlugin } from '../typegen/plugin'\nimport type { GeneratorSpec } from '../generator-extension/define'\nimport type { DiscoveredGenerator } from '../generator-extension/discover'\nimport { KickPluginConflictError, type KickCliPlugin, type KickCliPluginContext } from './types'\n\nexport interface MergedPlugins {\n commands: KickCommandDefinition[]\n typegens: TypegenPlugin[]\n /** DiscoveredGenerator shape so this list slots into the existing\n * dispatch path next to package.json-discovered entries. `source`\n * carries the plugin name for error attribution. */\n generators: DiscoveredGenerator[]\n /**\n * Apply every plugin's register() in input order. ctx is optional so\n * tests + lightweight callers can invoke `register(program)` without\n * constructing a full context; it falls back to cwd=process.cwd(),\n * config=null, log=no-op.\n */\n register: (program: Command, ctx?: KickCliPluginContext) => Promise<void>\n}\n\nexport function mergeCliPlugins(\n plugins: readonly KickCliPlugin[],\n adopterCommands: readonly KickCommandDefinition[] = [],\n): MergedPlugins {\n // Plugin-name dedup — catches double-install.\n const seenPluginNames = new Map<string, number>()\n for (const p of plugins) {\n const count = (seenPluginNames.get(p.name) ?? 0) + 1\n seenPluginNames.set(p.name, count)\n if (count === 2) {\n throw new KickPluginConflictError('plugin', p.name, [p.name, p.name])\n }\n }\n\n const commandOwners = new Map<string, string>()\n const pluginCommands: KickCommandDefinition[] = []\n for (const p of plugins) {\n for (const cmd of p.commands ?? []) {\n const prior = commandOwners.get(cmd.name)\n if (prior) {\n throw new KickPluginConflictError('command', cmd.name, [prior, p.name])\n }\n commandOwners.set(cmd.name, p.name)\n pluginCommands.push(cmd)\n }\n }\n\n const adopterNames = new Set(adopterCommands.map((c) => c.name))\n const filteredPlugin = pluginCommands.filter((c) => !adopterNames.has(c.name))\n const commands = [...filteredPlugin, ...adopterCommands]\n\n const typegenOwners = new Map<string, string>()\n const typegens: TypegenPlugin[] = []\n for (const p of plugins) {\n for (const tg of p.typegens ?? []) {\n const prior = typegenOwners.get(tg.id)\n if (prior) {\n throw new KickPluginConflictError('typegen', tg.id, [prior, p.name])\n }\n typegenOwners.set(tg.id, p.name)\n typegens.push(tg)\n }\n }\n\n const generatorOwners = new Map<string, string>()\n const generators: DiscoveredGenerator[] = []\n for (const p of plugins) {\n for (const spec of p.generators ?? []) {\n const prior = generatorOwners.get(spec.name)\n if (prior) {\n throw new KickPluginConflictError('generator', spec.name, [prior, p.name])\n }\n generatorOwners.set(spec.name, p.name)\n generators.push({ source: p.name, spec: spec satisfies GeneratorSpec })\n }\n }\n\n /**\n * Apply every plugin's `register()` callback in input order against the\n * given Commander program. Each callback receives a {@link KickCliPluginContext}:\n * caller-supplied ctx wins (test fixtures can inject a different\n * workspace boundary); otherwise a default ctx is built with\n * `findProjectRoot(process.cwd())` as the project root, `cwd` matching\n * `process.cwd()`, null config, no-op log, and the merged generator set\n * threaded through so the `kick/generate` built-in can surface each as\n * a Commander subcommand. The dynamic import of `findProjectRoot` keeps\n * the caller-supplied fast path zero-cost.\n */\n const register = async (program: Command, ctx?: KickCliPluginContext): Promise<void> => {\n let resolved: KickCliPluginContext\n if (ctx) {\n resolved = { generators, ...ctx }\n } else {\n const { findProjectRoot } = await import('../utils/project-root')\n const cwd = process.cwd()\n resolved = {\n cwd,\n projectRoot: findProjectRoot(cwd),\n config: null,\n log: () => {},\n generators,\n }\n }\n for (const p of plugins) {\n if (p.register) await p.register(program, resolved)\n }\n }\n\n return { commands, typegens, generators, register }\n}\n","// Barrel intentionally omits `./builtins` — that module top-level-imports\n// every register*Command, which pulls heavy modules (project scaffolders,\n// fs reads at import time) into the graph. Importers that need the\n// builtin list go through `./plugin/builtins` directly; tests + adopter\n// plugins consuming only the contract types import from here.\n\nexport type { KickCliPlugin } from './types'\nexport { defineCliPlugin, KickPluginConflictError } from './types'\nexport { mergeCliPlugins, type MergedPlugins } from './merge'\n"],"mappings":";;;;;;;;;;wFA4CA,SAAgB,EACd,EACA,EAAoD,CAAC,EACtC,CAEf,IAAM,EAAkB,IAAI,IAC5B,IAAK,IAAM,KAAK,EAAS,CACvB,IAAM,GAAS,EAAgB,IAAI,EAAE,IAAI,GAAK,GAAK,EAEnD,GADA,EAAgB,IAAI,EAAE,KAAM,CAAK,EAC7B,IAAU,EACZ,MAAM,IAAI,EAAwB,SAAU,EAAE,KAAM,CAAC,EAAE,KAAM,EAAE,IAAI,CAAC,CAExE,CAEA,IAAM,EAAgB,IAAI,IACpB,EAA0C,CAAC,EACjD,IAAK,IAAM,KAAK,EACd,IAAK,IAAM,KAAO,EAAE,UAAY,CAAC,EAAG,CAClC,IAAM,EAAQ,EAAc,IAAI,EAAI,IAAI,EACxC,GAAI,EACF,MAAM,IAAI,EAAwB,UAAW,EAAI,KAAM,CAAC,EAAO,EAAE,IAAI,CAAC,EAExE,EAAc,IAAI,EAAI,KAAM,EAAE,IAAI,EAClC,EAAe,KAAK,CAAG,CACzB,CAGF,IAAM,EAAe,IAAI,IAAI,EAAgB,IAAK,GAAM,EAAE,IAAI,CAAC,EAEzD,EAAW,CAAC,GADK,EAAe,OAAQ,GAAM,CAAC,EAAa,IAAI,EAAE,IAAI,CAC1C,EAAG,GAAG,CAAe,EAEjD,EAAgB,IAAI,IACpB,EAA4B,CAAC,EACnC,IAAK,IAAM,KAAK,EACd,IAAK,IAAM,KAAM,EAAE,UAAY,CAAC,EAAG,CACjC,IAAM,EAAQ,EAAc,IAAI,EAAG,EAAE,EACrC,GAAI,EACF,MAAM,IAAI,EAAwB,UAAW,EAAG,GAAI,CAAC,EAAO,EAAE,IAAI,CAAC,EAErE,EAAc,IAAI,EAAG,GAAI,EAAE,IAAI,EAC/B,EAAS,KAAK,CAAE,CAClB,CAGF,IAAM,EAAkB,IAAI,IACtB,EAAoC,CAAC,EAC3C,IAAK,IAAM,KAAK,EACd,IAAK,IAAM,KAAQ,EAAE,YAAc,CAAC,EAAG,CACrC,IAAM,EAAQ,EAAgB,IAAI,EAAK,IAAI,EAC3C,GAAI,EACF,MAAM,IAAI,EAAwB,YAAa,EAAK,KAAM,CAAC,EAAO,EAAE,IAAI,CAAC,EAE3E,EAAgB,IAAI,EAAK,KAAM,EAAE,IAAI,EACrC,EAAW,KAAK,CAAE,OAAQ,EAAE,KAAY,MAA6B,CAAC,CACxE,CAkCF,MAAO,CAAE,WAAU,WAAU,aAAY,eApBjB,EAAkB,IAA8C,CACtF,IAAI,EACJ,GAAI,EACF,EAAW,CAAE,aAAY,GAAG,CAAI,MAC3B,CACL,GAAM,CAAE,mBAAoB,MAAM,OAAO,8BAAwB,CAAA,KAAA,GAAA,EAAA,CAAA,EAC3D,EAAM,QAAQ,IAAI,EACxB,EAAW,CACT,MACA,YAAa,EAAgB,CAAG,EAChC,OAAQ,KACR,QAAW,CAAC,EACZ,YACF,CACF,CACA,IAAK,IAAM,KAAK,EACV,EAAE,UAAU,MAAM,EAAE,SAAS,EAAS,CAAQ,CAEtD,CAEkD,CACpD"}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs-cli v6.9.1
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Felix Orinda
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import{r as e,t}from"./config-DzcY7KDb.mjs";import{l as n,o as r}from"./project-docs-DG-aI5f_.mjs";import{existsSync as i,readFileSync as a}from"node:fs";import{dirname as o,join as s,resolve as c}from"node:path";import{fileURLToPath as l}from"node:url";import{execFileSync as u,execSync as d}from"node:child_process";const f={swagger:`@forinda/kickjs-swagger`,ws:`@forinda/kickjs-ws`,queue:`@forinda/kickjs-queue`,devtools:`@forinda/kickjs-devtools`},p={zod:{name:`zod`,range:`^4.3.6`},valibot:{name:`valibot`,range:`^1.4.1`},yup:{name:`yup`,range:`^1.7.1`}};function m(e,t){let n=e[t];if(!n)throw Error(`generatePackageJson: missing resolved version for ${t}. Add it to SIBLING_PACKAGES in generators/project.ts.`);return n}function h(e,t,n,r=[],i=`zod`,a=`express`){let o=p[i],s={"@forinda/kickjs":m(n,`@forinda/kickjs`),"@forinda/kickjs-schema":m(n,`@forinda/kickjs-schema`),dotenv:`^17.3.1`,"reflect-metadata":`^0.2.2`,[o.name]:o.range};a===`express`?s.express=`^5.1.0`:a===`fastify`?(s.fastify=`^5.0.0`,s[`@fastify/middie`]=`^9.0.0`,s[`serve-static`]=`^2.2.0`):a===`h3`&&(s.h3=`^1.0.0`,s[`serve-static`]=`^2.2.0`);for(let e of r){let t=f[e];t&&!s[t]&&(s[t]=m(n,t))}return JSON.stringify({name:e,version:`0.0.0`,type:`module`,scripts:{dev:`kick dev`,"dev:debug":`kick dev:debug`,build:`kick build`,start:`kick start`,test:`vitest run`,"test:watch":`vitest`,typecheck:`tsc --noEmit`,typegen:`kick typegen`,lint:`eslint src/`,format:`prettier --write src/`},dependencies:s,devDependencies:{"@forinda/kickjs-cli":m(n,`@forinda/kickjs-cli`),"@forinda/kickjs-vite":m(n,`@forinda/kickjs-vite`),"@swc/core":`^1.15.21`,...a===`express`?{"@types/express":`^5.0.6`}:{},"@types/node":`^25.0.0`,"unplugin-swc":`^1.5.9`,vite:`^8.0.3`,vitest:`^4.1.2`,typescript:`^7.0.2`,prettier:`^3.8.1`}},null,2)}function g(){return`import { defineConfig } from 'vite'
|
|
12
|
+
import { resolve } from 'node:path'
|
|
13
|
+
import swc from 'unplugin-swc'
|
|
14
|
+
import { kickjsVitePlugin, envWatchPlugin } from '@forinda/kickjs-vite'
|
|
15
|
+
|
|
16
|
+
export default defineConfig({
|
|
17
|
+
oxc: false,
|
|
18
|
+
plugins: [
|
|
19
|
+
swc.vite(),
|
|
20
|
+
kickjsVitePlugin({ entry: 'src/index.ts' }),
|
|
21
|
+
// Watches .env files and triggers a full reload on change so the
|
|
22
|
+
// dev server picks up env tweaks without a manual restart.
|
|
23
|
+
envWatchPlugin(),
|
|
24
|
+
],
|
|
25
|
+
resolve: {
|
|
26
|
+
alias: {
|
|
27
|
+
'@': resolve(__dirname, 'src'),
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
build: {
|
|
31
|
+
target: 'node20',
|
|
32
|
+
ssr: true,
|
|
33
|
+
outDir: 'dist',
|
|
34
|
+
sourcemap: true,
|
|
35
|
+
rollupOptions: {
|
|
36
|
+
input: resolve(__dirname, 'src/index.ts'),
|
|
37
|
+
output: { format: 'esm' },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
`}function _(){return JSON.stringify({compilerOptions:{target:`ES2022`,module:`ESNext`,moduleResolution:`bundler`,lib:[`ES2022`],types:[`node`,`vite/client`],strict:!0,esModuleInterop:!0,skipLibCheck:!0,sourceMap:!0,declaration:!0,experimentalDecorators:!0,emitDecoratorMetadata:!0,outDir:`dist`,paths:{"@/*":[`./src/*`]}},include:[`src`,`.kickjs/types/**/*.d.ts`,`.kickjs/types/**/*.ts`]},null,2)}function v(){return JSON.stringify({semi:!1,singleQuote:!0,trailingComma:`all`,printWidth:100,tabWidth:2},null,2)}function y(){return`# https://editorconfig.org
|
|
42
|
+
root = true
|
|
43
|
+
|
|
44
|
+
[*]
|
|
45
|
+
indent_style = space
|
|
46
|
+
indent_size = 2
|
|
47
|
+
end_of_line = lf
|
|
48
|
+
charset = utf-8
|
|
49
|
+
trim_trailing_whitespace = true
|
|
50
|
+
insert_final_newline = true
|
|
51
|
+
|
|
52
|
+
[*.md]
|
|
53
|
+
trim_trailing_whitespace = false
|
|
54
|
+
`}function b(){return`node_modules/
|
|
55
|
+
dist/
|
|
56
|
+
.env
|
|
57
|
+
coverage/
|
|
58
|
+
.DS_Store
|
|
59
|
+
*.tsbuildinfo
|
|
60
|
+
.kickjs/
|
|
61
|
+
`}function x(){return`# Auto-detect text files and normalise line endings to LF
|
|
62
|
+
* text=auto eol=lf
|
|
63
|
+
|
|
64
|
+
# Explicitly mark generated / binary files
|
|
65
|
+
*.png binary
|
|
66
|
+
*.jpg binary
|
|
67
|
+
*.jpeg binary
|
|
68
|
+
*.gif binary
|
|
69
|
+
*.ico binary
|
|
70
|
+
*.woff binary
|
|
71
|
+
*.woff2 binary
|
|
72
|
+
*.ttf binary
|
|
73
|
+
*.eot binary
|
|
74
|
+
|
|
75
|
+
# Lock files — treat as generated
|
|
76
|
+
pnpm-lock.yaml -diff linguist-generated
|
|
77
|
+
yarn.lock -diff linguist-generated
|
|
78
|
+
package-lock.json -diff linguist-generated
|
|
79
|
+
`}function S(){return`PORT=3000
|
|
80
|
+
NODE_ENV=development
|
|
81
|
+
`}function C(){return`PORT=3000
|
|
82
|
+
NODE_ENV=development
|
|
83
|
+
`}function w(){return`import { defineConfig } from 'vitest/config'
|
|
84
|
+
import swc from 'unplugin-swc'
|
|
85
|
+
|
|
86
|
+
export default defineConfig({
|
|
87
|
+
plugins: [swc.vite()],
|
|
88
|
+
test: {
|
|
89
|
+
globals: true,
|
|
90
|
+
environment: 'node',
|
|
91
|
+
include: ['src/**/*.test.ts'],
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
`}const T={express:{from:`@forinda/kickjs`,name:`expressRuntime`},fastify:{from:`@forinda/kickjs/fastify`,name:`fastifyRuntime`},h3:{from:`@forinda/kickjs/h3`,name:`h3Runtime`}};function E(e,t,n,r=[],i=`express`){let a=T[i],o=i===`express`;switch(t){case`minimal`:{let t=[],i=[],s=o?`import { bootstrap, ${a.name} } from '@forinda/kickjs'`:`import { bootstrap } from '@forinda/kickjs'\nimport { ${a.name} } from '${a.from}'`;r.includes(`swagger`)&&(t.push(`import { SwaggerAdapter } from '@forinda/kickjs-swagger'`),i.push(` SwaggerAdapter({ info: { title: '${e}', version: '${n}' } }),`)),r.includes(`devtools`)&&(t.push(`import { DevToolsAdapter } from '@forinda/kickjs-devtools'`),i.push(` DevToolsAdapter(),`));let c=t.length?t.join(`
|
|
95
|
+
`)+`
|
|
96
|
+
`:``,l=i.length?`,\n adapters: [\n${i.join(`
|
|
97
|
+
`)}\n ]`:``;return`import 'reflect-metadata'
|
|
98
|
+
// Side-effect import — registers the extended env schema with kickjs
|
|
99
|
+
// **before** any controller / service / @Value gets resolved. Without
|
|
100
|
+
// this line ConfigService.get('YOUR_KEY') returns undefined because the
|
|
101
|
+
// cached schema would still be the base shape. See guide/configuration.
|
|
102
|
+
import './config'
|
|
103
|
+
${s}
|
|
104
|
+
${c}import { modules } from './modules'
|
|
105
|
+
|
|
106
|
+
// Export the app for the Vite plugin (dev mode)
|
|
107
|
+
export const app = await bootstrap({ modules, runtime: ${a.name}()${l} })
|
|
108
|
+
`}default:{let t=[],i=[];r.includes(`devtools`)&&(t.push(`import { DevToolsAdapter } from '@forinda/kickjs-devtools'`),i.push(` DevToolsAdapter(),`)),r.includes(`swagger`)&&(t.push(`import { SwaggerAdapter } from '@forinda/kickjs-swagger'`),i.push(` SwaggerAdapter({\n info: { title: '${e}', version: '${n}' },\n }),`));let s=t.length?t.join(`
|
|
109
|
+
`)+`
|
|
110
|
+
`:``,c=i.length?`\n adapters: [\n${i.join(`
|
|
111
|
+
`)}\n ],`:``,l=[`bootstrap`,`requestId`,`requestLogger`,`helmet`,`cors`];o&&l.push(a.name);let u=o?`import express from 'express'\nimport {\n ${l.join(`,
|
|
112
|
+
`)},\n} from '@forinda/kickjs'`:`import {\n ${l.join(`,
|
|
113
|
+
`)},\n} from '@forinda/kickjs'\nimport { ${a.name} } from '${a.from}'`,d=o?`
|
|
114
|
+
express.json(),`:``;return`import 'reflect-metadata'
|
|
115
|
+
// Side-effect import — registers the extended env schema with kickjs
|
|
116
|
+
// **before** any controller / service / @Value gets resolved. Without
|
|
117
|
+
// this line ConfigService.get('YOUR_KEY') returns undefined because the
|
|
118
|
+
// cached schema would still be the base shape. See guide/configuration.
|
|
119
|
+
import './config'
|
|
120
|
+
${u}
|
|
121
|
+
${s}import { modules } from './modules'
|
|
122
|
+
|
|
123
|
+
// Export the app for the Vite plugin (dev mode)
|
|
124
|
+
export const app = await bootstrap({
|
|
125
|
+
modules,
|
|
126
|
+
runtime: ${a.name}(),${c}
|
|
127
|
+
middleware: [
|
|
128
|
+
helmet(),
|
|
129
|
+
cors({ origin: '*' }),
|
|
130
|
+
requestId(),
|
|
131
|
+
requestLogger(),${d}
|
|
132
|
+
],
|
|
133
|
+
})
|
|
134
|
+
`}}}function D(){return`import { defineModules } from '@forinda/kickjs'
|
|
135
|
+
import { HelloModule } from './hello/hello.module'
|
|
136
|
+
|
|
137
|
+
// Remove HelloModule and run: kick g module <name>
|
|
138
|
+
// \`defineModules()\` returns a chainable list — \`kick g module\` appends
|
|
139
|
+
// \`.mount(NewModule())\` to the chain on every generation.
|
|
140
|
+
export const modules = defineModules().mount(HelloModule())
|
|
141
|
+
`}function O(e=`zod`){return e===`valibot`?`import { loadEnvFromSchema } from '@forinda/kickjs/config'
|
|
142
|
+
import { fromValibot } from '@forinda/kickjs-schema/valibot'
|
|
143
|
+
import * as v from 'valibot'
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Project environment schema (Valibot).
|
|
147
|
+
*
|
|
148
|
+
* \`fromValibot\` wraps the Valibot schema as a \`KickSchema\` so the
|
|
149
|
+
* env loader, validate middleware, and swagger spec generator all see
|
|
150
|
+
* the same shape. The default export is the contract \`kick typegen\`
|
|
151
|
+
* reads to populate \`KickEnv\` via \`InferSchemaOutput<typeof _envSchema>\`
|
|
152
|
+
* — that's what makes \`@Value('FOO')\` autocomplete and
|
|
153
|
+
* \`process.env.FOO\` typed.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* DATABASE_URL: v.pipe(v.string(), v.url()),
|
|
157
|
+
* JWT_SECRET: v.pipe(v.string(), v.minLength(32)),
|
|
158
|
+
* REDIS_URL: v.optional(v.pipe(v.string(), v.url())),
|
|
159
|
+
*/
|
|
160
|
+
const envSchema = fromValibot(
|
|
161
|
+
v.object({
|
|
162
|
+
PORT: v.optional(v.pipe(v.string(), v.transform(Number)), '3000'),
|
|
163
|
+
NODE_ENV: v.optional(v.picklist(['development', 'production', 'test']), 'development'),
|
|
164
|
+
LOG_LEVEL: v.optional(v.string(), 'info'),
|
|
165
|
+
// DATABASE_URL: v.pipe(v.string(), v.url()),
|
|
166
|
+
}),
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* IMPORTANT — side effect: register the schema with kickjs's env cache
|
|
171
|
+
* **at module-load time**. \`ConfigService\` and \`@Value()\` both consume
|
|
172
|
+
* this cache, and they will fall back to the base schema (or undefined)
|
|
173
|
+
* if no extended schema has been registered before they're resolved.
|
|
174
|
+
*
|
|
175
|
+
* As long as \`src/index.ts\` imports this file (\`import './config'\`) at
|
|
176
|
+
* the top — before \`bootstrap()\` runs — every controller and service
|
|
177
|
+
* in the app sees the typed extended values.
|
|
178
|
+
*/
|
|
179
|
+
export const env = loadEnvFromSchema(envSchema)
|
|
180
|
+
|
|
181
|
+
export default envSchema
|
|
182
|
+
`:e===`yup`?`import { loadEnvFromSchema } from '@forinda/kickjs/config'
|
|
183
|
+
import { fromYup } from '@forinda/kickjs-schema/yup'
|
|
184
|
+
import * as yup from 'yup'
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Project environment schema (Yup).
|
|
188
|
+
*
|
|
189
|
+
* \`fromYup\` wraps the Yup schema as a \`KickSchema\` so the env loader,
|
|
190
|
+
* validate middleware, and swagger spec generator all see the same
|
|
191
|
+
* shape. The default export is the contract \`kick typegen\` reads to
|
|
192
|
+
* populate \`KickEnv\` via \`InferSchemaOutput<typeof _envSchema>\`.
|
|
193
|
+
*
|
|
194
|
+
* Note: Yup's \`.url()\` defaults to http/https; database connection
|
|
195
|
+
* strings like \`postgres://\` use \`.matches(/^[a-z]+:\\/\\/.+/i)\` or
|
|
196
|
+
* a plain \`.string().required()\`.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* DATABASE_URL: yup.string().required(),
|
|
200
|
+
* JWT_SECRET: yup.string().min(32).required(),
|
|
201
|
+
* REDIS_URL: yup.string().url().optional(),
|
|
202
|
+
*/
|
|
203
|
+
const envSchema = fromYup(
|
|
204
|
+
yup.object({
|
|
205
|
+
PORT: yup.number().default(3000),
|
|
206
|
+
NODE_ENV: yup
|
|
207
|
+
.string()
|
|
208
|
+
.oneOf(['development', 'production', 'test'])
|
|
209
|
+
.default('development'),
|
|
210
|
+
LOG_LEVEL: yup.string().default('info'),
|
|
211
|
+
// DATABASE_URL: yup.string().required(),
|
|
212
|
+
}),
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* IMPORTANT — side effect: register the schema with kickjs's env cache
|
|
217
|
+
* **at module-load time**. \`ConfigService\` and \`@Value()\` both consume
|
|
218
|
+
* this cache, and they will fall back to the base schema (or undefined)
|
|
219
|
+
* if no extended schema has been registered before they're resolved.
|
|
220
|
+
*
|
|
221
|
+
* As long as \`src/index.ts\` imports this file (\`import './config'\`) at
|
|
222
|
+
* the top — before \`bootstrap()\` runs — every controller and service
|
|
223
|
+
* in the app sees the typed extended values.
|
|
224
|
+
*/
|
|
225
|
+
export const env = loadEnvFromSchema(envSchema)
|
|
226
|
+
|
|
227
|
+
export default envSchema
|
|
228
|
+
`:`import { loadEnvFromSchema } from '@forinda/kickjs/config'
|
|
229
|
+
import { fromZod } from '@forinda/kickjs-schema/zod'
|
|
230
|
+
import { z } from 'zod'
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Project environment schema (Zod).
|
|
234
|
+
*
|
|
235
|
+
* \`fromZod\` wraps the Zod schema as a \`KickSchema\` so the env loader,
|
|
236
|
+
* validate middleware, and swagger spec generator all see the same
|
|
237
|
+
* shape. The default export is the contract \`kick typegen\` reads to
|
|
238
|
+
* populate \`KickEnv\` via \`InferSchemaOutput<typeof _envSchema>\` —
|
|
239
|
+
* that's what makes \`@Value('FOO')\` autocomplete and
|
|
240
|
+
* \`process.env.FOO\` typed.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* DATABASE_URL: z.string().url(),
|
|
244
|
+
* JWT_SECRET: z.string().min(32),
|
|
245
|
+
* REDIS_URL: z.string().url().optional(),
|
|
246
|
+
*/
|
|
247
|
+
const envSchema = fromZod(
|
|
248
|
+
z.object({
|
|
249
|
+
PORT: z.coerce.number().default(3000),
|
|
250
|
+
NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
|
|
251
|
+
LOG_LEVEL: z.string().default('info'),
|
|
252
|
+
// DATABASE_URL: z.string().url(),
|
|
253
|
+
}),
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* IMPORTANT — side effect: register the schema with kickjs's env cache
|
|
258
|
+
* **at module-load time**. \`ConfigService\` and \`@Value()\` both consume
|
|
259
|
+
* this cache, and they will fall back to the base schema (or undefined)
|
|
260
|
+
* if no extended schema has been registered before they're resolved.
|
|
261
|
+
*
|
|
262
|
+
* As long as \`src/index.ts\` imports this file (\`import './config'\`) at
|
|
263
|
+
* the top — before \`bootstrap()\` runs — every controller and service
|
|
264
|
+
* in the app sees the typed extended values.
|
|
265
|
+
*/
|
|
266
|
+
export const env = loadEnvFromSchema(envSchema)
|
|
267
|
+
|
|
268
|
+
export default envSchema
|
|
269
|
+
`}function k(){return`import { Service } from '@forinda/kickjs'
|
|
270
|
+
|
|
271
|
+
@Service()
|
|
272
|
+
export class HelloService {
|
|
273
|
+
greet(name: string) {
|
|
274
|
+
return { message: \`Hello \${name} from KickJS!\`, timestamp: new Date().toISOString() }
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
healthCheck() {
|
|
278
|
+
return { status: 'ok', uptime: process.uptime() }
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
`}function A(){return`import { Controller, Get, Autowired, type Ctx } from '@forinda/kickjs'
|
|
282
|
+
import { HelloService } from './hello.service'
|
|
283
|
+
|
|
284
|
+
// \`Ctx<KickRoutes.HelloController['<method>']>\` is generated by
|
|
285
|
+
// \`kick typegen\` (auto-run on \`kick dev\`). The first run after a fresh
|
|
286
|
+
// scaffold creates \`.kickjs/types/routes.ts\` so this file typechecks.
|
|
287
|
+
// See https://kickjs.app/guide/typegen.
|
|
288
|
+
|
|
289
|
+
@Controller()
|
|
290
|
+
export class HelloController {
|
|
291
|
+
@Autowired() private readonly helloService!: HelloService
|
|
292
|
+
|
|
293
|
+
// Return-value handlers: the runtime sends the returned payload as
|
|
294
|
+
// 200 json, and \`kick typegen\` infers the response type into
|
|
295
|
+
// \`KickRoutes.Api\` — which is what makes the typed client
|
|
296
|
+
// (@forinda/kickjs-client) end-to-end type-safe.
|
|
297
|
+
@Get('/')
|
|
298
|
+
index(_ctx: Ctx<KickRoutes.HelloController['index']>) {
|
|
299
|
+
return this.helloService.greet('World')
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
@Get('/health')
|
|
303
|
+
health(_ctx: Ctx<KickRoutes.HelloController['health']>) {
|
|
304
|
+
return this.helloService.healthCheck()
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
`}function j(){return`import { defineModule } from '@forinda/kickjs'
|
|
308
|
+
import { HelloController } from './hello.controller'
|
|
309
|
+
|
|
310
|
+
export const HelloModule = defineModule({
|
|
311
|
+
name: 'HelloModule',
|
|
312
|
+
build: () => ({
|
|
313
|
+
// \`register(container)\` is optional — only implement it when you need
|
|
314
|
+
// to bind a token to a concrete implementation, e.g.
|
|
315
|
+
// register(container) {
|
|
316
|
+
// container.registerFactory(USER_REPOSITORY, () => container.resolve(InMemoryUserRepository))
|
|
317
|
+
// }
|
|
318
|
+
// The HelloService uses @Service() so the decorator handles registration.
|
|
319
|
+
|
|
320
|
+
routes() {
|
|
321
|
+
return {
|
|
322
|
+
path: '/hello',
|
|
323
|
+
controller: HelloController,
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
}),
|
|
327
|
+
})
|
|
328
|
+
`}function M(e,t=`inmemory`,n=`pnpm`,r=`express`){return`import { defineConfig } from '@forinda/kickjs-cli'
|
|
329
|
+
|
|
330
|
+
export default defineConfig({
|
|
331
|
+
pattern: '${e}',
|
|
332
|
+
// The HTTP engine this app boots on (matches \`bootstrap({ runtime })\` in
|
|
333
|
+
// src/index.ts). Dep-aware commands read it: \`kick add upload\` installs the
|
|
334
|
+
// engine's multipart driver, \`kick doctor\` checks the engine peers, and
|
|
335
|
+
// \`kick typegen\` flips the runtime escape-hatch types to this engine.
|
|
336
|
+
runtime: '${r}',
|
|
337
|
+
// Pinned so \`kick add\` and other dep-installing commands always use the
|
|
338
|
+
// project's intended package manager, regardless of which lockfile exists.
|
|
339
|
+
packageManager: '${n}',
|
|
340
|
+
modules: {
|
|
341
|
+
dir: 'src/modules',
|
|
342
|
+
repo: ${t===`inmemory`?`'inmemory'`:`{ name: '${t}' }`},
|
|
343
|
+
pluralize: true,
|
|
344
|
+
},
|
|
345
|
+
|
|
346
|
+
// \`kick typegen\` populates \`.kickjs/types/\` so \`Ctx<KickRoutes.X['method']>\`
|
|
347
|
+
// resolves to fully-typed params/body/query. Auto-runs on \`kick dev\`.
|
|
348
|
+
// \`'kickjs-schema'\` routes inference through \`InferSchemaOutput\` so the
|
|
349
|
+
// typegen works for any wrapped schema (Zod / Valibot / Yup). Switch
|
|
350
|
+
// to \`'zod'\` if you ship Zod schemas without \`fromZod()\` wrapping, or
|
|
351
|
+
// set \`schemaValidator: false\` to skip schema-driven body typing.
|
|
352
|
+
typegen: {
|
|
353
|
+
schemaValidator: 'kickjs-schema',
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
commands: [
|
|
357
|
+
{
|
|
358
|
+
name: 'test',
|
|
359
|
+
description: 'Run tests with Vitest',
|
|
360
|
+
steps: 'npx vitest run',
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: 'format',
|
|
364
|
+
description: 'Format code with Prettier',
|
|
365
|
+
steps: 'npx prettier --write src/',
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
name: 'format:check',
|
|
369
|
+
description: 'Check formatting without writing',
|
|
370
|
+
steps: 'npx prettier --check src/',
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
name: 'ci:check',
|
|
374
|
+
description: 'Run typecheck + format check',
|
|
375
|
+
steps: ['npx tsc --noEmit', 'npx prettier --check src/'],
|
|
376
|
+
aliases: ['verify'],
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
})
|
|
380
|
+
`}const N={kickjs:{pkg:`@forinda/kickjs`,peers:[`express`],description:`Unified framework: DI, decorators, routing, middleware`,core:!0},vite:{pkg:`@forinda/kickjs-vite`,peers:[`vite`],description:`Vite plugin: dev server, HMR, module discovery`,dev:!0,core:!0},cli:{pkg:`@forinda/kickjs-cli`,peers:[],description:`CLI tool and code generators`,dev:!0,core:!0},zod:{pkg:`zod`,peers:[],description:`Zod schema validation (env, DTOs, OpenAPI) — wrap with fromZod()`},valibot:{pkg:`valibot`,peers:[],description:`Valibot schema validation — wrap with fromValibot()`},yup:{pkg:`yup`,peers:[],description:`Yup schema validation — wrap with fromYup()`},auth:{pkg:`@forinda/kickjs-auth`,peers:[`jsonwebtoken`],description:`JWT, API key, OAuth strategies, @Public, @Roles (+ optional argon2/bcryptjs)`,deprecated:`auth is moving to BYO — compose @LoadAuthUser/@RequireRole/@Public from defineContextDecorator (see the BYO Auth recipe in the docs)`},ai:{pkg:`@forinda/kickjs-ai`,peers:[`zod`],description:`AI toolkit — LLM providers, tool definitions from controllers`},swagger:{pkg:`@forinda/kickjs-swagger`,peers:[],description:`OpenAPI spec + Swagger UI + ReDoc`},db:{pkg:`@forinda/kickjs-db`,peers:[],description:`kick/db core — schema DSL, migrations, KickDbClient, customType`},pg:{pkg:`@forinda/kickjs-db`,peers:[`pg`],description:`kick/db + PostgreSQL driver (use @forinda/kickjs-db/pg)`},sqlite:{pkg:`@forinda/kickjs-db`,peers:[`better-sqlite3`],description:`kick/db + SQLite driver (use @forinda/kickjs-db/sqlite)`},mysql:{pkg:`@forinda/kickjs-db`,peers:[`mysql2`],description:`kick/db + MySQL driver (use @forinda/kickjs-db/mysql)`},drizzle:{pkg:`@forinda/kickjs-drizzle`,peers:[`drizzle-orm`],description:`Drizzle ORM adapter + query builder`,deprecated:"early-adoption adapter, no longer maintained — wire Drizzle directly (BYO), or use @forinda/kickjs-db, the built-in Kick ORM (`kick add db` / pg / sqlite / mysql)"},prisma:{pkg:`@forinda/kickjs-prisma`,peers:[`@prisma/client`],description:`Prisma adapter + query builder`,deprecated:"early-adoption adapter, no longer maintained — wire Prisma directly (BYO), or use @forinda/kickjs-db, the built-in Kick ORM (`kick add db` / pg / sqlite / mysql)"},ws:{pkg:`@forinda/kickjs-ws`,peers:[`ws`],description:`WebSocket with @WsController decorators`},devtools:{pkg:`@forinda/kickjs-devtools`,peers:[],description:`Development dashboard — routes, DI, metrics, health`,dev:!0},queue:{pkg:`@forinda/kickjs-queue`,peers:[],description:`Queue adapter (BullMQ/RabbitMQ/Kafka)`},"queue:bullmq":{pkg:`@forinda/kickjs-queue`,peers:[`bullmq`,`ioredis`],description:`Queue with BullMQ + Redis`},"queue:rabbitmq":{pkg:`@forinda/kickjs-queue`,peers:[`amqplib`],description:`Queue with RabbitMQ`},"queue:kafka":{pkg:`@forinda/kickjs-queue`,peers:[`kafkajs`],description:`Queue with Kafka`},"queue:redis-pubsub":{pkg:`@forinda/kickjs-queue`,peers:[`ioredis`],description:`Lightweight pub/sub via Redis (no persistence)`},mcp:{pkg:`@forinda/kickjs-mcp`,peers:[`@modelcontextprotocol/sdk`],description:`Model Context Protocol server — expose @Controller endpoints as AI tools`},testing:{pkg:`@forinda/kickjs-testing`,peers:[],description:`Test utilities and TestModule builder`,dev:!0}},P=Object.entries(N).filter(([e,t])=>!t.core&&!t.deprecated&&!e.includes(`:`)&&![`pg`,`sqlite`,`mysql`,`zod`,`valibot`,`yup`].includes(e)).map(([e])=>e).join(`, `),F={express:{prod:`multer`,dev:`@types/multer`,note:`Express uploads use multer (memory/disk storage, ctx.file / ctx.files).`},fastify:{prod:`@fastify/multipart`,note:`Fastify uploads use @fastify/multipart (buffered into ctx.file / ctx.files).`},h3:{note:`h3 parses multipart natively (readMultipartFormData) — no driver to install.`}};async function I(t=process.cwd()){let n=(await e(t))?.runtime;return n===`express`||n===`fastify`||n===`h3`?n:L(t)}function L(e=process.cwd()){let t=R(`package.json`,e);if(t)try{let e=JSON.parse(a(c(t,`package.json`),`utf-8`)),n={...e.dependencies,...e.devDependencies};if(`fastify`in n)return`fastify`;if(`h3`in n)return`h3`}catch{}return`express`}function R(e,t=process.cwd()){let n=t;for(;;){if(i(c(n,e)))return n;let t=o(n);if(t===n)return null;n=t}}function z(){return R(`pnpm-lock.yaml`)?`pnpm`:R(`yarn.lock`)?`yarn`:R(`bun.lockb`)||R(`bun.lock`)?`bun`:R(`package-lock.json`)?`npm`:null}function B(){let e=process.cwd();for(;e;){let n=c(e,`package.json`);if(i(n))try{let e=JSON.parse(a(n,`utf-8`)).packageManager;if(typeof e==`string`){let n=e.split(`@`)[0];if(t.includes(n))return n}}catch{}let r=o(e);if(r===e)return null;e=r}return null}async function V(n){if(n&&t.includes(n))return{pm:n,source:`flag`};let r=await e(process.cwd());if(r?.packageManager&&t.includes(r.packageManager))return{pm:r.packageManager,source:`config`};let i=B();if(i)return{pm:i,source:`package.json`};let a=z();return a?{pm:a,source:`lockfile`}:{pm:`npm`,source:`default`}}async function H(e){let{pm:t}=await V(e);return t}function U(e=!1){let t=Object.entries(N),n=Math.max(...t.map(([e])=>e.length)),r=t.filter(([,e])=>e.core),i=t.filter(([,e])=>!e.core),a=([e,t])=>{let r=e.padEnd(n+2),i=t.peers.length?` (+ ${t.peers.join(`, `)})`:``,a=t.deprecated?` [DEPRECATED — ${t.deprecated}]`:``;return` ${r} ${t.description}${i}${a}`};console.log(`
|
|
381
|
+
Core packages (always installed by \`kick new\`):
|
|
382
|
+
`);for(let e of r)console.log(a(e));if(e){console.log(`
|
|
383
|
+
Optional packages (add as needed):
|
|
384
|
+
`);for(let e of i)console.log(a(e))}else console.log(`\n Plus ${i.length} optional packages (auth, swagger, db, queue, …).`),console.log(" Run `kick add --list --all` for the full catalog.");console.log(`
|
|
385
|
+
Usage: kick add ai db swagger`),console.log(` kick add queue:bullmq`),console.log(` kick add upload # installs the multipart driver for your runtime`),console.log()}function W(e,t,n=`express`){let r=new Set,i=new Set,a=[],o=[],s=[];for(let c of e){if(c===`upload`){let e=F[n];s.push(`upload (${n}): ${e.note}`),e.prod&&(t?i:r).add(e.prod),e.dev&&i.add(e.dev);continue}let e=N[c];if(!e){a.push(c);continue}e.deprecated&&o.push(`'${c}' (${e.pkg}) is deprecated — ${e.deprecated}`);let l=t||e.dev?i:r;l.add(e.pkg);for(let t of e.peers)l.add(t)}return{prodDeps:[...r],devDeps:[...i],unknown:a,warnings:o,notices:s}}function G(e){e.command(`list`).alias(`ls`).description(`List KickJS packages (core only; pair with --all for the full catalog)`).option(`--all`,`Include the full optional catalog`).action(e=>{U(!!e.all)})}function K(e){e.command(`add [packages...]`).description(`Add KickJS packages with their required dependencies`).option(`--pm <manager>`,`Package manager override`).option(`-D, --dev`,`Install as dev dependency`).option(`--list`,`List packages (core only by default; pair with --all)`).option(`--all`,`When listing, include the full optional catalog`).action(async(e,t)=>{if(t.list||e.length===0){U(!!t.all);return}let{pm:n,source:r}=await V(t.pm);console.log(`\n Using ${n} (resolved from ${r})`);let i=await I(process.cwd()),{prodDeps:a,devDeps:o,unknown:s,warnings:c,notices:l}=W(e,!!t.dev,i);for(let e of c)console.warn(`\n WARNING: ${e}`);for(let e of l)console.log(`\n ${e}`);if(!(s.length>0&&(console.log(`\n Unknown packages: ${s.join(`, `)}`),console.log(` Run "kick add --list" to see available packages.
|
|
386
|
+
`),a.length===0&&o.length===0))){if(a.length>0){let e=a,t=`${n} add ${e.join(` `)}`;console.log(`\n Installing ${e.length} dependency(ies):`);for(let t of e)console.log(` + ${t}`);console.log();try{d(t,{stdio:`inherit`})}catch{console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}if(o.length>0){let e=o,t=`${n} add -D ${e.join(` `)}`;console.log(`\n Installing ${e.length} dev dependency(ies):`);for(let t of e)console.log(` + ${t} (dev)`);console.log();try{d(t,{stdio:`inherit`})}catch{console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}console.log(` Done!
|
|
387
|
+
`)}})}const q=o(l(import.meta.url)),J=JSON.parse(a(s(q,`..`,`package.json`),`utf-8`)),Y=`^${J.version}`,X=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-schema`,`@forinda/kickjs-vite`,`@forinda/kickjs-swagger`,`@forinda/kickjs-ws`,`@forinda/kickjs-queue`,`@forinda/kickjs-devtools`,`@forinda/kickjs-testing`,`@forinda/kickjs-client`];async function Z(){let e=await Promise.all(X.map(async e=>{try{let t=u(`npm`,[`view`,e,`version`],{encoding:`utf-8`,timeout:5e3,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim();if(t&&/^\d+\.\d+\.\d+/.test(t))return[e,`^${t}`]}catch{}return[e,Y]}));return Object.fromEntries(e)}function Q(e,t){try{let n=u(`npm`,[`view`,`${e}@${t}`,`version`],{encoding:`utf-8`,timeout:5e3,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim();return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}catch{return null}}function $(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function ee(e,t){let n=e=>$(e).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10)||0),[r=0,i=0,a=0]=n(e),[o=0,s=0,c=0]=n(t);return r===o?i===s?a>=c:i>s:r>o}function te(e,t,n){try{let r=u(`npm`,[`view`,`${e}@${t}`,`exports`,`--json`],{encoding:`utf-8`,timeout:5e3,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim();if(!r)return!1;let i=JSON.parse(r);return Object.prototype.hasOwnProperty.call(i,n)}catch{return!1}}async function ne(e){let{name:t,directory:i,packageManager:a=`pnpm`,template:o=`rest`,defaultRepo:c=`inmemory`,packages:l=[],schemaLib:u=`zod`,runtime:f=`express`}=e,p=i,m=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${t}\n`),m(`Resolving package versions...`);let T=await Z();if(f!==`express`)if(te(`@forinda/kickjs`,`latest`,`./${f}`))m(`Using @forinda/kickjs@latest (stable ships the ${f} runtime)`);else{let e=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-vite`],t=[],n=!1;for(let r of e){let e=Q(r,`alpha`);e&&ee(e,$(T[r]))&&(T[r]=`^${e}`,t.push(`${r}@^${e}`),r===`@forinda/kickjs`&&(n=!0))}m(n?`Using the alpha channel for the ${f} runtime: ${t.join(`, `)}`:`WARNING: could not resolve @forinda/kickjs@alpha — the ${f} runtime subpath may be missing. After install, run: ${a} add @forinda/kickjs@alpha`)}await n(s(p,`package.json`),h(t,o,T,l,u,f)),await n(s(p,`vite.config.ts`),g()),await n(s(p,`tsconfig.json`),_()),await n(s(p,`.prettierrc`),v()),await n(s(p,`.editorconfig`),y()),await n(s(p,`.gitignore`),b()),await n(s(p,`.gitattributes`),x()),await n(s(p,`.env`),S()),await n(s(p,`.env.example`),C()),await n(s(p,`src/config/index.ts`),O(u)),await n(s(p,`src/index.ts`),E(t,o,J.version,l,f)),await n(s(p,`src/modules/index.ts`),D()),await n(s(p,`src/modules/hello/hello.service.ts`),k()),await n(s(p,`src/modules/hello/hello.controller.ts`),A()),await n(s(p,`src/modules/hello/hello.module.ts`),j()),await n(s(p,`kick.config.ts`),M(o,c,a,f)),await n(s(p,`vitest.config.ts`),w()),await n(s(p,`README.md`),r(t,o,a));let{generateAgentDocs:N}=await import(`./agent-docs-B91ALPZR.mjs`).then(e=>e.t);if(await N({outDir:p,name:t,pm:a,template:o,only:`all`,force:!0}),e.installDeps){console.log(`\n Installing dependencies with ${a}...\n`);try{d(`${a} install`,{cwd:p,stdio:`inherit`}),console.log(`
|
|
388
|
+
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${a} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-BZKiGXjW.mjs`).then(e=>e.n);await e({cwd:p,allowDuplicates:!0,silent:!0})}catch{}if(e.initGit)try{d(`git init`,{cwd:p,stdio:`pipe`}),d(`git branch -M main`,{cwd:p,stdio:`pipe`}),d(`git add -A`,{cwd:p,stdio:`pipe`}),d(`git commit -m "chore: initial commit from kick new"`,{cwd:p,stdio:`pipe`}),m(`Git repository initialized`)}catch{m(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
389
|
+
Project scaffolded successfully!`),console.log();let F=p!==process.cwd();m(`Next steps:`),F&&m(` cd ${t}`),e.installDeps||m(` ${a} install`);let I={rest:`kick g module user`,ddd:`kick g module user --repo drizzle`,cqrs:`kick g module user --pattern cqrs`,minimal:`# add your routes to src/index.ts`};m(` ${I[o]??I.rest}`),m(` kick dev`),m(``),m(`Commands:`),m(` kick dev Start dev server with Vite HMR`),m(` kick build Production build via Vite`),m(` kick start Run production build`),m(``),m(`Generators:`),m(` kick g module <name> Full DDD module (controller, DTOs, use-cases, repo)`),m(` kick g scaffold <n> <f..> CRUD module from field definitions`),m(` kick g controller <name> Standalone controller`),m(` kick g service <name> @Service() class`),m(` kick g middleware <name> Express middleware`),m(` kick g guard <name> Route guard (auth, roles, etc.)`),m(` kick g adapter <name> AppAdapter with lifecycle hooks`),m(` kick g dto <name> Zod DTO schema`),m(` kick g config Generate kick.config.ts`),m(``),m(`Add packages:`),m(` kick add <pkg> Install a KickJS package + peers`),m(` kick add --list Show all available packages`),m(``),m(`Available: ${P}`),m(``)}export{K as a,H as c,F as i,Z as n,G as o,N as r,I as s,ne as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v6.
|
|
2
|
+
* @forinda/kickjs-cli v6.9.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{l as e,o as t}from"./project-docs-
|
|
11
|
+
import{l as e,o as t}from"./project-docs-Dlq_ipnh.mjs";import{i as n,t as r}from"./config-CFAZrUmi.mjs";import{dirname as i,join as a,resolve as o}from"node:path";import{existsSync as s,readFileSync as c}from"node:fs";import{execFileSync as l,execSync as u}from"node:child_process";import{fileURLToPath as d}from"node:url";const f={express:{from:`@forinda/kickjs`,name:`expressRuntime`},fastify:{from:`@forinda/kickjs/fastify`,name:`fastifyRuntime`},h3:{from:`@forinda/kickjs/h3`,name:`h3Runtime`}};function p(e,t,n,r=[],i=`express`){let a=f[i],o=i===`express`;switch(t){case`minimal`:{let t=[],i=[],s=o?`import { bootstrap, ${a.name} } from '@forinda/kickjs'`:`import { bootstrap } from '@forinda/kickjs'\nimport { ${a.name} } from '${a.from}'`;r.includes(`swagger`)&&(t.push(`import { SwaggerAdapter } from '@forinda/kickjs-swagger'`),i.push(` SwaggerAdapter({ info: { title: '${e}', version: '${n}' } }),`)),r.includes(`devtools`)&&(t.push(`import { DevToolsAdapter } from '@forinda/kickjs-devtools'`),i.push(` DevToolsAdapter(),`));let c=t.length?t.join(`
|
|
12
12
|
`)+`
|
|
13
13
|
`:``,l=i.length?`,\n adapters: [\n${i.join(`
|
|
14
14
|
`)}\n ]`:``;return`import 'reflect-metadata'
|
|
@@ -294,7 +294,7 @@ export default defineConfig({
|
|
|
294
294
|
},
|
|
295
295
|
],
|
|
296
296
|
})
|
|
297
|
-
`}const b={swagger:`@forinda/kickjs-swagger`,ws:`@forinda/kickjs-ws`,queue:`@forinda/kickjs-queue`,devtools:`@forinda/kickjs-devtools`},x={zod:{name:`zod`,range:`^4.3.6`},valibot:{name:`valibot`,range:`^1.4.1`},yup:{name:`yup`,range:`^1.7.1`}};function S(e,t){let n=e[t];if(!n)throw Error(`generatePackageJson: missing resolved version for ${t}. Add it to SIBLING_PACKAGES in generators/project.ts.`);return n}function C(e,t,n,r=[],i=`zod`,a=`express`){let o=x[i],s={"@forinda/kickjs":S(n,`@forinda/kickjs`),"@forinda/kickjs-schema":S(n,`@forinda/kickjs-schema`),dotenv:`^17.3.1`,"reflect-metadata":`^0.2.2`,[o.name]:o.range};a===`express`?s.express=`^5.1.0`:a===`fastify`?(s.fastify=`^5.0.0`,s[`@fastify/middie`]=`^9.0.0`,s[`serve-static`]=`^2.2.0`):a===`h3`&&(s.h3=`^1.0.0`,s[`serve-static`]=`^2.2.0`);for(let e of r){let t=b[e];t&&!s[t]&&(s[t]=S(n,t))}return JSON.stringify({name:e,version:`0.0.0`,type:`module`,scripts:{dev:`kick dev`,"dev:debug":`kick dev:debug`,build:`kick build`,start:`kick start`,test:`vitest run`,"test:watch":`vitest`,typecheck:`tsc --noEmit`,typegen:`kick typegen`,lint:`eslint src/`,format:`prettier --write src/`},dependencies:s,devDependencies:{"@forinda/kickjs-cli":S(n,`@forinda/kickjs-cli`),"@forinda/kickjs-vite":S(n,`@forinda/kickjs-vite`),"@swc/core":`^1.15.21`,...a===`express`?{"@types/express":`^5.0.6`}:{},"@types/node":`^25.0.0`,"unplugin-swc":`^1.5.9`,vite:`^8.0.3`,vitest:`^4.1.2`,typescript:`^
|
|
297
|
+
`}const b={swagger:`@forinda/kickjs-swagger`,ws:`@forinda/kickjs-ws`,queue:`@forinda/kickjs-queue`,devtools:`@forinda/kickjs-devtools`},x={zod:{name:`zod`,range:`^4.3.6`},valibot:{name:`valibot`,range:`^1.4.1`},yup:{name:`yup`,range:`^1.7.1`}};function S(e,t){let n=e[t];if(!n)throw Error(`generatePackageJson: missing resolved version for ${t}. Add it to SIBLING_PACKAGES in generators/project.ts.`);return n}function C(e,t,n,r=[],i=`zod`,a=`express`){let o=x[i],s={"@forinda/kickjs":S(n,`@forinda/kickjs`),"@forinda/kickjs-schema":S(n,`@forinda/kickjs-schema`),dotenv:`^17.3.1`,"reflect-metadata":`^0.2.2`,[o.name]:o.range};a===`express`?s.express=`^5.1.0`:a===`fastify`?(s.fastify=`^5.0.0`,s[`@fastify/middie`]=`^9.0.0`,s[`serve-static`]=`^2.2.0`):a===`h3`&&(s.h3=`^1.0.0`,s[`serve-static`]=`^2.2.0`);for(let e of r){let t=b[e];t&&!s[t]&&(s[t]=S(n,t))}return JSON.stringify({name:e,version:`0.0.0`,type:`module`,scripts:{dev:`kick dev`,"dev:debug":`kick dev:debug`,build:`kick build`,start:`kick start`,test:`vitest run`,"test:watch":`vitest`,typecheck:`tsc --noEmit`,typegen:`kick typegen`,lint:`eslint src/`,format:`prettier --write src/`},dependencies:s,devDependencies:{"@forinda/kickjs-cli":S(n,`@forinda/kickjs-cli`),"@forinda/kickjs-vite":S(n,`@forinda/kickjs-vite`),"@swc/core":`^1.15.21`,...a===`express`?{"@types/express":`^5.0.6`}:{},"@types/node":`^25.0.0`,"unplugin-swc":`^1.5.9`,vite:`^8.0.3`,vitest:`^4.1.2`,typescript:`^7.0.2`,prettier:`^3.8.1`}},null,2)}function w(){return`import { defineConfig } from 'vite'
|
|
298
298
|
import { resolve } from 'node:path'
|
|
299
299
|
import swc from 'unplugin-swc'
|
|
300
300
|
import { kickjsVitePlugin, envWatchPlugin } from '@forinda/kickjs-vite'
|
|
@@ -384,7 +384,7 @@ export default defineConfig({
|
|
|
384
384
|
`);for(let e of i)console.log(a(e))}else console.log(`\n Plus ${i.length} optional packages (auth, swagger, db, queue, …).`),console.log(" Run `kick add --list --all` for the full catalog.");console.log(`
|
|
385
385
|
Usage: kick add ai db swagger`),console.log(` kick add queue:bullmq`),console.log(` kick add upload # installs the multipart driver for your runtime`),console.log()}function W(e,t,n=`express`){let r=new Set,i=new Set,a=[],o=[],s=[];for(let c of e){if(c===`upload`){let e=F[n];s.push(`upload (${n}): ${e.note}`),e.prod&&(t?i:r).add(e.prod),e.dev&&i.add(e.dev);continue}let e=N[c];if(!e){a.push(c);continue}e.deprecated&&o.push(`'${c}' (${e.pkg}) is deprecated — ${e.deprecated}`);let l=t||e.dev?i:r;l.add(e.pkg);for(let t of e.peers)l.add(t)}return{prodDeps:[...r],devDeps:[...i],unknown:a,warnings:o,notices:s}}function G(e){e.command(`list`).alias(`ls`).description(`List KickJS packages (core only; pair with --all for the full catalog)`).option(`--all`,`Include the full optional catalog`).action(e=>{U(!!e.all)})}function K(e){e.command(`add [packages...]`).description(`Add KickJS packages with their required dependencies`).option(`--pm <manager>`,`Package manager override`).option(`-D, --dev`,`Install as dev dependency`).option(`--list`,`List packages (core only by default; pair with --all)`).option(`--all`,`When listing, include the full optional catalog`).action(async(e,t)=>{if(t.list||e.length===0){U(!!t.all);return}let{pm:n,source:r}=await V(t.pm);console.log(`\n Using ${n} (resolved from ${r})`);let i=await I(process.cwd()),{prodDeps:a,devDeps:o,unknown:s,warnings:c,notices:l}=W(e,!!t.dev,i);for(let e of c)console.warn(`\n WARNING: ${e}`);for(let e of l)console.log(`\n ${e}`);if(!(s.length>0&&(console.log(`\n Unknown packages: ${s.join(`, `)}`),console.log(` Run "kick add --list" to see available packages.
|
|
386
386
|
`),a.length===0&&o.length===0))){if(a.length>0){let e=a,t=`${n} add ${e.join(` `)}`;console.log(`\n Installing ${e.length} dependency(ies):`);for(let t of e)console.log(` + ${t}`);console.log();try{u(t,{stdio:`inherit`})}catch{console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}if(o.length>0){let e=o,t=`${n} add -D ${e.join(` `)}`;console.log(`\n Installing ${e.length} dev dependency(ies):`);for(let t of e)console.log(` + ${t} (dev)`);console.log();try{u(t,{stdio:`inherit`})}catch{console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}console.log(` Done!
|
|
387
|
-
`)}})}const q=i(d(import.meta.url)),J=JSON.parse(c(a(q,`..`,`package.json`),`utf-8`)),Y=`^${J.version}`,X=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-schema`,`@forinda/kickjs-vite`,`@forinda/kickjs-swagger`,`@forinda/kickjs-ws`,`@forinda/kickjs-queue`,`@forinda/kickjs-devtools`,`@forinda/kickjs-testing`,`@forinda/kickjs-client`];async function Z(){let e=await Promise.all(X.map(async e=>{try{let t=l(`npm`,[`view`,e,`version`],{encoding:`utf-8`,timeout:5e3,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim();if(t&&/^\d+\.\d+\.\d+/.test(t))return[e,`^${t}`]}catch{}return[e,Y]}));return Object.fromEntries(e)}function Q(e,t){try{let n=l(`npm`,[`view`,`${e}@${t}`,`version`],{encoding:`utf-8`,timeout:5e3,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim();return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}catch{return null}}function $(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function ee(e,t){let n=e=>$(e).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10)||0),[r=0,i=0,a=0]=n(e),[o=0,s=0,c=0]=n(t);return r===o?i===s?a>=c:i>s:r>o}function te(e,t,n){try{let r=l(`npm`,[`view`,`${e}@${t}`,`exports`,`--json`],{encoding:`utf-8`,timeout:5e3,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim();if(!r)return!1;let i=JSON.parse(r);return Object.prototype.hasOwnProperty.call(i,n)}catch{return!1}}async function ne(n){let{name:r,directory:i,packageManager:o=`pnpm`,template:s=`rest`,defaultRepo:c=`inmemory`,packages:l=[],schemaLib:d=`zod`,runtime:f=`express`}=n,b=i,x=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${r}\n`),x(`Resolving package versions...`);let S=await Z();if(f!==`express`)if(te(`@forinda/kickjs`,`latest`,`./${f}`))x(`Using @forinda/kickjs@latest (stable ships the ${f} runtime)`);else{let e=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-vite`],t=[],n=!1;for(let r of e){let e=Q(r,`alpha`);e&&ee(e,$(S[r]))&&(S[r]=`^${e}`,t.push(`${r}@^${e}`),r===`@forinda/kickjs`&&(n=!0))}x(n?`Using the alpha channel for the ${f} runtime: ${t.join(`, `)}`:`WARNING: could not resolve @forinda/kickjs@alpha — the ${f} runtime subpath may be missing. After install, run: ${o} add @forinda/kickjs@alpha`)}await e(a(b,`package.json`),C(r,s,S,l,d,f)),await e(a(b,`vite.config.ts`),w()),await e(a(b,`tsconfig.json`),T()),await e(a(b,`.prettierrc`),E()),await e(a(b,`.editorconfig`),D()),await e(a(b,`.gitignore`),O()),await e(a(b,`.gitattributes`),k()),await e(a(b,`.env`),A()),await e(a(b,`.env.example`),j()),await e(a(b,`src/config/index.ts`),h(d)),await e(a(b,`src/index.ts`),p(r,s,J.version,l,f)),await e(a(b,`src/modules/index.ts`),m()),await e(a(b,`src/modules/hello/hello.service.ts`),g()),await e(a(b,`src/modules/hello/hello.controller.ts`),_()),await e(a(b,`src/modules/hello/hello.module.ts`),v()),await e(a(b,`kick.config.ts`),y(s,c,o,f)),await e(a(b,`vitest.config.ts`),M()),await e(a(b,`README.md`),t(r,s,o));let{generateAgentDocs:N}=await import(`./agent-docs-
|
|
388
|
-
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${o} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-
|
|
387
|
+
`)}})}const q=i(d(import.meta.url)),J=JSON.parse(c(a(q,`..`,`package.json`),`utf-8`)),Y=`^${J.version}`,X=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-schema`,`@forinda/kickjs-vite`,`@forinda/kickjs-swagger`,`@forinda/kickjs-ws`,`@forinda/kickjs-queue`,`@forinda/kickjs-devtools`,`@forinda/kickjs-testing`,`@forinda/kickjs-client`];async function Z(){let e=await Promise.all(X.map(async e=>{try{let t=l(`npm`,[`view`,e,`version`],{encoding:`utf-8`,timeout:5e3,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim();if(t&&/^\d+\.\d+\.\d+/.test(t))return[e,`^${t}`]}catch{}return[e,Y]}));return Object.fromEntries(e)}function Q(e,t){try{let n=l(`npm`,[`view`,`${e}@${t}`,`version`],{encoding:`utf-8`,timeout:5e3,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim();return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}catch{return null}}function $(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function ee(e,t){let n=e=>$(e).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10)||0),[r=0,i=0,a=0]=n(e),[o=0,s=0,c=0]=n(t);return r===o?i===s?a>=c:i>s:r>o}function te(e,t,n){try{let r=l(`npm`,[`view`,`${e}@${t}`,`exports`,`--json`],{encoding:`utf-8`,timeout:5e3,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim();if(!r)return!1;let i=JSON.parse(r);return Object.prototype.hasOwnProperty.call(i,n)}catch{return!1}}async function ne(n){let{name:r,directory:i,packageManager:o=`pnpm`,template:s=`rest`,defaultRepo:c=`inmemory`,packages:l=[],schemaLib:d=`zod`,runtime:f=`express`}=n,b=i,x=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${r}\n`),x(`Resolving package versions...`);let S=await Z();if(f!==`express`)if(te(`@forinda/kickjs`,`latest`,`./${f}`))x(`Using @forinda/kickjs@latest (stable ships the ${f} runtime)`);else{let e=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-vite`],t=[],n=!1;for(let r of e){let e=Q(r,`alpha`);e&&ee(e,$(S[r]))&&(S[r]=`^${e}`,t.push(`${r}@^${e}`),r===`@forinda/kickjs`&&(n=!0))}x(n?`Using the alpha channel for the ${f} runtime: ${t.join(`, `)}`:`WARNING: could not resolve @forinda/kickjs@alpha — the ${f} runtime subpath may be missing. After install, run: ${o} add @forinda/kickjs@alpha`)}await e(a(b,`package.json`),C(r,s,S,l,d,f)),await e(a(b,`vite.config.ts`),w()),await e(a(b,`tsconfig.json`),T()),await e(a(b,`.prettierrc`),E()),await e(a(b,`.editorconfig`),D()),await e(a(b,`.gitignore`),O()),await e(a(b,`.gitattributes`),k()),await e(a(b,`.env`),A()),await e(a(b,`.env.example`),j()),await e(a(b,`src/config/index.ts`),h(d)),await e(a(b,`src/index.ts`),p(r,s,J.version,l,f)),await e(a(b,`src/modules/index.ts`),m()),await e(a(b,`src/modules/hello/hello.service.ts`),g()),await e(a(b,`src/modules/hello/hello.controller.ts`),_()),await e(a(b,`src/modules/hello/hello.module.ts`),v()),await e(a(b,`kick.config.ts`),y(s,c,o,f)),await e(a(b,`vitest.config.ts`),M()),await e(a(b,`README.md`),t(r,s,o));let{generateAgentDocs:N}=await import(`./agent-docs-DvLtd3g5.mjs`).then(e=>e.t);if(await N({outDir:b,name:r,pm:o,template:s,only:`all`,force:!0}),n.installDeps){console.log(`\n Installing dependencies with ${o}...\n`);try{u(`${o} install`,{cwd:b,stdio:`inherit`}),console.log(`
|
|
388
|
+
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${o} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-CdS37QWi.mjs`).then(e=>e.n);await e({cwd:b,allowDuplicates:!0,silent:!0})}catch{}if(n.initGit)try{u(`git init`,{cwd:b,stdio:`pipe`}),u(`git branch -M main`,{cwd:b,stdio:`pipe`}),u(`git add -A`,{cwd:b,stdio:`pipe`}),u(`git commit -m "chore: initial commit from kick new"`,{cwd:b,stdio:`pipe`}),x(`Git repository initialized`)}catch{x(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
389
389
|
Project scaffolded successfully!`),console.log();let F=b!==process.cwd();x(`Next steps:`),F&&x(` cd ${r}`),n.installDeps||x(` ${o} install`);let I={rest:`kick g module user`,ddd:`kick g module user --repo drizzle`,cqrs:`kick g module user --pattern cqrs`,minimal:`# add your routes to src/index.ts`};x(` ${I[s]??I.rest}`),x(` kick dev`),x(``),x(`Commands:`),x(` kick dev Start dev server with Vite HMR`),x(` kick build Production build via Vite`),x(` kick start Run production build`),x(``),x(`Generators:`),x(` kick g module <name> Full DDD module (controller, DTOs, use-cases, repo)`),x(` kick g scaffold <n> <f..> CRUD module from field definitions`),x(` kick g controller <name> Standalone controller`),x(` kick g service <name> @Service() class`),x(` kick g middleware <name> Express middleware`),x(` kick g guard <name> Route guard (auth, roles, etc.)`),x(` kick g adapter <name> AppAdapter with lifecycle hooks`),x(` kick g dto <name> Zod DTO schema`),x(` kick g config Generate kick.config.ts`),x(``),x(`Add packages:`),x(` kick add <pkg> Install a KickJS package + peers`),x(` kick add --list Show all available packages`),x(``),x(`Available: ${P}`),x(``)}export{K as a,H as c,F as i,Z as n,G as o,N as r,I as s,ne as t};
|
|
390
|
-
//# sourceMappingURL=project-
|
|
390
|
+
//# sourceMappingURL=project-BSSB5kBG.mjs.map
|