@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,151 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_config = require('./config-CLEDqKO3.cjs');
|
|
3
|
+
const require_docker = require('./docker-5d8Yh5_X.cjs');
|
|
4
|
+
const require_env = require('./env-B-OKjgI4.cjs');
|
|
5
|
+
const require_models = require('./models-DyNwdOcz.cjs');
|
|
6
|
+
const require_monorepo = require('./monorepo-sEK8gW59.cjs');
|
|
7
|
+
const require_package = require('./package-PP-o1nvq.cjs');
|
|
8
|
+
const require_source = require('./source-DT5Xhiob.cjs');
|
|
9
|
+
const require_templates = require('./templates-DM_rtYYW.cjs');
|
|
10
|
+
const require_utils = require('./utils-BX3F4fT8.cjs');
|
|
11
|
+
const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
|
|
12
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
13
|
+
const node_child_process = require_chunk.__toESM(require("node:child_process"));
|
|
14
|
+
const prompts = require_chunk.__toESM(require("prompts"));
|
|
15
|
+
|
|
16
|
+
//#region src/init/index.ts
|
|
17
|
+
/**
|
|
18
|
+
* Main init command - scaffolds a new project
|
|
19
|
+
*/
|
|
20
|
+
async function initCommand(projectName, options = {}) {
|
|
21
|
+
const cwd = process.cwd();
|
|
22
|
+
const pkgManager = require_utils.detectPackageManager(cwd);
|
|
23
|
+
prompts.default.override({});
|
|
24
|
+
const onCancel = () => {
|
|
25
|
+
process.exit(0);
|
|
26
|
+
};
|
|
27
|
+
const answers = await (0, prompts.default)([
|
|
28
|
+
{
|
|
29
|
+
type: projectName ? null : "text",
|
|
30
|
+
name: "name",
|
|
31
|
+
message: "Project name:",
|
|
32
|
+
initial: "my-api",
|
|
33
|
+
validate: (value) => {
|
|
34
|
+
const nameValid = require_utils.validateProjectName(value);
|
|
35
|
+
if (nameValid !== true) return nameValid;
|
|
36
|
+
const dirValid = require_utils.checkDirectoryExists(value, cwd);
|
|
37
|
+
if (dirValid !== true) return dirValid;
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: options.template || options.yes ? null : "select",
|
|
43
|
+
name: "template",
|
|
44
|
+
message: "Template:",
|
|
45
|
+
choices: require_templates.templateChoices,
|
|
46
|
+
initial: 0
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: options.yes ? null : "confirm",
|
|
50
|
+
name: "telescope",
|
|
51
|
+
message: "Include Telescope (debugging dashboard)?",
|
|
52
|
+
initial: true
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: options.yes ? null : "confirm",
|
|
56
|
+
name: "database",
|
|
57
|
+
message: "Include database support (Kysely)?",
|
|
58
|
+
initial: true
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: options.yes ? null : "select",
|
|
62
|
+
name: "routeStyle",
|
|
63
|
+
message: "Route organization:",
|
|
64
|
+
choices: require_templates.routeStyleChoices,
|
|
65
|
+
initial: 0
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: options.yes || options.monorepo !== void 0 ? null : "confirm",
|
|
69
|
+
name: "monorepo",
|
|
70
|
+
message: "Setup as monorepo?",
|
|
71
|
+
initial: false
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: (prev) => (prev === true || options.monorepo) && !options.apiPath ? "text" : null,
|
|
75
|
+
name: "apiPath",
|
|
76
|
+
message: "API app path:",
|
|
77
|
+
initial: "apps/api"
|
|
78
|
+
}
|
|
79
|
+
], { onCancel });
|
|
80
|
+
const name = projectName || answers.name;
|
|
81
|
+
if (!name) {
|
|
82
|
+
console.error(" Error: Project name is required\n");
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
if (projectName) {
|
|
86
|
+
const nameValid = require_utils.validateProjectName(projectName);
|
|
87
|
+
if (nameValid !== true) {
|
|
88
|
+
console.error(` Error: ${nameValid}\n`);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
const dirValid = require_utils.checkDirectoryExists(projectName, cwd);
|
|
92
|
+
if (dirValid !== true) {
|
|
93
|
+
console.error(` Error: ${dirValid}\n`);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const monorepo = options.monorepo ?? (options.yes ? false : answers.monorepo ?? false);
|
|
98
|
+
const templateOptions = {
|
|
99
|
+
name,
|
|
100
|
+
template: options.template || answers.template || "minimal",
|
|
101
|
+
telescope: options.yes ? true : answers.telescope ?? true,
|
|
102
|
+
database: options.yes ? true : answers.database ?? true,
|
|
103
|
+
routeStyle: options.yes ? "file-based" : answers.routeStyle ?? "file-based",
|
|
104
|
+
monorepo,
|
|
105
|
+
apiPath: monorepo ? options.apiPath ?? answers.apiPath ?? "apps/api" : ""
|
|
106
|
+
};
|
|
107
|
+
const targetDir = (0, node_path.join)(cwd, name);
|
|
108
|
+
const template = require_templates.getTemplate(templateOptions.template);
|
|
109
|
+
const isMonorepo = templateOptions.monorepo;
|
|
110
|
+
const apiPath = templateOptions.apiPath;
|
|
111
|
+
await (0, node_fs_promises.mkdir)(targetDir, { recursive: true });
|
|
112
|
+
const appDir = isMonorepo ? (0, node_path.join)(targetDir, apiPath) : targetDir;
|
|
113
|
+
if (isMonorepo) await (0, node_fs_promises.mkdir)(appDir, { recursive: true });
|
|
114
|
+
const appFiles = [
|
|
115
|
+
...require_package.generatePackageJson(templateOptions, template),
|
|
116
|
+
...require_config.generateConfigFiles(templateOptions, template),
|
|
117
|
+
...require_env.generateEnvFiles(templateOptions, template),
|
|
118
|
+
...require_source.generateSourceFiles(templateOptions, template),
|
|
119
|
+
...require_docker.generateDockerFiles(templateOptions, template)
|
|
120
|
+
];
|
|
121
|
+
const rootFiles = [...require_monorepo.generateMonorepoFiles(templateOptions, template), ...require_models.generateModelsPackage(templateOptions)];
|
|
122
|
+
for (const { path, content } of rootFiles) {
|
|
123
|
+
const fullPath = (0, node_path.join)(targetDir, path);
|
|
124
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(fullPath), { recursive: true });
|
|
125
|
+
await (0, node_fs_promises.writeFile)(fullPath, content);
|
|
126
|
+
}
|
|
127
|
+
for (const { path, content } of appFiles) {
|
|
128
|
+
const fullPath = (0, node_path.join)(appDir, path);
|
|
129
|
+
const displayPath = isMonorepo ? `${apiPath}/${path}` : path;
|
|
130
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(fullPath), { recursive: true });
|
|
131
|
+
await (0, node_fs_promises.writeFile)(fullPath, content);
|
|
132
|
+
}
|
|
133
|
+
if (!options.skipInstall) try {
|
|
134
|
+
(0, node_child_process.execSync)(require_utils.getInstallCommand(pkgManager), {
|
|
135
|
+
cwd: targetDir,
|
|
136
|
+
stdio: "inherit"
|
|
137
|
+
});
|
|
138
|
+
} catch {
|
|
139
|
+
console.error("\n Warning: Failed to install dependencies.");
|
|
140
|
+
}
|
|
141
|
+
const devCommand = require_utils.getRunCommand(pkgManager, "dev");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//#endregion
|
|
145
|
+
Object.defineProperty(exports, 'initCommand', {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
get: function () {
|
|
148
|
+
return initCommand;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
//# sourceMappingURL=init-qLFsWR-R.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-qLFsWR-R.cjs","names":["projectName?: string","options: InitOptions","value: string","templateChoices","routeStyleChoices","templateOptions: TemplateOptions"],"sources":["../src/init/index.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport prompts from 'prompts';\nimport { generateConfigFiles } from './generators/config.js';\nimport { generateDockerFiles } from './generators/docker.js';\nimport { generateEnvFiles } from './generators/env.js';\nimport { generateModelsPackage } from './generators/models.js';\nimport { generateMonorepoFiles } from './generators/monorepo.js';\nimport { generatePackageJson } from './generators/package.js';\nimport { generateSourceFiles } from './generators/source.js';\nimport {\n type TemplateName,\n type TemplateOptions,\n getTemplate,\n routeStyleChoices,\n templateChoices,\n} from './templates/index.js';\nimport {\n checkDirectoryExists,\n detectPackageManager,\n getInstallCommand,\n getRunCommand,\n validateProjectName,\n} from './utils.js';\n\nexport interface InitOptions {\n template?: TemplateName;\n skipInstall?: boolean;\n yes?: boolean;\n monorepo?: boolean;\n apiPath?: string;\n}\n\n/**\n * Main init command - scaffolds a new project\n */\nexport async function initCommand(\n projectName?: string,\n options: InitOptions = {},\n): Promise<void> {\n const cwd = process.cwd();\n const pkgManager = detectPackageManager(cwd);\n\n // Handle Ctrl+C gracefully\n prompts.override({});\n const onCancel = () => {\n process.exit(0);\n };\n\n // Gather answers via prompts\n const answers = await prompts(\n [\n {\n type: projectName ? null : 'text',\n name: 'name',\n message: 'Project name:',\n initial: 'my-api',\n validate: (value: string) => {\n const nameValid = validateProjectName(value);\n if (nameValid !== true) return nameValid;\n const dirValid = checkDirectoryExists(value, cwd);\n if (dirValid !== true) return dirValid;\n return true;\n },\n },\n {\n type: options.template || options.yes ? null : 'select',\n name: 'template',\n message: 'Template:',\n choices: templateChoices,\n initial: 0,\n },\n {\n type: options.yes ? null : 'confirm',\n name: 'telescope',\n message: 'Include Telescope (debugging dashboard)?',\n initial: true,\n },\n {\n type: options.yes ? null : 'confirm',\n name: 'database',\n message: 'Include database support (Kysely)?',\n initial: true,\n },\n {\n type: options.yes ? null : 'select',\n name: 'routeStyle',\n message: 'Route organization:',\n choices: routeStyleChoices,\n initial: 0,\n },\n {\n type: options.yes || options.monorepo !== undefined ? null : 'confirm',\n name: 'monorepo',\n message: 'Setup as monorepo?',\n initial: false,\n },\n {\n type: (prev) =>\n (prev === true || options.monorepo) && !options.apiPath\n ? 'text'\n : null,\n name: 'apiPath',\n message: 'API app path:',\n initial: 'apps/api',\n },\n ],\n { onCancel },\n );\n\n // Build final options\n const name = projectName || answers.name;\n if (!name) {\n console.error(' Error: Project name is required\\n');\n process.exit(1);\n }\n\n // Validate name if provided via argument\n if (projectName) {\n const nameValid = validateProjectName(projectName);\n if (nameValid !== true) {\n console.error(` Error: ${nameValid}\\n`);\n process.exit(1);\n }\n const dirValid = checkDirectoryExists(projectName, cwd);\n if (dirValid !== true) {\n console.error(` Error: ${dirValid}\\n`);\n process.exit(1);\n }\n }\n\n const monorepo =\n options.monorepo ?? (options.yes ? false : (answers.monorepo ?? false));\n const templateOptions: TemplateOptions = {\n name,\n template: options.template || answers.template || 'minimal',\n telescope: options.yes ? true : (answers.telescope ?? true),\n database: options.yes ? true : (answers.database ?? true),\n routeStyle: options.yes\n ? 'file-based'\n : (answers.routeStyle ?? 'file-based'),\n monorepo,\n apiPath: monorepo ? (options.apiPath ?? answers.apiPath ?? 'apps/api') : '',\n };\n\n const targetDir = join(cwd, name);\n const template = getTemplate(templateOptions.template);\n\n const isMonorepo = templateOptions.monorepo;\n const apiPath = templateOptions.apiPath;\n\n // Create project directory\n await mkdir(targetDir, { recursive: true });\n\n // For monorepo, app files go in the specified apiPath (e.g., apps/api)\n const appDir = isMonorepo ? join(targetDir, apiPath) : targetDir;\n if (isMonorepo) {\n await mkdir(appDir, { recursive: true });\n }\n\n // Collect app files\n const appFiles = [\n ...generatePackageJson(templateOptions, template),\n ...generateConfigFiles(templateOptions, template),\n ...generateEnvFiles(templateOptions, template),\n ...generateSourceFiles(templateOptions, template),\n ...generateDockerFiles(templateOptions, template),\n ];\n\n // Collect root monorepo files (includes packages/models)\n const rootFiles = [\n ...generateMonorepoFiles(templateOptions, template),\n ...generateModelsPackage(templateOptions),\n ];\n\n // Write root files (for monorepo)\n for (const { path, content } of rootFiles) {\n const fullPath = join(targetDir, path);\n await mkdir(dirname(fullPath), { recursive: true });\n await writeFile(fullPath, content);\n }\n\n // Write app files\n for (const { path, content } of appFiles) {\n const fullPath = join(appDir, path);\n const displayPath = isMonorepo ? `${apiPath}/${path}` : path;\n await mkdir(dirname(fullPath), { recursive: true });\n await writeFile(fullPath, content);\n }\n\n // Install dependencies\n if (!options.skipInstall) {\n try {\n execSync(getInstallCommand(pkgManager), {\n cwd: targetDir,\n stdio: 'inherit',\n });\n } catch {\n console.error('\\n Warning: Failed to install dependencies.');\n }\n }\n\n // Print next steps\n const devCommand = getRunCommand(pkgManager, 'dev');\n}\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifests-
|
|
1
|
+
{"version":3,"file":"manifests-DIA_2QYd.mjs","names":["outputDir: string","routes: RouteInfo[]","functions: FunctionInfo[]","crons: CronInfo[]","subscribers: SubscriberInfo[]","appInfo: ServerAppInfo"],"sources":["../src/build/manifests.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { join, relative } from 'path';\nimport type {\n CronInfo,\n FunctionInfo,\n RouteInfo,\n SubscriberInfo,\n} from '../types';\n\nconst logger = console;\n\nexport type ManifestProvider = 'aws' | 'server';\n\nexport interface ServerAppInfo {\n handler: string;\n endpoints: string;\n}\n\nexport async function generateAwsManifest(\n outputDir: string,\n routes: RouteInfo[],\n functions: FunctionInfo[],\n crons: CronInfo[],\n subscribers: SubscriberInfo[],\n): Promise<void> {\n const manifestDir = join(outputDir, 'manifest');\n await mkdir(manifestDir, { recursive: true });\n\n // Filter out 'ALL' method routes (server-specific)\n const awsRoutes = routes.filter((r) => r.method !== 'ALL');\n\n const content = `export const manifest = {\n routes: ${JSON.stringify(awsRoutes, null, 2)},\n functions: ${JSON.stringify(functions, null, 2)},\n crons: ${JSON.stringify(crons, null, 2)},\n subscribers: ${JSON.stringify(subscribers, null, 2)},\n} as const;\n\n// Derived types\nexport type Route = (typeof manifest.routes)[number];\nexport type Function = (typeof manifest.functions)[number];\nexport type Cron = (typeof manifest.crons)[number];\nexport type Subscriber = (typeof manifest.subscribers)[number];\n\n// Useful union types\nexport type Authorizer = Route['authorizer'];\nexport type HttpMethod = Route['method'];\nexport type RoutePath = Route['path'];\n`;\n\n const manifestPath = join(manifestDir, 'aws.ts');\n await writeFile(manifestPath, content);\n\n logger.log(\n `Generated AWS manifest with ${awsRoutes.length} routes, ${functions.length} functions, ${crons.length} crons, ${subscribers.length} subscribers`,\n );\n logger.log(`Manifest: ${relative(process.cwd(), manifestPath)}`);\n}\n\nexport async function generateServerManifest(\n outputDir: string,\n appInfo: ServerAppInfo,\n routes: RouteInfo[],\n subscribers: SubscriberInfo[],\n): Promise<void> {\n const manifestDir = join(outputDir, 'manifest');\n await mkdir(manifestDir, { recursive: true });\n\n // For server, extract route metadata (path, method, authorizer)\n const serverRoutes = routes\n .filter((r) => r.method !== 'ALL')\n .map((r) => ({\n path: r.path,\n method: r.method,\n authorizer: r.authorizer,\n }));\n\n // Server subscribers only need name and events\n const serverSubscribers = subscribers.map((s) => ({\n name: s.name,\n subscribedEvents: s.subscribedEvents,\n }));\n\n const content = `export const manifest = {\n app: ${JSON.stringify(appInfo, null, 2)},\n routes: ${JSON.stringify(serverRoutes, null, 2)},\n subscribers: ${JSON.stringify(serverSubscribers, null, 2)},\n} as const;\n\n// Derived types\nexport type Route = (typeof manifest.routes)[number];\nexport type Subscriber = (typeof manifest.subscribers)[number];\n\n// Useful union types\nexport type Authorizer = Route['authorizer'];\nexport type HttpMethod = Route['method'];\nexport type RoutePath = Route['path'];\n`;\n\n const manifestPath = join(manifestDir, 'server.ts');\n await writeFile(manifestPath, content);\n\n logger.log(\n `Generated server manifest with ${serverRoutes.length} routes, ${serverSubscribers.length} subscribers`,\n );\n logger.log(`Manifest: ${relative(process.cwd(), manifestPath)}`);\n}\n"],"mappings":";;;;AASA,MAAM,SAAS;AASf,eAAsB,oBACpBA,WACAC,QACAC,WACAC,OACAC,aACe;CACf,MAAM,cAAc,KAAK,WAAW,WAAW;AAC/C,OAAM,MAAM,aAAa,EAAE,WAAW,KAAM,EAAC;CAG7C,MAAM,YAAY,OAAO,OAAO,CAAC,MAAM,EAAE,WAAW,MAAM;CAE1D,MAAM,WAAW;YACP,KAAK,UAAU,WAAW,MAAM,EAAE,CAAC;eAChC,KAAK,UAAU,WAAW,MAAM,EAAE,CAAC;WACvC,KAAK,UAAU,OAAO,MAAM,EAAE,CAAC;iBACzB,KAAK,UAAU,aAAa,MAAM,EAAE,CAAC;;;;;;;;;;;;;;CAepD,MAAM,eAAe,KAAK,aAAa,SAAS;AAChD,OAAM,UAAU,cAAc,QAAQ;AAEtC,QAAO,KACJ,8BAA8B,UAAU,OAAO,WAAW,UAAU,OAAO,cAAc,MAAM,OAAO,UAAU,YAAY,OAAO,cACrI;AACD,QAAO,KAAK,YAAY,SAAS,QAAQ,KAAK,EAAE,aAAa,CAAC,EAAE;AACjE;AAED,eAAsB,uBACpBJ,WACAK,SACAJ,QACAG,aACe;CACf,MAAM,cAAc,KAAK,WAAW,WAAW;AAC/C,OAAM,MAAM,aAAa,EAAE,WAAW,KAAM,EAAC;CAG7C,MAAM,eAAe,OAClB,OAAO,CAAC,MAAM,EAAE,WAAW,MAAM,CACjC,IAAI,CAAC,OAAO;EACX,MAAM,EAAE;EACR,QAAQ,EAAE;EACV,YAAY,EAAE;CACf,GAAE;CAGL,MAAM,oBAAoB,YAAY,IAAI,CAAC,OAAO;EAChD,MAAM,EAAE;EACR,kBAAkB,EAAE;CACrB,GAAE;CAEH,MAAM,WAAW;SACV,KAAK,UAAU,SAAS,MAAM,EAAE,CAAC;YAC9B,KAAK,UAAU,cAAc,MAAM,EAAE,CAAC;iBACjC,KAAK,UAAU,mBAAmB,MAAM,EAAE,CAAC;;;;;;;;;;;;CAa1D,MAAM,eAAe,KAAK,aAAa,YAAY;AACnD,OAAM,UAAU,cAAc,QAAQ;AAEtC,QAAO,KACJ,iCAAiC,aAAa,OAAO,WAAW,kBAAkB,OAAO,cAC3F;AACD,QAAO,KAAK,YAAY,SAAS,QAAQ,KAAK,EAAE,aAAa,CAAC,EAAE;AACjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifests-
|
|
1
|
+
{"version":3,"file":"manifests-VJ9-2JpW.cjs","names":["outputDir: string","routes: RouteInfo[]","functions: FunctionInfo[]","crons: CronInfo[]","subscribers: SubscriberInfo[]","appInfo: ServerAppInfo"],"sources":["../src/build/manifests.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { join, relative } from 'path';\nimport type {\n CronInfo,\n FunctionInfo,\n RouteInfo,\n SubscriberInfo,\n} from '../types';\n\nconst logger = console;\n\nexport type ManifestProvider = 'aws' | 'server';\n\nexport interface ServerAppInfo {\n handler: string;\n endpoints: string;\n}\n\nexport async function generateAwsManifest(\n outputDir: string,\n routes: RouteInfo[],\n functions: FunctionInfo[],\n crons: CronInfo[],\n subscribers: SubscriberInfo[],\n): Promise<void> {\n const manifestDir = join(outputDir, 'manifest');\n await mkdir(manifestDir, { recursive: true });\n\n // Filter out 'ALL' method routes (server-specific)\n const awsRoutes = routes.filter((r) => r.method !== 'ALL');\n\n const content = `export const manifest = {\n routes: ${JSON.stringify(awsRoutes, null, 2)},\n functions: ${JSON.stringify(functions, null, 2)},\n crons: ${JSON.stringify(crons, null, 2)},\n subscribers: ${JSON.stringify(subscribers, null, 2)},\n} as const;\n\n// Derived types\nexport type Route = (typeof manifest.routes)[number];\nexport type Function = (typeof manifest.functions)[number];\nexport type Cron = (typeof manifest.crons)[number];\nexport type Subscriber = (typeof manifest.subscribers)[number];\n\n// Useful union types\nexport type Authorizer = Route['authorizer'];\nexport type HttpMethod = Route['method'];\nexport type RoutePath = Route['path'];\n`;\n\n const manifestPath = join(manifestDir, 'aws.ts');\n await writeFile(manifestPath, content);\n\n logger.log(\n `Generated AWS manifest with ${awsRoutes.length} routes, ${functions.length} functions, ${crons.length} crons, ${subscribers.length} subscribers`,\n );\n logger.log(`Manifest: ${relative(process.cwd(), manifestPath)}`);\n}\n\nexport async function generateServerManifest(\n outputDir: string,\n appInfo: ServerAppInfo,\n routes: RouteInfo[],\n subscribers: SubscriberInfo[],\n): Promise<void> {\n const manifestDir = join(outputDir, 'manifest');\n await mkdir(manifestDir, { recursive: true });\n\n // For server, extract route metadata (path, method, authorizer)\n const serverRoutes = routes\n .filter((r) => r.method !== 'ALL')\n .map((r) => ({\n path: r.path,\n method: r.method,\n authorizer: r.authorizer,\n }));\n\n // Server subscribers only need name and events\n const serverSubscribers = subscribers.map((s) => ({\n name: s.name,\n subscribedEvents: s.subscribedEvents,\n }));\n\n const content = `export const manifest = {\n app: ${JSON.stringify(appInfo, null, 2)},\n routes: ${JSON.stringify(serverRoutes, null, 2)},\n subscribers: ${JSON.stringify(serverSubscribers, null, 2)},\n} as const;\n\n// Derived types\nexport type Route = (typeof manifest.routes)[number];\nexport type Subscriber = (typeof manifest.subscribers)[number];\n\n// Useful union types\nexport type Authorizer = Route['authorizer'];\nexport type HttpMethod = Route['method'];\nexport type RoutePath = Route['path'];\n`;\n\n const manifestPath = join(manifestDir, 'server.ts');\n await writeFile(manifestPath, content);\n\n logger.log(\n `Generated server manifest with ${serverRoutes.length} routes, ${serverSubscribers.length} subscribers`,\n );\n logger.log(`Manifest: ${relative(process.cwd(), manifestPath)}`);\n}\n"],"mappings":";;;;;AASA,MAAM,SAAS;AASf,eAAsB,oBACpBA,WACAC,QACAC,WACAC,OACAC,aACe;CACf,MAAM,cAAc,eAAK,WAAW,WAAW;AAC/C,OAAM,4BAAM,aAAa,EAAE,WAAW,KAAM,EAAC;CAG7C,MAAM,YAAY,OAAO,OAAO,CAAC,MAAM,EAAE,WAAW,MAAM;CAE1D,MAAM,WAAW;YACP,KAAK,UAAU,WAAW,MAAM,EAAE,CAAC;eAChC,KAAK,UAAU,WAAW,MAAM,EAAE,CAAC;WACvC,KAAK,UAAU,OAAO,MAAM,EAAE,CAAC;iBACzB,KAAK,UAAU,aAAa,MAAM,EAAE,CAAC;;;;;;;;;;;;;;CAepD,MAAM,eAAe,eAAK,aAAa,SAAS;AAChD,OAAM,gCAAU,cAAc,QAAQ;AAEtC,QAAO,KACJ,8BAA8B,UAAU,OAAO,WAAW,UAAU,OAAO,cAAc,MAAM,OAAO,UAAU,YAAY,OAAO,cACrI;AACD,QAAO,KAAK,YAAY,mBAAS,QAAQ,KAAK,EAAE,aAAa,CAAC,EAAE;AACjE;AAED,eAAsB,uBACpBJ,WACAK,SACAJ,QACAG,aACe;CACf,MAAM,cAAc,eAAK,WAAW,WAAW;AAC/C,OAAM,4BAAM,aAAa,EAAE,WAAW,KAAM,EAAC;CAG7C,MAAM,eAAe,OAClB,OAAO,CAAC,MAAM,EAAE,WAAW,MAAM,CACjC,IAAI,CAAC,OAAO;EACX,MAAM,EAAE;EACR,QAAQ,EAAE;EACV,YAAY,EAAE;CACf,GAAE;CAGL,MAAM,oBAAoB,YAAY,IAAI,CAAC,OAAO;EAChD,MAAM,EAAE;EACR,kBAAkB,EAAE;CACrB,GAAE;CAEH,MAAM,WAAW;SACV,KAAK,UAAU,SAAS,MAAM,EAAE,CAAC;YAC9B,KAAK,UAAU,cAAc,MAAM,EAAE,CAAC;iBACjC,KAAK,UAAU,mBAAmB,MAAM,EAAE,CAAC;;;;;;;;;;;;CAa1D,MAAM,eAAe,eAAK,aAAa,YAAY;AACnD,OAAM,gCAAU,cAAc,QAAQ;AAEtC,QAAO,KACJ,iCAAiC,aAAa,OAAO,WAAW,kBAAkB,OAAO,cAC3F;AACD,QAAO,KAAK,YAAY,mBAAS,QAAQ,KAAK,EAAE,aAAa,CAAC,EAAE;AACjE"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/init/templates/minimal.ts
|
|
3
|
+
const minimalTemplate = {
|
|
4
|
+
name: "minimal",
|
|
5
|
+
description: "Basic health endpoint",
|
|
6
|
+
dependencies: {
|
|
7
|
+
"@geekmidas/constructs": "workspace:*",
|
|
8
|
+
"@geekmidas/envkit": "workspace:*",
|
|
9
|
+
"@geekmidas/logger": "workspace:*",
|
|
10
|
+
hono: "~4.8.2",
|
|
11
|
+
pino: "~9.6.0"
|
|
12
|
+
},
|
|
13
|
+
devDependencies: {
|
|
14
|
+
"@biomejs/biome": "~1.9.4",
|
|
15
|
+
"@geekmidas/cli": "workspace:*",
|
|
16
|
+
"@types/node": "~22.0.0",
|
|
17
|
+
tsx: "~4.20.0",
|
|
18
|
+
turbo: "~2.3.0",
|
|
19
|
+
typescript: "~5.8.2",
|
|
20
|
+
vitest: "~4.0.0"
|
|
21
|
+
},
|
|
22
|
+
scripts: {
|
|
23
|
+
dev: "gkm dev",
|
|
24
|
+
build: "gkm build",
|
|
25
|
+
test: "vitest",
|
|
26
|
+
"test:once": "vitest run",
|
|
27
|
+
typecheck: "tsc --noEmit",
|
|
28
|
+
lint: "biome lint .",
|
|
29
|
+
fmt: "biome format . --write",
|
|
30
|
+
"fmt:check": "biome format ."
|
|
31
|
+
},
|
|
32
|
+
files: (options) => {
|
|
33
|
+
const files = [
|
|
34
|
+
{
|
|
35
|
+
path: "src/config/env.ts",
|
|
36
|
+
content: `import { EnvironmentParser } from '@geekmidas/envkit';
|
|
37
|
+
|
|
38
|
+
export const envParser = new EnvironmentParser(process.env);
|
|
39
|
+
|
|
40
|
+
export const config = envParser
|
|
41
|
+
.create((get) => ({
|
|
42
|
+
port: get('PORT').string().transform(Number).default(3000),
|
|
43
|
+
nodeEnv: get('NODE_ENV').string().default('development'),
|
|
44
|
+
}))
|
|
45
|
+
.parse();
|
|
46
|
+
`
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
path: "src/config/logger.ts",
|
|
50
|
+
content: `import { PinoLogger } from '@geekmidas/logger/pino';
|
|
51
|
+
|
|
52
|
+
export const logger = new PinoLogger({
|
|
53
|
+
app: '${options.name}',
|
|
54
|
+
level: process.env.LOG_LEVEL || 'info',
|
|
55
|
+
});
|
|
56
|
+
`
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
path: "src/endpoints/health.ts",
|
|
60
|
+
content: `import { e } from '@geekmidas/constructs/endpoints';
|
|
61
|
+
|
|
62
|
+
export default e
|
|
63
|
+
.get('/health')
|
|
64
|
+
.handle(async () => ({
|
|
65
|
+
status: 'ok',
|
|
66
|
+
timestamp: new Date().toISOString(),
|
|
67
|
+
}));
|
|
68
|
+
`
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
if (options.telescope) files.push({
|
|
72
|
+
path: "src/config/telescope.ts",
|
|
73
|
+
content: `import { Telescope } from '@geekmidas/telescope';
|
|
74
|
+
import { InMemoryStorage } from '@geekmidas/telescope/storage/memory';
|
|
75
|
+
|
|
76
|
+
export const telescope = new Telescope({
|
|
77
|
+
storage: new InMemoryStorage({ maxEntries: 100 }),
|
|
78
|
+
enabled: process.env.NODE_ENV === 'development',
|
|
79
|
+
});
|
|
80
|
+
`
|
|
81
|
+
});
|
|
82
|
+
return files;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
Object.defineProperty(exports, 'minimalTemplate', {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return minimalTemplate;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=minimal-Bdhhpp7v.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimal-Bdhhpp7v.cjs","names":["minimalTemplate: TemplateConfig","options: TemplateOptions","files: GeneratedFile[]"],"sources":["../src/init/templates/minimal.ts"],"sourcesContent":["import type {\n GeneratedFile,\n TemplateConfig,\n TemplateOptions,\n} from './index.js';\n\nexport const minimalTemplate: TemplateConfig = {\n name: 'minimal',\n description: 'Basic health endpoint',\n\n dependencies: {\n '@geekmidas/constructs': 'workspace:*',\n '@geekmidas/envkit': 'workspace:*',\n '@geekmidas/logger': 'workspace:*',\n hono: '~4.8.2',\n pino: '~9.6.0',\n },\n\n devDependencies: {\n '@biomejs/biome': '~1.9.4',\n '@geekmidas/cli': 'workspace:*',\n '@types/node': '~22.0.0',\n tsx: '~4.20.0',\n turbo: '~2.3.0',\n typescript: '~5.8.2',\n vitest: '~4.0.0',\n },\n\n scripts: {\n dev: 'gkm dev',\n build: 'gkm build',\n test: 'vitest',\n 'test:once': 'vitest run',\n typecheck: 'tsc --noEmit',\n lint: 'biome lint .',\n fmt: 'biome format . --write',\n 'fmt:check': 'biome format .',\n },\n\n files: (options: TemplateOptions): GeneratedFile[] => {\n const files: GeneratedFile[] = [\n // src/config/env.ts\n {\n path: 'src/config/env.ts',\n content: `import { EnvironmentParser } from '@geekmidas/envkit';\n\nexport const envParser = new EnvironmentParser(process.env);\n\nexport const config = envParser\n .create((get) => ({\n port: get('PORT').string().transform(Number).default(3000),\n nodeEnv: get('NODE_ENV').string().default('development'),\n }))\n .parse();\n`,\n },\n\n // src/config/logger.ts - using pino\n {\n path: 'src/config/logger.ts',\n content: `import { PinoLogger } from '@geekmidas/logger/pino';\n\nexport const logger = new PinoLogger({\n app: '${options.name}',\n level: process.env.LOG_LEVEL || 'info',\n});\n`,\n },\n\n // src/endpoints/health.ts\n {\n path: 'src/endpoints/health.ts',\n content: `import { e } from '@geekmidas/constructs/endpoints';\n\nexport default e\n .get('/health')\n .handle(async () => ({\n status: 'ok',\n timestamp: new Date().toISOString(),\n }));\n`,\n },\n ];\n\n // Add Telescope config if enabled\n if (options.telescope) {\n files.push({\n path: 'src/config/telescope.ts',\n content: `import { Telescope } from '@geekmidas/telescope';\nimport { InMemoryStorage } from '@geekmidas/telescope/storage/memory';\n\nexport const telescope = new Telescope({\n storage: new InMemoryStorage({ maxEntries: 100 }),\n enabled: process.env.NODE_ENV === 'development',\n});\n`,\n });\n }\n\n return files;\n },\n};\n"],"mappings":";;AAMA,MAAaA,kBAAkC;CAC7C,MAAM;CACN,aAAa;CAEb,cAAc;EACZ,yBAAyB;EACzB,qBAAqB;EACrB,qBAAqB;EACrB,MAAM;EACN,MAAM;CACP;CAED,iBAAiB;EACf,kBAAkB;EAClB,kBAAkB;EAClB,eAAe;EACf,KAAK;EACL,OAAO;EACP,YAAY;EACZ,QAAQ;CACT;CAED,SAAS;EACP,KAAK;EACL,OAAO;EACP,MAAM;EACN,aAAa;EACb,WAAW;EACX,MAAM;EACN,KAAK;EACL,aAAa;CACd;CAED,OAAO,CAACC,YAA8C;EACpD,MAAMC,QAAyB;GAE7B;IACE,MAAM;IACN,UAAU;;;;;;;;;;;GAWX;GAGD;IACE,MAAM;IACN,UAAU;;;UAGR,QAAQ,KAAK;;;;GAIhB;GAGD;IACE,MAAM;IACN,UAAU;;;;;;;;;GASX;EACF;AAGD,MAAI,QAAQ,UACV,OAAM,KAAK;GACT,MAAM;GACN,UAAU;;;;;;;;EAQX,EAAC;AAGJ,SAAO;CACR;AACF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//#region src/init/templates/minimal.ts
|
|
2
|
+
const minimalTemplate = {
|
|
3
|
+
name: "minimal",
|
|
4
|
+
description: "Basic health endpoint",
|
|
5
|
+
dependencies: {
|
|
6
|
+
"@geekmidas/constructs": "workspace:*",
|
|
7
|
+
"@geekmidas/envkit": "workspace:*",
|
|
8
|
+
"@geekmidas/logger": "workspace:*",
|
|
9
|
+
hono: "~4.8.2",
|
|
10
|
+
pino: "~9.6.0"
|
|
11
|
+
},
|
|
12
|
+
devDependencies: {
|
|
13
|
+
"@biomejs/biome": "~1.9.4",
|
|
14
|
+
"@geekmidas/cli": "workspace:*",
|
|
15
|
+
"@types/node": "~22.0.0",
|
|
16
|
+
tsx: "~4.20.0",
|
|
17
|
+
turbo: "~2.3.0",
|
|
18
|
+
typescript: "~5.8.2",
|
|
19
|
+
vitest: "~4.0.0"
|
|
20
|
+
},
|
|
21
|
+
scripts: {
|
|
22
|
+
dev: "gkm dev",
|
|
23
|
+
build: "gkm build",
|
|
24
|
+
test: "vitest",
|
|
25
|
+
"test:once": "vitest run",
|
|
26
|
+
typecheck: "tsc --noEmit",
|
|
27
|
+
lint: "biome lint .",
|
|
28
|
+
fmt: "biome format . --write",
|
|
29
|
+
"fmt:check": "biome format ."
|
|
30
|
+
},
|
|
31
|
+
files: (options) => {
|
|
32
|
+
const files = [
|
|
33
|
+
{
|
|
34
|
+
path: "src/config/env.ts",
|
|
35
|
+
content: `import { EnvironmentParser } from '@geekmidas/envkit';
|
|
36
|
+
|
|
37
|
+
export const envParser = new EnvironmentParser(process.env);
|
|
38
|
+
|
|
39
|
+
export const config = envParser
|
|
40
|
+
.create((get) => ({
|
|
41
|
+
port: get('PORT').string().transform(Number).default(3000),
|
|
42
|
+
nodeEnv: get('NODE_ENV').string().default('development'),
|
|
43
|
+
}))
|
|
44
|
+
.parse();
|
|
45
|
+
`
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
path: "src/config/logger.ts",
|
|
49
|
+
content: `import { PinoLogger } from '@geekmidas/logger/pino';
|
|
50
|
+
|
|
51
|
+
export const logger = new PinoLogger({
|
|
52
|
+
app: '${options.name}',
|
|
53
|
+
level: process.env.LOG_LEVEL || 'info',
|
|
54
|
+
});
|
|
55
|
+
`
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
path: "src/endpoints/health.ts",
|
|
59
|
+
content: `import { e } from '@geekmidas/constructs/endpoints';
|
|
60
|
+
|
|
61
|
+
export default e
|
|
62
|
+
.get('/health')
|
|
63
|
+
.handle(async () => ({
|
|
64
|
+
status: 'ok',
|
|
65
|
+
timestamp: new Date().toISOString(),
|
|
66
|
+
}));
|
|
67
|
+
`
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
if (options.telescope) files.push({
|
|
71
|
+
path: "src/config/telescope.ts",
|
|
72
|
+
content: `import { Telescope } from '@geekmidas/telescope';
|
|
73
|
+
import { InMemoryStorage } from '@geekmidas/telescope/storage/memory';
|
|
74
|
+
|
|
75
|
+
export const telescope = new Telescope({
|
|
76
|
+
storage: new InMemoryStorage({ maxEntries: 100 }),
|
|
77
|
+
enabled: process.env.NODE_ENV === 'development',
|
|
78
|
+
});
|
|
79
|
+
`
|
|
80
|
+
});
|
|
81
|
+
return files;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
export { minimalTemplate };
|
|
87
|
+
//# sourceMappingURL=minimal-C4GsE45s.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimal-C4GsE45s.mjs","names":["minimalTemplate: TemplateConfig","options: TemplateOptions","files: GeneratedFile[]"],"sources":["../src/init/templates/minimal.ts"],"sourcesContent":["import type {\n GeneratedFile,\n TemplateConfig,\n TemplateOptions,\n} from './index.js';\n\nexport const minimalTemplate: TemplateConfig = {\n name: 'minimal',\n description: 'Basic health endpoint',\n\n dependencies: {\n '@geekmidas/constructs': 'workspace:*',\n '@geekmidas/envkit': 'workspace:*',\n '@geekmidas/logger': 'workspace:*',\n hono: '~4.8.2',\n pino: '~9.6.0',\n },\n\n devDependencies: {\n '@biomejs/biome': '~1.9.4',\n '@geekmidas/cli': 'workspace:*',\n '@types/node': '~22.0.0',\n tsx: '~4.20.0',\n turbo: '~2.3.0',\n typescript: '~5.8.2',\n vitest: '~4.0.0',\n },\n\n scripts: {\n dev: 'gkm dev',\n build: 'gkm build',\n test: 'vitest',\n 'test:once': 'vitest run',\n typecheck: 'tsc --noEmit',\n lint: 'biome lint .',\n fmt: 'biome format . --write',\n 'fmt:check': 'biome format .',\n },\n\n files: (options: TemplateOptions): GeneratedFile[] => {\n const files: GeneratedFile[] = [\n // src/config/env.ts\n {\n path: 'src/config/env.ts',\n content: `import { EnvironmentParser } from '@geekmidas/envkit';\n\nexport const envParser = new EnvironmentParser(process.env);\n\nexport const config = envParser\n .create((get) => ({\n port: get('PORT').string().transform(Number).default(3000),\n nodeEnv: get('NODE_ENV').string().default('development'),\n }))\n .parse();\n`,\n },\n\n // src/config/logger.ts - using pino\n {\n path: 'src/config/logger.ts',\n content: `import { PinoLogger } from '@geekmidas/logger/pino';\n\nexport const logger = new PinoLogger({\n app: '${options.name}',\n level: process.env.LOG_LEVEL || 'info',\n});\n`,\n },\n\n // src/endpoints/health.ts\n {\n path: 'src/endpoints/health.ts',\n content: `import { e } from '@geekmidas/constructs/endpoints';\n\nexport default e\n .get('/health')\n .handle(async () => ({\n status: 'ok',\n timestamp: new Date().toISOString(),\n }));\n`,\n },\n ];\n\n // Add Telescope config if enabled\n if (options.telescope) {\n files.push({\n path: 'src/config/telescope.ts',\n content: `import { Telescope } from '@geekmidas/telescope';\nimport { InMemoryStorage } from '@geekmidas/telescope/storage/memory';\n\nexport const telescope = new Telescope({\n storage: new InMemoryStorage({ maxEntries: 100 }),\n enabled: process.env.NODE_ENV === 'development',\n});\n`,\n });\n }\n\n return files;\n },\n};\n"],"mappings":";AAMA,MAAaA,kBAAkC;CAC7C,MAAM;CACN,aAAa;CAEb,cAAc;EACZ,yBAAyB;EACzB,qBAAqB;EACrB,qBAAqB;EACrB,MAAM;EACN,MAAM;CACP;CAED,iBAAiB;EACf,kBAAkB;EAClB,kBAAkB;EAClB,eAAe;EACf,KAAK;EACL,OAAO;EACP,YAAY;EACZ,QAAQ;CACT;CAED,SAAS;EACP,KAAK;EACL,OAAO;EACP,MAAM;EACN,aAAa;EACb,WAAW;EACX,MAAM;EACN,KAAK;EACL,aAAa;CACd;CAED,OAAO,CAACC,YAA8C;EACpD,MAAMC,QAAyB;GAE7B;IACE,MAAM;IACN,UAAU;;;;;;;;;;;GAWX;GAGD;IACE,MAAM;IACN,UAAU;;;UAGR,QAAQ,KAAK;;;;GAIhB;GAGD;IACE,MAAM;IACN,UAAU;;;;;;;;;GASX;EACF;AAGD,MAAI,QAAQ,UACV,OAAM,KAAK;GACT,MAAM;GACN,UAAU;;;;;;;;EAQX,EAAC;AAGJ,SAAO;CACR;AACF"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/init/generators/models.ts
|
|
3
|
+
/**
|
|
4
|
+
* Generate packages/models for shared Zod schemas (monorepo only)
|
|
5
|
+
*/
|
|
6
|
+
function generateModelsPackage(options) {
|
|
7
|
+
if (!options.monorepo) return [];
|
|
8
|
+
const packageName = `@${options.name}/models`;
|
|
9
|
+
const packageJson = {
|
|
10
|
+
name: packageName,
|
|
11
|
+
version: "0.0.1",
|
|
12
|
+
private: true,
|
|
13
|
+
type: "module",
|
|
14
|
+
exports: {
|
|
15
|
+
".": {
|
|
16
|
+
types: "./dist/index.d.ts",
|
|
17
|
+
import: "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./*": {
|
|
20
|
+
types: "./dist/*.d.ts",
|
|
21
|
+
import: "./dist/*.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
scripts: {
|
|
25
|
+
build: "tsc",
|
|
26
|
+
"build:watch": "tsc --watch",
|
|
27
|
+
typecheck: "tsc --noEmit"
|
|
28
|
+
},
|
|
29
|
+
dependencies: { zod: "~4.1.0" },
|
|
30
|
+
devDependencies: { typescript: "~5.8.2" }
|
|
31
|
+
};
|
|
32
|
+
const tsConfig = {
|
|
33
|
+
extends: "../../tsconfig.json",
|
|
34
|
+
compilerOptions: {
|
|
35
|
+
outDir: "./dist",
|
|
36
|
+
rootDir: "./src"
|
|
37
|
+
},
|
|
38
|
+
include: ["src/**/*.ts"],
|
|
39
|
+
exclude: ["node_modules", "dist"]
|
|
40
|
+
};
|
|
41
|
+
const indexTs = `import { z } from 'zod';
|
|
42
|
+
|
|
43
|
+
// ============================================
|
|
44
|
+
// Common Schemas
|
|
45
|
+
// ============================================
|
|
46
|
+
|
|
47
|
+
export const idSchema = z.string().uuid();
|
|
48
|
+
|
|
49
|
+
export const timestampsSchema = z.object({
|
|
50
|
+
createdAt: z.coerce.date(),
|
|
51
|
+
updatedAt: z.coerce.date(),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const paginationSchema = z.object({
|
|
55
|
+
page: z.coerce.number().int().positive().default(1),
|
|
56
|
+
limit: z.coerce.number().int().positive().max(100).default(20),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const paginatedResponseSchema = <T extends z.ZodTypeAny>(itemSchema: T) =>
|
|
60
|
+
z.object({
|
|
61
|
+
items: z.array(itemSchema),
|
|
62
|
+
total: z.number(),
|
|
63
|
+
page: z.number(),
|
|
64
|
+
limit: z.number(),
|
|
65
|
+
totalPages: z.number(),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// ============================================
|
|
69
|
+
// User Schemas
|
|
70
|
+
// ============================================
|
|
71
|
+
|
|
72
|
+
export const userSchema = z.object({
|
|
73
|
+
id: idSchema,
|
|
74
|
+
email: z.string().email(),
|
|
75
|
+
name: z.string().min(1).max(100),
|
|
76
|
+
...timestampsSchema.shape,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export const createUserSchema = userSchema.omit({
|
|
80
|
+
id: true,
|
|
81
|
+
createdAt: true,
|
|
82
|
+
updatedAt: true,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const updateUserSchema = createUserSchema.partial();
|
|
86
|
+
|
|
87
|
+
// ============================================
|
|
88
|
+
// Type Exports
|
|
89
|
+
// ============================================
|
|
90
|
+
|
|
91
|
+
export type Id = z.infer<typeof idSchema>;
|
|
92
|
+
export type Timestamps = z.infer<typeof timestampsSchema>;
|
|
93
|
+
export type Pagination = z.infer<typeof paginationSchema>;
|
|
94
|
+
export type User = z.infer<typeof userSchema>;
|
|
95
|
+
export type CreateUser = z.infer<typeof createUserSchema>;
|
|
96
|
+
export type UpdateUser = z.infer<typeof updateUserSchema>;
|
|
97
|
+
`;
|
|
98
|
+
return [
|
|
99
|
+
{
|
|
100
|
+
path: "packages/models/package.json",
|
|
101
|
+
content: JSON.stringify(packageJson, null, 2) + "\n"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
path: "packages/models/tsconfig.json",
|
|
105
|
+
content: JSON.stringify(tsConfig, null, 2) + "\n"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
path: "packages/models/src/index.ts",
|
|
109
|
+
content: indexTs
|
|
110
|
+
}
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
Object.defineProperty(exports, 'generateModelsPackage', {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () {
|
|
118
|
+
return generateModelsPackage;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=models-DyNwdOcz.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models-DyNwdOcz.cjs","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"}
|