@forinda/kickjs-cli 8.2.3 → 8.3.0

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.
Files changed (47) hide show
  1. package/dist/{agent-docs-Ckay-1_c.mjs → agent-docs-CpoUa3NG.mjs} +3 -3
  2. package/dist/{agent-docs-Ckay-1_c.mjs.map → agent-docs-CpoUa3NG.mjs.map} +1 -1
  3. package/dist/{agent-docs-ckWIFTVN.mjs → agent-docs-VPtM_Kgj.mjs} +2 -2
  4. package/dist/{build-CVXO_yUd.mjs → build-BKNvIOBh.mjs} +3 -3
  5. package/dist/{build-CVXO_yUd.mjs.map → build-BKNvIOBh.mjs.map} +1 -1
  6. package/dist/{build-0-2XImDT.mjs → build-BhoYGIVD.mjs} +2 -2
  7. package/dist/{builtins-DsF3W8nQ.mjs → builtins-6FCYMic-.mjs} +35 -26
  8. package/dist/{builtins-BFBP6hSP.mjs → builtins-BvdsVFXh.mjs} +2 -2
  9. package/dist/cli.mjs +2 -2
  10. package/dist/{config-CXqsXPQB.mjs → config-3zv5pWqb.mjs} +2 -2
  11. package/dist/{config-DDHiaBAp.mjs → config-LkaeajTr.mjs} +3 -3
  12. package/dist/config-LkaeajTr.mjs.map +1 -0
  13. package/dist/{doctor-BoCM5VzN.mjs → doctor-3-n9AElz.mjs} +4 -4
  14. package/dist/{doctor-BoCM5VzN.mjs.map → doctor-3-n9AElz.mjs.map} +1 -1
  15. package/dist/{fullstack-DGH8LtUr.mjs → fullstack-0D2Dgia_.mjs} +14 -15
  16. package/dist/{fullstack-TNXwfWim.mjs → fullstack-D_OHhyZX.mjs} +15 -16
  17. package/dist/fullstack-D_OHhyZX.mjs.map +1 -0
  18. package/dist/index.d.mts +62 -0
  19. package/dist/index.d.mts.map +1 -1
  20. package/dist/index.mjs +2 -2
  21. package/dist/{plugin-BIlCVqfL.mjs → plugin-3V8ZP2h3.mjs} +2 -2
  22. package/dist/{plugin-_dzDQrjh.mjs → plugin-MfCs1kvG.mjs} +2 -2
  23. package/dist/project-D-8rOQYi.mjs +451 -0
  24. package/dist/project-D-8rOQYi.mjs.map +1 -0
  25. package/dist/project-Evcbbdbq.mjs +450 -0
  26. package/dist/{project-docs-CjKscwGL.mjs → project-docs-B-qcYAX9.mjs} +1 -1
  27. package/dist/{project-docs-pgIpkegR.mjs → project-docs-B6XKHBMO.mjs} +2 -2
  28. package/dist/{project-docs-pgIpkegR.mjs.map → project-docs-B6XKHBMO.mjs.map} +1 -1
  29. package/dist/{project-root-DxyENcsv.mjs → project-root-6mdsMXwA.mjs} +3 -3
  30. package/dist/{project-root-DxyENcsv.mjs.map → project-root-6mdsMXwA.mjs.map} +1 -1
  31. package/dist/{project-root-DrOatPqt.mjs → project-root-CxadsnDd.mjs} +2 -2
  32. package/dist/{prompts-CmfXdpn5.mjs → prompts-BtUBi1ob.mjs} +2 -2
  33. package/dist/{prompts-CmfXdpn5.mjs.map → prompts-BtUBi1ob.mjs.map} +1 -1
  34. package/dist/{rolldown-runtime-DYoa8wui.mjs → rolldown-runtime-BeIFeoWC.mjs} +1 -1
  35. package/dist/{run-plugins-RhPvviAu.mjs → run-plugins-lLfcDAbT.mjs} +77 -68
  36. package/dist/run-plugins-lLfcDAbT.mjs.map +1 -0
  37. package/dist/{typegen-CoIiSCqa.mjs → typegen-DLdD6SMm.mjs} +4 -4
  38. package/dist/{typegen-BWgxNmXV.mjs → typegen-yk3CJH18.mjs} +5 -5
  39. package/dist/{typegen-BWgxNmXV.mjs.map → typegen-yk3CJH18.mjs.map} +1 -1
  40. package/dist/{types-CDQ5ghz9.mjs → types-HQhLYWkB.mjs} +1 -1
  41. package/package.json +7 -7
  42. package/dist/config-DDHiaBAp.mjs.map +0 -1
  43. package/dist/fullstack-TNXwfWim.mjs.map +0 -1
  44. package/dist/project-CbaOLcsd.mjs +0 -428
  45. package/dist/project-CbaOLcsd.mjs.map +0 -1
  46. package/dist/project-Dck92mbC.mjs +0 -427
  47. package/dist/run-plugins-RhPvviAu.mjs.map +0 -1
@@ -1,427 +0,0 @@
1
- /**
2
- * @forinda/kickjs-cli v8.2.3
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{a as e,t}from"./config-CXqsXPQB.mjs";import{l as n,o as r}from"./project-docs-CjKscwGL.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{execFile as u,execFileSync as d,execSync as f,spawnSync as p}from"node:child_process";import{promisify as m}from"node:util";const h=m(u),g=/[&|<>^"'`(){}[\];!%\r\n\\]/;function _(e,t,n=process.platform){if(n!==`win32`)return[e,t];if(g.test(e)||t.some(e=>g.test(e)))return null;let r=[e,...t].map(e=>e.includes(` `)?`"${e}"`:e).join(` `);return[process.env.ComSpec||`cmd.exe`,[`/d`,`/s`,`/c`,r]]}function v(e,t,n={}){let r=_(e,t);if(!r)return null;try{return d(r[0],r[1],{encoding:`utf-8`,timeout:n.timeout??5e3,cwd:n.cwd,stdio:[`ignore`,`pipe`,`ignore`],windowsHide:!0}).toString().trim()||null}catch{return null}}function y(e,t,n={}){let r=_(e,t);if(!r)throw Error(`Refusing to run '${e}': unsafe arguments`);d(r[0],r[1],{cwd:n.cwd,stdio:`inherit`,windowsHide:!0})}function b(e,t,n){f(e,{cwd:t,stdio:`inherit`,env:n?{...process.env,...n}:process.env})}function ee(e,t,n){let r=p(process.execPath,[e],{cwd:n,stdio:`inherit`,env:{...process.env,...t}});r.status!==0&&process.exit(r.status??1)}async function x(e,t,n={}){let r=_(e,t);if(!r)return null;try{let{stdout:e}=await h(r[0],r[1],{encoding:`utf-8`,timeout:n.timeout??5e3,cwd:n.cwd,windowsHide:!0});return e.toString().trim()||null}catch{return null}}const S={swagger:`@forinda/kickjs-swagger`,ws:`@forinda/kickjs-ws`,queue:`@forinda/kickjs-queue`,devtools:`@forinda/kickjs-devtools`},C={zod:{name:`zod`,range:`^4.3.6`},valibot:{name:`valibot`,range:`^1.4.1`},yup:{name:`yup`,range:`^1.7.1`}};function w(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 T(e,t,n,r=[],i=`zod`,a=`express`,o=!1){let s=C[i],c={"@forinda/kickjs":w(n,`@forinda/kickjs`),"@forinda/kickjs-schema":w(n,`@forinda/kickjs-schema`),dotenv:`^17.3.1`,"reflect-metadata":`^0.2.2`,[s.name]:s.range};a===`express`?c.express=`^5.1.0`:a===`fastify`?(c.fastify=`^5.0.0`,c[`@fastify/middie`]=`^9.0.0`,c[`serve-static`]=`^2.2.0`):a===`h3`&&(c.h3=`^1.0.0`,c[`serve-static`]=`^2.2.0`);for(let e of r){let t=S[e];t&&!c[t]&&(c[t]=w(n,t))}return JSON.stringify({name:e,version:`0.0.0`,type:`module`,scripts:{dev:`kick dev`,build:`kick build`,start:`kick start`,test:`vitest run`},dependencies:c,devDependencies:{"@forinda/kickjs-cli":w(n,`@forinda/kickjs-cli`),"@forinda/kickjs-testing":w(n,`@forinda/kickjs-testing`),"@forinda/kickjs-vite":w(n,`@forinda/kickjs-vite`),"@types/supertest":`^7.2.1`,"@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`,supertest:`^7.2.2`,vitest:`^4.1.2`,typescript:`^7.0.2`,...o?{"@typescript/typescript6":`^6.0.2`}:{},oxfmt:`^0.65.0`,oxlint:`^1.80.0`}},null,2)}function E(){return`import { defineConfig } from 'vite'
12
- import { fileURLToPath } from 'node:url'
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
- '@': fileURLToPath(new URL('./src', import.meta.url)),
28
- },
29
- },
30
- build: {
31
- target: 'node20',
32
- ssr: true,
33
- outDir: 'dist',
34
- sourcemap: true,
35
- rollupOptions: {
36
- input: fileURLToPath(new URL('./src/index.ts', import.meta.url)),
37
- output: { format: 'esm' },
38
- },
39
- },
40
- })
41
- `}function te(){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 ne(){return JSON.stringify({$schema:`./node_modules/oxfmt/configuration_schema.json`,semi:!1,singleQuote:!0,trailingComma:`all`,printWidth:100,tabWidth:2,ignorePatterns:[`**/dist/`,`**/.kickjs/`,`**/node_modules/`]},null,2)}function re(){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 ie(){return`node_modules/
55
- dist/
56
- .env
57
- # Machine-specific: each developer's test env differs (database names, ports).
58
- # The shared template is the committed \`.env.test.example\`.
59
- .env.test
60
- *.local
61
- coverage/
62
- .DS_Store
63
- *.tsbuildinfo
64
- .kickjs/
65
- `}function ae(){return`# Auto-detect text files and normalise line endings to LF
66
- * text=auto eol=lf
67
-
68
- # Explicitly mark generated / binary files
69
- *.png binary
70
- *.jpg binary
71
- *.jpeg binary
72
- *.gif binary
73
- *.ico binary
74
- *.woff binary
75
- *.woff2 binary
76
- *.ttf binary
77
- *.eot binary
78
-
79
- # Lock files — treat as generated
80
- pnpm-lock.yaml -diff linguist-generated
81
- yarn.lock -diff linguist-generated
82
- package-lock.json -diff linguist-generated
83
- `}function oe(){return`PORT=3000
84
- NODE_ENV=development
85
- `}function se(){return`PORT=3000
86
- NODE_ENV=development
87
- `}function D(){return`# Read INSTEAD of .env when NODE_ENV=test (or under vitest).
88
- # No fallback to .env — declare here everything the suite needs, so a
89
- # missing var fails the run instead of silently resolving to your dev value.
90
- #
91
- # Not committed. Add new keys to .env.test.example too, with placeholder
92
- # values — never real endpoints or credentials.
93
- NODE_ENV=test
94
- PORT=0
95
- LOG_LEVEL=silent
96
- `}function ce(){return`# Template for .env.test. Copy it and fill in your machine's values:
97
- # cp .env.test.example .env.test
98
- ${D()}`}function O(){return`import { defineConfig, mergeConfig } from 'vitest/config'
99
- import viteConfig from './vite.config.ts'
100
-
101
- // A \`vitest.config.ts\` OVERRIDES \`vite.config.ts\` outright — vitest does not
102
- // merge the two, and it never reads tsconfig \`paths\`. Restating settings here
103
- // would mean the \`@\` alias lives in three files and drifts in two of them, so
104
- // merge the real config instead: the alias, plugins, and ssr externals all come
105
- // from one place.
106
- export default mergeConfig(
107
- viteConfig,
108
- defineConfig({
109
- test: {
110
- globals: true,
111
- environment: 'node',
112
- include: ['src/**/*.test.ts'],
113
- },
114
- }),
115
- )
116
- `}const k={express:{from:`@forinda/kickjs`,name:`expressRuntime`},fastify:{from:`@forinda/kickjs/fastify`,name:`fastifyRuntime`},h3:{from:`@forinda/kickjs/h3`,name:`h3Runtime`}};function A(e,t,n,r=[],i=`express`,a){let o=k[i],s=i===`express`;switch(t){case`minimal`:{let t=[],i=[],c=s?`import { bootstrap, ${o.name} } from '@forinda/kickjs'`:`import { bootstrap } from '@forinda/kickjs'\nimport { ${o.name} } from '${o.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(),`)),a&&(t.push(`import { SpaAdapter } from '@forinda/kickjs/spa'`),i.push(` // Serves the built frontend from this origin in production.
117
- // Inert until the client build exists, so \`kick dev\` (where Vite
118
- // serves the client and proxies /api here) is unaffected.
119
- SpaAdapter({ clientDir: ${JSON.stringify(a)} }),`));let l=t.length?t.join(`
120
- `)+`
121
- `:``,u=i.length?`,\n adapters: [\n${i.join(`
122
- `)}\n ]`:``;return`import 'reflect-metadata'
123
- // Side-effect import — registers the extended env schema with kickjs
124
- // **before** any controller / service / @Value gets resolved. Without
125
- // this line ConfigService.get('YOUR_KEY') returns undefined because the
126
- // cached schema would still be the base shape. See guide/configuration.
127
- import './config'
128
- ${c}
129
- ${l}import { modules } from './modules'
130
-
131
- // Export the app for the Vite plugin (dev mode)
132
- export const app = await bootstrap({ modules, runtime: ${o.name}()${u} })
133
- `}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 a=t.length?t.join(`
134
- `)+`
135
- `:``,c=i.length?`\n adapters: [\n${i.join(`
136
- `)}\n ],`:``,l=[`bootstrap`,`requestId`,`requestLogger`,`helmet`,`cors`];s&&l.push(o.name);let u=s?`import express from 'express'\nimport {\n ${l.join(`,
137
- `)},\n} from '@forinda/kickjs'`:`import {\n ${l.join(`,
138
- `)},\n} from '@forinda/kickjs'\nimport { ${o.name} } from '${o.from}'`,d=s?`
139
- express.json(),`:``;return`import 'reflect-metadata'
140
- // Side-effect import — registers the extended env schema with kickjs
141
- // **before** any controller / service / @Value gets resolved. Without
142
- // this line ConfigService.get('YOUR_KEY') returns undefined because the
143
- // cached schema would still be the base shape. See guide/configuration.
144
- import './config'
145
- ${u}
146
- ${a}import { modules } from './modules'
147
-
148
- // Export the app for the Vite plugin (dev mode)
149
- export const app = await bootstrap({
150
- modules,
151
- runtime: ${o.name}(),${c}
152
- middlewares: [
153
- // Security headers. The framework injects helmet() with these defaults
154
- // anyway — declaring it here is what lets you CHANGE them, e.g.
155
- // helmet({ frameguard: 'SAMEORIGIN' }) or helmet({ hsts: false }).
156
- // Auto-injection stands down as soon as this line is present.
157
- helmet(),
158
- cors({ origin: '*' }),
159
- requestId(),
160
- requestLogger(),${d}
161
- ],
162
- })
163
- `}}}function j(){return`import { defineModules } from '@forinda/kickjs'
164
- import { HelloModule } from './hello/hello.module'
165
-
166
- // Remove HelloModule and run: kick g module <name>
167
- // \`defineModules()\` returns a chainable list — \`kick g module\` appends
168
- // \`.mount(NewModule())\` to the chain on every generation.
169
- export const modules = defineModules().mount(HelloModule())
170
- `}function M(e=`zod`){return e===`valibot`?`import { loadEnvFromSchema } from '@forinda/kickjs/config'
171
- import { fromValibot } from '@forinda/kickjs-schema/valibot'
172
- import * as v from 'valibot'
173
-
174
- /**
175
- * Project environment schema (Valibot).
176
- *
177
- * \`fromValibot\` wraps the Valibot schema as a \`KickSchema\` so the
178
- * env loader, validate middleware, and swagger spec generator all see
179
- * the same shape. The default export is the contract \`kick typegen\`
180
- * reads to populate \`KickEnv\` via \`InferSchemaOutput<typeof _envSchema>\`
181
- * — that's what makes \`@Value('FOO')\` autocomplete and
182
- * \`process.env.FOO\` typed.
183
- *
184
- * @example
185
- * DATABASE_URL: v.pipe(v.string(), v.url()),
186
- * JWT_SECRET: v.pipe(v.string(), v.minLength(32)),
187
- * REDIS_URL: v.optional(v.pipe(v.string(), v.url())),
188
- */
189
- const envSchema = fromValibot(
190
- v.object({
191
- PORT: v.optional(v.pipe(v.string(), v.transform(Number)), '3000'),
192
- NODE_ENV: v.optional(v.picklist(['development', 'production', 'test']), 'development'),
193
- LOG_LEVEL: v.optional(v.string(), 'info'),
194
- // DATABASE_URL: v.pipe(v.string(), v.url()),
195
- }),
196
- )
197
-
198
- /**
199
- * IMPORTANT — side effect: register the schema with kickjs's env cache
200
- * **at module-load time**. \`ConfigService\` and \`@Value()\` both consume
201
- * this cache, and they will fall back to the base schema (or undefined)
202
- * if no extended schema has been registered before they're resolved.
203
- *
204
- * As long as \`src/index.ts\` imports this file (\`import './config'\`) at
205
- * the top — before \`bootstrap()\` runs — every controller and service
206
- * in the app sees the typed extended values.
207
- */
208
- export const env = loadEnvFromSchema(envSchema)
209
-
210
- export default envSchema
211
- `:e===`yup`?`import { loadEnvFromSchema } from '@forinda/kickjs/config'
212
- import { fromYup } from '@forinda/kickjs-schema/yup'
213
- import * as yup from 'yup'
214
-
215
- /**
216
- * Project environment schema (Yup).
217
- *
218
- * \`fromYup\` wraps the Yup schema as a \`KickSchema\` so the env loader,
219
- * validate middleware, and swagger spec generator all see the same
220
- * shape. The default export is the contract \`kick typegen\` reads to
221
- * populate \`KickEnv\` via \`InferSchemaOutput<typeof _envSchema>\`.
222
- *
223
- * Note: Yup's \`.url()\` defaults to http/https; database connection
224
- * strings like \`postgres://\` use \`.matches(/^[a-z]+:\\/\\/.+/i)\` or
225
- * a plain \`.string().required()\`.
226
- *
227
- * @example
228
- * DATABASE_URL: yup.string().required(),
229
- * JWT_SECRET: yup.string().min(32).required(),
230
- * REDIS_URL: yup.string().url().optional(),
231
- */
232
- const envSchema = fromYup(
233
- yup.object({
234
- PORT: yup.number().default(3000),
235
- NODE_ENV: yup
236
- .string()
237
- .oneOf(['development', 'production', 'test'])
238
- .default('development'),
239
- LOG_LEVEL: yup.string().default('info'),
240
- // DATABASE_URL: yup.string().required(),
241
- }),
242
- )
243
-
244
- /**
245
- * IMPORTANT — side effect: register the schema with kickjs's env cache
246
- * **at module-load time**. \`ConfigService\` and \`@Value()\` both consume
247
- * this cache, and they will fall back to the base schema (or undefined)
248
- * if no extended schema has been registered before they're resolved.
249
- *
250
- * As long as \`src/index.ts\` imports this file (\`import './config'\`) at
251
- * the top — before \`bootstrap()\` runs — every controller and service
252
- * in the app sees the typed extended values.
253
- */
254
- export const env = loadEnvFromSchema(envSchema)
255
-
256
- export default envSchema
257
- `:`import { loadEnvFromSchema } from '@forinda/kickjs/config'
258
- import { fromZod } from '@forinda/kickjs-schema/zod'
259
- import { z } from 'zod'
260
-
261
- /**
262
- * Project environment schema (Zod).
263
- *
264
- * \`fromZod\` wraps the Zod schema as a \`KickSchema\` so the env loader,
265
- * validate middleware, and swagger spec generator all see the same
266
- * shape. The default export is the contract \`kick typegen\` reads to
267
- * populate \`KickEnv\` via \`InferSchemaOutput<typeof _envSchema>\` —
268
- * that's what makes \`@Value('FOO')\` autocomplete and
269
- * \`process.env.FOO\` typed.
270
- *
271
- * @example
272
- * DATABASE_URL: z.string().url(),
273
- * JWT_SECRET: z.string().min(32),
274
- * REDIS_URL: z.string().url().optional(),
275
- */
276
- const envSchema = fromZod(
277
- z.object({
278
- PORT: z.coerce.number().default(3000),
279
- NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
280
- LOG_LEVEL: z.string().default('info'),
281
- // DATABASE_URL: z.string().url(),
282
- }),
283
- )
284
-
285
- /**
286
- * IMPORTANT — side effect: register the schema with kickjs's env cache
287
- * **at module-load time**. \`ConfigService\` and \`@Value()\` both consume
288
- * this cache, and they will fall back to the base schema (or undefined)
289
- * if no extended schema has been registered before they're resolved.
290
- *
291
- * As long as \`src/index.ts\` imports this file (\`import './config'\`) at
292
- * the top — before \`bootstrap()\` runs — every controller and service
293
- * in the app sees the typed extended values.
294
- */
295
- export const env = loadEnvFromSchema(envSchema)
296
-
297
- export default envSchema
298
- `}function N(){return`import { Service } from '@forinda/kickjs'
299
-
300
- @Service()
301
- export class HelloService {
302
- greet(name: string) {
303
- return { message: \`Hello \${name} from KickJS!\`, timestamp: new Date().toISOString() }
304
- }
305
-
306
- healthCheck() {
307
- return { status: 'ok', uptime: process.uptime() }
308
- }
309
- }
310
- `}function P(){return`import { Controller, Get, Autowired, type Ctx } from '@forinda/kickjs'
311
- import { HelloService } from './hello.service'
312
-
313
- // \`Ctx<KickRoutes.HelloController['<method>']>\` is generated by
314
- // \`kick typegen\` (auto-run on \`kick dev\`). The first run after a fresh
315
- // scaffold creates \`.kickjs/types/routes.ts\` so this file typechecks.
316
- // See https://kickjs.app/guide/typegen.
317
-
318
- @Controller()
319
- export class HelloController {
320
- @Autowired() private readonly helloService!: HelloService
321
-
322
- // Return-value handlers: the runtime sends the returned payload as
323
- // 200 json, and \`kick typegen\` infers the response type into
324
- // \`KickRoutes.Api\` — which is what makes the typed client
325
- // (@forinda/kickjs-client) end-to-end type-safe.
326
- @Get('/')
327
- index(_ctx: Ctx<KickRoutes.HelloController['index']>) {
328
- return this.helloService.greet('World')
329
- }
330
-
331
- @Get('/health')
332
- health(_ctx: Ctx<KickRoutes.HelloController['health']>) {
333
- return this.helloService.healthCheck()
334
- }
335
- }
336
- `}function F(){return`import { defineModule } from '@forinda/kickjs'
337
- import { HelloController } from './hello.controller'
338
-
339
- export const HelloModule = defineModule({
340
- name: 'HelloModule',
341
- build: () => ({
342
- // \`register(container)\` is optional — only implement it when you need
343
- // to bind a token to a concrete implementation, e.g.
344
- // register(container) {
345
- // container.registerFactory(USER_REPOSITORY, () => container.resolve(InMemoryUserRepository))
346
- // }
347
- // The HelloService uses @Service() so the decorator handles registration.
348
-
349
- routes() {
350
- return {
351
- path: '/hello',
352
- controller: HelloController,
353
- }
354
- },
355
- }),
356
- })
357
- `}function I(e,t=`inmemory`,n=`pnpm`,r=`express`,i=!1){return`import { defineConfig } from '@forinda/kickjs-cli'
358
-
359
- export default defineConfig({
360
- pattern: '${e}',
361
- // The HTTP engine this app boots on (matches \`bootstrap({ runtime })\` in
362
- // src/index.ts). Dep-aware commands read it: \`kick add upload\` installs the
363
- // engine's multipart driver, \`kick doctor\` checks the engine peers, and
364
- // \`kick typegen\` flips the runtime escape-hatch types to this engine.
365
- runtime: '${r}',
366
- // Pinned so \`kick add\` and other dep-installing commands always use the
367
- // project's intended package manager, regardless of which lockfile exists.
368
- packageManager: '${n}',
369
- modules: {
370
- dir: 'src/modules',
371
- repo: ${t===`inmemory`?`'inmemory'`:`{ name: '${t}' }`},
372
- pluralize: true,
373
- },
374
-
375
- // \`kick typegen\` populates \`.kickjs/types/\` so \`Ctx<KickRoutes.X['method']>\`
376
- // resolves to fully-typed params/body/query. Auto-runs on \`kick dev\`.
377
- // \`'kickjs-schema'\` routes inference through \`InferSchemaOutput\` so the
378
- // typegen works for any wrapped schema (Zod / Valibot / Yup). Switch
379
- // to \`'zod'\` if you ship Zod schemas without \`fromZod()\` wrapping, or
380
- // set \`schemaValidator: false\` to skip schema-driven body typing.
381
- typegen: {
382
- schemaValidator: 'kickjs-schema',${i?`
383
- // web/ reads this map from the ambient KickClientApi namespace. Producing
384
- // it builds a TypeScript program over the server, so it stays off unless a
385
- // project actually consumes it.
386
- client: true,`:``}
387
- },
388
-
389
- commands: [
390
- {
391
- name: 'test',
392
- description: 'Run tests with Vitest',
393
- steps: 'vitest run',
394
- },
395
- {
396
- name: 'lint',
397
- description: 'Lint with oxlint',
398
- steps: 'oxlint src/',
399
- },
400
- {
401
- name: 'format',
402
- description: 'Format code with oxfmt',
403
- steps: 'oxfmt src/',
404
- },
405
- {
406
- name: 'format:check',
407
- description: 'Check formatting without writing',
408
- steps: 'oxfmt --check src/',
409
- },
410
- {
411
- name: 'ci:check',
412
- description: 'Run typecheck + lint + format check',
413
- steps: ['kick typecheck', 'oxlint src/', 'oxfmt --check src/'],
414
- aliases: ['verify'],
415
- },
416
- ],
417
- })
418
- `}const L={kickjs:{pkg:`@forinda/kickjs`,peers:[],enginePeers:!0,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()`},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)`},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}},R=Object.entries(L).filter(([e,t])=>!t.core&&!t.deprecated&&!e.includes(`:`)&&![`pg`,`sqlite`,`mysql`,`zod`,`valibot`,`yup`].includes(e)).map(([e])=>e).join(`, `),z={express:[`express`],fastify:[`fastify`,`@fastify/middie`,`serve-static`],h3:[`h3`,`serve-static`]},B={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.`}};function V(e){if(e!==void 0){if(e===`express`||e===`fastify`||e===`h3`)return e;throw Error(`Invalid --runtime '${String(e)}'. Expected express, fastify or h3.`)}}async function H(e=process.cwd()){return(await U(e)).runtime}async function U(t=process.cwd()){let n=(await e(t))?.runtime;return n===`express`||n===`fastify`||n===`h3`?{runtime:n,candidates:[n],ambiguous:!1,fromConfig:!0}:{...G(t),fromConfig:!1}}const W=[[`express`,`express`],[`fastify`,`fastify`],[`h3`,`h3`]];function G(e=process.cwd()){let t=K(`package.json`,e);if(!t)return{runtime:`express`,candidates:[],ambiguous:!1};let n={},r={};try{let e=JSON.parse(a(c(t,`package.json`),`utf-8`));n=e.dependencies??{},r=e.devDependencies??{}}catch{return{runtime:`express`,candidates:[],ambiguous:!1}}let i=W.filter(([e])=>e in n).map(([,e])=>e),o=W.filter(([e])=>e in r&&!(e in n)).map(([,e])=>e),s=[...i,...o];return i.length===1?{runtime:i[0],candidates:s,ambiguous:!1}:i.length===0&&o.length===1?{runtime:o[0],candidates:s,ambiguous:!1}:s.length===0?{runtime:`express`,candidates:s,ambiguous:!1}:{runtime:`express`,candidates:s,ambiguous:!0}}function K(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 le(){return K(`pnpm-lock.yaml`)?`pnpm`:K(`yarn.lock`)?`yarn`:K(`bun.lockb`)||K(`bun.lock`)?`bun`:K(`package-lock.json`)?`npm`:null}function ue(){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 q(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=ue();if(i)return{pm:i,source:`package.json`};let a=le();return a?{pm:a,source:`lockfile`}:{pm:`npm`,source:`default`}}async function de(e){let{pm:t}=await q(e);return t}function J(e=!1,t){let n=Object.entries(L),r=Math.max(...n.map(([e])=>e.length)),i=n.filter(([,e])=>e.core),a=n.filter(([,e])=>!e.core),o=([e,n])=>{let i=e.padEnd(r+2),a=n.enginePeers?[...n.peers,...z[t??`express`]]:n.peers,o=n.enginePeers?` [${t??`express`} engine]`:``,s=a.length?` (+ ${a.join(`, `)})${o}`:``,c=n.deprecated?` [DEPRECATED — ${n.deprecated}]`:``;return` ${i} ${n.description}${s}${c}`};console.log(`
419
- Core packages (always installed by \`kick new\`):
420
- `);for(let e of i)console.log(o(e));if(e){console.log(`
421
- Optional packages (add as needed):
422
- `);for(let e of a)console.log(o(e))}else console.log(`\n Plus ${a.length} optional packages (swagger, db, queue, …).`),console.log(" Run `kick add --list --all` for the full catalog.");console.log(`
423
- 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 fe(e,t,n=`express`){let r=new Set,i=new Set,a=[],o=[],s=[];for(let c of e){if(c===`upload`){let e=B[n];s.push(`upload (${n}): ${e.note}`),e.prod&&(t?i:r).add(e.prod),e.dev&&i.add(e.dev);continue}let e=L[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);if(e.enginePeers){let e=z[n];for(let t of e)l.add(t);s.push(`${c} (${n}): engine peers ${e.join(`, `)}`)}}return{prodDeps:[...r],devDeps:[...i],unknown:a,warnings:o,notices:s}}function pe(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`).option(`--runtime <engine>`,`HTTP engine to show peers for: express | fastify | h3`).action(async e=>{J(!!e.all,V(e.runtime)??await H())})}function me(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(`--runtime <engine>`,`HTTP engine for peer resolution: express | fastify | h3 (overrides kick.config.ts)`).option(`--all`,`When listing, include the full optional catalog`).action(async(e,t)=>{if(t.list||e.length===0){J(!!t.all,V(t.runtime)??await H());return}let{pm:n,source:r}=await q(t.pm);console.log(`\n Using ${n} (resolved from ${r})`);let i=V(t.runtime),a=await U(process.cwd()),o=i??a.runtime;if(!i&&a.ambiguous){console.error(`\n Cannot tell which HTTP engine this app boots on: found ${a.candidates.join(`, `)} in package.json.\n\n Installing engine peers for the wrong one is worse than not installing them, so:\n • set \`runtime: '<engine>'\` in kick.config.ts (permanent, also fixes kick doctor), or\n • pass --runtime <${a.candidates.join(`|`)}> for this command\n`),process.exitCode=1;return}let{prodDeps:s,devDeps:c,unknown:l,warnings:u,notices:d}=fe(e,!!t.dev,o);for(let e of u)console.warn(`\n WARNING: ${e}`);for(let e of d)console.log(`\n ${e}`);if(!(l.length>0&&(console.log(`\n Unknown packages: ${l.join(`, `)}`),console.log(` Run "kick add --list" to see available packages.
424
- `),s.length===0&&c.length===0))){if(s.length>0){let e=s,t=`${n} add ${e.join(` `)}`;console.log(`\n Installing ${e.length} dependency(ies):`);for(let t of e)console.log(` + ${t}`);console.log();try{f(t,{stdio:`inherit`})}catch{console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}if(c.length>0){let e=c,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{f(t,{stdio:`inherit`})}catch{console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}console.log(` Done!
425
- `)}})}const Y=o(l(import.meta.url)),X=JSON.parse(a([s(Y,`..`,`package.json`),s(Y,`..`,`..`,`package.json`)].find(i),`utf-8`)),he=[`@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`];function Z(e){return e===`@forinda/kickjs-cli`?`^${X.version}`:`latest`}async function Q(){let e=await Promise.all(he.map(async e=>{let t=await x(`npm`,[`view`,e,`version`],{timeout:2e4});return t&&/^\d+\.\d+\.\d+/.test(t)?[e,`^${t}`]:[e,Z(e)]}));return Object.fromEntries(e)}function ge(e,t){let n=v(`npm`,[`view`,`${e}@${t}`,`version`],{timeout:2e4});return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}function $(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function _e(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 ve(e,t,n){let r=v(`npm`,[`view`,`${e}@${t}`,`exports`,`--json`],{timeout:2e4});if(!r)return!1;try{let e=JSON.parse(r);return Object.prototype.hasOwnProperty.call(e,n)}catch{return!1}}async function ye(e){let{name:t,directory:i,packageManager:a=`pnpm`,template:o=`rest`,defaultRepo:c=`inmemory`,packages:l=[],schemaLib:u=`zod`,runtime:d=`express`}=e,p=i,m=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${t}\n`),m(`Resolving package versions...`);let h=await Q(),g=Object.keys(h).filter(e=>h[e]===`latest`);if(g.length>0&&m(`WARNING: could not reach npm for ${g.join(`, `)} — pinned to 'latest'`),d!==`express`){if(ve(`@forinda/kickjs`,`latest`,`./${d}`))m(`Using @forinda/kickjs@latest (stable ships the ${d} runtime)`);else{let e=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-vite`],t=[],n=!1;for(let r of e){let e=ge(r,`alpha`);e&&_e(e,$(h[r]))&&(h[r]=`^${e}`,t.push(`${r}@^${e}`),r===`@forinda/kickjs`&&(n=!0))}m(n?`Using the alpha channel for the ${d} runtime: ${t.join(`, `)}`:`WARNING: could not resolve @forinda/kickjs@alpha — the ${d} runtime subpath may be missing. After install, run: ${a} add @forinda/kickjs@alpha`)}}await n(s(p,`package.json`),T(t,o,h,l,u,d,e.withClientMap)),await n(s(p,`vite.config.ts`),E()),await n(s(p,`tsconfig.json`),te()),await n(s(p,`.oxfmtrc.json`),ne()),await n(s(p,`.editorconfig`),re()),await n(s(p,`.gitignore`),ie()),await n(s(p,`.gitattributes`),ae()),await n(s(p,`.env`),oe()),await n(s(p,`.env.example`),se()),await n(s(p,`.env.test`),D()),await n(s(p,`.env.test.example`),ce()),await n(s(p,`src/config/index.ts`),M(u)),await n(s(p,`src/index.ts`),A(t,o,X.version,l,d,e.spaClientDir)),await n(s(p,`src/modules/index.ts`),j()),await n(s(p,`src/modules/hello/hello.service.ts`),N()),await n(s(p,`src/modules/hello/hello.controller.ts`),P()),await n(s(p,`src/modules/hello/hello.module.ts`),F()),await n(s(p,`kick.config.ts`),I(o,c,a,d,e.withClientMap)),await n(s(p,`vitest.config.ts`),O()),await n(s(p,`README.md`),r(t,o,a));let{generateAgentDocs:_}=await import(`./agent-docs-ckWIFTVN.mjs`).then(e=>e.t);if(await _({outDir:p,name:t,pm:a,template:o,only:`all`,force:!0}),e.installDeps){console.log(`\n Installing dependencies with ${a}...\n`);try{f(`${a} install`,{cwd:p,stdio:`inherit`}),console.log(`
426
- Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${a} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-CoIiSCqa.mjs`).then(e=>e.n);await e({cwd:p,allowDuplicates:!0,silent:!0})}catch{}if(e.initGit)try{f(`git init`,{cwd:p,stdio:`pipe`}),f(`git branch -M main`,{cwd:p,stdio:`pipe`}),f(`git add -A`,{cwd:p,stdio:`pipe`}),f(`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(`
427
- Project scaffolded successfully!`),console.log();let v=p!==process.cwd();m(`Next steps:`),v&&m(` cd ${t}`),e.installDeps||m(` ${a} install`);let y={rest:`kick g module user`,minimal:`# add your routes to src/index.ts`};m(` ${y[o]??y.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> REST module (controller, service, DTOs, repository)`),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> Global connect-style 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> DTO schema (Zod / Valibot / Yup)`),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: ${R}`),m(``)}export{me as a,de as c,b as d,B as i,y as l,Q as n,pe as o,L as r,H as s,ye as t,ee as u};