@forinda/kickjs-cli 5.5.1 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{run-plugins-tnHiahkq.mjs → builtins-CYSzLo7U.mjs} +2 -2
- package/dist/cli.mjs +4086 -2
- package/dist/config-ierHW69f.mjs +12 -0
- package/dist/{config-Buzo7RE1.mjs.map → config-ierHW69f.mjs.map} +1 -1
- package/dist/{generator-extension-m04pTdQi.mjs → generator-extension-BXLt3Tp_.mjs} +314 -78
- package/dist/generator-extension-BXLt3Tp_.mjs.map +1 -0
- package/dist/index.d.mts +141 -31
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -0
- package/dist/{plugin-BnIpCxAe.mjs → plugin-D_nBy6VP.mjs} +3 -3
- package/dist/{plugin-BnIpCxAe.mjs.map → plugin-D_nBy6VP.mjs.map} +1 -1
- package/dist/project-root-CqGZOrRR.mjs +12 -0
- package/dist/project-root-CqGZOrRR.mjs.map +1 -0
- package/dist/{rolldown-runtime-Dnwyy6jt.mjs → rolldown-runtime-B8-Ifyj3.mjs} +1 -1
- package/dist/{builtins-DXPOvADa.mjs → run-plugins-Cvgyo_th.mjs} +90 -288
- package/dist/run-plugins-Cvgyo_th.mjs.map +1 -0
- package/dist/{typegen-CYaoTJ6r.mjs → typegen-C3G375CR.mjs} +4 -4
- package/dist/{typegen-CYaoTJ6r.mjs.map → typegen-C3G375CR.mjs.map} +1 -1
- package/dist/{types-RTdCiPdS.mjs → types-Kj2ldTnQ.mjs} +2 -2
- package/dist/types-Kj2ldTnQ.mjs.map +1 -0
- package/package.json +7 -6
- package/dist/builtins-DXPOvADa.mjs.map +0 -1
- package/dist/builtins-DYktFyU-.mjs +0 -3952
- package/dist/config-Bu3PcPYn.mjs +0 -11
- package/dist/config-Buzo7RE1.mjs +0 -12
- package/dist/generator-extension-m04pTdQi.mjs.map +0 -1
- package/dist/plugin-DZZsizSI.mjs +0 -11
- package/dist/typegen-COED-VIb.mjs +0 -116
- package/dist/types-RTdCiPdS.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -290,6 +290,30 @@ interface TypegenPluginResult {
|
|
|
290
290
|
status: 'written' | 'unchanged' | 'skipped';
|
|
291
291
|
outFile?: string;
|
|
292
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* Identity factory for {@link TypegenPlugin}. Returns the spec verbatim.
|
|
295
|
+
* Exists for type inference and forward-compatibility — future
|
|
296
|
+
* fields can be added with defaults without breaking adopters.
|
|
297
|
+
*
|
|
298
|
+
* Mirrors {@link defineGenerator} ergonomics. Use at the call site so
|
|
299
|
+
* the plugin's `generate(ctx)` body gets a fully-typed `ctx` without
|
|
300
|
+
* an explicit annotation:
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* import { defineTypegen } from '@forinda/kickjs-cli'
|
|
305
|
+
*
|
|
306
|
+
* export const drizzleTypegen = defineTypegen({
|
|
307
|
+
* id: 'drizzle',
|
|
308
|
+
* inputs: ['src/db/schema.ts'],
|
|
309
|
+
* async generate(ctx) {
|
|
310
|
+
* const schema = await ctx.importTs(`${ctx.cwd}/src/db/schema.ts`)
|
|
311
|
+
* return `// declare module …`
|
|
312
|
+
* },
|
|
313
|
+
* })
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
declare function defineTypegen(spec: TypegenPlugin): TypegenPlugin;
|
|
293
317
|
//#endregion
|
|
294
318
|
//#region src/generator-extension/define.d.ts
|
|
295
319
|
/**
|
|
@@ -336,7 +360,7 @@ interface TypegenPluginResult {
|
|
|
336
360
|
* generators without rewriting their templates.
|
|
337
361
|
*/
|
|
338
362
|
interface GeneratorContext {
|
|
339
|
-
/** Raw name passed on the command line (`kick g
|
|
363
|
+
/** Raw name passed on the command line (`kick g drizzle-typegen UserPost` → `'UserPost'`). */
|
|
340
364
|
name: string;
|
|
341
365
|
/** PascalCase form (`UserPost`). */
|
|
342
366
|
pascal: string;
|
|
@@ -354,8 +378,23 @@ interface GeneratorContext {
|
|
|
354
378
|
pluralCamel?: string;
|
|
355
379
|
/** Modules directory from `kick.config.ts` (default `'src/modules'`). */
|
|
356
380
|
modulesDir: string;
|
|
357
|
-
/**
|
|
381
|
+
/**
|
|
382
|
+
* Working directory the CLI was invoked from. May be a nested subdirectory
|
|
383
|
+
* if the adopter ran `kick g ...` from `src/modules/foo/` — for "write
|
|
384
|
+
* files relative to the project" use {@link projectRoot} instead.
|
|
385
|
+
*/
|
|
358
386
|
cwd: string;
|
|
387
|
+
/**
|
|
388
|
+
* Resolved project root — the nearest ancestor directory of {@link cwd}
|
|
389
|
+
* containing `kick.config.{ts,js,mjs,json}` (or `package.json` as a
|
|
390
|
+
* fallback). Always set; falls back to `cwd` when no marker is found.
|
|
391
|
+
*
|
|
392
|
+
* Use this when writing files that must land at a known location
|
|
393
|
+
* regardless of where the adopter typed the command. `kick g ...` from
|
|
394
|
+
* inside `src/modules/foo/` will still see `projectRoot` pointing at
|
|
395
|
+
* the directory that owns `kick.config.ts`.
|
|
396
|
+
*/
|
|
397
|
+
projectRoot: string;
|
|
359
398
|
/** Positional arguments passed AFTER the name (e.g. `kick g command Order extra1 extra2` → `['extra1', 'extra2']`). */
|
|
360
399
|
args: string[];
|
|
361
400
|
/** Flag values from the command line — booleans for switches, strings for `--key value`. */
|
|
@@ -428,6 +467,35 @@ interface GeneratorSpec {
|
|
|
428
467
|
*/
|
|
429
468
|
declare function defineGenerator(spec: GeneratorSpec): GeneratorSpec;
|
|
430
469
|
//#endregion
|
|
470
|
+
//#region src/generator-extension/discover.d.ts
|
|
471
|
+
/**
|
|
472
|
+
* One row in the discovered registry. `source` is the npm package name
|
|
473
|
+
* the generator came from — surfaced in error messages so adopters can
|
|
474
|
+
* see which plugin owns a given generator.
|
|
475
|
+
*/
|
|
476
|
+
interface DiscoveredGenerator {
|
|
477
|
+
source: string;
|
|
478
|
+
spec: GeneratorSpec;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Plugin discovery result, kept around even when no generators were
|
|
482
|
+
* registered so callers can distinguish "no plugins installed" from
|
|
483
|
+
* "no plugins matched the requested name."
|
|
484
|
+
*/
|
|
485
|
+
interface DiscoveryResult {
|
|
486
|
+
generators: DiscoveredGenerator[];
|
|
487
|
+
/** Packages whose `kickjs.generators` was loaded successfully. */
|
|
488
|
+
loaded: string[];
|
|
489
|
+
/**
|
|
490
|
+
* Packages we tried to load but failed — typically a missing entry
|
|
491
|
+
* file or a default export that wasn't an array of GeneratorSpec.
|
|
492
|
+
*/
|
|
493
|
+
failed: Array<{
|
|
494
|
+
source: string;
|
|
495
|
+
reason: string;
|
|
496
|
+
}>;
|
|
497
|
+
}
|
|
498
|
+
//#endregion
|
|
431
499
|
//#region src/plugin/types.d.ts
|
|
432
500
|
/**
|
|
433
501
|
* Runtime context handed to `register()` — saves callbacks from
|
|
@@ -435,10 +503,40 @@ declare function defineGenerator(spec: GeneratorSpec): GeneratorSpec;
|
|
|
435
503
|
* land here without changing the callback signature.
|
|
436
504
|
*/
|
|
437
505
|
interface KickCliPluginContext {
|
|
506
|
+
/**
|
|
507
|
+
* Working directory the CLI was invoked from. Plugin authors that need
|
|
508
|
+
* a stable "project base" location (e.g. to write artifacts, resolve
|
|
509
|
+
* config-relative paths) should prefer {@link projectRoot} over `cwd`
|
|
510
|
+
* — `cwd` is whatever the adopter typed the command from, including
|
|
511
|
+
* arbitrary subdirectories.
|
|
512
|
+
*/
|
|
438
513
|
cwd: string;
|
|
514
|
+
/**
|
|
515
|
+
* Resolved project root — the directory `loadKickConfig` walked up to
|
|
516
|
+
* via `findProjectRoot()`. Always set to a usable absolute path: when
|
|
517
|
+
* a `kick.config.{ts,js,mjs,json}` is found, that directory; otherwise
|
|
518
|
+
* the nearest ancestor with a `package.json`; otherwise `cwd` itself.
|
|
519
|
+
*
|
|
520
|
+
* Populated by `mergeCliPlugins.register()` from the same resolution
|
|
521
|
+
* that `cli.ts` performs at startup, so plugin authors get a coherent
|
|
522
|
+
* view of the project root without re-walking the filesystem.
|
|
523
|
+
*/
|
|
524
|
+
projectRoot: string;
|
|
439
525
|
/** Resolved kick.config.ts (null if the project has none). */
|
|
440
526
|
config: KickConfig | null;
|
|
441
527
|
log: (msg: string) => void;
|
|
528
|
+
/**
|
|
529
|
+
* Plugin-shipped generators merged from built-ins + adopter
|
|
530
|
+
* `kick.config.ts > plugins[]`. Populated by `mergeCliPlugins` and
|
|
531
|
+
* threaded through so `register()` callbacks (notably
|
|
532
|
+
* `kick/generate`) can register each plugin generator as a real
|
|
533
|
+
* Commander subcommand — without that, plugin generators only fire
|
|
534
|
+
* via the bare-action dispatch and are invisible to `kick g --help`.
|
|
535
|
+
*
|
|
536
|
+
* Optional so light test harnesses that call `plugin.register(program)`
|
|
537
|
+
* directly (no merge step) stay unaffected.
|
|
538
|
+
*/
|
|
539
|
+
generators?: DiscoveredGenerator[];
|
|
442
540
|
}
|
|
443
541
|
interface KickCliPlugin {
|
|
444
542
|
/** Stable identifier — used in error messages on conflict + de-dup. */
|
|
@@ -864,8 +962,24 @@ interface KickConfig {
|
|
|
864
962
|
}
|
|
865
963
|
/** Helper to define a type-safe kick.config.ts */
|
|
866
964
|
declare function defineConfig(config: KickConfig): KickConfig;
|
|
867
|
-
/**
|
|
868
|
-
|
|
965
|
+
/**
|
|
966
|
+
* Load `kick.config.*` starting from `startDir` and walking up toward
|
|
967
|
+
* the filesystem root until a config file is found. Returns `null`
|
|
968
|
+
* when no config exists anywhere on the way up.
|
|
969
|
+
*
|
|
970
|
+
* Walking up means adopters can run `kick <cmd>` from any subdirectory
|
|
971
|
+
* (e.g. `src/modules/users/`) and still pick up the project's config —
|
|
972
|
+
* before this change a nested-cwd invocation silently saw `null` and
|
|
973
|
+
* fell back to framework defaults.
|
|
974
|
+
*
|
|
975
|
+
* TypeScript configs (`.ts`) are loaded via `jiti` when available;
|
|
976
|
+
* `.js` / `.mjs` use native `import()`; `.json` uses `JSON.parse`. The
|
|
977
|
+
* jiti import is dynamic + best-effort: if the dep is missing we
|
|
978
|
+
* surface a warning telling the adopter how to install it, instead of
|
|
979
|
+
* silently dropping the config (which is what the previous bare-catch
|
|
980
|
+
* did).
|
|
981
|
+
*/
|
|
982
|
+
declare function loadKickConfig(startDir: string): Promise<KickConfig | null>;
|
|
869
983
|
//#endregion
|
|
870
984
|
//#region src/generators/templates/types.d.ts
|
|
871
985
|
/**
|
|
@@ -1017,34 +1131,23 @@ interface InitProjectOptions {
|
|
|
1017
1131
|
/** Scaffold a new KickJS project */
|
|
1018
1132
|
declare function initProject(options: InitProjectOptions): Promise<void>;
|
|
1019
1133
|
//#endregion
|
|
1020
|
-
//#region src/
|
|
1134
|
+
//#region src/utils/project-root.d.ts
|
|
1021
1135
|
/**
|
|
1022
|
-
*
|
|
1023
|
-
*
|
|
1024
|
-
*
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
*
|
|
1032
|
-
*
|
|
1033
|
-
*
|
|
1136
|
+
* Walk up from `startDir` looking for the project root. A directory
|
|
1137
|
+
* counts as the root when it contains any of:
|
|
1138
|
+
* - `kick.config.{ts,js,mjs,json}` (strongest signal)
|
|
1139
|
+
* - `package.json` (fallback when no config file exists yet)
|
|
1140
|
+
*
|
|
1141
|
+
* Returns the absolute path of the first matching directory, or
|
|
1142
|
+
* `startDir` itself when nothing was found (no surprises — callers
|
|
1143
|
+
* that didn't find a config still get a reasonable cwd).
|
|
1144
|
+
*
|
|
1145
|
+
* `kick.config.*` wins over `package.json` when both appear at
|
|
1146
|
+
* different levels, so adopters running `kick typegen` from `src/`
|
|
1147
|
+
* land on the project root that owns the config, not on the nearest
|
|
1148
|
+
* workspace package boundary in a monorepo.
|
|
1034
1149
|
*/
|
|
1035
|
-
|
|
1036
|
-
generators: DiscoveredGenerator[];
|
|
1037
|
-
/** Packages whose `kickjs.generators` was loaded successfully. */
|
|
1038
|
-
loaded: string[];
|
|
1039
|
-
/**
|
|
1040
|
-
* Packages we tried to load but failed — typically a missing entry
|
|
1041
|
-
* file or a default export that wasn't an array of GeneratorSpec.
|
|
1042
|
-
*/
|
|
1043
|
-
failed: Array<{
|
|
1044
|
-
source: string;
|
|
1045
|
-
reason: string;
|
|
1046
|
-
}>;
|
|
1047
|
-
}
|
|
1150
|
+
declare function findProjectRoot(startDir?: string): string;
|
|
1048
1151
|
//#endregion
|
|
1049
1152
|
//#region src/generator-extension/context.d.ts
|
|
1050
1153
|
/**
|
|
@@ -1059,6 +1162,13 @@ declare function buildGeneratorContext(input: {
|
|
|
1059
1162
|
flags?: Record<string, string | boolean>;
|
|
1060
1163
|
modulesDir?: string;
|
|
1061
1164
|
cwd?: string;
|
|
1165
|
+
/**
|
|
1166
|
+
* Resolved project root. When omitted, derived from {@link cwd} via
|
|
1167
|
+
* `findProjectRoot()` so adopter-facing call sites stay zero-config.
|
|
1168
|
+
* Callers that already know the root (e.g. `cli.ts` after one upfront
|
|
1169
|
+
* resolution) should pass it through to avoid redundant fs walks.
|
|
1170
|
+
*/
|
|
1171
|
+
projectRoot?: string;
|
|
1062
1172
|
pluralize?: boolean;
|
|
1063
1173
|
}): GeneratorContext;
|
|
1064
1174
|
//#endregion
|
|
@@ -1076,5 +1186,5 @@ declare function toKebabCase(name: string): string;
|
|
|
1076
1186
|
*/
|
|
1077
1187
|
declare function pluralize(name: string): string;
|
|
1078
1188
|
//#endregion
|
|
1079
|
-
export { type DiscoveredGenerator, type DiscoveryResult, type GeneratorArg, type GeneratorContext, type GeneratorFile, type GeneratorFlag, type GeneratorSpec, type KickCliPlugin, type KickCliPluginContext, type KickCommandDefinition, type KickConfig, type KickDbConfigBlock, KickPluginConflictError, type TypegenContext, type TypegenPlugin, type TypegenPluginResult, buildGeneratorContext, defineCliPlugin, defineConfig, defineGenerator, generateAdapter, generateController, generateDto, generateGuard, generateMiddleware, generateModule, generateService, initProject, loadKickConfig, pluralize, toCamelCase, toKebabCase, toPascalCase };
|
|
1189
|
+
export { type DiscoveredGenerator, type DiscoveryResult, type GeneratorArg, type GeneratorContext, type GeneratorFile, type GeneratorFlag, type GeneratorSpec, type KickCliPlugin, type KickCliPluginContext, type KickCommandDefinition, type KickConfig, type KickDbConfigBlock, KickPluginConflictError, type TypegenContext, type TypegenPlugin, type TypegenPluginResult, buildGeneratorContext, defineCliPlugin, defineConfig, defineGenerator, defineTypegen, findProjectRoot, generateAdapter, generateController, generateDto, generateGuard, generateMiddleware, generateModule, generateService, initProject, loadKickConfig, pluralize, toCamelCase, toKebabCase, toPascalCase };
|
|
1080
1190
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/typegen/scanner.ts","../src/typegen/plugin.ts","../src/generator-extension/define.ts","../src/plugin/types.ts","../src/config.ts","../src/generators/templates/types.ts","../src/generators/module.ts","../src/generators/adapter.ts","../src/generators/middleware.ts","../src/generators/guard.ts","../src/generators/service.ts","../src/generators/controller.ts","../src/generators/dto.ts","../src/generators/project.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/typegen/scanner.ts","../src/typegen/plugin.ts","../src/generator-extension/define.ts","../src/generator-extension/discover.ts","../src/plugin/types.ts","../src/config.ts","../src/generators/templates/types.ts","../src/generators/module.ts","../src/generators/adapter.ts","../src/generators/middleware.ts","../src/generators/guard.ts","../src/generators/service.ts","../src/generators/controller.ts","../src/generators/dto.ts","../src/generators/project.ts","../src/utils/project-root.ts","../src/generator-extension/context.ts","../src/utils/naming.ts"],"mappings":";;;;;;;AAgCA;;;;AAOU;AAEV;;;;AAAmD;AAGnD;;;;;;;;;;;AAUW;AAIX;;cA1Ba,eAAA;AAAA,KASD,aAAA,WAAwB,eAAe;;UAGlC,eAAA;EA2CQ;EAzCvB,SAAA;EAcA;EAZA,SAAA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;EACA,MAAA;EACA,UAAA;EACA,UAAA;EACA,OAAA,GAAU,cAAc;EACxB,SAAA;AAAA;AAAA,iBAGoB,WAAA,CAAY,OAAA,EAAS,kBAAA,GAAqB,OAAO;;;KC4ElE,eAAA;AAAA,UAEK,kBAAA;EACR,IAAA;EACA,SAAA;EACA,cAAA;EACA,OAAA;EACA,WAAA;EACA,QAAA,GAAW,eAAe;EAC1B,WAAA;EACA,QAAA;AAAA;;iBAIoB,WAAA,CAAY,OAAA,EAAS,kBAAA,GAAqB,OAAO;;;;;;AdzEvE;;;;AAOU;AAEV;;;;AAAmD;AAGnD;;iBexBgB,eAAA,CAAgB,QAAgC;;;;;AfYhE;;;;iBgBfgB,qBAAA,CAAsB,KAAA;EACpC,IAAA;EACA,IAAA;EACA,KAAA,GAAQ,MAAA;EACR,UAAA;EACA,GAAA;EhBsBe;;;;;;EgBff,WAAA;EACA,SAAA;AAAA,IACE,gBAAgB;;;;iBC5BJ,YAAA,CAAa,IAAY;;iBAOzB,WAAA,CAAY,IAAY;;iBAMxB,WAAA,CAAY,IAAY;;AjBuB9B;AAEV;;;iBiBbgB,SAAA,CAAU,IAAY"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v5.
|
|
2
|
+
* @forinda/kickjs-cli v5.8.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,4 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{
|
|
11
|
+
import{E as e,S as t,T as n,a as r,d as i,f as a,g as o,h as s,i as c,m as l,p as u,r as d,w as f,y as p}from"./generator-extension-BXLt3Tp_.mjs";import{i as m,r as h}from"./config-ierHW69f.mjs";import{t as g}from"./project-root-CqGZOrRR.mjs";import{n as _,t as v}from"./types-Kj2ldTnQ.mjs";function y(e){return e}export{v as KickPluginConflictError,d as buildGeneratorContext,_ as defineCliPlugin,h as defineConfig,c as defineGenerator,y as defineTypegen,g as findProjectRoot,o as generateAdapter,a as generateController,i as generateDto,l as generateGuard,s as generateMiddleware,p as generateModule,u as generateService,r as initProject,m as loadKickConfig,t as pluralize,f as toCamelCase,n as toKebabCase,e as toPascalCase};
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/typegen/plugin.ts"],"sourcesContent":["// TypegenPlugin contract — M2.B-T7.\n//\n// Each plugin owns a single `.kickjs/types/<id>.d.ts` file. The runner\n// invokes `generate(ctx)` per plugin, prepends a banner, writes only on\n// content change, and surfaces drift in --check mode (CI gate).\n//\n// Built-in plugins (kick/routes, kick/env, kick/assets, kick/db) live under\n// `./builtin`. Adopters register additional plugins via kick.config.ts.\n\nimport type { KickConfig } from '../config'\nimport type { ScanOptions, ScanResult } from './scanner'\n\nexport interface TypegenLogger {\n info(msg: string): void\n warn(msg: string): void\n error(msg: string): void\n}\n\nexport interface TypegenContext {\n cwd: string\n config: KickConfig\n /** Dynamic-import a TS module (Node loader). Used by plugins that need to\n * read the adopter's schema / route map / asset registry at generate time. */\n importTs<T = unknown>(absPath: string): Promise<T>\n /** Write under `cwd`. Caller passes a relPath (e.g. `.kickjs/types/foo.d.ts`). */\n writeFile(relPath: string, contents: string): Promise<void>\n /**\n * Run `scanProject` once per typegen pass, memoizing the result so\n * multiple plugins (`kick/routes`, `kick/env`, future adopter plugins)\n * share a single fs walk + AST extraction.\n *\n * The runner uses an order-independent cache key derived from the\n * resolved options (`root`, `cwd`, `extensions`, `exclude`, `envFile`)\n * — semantically equal options hit the cache regardless of how the\n * caller built the literal. (We deliberately don't `JSON.stringify`\n * the options for caching since that would be sensitive to property\n * insertion order.) Plugins that don't need scanner data can ignore\n * this method entirely.\n *\n * Implementation lives in the runner so test harnesses can inject\n * a stub scanner; plugins only see the function.\n */\n getScanResult(opts: ScanOptions): Promise<ScanResult>\n log: TypegenLogger\n}\n\nexport interface TypegenPlugin {\n /** Stable id — used as filename: `.kickjs/types/${id}<outExtension>` (slashes → `__`). */\n id: string\n /** Glob patterns the Vite watcher subscribes to; change → re-run this plugin. */\n inputs: string[]\n /**\n * Output filename extension. Default `.d.ts` — the right choice for\n * pure module-augmentation plugins (kick/db, kick/assets) since\n * declaration files don't need the runtime-import dance.\n *\n * `kick/routes` overrides to `.ts` because it emits hoisted\n * `import type {...} from '...'` lines at the top of the file. Inline\n * `import('...').X` references inside `.d.ts` silently degrade to\n * `unknown` under `moduleResolution: 'bundler'`; emitting `.ts`\n * sidesteps that quirk and gets full type resolution.\n *\n * Adopter-supplied plugins should leave this unset unless they hit\n * the same hoisted-import constraint.\n */\n outExtension?: string\n /**\n * Return the augmentation source (without banner — runner prepends).\n * Return null to skip emission (e.g. no schema file present).\n */\n generate(ctx: TypegenContext): Promise<string | null>\n}\n\nexport interface TypegenPluginResult {\n id: string\n status: 'written' | 'unchanged' | 'skipped'\n outFile?: string\n}\n\n/**\n * Identity factory for {@link TypegenPlugin}. Returns the spec verbatim.\n * Exists for type inference and forward-compatibility — future\n * fields can be added with defaults without breaking adopters.\n *\n * Mirrors {@link defineGenerator} ergonomics. Use at the call site so\n * the plugin's `generate(ctx)` body gets a fully-typed `ctx` without\n * an explicit annotation:\n *\n * @example\n * ```ts\n * import { defineTypegen } from '@forinda/kickjs-cli'\n *\n * export const drizzleTypegen = defineTypegen({\n * id: 'drizzle',\n * inputs: ['src/db/schema.ts'],\n * async generate(ctx) {\n * const schema = await ctx.importTs(`${ctx.cwd}/src/db/schema.ts`)\n * return `// declare module …`\n * },\n * })\n * ```\n */\nexport function defineTypegen(spec: TypegenPlugin): TypegenPlugin {\n return spec\n}\n"],"mappings":";;;;;;;;;;mSAsGA,SAAgB,EAAc,EAAoC,CAChE,OAAO,CACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v5.
|
|
2
|
+
* @forinda/kickjs-cli v5.8.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as e}from"./rolldown-runtime-
|
|
12
|
-
//# sourceMappingURL=plugin-
|
|
11
|
+
import{t as e}from"./rolldown-runtime-B8-Ifyj3.mjs";import{t}from"./types-Kj2ldTnQ.mjs";function n(e,n=[]){let r=new Map;for(let n of e){let e=(r.get(n.name)??0)+1;if(r.set(n.name,e),e===2)throw new t(`plugin`,n.name,[n.name,n.name])}let i=new Map,a=[];for(let n of e)for(let e of n.commands??[]){let r=i.get(e.name);if(r)throw new t(`command`,e.name,[r,n.name]);i.set(e.name,n.name),a.push(e)}let o=new Set(n.map(e=>e.name)),s=[...a.filter(e=>!o.has(e.name)),...n],c=new Map,l=[];for(let n of e)for(let e of n.typegens??[]){let r=c.get(e.id);if(r)throw new t(`typegen`,e.id,[r,n.name]);c.set(e.id,n.name),l.push(e)}let u=new Map,d=[];for(let n of e)for(let e of n.generators??[]){let r=u.get(e.name);if(r)throw new t(`generator`,e.name,[r,n.name]);u.set(e.name,n.name),d.push({source:n.name,spec:e})}return{commands:s,typegens:l,generators:d,register:async(t,n)=>{let r;if(n)r={generators:d,...n};else{let{findProjectRoot:e}=await import(`./project-root-CqGZOrRR.mjs`).then(e=>e.n),t=process.cwd();r={cwd:t,projectRoot:e(t),config:null,log:()=>{},generators:d}}for(let n of e)n.register&&await n.register(t,r)}}}var r=e({mergeCliPlugins:()=>n});export{n,r as t};
|
|
12
|
+
//# sourceMappingURL=plugin-D_nBy6VP.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-
|
|
1
|
+
{"version":3,"file":"plugin-D_nBy6VP.mjs","names":[],"sources":["../src/plugin/merge.ts","../src/plugin/index.ts"],"sourcesContent":["// Plugin → unified registry merge.\n//\n// Resolution rules (per the v1 spec + dogfood pivot):\n// - duplicate plugin `name` across the input array → conflict error.\n// Catches the double-install case (built-in shipped twice, or\n// adopter requiring the same plugin twice).\n// - plugin commands appear first in the merged list, then adopter\n// commands; adopter `commands` of the same name override the\n// plugin entry (filter pass).\n// - duplicate command name across two plugins → conflict error\n// listing both plugin names. Adopter overriding a plugin is\n// allowed and not an error.\n// - duplicate typegen id across two plugins → same error. Typegens\n// have no adopter override path; only plugins contribute them.\n// - register() functions are collected in input order; the caller\n// invokes each one against the same Command program. They have no\n// id-level conflict surface — owners are responsible for picking\n// non-colliding command names inside their own register().\n// - plugin order = array order. No implicit precedence rules.\n\nimport type { Command } from 'commander'\n\nimport type { KickCommandDefinition } from '../config'\nimport type { TypegenPlugin } from '../typegen/plugin'\nimport type { GeneratorSpec } from '../generator-extension/define'\nimport type { DiscoveredGenerator } from '../generator-extension/discover'\nimport { KickPluginConflictError, type KickCliPlugin, type KickCliPluginContext } from './types'\n\nexport interface MergedPlugins {\n commands: KickCommandDefinition[]\n typegens: TypegenPlugin[]\n /** DiscoveredGenerator shape so this list slots into the existing\n * dispatch path next to package.json-discovered entries. `source`\n * carries the plugin name for error attribution. */\n generators: DiscoveredGenerator[]\n /**\n * Apply every plugin's register() in input order. ctx is optional so\n * tests + lightweight callers can invoke `register(program)` without\n * constructing a full context; it falls back to cwd=process.cwd(),\n * config=null, log=no-op.\n */\n register: (program: Command, ctx?: KickCliPluginContext) => Promise<void>\n}\n\nexport function mergeCliPlugins(\n plugins: readonly KickCliPlugin[],\n adopterCommands: readonly KickCommandDefinition[] = [],\n): MergedPlugins {\n // Plugin-name dedup — catches double-install.\n const seenPluginNames = new Map<string, number>()\n for (const p of plugins) {\n const count = (seenPluginNames.get(p.name) ?? 0) + 1\n seenPluginNames.set(p.name, count)\n if (count === 2) {\n throw new KickPluginConflictError('plugin', p.name, [p.name, p.name])\n }\n }\n\n const commandOwners = new Map<string, string>()\n const pluginCommands: KickCommandDefinition[] = []\n for (const p of plugins) {\n for (const cmd of p.commands ?? []) {\n const prior = commandOwners.get(cmd.name)\n if (prior) {\n throw new KickPluginConflictError('command', cmd.name, [prior, p.name])\n }\n commandOwners.set(cmd.name, p.name)\n pluginCommands.push(cmd)\n }\n }\n\n const adopterNames = new Set(adopterCommands.map((c) => c.name))\n const filteredPlugin = pluginCommands.filter((c) => !adopterNames.has(c.name))\n const commands = [...filteredPlugin, ...adopterCommands]\n\n const typegenOwners = new Map<string, string>()\n const typegens: TypegenPlugin[] = []\n for (const p of plugins) {\n for (const tg of p.typegens ?? []) {\n const prior = typegenOwners.get(tg.id)\n if (prior) {\n throw new KickPluginConflictError('typegen', tg.id, [prior, p.name])\n }\n typegenOwners.set(tg.id, p.name)\n typegens.push(tg)\n }\n }\n\n const generatorOwners = new Map<string, string>()\n const generators: DiscoveredGenerator[] = []\n for (const p of plugins) {\n for (const spec of p.generators ?? []) {\n const prior = generatorOwners.get(spec.name)\n if (prior) {\n throw new KickPluginConflictError('generator', spec.name, [prior, p.name])\n }\n generatorOwners.set(spec.name, p.name)\n generators.push({ source: p.name, spec: spec satisfies GeneratorSpec })\n }\n }\n\n /**\n * Apply every plugin's `register()` callback in input order against the\n * given Commander program. Each callback receives a {@link KickCliPluginContext}:\n * caller-supplied ctx wins (test fixtures can inject a different\n * workspace boundary); otherwise a default ctx is built with\n * `findProjectRoot(process.cwd())` as the project root, `cwd` matching\n * `process.cwd()`, null config, no-op log, and the merged generator set\n * threaded through so the `kick/generate` built-in can surface each as\n * a Commander subcommand. The dynamic import of `findProjectRoot` keeps\n * the caller-supplied fast path zero-cost.\n */\n const register = async (program: Command, ctx?: KickCliPluginContext): Promise<void> => {\n let resolved: KickCliPluginContext\n if (ctx) {\n resolved = { generators, ...ctx }\n } else {\n const { findProjectRoot } = await import('../utils/project-root')\n const cwd = process.cwd()\n resolved = {\n cwd,\n projectRoot: findProjectRoot(cwd),\n config: null,\n log: () => {},\n generators,\n }\n }\n for (const p of plugins) {\n if (p.register) await p.register(program, resolved)\n }\n }\n\n return { commands, typegens, generators, register }\n}\n","// Barrel intentionally omits `./builtins` — that module top-level-imports\n// every register*Command, which pulls heavy modules (project scaffolders,\n// fs reads at import time) into the graph. Importers that need the\n// builtin list go through `./plugin/builtins` directly; tests + adopter\n// plugins consuming only the contract types import from here.\n\nexport type { KickCliPlugin } from './types'\nexport { defineCliPlugin, KickPluginConflictError } from './types'\nexport { mergeCliPlugins, type MergedPlugins } from './merge'\n"],"mappings":";;;;;;;;;;wFA4CA,SAAgB,EACd,EACA,EAAoD,CAAC,EACtC,CAEf,IAAM,EAAkB,IAAI,IAC5B,IAAK,IAAM,KAAK,EAAS,CACvB,IAAM,GAAS,EAAgB,IAAI,EAAE,IAAI,GAAK,GAAK,EAEnD,GADA,EAAgB,IAAI,EAAE,KAAM,CAAK,EAC7B,IAAU,EACZ,MAAM,IAAI,EAAwB,SAAU,EAAE,KAAM,CAAC,EAAE,KAAM,EAAE,IAAI,CAAC,CAExE,CAEA,IAAM,EAAgB,IAAI,IACpB,EAA0C,CAAC,EACjD,IAAK,IAAM,KAAK,EACd,IAAK,IAAM,KAAO,EAAE,UAAY,CAAC,EAAG,CAClC,IAAM,EAAQ,EAAc,IAAI,EAAI,IAAI,EACxC,GAAI,EACF,MAAM,IAAI,EAAwB,UAAW,EAAI,KAAM,CAAC,EAAO,EAAE,IAAI,CAAC,EAExE,EAAc,IAAI,EAAI,KAAM,EAAE,IAAI,EAClC,EAAe,KAAK,CAAG,CACzB,CAGF,IAAM,EAAe,IAAI,IAAI,EAAgB,IAAK,GAAM,EAAE,IAAI,CAAC,EAEzD,EAAW,CAAC,GADK,EAAe,OAAQ,GAAM,CAAC,EAAa,IAAI,EAAE,IAAI,CAC1C,EAAG,GAAG,CAAe,EAEjD,EAAgB,IAAI,IACpB,EAA4B,CAAC,EACnC,IAAK,IAAM,KAAK,EACd,IAAK,IAAM,KAAM,EAAE,UAAY,CAAC,EAAG,CACjC,IAAM,EAAQ,EAAc,IAAI,EAAG,EAAE,EACrC,GAAI,EACF,MAAM,IAAI,EAAwB,UAAW,EAAG,GAAI,CAAC,EAAO,EAAE,IAAI,CAAC,EAErE,EAAc,IAAI,EAAG,GAAI,EAAE,IAAI,EAC/B,EAAS,KAAK,CAAE,CAClB,CAGF,IAAM,EAAkB,IAAI,IACtB,EAAoC,CAAC,EAC3C,IAAK,IAAM,KAAK,EACd,IAAK,IAAM,KAAQ,EAAE,YAAc,CAAC,EAAG,CACrC,IAAM,EAAQ,EAAgB,IAAI,EAAK,IAAI,EAC3C,GAAI,EACF,MAAM,IAAI,EAAwB,YAAa,EAAK,KAAM,CAAC,EAAO,EAAE,IAAI,CAAC,EAE3E,EAAgB,IAAI,EAAK,KAAM,EAAE,IAAI,EACrC,EAAW,KAAK,CAAE,OAAQ,EAAE,KAAY,MAA6B,CAAC,CACxE,CAkCF,MAAO,CAAE,WAAU,WAAU,aAAY,eApBjB,EAAkB,IAA8C,CACtF,IAAI,EACJ,GAAI,EACF,EAAW,CAAE,aAAY,GAAG,CAAI,MAC3B,CACL,GAAM,CAAE,mBAAoB,MAAM,OAAO,+BAAA,KAAA,GAAA,EAAA,CAAA,EACnC,EAAM,QAAQ,IAAI,EACxB,EAAW,CACT,MACA,YAAa,EAAgB,CAAG,EAChC,OAAQ,KACR,QAAW,CAAC,EACZ,YACF,CACF,CACA,IAAK,IAAM,KAAK,EACV,EAAE,UAAU,MAAM,EAAE,SAAS,EAAS,CAAQ,CAEtD,CAEkD,CACpD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs-cli v5.8.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Felix Orinda
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import{t as e}from"./rolldown-runtime-B8-Ifyj3.mjs";import{dirname as t,parse as n,resolve as r}from"node:path";import{existsSync as i}from"node:fs";var a=e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=r(e),{root:s}=n(a),c=null,l=a;for(;;){for(let e of o)if(i(r(l,e)))return l;if(c===null&&i(r(l,`package.json`))&&(c=l),l===s)break;let e=t(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
|
|
12
|
+
//# sourceMappingURL=project-root-CqGZOrRR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-root-CqGZOrRR.mjs","names":[],"sources":["../src/utils/project-root.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { dirname, parse, resolve } from 'node:path'\n\nconst CONFIG_FILENAMES = ['kick.config.ts', 'kick.config.js', 'kick.config.mjs', 'kick.config.json']\n\n/**\n * Walk up from `startDir` looking for the project root. A directory\n * counts as the root when it contains any of:\n * - `kick.config.{ts,js,mjs,json}` (strongest signal)\n * - `package.json` (fallback when no config file exists yet)\n *\n * Returns the absolute path of the first matching directory, or\n * `startDir` itself when nothing was found (no surprises — callers\n * that didn't find a config still get a reasonable cwd).\n *\n * `kick.config.*` wins over `package.json` when both appear at\n * different levels, so adopters running `kick typegen` from `src/`\n * land on the project root that owns the config, not on the nearest\n * workspace package boundary in a monorepo.\n */\nexport function findProjectRoot(startDir: string = process.cwd()): string {\n const start = resolve(startDir)\n const { root: fsRoot } = parse(start)\n\n let firstPackageJson: string | null = null\n let cursor = start\n while (true) {\n for (const name of CONFIG_FILENAMES) {\n if (existsSync(resolve(cursor, name))) return cursor\n }\n if (firstPackageJson === null && existsSync(resolve(cursor, 'package.json'))) {\n firstPackageJson = cursor\n }\n if (cursor === fsRoot) break\n const parent = dirname(cursor)\n if (parent === cursor) break\n cursor = parent\n }\n\n return firstPackageJson ?? start\n}\n"],"mappings":";;;;;;;;;;sLAGA,MAAM,EAAmB,CAAC,iBAAkB,iBAAkB,kBAAmB,kBAAkB,EAiBnG,SAAgB,EAAgB,EAAmB,QAAQ,IAAI,EAAW,CACxE,IAAM,EAAQ,EAAQ,CAAQ,EACxB,CAAE,KAAM,GAAW,EAAM,CAAK,EAEhC,EAAkC,KAClC,EAAS,EACb,OAAa,CACX,IAAK,IAAM,KAAQ,EACjB,GAAI,EAAW,EAAQ,EAAQ,CAAI,CAAC,EAAG,OAAO,EAKhD,GAHI,IAAqB,MAAQ,EAAW,EAAQ,EAAQ,cAAc,CAAC,IACzE,EAAmB,GAEjB,IAAW,EAAQ,MACvB,IAAM,EAAS,EAAQ,CAAM,EAC7B,GAAI,IAAW,EAAQ,MACvB,EAAS,CACX,CAEA,OAAO,GAAoB,CAC7B"}
|