@geekmidas/cli 0.26.0 → 0.27.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/dist/{config-CTftATBX.cjs → config-BhryDQEq.cjs} +2 -2
- package/dist/{config-CTftATBX.cjs.map → config-BhryDQEq.cjs.map} +1 -1
- package/dist/{config-BogU0_oQ.mjs → config-C9bdq0l-.mjs} +2 -2
- package/dist/{config-BogU0_oQ.mjs.map → config-C9bdq0l-.mjs.map} +1 -1
- package/dist/config.cjs +2 -2
- package/dist/config.mjs +2 -2
- package/dist/index-CWN-bgrO.d.mts.map +1 -1
- package/dist/index-DEWYvYvg.d.cts.map +1 -1
- package/dist/index.cjs +118 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +118 -25
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi-DNbXfhXE.mjs → openapi-BCEFhkLh.mjs} +2 -2
- package/dist/{openapi-DNbXfhXE.mjs.map → openapi-BCEFhkLh.mjs.map} +1 -1
- package/dist/{openapi-BrhkPKM7.cjs → openapi-D82bBqG7.cjs} +2 -2
- package/dist/{openapi-BrhkPKM7.cjs.map → openapi-D82bBqG7.cjs.map} +1 -1
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.mjs +3 -3
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-iWgBlX6h.cjs → workspace-CiZBOjf9.cjs} +1 -7
- package/dist/{workspace-iWgBlX6h.cjs.map → workspace-CiZBOjf9.cjs.map} +1 -1
- package/dist/{workspace-CPLEZDZf.mjs → workspace-DQjmv9lk.mjs} +1 -7
- package/dist/{workspace-CPLEZDZf.mjs.map → workspace-DQjmv9lk.mjs.map} +1 -1
- package/package.json +4 -4
- package/src/init/__tests__/generators.spec.ts +12 -6
- package/src/init/__tests__/init.spec.ts +18 -6
- package/src/init/generators/models.ts +49 -19
- package/src/init/templates/api.ts +55 -3
- package/src/init/templates/minimal.ts +6 -0
- package/src/init/templates/serverless.ts +7 -0
- package/src/init/templates/worker.ts +6 -0
- package/src/workspace/__tests__/index.spec.ts +5 -6
- package/src/workspace/__tests__/schema.spec.ts +5 -5
- 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-
|
|
3
|
-
import { getAppNameFromCwd, loadAppConfig, loadConfig, loadWorkspaceConfig, parseModuleConfig } from "./config-
|
|
4
|
-
import { ConstructGenerator, EndpointGenerator, OPENAPI_OUTPUT_PATH, OpenApiTsGenerator, generateOpenApi, openapiCommand, resolveOpenApiConfig } from "./openapi-
|
|
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.
|
|
29
|
+
var version = "0.27.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";
|
|
@@ -4974,25 +4974,25 @@ function generateModelsPackage(options) {
|
|
|
4974
4974
|
include: ["src/**/*.ts"],
|
|
4975
4975
|
exclude: ["node_modules", "dist"]
|
|
4976
4976
|
};
|
|
4977
|
-
const
|
|
4977
|
+
const commonTs = `import { z } from 'zod';
|
|
4978
4978
|
|
|
4979
4979
|
// ============================================
|
|
4980
4980
|
// Common Schemas
|
|
4981
4981
|
// ============================================
|
|
4982
4982
|
|
|
4983
|
-
export const
|
|
4983
|
+
export const IdSchema = z.string().uuid();
|
|
4984
4984
|
|
|
4985
|
-
export const
|
|
4985
|
+
export const TimestampsSchema = z.object({
|
|
4986
4986
|
createdAt: z.coerce.date(),
|
|
4987
4987
|
updatedAt: z.coerce.date(),
|
|
4988
4988
|
});
|
|
4989
4989
|
|
|
4990
|
-
export const
|
|
4990
|
+
export const PaginationSchema = z.object({
|
|
4991
4991
|
page: z.coerce.number().int().positive().default(1),
|
|
4992
4992
|
limit: z.coerce.number().int().positive().max(100).default(20),
|
|
4993
4993
|
});
|
|
4994
4994
|
|
|
4995
|
-
export const
|
|
4995
|
+
export const PaginatedResponseSchema = <T extends z.ZodTypeAny>(itemSchema: T) =>
|
|
4996
4996
|
z.object({
|
|
4997
4997
|
items: z.array(itemSchema),
|
|
4998
4998
|
total: z.number(),
|
|
@@ -5001,35 +5001,59 @@ export const paginatedResponseSchema = <T extends z.ZodTypeAny>(itemSchema: T) =
|
|
|
5001
5001
|
totalPages: z.number(),
|
|
5002
5002
|
});
|
|
5003
5003
|
|
|
5004
|
+
// ============================================
|
|
5005
|
+
// Type Exports
|
|
5006
|
+
// ============================================
|
|
5007
|
+
|
|
5008
|
+
export type Id = z.infer<typeof IdSchema>;
|
|
5009
|
+
export type Timestamps = z.infer<typeof TimestampsSchema>;
|
|
5010
|
+
export type Pagination = z.infer<typeof PaginationSchema>;
|
|
5011
|
+
`;
|
|
5012
|
+
const userTs = `import { z } from 'zod';
|
|
5013
|
+
import { IdSchema, TimestampsSchema } from './common.js';
|
|
5014
|
+
|
|
5004
5015
|
// ============================================
|
|
5005
5016
|
// User Schemas
|
|
5006
5017
|
// ============================================
|
|
5007
5018
|
|
|
5008
|
-
export const
|
|
5009
|
-
id:
|
|
5019
|
+
export const UserSchema = z.object({
|
|
5020
|
+
id: IdSchema,
|
|
5010
5021
|
email: z.string().email(),
|
|
5011
5022
|
name: z.string().min(1).max(100),
|
|
5012
|
-
...
|
|
5023
|
+
...TimestampsSchema.shape,
|
|
5013
5024
|
});
|
|
5014
5025
|
|
|
5015
|
-
export const
|
|
5026
|
+
export const CreateUserSchema = UserSchema.omit({
|
|
5016
5027
|
id: true,
|
|
5017
5028
|
createdAt: true,
|
|
5018
5029
|
updatedAt: true,
|
|
5019
5030
|
});
|
|
5020
5031
|
|
|
5021
|
-
export const
|
|
5032
|
+
export const UpdateUserSchema = CreateUserSchema.partial();
|
|
5033
|
+
|
|
5034
|
+
// ============================================
|
|
5035
|
+
// Response Schemas
|
|
5036
|
+
// ============================================
|
|
5037
|
+
|
|
5038
|
+
export const UserResponseSchema = UserSchema.pick({
|
|
5039
|
+
id: true,
|
|
5040
|
+
name: true,
|
|
5041
|
+
email: true,
|
|
5042
|
+
});
|
|
5043
|
+
|
|
5044
|
+
export const ListUsersResponseSchema = z.object({
|
|
5045
|
+
users: z.array(UserSchema.pick({ id: true, name: true })),
|
|
5046
|
+
});
|
|
5022
5047
|
|
|
5023
5048
|
// ============================================
|
|
5024
5049
|
// Type Exports
|
|
5025
5050
|
// ============================================
|
|
5026
5051
|
|
|
5027
|
-
export type
|
|
5028
|
-
export type
|
|
5029
|
-
export type
|
|
5030
|
-
export type
|
|
5031
|
-
export type
|
|
5032
|
-
export type UpdateUser = z.infer<typeof updateUserSchema>;
|
|
5052
|
+
export type User = z.infer<typeof UserSchema>;
|
|
5053
|
+
export type CreateUser = z.infer<typeof CreateUserSchema>;
|
|
5054
|
+
export type UpdateUser = z.infer<typeof UpdateUserSchema>;
|
|
5055
|
+
export type UserResponse = z.infer<typeof UserResponseSchema>;
|
|
5056
|
+
export type ListUsersResponse = z.infer<typeof ListUsersResponseSchema>;
|
|
5033
5057
|
`;
|
|
5034
5058
|
return [
|
|
5035
5059
|
{
|
|
@@ -5041,8 +5065,12 @@ export type UpdateUser = z.infer<typeof updateUserSchema>;
|
|
|
5041
5065
|
content: `${JSON.stringify(tsConfig, null, 2)}\n`
|
|
5042
5066
|
},
|
|
5043
5067
|
{
|
|
5044
|
-
path: "packages/models/src/
|
|
5045
|
-
content:
|
|
5068
|
+
path: "packages/models/src/common.ts",
|
|
5069
|
+
content: commonTs
|
|
5070
|
+
},
|
|
5071
|
+
{
|
|
5072
|
+
path: "packages/models/src/user.ts",
|
|
5073
|
+
content: userTs
|
|
5046
5074
|
}
|
|
5047
5075
|
];
|
|
5048
5076
|
}
|
|
@@ -5347,6 +5375,7 @@ const apiTemplate = {
|
|
|
5347
5375
|
"@geekmidas/envkit": GEEKMIDAS_VERSIONS["@geekmidas/envkit"],
|
|
5348
5376
|
"@geekmidas/events": GEEKMIDAS_VERSIONS["@geekmidas/events"],
|
|
5349
5377
|
"@geekmidas/logger": GEEKMIDAS_VERSIONS["@geekmidas/logger"],
|
|
5378
|
+
"@geekmidas/rate-limit": GEEKMIDAS_VERSIONS["@geekmidas/rate-limit"],
|
|
5350
5379
|
"@geekmidas/schema": GEEKMIDAS_VERSIONS["@geekmidas/schema"],
|
|
5351
5380
|
"@geekmidas/services": GEEKMIDAS_VERSIONS["@geekmidas/services"],
|
|
5352
5381
|
"@geekmidas/errors": GEEKMIDAS_VERSIONS["@geekmidas/errors"],
|
|
@@ -5375,11 +5404,12 @@ const apiTemplate = {
|
|
|
5375
5404
|
"fmt:check": "biome format ."
|
|
5376
5405
|
},
|
|
5377
5406
|
files: (options) => {
|
|
5378
|
-
const { loggerType, routesStructure } = options;
|
|
5407
|
+
const { loggerType, routesStructure, monorepo, name: name$1 } = options;
|
|
5379
5408
|
const loggerContent = `import { createLogger } from '@geekmidas/logger/${loggerType}';
|
|
5380
5409
|
|
|
5381
5410
|
export const logger = createLogger();
|
|
5382
5411
|
`;
|
|
5412
|
+
const modelsImport = monorepo ? `@${name$1}/models` : null;
|
|
5383
5413
|
const getRoutePath = (file) => {
|
|
5384
5414
|
switch (routesStructure) {
|
|
5385
5415
|
case "centralized-endpoints": return `src/endpoints/${file}`;
|
|
@@ -5416,9 +5446,14 @@ export const config = envParser
|
|
|
5416
5446
|
{
|
|
5417
5447
|
path: getRoutePath("health.ts"),
|
|
5418
5448
|
content: `import { e } from '@geekmidas/constructs/endpoints';
|
|
5449
|
+
import { z } from 'zod';
|
|
5419
5450
|
|
|
5420
5451
|
export const healthEndpoint = e
|
|
5421
5452
|
.get('/health')
|
|
5453
|
+
.output(z.object({
|
|
5454
|
+
status: z.string(),
|
|
5455
|
+
timestamp: z.string(),
|
|
5456
|
+
}))
|
|
5422
5457
|
.handle(async () => ({
|
|
5423
5458
|
status: 'ok',
|
|
5424
5459
|
timestamp: new Date().toISOString(),
|
|
@@ -5427,10 +5462,31 @@ export const healthEndpoint = e
|
|
|
5427
5462
|
},
|
|
5428
5463
|
{
|
|
5429
5464
|
path: getRoutePath("users/list.ts"),
|
|
5430
|
-
content: `import { e } from '@geekmidas/constructs/endpoints';
|
|
5465
|
+
content: modelsImport ? `import { e } from '@geekmidas/constructs/endpoints';
|
|
5466
|
+
import { ListUsersResponseSchema } from '${modelsImport}/user';
|
|
5467
|
+
|
|
5468
|
+
export const listUsersEndpoint = e
|
|
5469
|
+
.get('/users')
|
|
5470
|
+
.output(ListUsersResponseSchema)
|
|
5471
|
+
.handle(async () => ({
|
|
5472
|
+
users: [
|
|
5473
|
+
{ id: '1', name: 'Alice' },
|
|
5474
|
+
{ id: '2', name: 'Bob' },
|
|
5475
|
+
],
|
|
5476
|
+
}));
|
|
5477
|
+
` : `import { e } from '@geekmidas/constructs/endpoints';
|
|
5478
|
+
import { z } from 'zod';
|
|
5479
|
+
|
|
5480
|
+
const UserSchema = z.object({
|
|
5481
|
+
id: z.string(),
|
|
5482
|
+
name: z.string(),
|
|
5483
|
+
});
|
|
5431
5484
|
|
|
5432
5485
|
export const listUsersEndpoint = e
|
|
5433
5486
|
.get('/users')
|
|
5487
|
+
.output(z.object({
|
|
5488
|
+
users: z.array(UserSchema),
|
|
5489
|
+
}))
|
|
5434
5490
|
.handle(async () => ({
|
|
5435
5491
|
users: [
|
|
5436
5492
|
{ id: '1', name: 'Alice' },
|
|
@@ -5441,12 +5497,30 @@ export const listUsersEndpoint = e
|
|
|
5441
5497
|
},
|
|
5442
5498
|
{
|
|
5443
5499
|
path: getRoutePath("users/get.ts"),
|
|
5444
|
-
content: `import { e } from '@geekmidas/constructs/endpoints';
|
|
5500
|
+
content: modelsImport ? `import { e } from '@geekmidas/constructs/endpoints';
|
|
5501
|
+
import { z } from 'zod';
|
|
5502
|
+
import { UserResponseSchema } from '${modelsImport}/user';
|
|
5503
|
+
|
|
5504
|
+
export const getUserEndpoint = e
|
|
5505
|
+
.get('/users/:id')
|
|
5506
|
+
.params(z.object({ id: z.string() }))
|
|
5507
|
+
.output(UserResponseSchema)
|
|
5508
|
+
.handle(async ({ params }) => ({
|
|
5509
|
+
id: params.id,
|
|
5510
|
+
name: 'Alice',
|
|
5511
|
+
email: 'alice@example.com',
|
|
5512
|
+
}));
|
|
5513
|
+
` : `import { e } from '@geekmidas/constructs/endpoints';
|
|
5445
5514
|
import { z } from 'zod';
|
|
5446
5515
|
|
|
5447
5516
|
export const getUserEndpoint = e
|
|
5448
5517
|
.get('/users/:id')
|
|
5449
5518
|
.params(z.object({ id: z.string() }))
|
|
5519
|
+
.output(z.object({
|
|
5520
|
+
id: z.string(),
|
|
5521
|
+
name: z.string(),
|
|
5522
|
+
email: z.string().email(),
|
|
5523
|
+
}))
|
|
5450
5524
|
.handle(async ({ params }) => ({
|
|
5451
5525
|
id: params.id,
|
|
5452
5526
|
name: 'Alice',
|
|
@@ -5554,6 +5628,7 @@ const minimalTemplate = {
|
|
|
5554
5628
|
"@geekmidas/constructs": GEEKMIDAS_VERSIONS["@geekmidas/constructs"],
|
|
5555
5629
|
"@geekmidas/envkit": GEEKMIDAS_VERSIONS["@geekmidas/envkit"],
|
|
5556
5630
|
"@geekmidas/logger": GEEKMIDAS_VERSIONS["@geekmidas/logger"],
|
|
5631
|
+
"@geekmidas/rate-limit": GEEKMIDAS_VERSIONS["@geekmidas/rate-limit"],
|
|
5557
5632
|
"@geekmidas/schema": GEEKMIDAS_VERSIONS["@geekmidas/schema"],
|
|
5558
5633
|
"@hono/node-server": "~1.14.1",
|
|
5559
5634
|
hono: "~4.8.2",
|
|
@@ -5616,9 +5691,14 @@ export const config = envParser
|
|
|
5616
5691
|
{
|
|
5617
5692
|
path: getRoutePath("health.ts"),
|
|
5618
5693
|
content: `import { e } from '@geekmidas/constructs/endpoints';
|
|
5694
|
+
import { z } from 'zod';
|
|
5619
5695
|
|
|
5620
5696
|
export const healthEndpoint = e
|
|
5621
5697
|
.get('/health')
|
|
5698
|
+
.output(z.object({
|
|
5699
|
+
status: z.string(),
|
|
5700
|
+
timestamp: z.string(),
|
|
5701
|
+
}))
|
|
5622
5702
|
.handle(async () => ({
|
|
5623
5703
|
status: 'ok',
|
|
5624
5704
|
timestamp: new Date().toISOString(),
|
|
@@ -5721,6 +5801,7 @@ const serverlessTemplate = {
|
|
|
5721
5801
|
"@geekmidas/envkit": GEEKMIDAS_VERSIONS["@geekmidas/envkit"],
|
|
5722
5802
|
"@geekmidas/logger": GEEKMIDAS_VERSIONS["@geekmidas/logger"],
|
|
5723
5803
|
"@geekmidas/cloud": GEEKMIDAS_VERSIONS["@geekmidas/cloud"],
|
|
5804
|
+
"@geekmidas/rate-limit": GEEKMIDAS_VERSIONS["@geekmidas/rate-limit"],
|
|
5724
5805
|
"@geekmidas/schema": GEEKMIDAS_VERSIONS["@geekmidas/schema"],
|
|
5725
5806
|
"@hono/node-server": "~1.14.1",
|
|
5726
5807
|
hono: "~4.8.2",
|
|
@@ -5784,9 +5865,15 @@ export const config = envParser
|
|
|
5784
5865
|
{
|
|
5785
5866
|
path: getRoutePath("health.ts"),
|
|
5786
5867
|
content: `import { e } from '@geekmidas/constructs/endpoints';
|
|
5868
|
+
import { z } from 'zod';
|
|
5787
5869
|
|
|
5788
5870
|
export const healthEndpoint = e
|
|
5789
5871
|
.get('/health')
|
|
5872
|
+
.output(z.object({
|
|
5873
|
+
status: z.string(),
|
|
5874
|
+
timestamp: z.string(),
|
|
5875
|
+
region: z.string(),
|
|
5876
|
+
}))
|
|
5790
5877
|
.handle(async () => ({
|
|
5791
5878
|
status: 'ok',
|
|
5792
5879
|
timestamp: new Date().toISOString(),
|
|
@@ -5835,6 +5922,7 @@ const workerTemplate = {
|
|
|
5835
5922
|
"@geekmidas/envkit": GEEKMIDAS_VERSIONS["@geekmidas/envkit"],
|
|
5836
5923
|
"@geekmidas/events": GEEKMIDAS_VERSIONS["@geekmidas/events"],
|
|
5837
5924
|
"@geekmidas/logger": GEEKMIDAS_VERSIONS["@geekmidas/logger"],
|
|
5925
|
+
"@geekmidas/rate-limit": GEEKMIDAS_VERSIONS["@geekmidas/rate-limit"],
|
|
5838
5926
|
"@geekmidas/schema": GEEKMIDAS_VERSIONS["@geekmidas/schema"],
|
|
5839
5927
|
"@hono/node-server": "~1.14.1",
|
|
5840
5928
|
hono: "~4.8.2",
|
|
@@ -5897,9 +5985,14 @@ export const config = envParser
|
|
|
5897
5985
|
{
|
|
5898
5986
|
path: getRoutePath("health.ts"),
|
|
5899
5987
|
content: `import { e } from '@geekmidas/constructs/endpoints';
|
|
5988
|
+
import { z } from 'zod';
|
|
5900
5989
|
|
|
5901
5990
|
export const healthEndpoint = e
|
|
5902
5991
|
.get('/health')
|
|
5992
|
+
.output(z.object({
|
|
5993
|
+
status: z.string(),
|
|
5994
|
+
timestamp: z.string(),
|
|
5995
|
+
}))
|
|
5903
5996
|
.handle(async () => ({
|
|
5904
5997
|
status: 'ok',
|
|
5905
5998
|
timestamp: new Date().toISOString(),
|