@geekmidas/cli 0.3.0 → 0.5.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 +488 -71
- package/dist/CronGenerator-BPTqNYOR.d.cts +14 -0
- package/dist/{CronGenerator-Bh26MaNA.mjs → CronGenerator-CCRYptuT.mjs} +2 -2
- package/dist/{CronGenerator-Bh26MaNA.mjs.map → CronGenerator-CCRYptuT.mjs.map} +1 -1
- package/dist/{CronGenerator-C6MF8rlG.cjs → CronGenerator-D4TWXQbh.cjs} +2 -2
- package/dist/{CronGenerator-C6MF8rlG.cjs.map → CronGenerator-D4TWXQbh.cjs.map} +1 -1
- package/dist/CronGenerator-YAj59JUd.d.mts +14 -0
- package/dist/EndpointGenerator-ChAD1INz.d.cts +19 -0
- package/dist/EndpointGenerator-Cj3O1U8-.d.mts +19 -0
- package/dist/{EndpointGenerator-CWh18d92.mjs → EndpointGenerator-DGivkPLT.mjs} +77 -7
- package/dist/EndpointGenerator-DGivkPLT.mjs.map +1 -0
- package/dist/{EndpointGenerator-C73wNoih.cjs → EndpointGenerator-npWEDoK2.cjs} +77 -7
- package/dist/EndpointGenerator-npWEDoK2.cjs.map +1 -0
- package/dist/FunctionGenerator-429-9NER.d.cts +14 -0
- package/dist/FunctionGenerator-BQ4ehoID.d.mts +14 -0
- package/dist/{FunctionGenerator-BNE_GC7N.mjs → FunctionGenerator-CVk0h8tO.mjs} +2 -2
- package/dist/{FunctionGenerator-BNE_GC7N.mjs.map → FunctionGenerator-CVk0h8tO.mjs.map} +1 -1
- package/dist/{FunctionGenerator-FgZUTd8L.cjs → FunctionGenerator-DYTnyr4c.cjs} +2 -2
- package/dist/{FunctionGenerator-FgZUTd8L.cjs.map → FunctionGenerator-DYTnyr4c.cjs.map} +1 -1
- package/dist/Generator-BjHK_qce.d.mts +27 -0
- package/dist/{Generator-UanJW0_V.mjs → Generator-CDt4pB3W.mjs} +1 -1
- package/dist/{Generator-UanJW0_V.mjs.map → Generator-CDt4pB3W.mjs.map} +1 -1
- package/dist/{Generator-CDoEXCDg.cjs → Generator-CLVplqm2.cjs} +1 -1
- package/dist/{Generator-CDoEXCDg.cjs.map → Generator-CLVplqm2.cjs.map} +1 -1
- package/dist/Generator-DxQMCQp7.d.cts +27 -0
- package/dist/OpenApiTsGenerator-Be-sKGTT.cjs +501 -0
- package/dist/OpenApiTsGenerator-Be-sKGTT.cjs.map +1 -0
- package/dist/OpenApiTsGenerator-C4mHHaku.mjs +495 -0
- package/dist/OpenApiTsGenerator-C4mHHaku.mjs.map +1 -0
- package/dist/SubscriberGenerator-7uX42xyG.d.mts +15 -0
- package/dist/{SubscriberGenerator-Dnlj_1FK.mjs → SubscriberGenerator-DABaJXML.mjs} +2 -2
- package/dist/{SubscriberGenerator-Dnlj_1FK.mjs.map → SubscriberGenerator-DABaJXML.mjs.map} +1 -1
- package/dist/{SubscriberGenerator-Bd-a7aiw.cjs → SubscriberGenerator-D_zpNGFr.cjs} +2 -2
- package/dist/{SubscriberGenerator-Bd-a7aiw.cjs.map → SubscriberGenerator-D_zpNGFr.cjs.map} +1 -1
- package/dist/SubscriberGenerator-Dtb3HS4i.d.cts +15 -0
- package/dist/api-B3SCEHPf.cjs +190 -0
- package/dist/api-B3SCEHPf.cjs.map +1 -0
- package/dist/api-BKIN0s0S.mjs +184 -0
- package/dist/api-BKIN0s0S.mjs.map +1 -0
- package/dist/build/index.cjs +11 -10
- package/dist/build/index.d.cts +7 -0
- package/dist/build/index.d.mts +7 -0
- package/dist/build/index.mjs +11 -10
- package/dist/build/manifests.cjs +1 -1
- package/dist/build/manifests.d.cts +13 -0
- package/dist/build/manifests.d.mts +13 -0
- package/dist/build/manifests.mjs +1 -1
- package/dist/build/providerResolver.cjs +1 -1
- package/dist/build/providerResolver.d.cts +23 -0
- package/dist/build/providerResolver.d.mts +23 -0
- package/dist/build/providerResolver.mjs +1 -1
- package/dist/build/types.d.cts +3 -0
- package/dist/build/types.d.mts +3 -0
- package/dist/{build-C6uEGRj8.mjs → build-B8C_qHir.mjs} +15 -13
- package/dist/build-B8C_qHir.mjs.map +1 -0
- package/dist/{build-CBYBPZpC.cjs → build-D0Wr49bf.cjs} +15 -13
- package/dist/build-D0Wr49bf.cjs.map +1 -0
- package/dist/config-Ba-Gbpbc.d.cts +11 -0
- package/dist/config-Bq72aj8e.mjs +75 -0
- package/dist/config-Bq72aj8e.mjs.map +1 -0
- package/dist/config-CFls09Ey.cjs +93 -0
- package/dist/config-CFls09Ey.cjs.map +1 -0
- package/dist/config-CLEDqKO3.cjs +157 -0
- package/dist/config-CLEDqKO3.cjs.map +1 -0
- package/dist/config-DBsmMDhf.d.mts +11 -0
- package/dist/config-Dp8RonV_.mjs +151 -0
- package/dist/config-Dp8RonV_.mjs.map +1 -0
- package/dist/config.cjs +4 -2
- package/dist/config.d.cts +48 -0
- package/dist/config.d.mts +48 -0
- package/dist/config.mjs +2 -2
- package/dist/dev/index.cjs +12 -10
- package/dist/dev/index.d.cts +36 -0
- package/dist/dev/index.d.mts +36 -0
- package/dist/dev/index.mjs +10 -10
- package/dist/dev-B734w3L1.mjs +343 -0
- package/dist/dev-B734w3L1.mjs.map +1 -0
- package/dist/{dev-DbtyToc7.cjs → dev-DHqYn8k4.cjs} +161 -47
- package/dist/dev-DHqYn8k4.cjs.map +1 -0
- package/dist/docker-5d8Yh5_X.cjs +119 -0
- package/dist/docker-5d8Yh5_X.cjs.map +1 -0
- package/dist/docker-DlUqdFle.mjs +113 -0
- package/dist/docker-DlUqdFle.mjs.map +1 -0
- package/dist/env-B-OKjgI4.cjs +144 -0
- package/dist/env-B-OKjgI4.cjs.map +1 -0
- package/dist/env-HfuJRlg5.d.cts +11 -0
- package/dist/env-nd-iQPYM.d.mts +11 -0
- package/dist/env-tv1HlZlw.mjs +138 -0
- package/dist/env-tv1HlZlw.mjs.map +1 -0
- package/dist/generators/CronGenerator.cjs +2 -2
- package/dist/generators/CronGenerator.d.cts +5 -0
- package/dist/generators/CronGenerator.d.mts +5 -0
- package/dist/generators/CronGenerator.mjs +2 -2
- package/dist/generators/EndpointGenerator.cjs +2 -2
- package/dist/generators/EndpointGenerator.d.cts +5 -0
- package/dist/generators/EndpointGenerator.d.mts +5 -0
- package/dist/generators/EndpointGenerator.mjs +2 -2
- package/dist/generators/FunctionGenerator.cjs +2 -2
- package/dist/generators/FunctionGenerator.d.cts +5 -0
- package/dist/generators/FunctionGenerator.d.mts +5 -0
- package/dist/generators/FunctionGenerator.mjs +2 -2
- package/dist/generators/Generator.cjs +1 -1
- package/dist/generators/Generator.d.cts +4 -0
- package/dist/generators/Generator.d.mts +4 -0
- package/dist/generators/Generator.mjs +1 -1
- package/dist/generators/OpenApiTsGenerator.cjs +3 -0
- package/dist/generators/OpenApiTsGenerator.d.cts +44 -0
- package/dist/generators/OpenApiTsGenerator.d.mts +44 -0
- package/dist/generators/OpenApiTsGenerator.mjs +3 -0
- package/dist/generators/SubscriberGenerator.cjs +2 -2
- package/dist/generators/SubscriberGenerator.d.cts +5 -0
- package/dist/generators/SubscriberGenerator.d.mts +5 -0
- package/dist/generators/SubscriberGenerator.mjs +2 -2
- package/dist/generators/index.cjs +6 -6
- package/dist/generators/index.d.cts +8 -0
- package/dist/generators/index.d.mts +8 -0
- package/dist/generators/index.mjs +6 -6
- package/dist/index-C523No_B.d.mts +64 -0
- package/dist/index-DrzN4xkQ.d.cts +64 -0
- package/dist/index.cjs +56 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +56 -18
- package/dist/index.mjs.map +1 -1
- package/dist/init/generators/config.cjs +3 -0
- package/dist/init/generators/config.d.cts +3 -0
- package/dist/init/generators/config.d.mts +3 -0
- package/dist/init/generators/config.mjs +3 -0
- package/dist/init/generators/docker.cjs +3 -0
- package/dist/init/generators/docker.d.cts +11 -0
- package/dist/init/generators/docker.d.mts +11 -0
- package/dist/init/generators/docker.mjs +3 -0
- package/dist/init/generators/env.cjs +3 -0
- package/dist/init/generators/env.d.cts +3 -0
- package/dist/init/generators/env.d.mts +3 -0
- package/dist/init/generators/env.mjs +3 -0
- package/dist/init/generators/index.cjs +9 -0
- package/dist/init/generators/index.d.cts +6 -0
- package/dist/init/generators/index.d.mts +6 -0
- package/dist/init/generators/index.mjs +6 -0
- package/dist/init/generators/models.cjs +3 -0
- package/dist/init/generators/models.d.cts +11 -0
- package/dist/init/generators/models.d.mts +11 -0
- package/dist/init/generators/models.mjs +3 -0
- package/dist/init/generators/monorepo.cjs +3 -0
- package/dist/init/generators/monorepo.d.cts +11 -0
- package/dist/init/generators/monorepo.d.mts +11 -0
- package/dist/init/generators/monorepo.mjs +3 -0
- package/dist/init/generators/package.cjs +3 -0
- package/dist/init/generators/package.d.cts +3 -0
- package/dist/init/generators/package.d.mts +3 -0
- package/dist/init/generators/package.mjs +3 -0
- package/dist/init/generators/source.cjs +3 -0
- package/dist/init/generators/source.d.cts +3 -0
- package/dist/init/generators/source.d.mts +3 -0
- package/dist/init/generators/source.mjs +3 -0
- package/dist/init/index.cjs +16 -0
- package/dist/init/index.d.cts +17 -0
- package/dist/init/index.d.mts +17 -0
- package/dist/init/index.mjs +16 -0
- package/dist/init/templates/api.cjs +3 -0
- package/dist/init/templates/api.d.cts +7 -0
- package/dist/init/templates/api.d.mts +7 -0
- package/dist/init/templates/api.mjs +3 -0
- package/dist/init/templates/index.cjs +10 -0
- package/dist/init/templates/index.d.cts +2 -0
- package/dist/init/templates/index.d.mts +2 -0
- package/dist/init/templates/index.mjs +7 -0
- package/dist/init/templates/minimal.cjs +3 -0
- package/dist/init/templates/minimal.d.cts +7 -0
- package/dist/init/templates/minimal.d.mts +7 -0
- package/dist/init/templates/minimal.mjs +3 -0
- package/dist/init/templates/serverless.cjs +3 -0
- package/dist/init/templates/serverless.d.cts +7 -0
- package/dist/init/templates/serverless.d.mts +7 -0
- package/dist/init/templates/serverless.mjs +3 -0
- package/dist/init/templates/worker.cjs +3 -0
- package/dist/init/templates/worker.d.cts +7 -0
- package/dist/init/templates/worker.d.mts +7 -0
- package/dist/init/templates/worker.mjs +3 -0
- package/dist/init/utils.cjs +7 -0
- package/dist/init/utils.d.cts +25 -0
- package/dist/init/utils.d.mts +25 -0
- package/dist/init/utils.mjs +3 -0
- package/dist/init-CtOnZn3G.mjs +145 -0
- package/dist/init-CtOnZn3G.mjs.map +1 -0
- package/dist/init-qLFsWR-R.cjs +151 -0
- package/dist/init-qLFsWR-R.cjs.map +1 -0
- package/dist/{manifests-C2eMoMUm.mjs → manifests-DIA_2QYd.mjs} +1 -1
- package/dist/{manifests-C2eMoMUm.mjs.map → manifests-DIA_2QYd.mjs.map} +1 -1
- package/dist/{manifests-CK1VV_pM.cjs → manifests-VJ9-2JpW.cjs} +1 -1
- package/dist/{manifests-CK1VV_pM.cjs.map → manifests-VJ9-2JpW.cjs.map} +1 -1
- package/dist/minimal-Bdhhpp7v.cjs +93 -0
- package/dist/minimal-Bdhhpp7v.cjs.map +1 -0
- package/dist/minimal-C4GsE45s.mjs +87 -0
- package/dist/minimal-C4GsE45s.mjs.map +1 -0
- package/dist/models-DyNwdOcz.cjs +121 -0
- package/dist/models-DyNwdOcz.cjs.map +1 -0
- package/dist/models-cvNg6Oea.mjs +115 -0
- package/dist/models-cvNg6Oea.mjs.map +1 -0
- package/dist/monorepo-Cknwzj5C.mjs +184 -0
- package/dist/monorepo-Cknwzj5C.mjs.map +1 -0
- package/dist/monorepo-sEK8gW59.cjs +190 -0
- package/dist/monorepo-sEK8gW59.cjs.map +1 -0
- package/dist/openapi-BQWPWyNB.cjs +56 -0
- package/dist/openapi-BQWPWyNB.cjs.map +1 -0
- package/dist/openapi-DBX8cJJ8.mjs +50 -0
- package/dist/openapi-DBX8cJJ8.mjs.map +1 -0
- package/dist/{openapi-react-query-D9Z7lh0p.cjs → openapi-react-query-DxHjXQvg.cjs} +1 -1
- package/dist/{openapi-react-query-D9Z7lh0p.cjs.map → openapi-react-query-DxHjXQvg.cjs.map} +1 -1
- package/dist/{openapi-react-query-MEBlYIM1.mjs → openapi-react-query-o7Mp1Jd5.mjs} +1 -1
- package/dist/{openapi-react-query-MEBlYIM1.mjs.map → openapi-react-query-o7Mp1Jd5.mjs.map} +1 -1
- package/dist/openapi-react-query.cjs +1 -1
- package/dist/openapi-react-query.d.cts +11 -0
- package/dist/openapi-react-query.d.mts +11 -0
- package/dist/openapi-react-query.mjs +1 -1
- package/dist/openapi.cjs +5 -4
- package/dist/openapi.d.cts +11 -0
- package/dist/openapi.d.mts +11 -0
- package/dist/openapi.mjs +5 -4
- package/dist/package-C7WhWU8m.d.mts +11 -0
- package/dist/package-CIfmeuSW.mjs +51 -0
- package/dist/package-CIfmeuSW.mjs.map +1 -0
- package/dist/package-DvWEMz6z.d.cts +11 -0
- package/dist/package-PP-o1nvq.cjs +57 -0
- package/dist/package-PP-o1nvq.cjs.map +1 -0
- package/dist/{providerResolver-B_TjNF0_.mjs → providerResolver-DEVKngbC.mjs} +1 -1
- package/dist/{providerResolver-B_TjNF0_.mjs.map → providerResolver-DEVKngbC.mjs.map} +1 -1
- package/dist/{providerResolver-DgvzNfP4.cjs → providerResolver-DOTbN9jo.cjs} +1 -1
- package/dist/{providerResolver-DgvzNfP4.cjs.map → providerResolver-DOTbN9jo.cjs.map} +1 -1
- package/dist/serverless-DkHBF2vC.mjs +108 -0
- package/dist/serverless-DkHBF2vC.mjs.map +1 -0
- package/dist/serverless-Yav3GRVz.cjs +114 -0
- package/dist/serverless-Yav3GRVz.cjs.map +1 -0
- package/dist/source-D6v2BnKT.d.mts +11 -0
- package/dist/source-D8fK9qRo.d.cts +11 -0
- package/dist/source-DT5Xhiob.cjs +17 -0
- package/dist/source-DT5Xhiob.cjs.map +1 -0
- package/dist/source-DnaH_MLA.mjs +11 -0
- package/dist/source-DnaH_MLA.mjs.map +1 -0
- package/dist/templates-CBFUwpBy.mjs +64 -0
- package/dist/templates-CBFUwpBy.mjs.map +1 -0
- package/dist/templates-DM_rtYYW.cjs +87 -0
- package/dist/templates-DM_rtYYW.cjs.map +1 -0
- package/dist/types-C4KITv-y.d.mts +51 -0
- package/dist/types-Cxl8-uwV.d.mts +129 -0
- package/dist/types-DB99_qIy.d.cts +129 -0
- package/dist/types-DLFN49M3.d.cts +51 -0
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/utils-BX3F4fT8.cjs +99 -0
- package/dist/utils-BX3F4fT8.cjs.map +1 -0
- package/dist/utils-C31-SWHP.mjs +69 -0
- package/dist/utils-C31-SWHP.mjs.map +1 -0
- package/dist/worker--8O5a3Hv.cjs +150 -0
- package/dist/worker--8O5a3Hv.cjs.map +1 -0
- package/dist/worker-Jme7uOOJ.mjs +144 -0
- package/dist/worker-Jme7uOOJ.mjs.map +1 -0
- package/docs/OPENAPI_TYPESCRIPT_DESIGN.md +408 -0
- package/package.json +19 -4
- package/src/__tests__/loadEnvFiles.spec.ts +131 -0
- package/src/__tests__/openapi.spec.ts +78 -63
- package/src/build/index.ts +14 -16
- package/src/build/types.ts +18 -2
- package/src/config.ts +61 -2
- package/src/dev/__tests__/index.spec.ts +98 -1
- package/src/dev/index.ts +229 -42
- package/src/generators/EndpointGenerator.ts +98 -5
- package/src/generators/OpenApiTsGenerator.ts +798 -0
- package/src/index.ts +32 -3
- package/src/init/__tests__/generators.spec.ts +366 -0
- package/src/init/__tests__/init.spec.ts +341 -0
- package/src/init/__tests__/utils.spec.ts +104 -0
- package/src/init/generators/config.ts +192 -0
- package/src/init/generators/docker.ts +134 -0
- package/src/init/generators/env.ts +182 -0
- package/src/init/generators/index.ts +4 -0
- package/src/init/generators/models.ts +129 -0
- package/src/init/generators/monorepo.ts +211 -0
- package/src/init/generators/package.ts +81 -0
- package/src/init/generators/source.ts +15 -0
- package/src/init/index.ts +206 -0
- package/src/init/templates/api.ts +218 -0
- package/src/init/templates/index.ts +108 -0
- package/src/init/templates/minimal.ts +102 -0
- package/src/init/templates/serverless.ts +129 -0
- package/src/init/templates/worker.ts +169 -0
- package/src/init/utils.ts +98 -0
- package/src/openapi.ts +36 -15
- package/src/types.ts +43 -0
- package/tsdown.config.ts +1 -1
- package/dist/EndpointGenerator-C73wNoih.cjs.map +0 -1
- package/dist/EndpointGenerator-CWh18d92.mjs.map +0 -1
- package/dist/build-C6uEGRj8.mjs.map +0 -1
- package/dist/build-CBYBPZpC.cjs.map +0 -1
- package/dist/config-D1EpSGk6.cjs +0 -36
- package/dist/config-D1EpSGk6.cjs.map +0 -1
- package/dist/config-U-mdW-7Y.mjs +0 -30
- package/dist/config-U-mdW-7Y.mjs.map +0 -1
- package/dist/dev-DbtyToc7.cjs.map +0 -1
- package/dist/dev-DnGYXuMn.mjs +0 -241
- package/dist/dev-DnGYXuMn.mjs.map +0 -1
- package/dist/openapi-BTHbPrxS.mjs +0 -36
- package/dist/openapi-BTHbPrxS.mjs.map +0 -1
- package/dist/openapi-CewcfoRH.cjs +0 -42
- package/dist/openapi-CewcfoRH.cjs.map +0 -1
- /package/dist/{generators-CEKtVh81.cjs → generators-3IemvCLk.cjs} +0 -0
- /package/dist/{generators-CsLujGXs.mjs → generators-FNpdfN6J.mjs} +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
//#region src/init/generators/models.ts
|
|
2
|
+
/**
|
|
3
|
+
* Generate packages/models for shared Zod schemas (monorepo only)
|
|
4
|
+
*/
|
|
5
|
+
function generateModelsPackage(options) {
|
|
6
|
+
if (!options.monorepo) return [];
|
|
7
|
+
const packageName = `@${options.name}/models`;
|
|
8
|
+
const packageJson = {
|
|
9
|
+
name: packageName,
|
|
10
|
+
version: "0.0.1",
|
|
11
|
+
private: true,
|
|
12
|
+
type: "module",
|
|
13
|
+
exports: {
|
|
14
|
+
".": {
|
|
15
|
+
types: "./dist/index.d.ts",
|
|
16
|
+
import: "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./*": {
|
|
19
|
+
types: "./dist/*.d.ts",
|
|
20
|
+
import: "./dist/*.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
scripts: {
|
|
24
|
+
build: "tsc",
|
|
25
|
+
"build:watch": "tsc --watch",
|
|
26
|
+
typecheck: "tsc --noEmit"
|
|
27
|
+
},
|
|
28
|
+
dependencies: { zod: "~4.1.0" },
|
|
29
|
+
devDependencies: { typescript: "~5.8.2" }
|
|
30
|
+
};
|
|
31
|
+
const tsConfig = {
|
|
32
|
+
extends: "../../tsconfig.json",
|
|
33
|
+
compilerOptions: {
|
|
34
|
+
outDir: "./dist",
|
|
35
|
+
rootDir: "./src"
|
|
36
|
+
},
|
|
37
|
+
include: ["src/**/*.ts"],
|
|
38
|
+
exclude: ["node_modules", "dist"]
|
|
39
|
+
};
|
|
40
|
+
const indexTs = `import { z } from 'zod';
|
|
41
|
+
|
|
42
|
+
// ============================================
|
|
43
|
+
// Common Schemas
|
|
44
|
+
// ============================================
|
|
45
|
+
|
|
46
|
+
export const idSchema = z.string().uuid();
|
|
47
|
+
|
|
48
|
+
export const timestampsSchema = z.object({
|
|
49
|
+
createdAt: z.coerce.date(),
|
|
50
|
+
updatedAt: z.coerce.date(),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const paginationSchema = z.object({
|
|
54
|
+
page: z.coerce.number().int().positive().default(1),
|
|
55
|
+
limit: z.coerce.number().int().positive().max(100).default(20),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const paginatedResponseSchema = <T extends z.ZodTypeAny>(itemSchema: T) =>
|
|
59
|
+
z.object({
|
|
60
|
+
items: z.array(itemSchema),
|
|
61
|
+
total: z.number(),
|
|
62
|
+
page: z.number(),
|
|
63
|
+
limit: z.number(),
|
|
64
|
+
totalPages: z.number(),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// ============================================
|
|
68
|
+
// User Schemas
|
|
69
|
+
// ============================================
|
|
70
|
+
|
|
71
|
+
export const userSchema = z.object({
|
|
72
|
+
id: idSchema,
|
|
73
|
+
email: z.string().email(),
|
|
74
|
+
name: z.string().min(1).max(100),
|
|
75
|
+
...timestampsSchema.shape,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export const createUserSchema = userSchema.omit({
|
|
79
|
+
id: true,
|
|
80
|
+
createdAt: true,
|
|
81
|
+
updatedAt: true,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export const updateUserSchema = createUserSchema.partial();
|
|
85
|
+
|
|
86
|
+
// ============================================
|
|
87
|
+
// Type Exports
|
|
88
|
+
// ============================================
|
|
89
|
+
|
|
90
|
+
export type Id = z.infer<typeof idSchema>;
|
|
91
|
+
export type Timestamps = z.infer<typeof timestampsSchema>;
|
|
92
|
+
export type Pagination = z.infer<typeof paginationSchema>;
|
|
93
|
+
export type User = z.infer<typeof userSchema>;
|
|
94
|
+
export type CreateUser = z.infer<typeof createUserSchema>;
|
|
95
|
+
export type UpdateUser = z.infer<typeof updateUserSchema>;
|
|
96
|
+
`;
|
|
97
|
+
return [
|
|
98
|
+
{
|
|
99
|
+
path: "packages/models/package.json",
|
|
100
|
+
content: JSON.stringify(packageJson, null, 2) + "\n"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
path: "packages/models/tsconfig.json",
|
|
104
|
+
content: JSON.stringify(tsConfig, null, 2) + "\n"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
path: "packages/models/src/index.ts",
|
|
108
|
+
content: indexTs
|
|
109
|
+
}
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { generateModelsPackage };
|
|
115
|
+
//# sourceMappingURL=models-cvNg6Oea.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models-cvNg6Oea.mjs","names":["options: TemplateOptions"],"sources":["../src/init/generators/models.ts"],"sourcesContent":["import type { GeneratedFile, TemplateOptions } from '../templates/index.js';\n\n/**\n * Generate packages/models for shared Zod schemas (monorepo only)\n */\nexport function generateModelsPackage(\n options: TemplateOptions,\n): GeneratedFile[] {\n if (!options.monorepo) {\n return [];\n }\n\n // Package name based on project name\n const packageName = `@${options.name}/models`;\n\n // package.json for models\n const packageJson = {\n name: packageName,\n version: '0.0.1',\n private: true,\n type: 'module',\n exports: {\n '.': {\n types: './dist/index.d.ts',\n import: './dist/index.js',\n },\n './*': {\n types: './dist/*.d.ts',\n import: './dist/*.js',\n },\n },\n scripts: {\n build: 'tsc',\n 'build:watch': 'tsc --watch',\n typecheck: 'tsc --noEmit',\n },\n dependencies: {\n zod: '~4.1.0',\n },\n devDependencies: {\n typescript: '~5.8.2',\n },\n };\n\n // tsconfig.json for models - extends root\n const tsConfig = {\n extends: '../../tsconfig.json',\n compilerOptions: {\n outDir: './dist',\n rootDir: './src',\n },\n include: ['src/**/*.ts'],\n exclude: ['node_modules', 'dist'],\n };\n\n // Main index.ts with example schemas\n const indexTs = `import { z } from 'zod';\n\n// ============================================\n// Common Schemas\n// ============================================\n\nexport const idSchema = z.string().uuid();\n\nexport const timestampsSchema = z.object({\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n});\n\nexport const paginationSchema = z.object({\n page: z.coerce.number().int().positive().default(1),\n limit: z.coerce.number().int().positive().max(100).default(20),\n});\n\nexport const paginatedResponseSchema = <T extends z.ZodTypeAny>(itemSchema: T) =>\n z.object({\n items: z.array(itemSchema),\n total: z.number(),\n page: z.number(),\n limit: z.number(),\n totalPages: z.number(),\n });\n\n// ============================================\n// User Schemas\n// ============================================\n\nexport const userSchema = z.object({\n id: idSchema,\n email: z.string().email(),\n name: z.string().min(1).max(100),\n ...timestampsSchema.shape,\n});\n\nexport const createUserSchema = userSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n});\n\nexport const updateUserSchema = createUserSchema.partial();\n\n// ============================================\n// Type Exports\n// ============================================\n\nexport type Id = z.infer<typeof idSchema>;\nexport type Timestamps = z.infer<typeof timestampsSchema>;\nexport type Pagination = z.infer<typeof paginationSchema>;\nexport type User = z.infer<typeof userSchema>;\nexport type CreateUser = z.infer<typeof createUserSchema>;\nexport type UpdateUser = z.infer<typeof updateUserSchema>;\n`;\n\n return [\n {\n path: 'packages/models/package.json',\n content: JSON.stringify(packageJson, null, 2) + '\\n',\n },\n {\n path: 'packages/models/tsconfig.json',\n content: JSON.stringify(tsConfig, null, 2) + '\\n',\n },\n {\n path: 'packages/models/src/index.ts',\n content: indexTs,\n },\n ];\n}\n"],"mappings":";;;;AAKA,SAAgB,sBACdA,SACiB;AACjB,MAAK,QAAQ,SACX,QAAO,CAAE;CAIX,MAAM,eAAe,GAAG,QAAQ,KAAK;CAGrC,MAAM,cAAc;EAClB,MAAM;EACN,SAAS;EACT,SAAS;EACT,MAAM;EACN,SAAS;GACP,KAAK;IACH,OAAO;IACP,QAAQ;GACT;GACD,OAAO;IACL,OAAO;IACP,QAAQ;GACT;EACF;EACD,SAAS;GACP,OAAO;GACP,eAAe;GACf,WAAW;EACZ;EACD,cAAc,EACZ,KAAK,SACN;EACD,iBAAiB,EACf,YAAY,SACb;CACF;CAGD,MAAM,WAAW;EACf,SAAS;EACT,iBAAiB;GACf,QAAQ;GACR,SAAS;EACV;EACD,SAAS,CAAC,aAAc;EACxB,SAAS,CAAC,gBAAgB,MAAO;CAClC;CAGD,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DjB,QAAO;EACL;GACE,MAAM;GACN,SAAS,KAAK,UAAU,aAAa,MAAM,EAAE,GAAG;EACjD;EACD;GACE,MAAM;GACN,SAAS,KAAK,UAAU,UAAU,MAAM,EAAE,GAAG;EAC9C;EACD;GACE,MAAM;GACN,SAAS;EACV;CACF;AACF"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
//#region src/init/generators/monorepo.ts
|
|
2
|
+
/**
|
|
3
|
+
* Generate monorepo root files (pnpm-workspace.yaml, root package.json, etc.)
|
|
4
|
+
*/
|
|
5
|
+
function generateMonorepoFiles(options, _template) {
|
|
6
|
+
if (!options.monorepo) return [];
|
|
7
|
+
const rootPackageJson = {
|
|
8
|
+
name: options.name,
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
private: true,
|
|
11
|
+
type: "module",
|
|
12
|
+
scripts: {
|
|
13
|
+
dev: "turbo dev",
|
|
14
|
+
build: "turbo build",
|
|
15
|
+
test: "turbo test",
|
|
16
|
+
"test:once": "turbo test:once",
|
|
17
|
+
typecheck: "turbo typecheck",
|
|
18
|
+
lint: "biome lint .",
|
|
19
|
+
fmt: "biome format . --write",
|
|
20
|
+
"fmt:check": "biome format ."
|
|
21
|
+
},
|
|
22
|
+
devDependencies: {
|
|
23
|
+
"@biomejs/biome": "~1.9.4",
|
|
24
|
+
turbo: "~2.3.0",
|
|
25
|
+
typescript: "~5.8.2",
|
|
26
|
+
vitest: "~4.0.0"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const apiPathParts = options.apiPath.split("/");
|
|
30
|
+
const appsFolder = apiPathParts[0] || "apps";
|
|
31
|
+
const pnpmWorkspace = `packages:
|
|
32
|
+
- '${appsFolder}/*'
|
|
33
|
+
- 'packages/*'
|
|
34
|
+
`;
|
|
35
|
+
const biomeConfig = {
|
|
36
|
+
$schema: "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
37
|
+
vcs: {
|
|
38
|
+
enabled: true,
|
|
39
|
+
clientKind: "git",
|
|
40
|
+
useIgnoreFile: true
|
|
41
|
+
},
|
|
42
|
+
organizeImports: { enabled: true },
|
|
43
|
+
formatter: {
|
|
44
|
+
enabled: true,
|
|
45
|
+
indentStyle: "space",
|
|
46
|
+
indentWidth: 2,
|
|
47
|
+
lineWidth: 80
|
|
48
|
+
},
|
|
49
|
+
javascript: { formatter: {
|
|
50
|
+
quoteStyle: "single",
|
|
51
|
+
trailingCommas: "all",
|
|
52
|
+
semicolons: "always",
|
|
53
|
+
arrowParentheses: "always"
|
|
54
|
+
} },
|
|
55
|
+
linter: {
|
|
56
|
+
enabled: true,
|
|
57
|
+
rules: {
|
|
58
|
+
recommended: true,
|
|
59
|
+
correctness: {
|
|
60
|
+
noUnusedImports: "error",
|
|
61
|
+
noUnusedVariables: "error"
|
|
62
|
+
},
|
|
63
|
+
style: { noNonNullAssertion: "off" }
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
files: { ignore: [
|
|
67
|
+
"node_modules",
|
|
68
|
+
"dist",
|
|
69
|
+
".gkm",
|
|
70
|
+
"coverage"
|
|
71
|
+
] }
|
|
72
|
+
};
|
|
73
|
+
const turboConfig = {
|
|
74
|
+
$schema: "https://turbo.build/schema.json",
|
|
75
|
+
tasks: {
|
|
76
|
+
build: {
|
|
77
|
+
dependsOn: ["^build"],
|
|
78
|
+
outputs: ["dist/**"]
|
|
79
|
+
},
|
|
80
|
+
dev: {
|
|
81
|
+
cache: false,
|
|
82
|
+
persistent: true
|
|
83
|
+
},
|
|
84
|
+
test: {
|
|
85
|
+
dependsOn: ["^build"],
|
|
86
|
+
cache: false
|
|
87
|
+
},
|
|
88
|
+
"test:once": {
|
|
89
|
+
dependsOn: ["^build"],
|
|
90
|
+
outputs: ["coverage/**"]
|
|
91
|
+
},
|
|
92
|
+
typecheck: {
|
|
93
|
+
dependsOn: ["^build"],
|
|
94
|
+
outputs: []
|
|
95
|
+
},
|
|
96
|
+
lint: { outputs: [] },
|
|
97
|
+
fmt: { outputs: [] }
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const gitignore = `# Dependencies
|
|
101
|
+
node_modules/
|
|
102
|
+
|
|
103
|
+
# Build output
|
|
104
|
+
dist/
|
|
105
|
+
.gkm/
|
|
106
|
+
|
|
107
|
+
# Environment
|
|
108
|
+
.env
|
|
109
|
+
.env.local
|
|
110
|
+
.env.*.local
|
|
111
|
+
|
|
112
|
+
# IDE
|
|
113
|
+
.idea/
|
|
114
|
+
.vscode/
|
|
115
|
+
*.swp
|
|
116
|
+
*.swo
|
|
117
|
+
|
|
118
|
+
# OS
|
|
119
|
+
.DS_Store
|
|
120
|
+
Thumbs.db
|
|
121
|
+
|
|
122
|
+
# Logs
|
|
123
|
+
*.log
|
|
124
|
+
npm-debug.log*
|
|
125
|
+
yarn-debug.log*
|
|
126
|
+
pnpm-debug.log*
|
|
127
|
+
|
|
128
|
+
# Test coverage
|
|
129
|
+
coverage/
|
|
130
|
+
|
|
131
|
+
# TypeScript cache
|
|
132
|
+
*.tsbuildinfo
|
|
133
|
+
|
|
134
|
+
# Turbo
|
|
135
|
+
.turbo/
|
|
136
|
+
`;
|
|
137
|
+
const tsConfig = {
|
|
138
|
+
compilerOptions: {
|
|
139
|
+
target: "ES2022",
|
|
140
|
+
module: "NodeNext",
|
|
141
|
+
moduleResolution: "NodeNext",
|
|
142
|
+
lib: ["ES2022"],
|
|
143
|
+
strict: true,
|
|
144
|
+
esModuleInterop: true,
|
|
145
|
+
skipLibCheck: true,
|
|
146
|
+
forceConsistentCasingInFileNames: true,
|
|
147
|
+
resolveJsonModule: true,
|
|
148
|
+
declaration: true,
|
|
149
|
+
declarationMap: true,
|
|
150
|
+
composite: true
|
|
151
|
+
},
|
|
152
|
+
exclude: ["node_modules", "dist"]
|
|
153
|
+
};
|
|
154
|
+
return [
|
|
155
|
+
{
|
|
156
|
+
path: "package.json",
|
|
157
|
+
content: JSON.stringify(rootPackageJson, null, 2) + "\n"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
path: "pnpm-workspace.yaml",
|
|
161
|
+
content: pnpmWorkspace
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
path: "tsconfig.json",
|
|
165
|
+
content: JSON.stringify(tsConfig, null, 2) + "\n"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
path: "biome.json",
|
|
169
|
+
content: JSON.stringify(biomeConfig, null, 2) + "\n"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
path: "turbo.json",
|
|
173
|
+
content: JSON.stringify(turboConfig, null, 2) + "\n"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
path: ".gitignore",
|
|
177
|
+
content: gitignore
|
|
178
|
+
}
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
//#endregion
|
|
183
|
+
export { generateMonorepoFiles };
|
|
184
|
+
//# sourceMappingURL=monorepo-Cknwzj5C.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monorepo-Cknwzj5C.mjs","names":["options: TemplateOptions","_template: TemplateConfig"],"sources":["../src/init/generators/monorepo.ts"],"sourcesContent":["import type {\n GeneratedFile,\n TemplateConfig,\n TemplateOptions,\n} from '../templates/index.js';\n\n/**\n * Generate monorepo root files (pnpm-workspace.yaml, root package.json, etc.)\n */\nexport function generateMonorepoFiles(\n options: TemplateOptions,\n _template: TemplateConfig,\n): GeneratedFile[] {\n if (!options.monorepo) {\n return [];\n }\n\n // Root package.json for monorepo\n const rootPackageJson = {\n name: options.name,\n version: '0.0.1',\n private: true,\n type: 'module',\n scripts: {\n dev: 'turbo dev',\n build: 'turbo build',\n test: 'turbo test',\n 'test:once': 'turbo test:once',\n typecheck: 'turbo typecheck',\n lint: 'biome lint .',\n fmt: 'biome format . --write',\n 'fmt:check': 'biome format .',\n },\n devDependencies: {\n '@biomejs/biome': '~1.9.4',\n turbo: '~2.3.0',\n typescript: '~5.8.2',\n vitest: '~4.0.0',\n },\n };\n\n // pnpm-workspace.yaml - detect folder structure from apiPath\n const apiPathParts = options.apiPath.split('/');\n const appsFolder = apiPathParts[0] || 'apps';\n\n const pnpmWorkspace = `packages:\n - '${appsFolder}/*'\n - 'packages/*'\n`;\n\n // Root biome.json\n const biomeConfig = {\n $schema: 'https://biomejs.dev/schemas/1.9.4/schema.json',\n vcs: {\n enabled: true,\n clientKind: 'git',\n useIgnoreFile: true,\n },\n organizeImports: {\n enabled: true,\n },\n formatter: {\n enabled: true,\n indentStyle: 'space',\n indentWidth: 2,\n lineWidth: 80,\n },\n javascript: {\n formatter: {\n quoteStyle: 'single',\n trailingCommas: 'all',\n semicolons: 'always',\n arrowParentheses: 'always',\n },\n },\n linter: {\n enabled: true,\n rules: {\n recommended: true,\n correctness: {\n noUnusedImports: 'error',\n noUnusedVariables: 'error',\n },\n style: {\n noNonNullAssertion: 'off',\n },\n },\n },\n files: {\n ignore: ['node_modules', 'dist', '.gkm', 'coverage'],\n },\n };\n\n // Root turbo.json\n const turboConfig = {\n $schema: 'https://turbo.build/schema.json',\n tasks: {\n build: {\n dependsOn: ['^build'],\n outputs: ['dist/**'],\n },\n dev: {\n cache: false,\n persistent: true,\n },\n test: {\n dependsOn: ['^build'],\n cache: false,\n },\n 'test:once': {\n dependsOn: ['^build'],\n outputs: ['coverage/**'],\n },\n typecheck: {\n dependsOn: ['^build'],\n outputs: [],\n },\n lint: {\n outputs: [],\n },\n fmt: {\n outputs: [],\n },\n },\n };\n\n // Root .gitignore\n const gitignore = `# Dependencies\nnode_modules/\n\n# Build output\ndist/\n.gkm/\n\n# Environment\n.env\n.env.local\n.env.*.local\n\n# IDE\n.idea/\n.vscode/\n*.swp\n*.swo\n\n# OS\n.DS_Store\nThumbs.db\n\n# Logs\n*.log\nnpm-debug.log*\nyarn-debug.log*\npnpm-debug.log*\n\n# Test coverage\ncoverage/\n\n# TypeScript cache\n*.tsbuildinfo\n\n# Turbo\n.turbo/\n`;\n\n // Root tsconfig.json - base config for all packages\n const tsConfig = {\n compilerOptions: {\n target: 'ES2022',\n module: 'NodeNext',\n moduleResolution: 'NodeNext',\n lib: ['ES2022'],\n strict: true,\n esModuleInterop: true,\n skipLibCheck: true,\n forceConsistentCasingInFileNames: true,\n resolveJsonModule: true,\n declaration: true,\n declarationMap: true,\n composite: true,\n },\n exclude: ['node_modules', 'dist'],\n };\n\n return [\n {\n path: 'package.json',\n content: JSON.stringify(rootPackageJson, null, 2) + '\\n',\n },\n {\n path: 'pnpm-workspace.yaml',\n content: pnpmWorkspace,\n },\n {\n path: 'tsconfig.json',\n content: JSON.stringify(tsConfig, null, 2) + '\\n',\n },\n {\n path: 'biome.json',\n content: JSON.stringify(biomeConfig, null, 2) + '\\n',\n },\n {\n path: 'turbo.json',\n content: JSON.stringify(turboConfig, null, 2) + '\\n',\n },\n {\n path: '.gitignore',\n content: gitignore,\n },\n ];\n}\n"],"mappings":";;;;AASA,SAAgB,sBACdA,SACAC,WACiB;AACjB,MAAK,QAAQ,SACX,QAAO,CAAE;CAIX,MAAM,kBAAkB;EACtB,MAAM,QAAQ;EACd,SAAS;EACT,SAAS;EACT,MAAM;EACN,SAAS;GACP,KAAK;GACL,OAAO;GACP,MAAM;GACN,aAAa;GACb,WAAW;GACX,MAAM;GACN,KAAK;GACL,aAAa;EACd;EACD,iBAAiB;GACf,kBAAkB;GAClB,OAAO;GACP,YAAY;GACZ,QAAQ;EACT;CACF;CAGD,MAAM,eAAe,QAAQ,QAAQ,MAAM,IAAI;CAC/C,MAAM,aAAa,aAAa,MAAM;CAEtC,MAAM,iBAAiB;OAClB,WAAW;;;CAKhB,MAAM,cAAc;EAClB,SAAS;EACT,KAAK;GACH,SAAS;GACT,YAAY;GACZ,eAAe;EAChB;EACD,iBAAiB,EACf,SAAS,KACV;EACD,WAAW;GACT,SAAS;GACT,aAAa;GACb,aAAa;GACb,WAAW;EACZ;EACD,YAAY,EACV,WAAW;GACT,YAAY;GACZ,gBAAgB;GAChB,YAAY;GACZ,kBAAkB;EACnB,EACF;EACD,QAAQ;GACN,SAAS;GACT,OAAO;IACL,aAAa;IACb,aAAa;KACX,iBAAiB;KACjB,mBAAmB;IACpB;IACD,OAAO,EACL,oBAAoB,MACrB;GACF;EACF;EACD,OAAO,EACL,QAAQ;GAAC;GAAgB;GAAQ;GAAQ;EAAW,EACrD;CACF;CAGD,MAAM,cAAc;EAClB,SAAS;EACT,OAAO;GACL,OAAO;IACL,WAAW,CAAC,QAAS;IACrB,SAAS,CAAC,SAAU;GACrB;GACD,KAAK;IACH,OAAO;IACP,YAAY;GACb;GACD,MAAM;IACJ,WAAW,CAAC,QAAS;IACrB,OAAO;GACR;GACD,aAAa;IACX,WAAW,CAAC,QAAS;IACrB,SAAS,CAAC,aAAc;GACzB;GACD,WAAW;IACT,WAAW,CAAC,QAAS;IACrB,SAAS,CAAE;GACZ;GACD,MAAM,EACJ,SAAS,CAAE,EACZ;GACD,KAAK,EACH,SAAS,CAAE,EACZ;EACF;CACF;CAGD,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCnB,MAAM,WAAW;EACf,iBAAiB;GACf,QAAQ;GACR,QAAQ;GACR,kBAAkB;GAClB,KAAK,CAAC,QAAS;GACf,QAAQ;GACR,iBAAiB;GACjB,cAAc;GACd,kCAAkC;GAClC,mBAAmB;GACnB,aAAa;GACb,gBAAgB;GAChB,WAAW;EACZ;EACD,SAAS,CAAC,gBAAgB,MAAO;CAClC;AAED,QAAO;EACL;GACE,MAAM;GACN,SAAS,KAAK,UAAU,iBAAiB,MAAM,EAAE,GAAG;EACrD;EACD;GACE,MAAM;GACN,SAAS;EACV;EACD;GACE,MAAM;GACN,SAAS,KAAK,UAAU,UAAU,MAAM,EAAE,GAAG;EAC9C;EACD;GACE,MAAM;GACN,SAAS,KAAK,UAAU,aAAa,MAAM,EAAE,GAAG;EACjD;EACD;GACE,MAAM;GACN,SAAS,KAAK,UAAU,aAAa,MAAM,EAAE,GAAG;EACjD;EACD;GACE,MAAM;GACN,SAAS;EACV;CACF;AACF"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/init/generators/monorepo.ts
|
|
3
|
+
/**
|
|
4
|
+
* Generate monorepo root files (pnpm-workspace.yaml, root package.json, etc.)
|
|
5
|
+
*/
|
|
6
|
+
function generateMonorepoFiles(options, _template) {
|
|
7
|
+
if (!options.monorepo) return [];
|
|
8
|
+
const rootPackageJson = {
|
|
9
|
+
name: options.name,
|
|
10
|
+
version: "0.0.1",
|
|
11
|
+
private: true,
|
|
12
|
+
type: "module",
|
|
13
|
+
scripts: {
|
|
14
|
+
dev: "turbo dev",
|
|
15
|
+
build: "turbo build",
|
|
16
|
+
test: "turbo test",
|
|
17
|
+
"test:once": "turbo test:once",
|
|
18
|
+
typecheck: "turbo typecheck",
|
|
19
|
+
lint: "biome lint .",
|
|
20
|
+
fmt: "biome format . --write",
|
|
21
|
+
"fmt:check": "biome format ."
|
|
22
|
+
},
|
|
23
|
+
devDependencies: {
|
|
24
|
+
"@biomejs/biome": "~1.9.4",
|
|
25
|
+
turbo: "~2.3.0",
|
|
26
|
+
typescript: "~5.8.2",
|
|
27
|
+
vitest: "~4.0.0"
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const apiPathParts = options.apiPath.split("/");
|
|
31
|
+
const appsFolder = apiPathParts[0] || "apps";
|
|
32
|
+
const pnpmWorkspace = `packages:
|
|
33
|
+
- '${appsFolder}/*'
|
|
34
|
+
- 'packages/*'
|
|
35
|
+
`;
|
|
36
|
+
const biomeConfig = {
|
|
37
|
+
$schema: "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
38
|
+
vcs: {
|
|
39
|
+
enabled: true,
|
|
40
|
+
clientKind: "git",
|
|
41
|
+
useIgnoreFile: true
|
|
42
|
+
},
|
|
43
|
+
organizeImports: { enabled: true },
|
|
44
|
+
formatter: {
|
|
45
|
+
enabled: true,
|
|
46
|
+
indentStyle: "space",
|
|
47
|
+
indentWidth: 2,
|
|
48
|
+
lineWidth: 80
|
|
49
|
+
},
|
|
50
|
+
javascript: { formatter: {
|
|
51
|
+
quoteStyle: "single",
|
|
52
|
+
trailingCommas: "all",
|
|
53
|
+
semicolons: "always",
|
|
54
|
+
arrowParentheses: "always"
|
|
55
|
+
} },
|
|
56
|
+
linter: {
|
|
57
|
+
enabled: true,
|
|
58
|
+
rules: {
|
|
59
|
+
recommended: true,
|
|
60
|
+
correctness: {
|
|
61
|
+
noUnusedImports: "error",
|
|
62
|
+
noUnusedVariables: "error"
|
|
63
|
+
},
|
|
64
|
+
style: { noNonNullAssertion: "off" }
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
files: { ignore: [
|
|
68
|
+
"node_modules",
|
|
69
|
+
"dist",
|
|
70
|
+
".gkm",
|
|
71
|
+
"coverage"
|
|
72
|
+
] }
|
|
73
|
+
};
|
|
74
|
+
const turboConfig = {
|
|
75
|
+
$schema: "https://turbo.build/schema.json",
|
|
76
|
+
tasks: {
|
|
77
|
+
build: {
|
|
78
|
+
dependsOn: ["^build"],
|
|
79
|
+
outputs: ["dist/**"]
|
|
80
|
+
},
|
|
81
|
+
dev: {
|
|
82
|
+
cache: false,
|
|
83
|
+
persistent: true
|
|
84
|
+
},
|
|
85
|
+
test: {
|
|
86
|
+
dependsOn: ["^build"],
|
|
87
|
+
cache: false
|
|
88
|
+
},
|
|
89
|
+
"test:once": {
|
|
90
|
+
dependsOn: ["^build"],
|
|
91
|
+
outputs: ["coverage/**"]
|
|
92
|
+
},
|
|
93
|
+
typecheck: {
|
|
94
|
+
dependsOn: ["^build"],
|
|
95
|
+
outputs: []
|
|
96
|
+
},
|
|
97
|
+
lint: { outputs: [] },
|
|
98
|
+
fmt: { outputs: [] }
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const gitignore = `# Dependencies
|
|
102
|
+
node_modules/
|
|
103
|
+
|
|
104
|
+
# Build output
|
|
105
|
+
dist/
|
|
106
|
+
.gkm/
|
|
107
|
+
|
|
108
|
+
# Environment
|
|
109
|
+
.env
|
|
110
|
+
.env.local
|
|
111
|
+
.env.*.local
|
|
112
|
+
|
|
113
|
+
# IDE
|
|
114
|
+
.idea/
|
|
115
|
+
.vscode/
|
|
116
|
+
*.swp
|
|
117
|
+
*.swo
|
|
118
|
+
|
|
119
|
+
# OS
|
|
120
|
+
.DS_Store
|
|
121
|
+
Thumbs.db
|
|
122
|
+
|
|
123
|
+
# Logs
|
|
124
|
+
*.log
|
|
125
|
+
npm-debug.log*
|
|
126
|
+
yarn-debug.log*
|
|
127
|
+
pnpm-debug.log*
|
|
128
|
+
|
|
129
|
+
# Test coverage
|
|
130
|
+
coverage/
|
|
131
|
+
|
|
132
|
+
# TypeScript cache
|
|
133
|
+
*.tsbuildinfo
|
|
134
|
+
|
|
135
|
+
# Turbo
|
|
136
|
+
.turbo/
|
|
137
|
+
`;
|
|
138
|
+
const tsConfig = {
|
|
139
|
+
compilerOptions: {
|
|
140
|
+
target: "ES2022",
|
|
141
|
+
module: "NodeNext",
|
|
142
|
+
moduleResolution: "NodeNext",
|
|
143
|
+
lib: ["ES2022"],
|
|
144
|
+
strict: true,
|
|
145
|
+
esModuleInterop: true,
|
|
146
|
+
skipLibCheck: true,
|
|
147
|
+
forceConsistentCasingInFileNames: true,
|
|
148
|
+
resolveJsonModule: true,
|
|
149
|
+
declaration: true,
|
|
150
|
+
declarationMap: true,
|
|
151
|
+
composite: true
|
|
152
|
+
},
|
|
153
|
+
exclude: ["node_modules", "dist"]
|
|
154
|
+
};
|
|
155
|
+
return [
|
|
156
|
+
{
|
|
157
|
+
path: "package.json",
|
|
158
|
+
content: JSON.stringify(rootPackageJson, null, 2) + "\n"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
path: "pnpm-workspace.yaml",
|
|
162
|
+
content: pnpmWorkspace
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
path: "tsconfig.json",
|
|
166
|
+
content: JSON.stringify(tsConfig, null, 2) + "\n"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
path: "biome.json",
|
|
170
|
+
content: JSON.stringify(biomeConfig, null, 2) + "\n"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
path: "turbo.json",
|
|
174
|
+
content: JSON.stringify(turboConfig, null, 2) + "\n"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
path: ".gitignore",
|
|
178
|
+
content: gitignore
|
|
179
|
+
}
|
|
180
|
+
];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
//#endregion
|
|
184
|
+
Object.defineProperty(exports, 'generateMonorepoFiles', {
|
|
185
|
+
enumerable: true,
|
|
186
|
+
get: function () {
|
|
187
|
+
return generateMonorepoFiles;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
//# sourceMappingURL=monorepo-sEK8gW59.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monorepo-sEK8gW59.cjs","names":["options: TemplateOptions","_template: TemplateConfig"],"sources":["../src/init/generators/monorepo.ts"],"sourcesContent":["import type {\n GeneratedFile,\n TemplateConfig,\n TemplateOptions,\n} from '../templates/index.js';\n\n/**\n * Generate monorepo root files (pnpm-workspace.yaml, root package.json, etc.)\n */\nexport function generateMonorepoFiles(\n options: TemplateOptions,\n _template: TemplateConfig,\n): GeneratedFile[] {\n if (!options.monorepo) {\n return [];\n }\n\n // Root package.json for monorepo\n const rootPackageJson = {\n name: options.name,\n version: '0.0.1',\n private: true,\n type: 'module',\n scripts: {\n dev: 'turbo dev',\n build: 'turbo build',\n test: 'turbo test',\n 'test:once': 'turbo test:once',\n typecheck: 'turbo typecheck',\n lint: 'biome lint .',\n fmt: 'biome format . --write',\n 'fmt:check': 'biome format .',\n },\n devDependencies: {\n '@biomejs/biome': '~1.9.4',\n turbo: '~2.3.0',\n typescript: '~5.8.2',\n vitest: '~4.0.0',\n },\n };\n\n // pnpm-workspace.yaml - detect folder structure from apiPath\n const apiPathParts = options.apiPath.split('/');\n const appsFolder = apiPathParts[0] || 'apps';\n\n const pnpmWorkspace = `packages:\n - '${appsFolder}/*'\n - 'packages/*'\n`;\n\n // Root biome.json\n const biomeConfig = {\n $schema: 'https://biomejs.dev/schemas/1.9.4/schema.json',\n vcs: {\n enabled: true,\n clientKind: 'git',\n useIgnoreFile: true,\n },\n organizeImports: {\n enabled: true,\n },\n formatter: {\n enabled: true,\n indentStyle: 'space',\n indentWidth: 2,\n lineWidth: 80,\n },\n javascript: {\n formatter: {\n quoteStyle: 'single',\n trailingCommas: 'all',\n semicolons: 'always',\n arrowParentheses: 'always',\n },\n },\n linter: {\n enabled: true,\n rules: {\n recommended: true,\n correctness: {\n noUnusedImports: 'error',\n noUnusedVariables: 'error',\n },\n style: {\n noNonNullAssertion: 'off',\n },\n },\n },\n files: {\n ignore: ['node_modules', 'dist', '.gkm', 'coverage'],\n },\n };\n\n // Root turbo.json\n const turboConfig = {\n $schema: 'https://turbo.build/schema.json',\n tasks: {\n build: {\n dependsOn: ['^build'],\n outputs: ['dist/**'],\n },\n dev: {\n cache: false,\n persistent: true,\n },\n test: {\n dependsOn: ['^build'],\n cache: false,\n },\n 'test:once': {\n dependsOn: ['^build'],\n outputs: ['coverage/**'],\n },\n typecheck: {\n dependsOn: ['^build'],\n outputs: [],\n },\n lint: {\n outputs: [],\n },\n fmt: {\n outputs: [],\n },\n },\n };\n\n // Root .gitignore\n const gitignore = `# Dependencies\nnode_modules/\n\n# Build output\ndist/\n.gkm/\n\n# Environment\n.env\n.env.local\n.env.*.local\n\n# IDE\n.idea/\n.vscode/\n*.swp\n*.swo\n\n# OS\n.DS_Store\nThumbs.db\n\n# Logs\n*.log\nnpm-debug.log*\nyarn-debug.log*\npnpm-debug.log*\n\n# Test coverage\ncoverage/\n\n# TypeScript cache\n*.tsbuildinfo\n\n# Turbo\n.turbo/\n`;\n\n // Root tsconfig.json - base config for all packages\n const tsConfig = {\n compilerOptions: {\n target: 'ES2022',\n module: 'NodeNext',\n moduleResolution: 'NodeNext',\n lib: ['ES2022'],\n strict: true,\n esModuleInterop: true,\n skipLibCheck: true,\n forceConsistentCasingInFileNames: true,\n resolveJsonModule: true,\n declaration: true,\n declarationMap: true,\n composite: true,\n },\n exclude: ['node_modules', 'dist'],\n };\n\n return [\n {\n path: 'package.json',\n content: JSON.stringify(rootPackageJson, null, 2) + '\\n',\n },\n {\n path: 'pnpm-workspace.yaml',\n content: pnpmWorkspace,\n },\n {\n path: 'tsconfig.json',\n content: JSON.stringify(tsConfig, null, 2) + '\\n',\n },\n {\n path: 'biome.json',\n content: JSON.stringify(biomeConfig, null, 2) + '\\n',\n },\n {\n path: 'turbo.json',\n content: JSON.stringify(turboConfig, null, 2) + '\\n',\n },\n {\n path: '.gitignore',\n content: gitignore,\n },\n ];\n}\n"],"mappings":";;;;;AASA,SAAgB,sBACdA,SACAC,WACiB;AACjB,MAAK,QAAQ,SACX,QAAO,CAAE;CAIX,MAAM,kBAAkB;EACtB,MAAM,QAAQ;EACd,SAAS;EACT,SAAS;EACT,MAAM;EACN,SAAS;GACP,KAAK;GACL,OAAO;GACP,MAAM;GACN,aAAa;GACb,WAAW;GACX,MAAM;GACN,KAAK;GACL,aAAa;EACd;EACD,iBAAiB;GACf,kBAAkB;GAClB,OAAO;GACP,YAAY;GACZ,QAAQ;EACT;CACF;CAGD,MAAM,eAAe,QAAQ,QAAQ,MAAM,IAAI;CAC/C,MAAM,aAAa,aAAa,MAAM;CAEtC,MAAM,iBAAiB;OAClB,WAAW;;;CAKhB,MAAM,cAAc;EAClB,SAAS;EACT,KAAK;GACH,SAAS;GACT,YAAY;GACZ,eAAe;EAChB;EACD,iBAAiB,EACf,SAAS,KACV;EACD,WAAW;GACT,SAAS;GACT,aAAa;GACb,aAAa;GACb,WAAW;EACZ;EACD,YAAY,EACV,WAAW;GACT,YAAY;GACZ,gBAAgB;GAChB,YAAY;GACZ,kBAAkB;EACnB,EACF;EACD,QAAQ;GACN,SAAS;GACT,OAAO;IACL,aAAa;IACb,aAAa;KACX,iBAAiB;KACjB,mBAAmB;IACpB;IACD,OAAO,EACL,oBAAoB,MACrB;GACF;EACF;EACD,OAAO,EACL,QAAQ;GAAC;GAAgB;GAAQ;GAAQ;EAAW,EACrD;CACF;CAGD,MAAM,cAAc;EAClB,SAAS;EACT,OAAO;GACL,OAAO;IACL,WAAW,CAAC,QAAS;IACrB,SAAS,CAAC,SAAU;GACrB;GACD,KAAK;IACH,OAAO;IACP,YAAY;GACb;GACD,MAAM;IACJ,WAAW,CAAC,QAAS;IACrB,OAAO;GACR;GACD,aAAa;IACX,WAAW,CAAC,QAAS;IACrB,SAAS,CAAC,aAAc;GACzB;GACD,WAAW;IACT,WAAW,CAAC,QAAS;IACrB,SAAS,CAAE;GACZ;GACD,MAAM,EACJ,SAAS,CAAE,EACZ;GACD,KAAK,EACH,SAAS,CAAE,EACZ;EACF;CACF;CAGD,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCnB,MAAM,WAAW;EACf,iBAAiB;GACf,QAAQ;GACR,QAAQ;GACR,kBAAkB;GAClB,KAAK,CAAC,QAAS;GACf,QAAQ;GACR,iBAAiB;GACjB,cAAc;GACd,kCAAkC;GAClC,mBAAmB;GACnB,aAAa;GACb,gBAAgB;GAChB,WAAW;EACZ;EACD,SAAS,CAAC,gBAAgB,MAAO;CAClC;AAED,QAAO;EACL;GACE,MAAM;GACN,SAAS,KAAK,UAAU,iBAAiB,MAAM,EAAE,GAAG;EACrD;EACD;GACE,MAAM;GACN,SAAS;EACV;EACD;GACE,MAAM;GACN,SAAS,KAAK,UAAU,UAAU,MAAM,EAAE,GAAG;EAC9C;EACD;GACE,MAAM;GACN,SAAS,KAAK,UAAU,aAAa,MAAM,EAAE,GAAG;EACjD;EACD;GACE,MAAM;GACN,SAAS,KAAK,UAAU,aAAa,MAAM,EAAE,GAAG;EACjD;EACD;GACE,MAAM;GACN,SAAS;EACV;CACF;AACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_config = require('./config-CFls09Ey.cjs');
|
|
3
|
+
const require_EndpointGenerator = require('./EndpointGenerator-npWEDoK2.cjs');
|
|
4
|
+
const require_OpenApiTsGenerator = require('./OpenApiTsGenerator-Be-sKGTT.cjs');
|
|
5
|
+
const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
|
|
6
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
7
|
+
const __geekmidas_constructs_endpoints = require_chunk.__toESM(require("@geekmidas/constructs/endpoints"));
|
|
8
|
+
|
|
9
|
+
//#region src/openapi.ts
|
|
10
|
+
async function openapiCommand(options = {}) {
|
|
11
|
+
const logger = console;
|
|
12
|
+
try {
|
|
13
|
+
const config = await require_config.loadConfig(options.cwd);
|
|
14
|
+
const endpointGenerator = new require_EndpointGenerator.EndpointGenerator();
|
|
15
|
+
const loadedEndpoints = await endpointGenerator.load(config.routes);
|
|
16
|
+
if (loadedEndpoints.length === 0) {
|
|
17
|
+
logger.log("No valid endpoints found");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const endpoints = loadedEndpoints.map(({ construct }) => construct);
|
|
21
|
+
const isJson = options.json === true;
|
|
22
|
+
const defaultOutput = isJson ? "openapi.json" : "openapi.ts";
|
|
23
|
+
const outputPath = options.output || (0, node_path.join)(process.cwd(), defaultOutput);
|
|
24
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(outputPath), { recursive: true });
|
|
25
|
+
if (isJson) {
|
|
26
|
+
const spec = await __geekmidas_constructs_endpoints.Endpoint.buildOpenApiSchema(endpoints, {
|
|
27
|
+
title: "API Documentation",
|
|
28
|
+
version: "1.0.0",
|
|
29
|
+
description: "Auto-generated API documentation from endpoints"
|
|
30
|
+
});
|
|
31
|
+
await (0, node_fs_promises.writeFile)(outputPath, JSON.stringify(spec, null, 2));
|
|
32
|
+
logger.log(`OpenAPI JSON spec generated: ${outputPath}`);
|
|
33
|
+
} else {
|
|
34
|
+
const tsGenerator = new require_OpenApiTsGenerator.OpenApiTsGenerator();
|
|
35
|
+
const tsContent = await tsGenerator.generate(endpoints, {
|
|
36
|
+
title: "API Documentation",
|
|
37
|
+
version: "1.0.0",
|
|
38
|
+
description: "Auto-generated API documentation from endpoints"
|
|
39
|
+
});
|
|
40
|
+
await (0, node_fs_promises.writeFile)(outputPath, tsContent);
|
|
41
|
+
logger.log(`OpenAPI TypeScript module generated: ${outputPath}`);
|
|
42
|
+
}
|
|
43
|
+
logger.log(`Found ${endpoints.length} endpoints`);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw new Error(`OpenAPI generation failed: ${error.message}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
Object.defineProperty(exports, 'openapiCommand', {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () {
|
|
53
|
+
return openapiCommand;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=openapi-BQWPWyNB.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-BQWPWyNB.cjs","names":["options: OpenAPIOptions","EndpointGenerator","OpenApiTsGenerator"],"sources":["../src/openapi.ts"],"sourcesContent":["#!/usr/bin/env -S npx tsx\n\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { Endpoint } from '@geekmidas/constructs/endpoints';\nimport { loadConfig } from './config.js';\nimport { EndpointGenerator } from './generators/EndpointGenerator.js';\nimport { OpenApiTsGenerator } from './generators/OpenApiTsGenerator.js';\n\ninterface OpenAPIOptions {\n output?: string;\n json?: boolean;\n cwd?: string;\n}\n\nexport async function openapiCommand(\n options: OpenAPIOptions = {},\n): Promise<void> {\n const logger = console;\n\n try {\n // Load config using existing function\n const config = await loadConfig(options.cwd);\n const endpointGenerator = new EndpointGenerator();\n\n // Load all endpoints using the refactored function\n const loadedEndpoints = await endpointGenerator.load(config.routes);\n\n if (loadedEndpoints.length === 0) {\n logger.log('No valid endpoints found');\n return;\n }\n\n // Extract just the endpoint instances for OpenAPI generation\n const endpoints = loadedEndpoints.map(({ construct }) => construct);\n\n // Determine output format (TypeScript is default)\n const isJson = options.json === true;\n const defaultOutput = isJson ? 'openapi.json' : 'openapi.ts';\n const outputPath = options.output || join(process.cwd(), defaultOutput);\n\n // Ensure output directory exists\n await mkdir(dirname(outputPath), { recursive: true });\n\n if (isJson) {\n // Generate JSON OpenAPI spec (legacy)\n const spec = await Endpoint.buildOpenApiSchema(endpoints, {\n title: 'API Documentation',\n version: '1.0.0',\n description: 'Auto-generated API documentation from endpoints',\n });\n\n await writeFile(outputPath, JSON.stringify(spec, null, 2));\n logger.log(`OpenAPI JSON spec generated: ${outputPath}`);\n } else {\n // Generate TypeScript OpenAPI module (default)\n const tsGenerator = new OpenApiTsGenerator();\n const tsContent = await tsGenerator.generate(endpoints, {\n title: 'API Documentation',\n version: '1.0.0',\n description: 'Auto-generated API documentation from endpoints',\n });\n\n await writeFile(outputPath, tsContent);\n logger.log(`OpenAPI TypeScript module generated: ${outputPath}`);\n }\n\n logger.log(`Found ${endpoints.length} endpoints`);\n } catch (error) {\n throw new Error(`OpenAPI generation failed: ${(error as Error).message}`);\n }\n}\n"],"mappings":";;;;;;;;;AAeA,eAAsB,eACpBA,UAA0B,CAAE,GACb;CACf,MAAM,SAAS;AAEf,KAAI;EAEF,MAAM,SAAS,MAAM,0BAAW,QAAQ,IAAI;EAC5C,MAAM,oBAAoB,IAAIC;EAG9B,MAAM,kBAAkB,MAAM,kBAAkB,KAAK,OAAO,OAAO;AAEnE,MAAI,gBAAgB,WAAW,GAAG;AAChC,UAAO,IAAI,2BAA2B;AACtC;EACD;EAGD,MAAM,YAAY,gBAAgB,IAAI,CAAC,EAAE,WAAW,KAAK,UAAU;EAGnE,MAAM,SAAS,QAAQ,SAAS;EAChC,MAAM,gBAAgB,SAAS,iBAAiB;EAChD,MAAM,aAAa,QAAQ,UAAU,oBAAK,QAAQ,KAAK,EAAE,cAAc;AAGvE,QAAM,4BAAM,uBAAQ,WAAW,EAAE,EAAE,WAAW,KAAM,EAAC;AAErD,MAAI,QAAQ;GAEV,MAAM,OAAO,MAAM,0CAAS,mBAAmB,WAAW;IACxD,OAAO;IACP,SAAS;IACT,aAAa;GACd,EAAC;AAEF,SAAM,gCAAU,YAAY,KAAK,UAAU,MAAM,MAAM,EAAE,CAAC;AAC1D,UAAO,KAAK,+BAA+B,WAAW,EAAE;EACzD,OAAM;GAEL,MAAM,cAAc,IAAIC;GACxB,MAAM,YAAY,MAAM,YAAY,SAAS,WAAW;IACtD,OAAO;IACP,SAAS;IACT,aAAa;GACd,EAAC;AAEF,SAAM,gCAAU,YAAY,UAAU;AACtC,UAAO,KAAK,uCAAuC,WAAW,EAAE;EACjE;AAED,SAAO,KAAK,QAAQ,UAAU,OAAO,YAAY;CAClD,SAAQ,OAAO;AACd,QAAM,IAAI,OAAO,6BAA8B,MAAgB,QAAQ;CACxE;AACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { loadConfig } from "./config-Bq72aj8e.mjs";
|
|
2
|
+
import { EndpointGenerator } from "./EndpointGenerator-DGivkPLT.mjs";
|
|
3
|
+
import { OpenApiTsGenerator } from "./OpenApiTsGenerator-C4mHHaku.mjs";
|
|
4
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { Endpoint } from "@geekmidas/constructs/endpoints";
|
|
7
|
+
|
|
8
|
+
//#region src/openapi.ts
|
|
9
|
+
async function openapiCommand(options = {}) {
|
|
10
|
+
const logger = console;
|
|
11
|
+
try {
|
|
12
|
+
const config = await loadConfig(options.cwd);
|
|
13
|
+
const endpointGenerator = new EndpointGenerator();
|
|
14
|
+
const loadedEndpoints = await endpointGenerator.load(config.routes);
|
|
15
|
+
if (loadedEndpoints.length === 0) {
|
|
16
|
+
logger.log("No valid endpoints found");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const endpoints = loadedEndpoints.map(({ construct }) => construct);
|
|
20
|
+
const isJson = options.json === true;
|
|
21
|
+
const defaultOutput = isJson ? "openapi.json" : "openapi.ts";
|
|
22
|
+
const outputPath = options.output || join(process.cwd(), defaultOutput);
|
|
23
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
24
|
+
if (isJson) {
|
|
25
|
+
const spec = await Endpoint.buildOpenApiSchema(endpoints, {
|
|
26
|
+
title: "API Documentation",
|
|
27
|
+
version: "1.0.0",
|
|
28
|
+
description: "Auto-generated API documentation from endpoints"
|
|
29
|
+
});
|
|
30
|
+
await writeFile(outputPath, JSON.stringify(spec, null, 2));
|
|
31
|
+
logger.log(`OpenAPI JSON spec generated: ${outputPath}`);
|
|
32
|
+
} else {
|
|
33
|
+
const tsGenerator = new OpenApiTsGenerator();
|
|
34
|
+
const tsContent = await tsGenerator.generate(endpoints, {
|
|
35
|
+
title: "API Documentation",
|
|
36
|
+
version: "1.0.0",
|
|
37
|
+
description: "Auto-generated API documentation from endpoints"
|
|
38
|
+
});
|
|
39
|
+
await writeFile(outputPath, tsContent);
|
|
40
|
+
logger.log(`OpenAPI TypeScript module generated: ${outputPath}`);
|
|
41
|
+
}
|
|
42
|
+
logger.log(`Found ${endpoints.length} endpoints`);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw new Error(`OpenAPI generation failed: ${error.message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { openapiCommand };
|
|
50
|
+
//# sourceMappingURL=openapi-DBX8cJJ8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-DBX8cJJ8.mjs","names":["options: OpenAPIOptions"],"sources":["../src/openapi.ts"],"sourcesContent":["#!/usr/bin/env -S npx tsx\n\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { Endpoint } from '@geekmidas/constructs/endpoints';\nimport { loadConfig } from './config.js';\nimport { EndpointGenerator } from './generators/EndpointGenerator.js';\nimport { OpenApiTsGenerator } from './generators/OpenApiTsGenerator.js';\n\ninterface OpenAPIOptions {\n output?: string;\n json?: boolean;\n cwd?: string;\n}\n\nexport async function openapiCommand(\n options: OpenAPIOptions = {},\n): Promise<void> {\n const logger = console;\n\n try {\n // Load config using existing function\n const config = await loadConfig(options.cwd);\n const endpointGenerator = new EndpointGenerator();\n\n // Load all endpoints using the refactored function\n const loadedEndpoints = await endpointGenerator.load(config.routes);\n\n if (loadedEndpoints.length === 0) {\n logger.log('No valid endpoints found');\n return;\n }\n\n // Extract just the endpoint instances for OpenAPI generation\n const endpoints = loadedEndpoints.map(({ construct }) => construct);\n\n // Determine output format (TypeScript is default)\n const isJson = options.json === true;\n const defaultOutput = isJson ? 'openapi.json' : 'openapi.ts';\n const outputPath = options.output || join(process.cwd(), defaultOutput);\n\n // Ensure output directory exists\n await mkdir(dirname(outputPath), { recursive: true });\n\n if (isJson) {\n // Generate JSON OpenAPI spec (legacy)\n const spec = await Endpoint.buildOpenApiSchema(endpoints, {\n title: 'API Documentation',\n version: '1.0.0',\n description: 'Auto-generated API documentation from endpoints',\n });\n\n await writeFile(outputPath, JSON.stringify(spec, null, 2));\n logger.log(`OpenAPI JSON spec generated: ${outputPath}`);\n } else {\n // Generate TypeScript OpenAPI module (default)\n const tsGenerator = new OpenApiTsGenerator();\n const tsContent = await tsGenerator.generate(endpoints, {\n title: 'API Documentation',\n version: '1.0.0',\n description: 'Auto-generated API documentation from endpoints',\n });\n\n await writeFile(outputPath, tsContent);\n logger.log(`OpenAPI TypeScript module generated: ${outputPath}`);\n }\n\n logger.log(`Found ${endpoints.length} endpoints`);\n } catch (error) {\n throw new Error(`OpenAPI generation failed: ${(error as Error).message}`);\n }\n}\n"],"mappings":";;;;;;;;AAeA,eAAsB,eACpBA,UAA0B,CAAE,GACb;CACf,MAAM,SAAS;AAEf,KAAI;EAEF,MAAM,SAAS,MAAM,WAAW,QAAQ,IAAI;EAC5C,MAAM,oBAAoB,IAAI;EAG9B,MAAM,kBAAkB,MAAM,kBAAkB,KAAK,OAAO,OAAO;AAEnE,MAAI,gBAAgB,WAAW,GAAG;AAChC,UAAO,IAAI,2BAA2B;AACtC;EACD;EAGD,MAAM,YAAY,gBAAgB,IAAI,CAAC,EAAE,WAAW,KAAK,UAAU;EAGnE,MAAM,SAAS,QAAQ,SAAS;EAChC,MAAM,gBAAgB,SAAS,iBAAiB;EAChD,MAAM,aAAa,QAAQ,UAAU,KAAK,QAAQ,KAAK,EAAE,cAAc;AAGvE,QAAM,MAAM,QAAQ,WAAW,EAAE,EAAE,WAAW,KAAM,EAAC;AAErD,MAAI,QAAQ;GAEV,MAAM,OAAO,MAAM,SAAS,mBAAmB,WAAW;IACxD,OAAO;IACP,SAAS;IACT,aAAa;GACd,EAAC;AAEF,SAAM,UAAU,YAAY,KAAK,UAAU,MAAM,MAAM,EAAE,CAAC;AAC1D,UAAO,KAAK,+BAA+B,WAAW,EAAE;EACzD,OAAM;GAEL,MAAM,cAAc,IAAI;GACxB,MAAM,YAAY,MAAM,YAAY,SAAS,WAAW;IACtD,OAAO;IACP,SAAS;IACT,aAAa;GACd,EAAC;AAEF,SAAM,UAAU,YAAY,UAAU;AACtC,UAAO,KAAK,uCAAuC,WAAW,EAAE;EACjE;AAED,SAAO,KAAK,QAAQ,UAAU,OAAO,YAAY;CAClD,SAAQ,OAAO;AACd,QAAM,IAAI,OAAO,6BAA8B,MAAgB,QAAQ;CACxE;AACF"}
|