@geekmidas/cli 0.26.0 → 0.28.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.
Files changed (36) hide show
  1. package/dist/{config-CTftATBX.cjs → config-BhryDQEq.cjs} +2 -2
  2. package/dist/{config-CTftATBX.cjs.map → config-BhryDQEq.cjs.map} +1 -1
  3. package/dist/{config-BogU0_oQ.mjs → config-C9bdq0l-.mjs} +2 -2
  4. package/dist/{config-BogU0_oQ.mjs.map → config-C9bdq0l-.mjs.map} +1 -1
  5. package/dist/config.cjs +2 -2
  6. package/dist/config.mjs +2 -2
  7. package/dist/index-CWN-bgrO.d.mts.map +1 -1
  8. package/dist/index-DEWYvYvg.d.cts.map +1 -1
  9. package/dist/index.cjs +142 -40
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.mjs +142 -40
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/{openapi-DNbXfhXE.mjs → openapi-BCEFhkLh.mjs} +2 -2
  14. package/dist/{openapi-DNbXfhXE.mjs.map → openapi-BCEFhkLh.mjs.map} +1 -1
  15. package/dist/{openapi-BrhkPKM7.cjs → openapi-D82bBqG7.cjs} +2 -2
  16. package/dist/{openapi-BrhkPKM7.cjs.map → openapi-D82bBqG7.cjs.map} +1 -1
  17. package/dist/openapi.cjs +3 -3
  18. package/dist/openapi.mjs +3 -3
  19. package/dist/workspace/index.cjs +1 -1
  20. package/dist/workspace/index.mjs +1 -1
  21. package/dist/{workspace-iWgBlX6h.cjs → workspace-CiZBOjf9.cjs} +1 -7
  22. package/dist/{workspace-iWgBlX6h.cjs.map → workspace-CiZBOjf9.cjs.map} +1 -1
  23. package/dist/{workspace-CPLEZDZf.mjs → workspace-DQjmv9lk.mjs} +1 -7
  24. package/dist/{workspace-CPLEZDZf.mjs.map → workspace-DQjmv9lk.mjs.map} +1 -1
  25. package/package.json +5 -5
  26. package/src/init/__tests__/generators.spec.ts +12 -6
  27. package/src/init/__tests__/init.spec.ts +18 -6
  28. package/src/init/generators/models.ts +51 -30
  29. package/src/init/index.ts +15 -0
  30. package/src/init/templates/api.ts +55 -3
  31. package/src/init/templates/minimal.ts +6 -0
  32. package/src/init/templates/serverless.ts +7 -0
  33. package/src/init/templates/worker.ts +6 -0
  34. package/src/workspace/__tests__/index.spec.ts +5 -6
  35. package/src/workspace/__tests__/schema.spec.ts +5 -5
  36. package/src/workspace/schema.ts +1 -13
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env -S npx tsx
2
- import { __require, getAppBuildOrder, getDependencyEnvVars, getDeployTargetError, isDeployTargetSupported } from "./workspace-CPLEZDZf.mjs";
3
- import { getAppNameFromCwd, loadAppConfig, loadConfig, loadWorkspaceConfig, parseModuleConfig } from "./config-BogU0_oQ.mjs";
4
- import { ConstructGenerator, EndpointGenerator, OPENAPI_OUTPUT_PATH, OpenApiTsGenerator, generateOpenApi, openapiCommand, resolveOpenApiConfig } from "./openapi-DNbXfhXE.mjs";
2
+ import { __require, getAppBuildOrder, getDependencyEnvVars, getDeployTargetError, isDeployTargetSupported } from "./workspace-DQjmv9lk.mjs";
3
+ import { getAppNameFromCwd, loadAppConfig, loadConfig, loadWorkspaceConfig, parseModuleConfig } from "./config-C9bdq0l-.mjs";
4
+ import { ConstructGenerator, EndpointGenerator, OPENAPI_OUTPUT_PATH, OpenApiTsGenerator, generateOpenApi, openapiCommand, resolveOpenApiConfig } from "./openapi-BCEFhkLh.mjs";
5
5
  import { getKeyPath, maskPassword, readStageSecrets, secretsExist, setCustomSecret, toEmbeddableSecrets, writeStageSecrets } from "./storage-Dhst7BhI.mjs";
6
6
  import { DokployApi } from "./dokploy-api-B9qR2Yn1.mjs";
7
7
  import { generateReactQueryCommand } from "./openapi-react-query-5rSortLH.mjs";
@@ -26,7 +26,7 @@ import prompts from "prompts";
26
26
 
27
27
  //#region package.json
28
28
  var name = "@geekmidas/cli";
29
- var version = "0.25.0";
29
+ var version = "0.28.0";
30
30
  var description = "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs";
31
31
  var private$1 = false;
32
32
  var type = "module";
@@ -4945,21 +4945,8 @@ function generateModelsPackage(options) {
4945
4945
  version: "0.0.1",
4946
4946
  private: true,
4947
4947
  type: "module",
4948
- exports: {
4949
- ".": {
4950
- types: "./dist/index.d.ts",
4951
- import: "./dist/index.js"
4952
- },
4953
- "./*": {
4954
- types: "./dist/*.d.ts",
4955
- import: "./dist/*.js"
4956
- }
4957
- },
4958
- scripts: {
4959
- build: "tsc",
4960
- "build:watch": "tsc --watch",
4961
- typecheck: "tsc --noEmit"
4962
- },
4948
+ exports: { "./*": "./src/*.ts" },
4949
+ scripts: { typecheck: "tsc --noEmit" },
4963
4950
  dependencies: { zod: "~4.1.0" },
4964
4951
  devDependencies: { typescript: "~5.8.2" }
4965
4952
  };
@@ -4974,25 +4961,25 @@ function generateModelsPackage(options) {
4974
4961
  include: ["src/**/*.ts"],
4975
4962
  exclude: ["node_modules", "dist"]
4976
4963
  };
4977
- const indexTs = `import { z } from 'zod';
4964
+ const commonTs = `import { z } from 'zod';
4978
4965
 
4979
4966
  // ============================================
4980
4967
  // Common Schemas
4981
4968
  // ============================================
4982
4969
 
4983
- export const idSchema = z.string().uuid();
4970
+ export const IdSchema = z.string().uuid();
4984
4971
 
4985
- export const timestampsSchema = z.object({
4972
+ export const TimestampsSchema = z.object({
4986
4973
  createdAt: z.coerce.date(),
4987
4974
  updatedAt: z.coerce.date(),
4988
4975
  });
4989
4976
 
4990
- export const paginationSchema = z.object({
4977
+ export const PaginationSchema = z.object({
4991
4978
  page: z.coerce.number().int().positive().default(1),
4992
4979
  limit: z.coerce.number().int().positive().max(100).default(20),
4993
4980
  });
4994
4981
 
4995
- export const paginatedResponseSchema = <T extends z.ZodTypeAny>(itemSchema: T) =>
4982
+ export const PaginatedResponseSchema = <T extends z.ZodTypeAny>(itemSchema: T) =>
4996
4983
  z.object({
4997
4984
  items: z.array(itemSchema),
4998
4985
  total: z.number(),
@@ -5001,35 +4988,59 @@ export const paginatedResponseSchema = <T extends z.ZodTypeAny>(itemSchema: T) =
5001
4988
  totalPages: z.number(),
5002
4989
  });
5003
4990
 
4991
+ // ============================================
4992
+ // Type Exports
4993
+ // ============================================
4994
+
4995
+ export type Id = z.infer<typeof IdSchema>;
4996
+ export type Timestamps = z.infer<typeof TimestampsSchema>;
4997
+ export type Pagination = z.infer<typeof PaginationSchema>;
4998
+ `;
4999
+ const userTs = `import { z } from 'zod';
5000
+ import { IdSchema, TimestampsSchema } from './common.js';
5001
+
5004
5002
  // ============================================
5005
5003
  // User Schemas
5006
5004
  // ============================================
5007
5005
 
5008
- export const userSchema = z.object({
5009
- id: idSchema,
5006
+ export const UserSchema = z.object({
5007
+ id: IdSchema,
5010
5008
  email: z.string().email(),
5011
5009
  name: z.string().min(1).max(100),
5012
- ...timestampsSchema.shape,
5010
+ ...TimestampsSchema.shape,
5013
5011
  });
5014
5012
 
5015
- export const createUserSchema = userSchema.omit({
5013
+ export const CreateUserSchema = UserSchema.omit({
5016
5014
  id: true,
5017
5015
  createdAt: true,
5018
5016
  updatedAt: true,
5019
5017
  });
5020
5018
 
5021
- export const updateUserSchema = createUserSchema.partial();
5019
+ export const UpdateUserSchema = CreateUserSchema.partial();
5020
+
5021
+ // ============================================
5022
+ // Response Schemas
5023
+ // ============================================
5024
+
5025
+ export const UserResponseSchema = UserSchema.pick({
5026
+ id: true,
5027
+ name: true,
5028
+ email: true,
5029
+ });
5030
+
5031
+ export const ListUsersResponseSchema = z.object({
5032
+ users: z.array(UserSchema.pick({ id: true, name: true })),
5033
+ });
5022
5034
 
5023
5035
  // ============================================
5024
5036
  // Type Exports
5025
5037
  // ============================================
5026
5038
 
5027
- export type Id = z.infer<typeof idSchema>;
5028
- export type Timestamps = z.infer<typeof timestampsSchema>;
5029
- export type Pagination = z.infer<typeof paginationSchema>;
5030
- export type User = z.infer<typeof userSchema>;
5031
- export type CreateUser = z.infer<typeof createUserSchema>;
5032
- export type UpdateUser = z.infer<typeof updateUserSchema>;
5039
+ export type User = z.infer<typeof UserSchema>;
5040
+ export type CreateUser = z.infer<typeof CreateUserSchema>;
5041
+ export type UpdateUser = z.infer<typeof UpdateUserSchema>;
5042
+ export type UserResponse = z.infer<typeof UserResponseSchema>;
5043
+ export type ListUsersResponse = z.infer<typeof ListUsersResponseSchema>;
5033
5044
  `;
5034
5045
  return [
5035
5046
  {
@@ -5041,8 +5052,12 @@ export type UpdateUser = z.infer<typeof updateUserSchema>;
5041
5052
  content: `${JSON.stringify(tsConfig, null, 2)}\n`
5042
5053
  },
5043
5054
  {
5044
- path: "packages/models/src/index.ts",
5045
- content: indexTs
5055
+ path: "packages/models/src/common.ts",
5056
+ content: commonTs
5057
+ },
5058
+ {
5059
+ path: "packages/models/src/user.ts",
5060
+ content: userTs
5046
5061
  }
5047
5062
  ];
5048
5063
  }
@@ -5347,6 +5362,7 @@ const apiTemplate = {
5347
5362
  "@geekmidas/envkit": GEEKMIDAS_VERSIONS["@geekmidas/envkit"],
5348
5363
  "@geekmidas/events": GEEKMIDAS_VERSIONS["@geekmidas/events"],
5349
5364
  "@geekmidas/logger": GEEKMIDAS_VERSIONS["@geekmidas/logger"],
5365
+ "@geekmidas/rate-limit": GEEKMIDAS_VERSIONS["@geekmidas/rate-limit"],
5350
5366
  "@geekmidas/schema": GEEKMIDAS_VERSIONS["@geekmidas/schema"],
5351
5367
  "@geekmidas/services": GEEKMIDAS_VERSIONS["@geekmidas/services"],
5352
5368
  "@geekmidas/errors": GEEKMIDAS_VERSIONS["@geekmidas/errors"],
@@ -5375,11 +5391,12 @@ const apiTemplate = {
5375
5391
  "fmt:check": "biome format ."
5376
5392
  },
5377
5393
  files: (options) => {
5378
- const { loggerType, routesStructure } = options;
5394
+ const { loggerType, routesStructure, monorepo, name: name$1 } = options;
5379
5395
  const loggerContent = `import { createLogger } from '@geekmidas/logger/${loggerType}';
5380
5396
 
5381
5397
  export const logger = createLogger();
5382
5398
  `;
5399
+ const modelsImport = monorepo ? `@${name$1}/models` : null;
5383
5400
  const getRoutePath = (file) => {
5384
5401
  switch (routesStructure) {
5385
5402
  case "centralized-endpoints": return `src/endpoints/${file}`;
@@ -5416,9 +5433,14 @@ export const config = envParser
5416
5433
  {
5417
5434
  path: getRoutePath("health.ts"),
5418
5435
  content: `import { e } from '@geekmidas/constructs/endpoints';
5436
+ import { z } from 'zod';
5419
5437
 
5420
5438
  export const healthEndpoint = e
5421
5439
  .get('/health')
5440
+ .output(z.object({
5441
+ status: z.string(),
5442
+ timestamp: z.string(),
5443
+ }))
5422
5444
  .handle(async () => ({
5423
5445
  status: 'ok',
5424
5446
  timestamp: new Date().toISOString(),
@@ -5427,10 +5449,31 @@ export const healthEndpoint = e
5427
5449
  },
5428
5450
  {
5429
5451
  path: getRoutePath("users/list.ts"),
5430
- content: `import { e } from '@geekmidas/constructs/endpoints';
5452
+ content: modelsImport ? `import { e } from '@geekmidas/constructs/endpoints';
5453
+ import { ListUsersResponseSchema } from '${modelsImport}/user';
5454
+
5455
+ export const listUsersEndpoint = e
5456
+ .get('/users')
5457
+ .output(ListUsersResponseSchema)
5458
+ .handle(async () => ({
5459
+ users: [
5460
+ { id: '1', name: 'Alice' },
5461
+ { id: '2', name: 'Bob' },
5462
+ ],
5463
+ }));
5464
+ ` : `import { e } from '@geekmidas/constructs/endpoints';
5465
+ import { z } from 'zod';
5466
+
5467
+ const UserSchema = z.object({
5468
+ id: z.string(),
5469
+ name: z.string(),
5470
+ });
5431
5471
 
5432
5472
  export const listUsersEndpoint = e
5433
5473
  .get('/users')
5474
+ .output(z.object({
5475
+ users: z.array(UserSchema),
5476
+ }))
5434
5477
  .handle(async () => ({
5435
5478
  users: [
5436
5479
  { id: '1', name: 'Alice' },
@@ -5441,12 +5484,30 @@ export const listUsersEndpoint = e
5441
5484
  },
5442
5485
  {
5443
5486
  path: getRoutePath("users/get.ts"),
5444
- content: `import { e } from '@geekmidas/constructs/endpoints';
5487
+ content: modelsImport ? `import { e } from '@geekmidas/constructs/endpoints';
5445
5488
  import { z } from 'zod';
5489
+ import { UserResponseSchema } from '${modelsImport}/user';
5446
5490
 
5447
5491
  export const getUserEndpoint = e
5448
5492
  .get('/users/:id')
5449
5493
  .params(z.object({ id: z.string() }))
5494
+ .output(UserResponseSchema)
5495
+ .handle(async ({ params }) => ({
5496
+ id: params.id,
5497
+ name: 'Alice',
5498
+ email: 'alice@example.com',
5499
+ }));
5500
+ ` : `import { e } from '@geekmidas/constructs/endpoints';
5501
+ import { z } from 'zod';
5502
+
5503
+ export const getUserEndpoint = e
5504
+ .get('/users/:id')
5505
+ .params(z.object({ id: z.string() }))
5506
+ .output(z.object({
5507
+ id: z.string(),
5508
+ name: z.string(),
5509
+ email: z.string().email(),
5510
+ }))
5450
5511
  .handle(async ({ params }) => ({
5451
5512
  id: params.id,
5452
5513
  name: 'Alice',
@@ -5554,6 +5615,7 @@ const minimalTemplate = {
5554
5615
  "@geekmidas/constructs": GEEKMIDAS_VERSIONS["@geekmidas/constructs"],
5555
5616
  "@geekmidas/envkit": GEEKMIDAS_VERSIONS["@geekmidas/envkit"],
5556
5617
  "@geekmidas/logger": GEEKMIDAS_VERSIONS["@geekmidas/logger"],
5618
+ "@geekmidas/rate-limit": GEEKMIDAS_VERSIONS["@geekmidas/rate-limit"],
5557
5619
  "@geekmidas/schema": GEEKMIDAS_VERSIONS["@geekmidas/schema"],
5558
5620
  "@hono/node-server": "~1.14.1",
5559
5621
  hono: "~4.8.2",
@@ -5616,9 +5678,14 @@ export const config = envParser
5616
5678
  {
5617
5679
  path: getRoutePath("health.ts"),
5618
5680
  content: `import { e } from '@geekmidas/constructs/endpoints';
5681
+ import { z } from 'zod';
5619
5682
 
5620
5683
  export const healthEndpoint = e
5621
5684
  .get('/health')
5685
+ .output(z.object({
5686
+ status: z.string(),
5687
+ timestamp: z.string(),
5688
+ }))
5622
5689
  .handle(async () => ({
5623
5690
  status: 'ok',
5624
5691
  timestamp: new Date().toISOString(),
@@ -5721,6 +5788,7 @@ const serverlessTemplate = {
5721
5788
  "@geekmidas/envkit": GEEKMIDAS_VERSIONS["@geekmidas/envkit"],
5722
5789
  "@geekmidas/logger": GEEKMIDAS_VERSIONS["@geekmidas/logger"],
5723
5790
  "@geekmidas/cloud": GEEKMIDAS_VERSIONS["@geekmidas/cloud"],
5791
+ "@geekmidas/rate-limit": GEEKMIDAS_VERSIONS["@geekmidas/rate-limit"],
5724
5792
  "@geekmidas/schema": GEEKMIDAS_VERSIONS["@geekmidas/schema"],
5725
5793
  "@hono/node-server": "~1.14.1",
5726
5794
  hono: "~4.8.2",
@@ -5784,9 +5852,15 @@ export const config = envParser
5784
5852
  {
5785
5853
  path: getRoutePath("health.ts"),
5786
5854
  content: `import { e } from '@geekmidas/constructs/endpoints';
5855
+ import { z } from 'zod';
5787
5856
 
5788
5857
  export const healthEndpoint = e
5789
5858
  .get('/health')
5859
+ .output(z.object({
5860
+ status: z.string(),
5861
+ timestamp: z.string(),
5862
+ region: z.string(),
5863
+ }))
5790
5864
  .handle(async () => ({
5791
5865
  status: 'ok',
5792
5866
  timestamp: new Date().toISOString(),
@@ -5835,6 +5909,7 @@ const workerTemplate = {
5835
5909
  "@geekmidas/envkit": GEEKMIDAS_VERSIONS["@geekmidas/envkit"],
5836
5910
  "@geekmidas/events": GEEKMIDAS_VERSIONS["@geekmidas/events"],
5837
5911
  "@geekmidas/logger": GEEKMIDAS_VERSIONS["@geekmidas/logger"],
5912
+ "@geekmidas/rate-limit": GEEKMIDAS_VERSIONS["@geekmidas/rate-limit"],
5838
5913
  "@geekmidas/schema": GEEKMIDAS_VERSIONS["@geekmidas/schema"],
5839
5914
  "@hono/node-server": "~1.14.1",
5840
5915
  hono: "~4.8.2",
@@ -5897,9 +5972,14 @@ export const config = envParser
5897
5972
  {
5898
5973
  path: getRoutePath("health.ts"),
5899
5974
  content: `import { e } from '@geekmidas/constructs/endpoints';
5975
+ import { z } from 'zod';
5900
5976
 
5901
5977
  export const healthEndpoint = e
5902
5978
  .get('/health')
5979
+ .output(z.object({
5980
+ status: z.string(),
5981
+ timestamp: z.string(),
5982
+ }))
5903
5983
  .handle(async () => ({
5904
5984
  status: 'ok',
5905
5985
  timestamp: new Date().toISOString(),
@@ -6696,6 +6776,28 @@ async function initCommand(projectName, options = {}) {
6696
6776
  });
6697
6777
  } catch {}
6698
6778
  }
6779
+ console.log("\n📦 Initializing git repository...\n");
6780
+ try {
6781
+ execSync("git init", {
6782
+ cwd: targetDir,
6783
+ stdio: "pipe"
6784
+ });
6785
+ execSync("git branch -M main", {
6786
+ cwd: targetDir,
6787
+ stdio: "pipe"
6788
+ });
6789
+ execSync("git add .", {
6790
+ cwd: targetDir,
6791
+ stdio: "pipe"
6792
+ });
6793
+ execSync("git commit -m \"🎉 Project created with @geekmidas/toolbox\"", {
6794
+ cwd: targetDir,
6795
+ stdio: "pipe"
6796
+ });
6797
+ console.log(" Initialized git repository on branch main");
6798
+ } catch {
6799
+ console.log(" Could not initialize git repository (git may not be installed)");
6800
+ }
6699
6801
  printNextSteps(name$1, templateOptions, pkgManager);
6700
6802
  }
6701
6803
  /**