@forinda/kickjs-cli 8.14.3 → 8.14.4
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-brHNoyLK.mjs → agent-docs-B4ENB4Jf.mjs} +2 -2
- package/dist/{agent-docs-tr9_AJYU.mjs → agent-docs-IMSfDW1v.mjs} +3 -3
- package/dist/{agent-docs-tr9_AJYU.mjs.map → agent-docs-IMSfDW1v.mjs.map} +1 -1
- package/dist/{build-CI56pcUZ.mjs → build-BhsFtlz-.mjs} +3 -3
- package/dist/{build-CI56pcUZ.mjs.map → build-BhsFtlz-.mjs.map} +1 -1
- package/dist/{build-DRfjqnqV.mjs → build-fe-IPSgY.mjs} +2 -2
- package/dist/{builtins-CfuSe-qw.mjs → builtins-WhIqFKQq.mjs} +2 -2
- package/dist/{builtins-C9MmvIBs.mjs → builtins-aD7X3E3D.mjs} +4 -4
- package/dist/cli.mjs +2 -2
- package/dist/{config-sixJ2517.mjs → config-C8VZHQ4a.mjs} +3 -3
- package/dist/{config-sixJ2517.mjs.map → config-C8VZHQ4a.mjs.map} +1 -1
- package/dist/{config-DmEDJwvJ.mjs → config-uQW9K9TV.mjs} +2 -2
- package/dist/{doctor-Bkhf8Adv.mjs → doctor-D7Voplu-.mjs} +4 -4
- package/dist/{doctor-Bkhf8Adv.mjs.map → doctor-D7Voplu-.mjs.map} +1 -1
- package/dist/{fullstack-srmNRn5h.mjs → fullstack-CNN0RMJj.mjs} +4 -4
- package/dist/{fullstack-srmNRn5h.mjs.map → fullstack-CNN0RMJj.mjs.map} +1 -1
- package/dist/{fullstack-DAU0nTaN.mjs → fullstack-Cz6m6I32.mjs} +3 -3
- package/dist/index.mjs +2 -2
- package/dist/{package-manager-L8IEB6v4.mjs → package-manager-DjQ5hOIz.mjs} +3 -3
- package/dist/{package-manager-L8IEB6v4.mjs.map → package-manager-DjQ5hOIz.mjs.map} +1 -1
- package/dist/{package-manager-n73HlY1T.mjs → package-manager-KXWql8Ih.mjs} +2 -2
- package/dist/{plugin-T3Aes85q.mjs → plugin-Dmt8BaqI.mjs} +2 -2
- package/dist/{plugin-Cccp0Rzz.mjs → plugin-q3LTBltC.mjs} +2 -2
- package/dist/{project-DVOYSwrb.mjs → project-4oHY0jOl.mjs} +5 -5
- package/dist/{project-DVOYSwrb.mjs.map → project-4oHY0jOl.mjs.map} +1 -1
- package/dist/{project-mWxqd_g2.mjs → project-D9FX1B56.mjs} +4 -4
- package/dist/{project-root-u6rwcIHh.mjs → project-root-D4CQYHJy.mjs} +3 -3
- package/dist/{project-root-u6rwcIHh.mjs.map → project-root-D4CQYHJy.mjs.map} +1 -1
- package/dist/{project-root-CVGTdH_N.mjs → project-root-D6NXawpn.mjs} +2 -2
- package/dist/{rolldown-runtime-DB9qXK5A.mjs → rolldown-runtime-C6kPX6_j.mjs} +1 -1
- package/dist/{run-plugins-DXxLu7EH.mjs → run-plugins-9FIERkDq.mjs} +4 -4
- package/dist/{run-plugins-DXxLu7EH.mjs.map → run-plugins-9FIERkDq.mjs.map} +1 -1
- package/dist/{typegen-DaeXT-vU.mjs → typegen-CA-hDh1k.mjs} +4 -4
- package/dist/{typegen-Bdo4S6uC.mjs → typegen-CNVeHcvE.mjs} +5 -5
- package/dist/{typegen-Bdo4S6uC.mjs.map → typegen-CNVeHcvE.mjs.map} +1 -1
- package/dist/{types-COk7vdvT.mjs → types-cg36SCgd.mjs} +1 -1
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.14.
|
|
2
|
+
* @forinda/kickjs-cli v8.14.4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as e}from"./rolldown-runtime-
|
|
11
|
+
import{t as e}from"./rolldown-runtime-C6kPX6_j.mjs";import{existsSync as t,mkdirSync as n,readFileSync as r,writeFileSync as i}from"node:fs";import{dirname as a,isAbsolute as o,join as s,relative as c,resolve as l}from"node:path";import{fileURLToPath as u}from"node:url";import{access as d,readFile as f}from"node:fs/promises";var p=/* @__PURE__ */ e({BUILTIN_REPO_TYPES:()=>_,DEPRECATED_REPO_TYPES:()=>v,PACKAGE_MANAGERS:()=>m,PLURALIZE_DEFAULT:()=>!1,defineConfig:()=>b,execBin:()=>g,hasDependency:()=>x,hasSwagger:()=>C,loadKickConfig:()=>M,resolveModuleConfig:()=>k,resolvePluralize:()=>D,resolvePluralizeRoutes:()=>O,resolveSchemaLib:()=>w,resolveTokenScope:()=>T,runScript:()=>h,testImportSource:()=>S,validateAssetMap:()=>P,warnIfDeprecatedRepo:()=>y,writeAssetConfigSnapshot:()=>N});const m=[`pnpm`,`npm`,`yarn`,`bun`];function h(e,t){return e===`npm`||e===`bun`?`${e} run ${t}`:`${e} ${t}`}function g(e,t){return{npm:`npx ${t}`,pnpm:`pnpm exec ${t}`,yarn:`yarn ${t}`,bun:`bunx ${t}`}[e]}const _=[`inmemory`],v=[`prisma`,`drizzle`];function y(e){return v.includes(e)?(console.warn(` Note: '${e}' is no longer a built-in repository preset — a repository shaped to it is that library's interface, not KickJS's.\n Scaffolding a generic custom-repository stub instead; wire it to ${e} yourself.`),!0):!1}function b(e){return e}function x(e,n,i=`runtime`){try{let a=s(e,`package.json`);if(!t(a))return!1;let o=JSON.parse(r(a,`utf-8`));return o.dependencies?.[n]?!0:i===`any`&&!!o.devDependencies?.[n]}catch{return!1}}function S(e){return x(e,`vite-plus`,`any`)&&!x(e,`vitest`,`any`)?`vite-plus/test`:`vitest`}function C(e){return x(e,`@forinda/kickjs-swagger`,`runtime`)}function w(e){return x(e,`valibot`,`runtime`)?`valibot`:x(e,`yup`,`runtime`)?`yup`:`zod`}function T(e,n){if(e?.tokenScope&&typeof e.tokenScope==`string`&&e.tokenScope.length>0){let t=E(e.tokenScope);if(t.length>0)return t}try{let e=s(n,`package.json`);if(t(e)){let t=JSON.parse(r(e,`utf-8`));if(typeof t.name==`string`&&t.name.length>0){let e=t.name.match(/^@([^/]+)\//),n=E(e?e[1]:t.name);if(n.length>0)return n}}}catch{}return`app`}function E(e){return e.toLowerCase().replace(/[^a-z0-9-]/g,`-`).replace(/^-+|-+$/g,``).replace(/-{2,}/g,`-`)}function D(e,t){return e??t?.pluralize??!1}function O(e,t){return e??t?.pluralizeRoutes??!0}function k(e){if(!e)return{};let t={dir:e.modules?.dir,repo:e.modules?.repo,schemaDir:e.modules?.schemaDir,pluralize:e.modules?.pluralize,pluralizeRoutes:e.modules?.pluralizeRoutes,style:e.modules?.style};return t.style!==void 0&&t.style!==`define`&&t.style!==`class`&&(console.warn(` Warning: modules.style '${t.style}' is not a valid value (expected 'define' or 'class'). Falling back to 'define'.`),t.style=`define`),t.repo&&typeof t.repo==`string`&&!_.includes(t.repo)&&(y(t.repo)||console.warn(` Warning: modules.repo '${t.repo}' is not a built-in type (${_.join(`, `)}). It will generate a stub repository. Use { name: '${t.repo}' } to silence this warning.`)),t}const A=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function j(e){for(let n=e;;n=a(n)){if(t(s(n,`node_modules`,`@forinda`,`kickjs-cli`,`package.json`)))return{};if(a(n)===n)break}let n=s(a(u(import.meta.url)),`..`),r=[s(n,`dist`,`index.mjs`),s(n,`src`,`index.ts`)].find(t);return r?{"@forinda/kickjs-cli":r}:{}}async function M(e){let{findProjectRoot:t}=await import(`./project-root-D6NXawpn.mjs`).then(e=>e.n),n=t(e);for(let e of A){let t=s(n,e);try{await d(t)}catch{continue}if(e.endsWith(`.json`)){let e=await f(t,`utf-8`);return JSON.parse(e)}if(e.endsWith(`.ts`)){let r;try{r=await import(`jiti`)}catch(t){let n=t instanceof Error?t.message:String(t);n.includes(`Cannot find package 'jiti'`)||n.includes(`ERR_MODULE_NOT_FOUND`)?console.warn(`Warning: Failed to load ${e} — 'jiti' is required for TypeScript configs. Install jiti as a dev dependency, or rename the file to kick.config.js / kick.config.mjs / kick.config.json.`):console.warn(`Warning: Failed to initialize jiti for ${e}: ${n}`);continue}try{let e=await r.createJiti(n,{interopDefault:!0,fsCache:!1,alias:j(n),tsconfigPaths:!0}).import(t,{default:!0}),i=P(e,n);for(let e of i)console.warn(` Warning: ${e}`);return N(n,e),e}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Warning: Failed to load ${e}: ${n}`);continue}}try{let{pathToFileURL:e}=await import(`node:url`),r=await import(e(t).href),i=r.default??r,a=P(i,n);for(let e of a)console.warn(` Warning: ${e}`);return N(n,i),i}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Warning: Failed to load ${e}: ${n}`);continue}}return null}function N(e,t){if(t?.assetMap&&Object.keys(t.assetMap).length!==0)try{let r=s(e,`.kickjs`);n(r,{recursive:!0});let a={version:1,assetMap:t.assetMap,...t.build?.outDir?{build:{outDir:t.build.outDir}}:{}};i(s(r,`kick.config.json`),JSON.stringify(a,null,2)+`
|
|
12
12
|
`,`utf-8`)}catch{}}function P(e,n){let r=[];if(!e?.assetMap)return r;let i=l(n);for(let[a,o]of Object.entries(e.assetMap)){if(!a||a.includes(`/`)){r.push(`assetMap key '${a}' is invalid — must be a non-empty string without '/'`);continue}if(typeof o?.src!=`string`||o.src.length===0){r.push(`assetMap.${a} is missing a non-empty 'src' field`);continue}let e=l(n,o.src);t(e)||r.push(`assetMap.${a}.src ('${o.src}') does not exist — typegen + build will fail`),o.dest&&F(l(n,o.dest),i)&&r.push(`assetMap.${a}.dest ('${o.dest}') resolves outside the project root — refusing to copy`)}return r}function F(e,t){let n=c(t,e);return n===``?!1:n.startsWith(`..`)||o(n)}export{C as a,D as c,T as d,h as f,x as i,O as l,y as m,p as n,M as o,S as p,g as r,k as s,m as t,w as u};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.14.
|
|
2
|
+
* @forinda/kickjs-cli v8.14.4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{_ as e,a as t,c as n,h as r,i,o as a,p as o,t as s}from"./package-manager-
|
|
11
|
+
import{_ as e,a as t,c as n,h as r,i,o as a,p as o,t as s}from"./package-manager-DjQ5hOIz.mjs";import{s as c}from"./config-C8VZHQ4a.mjs";import{f as l,s as u}from"./project-4oHY0jOl.mjs";import{t as d}from"./project-root-D4CQYHJy.mjs";import{createRequire as f}from"node:module";import p,{dirname as m,join as h,relative as g,resolve as _}from"node:path";import{existsSync as v,readFileSync as y,readdirSync as b,statSync as x}from"node:fs";import{readFile as S}from"node:fs/promises";import C from"pluralize";import{pathToFileURL as w}from"node:url";import{defineGenerator as ee}from"@forinda/kickjs-cli-kit";C.addUncountableRule(`auth`);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 C.plural(e)}function k(e){return C.plural(e)}function A(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}const te={inmemory:`in-memory`,drizzle:`Drizzle`,prisma:`Prisma`};function ne(e){return e.charAt(0).toUpperCase()+e.slice(1).replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function re(e){return te[e]??ne(e)}function ie(e){return`create${e}Repository`}function j(e){return e??`define`}function M(e){let{pascal:t,kebab:n,plural:r=``,repo:i,style:a}=e,o=e.routePath??r,s=ie(t),c=j(a),l=`/**
|
|
12
12
|
* ${t} Module
|
|
13
13
|
*
|
|
14
14
|
* REST module with a flat folder structure.
|
|
@@ -1176,7 +1176,7 @@ export const ${l}Schema = ${F(u,`// Define your schema fields here\n name: ${d.
|
|
|
1176
1176
|
|
|
1177
1177
|
export type ${c}DTO = ${d.infer(`${l}Schema`)}
|
|
1178
1178
|
`),f.push(p),f}function De(){let e=(process.env.LOG_LEVEL??process.env.KICKJS_LOG_LEVEL??``).toLowerCase();return e===`debug`||e===`trace`}var Oe=class extends Error{drifted;constructor(e){let t=e.map(e=>` ${e.id} → ${e.outFile}`).join(`
|
|
1179
|
-
`);super(`kick typegen --check: ${e.length} generated file(s) are out of date:\n${t}\n Run \`kick typegen\` and commit the result.`),this.name=`TypegenDriftError`,this.drifted=e}};function ke(e){return e}function Ae(e){let t=/* @__PURE__ */ 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 je=`__kickjs_typegen_owner`;function Me(e){let{cwd:t,config:n}=e,r=e.debounceMs??100,i=e.pipeline??{runTypegen:async e=>(await import(`./typegen-
|
|
1179
|
+
`);super(`kick typegen --check: ${e.length} generated file(s) are out of date:\n${t}\n Run \`kick typegen\` and commit the result.`),this.name=`TypegenDriftError`,this.drifted=e}};function ke(e){return e}function Ae(e){let t=/* @__PURE__ */ 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 je=`__kickjs_typegen_owner`;function Me(e){let{cwd:t,config:n}=e,r=e.debounceMs??100,i=e.pipeline??{runTypegen:async e=>(await import(`./typegen-CNVeHcvE.mjs`).then(e=>e.n)).runTypegen(e),runAllPluginTypegens:async e=>(await import(`./run-plugins-9FIERkDq.mjs`).then(e=>e.n)).runAllPluginTypegens(e),writeTypegenArtifacts:async(e,t,n)=>(await import(`./typegen-CNVeHcvE.mjs`).then(e=>e.n)).writeTypegenArtifacts(e,t,n),buildAssets:async(e,t)=>(await import(`./build-BhsFtlz-.mjs`).then(e=>e.n)).buildAssets(e,t)},a=n?.typegen?.schemaValidator??`zod`,o=n?.typegen?.envFile,s=p.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=>p.resolve(t,e)):[],l=!!n?.assetMap&&Object.keys(n.assetMap).length>0,u=e=>e.replaceAll(`\\`,`/`),d=c.map(u),f=e=>{let t=u(e);return d.some(e=>t===e||t.startsWith(`${e}/`))},m=Ae(e.emitWarning),h=null,g=!1,_=/* @__PURE__ */ new Set,v=/* @__PURE__ */ 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,watch:!0}).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=f(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 Ne(e){return D(e).replace(/-/g,`_`)}function G(e){let t=e.cwd??process.cwd(),n=e.projectRoot??d(t),r=e.pluralize??!1,i=T(e.name),a=E(e.name),o=D(e.name),s=Ne(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 Pe(e,t){return _(e.cwd,t)}async function Fe(e){return import(w(e).href)}const K=/* @__PURE__ */ new Map;async function q(e){let t=K.get(e);if(t)return t;let n=Ie(e);return K.set(e,n),n}async function Ie(e){let t=_(e,`package.json`);if(!v(t))return{generators:[],loaded:[],failed:[]};let n=Le(JSON.parse(await S(t,`utf-8`))),r=f(_(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 S(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=_(m(t),s);if(!v(c)){o.push({source:e,reason:`kickjs.generators points to missing file: ${s}`});continue}let l;try{l=await Fe(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`});else{for(let t of u)Re(t)?i.push({source:e,spec:t}):o.push({source:e,reason:`manifest entry is not a valid GeneratorSpec (missing name/files)`});a.push(e)}}return{generators:i,loaded:a,failed:o}}function Le(e){let t=/* @__PURE__ */ 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 Re(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.name==`string`&&typeof t.files==`function`}async function ze(e,t=[]){let n=e.cwd??process.cwd(),r=t.find(t=>t.spec.name===e.generatorName);if(r)return J(r.spec,r.source,e,n);let i=Ve(await q(n),e.generatorName);return i?J(i.spec,i.source,e,n):null}async function Be(e,t=[]){let n=await q(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 Ve(e,t){return e.generators.find(e=>e.spec.name===t)}async function J(t,n,r,i){let a=G({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=Pe(a,t.path);await e(n,t.content),s.push(n)}return{files:s,source:n}}function He(e){return e}function Ue(e){return e}function Y(e){try{return JSON.parse(y(e,`utf-8`))}catch{return null}}function X(e){try{return y(e,`utf-8`)}catch{return null}}const Z=[`include`,`exclude`];function We(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r===`"`){let r=n;for(n++;n<e.length&&e[n]!==`"`;n++)e[n]===`\\`&&n++;t+=e.slice(r,n+1)}else if(r===`/`&&e[n+1]===`/`){for(;n<e.length&&e[n]!==`
|
|
1180
1180
|
`;)n++;t+=`
|
|
1181
1181
|
`}else if(r===`/`&&e[n+1]===`*`){let t=e.indexOf(`*/`,n+2);n=t===-1?e.length:t+1}else t+=r}try{return JSON.parse(t.replace(/,(\s*[}\]])/g,`$1`))}catch{return null}}function Ge(e){let t=h(e,`tsconfig.json`);if(v(t))return Q(t,/* @__PURE__ */ new Set)}function Q(e,t){if(t.has(e)||t.size>=16)return null;t.add(e);let n=X(e);if(n===null)return null;let r=We(n);if(typeof r!=`object`||!r)return null;let i=Array.isArray(r.extends)?r.extends:typeof r.extends==`string`?[r.extends]:[],a={},o={};for(let t of Z)r[t]!==void 0&&(r[`${t}Base`]=m(e));for(let n of i){if(typeof n!=`string`)continue;let r=Ke(m(e),n);if(!r)continue;let i=Q(r,t);if(i){Object.assign(a,i.compilerOptions);for(let e of Z)i[e]!==void 0&&(o[e]=i[e],o[`${e}Base`]=i[`${e}Base`])}}r.compilerOptions={...a,...r.compilerOptions};for(let e of Z)r[e]===void 0&&o[e]!==void 0&&(r[e]=o[e],r[`${e}Base`]=o[`${e}Base`]);return r}function Ke(e,t){if(t.startsWith(`.`)||t.startsWith(`/`))return $(_(e,t));let n=e;for(;;){let e=$(h(n,`node_modules`,t));if(e)return e;let r=m(n);if(r===n)break;n=r}return null}function $(e){if(v(e)){try{if(x(e).isDirectory()){let t=h(e,`tsconfig.json`);return v(t)?t:null}}catch{return null}return e}let t=`${e}.json`;return v(t)?t:null}function qe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Je(){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.
|
|
1182
1182
|
Install a supported version via nvm / fnm / volta.`}:{name:`Node version`,status:`pass`,message:e}}function Ye(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 Xe(e){if(!e.pkg||e.runtime!==`express`)return null;let t={...e.pkg.dependencies,...e.pkg.peerDependencies};return t[`@forinda/kickjs`]&&!t.express?{name:`express installed`,status:`fail`,fix:`This app runs on the Express runtime, but package.json does not include \`express\`. Install: ${s(e.cwd)} add express`}:t.express?{name:`express installed`,status:`pass`,message:t.express}:null}const Ze={express:[],fastify:[`fastify`,`@fastify/middie`],h3:[`h3`]};function Qe(e){if(!e.pkg||e.runtime===`express`)return null;let t={...e.pkg.dependencies,...e.pkg.peerDependencies,...e.pkg.devDependencies},n=Ze[e.runtime].filter(e=>!t[e]),r=`runtime engine (${e.runtime})`;return n.length>0?{name:r,status:`fail`,fix:`Resolved runtime '${e.runtime}' is missing engine peer(s): ${n.join(`, `)}.\nInstall: ${s(e.cwd)} add ${n.join(` `)}`}:e.runtime===`h3`&&$e(e.cwd,t.h3)===1?{name:r,status:`fail`,message:`h3 v1`,fix:`This version of @forinda/kickjs runs on h3 v2 only. Upgrade: ${s(e.cwd)} add h3@^2 — no code change for apps that only use KickJS APIs.`}:{name:r,status:`pass`}}function $e(e,t){let n=t;for(let t=_(e);;t=m(t)){try{n=JSON.parse(y(h(t,`node_modules`,`h3`,`package.json`),`utf8`)).version;break}catch{}if(m(t)===t)break}let r=/(\d+)/.exec(n)?.[1];return r===void 0?void 0:Number(r)}function et(e){if(!e.pkg||!nt(e.cwd))return null;let t=u[e.runtime],n=`upload driver (${e.runtime})`;return t.prod?{...e.pkg.dependencies,...e.pkg.peerDependencies,...e.pkg.devDependencies}[t.prod]?{name:n,status:`pass`,message:t.prod}:{name:n,status:`fail`,fix:`This project uses file uploads on the '${e.runtime}' runtime, which needs '${t.prod}'.\nInstall it: kick add upload (or ${s(e.cwd)} add ${t.prod})`}:{name:n,status:`pass`,message:`native multipart`}}const tt=2e3;function nt(e){let t=h(e,`src`);if(!v(t))return!1;let n=/@FileUpload\b|\bupload\.(single|array|none)\s*\(/,r=[t],i=0;for(;r.length>0&&i<tt;){let e=r.pop(),t;try{t=b(e,{withFileTypes:!0})}catch{continue}for(let a of t){if(i>=tt)break;let t=h(e,a.name);if(a.isDirectory())a.name!==`node_modules`&&r.push(t);else if(/\.(ts|tsx|mts|cts)$/.test(a.name)&&(i++,n.test(X(t)??``)))return!0}}return!1}function rt(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.\nInstall it: ${s(e.cwd)} add reflect-metadata\nThen import it at the top of src/index.ts:\n\n import 'reflect-metadata'\n // ... rest of bootstrap`}}function it(e){if(e.tsconfig===void 0)return[{name:`tsconfig.json present`,status:`fail`,fix:"Create a tsconfig.json with `experimentalDecorators: true` and `emitDecoratorMetadata: true`. `kick new` scaffolds one automatically."}];if(e.tsconfig===null)return[{name:`tsconfig.json readable`,status:`warn`,message:`could not parse tsconfig.json (or a config it extends)`,fix:"Check tsconfig.json for a syntax error, and that every path in its `extends` chain resolves. Decorator options could not be verified."}];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 at(e){let t=[`src/env.ts`,`src/env/index.ts`,`src/config/env.ts`,`src/config/index.ts`].map(t=>h(e.cwd,t)).filter(e=>v(e)).filter(e=>/\bloadEnv(?:FromSchema)?\s*\(/.test(X(e)??``));if(t.length===0)return null;let n=[`src/index.ts`,`src/main.ts`].map(t=>h(e.cwd,t)).find(e=>v(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=X(n)??``,i=m(n),a=[];for(let e of t){let t=g(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+)?['"]${qe(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=>g(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 \`${g(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 ${g(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 ot(e,t=st){let n=0,r=0,i=[e];for(;i.length>0&&r<t;){let e=i.pop(),a;try{a=b(e,{withFileTypes:!0})}catch{continue}for(let o of a){if(r>=t)break;r++;let a=h(e,o.name);if(o.isDirectory())i.push(a);else try{let e=x(a).mtimeMs;e>n&&(n=e)}catch{}}}return n}const st=2e3;function ct(e){let t=h(e.cwd,`.kickjs`,`types`);if(!v(t))return null;let n=ot(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 lt=[`vitest.config.ts`,`vitest.config.js`,`vitest.config.mts`,`vite.config.ts`,`jest.config.ts`,`jest.config.js`],ut=[`.env.test`,`.env.test.local`],dt=[`.env`,`.env.local`];function ft(e){let t=e.pkg?.scripts;if(t&&typeof t==`object`)for(let[e,n]of Object.entries(t)){if(!e.startsWith(`test`)||typeof n!=`string`)continue;let t=/KICKJS_ENV_FILE=(\S+)/.exec(n);if(t?.[1])return t[1]}return process.env.KICKJS_ENV_FILE??null}function pt(e){if(!lt.some(t=>v(h(e.cwd,t))))return null;let t=dt.filter(t=>v(h(e.cwd,t)));if(t.length===0)return null;let n=ut.filter(t=>v(h(e.cwd,t)));if(n.length>0){let t=ft(e);return t&&t!==`off`&&t!==`none`?{name:`test env isolation`,status:`warn`,message:`${n.join(`, `)} present, but KICKJS_ENV_FILE=${t} overrides it`,fix:`KICKJS_ENV_FILE is checked before test-mode isolation, so ${n[0]} is\nignored and "${t}" is read instead. Drop the override to use the\ntest files, or set KICKJS_ENV_FILE=off if env comes from the runner.`}:{name:`test env isolation`,status:`pass`,message:`${n.join(`, `)} present`}}return{name:`test env isolation`,status:`warn`,message:`${t.join(`, `)} present, no .env.test`,fix:`Under NODE_ENV=test (or vitest's VITEST) KickJS reads .env.test / .env.test.local
|
|
@@ -1189,4 +1189,4 @@ holding the whole environment the suite should run against
|
|
|
1189
1189
|
and supply env from the test runner.`}}function mt(e){let t={...e.pkg?.dependencies,...e.pkg?.devDependencies};if(!t[`@forinda/kickjs`]||!t[`@forinda/kickjs-di`])return null;let n=`one DI container`,r=t=>Y(h(e.cwd,`node_modules`,t,`package.json`)),i=r(`@forinda/kickjs`)?.dependencies?.[`@forinda/kickjs-di`],a=r(`@forinda/kickjs-di`)?.version,o=`Remove it and import from @forinda/kickjs, which re-exports it: ${s(e.cwd)} remove @forinda/kickjs-di`;return i&&a&&i!==a?{name:n,status:`fail`,message:`@forinda/kickjs-di ${a}, @forinda/kickjs uses ${i}`,fix:`Two copies of the DI container are installed, each with its own registrations — a class decorated against one is missing from the other.\n${o}`}:{name:n,status:`warn`,message:`@forinda/kickjs-di is listed in package.json`,fix:`@forinda/kickjs already depends on the exact version it needs; listing it too invites a second copy on the next upgrade.\n${o}`}}function ht(e){if(!e.tsconfig||!v(h(e.cwd,`.kickjs`,`types`)))return null;let t=`tsconfig includes typegen output`,n=t=>{let n=e.tsconfig[t],r=e.tsconfig[`${t}Base`]??e.cwd;return Array.isArray(n)?n.filter(e=>typeof e==`string`).map(t=>g(e.cwd,_(r,t)).replace(/\\/g,`/`)):[]},r=e=>/^\.kickjs\/(types(\/|$)|\*\*)/.test(e),i=e=>/^(\*\*\/)?\.kickjs(\/types)?(\/\*\*(\/\*)?|\/\*)?$/.test(e),a=n(`include`).filter(r),o=n(`exclude`).find(i),s=`Add ".kickjs/types/**/*.d.ts" and ".kickjs/types/**/*.ts" to "include" in tsconfig.json.`;return a.length===0?{name:t,status:`warn`,message:`.kickjs/types is not in include`,fix:`${s} Without them, the route, env and DI types from \`kick typegen\` don't apply.`}:o?{name:t,status:`warn`,message:`excluded by "${o}"`,fix:`Remove "${o}" from "exclude" in tsconfig.json — it drops the types \`kick typegen\` writes.`}:a.every(e=>e.endsWith(`.d.ts`))?{name:t,status:`warn`,message:`only the .d.ts files of .kickjs/types are included`,fix:`${s} The route types are a .ts file.`}:String(e.tsconfig.compilerOptions?.rootDir??``).replace(/^\.\//,``).replace(/\/$/,``)===`src`?{name:t,status:`warn`,message:`rootDir: 'src'`,fix:"Remove `rootDir` from tsconfig.json — the generated types live outside src/, and tsc refuses files outside rootDir."}:{name:t,status:`pass`}}const gt=[()=>Je(),Ye,Xe,Qe,et,mt,rt,it,ht,at,pt,ct];async function _t(e,t={}){let n={cwd:e,pkg:Y(h(e,`package.json`)),tsconfig:Ge(e),runtime:t.runtime??`express`},r=[...gt,...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 vt(e){switch(e){case`pass`:return o.green(`✔`);case`warn`:return o.yellow(`⚠`);case`fail`:return o.red(`✖`)}}function yt(e){let t=vt(e.status),n=e.message?` ${o.dim(`(${e.message})`)}`:``;return`${t} ${e.name}${n}`}function bt(e){return e.split(`
|
|
1190
1190
|
`).map(e=>` ${o.dim(`→`)} ${e}`).join(`
|
|
1191
1191
|
`)}function xt(e){return e?.doctor?.checks??[]}function St(e){e.command(`doctor`).description(`Pre-flight checks for your KickJS project (dev environment health)`).action(async()=>{let e=process.cwd(),r=xt(await c(e)),i=await l(e);t(`KickJS Doctor`);let s=await _t(e,{extraChecks:r,runtime:i});for(let e of s)a.message(yt(e)),e.fix&&e.status!==`pass`&&a.message(bt(e.fix));let u=s.filter(e=>e.status===`pass`).length,d=s.filter(e=>e.status===`warn`).length,f=s.filter(e=>e.status===`fail`).length,p=[o.green(`${u} passed`),d>0?o.yellow(`${d} warning${d===1?``:`s`}`):`${d} warnings`,f>0?o.red(`${f} error${f===1?``:`s`}`):`${f} errors`].join(`, `);f>0?(n(`${p} — fix the errors above before running the app`),process.exit(1)):n(d>0?`${p} — review the warnings`:o.green(`${p} — your environment looks good`))})}export{A,_e as C,I as D,de as E,T as F,k as M,E as N,N as O,D as P,B as S,L as T,Se as _,ze as a,U as b,je as c,ke as d,De as f,Ce as g,we as h,Be as i,O as j,M as k,Me as l,Te as m,He as n,G as o,Ee as p,St as r,ee as s,Ue as t,Oe as u,W as v,ge as w,R as x,be as y};
|
|
1192
|
-
//# sourceMappingURL=doctor-
|
|
1192
|
+
//# sourceMappingURL=doctor-D7Voplu-.mjs.map
|