@forinda/kickjs-cli 5.1.0 → 5.2.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/dist/{builtins-caRjFvKz.mjs → builtins-B0dptoXq.mjs} +626 -241
- package/dist/builtins-B0dptoXq.mjs.map +1 -0
- package/dist/{builtins-Cb_d-b1S.mjs → builtins-N3mDa6bM.mjs} +695 -273
- package/dist/cli.mjs +9 -9
- package/dist/{config-8bAt-mLl.mjs → config-Bc6ERRTE.mjs} +35 -5
- package/dist/{config-C_LQNClP.mjs → config-CRi3zCxk.mjs} +36 -6
- package/dist/config-CRi3zCxk.mjs.map +1 -0
- package/dist/{generator-extension-CYY-RI21.mjs → generator-extension-C-HwKvFf.mjs} +76 -39
- package/dist/generator-extension-C-HwKvFf.mjs.map +1 -0
- package/dist/index.d.mts +282 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/{plugin-D8K5fG-O.mjs → plugin-DfomEcef.mjs} +4 -4
- package/dist/{plugin-D8K5fG-O.mjs.map → plugin-DfomEcef.mjs.map} +1 -1
- package/dist/{plugin-Bgfg7qMk.mjs → plugin-b7ig7Uxv.mjs} +2 -2
- package/dist/{rolldown-runtime-BM29JyaJ.mjs → rolldown-runtime-CV_zlh2d.mjs} +1 -1
- package/dist/{run-plugins-BXvMFPhJ.mjs → run-plugins-D9abb5Nx.mjs} +2 -2
- package/dist/{typegen-BNz_RQTb.mjs → typegen-B9S81bOx.mjs} +48 -225
- package/dist/typegen-B9S81bOx.mjs.map +1 -0
- package/dist/{typegen-8ZeA1B-X.mjs → typegen-BKUAdp_3.mjs} +47 -228
- package/dist/{types-BBUo1vXh.mjs → types-CU89yUxU.mjs} +2 -2
- package/dist/{types-BBUo1vXh.mjs.map → types-CU89yUxU.mjs.map} +1 -1
- package/package.json +6 -4
- package/dist/builtins-caRjFvKz.mjs.map +0 -1
- package/dist/config-C_LQNClP.mjs.map +0 -1
- package/dist/generator-extension-CYY-RI21.mjs.map +0 -1
- package/dist/typegen-8ZeA1B-X.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v5.1
|
|
2
|
+
* @forinda/kickjs-cli v5.2.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
11
|
+
import { t as __exportAll } from "./rolldown-runtime-CV_zlh2d.mjs";
|
|
12
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
12
13
|
import { statSync } from "node:fs";
|
|
13
|
-
import { dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
14
14
|
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
15
15
|
import { globSync } from "glob";
|
|
16
|
+
import { groupAssetKeys } from "@forinda/kickjs";
|
|
16
17
|
//#region src/typegen/scanner.ts
|
|
17
18
|
/** Decorators that mark a class as DI-managed */
|
|
18
19
|
const DECORATOR_NAMES = [
|
|
@@ -730,12 +731,12 @@ function discoverAssets(assetMap, cwd) {
|
|
|
730
731
|
posix: true
|
|
731
732
|
});
|
|
732
733
|
matches.sort();
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
const
|
|
734
|
+
const { pairs } = groupAssetKeys(namespace, matches, { strategy: entry.keys ?? "auto" });
|
|
735
|
+
for (const { key: logical } of pairs) {
|
|
736
|
+
const subKey = logical.slice(namespace.length + 1);
|
|
736
737
|
seen.set(logical, {
|
|
737
738
|
namespace,
|
|
738
|
-
key
|
|
739
|
+
key: subKey
|
|
739
740
|
});
|
|
740
741
|
}
|
|
741
742
|
}
|
|
@@ -799,7 +800,7 @@ export {}
|
|
|
799
800
|
}
|
|
800
801
|
const LEAF = Symbol("asset-leaf");
|
|
801
802
|
function renderTree(node, indent) {
|
|
802
|
-
const keys = Object.keys(node).
|
|
803
|
+
const keys = Object.keys(node).toSorted();
|
|
803
804
|
const lines = [];
|
|
804
805
|
for (const key of keys) {
|
|
805
806
|
const child = node[key];
|
|
@@ -823,10 +824,6 @@ function isDir(path) {
|
|
|
823
824
|
return false;
|
|
824
825
|
}
|
|
825
826
|
}
|
|
826
|
-
function stripExt(path) {
|
|
827
|
-
const ext = extname(path);
|
|
828
|
-
return ext ? path.slice(0, -ext.length) : path;
|
|
829
|
-
}
|
|
830
827
|
//#endregion
|
|
831
828
|
//#region src/typegen/generator.ts
|
|
832
829
|
/**
|
|
@@ -954,7 +951,7 @@ export type ${typeName} = never
|
|
|
954
951
|
`;
|
|
955
952
|
return `${HEADER}
|
|
956
953
|
export type ${typeName} =
|
|
957
|
-
${[...new Set(names)].
|
|
954
|
+
${[...new Set(names)].toSorted().map((n) => ` | '${n}'`).join("\n")}
|
|
958
955
|
`;
|
|
959
956
|
}
|
|
960
957
|
/** Render the barrel index that re-exports the union types */
|
|
@@ -970,203 +967,11 @@ export type { ModuleToken } from './modules'
|
|
|
970
967
|
// \`dependsOn: ['TenantAdapter']\`, \`assets.mails.welcome()\`, and
|
|
971
968
|
// \`@Value('PORT')\` to resolve.
|
|
972
969
|
import './registry'
|
|
973
|
-
import './
|
|
970
|
+
import './kick__routes'
|
|
974
971
|
import './plugins'
|
|
975
972
|
import './augmentations'
|
|
976
973
|
import './assets'
|
|
977
|
-
${includeEnv ? "import './
|
|
978
|
-
}
|
|
979
|
-
/**
|
|
980
|
-
* Render the `query` field's TypeScript type for a single route.
|
|
981
|
-
*
|
|
982
|
-
* - When `@ApiQueryParams` is absent (`queryFilterable === null`), emits
|
|
983
|
-
* `unknown` so the user gets nothing extra.
|
|
984
|
-
* - When the decorator is present, emits an object literal whose keys
|
|
985
|
-
* are the standard query string keys (`filter`, `sort`, `q`, `page`,
|
|
986
|
-
* `limit`). `sort` is narrowed to a string-literal union of allowed
|
|
987
|
-
* field names with optional `-` direction prefix.
|
|
988
|
-
*/
|
|
989
|
-
function renderQueryShape(m) {
|
|
990
|
-
if (m.queryFilterable === null) return "unknown";
|
|
991
|
-
const sortable = m.querySortable ?? [];
|
|
992
|
-
return `{ filter?: string | string[]; sort?: ${sortable.length > 0 ? sortable.flatMap((f) => [`'${f}'`, `'-${f}'`]).join(" | ") : "string"}; q?: string; page?: string; limit?: string }`;
|
|
993
|
-
}
|
|
994
|
-
/** Render JSDoc lines summarising the @ApiQueryParams whitelist */
|
|
995
|
-
function renderQueryDocLines(m) {
|
|
996
|
-
const lines = [];
|
|
997
|
-
if (m.queryFilterable && m.queryFilterable.length > 0) lines.push(`Filterable: ${m.queryFilterable.join(", ")}`);
|
|
998
|
-
if (m.querySortable && m.querySortable.length > 0) lines.push(`Sortable: ${m.querySortable.join(", ")}`);
|
|
999
|
-
if (m.querySearchable && m.querySearchable.length > 0) lines.push(`Searchable: ${m.querySearchable.join(", ")}`);
|
|
1000
|
-
return lines;
|
|
1001
|
-
}
|
|
1002
|
-
/**
|
|
1003
|
-
* Plan a schema import for hoisting at the top of `routes.ts`. Returns
|
|
1004
|
-
* the alias the in-namespace code should use, or `null` if the schema
|
|
1005
|
-
* cannot be referenced (no validator configured, or source unresolvable).
|
|
1006
|
-
*
|
|
1007
|
-
* Aliases are unique per (alias-counter) so two schemas named
|
|
1008
|
-
* `createTaskSchema` from different modules don't collide.
|
|
1009
|
-
*/
|
|
1010
|
-
function planSchemaImport(schema, routeFilePath, routesOutFile, schemaValidator, imports) {
|
|
1011
|
-
if (!schema || schemaValidator !== "zod") return null;
|
|
1012
|
-
if (schema.source === null) return null;
|
|
1013
|
-
const specifier = resolveSchemaImportSpecifier(schema.source, routeFilePath, routesOutFile);
|
|
1014
|
-
if (specifier === "unknown") return null;
|
|
1015
|
-
const key = `${specifier}::${schema.identifier}`;
|
|
1016
|
-
let alias = imports.get(key)?.specifier;
|
|
1017
|
-
if (!alias) {
|
|
1018
|
-
alias = `_S${imports.size}`;
|
|
1019
|
-
imports.set(key, {
|
|
1020
|
-
identifier: schema.identifier,
|
|
1021
|
-
specifier: alias
|
|
1022
|
-
});
|
|
1023
|
-
} else alias = imports.get(key).specifier;
|
|
1024
|
-
return alias;
|
|
1025
|
-
}
|
|
1026
|
-
/** Build the `import type { ... } from '...'` lines for hoisted schema imports */
|
|
1027
|
-
function renderSchemaImports(imports) {
|
|
1028
|
-
if (imports.size === 0) return "";
|
|
1029
|
-
const lines = [];
|
|
1030
|
-
for (const [key, value] of imports) {
|
|
1031
|
-
const [path] = key.split("::");
|
|
1032
|
-
lines.push(`import type { ${value.identifier} as ${value.specifier} } from '${path}'`);
|
|
1033
|
-
}
|
|
1034
|
-
return lines.join("\n") + "\n";
|
|
1035
|
-
}
|
|
1036
|
-
/**
|
|
1037
|
-
* Compute the import specifier the generated `routes.d.ts` should use to
|
|
1038
|
-
* reach a schema declared either in the controller file (empty string)
|
|
1039
|
-
* or imported from elsewhere (relative path or bare module name).
|
|
1040
|
-
*
|
|
1041
|
-
* - Bare module names (`zod`, `@scope/pkg`) are returned as-is.
|
|
1042
|
-
* - Relative paths (`./users.dto`, `../shared/schema`) are resolved
|
|
1043
|
-
* against the controller's file path, then re-relativised against the
|
|
1044
|
-
* directory containing `routes.d.ts`.
|
|
1045
|
-
* - Empty string (same-file schema) becomes a relative path from the
|
|
1046
|
-
* `routes.d.ts` directory back to the controller file.
|
|
1047
|
-
*/
|
|
1048
|
-
function resolveSchemaImportSpecifier(source, routeFilePath, routesOutFile) {
|
|
1049
|
-
if (source === null) return "unknown";
|
|
1050
|
-
const routesDir = dirname(routesOutFile);
|
|
1051
|
-
if (source === "") {
|
|
1052
|
-
let rel = relative(routesDir, routeFilePath).split(sep).join("/");
|
|
1053
|
-
rel = rel.replace(/\.(ts|tsx|mts|cts)$/i, "");
|
|
1054
|
-
if (!rel.startsWith(".")) rel = "./" + rel;
|
|
1055
|
-
return rel;
|
|
1056
|
-
}
|
|
1057
|
-
if (!source.startsWith(".") && !source.startsWith("/")) return source;
|
|
1058
|
-
let rel = relative(routesDir, resolve(dirname(routeFilePath), source)).split(sep).join("/");
|
|
1059
|
-
rel = rel.replace(/\.(ts|tsx|mts|cts)$/i, "");
|
|
1060
|
-
if (!rel.startsWith(".")) rel = "./" + rel;
|
|
1061
|
-
return rel;
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* Render the `KickEnv` + `NodeJS.ProcessEnv` augmentation file from a
|
|
1065
|
-
* detected env schema. Mirrors the routes.ts pattern: emits as a `.ts`
|
|
1066
|
-
* file (not `.d.ts`) so the top-level `import type schema from '...'`
|
|
1067
|
-
* actually resolves under `moduleResolution: 'bundler'`.
|
|
1068
|
-
*
|
|
1069
|
-
* Returns `null` when no env file was discovered, so the caller can
|
|
1070
|
-
* skip writing the file altogether (rather than emitting an empty
|
|
1071
|
-
* augmentation that would shadow `KickEnv` to a useless `{}`).
|
|
1072
|
-
*/
|
|
1073
|
-
function renderEnv(env, envOutFile) {
|
|
1074
|
-
if (!env) return null;
|
|
1075
|
-
let rel = relative(dirname(envOutFile), env.filePath).split(sep).join("/");
|
|
1076
|
-
rel = rel.replace(/\.(ts|tsx|mts|cts)$/i, "");
|
|
1077
|
-
if (!rel.startsWith(".")) rel = "./" + rel;
|
|
1078
|
-
return `${HEADER}
|
|
1079
|
-
// Importing the schema as a type lets us infer its shape without
|
|
1080
|
-
// pulling in any runtime code. \`Awaited<>\` strips an accidental
|
|
1081
|
-
// Promise wrap on dynamic-imported defaults.
|
|
1082
|
-
import type _envSchema from '${rel}'
|
|
1083
|
-
|
|
1084
|
-
// Local type alias — interfaces can only \`extend\` an identifier,
|
|
1085
|
-
// not an inline import expression, so we resolve the schema's
|
|
1086
|
-
// inferred shape into a named type first.
|
|
1087
|
-
type _KickEnvShape = import('zod').infer<typeof _envSchema>
|
|
1088
|
-
|
|
1089
|
-
declare global {
|
|
1090
|
-
/**
|
|
1091
|
-
* Typed environment registry. Augmented from \`${env.relativePath}\`
|
|
1092
|
-
* so \`@Value('PORT')\`, \`Env<'PORT'>\`, and \`process.env.PORT\` are
|
|
1093
|
-
* all type-safe and autocomplete.
|
|
1094
|
-
*/
|
|
1095
|
-
interface KickEnv extends _KickEnvShape {}
|
|
1096
|
-
|
|
1097
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
1098
|
-
namespace NodeJS {
|
|
1099
|
-
/**
|
|
1100
|
-
* Narrow \`process.env\` so known keys exist as \`string\` (the raw
|
|
1101
|
-
* pre-Zod-coercion form). \`@Value\` and the \`ConfigService\` apply
|
|
1102
|
-
* the schema's transforms internally; access \`process.env\` directly
|
|
1103
|
-
* only when you need the raw string. Unknown keys still resolve to
|
|
1104
|
-
* \`string | undefined\` via the base @types/node declaration.
|
|
1105
|
-
*/
|
|
1106
|
-
interface ProcessEnv extends Record<keyof KickEnv, string> {}
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
export {}
|
|
1111
|
-
`;
|
|
1112
|
-
}
|
|
1113
|
-
/**
|
|
1114
|
-
* Render the `KickRoutes` global namespace augmentation. Each interface
|
|
1115
|
-
* inside corresponds to a controller class; each property is a single
|
|
1116
|
-
* route method on that controller, conforming to `RouteShape`.
|
|
1117
|
-
*
|
|
1118
|
-
* Fills `params` from URL patterns, `query` from `@ApiQueryParams`, and
|
|
1119
|
-
* `body`/`query`/`params` (when schema-validated) from the configured
|
|
1120
|
-
* schema validator. `response` is emitted as `unknown`.
|
|
1121
|
-
*/
|
|
1122
|
-
function renderRoutes(routes, routesOutFile, schemaValidator) {
|
|
1123
|
-
if (routes.length === 0) return `${HEADER}
|
|
1124
|
-
// (no routes discovered yet — annotate a controller method with
|
|
1125
|
-
// @Get/@Post/@Put/@Delete/@Patch and re-run \`kick typegen\`)
|
|
1126
|
-
declare global {
|
|
1127
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
1128
|
-
namespace KickRoutes {}
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
export {}
|
|
1132
|
-
`;
|
|
1133
|
-
const byController = /* @__PURE__ */ new Map();
|
|
1134
|
-
for (const r of routes) {
|
|
1135
|
-
const arr = byController.get(r.controller) ?? [];
|
|
1136
|
-
arr.push(r);
|
|
1137
|
-
byController.set(r.controller, arr);
|
|
1138
|
-
}
|
|
1139
|
-
const schemaImports = /* @__PURE__ */ new Map();
|
|
1140
|
-
const renderField = (schema, routeFilePath) => {
|
|
1141
|
-
const alias = planSchemaImport(schema, routeFilePath, routesOutFile, schemaValidator, schemaImports);
|
|
1142
|
-
return alias ? `import('zod').infer<typeof ${alias}>` : null;
|
|
1143
|
-
};
|
|
1144
|
-
const interfaces = [];
|
|
1145
|
-
for (const [controller, methods] of byController) {
|
|
1146
|
-
const lines = [` interface ${controller} {`];
|
|
1147
|
-
for (const m of methods) {
|
|
1148
|
-
const urlParamsType = m.pathParams.length > 0 ? `{ ${m.pathParams.map((p) => `${p}: string`).join("; ")} }` : "{}";
|
|
1149
|
-
const bodySchemaType = renderField(m.bodySchema, m.filePath);
|
|
1150
|
-
const querySchemaType = renderField(m.querySchema, m.filePath);
|
|
1151
|
-
const paramsType = renderField(m.paramsSchema, m.filePath) ?? urlParamsType;
|
|
1152
|
-
const bodyType = bodySchemaType ?? "unknown";
|
|
1153
|
-
const queryType = querySchemaType ?? renderQueryShape(m);
|
|
1154
|
-
const docLines = renderQueryDocLines(m);
|
|
1155
|
-
lines.push(` /**`, ` * ${m.httpMethod} ${m.path}`, ...docLines.map((d) => ` * ${d}`), ` */`, ` ${m.method}: {`, ` params: ${paramsType}`, ` body: ${bodyType}`, ` query: ${queryType}`, ` response: unknown`, ` }`);
|
|
1156
|
-
}
|
|
1157
|
-
lines.push(" }");
|
|
1158
|
-
interfaces.push(lines.join("\n"));
|
|
1159
|
-
}
|
|
1160
|
-
return `${HEADER}${renderSchemaImports(schemaImports)}
|
|
1161
|
-
declare global {
|
|
1162
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
1163
|
-
namespace KickRoutes {
|
|
1164
|
-
${interfaces.join("\n")}
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
export {}
|
|
1169
|
-
`;
|
|
974
|
+
${includeEnv ? "import './kick__env'\n" : ""}`;
|
|
1170
975
|
}
|
|
1171
976
|
/**
|
|
1172
977
|
* Render the `KickJsPluginRegistry` augmentation. Each entry maps the
|
|
@@ -1183,7 +988,7 @@ export {}
|
|
|
1183
988
|
function renderPlugins(items) {
|
|
1184
989
|
const byName = /* @__PURE__ */ new Map();
|
|
1185
990
|
for (const item of items) if (!byName.has(item.name)) byName.set(item.name, item);
|
|
1186
|
-
const entries = [...byName.values()].
|
|
991
|
+
const entries = [...byName.values()].toSorted((a, b) => a.name.localeCompare(b.name)).map((item) => ` '${item.name}': '${item.kind}'`).join("\n");
|
|
1187
992
|
return `${HEADER}
|
|
1188
993
|
declare module '@forinda/kickjs' {
|
|
1189
994
|
/**
|
|
@@ -1226,7 +1031,7 @@ export {}
|
|
|
1226
1031
|
const byName = /* @__PURE__ */ new Map();
|
|
1227
1032
|
for (const item of items) if (!byName.has(item.name)) byName.set(item.name, item);
|
|
1228
1033
|
const blocks = [];
|
|
1229
|
-
for (const item of [...byName.values()].
|
|
1034
|
+
for (const item of [...byName.values()].toSorted((a, b) => a.name.localeCompare(b.name))) {
|
|
1230
1035
|
const docLines = [];
|
|
1231
1036
|
if (item.description) for (const line of item.description.split("\n")) docLines.push(` * ${line}`);
|
|
1232
1037
|
if (item.example) {
|
|
@@ -1255,14 +1060,12 @@ async function generateTypes(opts) {
|
|
|
1255
1060
|
const { classes, routes = [], tokens = [], injects = [], collisions = [], env = null, pluginsAndAdapters = [], augmentations = [], assets = {
|
|
1256
1061
|
entries: [],
|
|
1257
1062
|
count: 0
|
|
1258
|
-
}, outDir, allowDuplicates = false, schemaValidator = false } = opts;
|
|
1063
|
+
}, outDir, allowDuplicates = false, schemaValidator: _schemaValidator = false } = opts;
|
|
1259
1064
|
if (collisions.length > 0 && !allowDuplicates) throw new TokenCollisionError(collisions);
|
|
1260
1065
|
await mkdir(outDir, { recursive: true });
|
|
1261
1066
|
const registryFile = join(outDir, "registry.d.ts");
|
|
1262
1067
|
const servicesFile = join(outDir, "services.d.ts");
|
|
1263
1068
|
const modulesFile = join(outDir, "modules.d.ts");
|
|
1264
|
-
const routesFile = join(outDir, "routes.ts");
|
|
1265
|
-
const envFile = join(outDir, "env.ts");
|
|
1266
1069
|
const pluginsFile = join(outDir, "plugins.d.ts");
|
|
1267
1070
|
const augmentationsFile = join(outDir, "augmentations.d.ts");
|
|
1268
1071
|
const assetsFile = join(outDir, "assets.d.ts");
|
|
@@ -1280,16 +1083,13 @@ async function generateTypes(opts) {
|
|
|
1280
1083
|
const modules = classes.filter((c) => c.decorator === "Module").map((c) => c.className);
|
|
1281
1084
|
const servicesContent = renderUnion("ServiceToken", allServices, "(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)");
|
|
1282
1085
|
const modulesContent = renderUnion("ModuleToken", modules, "(no @Module classes discovered — `kick g module <name>` to add one)");
|
|
1283
|
-
const routesContent = renderRoutes(routes, routesFile, schemaValidator);
|
|
1284
|
-
const envContent = renderEnv(env, envFile);
|
|
1285
1086
|
const pluginsContent = renderPlugins(pluginsAndAdapters);
|
|
1286
1087
|
const augmentationsContent = renderAugmentations(augmentations);
|
|
1287
1088
|
const assetsContent = renderAssetTypes(assets);
|
|
1288
|
-
const indexContent = renderIndex(
|
|
1089
|
+
const indexContent = renderIndex(env !== null);
|
|
1289
1090
|
await writeFile(registryFile, registryContent, "utf-8");
|
|
1290
1091
|
await writeFile(servicesFile, servicesContent, "utf-8");
|
|
1291
1092
|
await writeFile(modulesFile, modulesContent, "utf-8");
|
|
1292
|
-
await writeFile(routesFile, routesContent, "utf-8");
|
|
1293
1093
|
await writeFile(pluginsFile, pluginsContent, "utf-8");
|
|
1294
1094
|
await writeFile(augmentationsFile, augmentationsContent, "utf-8");
|
|
1295
1095
|
await writeFile(assetsFile, assetsContent, "utf-8");
|
|
@@ -1298,16 +1098,11 @@ async function generateTypes(opts) {
|
|
|
1298
1098
|
registryFile,
|
|
1299
1099
|
servicesFile,
|
|
1300
1100
|
modulesFile,
|
|
1301
|
-
routesFile,
|
|
1302
1101
|
pluginsFile,
|
|
1303
1102
|
augmentationsFile,
|
|
1304
1103
|
assetsFile,
|
|
1305
1104
|
indexFile
|
|
1306
1105
|
];
|
|
1307
|
-
if (envContent) {
|
|
1308
|
-
await writeFile(envFile, envContent, "utf-8");
|
|
1309
|
-
written.push(envFile);
|
|
1310
|
-
}
|
|
1311
1106
|
await writeFile(join(dirname(outDir), ".gitignore"), "# Auto-generated by kick typegen\n*\n", "utf-8");
|
|
1312
1107
|
const uniquePluginNames = new Set(pluginsAndAdapters.map((p) => p.name)).size;
|
|
1313
1108
|
const uniqueAugmentations = new Set(augmentations.map((a) => a.name)).size;
|
|
@@ -1319,7 +1114,7 @@ async function generateTypes(opts) {
|
|
|
1319
1114
|
pluginEntries: uniquePluginNames,
|
|
1320
1115
|
augmentationEntries: uniqueAugmentations,
|
|
1321
1116
|
assetEntries: assets.count,
|
|
1322
|
-
envWritten:
|
|
1117
|
+
envWritten: env !== null,
|
|
1323
1118
|
written,
|
|
1324
1119
|
resolvedCollisions: collisions.length
|
|
1325
1120
|
};
|
|
@@ -1424,6 +1219,20 @@ async function runTypegen(opts = {}) {
|
|
|
1424
1219
|
allowDuplicates,
|
|
1425
1220
|
schemaValidator
|
|
1426
1221
|
});
|
|
1222
|
+
if (opts.runPlugins !== false) try {
|
|
1223
|
+
const { runAllPluginTypegens } = await import("./run-plugins-D9abb5Nx.mjs");
|
|
1224
|
+
const { loadKickConfig } = await import("./config-CRi3zCxk.mjs").then((n) => n.n);
|
|
1225
|
+
await runAllPluginTypegens({
|
|
1226
|
+
cwd,
|
|
1227
|
+
config: await loadKickConfig(cwd),
|
|
1228
|
+
silent: true
|
|
1229
|
+
});
|
|
1230
|
+
} catch (err) {
|
|
1231
|
+
if (!silent) {
|
|
1232
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1233
|
+
console.warn(` kick typegen: plugin pipeline failed (${msg}) — continuing`);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1427
1236
|
const tokenWarnings = validateTokenConventions(scan.tokens);
|
|
1428
1237
|
const elapsed = Date.now() - start;
|
|
1429
1238
|
if (!silent) {
|
|
@@ -1469,9 +1278,11 @@ async function watchTypegen(opts = {}) {
|
|
|
1469
1278
|
const { srcDir, silent, cwd } = resolved;
|
|
1470
1279
|
const runOpts = {
|
|
1471
1280
|
...resolved,
|
|
1472
|
-
allowDuplicates: true
|
|
1281
|
+
allowDuplicates: true,
|
|
1282
|
+
runPlugins: false
|
|
1473
1283
|
};
|
|
1474
|
-
const
|
|
1284
|
+
const forcePolling = process.env.KICKJS_WATCH_POLLING === "1" || process.env.KICKJS_WATCH_POLLING === "true";
|
|
1285
|
+
const [{ runAllPluginTypegens }, { loadKickConfig }] = await Promise.all([import("./run-plugins-D9abb5Nx.mjs"), import("./config-CRi3zCxk.mjs").then((n) => n.n)]);
|
|
1475
1286
|
const pluginConfig = await loadKickConfig(cwd);
|
|
1476
1287
|
const runPlugins = () => runAllPluginTypegens({
|
|
1477
1288
|
cwd,
|
|
@@ -1493,6 +1304,16 @@ async function watchTypegen(opts = {}) {
|
|
|
1493
1304
|
runPlugins();
|
|
1494
1305
|
}, 100);
|
|
1495
1306
|
};
|
|
1307
|
+
if (forcePolling) {
|
|
1308
|
+
if (!silent) console.log(" kick typegen: polling mode (KICKJS_WATCH_POLLING)");
|
|
1309
|
+
const interval = setInterval(() => {
|
|
1310
|
+
safeRun({
|
|
1311
|
+
...runOpts,
|
|
1312
|
+
silent: true
|
|
1313
|
+
}, true);
|
|
1314
|
+
}, 2e3);
|
|
1315
|
+
return () => clearInterval(interval);
|
|
1316
|
+
}
|
|
1496
1317
|
let watcher;
|
|
1497
1318
|
try {
|
|
1498
1319
|
watcher = watch(srcDir, { recursive: true }, (_event, filename) => {
|
|
@@ -1527,4 +1348,6 @@ async function safeRun(opts, silent) {
|
|
|
1527
1348
|
}
|
|
1528
1349
|
}
|
|
1529
1350
|
//#endregion
|
|
1530
|
-
export { discoverAssets as a, TokenCollisionError as i, typegen_exports as n, renderAssetTypes as o, watchTypegen as r, runTypegen as t };
|
|
1351
|
+
export { discoverAssets as a, TokenCollisionError as i, typegen_exports as n, renderAssetTypes as o, watchTypegen as r, scanProject as s, runTypegen as t };
|
|
1352
|
+
|
|
1353
|
+
//# sourceMappingURL=typegen-B9S81bOx.mjs.map
|