@forinda/kickjs-cli 8.1.6 → 8.1.7
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-CW5TQHti.mjs → agent-docs-CNKIzlQ5.mjs} +3 -3
- package/dist/{agent-docs-CW5TQHti.mjs.map → agent-docs-CNKIzlQ5.mjs.map} +1 -1
- package/dist/{agent-docs-BBlVl1tY.mjs → agent-docs-DUtJ6p1e.mjs} +2 -2
- package/dist/{build-htBdOg51.mjs → build-C1ya_zWp.mjs} +3 -3
- package/dist/{build-DOI_zYDS.mjs → build-CYRMk2Z8.mjs} +4 -4
- package/dist/{build-DOI_zYDS.mjs.map → build-CYRMk2Z8.mjs.map} +1 -1
- package/dist/{builtins-Cj4BWpIe.mjs → builtins-Byjz8UuR.mjs} +2 -2
- package/dist/{builtins-SMK1mtlk.mjs → builtins-CTvWnQQZ.mjs} +21 -20
- package/dist/cli.mjs +2 -2
- package/dist/{config-BYSNxf_t.mjs → config-BZIWs0bx.mjs} +3 -3
- package/dist/{config-DST3ilXt.mjs → config-BaIkyt4R.mjs} +4 -4
- package/dist/{config-DST3ilXt.mjs.map → config-BaIkyt4R.mjs.map} +1 -1
- package/dist/{doctor-CJYTXARe.mjs → doctor-CtPbmFxW.mjs} +8 -7
- package/dist/{doctor-CJYTXARe.mjs.map → doctor-CtPbmFxW.mjs.map} +1 -1
- package/dist/{fullstack-19gafr4U.mjs → fullstack-KQgV78V3.mjs} +3 -3
- package/dist/{fullstack-Mkw3lkF1.mjs → fullstack-kj0NzeKU.mjs} +4 -4
- package/dist/{fullstack-Mkw3lkF1.mjs.map → fullstack-kj0NzeKU.mjs.map} +1 -1
- package/dist/index.d.mts +22 -22
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/plugin-B240AAOf.mjs +11 -0
- package/dist/{plugin-IEDGa0ny.mjs → plugin-KiE0QPvK.mjs} +2 -2
- package/dist/{project-5ljMCm0U.mjs → project-C5jzgKo-.mjs} +28 -26
- package/dist/{project-CAamSqrL.mjs → project-Dq4SdxF6.mjs} +26 -24
- package/dist/project-Dq4SdxF6.mjs.map +1 -0
- package/dist/{project-docs-CYCi7cHt.mjs → project-docs-CP73I9uv.mjs} +1 -1
- package/dist/{project-docs-at2gZlUE.mjs → project-docs-DRVouPvK.mjs} +2 -2
- package/dist/{project-docs-at2gZlUE.mjs.map → project-docs-DRVouPvK.mjs.map} +1 -1
- package/dist/{project-root-PMRCA_2T.mjs → project-root-BRMuHEs3.mjs} +3 -3
- package/dist/{project-root-PMRCA_2T.mjs.map → project-root-BRMuHEs3.mjs.map} +1 -1
- package/dist/{project-root-BhBKSGeK.mjs → project-root-D4iNxhPu.mjs} +2 -2
- package/dist/{prompts-BxPTyuY3.mjs → prompts-DDlFHtva.mjs} +2 -2
- package/dist/{prompts-BxPTyuY3.mjs.map → prompts-DDlFHtva.mjs.map} +1 -1
- package/dist/{rolldown-runtime-D-i_dFAb.mjs → rolldown-runtime-BAJI6YvG.mjs} +1 -1
- package/dist/{run-plugins-GxEtP9WR.mjs → run-plugins-BYPm9bbY.mjs} +91 -91
- package/dist/run-plugins-BYPm9bbY.mjs.map +1 -0
- package/dist/typegen-BZJk-Lmq.mjs +131 -0
- package/dist/typegen-BdNffFKy.mjs +132 -0
- package/dist/{typegen-CJvd5MEz.mjs.map → typegen-BdNffFKy.mjs.map} +1 -1
- package/dist/{types-PxKCj-JF.mjs → types-D8Vtq4vL.mjs} +1 -1
- package/package.json +6 -6
- package/dist/plugin-Cfiz2G3K.mjs +0 -12
- package/dist/plugin-Cfiz2G3K.mjs.map +0 -1
- package/dist/project-CAamSqrL.mjs.map +0 -1
- package/dist/run-plugins-GxEtP9WR.mjs.map +0 -1
- package/dist/typegen-CJvd5MEz.mjs +0 -132
- package/dist/typegen-D7aeVM0D.mjs +0 -131
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.1.
|
|
2
|
+
* @forinda/kickjs-cli v8.1.7
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{a as e,t}from"./config-
|
|
11
|
+
import{a as e,t}from"./config-BZIWs0bx.mjs";import{l as n,o as r}from"./project-docs-CP73I9uv.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
12
|
import { fileURLToPath } from 'node:url'
|
|
13
13
|
import swc from 'unplugin-swc'
|
|
14
14
|
import { kickjsVitePlugin, envWatchPlugin } from '@forinda/kickjs-vite'
|
|
@@ -38,7 +38,7 @@ export default defineConfig({
|
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
})
|
|
41
|
-
`}function
|
|
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
42
|
root = true
|
|
43
43
|
|
|
44
44
|
[*]
|
|
@@ -51,17 +51,18 @@ insert_final_newline = true
|
|
|
51
51
|
|
|
52
52
|
[*.md]
|
|
53
53
|
trim_trailing_whitespace = false
|
|
54
|
-
`}function
|
|
54
|
+
`}function ie(){return`node_modules/
|
|
55
55
|
dist/
|
|
56
56
|
.env
|
|
57
|
-
#
|
|
58
|
-
#
|
|
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
|
|
59
60
|
*.local
|
|
60
61
|
coverage/
|
|
61
62
|
.DS_Store
|
|
62
63
|
*.tsbuildinfo
|
|
63
64
|
.kickjs/
|
|
64
|
-
`}function
|
|
65
|
+
`}function ae(){return`# Auto-detect text files and normalise line endings to LF
|
|
65
66
|
* text=auto eol=lf
|
|
66
67
|
|
|
67
68
|
# Explicitly mark generated / binary files
|
|
@@ -79,21 +80,22 @@ coverage/
|
|
|
79
80
|
pnpm-lock.yaml -diff linguist-generated
|
|
80
81
|
yarn.lock -diff linguist-generated
|
|
81
82
|
package-lock.json -diff linguist-generated
|
|
82
|
-
`}function
|
|
83
|
+
`}function oe(){return`PORT=3000
|
|
83
84
|
NODE_ENV=development
|
|
84
|
-
`}function
|
|
85
|
+
`}function se(){return`PORT=3000
|
|
85
86
|
NODE_ENV=development
|
|
86
|
-
`}function
|
|
87
|
+
`}function D(){return`# Read INSTEAD of .env when NODE_ENV=test (or under vitest).
|
|
87
88
|
# No fallback to .env — declare here everything the suite needs, so a
|
|
88
89
|
# missing var fails the run instead of silently resolving to your dev value.
|
|
89
90
|
#
|
|
90
|
-
#
|
|
91
|
-
#
|
|
92
|
-
# everyone who clones the repo.
|
|
91
|
+
# Not committed. Add new keys to .env.test.example too, with placeholder
|
|
92
|
+
# values — never real endpoints or credentials.
|
|
93
93
|
NODE_ENV=test
|
|
94
94
|
PORT=0
|
|
95
95
|
LOG_LEVEL=silent
|
|
96
|
-
`}function
|
|
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'
|
|
97
99
|
import viteConfig from './vite.config.ts'
|
|
98
100
|
|
|
99
101
|
// A \`vitest.config.ts\` OVERRIDES \`vite.config.ts\` outright — vitest does not
|
|
@@ -111,7 +113,7 @@ export default mergeConfig(
|
|
|
111
113
|
},
|
|
112
114
|
}),
|
|
113
115
|
)
|
|
114
|
-
`}const
|
|
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.
|
|
115
117
|
// Inert until the client build exists, so \`kick dev\` (where Vite
|
|
116
118
|
// serves the client and proxies /api here) is unaffected.
|
|
117
119
|
SpaAdapter({ clientDir: ${JSON.stringify(a)} }),`));let l=t.length?t.join(`
|
|
@@ -158,14 +160,14 @@ export const app = await bootstrap({
|
|
|
158
160
|
requestLogger(),${d}
|
|
159
161
|
],
|
|
160
162
|
})
|
|
161
|
-
`}}}function
|
|
163
|
+
`}}}function j(){return`import { defineModules } from '@forinda/kickjs'
|
|
162
164
|
import { HelloModule } from './hello/hello.module'
|
|
163
165
|
|
|
164
166
|
// Remove HelloModule and run: kick g module <name>
|
|
165
167
|
// \`defineModules()\` returns a chainable list — \`kick g module\` appends
|
|
166
168
|
// \`.mount(NewModule())\` to the chain on every generation.
|
|
167
169
|
export const modules = defineModules().mount(HelloModule())
|
|
168
|
-
`}function
|
|
170
|
+
`}function M(e=`zod`){return e===`valibot`?`import { loadEnvFromSchema } from '@forinda/kickjs/config'
|
|
169
171
|
import { fromValibot } from '@forinda/kickjs-schema/valibot'
|
|
170
172
|
import * as v from 'valibot'
|
|
171
173
|
|
|
@@ -293,7 +295,7 @@ const envSchema = fromZod(
|
|
|
293
295
|
export const env = loadEnvFromSchema(envSchema)
|
|
294
296
|
|
|
295
297
|
export default envSchema
|
|
296
|
-
`}function
|
|
298
|
+
`}function N(){return`import { Service } from '@forinda/kickjs'
|
|
297
299
|
|
|
298
300
|
@Service()
|
|
299
301
|
export class HelloService {
|
|
@@ -305,7 +307,7 @@ export class HelloService {
|
|
|
305
307
|
return { status: 'ok', uptime: process.uptime() }
|
|
306
308
|
}
|
|
307
309
|
}
|
|
308
|
-
`}function
|
|
310
|
+
`}function P(){return`import { Controller, Get, Autowired, type Ctx } from '@forinda/kickjs'
|
|
309
311
|
import { HelloService } from './hello.service'
|
|
310
312
|
|
|
311
313
|
// \`Ctx<KickRoutes.HelloController['<method>']>\` is generated by
|
|
@@ -331,7 +333,7 @@ export class HelloController {
|
|
|
331
333
|
return this.helloService.healthCheck()
|
|
332
334
|
}
|
|
333
335
|
}
|
|
334
|
-
`}function
|
|
336
|
+
`}function F(){return`import { defineModule } from '@forinda/kickjs'
|
|
335
337
|
import { HelloController } from './hello.controller'
|
|
336
338
|
|
|
337
339
|
export const HelloModule = defineModule({
|
|
@@ -352,7 +354,7 @@ export const HelloModule = defineModule({
|
|
|
352
354
|
},
|
|
353
355
|
}),
|
|
354
356
|
})
|
|
355
|
-
`}function
|
|
357
|
+
`}function I(e,t=`inmemory`,n=`pnpm`,r=`express`,i=!1){return`import { defineConfig } from '@forinda/kickjs-cli'
|
|
356
358
|
|
|
357
359
|
export default defineConfig({
|
|
358
360
|
pattern: '${e}',
|
|
@@ -413,13 +415,13 @@ export default defineConfig({
|
|
|
413
415
|
},
|
|
414
416
|
],
|
|
415
417
|
})
|
|
416
|
-
`}const
|
|
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(`
|
|
417
419
|
Core packages (always installed by \`kick new\`):
|
|
418
420
|
`);for(let e of i)console.log(o(e));if(e){console.log(`
|
|
419
421
|
Optional packages (add as needed):
|
|
420
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(`
|
|
421
|
-
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
|
|
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.
|
|
422
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!
|
|
423
|
-
`)}})}const
|
|
424
|
-
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${a} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-
|
|
425
|
-
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`,ddd:`kick g module user --repo drizzle`,cqrs:`kick g module user --pattern cqrs`,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> 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> 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: ${
|
|
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-DUtJ6p1e.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-BZJk-Lmq.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`,ddd:`kick g module user --repo drizzle`,cqrs:`kick g module user --pattern cqrs`,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> 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> 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};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.1.
|
|
2
|
+
* @forinda/kickjs-cli v8.1.7
|
|
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-DRVouPvK.mjs";import{o as n,t as r}from"./config-BaIkyt4R.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{execFile as l,execFileSync as u,execSync as d,spawnSync as f}from"node:child_process";import{fileURLToPath as p}from"node:url";import{promisify as m}from"node:util";const h={express:{from:`@forinda/kickjs`,name:`expressRuntime`},fastify:{from:`@forinda/kickjs/fastify`,name:`fastifyRuntime`},h3:{from:`@forinda/kickjs/h3`,name:`h3Runtime`}};function g(e,t,n,r=[],i=`express`,a){let o=h[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.
|
|
12
12
|
// Inert until the client build exists, so \`kick dev\` (where Vite
|
|
13
13
|
// serves the client and proxies /api here) is unaffected.
|
|
14
14
|
SpaAdapter({ clientDir: ${JSON.stringify(a)} }),`));let l=t.length?t.join(`
|
|
@@ -62,7 +62,7 @@ import { HelloModule } from './hello/hello.module'
|
|
|
62
62
|
// \`defineModules()\` returns a chainable list — \`kick g module\` appends
|
|
63
63
|
// \`.mount(NewModule())\` to the chain on every generation.
|
|
64
64
|
export const modules = defineModules().mount(HelloModule())
|
|
65
|
-
`}function
|
|
65
|
+
`}function ee(e=`zod`){return e===`valibot`?`import { loadEnvFromSchema } from '@forinda/kickjs/config'
|
|
66
66
|
import { fromValibot } from '@forinda/kickjs-schema/valibot'
|
|
67
67
|
import * as v from 'valibot'
|
|
68
68
|
|
|
@@ -190,7 +190,7 @@ const envSchema = fromZod(
|
|
|
190
190
|
export const env = loadEnvFromSchema(envSchema)
|
|
191
191
|
|
|
192
192
|
export default envSchema
|
|
193
|
-
`}function
|
|
193
|
+
`}function v(){return`import { Service } from '@forinda/kickjs'
|
|
194
194
|
|
|
195
195
|
@Service()
|
|
196
196
|
export class HelloService {
|
|
@@ -202,7 +202,7 @@ export class HelloService {
|
|
|
202
202
|
return { status: 'ok', uptime: process.uptime() }
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
`}function
|
|
205
|
+
`}function y(){return`import { Controller, Get, Autowired, type Ctx } from '@forinda/kickjs'
|
|
206
206
|
import { HelloService } from './hello.service'
|
|
207
207
|
|
|
208
208
|
// \`Ctx<KickRoutes.HelloController['<method>']>\` is generated by
|
|
@@ -310,7 +310,7 @@ export default defineConfig({
|
|
|
310
310
|
},
|
|
311
311
|
],
|
|
312
312
|
})
|
|
313
|
-
`}const S=m(l),C=/[&|<>^"'`(){}[\];!%\r\n\\]/;function w(e,t,n=process.platform){if(n!==`win32`)return[e,t];if(C.test(e)||t.some(e=>C.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 T(e,t,n={}){let r=w(e,t);if(!r)return null;try{return u(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 E(e,t,n={}){let r=w(e,t);if(!r)throw Error(`Refusing to run '${e}': unsafe arguments`);u(r[0],r[1],{cwd:n.cwd,stdio:`inherit`,windowsHide:!0})}function D(e,t,n){let r=f(process.execPath,[e],{cwd:n,stdio:`inherit`,env:{...process.env,...t}});r.status!==0&&process.exit(r.status??1)}async function
|
|
313
|
+
`}const S=m(l),C=/[&|<>^"'`(){}[\];!%\r\n\\]/;function w(e,t,n=process.platform){if(n!==`win32`)return[e,t];if(C.test(e)||t.some(e=>C.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 T(e,t,n={}){let r=w(e,t);if(!r)return null;try{return u(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 E(e,t,n={}){let r=w(e,t);if(!r)throw Error(`Refusing to run '${e}': unsafe arguments`);u(r[0],r[1],{cwd:n.cwd,stdio:`inherit`,windowsHide:!0})}function D(e,t,n){let r=f(process.execPath,[e],{cwd:n,stdio:`inherit`,env:{...process.env,...t}});r.status!==0&&process.exit(r.status??1)}async function O(e,t,n={}){let r=w(e,t);if(!r)return null;try{let{stdout:e}=await S(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 k={swagger:`@forinda/kickjs-swagger`,ws:`@forinda/kickjs-ws`,queue:`@forinda/kickjs-queue`,devtools:`@forinda/kickjs-devtools`},A={zod:{name:`zod`,range:`^4.3.6`},valibot:{name:`valibot`,range:`^1.4.1`},yup:{name:`yup`,range:`^1.7.1`}};function j(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 te(e,t,n,r=[],i=`zod`,a=`express`,o=!1){let s=A[i],c={"@forinda/kickjs":j(n,`@forinda/kickjs`),"@forinda/kickjs-schema":j(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=k[e];t&&!c[t]&&(c[t]=j(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":j(n,`@forinda/kickjs-cli`),"@forinda/kickjs-testing":j(n,`@forinda/kickjs-testing`),"@forinda/kickjs-vite":j(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 ne(){return`import { defineConfig } from 'vite'
|
|
314
314
|
import { fileURLToPath } from 'node:url'
|
|
315
315
|
import swc from 'unplugin-swc'
|
|
316
316
|
import { kickjsVitePlugin, envWatchPlugin } from '@forinda/kickjs-vite'
|
|
@@ -340,7 +340,7 @@ export default defineConfig({
|
|
|
340
340
|
},
|
|
341
341
|
},
|
|
342
342
|
})
|
|
343
|
-
`}function
|
|
343
|
+
`}function re(){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 ie(){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 ae(){return`# https://editorconfig.org
|
|
344
344
|
root = true
|
|
345
345
|
|
|
346
346
|
[*]
|
|
@@ -353,17 +353,18 @@ insert_final_newline = true
|
|
|
353
353
|
|
|
354
354
|
[*.md]
|
|
355
355
|
trim_trailing_whitespace = false
|
|
356
|
-
`}function
|
|
356
|
+
`}function M(){return`node_modules/
|
|
357
357
|
dist/
|
|
358
358
|
.env
|
|
359
|
-
#
|
|
360
|
-
#
|
|
359
|
+
# Machine-specific: each developer's test env differs (database names, ports).
|
|
360
|
+
# The shared template is the committed \`.env.test.example\`.
|
|
361
|
+
.env.test
|
|
361
362
|
*.local
|
|
362
363
|
coverage/
|
|
363
364
|
.DS_Store
|
|
364
365
|
*.tsbuildinfo
|
|
365
366
|
.kickjs/
|
|
366
|
-
`}function
|
|
367
|
+
`}function N(){return`# Auto-detect text files and normalise line endings to LF
|
|
367
368
|
* text=auto eol=lf
|
|
368
369
|
|
|
369
370
|
# Explicitly mark generated / binary files
|
|
@@ -381,21 +382,22 @@ coverage/
|
|
|
381
382
|
pnpm-lock.yaml -diff linguist-generated
|
|
382
383
|
yarn.lock -diff linguist-generated
|
|
383
384
|
package-lock.json -diff linguist-generated
|
|
384
|
-
`}function N(){return`PORT=3000
|
|
385
|
-
NODE_ENV=development
|
|
386
385
|
`}function P(){return`PORT=3000
|
|
387
386
|
NODE_ENV=development
|
|
388
|
-
`}function F(){return
|
|
387
|
+
`}function F(){return`PORT=3000
|
|
388
|
+
NODE_ENV=development
|
|
389
|
+
`}function I(){return`# Read INSTEAD of .env when NODE_ENV=test (or under vitest).
|
|
389
390
|
# No fallback to .env — declare here everything the suite needs, so a
|
|
390
391
|
# missing var fails the run instead of silently resolving to your dev value.
|
|
391
392
|
#
|
|
392
|
-
#
|
|
393
|
-
#
|
|
394
|
-
# everyone who clones the repo.
|
|
393
|
+
# Not committed. Add new keys to .env.test.example too, with placeholder
|
|
394
|
+
# values — never real endpoints or credentials.
|
|
395
395
|
NODE_ENV=test
|
|
396
396
|
PORT=0
|
|
397
397
|
LOG_LEVEL=silent
|
|
398
|
-
`}function
|
|
398
|
+
`}function L(){return`# Template for .env.test. Copy it and fill in your machine's values:
|
|
399
|
+
# cp .env.test.example .env.test
|
|
400
|
+
${I()}`}function R(){return`import { defineConfig, mergeConfig } from 'vitest/config'
|
|
399
401
|
import viteConfig from './vite.config.ts'
|
|
400
402
|
|
|
401
403
|
// A \`vitest.config.ts\` OVERRIDES \`vite.config.ts\` outright — vitest does not
|
|
@@ -413,14 +415,14 @@ export default mergeConfig(
|
|
|
413
415
|
},
|
|
414
416
|
}),
|
|
415
417
|
)
|
|
416
|
-
`}const
|
|
418
|
+
`}const z={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}},B=Object.entries(z).filter(([e,t])=>!t.core&&!t.deprecated&&!e.includes(`:`)&&![`pg`,`sqlite`,`mysql`,`zod`,`valibot`,`yup`].includes(e)).map(([e])=>e).join(`, `),V={express:[`express`],fastify:[`fastify`,`@fastify/middie`,`serve-static`],h3:[`h3`,`serve-static`]},H={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 U(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 W(e=process.cwd()){return(await G(e)).runtime}async function G(e=process.cwd()){let t=(await n(e))?.runtime;return t===`express`||t===`fastify`||t===`h3`?{runtime:t,candidates:[t],ambiguous:!1,fromConfig:!0}:{...oe(e),fromConfig:!1}}const K=[[`express`,`express`],[`fastify`,`fastify`],[`h3`,`h3`]];function oe(e=process.cwd()){let t=q(`package.json`,e);if(!t)return{runtime:`express`,candidates:[],ambiguous:!1};let n={},r={};try{let e=JSON.parse(c(o(t,`package.json`),`utf-8`));n=e.dependencies??{},r=e.devDependencies??{}}catch{return{runtime:`express`,candidates:[],ambiguous:!1}}let i=K.filter(([e])=>e in n).map(([,e])=>e),a=K.filter(([e])=>e in r&&!(e in n)).map(([,e])=>e),s=[...i,...a];return i.length===1?{runtime:i[0],candidates:s,ambiguous:!1}:i.length===0&&a.length===1?{runtime:a[0],candidates:s,ambiguous:!1}:s.length===0?{runtime:`express`,candidates:s,ambiguous:!1}:{runtime:`express`,candidates:s,ambiguous:!0}}function q(e,t=process.cwd()){let n=t;for(;;){if(s(o(n,e)))return n;let t=i(n);if(t===n)return null;n=t}}function se(){return q(`pnpm-lock.yaml`)?`pnpm`:q(`yarn.lock`)?`yarn`:q(`bun.lockb`)||q(`bun.lock`)?`bun`:q(`package-lock.json`)?`npm`:null}function ce(){let e=process.cwd();for(;e;){let t=o(e,`package.json`);if(s(t))try{let e=JSON.parse(c(t,`utf-8`)).packageManager;if(typeof e==`string`){let t=e.split(`@`)[0];if(r.includes(t))return t}}catch{}let n=i(e);if(n===e)return null;e=n}return null}async function J(e){if(e&&r.includes(e))return{pm:e,source:`flag`};let t=await n(process.cwd());if(t?.packageManager&&r.includes(t.packageManager))return{pm:t.packageManager,source:`config`};let i=ce();if(i)return{pm:i,source:`package.json`};let a=se();return a?{pm:a,source:`lockfile`}:{pm:`npm`,source:`default`}}async function le(e){let{pm:t}=await J(e);return t}function Y(e=!1,t){let n=Object.entries(z),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,...V[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(`
|
|
417
419
|
Core packages (always installed by \`kick new\`):
|
|
418
420
|
`);for(let e of i)console.log(o(e));if(e){console.log(`
|
|
419
421
|
Optional packages (add as needed):
|
|
420
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(`
|
|
421
|
-
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 ue(e,t,n=`express`){let r=new Set,i=new Set,a=[],o=[],s=[];for(let c of e){if(c===`upload`){let e=
|
|
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 ue(e,t,n=`express`){let r=new Set,i=new Set,a=[],o=[],s=[];for(let c of e){if(c===`upload`){let e=H[n];s.push(`upload (${n}): ${e.note}`),e.prod&&(t?i:r).add(e.prod),e.dev&&i.add(e.dev);continue}let e=z[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=V[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 de(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=>{Y(!!e.all,U(e.runtime)??await W())})}function fe(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){Y(!!t.all,U(t.runtime)??await W());return}let{pm:n,source:r}=await J(t.pm);console.log(`\n Using ${n} (resolved from ${r})`);let i=U(t.runtime),a=await G(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:f}=ue(e,!!t.dev,o);for(let e of u)console.warn(`\n WARNING: ${e}`);for(let e of f)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.
|
|
422
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{d(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{d(t,{stdio:`inherit`})}catch{console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}console.log(` Done!
|
|
423
|
-
`)}})}const
|
|
424
|
-
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${o} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-
|
|
425
|
-
Project scaffolded successfully!`),console.log();let w=p!==process.cwd();m(`Next steps:`),w&&m(` cd ${r}`),n.installDeps||m(` ${o} install`);let T={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(` ${T[s]??T.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> 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: ${
|
|
426
|
-
//# sourceMappingURL=project-
|
|
425
|
+
`)}})}const X=i(p(import.meta.url)),Z=JSON.parse(c([a(X,`..`,`package.json`),a(X,`..`,`..`,`package.json`)].find(s),`utf-8`)),pe=[`@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 me(e){return e===`@forinda/kickjs-cli`?`^${Z.version}`:`latest`}async function Q(){let e=await Promise.all(pe.map(async e=>{let t=await O(`npm`,[`view`,e,`version`],{timeout:2e4});return t&&/^\d+\.\d+\.\d+/.test(t)?[e,`^${t}`]:[e,me(e)]}));return Object.fromEntries(e)}function he(e,t){let n=T(`npm`,[`view`,`${e}@${t}`,`version`],{timeout:2e4});return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}function $(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function ge(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 _e(e,t,n){let r=T(`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 ve(n){let{name:r,directory:i,packageManager:o=`pnpm`,template:s=`rest`,defaultRepo:c=`inmemory`,packages:l=[],schemaLib:u=`zod`,runtime:f=`express`}=n,p=i,m=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${r}\n`),m(`Resolving package versions...`);let h=await Q(),S=Object.keys(h).filter(e=>h[e]===`latest`);if(S.length>0&&m(`WARNING: could not reach npm for ${S.join(`, `)} — pinned to 'latest'`),f!==`express`){if(_e(`@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=he(r,`alpha`);e&&ge(e,$(h[r]))&&(h[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: ${o} add @forinda/kickjs@alpha`)}}await e(a(p,`package.json`),te(r,s,h,l,u,f,n.withClientMap)),await e(a(p,`vite.config.ts`),ne()),await e(a(p,`tsconfig.json`),re()),await e(a(p,`.oxfmtrc.json`),ie()),await e(a(p,`.editorconfig`),ae()),await e(a(p,`.gitignore`),M()),await e(a(p,`.gitattributes`),N()),await e(a(p,`.env`),P()),await e(a(p,`.env.example`),F()),await e(a(p,`.env.test`),I()),await e(a(p,`.env.test.example`),L()),await e(a(p,`src/config/index.ts`),ee(u)),await e(a(p,`src/index.ts`),g(r,s,Z.version,l,f,n.spaClientDir)),await e(a(p,`src/modules/index.ts`),_()),await e(a(p,`src/modules/hello/hello.service.ts`),v()),await e(a(p,`src/modules/hello/hello.controller.ts`),y()),await e(a(p,`src/modules/hello/hello.module.ts`),b()),await e(a(p,`kick.config.ts`),x(s,c,o,f,n.withClientMap)),await e(a(p,`vitest.config.ts`),R()),await e(a(p,`README.md`),t(r,s,o));let{generateAgentDocs:C}=await import(`./agent-docs-CNKIzlQ5.mjs`).then(e=>e.t);if(await C({outDir:p,name:r,pm:o,template:s,only:`all`,force:!0}),n.installDeps){console.log(`\n Installing dependencies with ${o}...\n`);try{d(`${o} install`,{cwd:p,stdio:`inherit`}),console.log(`
|
|
426
|
+
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${o} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-BdNffFKy.mjs`).then(e=>e.n);await e({cwd:p,allowDuplicates:!0,silent:!0})}catch{}if(n.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(`
|
|
427
|
+
Project scaffolded successfully!`),console.log();let w=p!==process.cwd();m(`Next steps:`),w&&m(` cd ${r}`),n.installDeps||m(` ${o} install`);let T={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(` ${T[s]??T.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> 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: ${B}`),m(``)}export{fe as a,le as c,H as i,E as l,Q as n,de as o,z as r,W as s,ve as t,D as u};
|
|
428
|
+
//# sourceMappingURL=project-Dq4SdxF6.mjs.map
|