@forinda/kickjs-cli 6.1.0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{agent-docs-DB5y-kvS.mjs → agent-docs-GpRHHdWC.mjs} +3 -3
- package/dist/{agent-docs-DB5y-kvS.mjs.map → agent-docs-GpRHHdWC.mjs.map} +1 -1
- package/dist/{build-9YFC7Rd4.mjs → build-D9X9QBkC.mjs} +3 -3
- package/dist/{build-9YFC7Rd4.mjs.map → build-D9X9QBkC.mjs.map} +1 -1
- package/dist/{builtins-mr3TIDa8.mjs → builtins-DHcybuaw.mjs} +2 -2
- package/dist/cli.mjs +6 -6
- package/dist/{config-Dc4XuP2E.mjs → config-DLy6JCCy.mjs} +3 -3
- package/dist/{config-Dc4XuP2E.mjs.map → config-DLy6JCCy.mjs.map} +1 -1
- package/dist/{doctor-shX-k8ju.mjs → doctor-CcVNNzGj.mjs} +6 -6
- package/dist/{doctor-shX-k8ju.mjs.map → doctor-CcVNNzGj.mjs.map} +1 -1
- package/dist/index.d.mts +8 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{plugin-DVOWYRqG.mjs → plugin-C6jhcq0N.mjs} +3 -3
- package/dist/{plugin-DVOWYRqG.mjs.map → plugin-C6jhcq0N.mjs.map} +1 -1
- package/dist/{project-docs-Cq_MswOY.mjs → project-docs-CqOymvmb.mjs} +2 -2
- package/dist/{project-docs-Cq_MswOY.mjs.map → project-docs-CqOymvmb.mjs.map} +1 -1
- package/dist/{project-root-C3u57Vec.mjs → project-root-yLxS5CqO.mjs} +3 -3
- package/dist/{project-root-C3u57Vec.mjs.map → project-root-yLxS5CqO.mjs.map} +1 -1
- package/dist/{rolldown-runtime-BMxBusPc.mjs → rolldown-runtime-BnMWUWuC.mjs} +1 -1
- package/dist/{run-plugins-COniKxrL.mjs → run-plugins-CubT9x_A.mjs} +5 -5
- package/dist/run-plugins-CubT9x_A.mjs.map +1 -0
- package/dist/{typegen-DPATg8Ix.mjs → typegen-BJwy65-p.mjs} +5 -5
- package/dist/{typegen-DPATg8Ix.mjs.map → typegen-BJwy65-p.mjs.map} +1 -1
- package/dist/{types-B2r_OeIa.mjs → types-D7d_Y66D.mjs} +1 -1
- package/package.json +4 -4
- package/dist/run-plugins-COniKxrL.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v6.1.
|
|
2
|
+
* @forinda/kickjs-cli v6.1.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{b as e,c as t,d as n,g as r,l as i,o as a,s as o,v as s}from"./project-docs-
|
|
11
|
+
import{b as e,c as t,d as n,g as r,l as i,o as a,s as o,v as s}from"./project-docs-CqOymvmb.mjs";import{i as c}from"./config-DLy6JCCy.mjs";import{t as l}from"./project-root-yLxS5CqO.mjs";import{createRequire as u}from"node:module";import d,{dirname as f,join as p,relative as m,resolve as h}from"node:path";import{existsSync as g,readFileSync as _,readdirSync as v,statSync as y}from"node:fs";import{readFile as b,writeFile as x}from"node:fs/promises";import S from"pluralize";import{execFileSync as C,execSync as w}from"node:child_process";import{fileURLToPath as ee,pathToFileURL as te}from"node:url";import{defineGenerator as ne}from"@forinda/kickjs-cli-kit";function T(e){return e.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():``).replace(/^(.)/,e=>e.toUpperCase())}function E(e){let t=T(e);return t.charAt(0).toLowerCase()+t.slice(1)}function D(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/[\s_]+/g,`-`).toLowerCase()}function O(e){return S.plural(e)}function k(e){return S.plural(e)}function A(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function re(e){return e.charAt(0).toUpperCase()+e.slice(1).replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function ie(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}function ae(e,t,n){let r={inmemory:`InMemory${e}Repository`,drizzle:`Drizzle${e}Repository`,prisma:`Prisma${e}Repository`},i={inmemory:`in-memory-${t}`,drizzle:`drizzle-${t}`,prisma:`prisma-${t}`};return{repoClass:r[n]??`${re(n)}${e}Repository`,repoFile:i[n]??`${ie(n)}-${t}`}}function j(e){return e??`define`}function M(e){let{pascal:t,kebab:n,plural:r=``,repo:i,style:a}=e,{repoClass:o,repoFile:s}=ae(t,n,i),c=j(a),l=`/**
|
|
12
12
|
* ${t} Module
|
|
13
13
|
*
|
|
14
14
|
* REST module with a flat folder structure.
|
|
@@ -1207,9 +1207,9 @@ export default defineConfig({
|
|
|
1207
1207
|
include: ['src/**/*.test.ts'],
|
|
1208
1208
|
},
|
|
1209
1209
|
})
|
|
1210
|
-
`}const We=f(ee(import.meta.url)),K=JSON.parse(_(p(We,`..`,`package.json`),`utf-8`)),Ge=`^${K.version}`,Ke=[`@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`];async function qe(){let e=await Promise.all(Ke.map(async e=>{try{let t=C(`npm`,[`view`,e,`version`],{encoding:`utf-8`,timeout:5e3,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim();if(t&&/^\d+\.\d+\.\d+/.test(t))return[e,`^${t}`]}catch{}return[e,Ge]}));return Object.fromEntries(e)}async function Je(t){let{name:n,directory:r,packageManager:i=`pnpm`,template:o=`rest`,defaultRepo:s=`inmemory`,packages:c=[],schemaLib:l=`zod`}=t,u=r,d=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${n}\n`),d(`Resolving package versions...`);let f=await qe();await e(p(u,`package.json`),Pe(n,o,f,c,l)),await e(p(u,`vite.config.ts`),Fe()),await e(p(u,`tsconfig.json`),Ie()),await e(p(u,`.prettierrc`),Le()),await e(p(u,`.editorconfig`),Re()),await e(p(u,`.gitignore`),ze()),await e(p(u,`.gitattributes`),Be()),await e(p(u,`.env`),Ve()),await e(p(u,`.env.example`),He()),await e(p(u,`src/config/index.ts`),me(l)),await e(p(u,`src/index.ts`),fe(n,o,K.version,c)),await e(p(u,`src/modules/index.ts`),pe()),await e(p(u,`src/modules/hello/hello.service.ts`),he()),await e(p(u,`src/modules/hello/hello.controller.ts`),ge()),await e(p(u,`src/modules/hello/hello.module.ts`),_e()),await e(p(u,`kick.config.ts`),ve(o,s,i)),await e(p(u,`vitest.config.ts`),Ue()),await e(p(u,`README.md`),a(n,o,i));let{generateAgentDocs:m}=await import(`./agent-docs-
|
|
1211
|
-
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${i} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-
|
|
1212
|
-
Project scaffolded successfully!`),console.log();let h=u!==process.cwd();d(`Next steps:`),h&&d(` cd ${n}`),t.installDeps||d(` ${i} install`);let g={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`};d(` ${g[o]??g.rest}`),d(` kick dev`),d(``),d(`Commands:`),d(` kick dev Start dev server with Vite HMR`),d(` kick build Production build via Vite`),d(` kick start Run production build`),d(``),d(`Generators:`),d(` kick g module <name> Full DDD module (controller, DTOs, use-cases, repo)`),d(` kick g scaffold <n> <f..> CRUD module from field definitions`),d(` kick g controller <name> Standalone controller`),d(` kick g service <name> @Service() class`),d(` kick g middleware <name> Express middleware`),d(` kick g guard <name> Route guard (auth, roles, etc.)`),d(` kick g adapter <name> AppAdapter with lifecycle hooks`),d(` kick g dto <name> Zod DTO schema`),d(` kick g config Generate kick.config.ts`),d(``),d(`Add packages:`),d(` kick add <pkg> Install a KickJS package + peers`),d(` kick add --list Show all available packages`),d(``),d(`Available: auth, swagger, drizzle, prisma, ws, queue, devtools, mcp, testing`),d(``)}function Ye(e){let t=new Map;return{report(n,r){let i=r instanceof Error?r.message:String(r);t.get(n)!==i&&(t.set(n,i),e(` kick typegen: ${n} pass failed (${i}) — types in .kickjs/types may be stale`))},clear(e){t.delete(e)}}}const Xe=`__kickjs_typegen_owner`;function Ze(e){let{cwd:t,config:n}=e,r=e.debounceMs??100,i=e.pipeline??{runTypegen:async e=>(await import(`./typegen-
|
|
1210
|
+
`}const We=f(ee(import.meta.url)),K=JSON.parse(_(p(We,`..`,`package.json`),`utf-8`)),Ge=`^${K.version}`,Ke=[`@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`];async function qe(){let e=await Promise.all(Ke.map(async e=>{try{let t=C(`npm`,[`view`,e,`version`],{encoding:`utf-8`,timeout:5e3,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim();if(t&&/^\d+\.\d+\.\d+/.test(t))return[e,`^${t}`]}catch{}return[e,Ge]}));return Object.fromEntries(e)}async function Je(t){let{name:n,directory:r,packageManager:i=`pnpm`,template:o=`rest`,defaultRepo:s=`inmemory`,packages:c=[],schemaLib:l=`zod`}=t,u=r,d=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${n}\n`),d(`Resolving package versions...`);let f=await qe();await e(p(u,`package.json`),Pe(n,o,f,c,l)),await e(p(u,`vite.config.ts`),Fe()),await e(p(u,`tsconfig.json`),Ie()),await e(p(u,`.prettierrc`),Le()),await e(p(u,`.editorconfig`),Re()),await e(p(u,`.gitignore`),ze()),await e(p(u,`.gitattributes`),Be()),await e(p(u,`.env`),Ve()),await e(p(u,`.env.example`),He()),await e(p(u,`src/config/index.ts`),me(l)),await e(p(u,`src/index.ts`),fe(n,o,K.version,c)),await e(p(u,`src/modules/index.ts`),pe()),await e(p(u,`src/modules/hello/hello.service.ts`),he()),await e(p(u,`src/modules/hello/hello.controller.ts`),ge()),await e(p(u,`src/modules/hello/hello.module.ts`),_e()),await e(p(u,`kick.config.ts`),ve(o,s,i)),await e(p(u,`vitest.config.ts`),Ue()),await e(p(u,`README.md`),a(n,o,i));let{generateAgentDocs:m}=await import(`./agent-docs-GpRHHdWC.mjs`).then(e=>e.t);if(await m({outDir:u,name:n,pm:i,template:o,only:`all`,force:!0}),t.installDeps){console.log(`\n Installing dependencies with ${i}...\n`);try{w(`${i} install`,{cwd:u,stdio:`inherit`}),console.log(`
|
|
1211
|
+
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${i} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-BJwy65-p.mjs`).then(e=>e.n);await e({cwd:u,allowDuplicates:!0,silent:!0})}catch{}if(t.initGit)try{w(`git init`,{cwd:u,stdio:`pipe`}),w(`git branch -M main`,{cwd:u,stdio:`pipe`}),w(`git add -A`,{cwd:u,stdio:`pipe`}),w(`git commit -m "chore: initial commit from kick new"`,{cwd:u,stdio:`pipe`}),d(`Git repository initialized`)}catch{d(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
1212
|
+
Project scaffolded successfully!`),console.log();let h=u!==process.cwd();d(`Next steps:`),h&&d(` cd ${n}`),t.installDeps||d(` ${i} install`);let g={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`};d(` ${g[o]??g.rest}`),d(` kick dev`),d(``),d(`Commands:`),d(` kick dev Start dev server with Vite HMR`),d(` kick build Production build via Vite`),d(` kick start Run production build`),d(``),d(`Generators:`),d(` kick g module <name> Full DDD module (controller, DTOs, use-cases, repo)`),d(` kick g scaffold <n> <f..> CRUD module from field definitions`),d(` kick g controller <name> Standalone controller`),d(` kick g service <name> @Service() class`),d(` kick g middleware <name> Express middleware`),d(` kick g guard <name> Route guard (auth, roles, etc.)`),d(` kick g adapter <name> AppAdapter with lifecycle hooks`),d(` kick g dto <name> Zod DTO schema`),d(` kick g config Generate kick.config.ts`),d(``),d(`Add packages:`),d(` kick add <pkg> Install a KickJS package + peers`),d(` kick add --list Show all available packages`),d(``),d(`Available: auth, swagger, drizzle, prisma, ws, queue, devtools, mcp, testing`),d(``)}function Ye(e){let t=new Map;return{report(n,r){let i=r instanceof Error?r.message:String(r);t.get(n)!==i&&(t.set(n,i),e(` kick typegen: ${n} pass failed (${i}) — types in .kickjs/types may be stale`))},clear(e){t.delete(e)}}}const Xe=`__kickjs_typegen_owner`;function Ze(e){let{cwd:t,config:n}=e,r=e.debounceMs??100,i=e.pipeline??{runTypegen:async e=>(await import(`./typegen-BJwy65-p.mjs`).then(e=>e.n)).runTypegen(e),runAllPluginTypegens:async e=>(await import(`./run-plugins-CubT9x_A.mjs`)).runAllPluginTypegens(e),writeTypegenArtifacts:async(e,t,n)=>(await import(`./typegen-BJwy65-p.mjs`).then(e=>e.n)).writeTypegenArtifacts(e,t,n),buildAssets:async(e,t)=>(await import(`./build-D9X9QBkC.mjs`).then(e=>e.n)).buildAssets(e,t)},a=n?.typegen?.schemaValidator??`zod`,o=n?.typegen?.envFile,s=d.resolve(t,n?.typegen?.outDir??`.kickjs/types`),c=n?.assetMap?Object.values(n.assetMap).map(e=>e?.src).filter(e=>typeof e==`string`&&e.length>0).map(e=>d.resolve(t,e)):[],l=!!n?.assetMap&&Object.keys(n.assetMap).length>0,u=e=>e.replaceAll(`\\`,`/`),f=c.map(u),p=e=>{let t=u(e);return f.some(e=>t===e||t.startsWith(`${e}/`))},m=Ye(e.emitWarning),h=null,g=!1,_=new Set,v=new Set,y=!1,b=!1;function x(r,c){i.runTypegen({cwd:t,silent:!0,allowDuplicates:!0,schemaValidator:a,envFile:o,srcDir:n?.typegen?.srcDir,outDir:n?.typegen?.outDir,assetMap:n?.assetMap,changedFiles:r,runPlugins:!1}).then(()=>m.clear(`scan`)).catch(e=>m.report(`scan`,e)),i.runAllPluginTypegens({cwd:t,config:n,silent:!0,changedFiles:r}).then(e=>i.writeTypegenArtifacts(s,e,!0)).then(()=>m.clear(`plugins`)).catch(e=>m.report(`plugins`,e)).finally(()=>e.onPassComplete?.()),c&&n&&i.buildAssets(n,{cwd:t,silent:!0}).catch(()=>{})}function S(){let e=y?void 0:{changed:[..._],removed:[...v]},t=b;_.clear(),v.clear(),y=!1,b=!1,x(e,t)}return{assetSrcRoots:c,handleWatchEvent(e,t){if(!g&&!u(t).includes(`/.kickjs/`)){if(e===`unlinkDir`)y=!0,l&&(b=!0);else{if(t.endsWith(`.d.ts`))return;let n=/\.(ts|tsx|mts|cts)$/.test(t),r=p(t);if(!n&&!r)return;r&&l&&(b=!0),n&&(e===`unlink`?(v.add(t),_.delete(t)):(_.add(t),v.delete(t)))}h&&clearTimeout(h),h=setTimeout(S,r)}},runOnce(){g||x(void 0,l)},dispose(){g=!0,h&&clearTimeout(h),h=null}}}function Qe(e){return D(e).replace(/-/g,`_`)}function q(e){let t=e.cwd??process.cwd(),n=e.projectRoot??l(t),r=e.pluralize??!0,i=T(e.name),a=E(e.name),o=D(e.name),s=Qe(e.name),c={name:e.name,pascal:i,camel:a,kebab:o,snake:s,modulesDir:e.modulesDir??`src/modules`,cwd:t,projectRoot:n,args:e.args??[],flags:e.flags??{}};if(r){let e=O(o);c.pluralKebab=e,c.pluralPascal=T(e),c.pluralCamel=E(e)}return c}function $e(e,t){return h(e.cwd,t)}async function et(e){return import(te(e).href)}const J=new Map;async function Y(e){let t=J.get(e);if(t)return t;let n=tt(e);return J.set(e,n),n}async function tt(e){let t=h(e,`package.json`);if(!g(t))return{generators:[],loaded:[],failed:[]};let n=nt(JSON.parse(await b(t,`utf-8`))),r=u(h(e,`package.json`)),i=[],a=[],o=[];for(let e of n){let t;try{t=r.resolve(`${e}/package.json`)}catch{continue}let n;try{n=JSON.parse(await b(t,`utf-8`))}catch(t){o.push({source:e,reason:`failed to parse package.json: ${t}`});continue}if(!n.kickjs?.generators)continue;let s=n.kickjs.generators,c=h(f(t),s);if(!g(c)){o.push({source:e,reason:`kickjs.generators points to missing file: ${s}`});continue}let l;try{l=await et(c)}catch(t){o.push({source:e,reason:`failed to import manifest: ${t}`});continue}let u=l.default;if(!Array.isArray(u)){o.push({source:e,reason:`manifest's default export is not an array of GeneratorSpec`});continue}for(let t of u){if(!rt(t)){o.push({source:e,reason:`manifest entry is not a valid GeneratorSpec (missing name/files)`});continue}i.push({source:e,spec:t})}a.push(e)}return{generators:i,loaded:a,failed:o}}function nt(e){let t=new Set;for(let n of[e.dependencies,e.devDependencies,e.peerDependencies])if(n)for(let e of Object.keys(n))t.add(e);return Array.from(t)}function rt(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.name==`string`&&typeof t.files==`function`}async function it(e,t=[]){let n=e.cwd??process.cwd(),r=t.find(t=>t.spec.name===e.generatorName);if(r)return X(r.spec,r.source,e,n);let i=ot(await Y(n),e.generatorName);return i?X(i.spec,i.source,e,n):null}async function at(e,t=[]){let n=await Y(e),r=new Set(t.map(e=>e.spec.name)),i=n.generators.filter(e=>!r.has(e.spec.name));return{generators:[...t,...i],loaded:n.loaded,failed:n.failed}}function ot(e,t){return e.generators.find(e=>e.spec.name===t)}async function X(t,n,r,i){let a=q({name:r.itemName,args:r.args,flags:r.flags,modulesDir:r.modulesDir,pluralize:r.pluralize,cwd:i,projectRoot:r.projectRoot}),o=await t.files(a),s=[];for(let t of o){let n=$e(a,t.path);await e(n,t.content),s.push(n)}return{files:s,source:n}}function st(e){return e}function ct(e){return e}function Z(e){try{return JSON.parse(_(e,`utf-8`))}catch{return null}}function Q(e){try{return _(e,`utf-8`)}catch{return null}}function lt(e){let t=Q(p(e,`tsconfig.json`));if(!t)return null;let n=t.replace(/\/\*[\s\S]*?\*\//g,``).replace(/\/\/.*$/gm,``),r;try{r=JSON.parse(n)}catch{return null}if(typeof r?.extends==`string`){let t=ut(e,r.extends);if(t){let e=Z(t)??{};r.compilerOptions={...e.compilerOptions,...r.compilerOptions}}}return r}function ut(e,t){if(t.startsWith(`.`)){let n=h(e,t);return g(n)?n:null}let n=p(e,`node_modules`,t);return g(n)?n:null}function dt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ft(){let e=process.version,t=Number.parseInt(e.replace(/^v/,``).split(`.`)[0],10);return Number.isNaN(t)||t<20?{name:`Node version`,status:`fail`,message:e,fix:`KickJS requires Node 20 or newer.
|
|
1213
1213
|
Install a supported version via nvm / fnm / volta.`}:{name:`Node version`,status:`pass`,message:e}}function $(e){if(!e.pkg)return{name:`@forinda/kickjs installed`,status:`warn`,message:`no package.json`};let t={...e.pkg.dependencies,...e.pkg.peerDependencies};return t[`@forinda/kickjs`]?{name:`@forinda/kickjs installed`,status:`pass`,message:t[`@forinda/kickjs`]}:{name:`@forinda/kickjs installed`,status:`fail`,fix:"This directory does not look like a KickJS project — `@forinda/kickjs` is not in your package.json. Run `kick doctor` from the project root, or scaffold a fresh project with `kick new <name>`."}}function pt(e){if(!e.pkg)return null;let t={...e.pkg.dependencies,...e.pkg.peerDependencies};return t[`@forinda/kickjs`]&&!t.express?{name:`express installed`,status:`fail`,fix:"`@forinda/kickjs` declares `express` as a required peer dependency, but your package.json does not include it. Install: pnpm add express"}:t.express?{name:`express installed`,status:`pass`,message:t.express}:null}function mt(e){if(!e.pkg)return{name:`reflect-metadata installed`,status:`warn`,message:`no package.json`};let t={...e.pkg.dependencies,...e.pkg.peerDependencies,...e.pkg.devDependencies};return t[`reflect-metadata`]?{name:`reflect-metadata installed`,status:`pass`,message:t[`reflect-metadata`]}:{name:`reflect-metadata installed`,status:`fail`,fix:`KickJS decorators require the reflect-metadata polyfill.
|
|
1214
1214
|
Install it: pnpm add reflect-metadata
|
|
1215
1215
|
Then import it at the top of src/index.ts:
|
|
@@ -1218,4 +1218,4 @@ Then import it at the top of src/index.ts:
|
|
|
1218
1218
|
// ... rest of bootstrap`}}function ht(e){if(!e.tsconfig)return[{name:`tsconfig.json present`,status:`fail`,fix:"Create a tsconfig.json with `experimentalDecorators: true` and `emitDecoratorMetadata: true`. `kick new` scaffolds one automatically."}];let t=e.tsconfig.compilerOptions??{},n=[];return n.push(t.experimentalDecorators===!0?{name:`tsconfig: experimentalDecorators`,status:`pass`}:{name:`tsconfig: experimentalDecorators`,status:`fail`,fix:'Add `"experimentalDecorators": true` to compilerOptions in tsconfig.json. Without it, @Service / @Controller / @Get etc. don\'t register any metadata at compile time.'}),n.push(t.emitDecoratorMetadata===!0?{name:`tsconfig: emitDecoratorMetadata`,status:`pass`}:{name:`tsconfig: emitDecoratorMetadata`,status:`fail`,fix:'Add `"emitDecoratorMetadata": true` to compilerOptions in tsconfig.json. The DI container uses this metadata for constructor-parameter injection.'}),n}function gt(e){let t=[`src/env.ts`,`src/env/index.ts`,`src/config/env.ts`,`src/config/index.ts`].map(t=>p(e.cwd,t)).filter(e=>g(e)).filter(e=>/\bloadEnv\s*\(/.test(Q(e)??``));if(t.length===0)return null;let n=[`src/index.ts`,`src/main.ts`].map(t=>p(e.cwd,t)).find(e=>g(e));if(!n)return{name:`env wiring`,status:`warn`,message:`env-init file exists but no src/index.ts or src/main.ts found`};let r=Q(n)??``,i=f(n),a=[];for(let e of t){let t=m(i,e).replace(/\\/g,`/`).replace(/\.ts$/,``),n=t.startsWith(`.`)?t:`./`+t,r=n.replace(/\/index$/,``);a.push(n,r);let o=e.replace(/\\/g,`/`).match(/\/src\/(.+?)(?:\.ts)?$/);if(o){let e=`@/`+o[1],t=e.replace(/\/index$/,``);a.push(e,t)}}let o=-1;for(let e of new Set(a)){let t=RegExp(`^import\\s+(?:.*?from\\s+)?['"]${dt(e)}['"]`,`m`),n=r.match(t);n&&n.index!==void 0&&(o===-1||n.index<o)&&(o=n.index)}let s=r.search(/\bbootstrap\s*\(/),c=t.map(t=>m(e.cwd,t).replace(/\\/g,`/`)).join(`, `);return o===-1?{name:`env wiring`,status:`fail`,message:c,fix:`An env-init file (${c}) calls \`loadEnv(...)\` but \`${m(e.cwd,n).replace(/\\/g,`/`)}\` doesn't import it.\nWithout this, ConfigService.get('X') returns undefined while @Value('X') works via process.env fallback — a half-broken config you won't notice until something is missing.\n\nFix: add a side-effect import at the top of ${m(e.cwd,n).replace(/\\/g,`/`)} (above bootstrap()), pointing at one of the detected files. For example:\n\n import './env'\n // or\n import './config'\n // or, with the @/ alias:\n import '@/config/env'`}:s!==-1&&o>s?{name:`env wiring`,status:`warn`,message:`env-init imported AFTER bootstrap() — should be before`,fix:`Move the env import above the bootstrap() call so the schema runs before any service reads from ConfigService.`}:{name:`env wiring`,status:`pass`}}function _t(e,t=vt){let n=0,r=0,i=[e];for(;i.length>0&&r<t;){let e=i.pop(),a;try{a=v(e,{withFileTypes:!0})}catch{continue}for(let o of a){if(r>=t)break;r++;let a=p(e,o.name);if(o.isDirectory()){i.push(a);continue}try{let e=y(a).mtimeMs;e>n&&(n=e)}catch{}}}return n}const vt=2e3;function yt(e){let t=p(e.cwd,`.kickjs`,`types`);if(!g(t))return null;let n=_t(t);if(n===0)return null;let r=Date.now()-n,i=Math.floor(r/6e4);return i>60?{name:`typegen freshness`,status:`warn`,message:`last updated ${i} minutes ago`,fix:"Re-run `kick typegen` (or `kick dev`, which runs it on every reload) so generated types match the current code."}:{name:`typegen freshness`,status:`pass`,message:i===0?`just now`:`${i}m ago`}}const bt=[()=>ft(),$,pt,mt,ht,gt,yt];async function xt(e,t={}){let n={cwd:e,pkg:Z(p(e,`package.json`)),tsconfig:lt(e)},r=[...bt,...t.extraChecks??[]],i=[];for(let e of r){let t;try{t=await e(n)}catch(t){i.push({name:e.name||`doctor check`,status:`fail`,message:t instanceof Error?t.message:String(t)});continue}t!=null&&(Array.isArray(t)?i.push(...t):i.push(t))}return i}function St(e){switch(e){case`pass`:return r.green(`✔`);case`warn`:return r.yellow(`⚠`);case`fail`:return r.red(`✖`)}}function Ct(e){let t=St(e.status),n=e.message?` ${r.dim(`(${e.message})`)}`:``;return`${t} ${e.name}${n}`}function wt(e){return e.split(`
|
|
1219
1219
|
`).map(e=>` ${r.dim(`→`)} ${e}`).join(`
|
|
1220
1220
|
`)}function Tt(e){return e?.doctor?.checks??[]}function Et(e){e.command(`doctor`).description(`Pre-flight checks for your KickJS project (dev environment health)`).action(async()=>{let e=process.cwd(),a=Tt(await c(e));t(`KickJS Doctor`);let o=await xt(e,{extraChecks:a});for(let e of o)i.message(Ct(e)),e.fix&&e.status!==`pass`&&i.message(wt(e.fix));let s=o.filter(e=>e.status===`pass`).length,l=o.filter(e=>e.status===`warn`).length,u=o.filter(e=>e.status===`fail`).length,d=[r.green(`${s} passed`),l>0?r.yellow(`${l} warning${l===1?``:`s`}`):`${l} warnings`,u>0?r.red(`${u} error${u===1?``:`s`}`):`${u} errors`].join(`, `);u>0?(n(`${d} — fix the errors above before running the app`),process.exit(1)):n(l>0?`${d} — review the warnings`:r.green(`${d} — your environment looks good`))})}export{O as A,L as C,N as D,P as E,E as M,D as N,M as O,T as P,R as S,F as T,Te as _,it as a,Se as b,Xe as c,je as d,Ae as f,W as g,De as h,at as i,k as j,A as k,Ze as l,Oe as m,st as n,q as o,ke as p,Et as r,ne as s,ct as t,Je as u,z as v,I as w,xe as x,V as y};
|
|
1221
|
-
//# sourceMappingURL=doctor-
|
|
1221
|
+
//# sourceMappingURL=doctor-CcVNNzGj.mjs.map
|