@geekmidas/cli 0.9.0 → 0.12.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 (146) hide show
  1. package/README.md +525 -0
  2. package/dist/bundler-DRXCw_YR.mjs +70 -0
  3. package/dist/bundler-DRXCw_YR.mjs.map +1 -0
  4. package/dist/bundler-WsEvH_b2.cjs +71 -0
  5. package/dist/bundler-WsEvH_b2.cjs.map +1 -0
  6. package/dist/{config-CFls09Ey.cjs → config-AmInkU7k.cjs} +10 -8
  7. package/dist/config-AmInkU7k.cjs.map +1 -0
  8. package/dist/{config-Bq72aj8e.mjs → config-DYULeEv8.mjs} +6 -4
  9. package/dist/config-DYULeEv8.mjs.map +1 -0
  10. package/dist/config.cjs +1 -1
  11. package/dist/config.d.cts +2 -1
  12. package/dist/config.d.cts.map +1 -0
  13. package/dist/config.d.mts +2 -1
  14. package/dist/config.d.mts.map +1 -0
  15. package/dist/config.mjs +1 -1
  16. package/dist/encryption-C8H-38Yy.mjs +42 -0
  17. package/dist/encryption-C8H-38Yy.mjs.map +1 -0
  18. package/dist/encryption-Dyf_r1h-.cjs +44 -0
  19. package/dist/encryption-Dyf_r1h-.cjs.map +1 -0
  20. package/dist/index.cjs +2125 -184
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.mjs +2143 -197
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/{openapi--vOy9mo4.mjs → openapi-BfFlOBCG.mjs} +812 -49
  25. package/dist/openapi-BfFlOBCG.mjs.map +1 -0
  26. package/dist/{openapi-CHhTPief.cjs → openapi-Bt_1FDpT.cjs} +805 -42
  27. package/dist/openapi-Bt_1FDpT.cjs.map +1 -0
  28. package/dist/{openapi-react-query-o5iMi8tz.cjs → openapi-react-query-B-sNWHFU.cjs} +5 -5
  29. package/dist/openapi-react-query-B-sNWHFU.cjs.map +1 -0
  30. package/dist/{openapi-react-query-CcciaVu5.mjs → openapi-react-query-B6XTeGqS.mjs} +5 -5
  31. package/dist/openapi-react-query-B6XTeGqS.mjs.map +1 -0
  32. package/dist/openapi-react-query.cjs +1 -1
  33. package/dist/openapi-react-query.d.cts.map +1 -0
  34. package/dist/openapi-react-query.d.mts.map +1 -0
  35. package/dist/openapi-react-query.mjs +1 -1
  36. package/dist/openapi.cjs +2 -2
  37. package/dist/openapi.d.cts +1 -1
  38. package/dist/openapi.d.cts.map +1 -0
  39. package/dist/openapi.d.mts +1 -1
  40. package/dist/openapi.d.mts.map +1 -0
  41. package/dist/openapi.mjs +2 -2
  42. package/dist/storage-BUYQJgz7.cjs +4 -0
  43. package/dist/storage-BXoJvmv2.cjs +149 -0
  44. package/dist/storage-BXoJvmv2.cjs.map +1 -0
  45. package/dist/storage-C9PU_30f.mjs +101 -0
  46. package/dist/storage-C9PU_30f.mjs.map +1 -0
  47. package/dist/storage-DLJAYxzJ.mjs +3 -0
  48. package/dist/{types-b-vwGpqc.d.cts → types-BR0M2v_c.d.mts} +100 -1
  49. package/dist/types-BR0M2v_c.d.mts.map +1 -0
  50. package/dist/{types-DXgiA1sF.d.mts → types-BhkZc-vm.d.cts} +100 -1
  51. package/dist/types-BhkZc-vm.d.cts.map +1 -0
  52. package/examples/cron-example.ts +27 -27
  53. package/examples/env.ts +27 -27
  54. package/examples/function-example.ts +31 -31
  55. package/examples/gkm.config.json +20 -20
  56. package/examples/gkm.config.ts +8 -8
  57. package/examples/gkm.minimal.config.json +5 -5
  58. package/examples/gkm.production.config.json +25 -25
  59. package/examples/logger.ts +2 -2
  60. package/package.json +6 -6
  61. package/src/__tests__/EndpointGenerator.hooks.spec.ts +191 -191
  62. package/src/__tests__/config.spec.ts +55 -55
  63. package/src/__tests__/loadEnvFiles.spec.ts +93 -93
  64. package/src/__tests__/normalizeHooksConfig.spec.ts +58 -58
  65. package/src/__tests__/openapi-react-query.spec.ts +497 -497
  66. package/src/__tests__/openapi.spec.ts +428 -428
  67. package/src/__tests__/test-helpers.ts +77 -76
  68. package/src/auth/__tests__/credentials.spec.ts +204 -0
  69. package/src/auth/__tests__/index.spec.ts +168 -0
  70. package/src/auth/credentials.ts +187 -0
  71. package/src/auth/index.ts +226 -0
  72. package/src/build/__tests__/index-new.spec.ts +474 -474
  73. package/src/build/__tests__/manifests.spec.ts +333 -333
  74. package/src/build/bundler.ts +141 -0
  75. package/src/build/endpoint-analyzer.ts +236 -0
  76. package/src/build/handler-templates.ts +1253 -0
  77. package/src/build/index.ts +250 -179
  78. package/src/build/manifests.ts +52 -52
  79. package/src/build/providerResolver.ts +145 -145
  80. package/src/build/types.ts +64 -43
  81. package/src/config.ts +39 -37
  82. package/src/deploy/__tests__/docker.spec.ts +111 -0
  83. package/src/deploy/__tests__/dokploy.spec.ts +245 -0
  84. package/src/deploy/__tests__/init.spec.ts +662 -0
  85. package/src/deploy/docker.ts +128 -0
  86. package/src/deploy/dokploy.ts +204 -0
  87. package/src/deploy/index.ts +136 -0
  88. package/src/deploy/init.ts +484 -0
  89. package/src/deploy/types.ts +48 -0
  90. package/src/dev/__tests__/index.spec.ts +266 -266
  91. package/src/dev/index.ts +647 -593
  92. package/src/docker/__tests__/compose.spec.ts +531 -0
  93. package/src/docker/__tests__/templates.spec.ts +280 -0
  94. package/src/docker/compose.ts +273 -0
  95. package/src/docker/index.ts +230 -0
  96. package/src/docker/templates.ts +446 -0
  97. package/src/generators/CronGenerator.ts +72 -72
  98. package/src/generators/EndpointGenerator.ts +699 -398
  99. package/src/generators/FunctionGenerator.ts +84 -84
  100. package/src/generators/Generator.ts +72 -72
  101. package/src/generators/OpenApiTsGenerator.ts +589 -589
  102. package/src/generators/SubscriberGenerator.ts +124 -124
  103. package/src/generators/__tests__/CronGenerator.spec.ts +433 -433
  104. package/src/generators/__tests__/EndpointGenerator.spec.ts +532 -382
  105. package/src/generators/__tests__/FunctionGenerator.spec.ts +244 -244
  106. package/src/generators/__tests__/SubscriberGenerator.spec.ts +397 -382
  107. package/src/generators/index.ts +4 -4
  108. package/src/index.ts +628 -206
  109. package/src/init/__tests__/generators.spec.ts +334 -334
  110. package/src/init/__tests__/init.spec.ts +332 -332
  111. package/src/init/__tests__/utils.spec.ts +89 -89
  112. package/src/init/generators/config.ts +175 -175
  113. package/src/init/generators/docker.ts +41 -41
  114. package/src/init/generators/env.ts +72 -72
  115. package/src/init/generators/index.ts +1 -1
  116. package/src/init/generators/models.ts +64 -64
  117. package/src/init/generators/monorepo.ts +161 -161
  118. package/src/init/generators/package.ts +71 -71
  119. package/src/init/generators/source.ts +6 -6
  120. package/src/init/index.ts +203 -208
  121. package/src/init/templates/api.ts +115 -115
  122. package/src/init/templates/index.ts +75 -75
  123. package/src/init/templates/minimal.ts +98 -98
  124. package/src/init/templates/serverless.ts +89 -89
  125. package/src/init/templates/worker.ts +98 -98
  126. package/src/init/utils.ts +54 -56
  127. package/src/openapi-react-query.ts +194 -194
  128. package/src/openapi.ts +63 -63
  129. package/src/secrets/__tests__/encryption.spec.ts +226 -0
  130. package/src/secrets/__tests__/generator.spec.ts +319 -0
  131. package/src/secrets/__tests__/index.spec.ts +91 -0
  132. package/src/secrets/__tests__/storage.spec.ts +403 -0
  133. package/src/secrets/encryption.ts +91 -0
  134. package/src/secrets/generator.ts +164 -0
  135. package/src/secrets/index.ts +383 -0
  136. package/src/secrets/storage.ts +134 -0
  137. package/src/secrets/types.ts +53 -0
  138. package/src/types.ts +295 -176
  139. package/tsconfig.json +9 -0
  140. package/tsdown.config.ts +11 -8
  141. package/dist/config-Bq72aj8e.mjs.map +0 -1
  142. package/dist/config-CFls09Ey.cjs.map +0 -1
  143. package/dist/openapi--vOy9mo4.mjs.map +0 -1
  144. package/dist/openapi-CHhTPief.cjs.map +0 -1
  145. package/dist/openapi-react-query-CcciaVu5.mjs.map +0 -1
  146. package/dist/openapi-react-query-o5iMi8tz.cjs.map +0 -1
package/src/types.ts CHANGED
@@ -1,239 +1,358 @@
1
1
  export type MainProvider = 'aws' | 'server';
2
2
  export type LegacyProvider =
3
- | 'server'
4
- | 'aws-apigatewayv1'
5
- | 'aws-apigatewayv2'
6
- | 'aws-lambda';
3
+ | 'server'
4
+ | 'aws-apigatewayv1'
5
+ | 'aws-apigatewayv2'
6
+ | 'aws-lambda';
7
7
 
8
8
  export type Routes = string | string[];
9
9
 
10
10
  export interface ProviderConfig {
11
- enabled?: boolean;
12
- outputDir?: string;
11
+ enabled?: boolean;
12
+ outputDir?: string;
13
13
  }
14
14
 
15
15
  export interface AWSApiGatewayConfig extends ProviderConfig {
16
- // Additional AWS API Gateway specific options
16
+ // Additional AWS API Gateway specific options
17
17
  }
18
18
 
19
19
  export interface AWSLambdaConfig extends ProviderConfig {
20
- // Additional AWS Lambda specific options
20
+ // Additional AWS Lambda specific options
21
+ }
22
+
23
+ export interface ProductionConfig {
24
+ /** Enable production mode (default: false) */
25
+ enabled?: boolean;
26
+ /** Bundle server into single file (default: true) */
27
+ bundle?: boolean;
28
+ /** Minify bundled output (default: true) */
29
+ minify?: boolean;
30
+ /** Health check endpoint path (default: '/health') */
31
+ healthCheck?: string;
32
+ /** Enable graceful shutdown handling (default: true) */
33
+ gracefulShutdown?: boolean;
34
+ /** Packages to exclude from bundling (default: []) */
35
+ external?: string[];
36
+ /** Include subscribers in production build (default: 'exclude' for serverless) */
37
+ subscribers?: 'include' | 'exclude';
38
+ /** Include OpenAPI spec in production (default: false) */
39
+ openapi?: boolean;
40
+ /**
41
+ * Enable build-time optimized handler generation (default: true)
42
+ * Generates specialized handlers based on endpoint tier:
43
+ * - minimal: Near-raw-Hono performance for simple endpoints
44
+ * - standard: Optimized handlers for auth/services
45
+ * - full: Uses HonoEndpoint.addRoutes for complex endpoints
46
+ */
47
+ optimizedHandlers?: boolean;
48
+ }
49
+
50
+ /** Service-specific configuration for docker-compose */
51
+ export interface ServiceConfig {
52
+ /**
53
+ * Full Docker image reference (e.g., 'postgis/postgis:16-3.4-alpine').
54
+ * When specified, overrides the default image entirely.
55
+ */
56
+ image?: string;
57
+ /**
58
+ * Docker image version/tag (e.g., '15-alpine' for postgres).
59
+ * Only used when `image` is not specified.
60
+ */
61
+ version?: string;
62
+ }
63
+
64
+ /** Supported docker-compose service names */
65
+ export type ComposeServiceName = 'postgres' | 'redis' | 'rabbitmq';
66
+
67
+ /** Services configuration - can be boolean (use defaults) or object with version */
68
+ export type ComposeServicesConfig = {
69
+ [K in ComposeServiceName]?: boolean | ServiceConfig;
70
+ };
71
+
72
+ export interface DockerConfig {
73
+ /** Container registry URL (e.g., 'ghcr.io/myorg') */
74
+ registry?: string;
75
+ /** Docker image name (default: derived from package.json name) */
76
+ imageName?: string;
77
+ /** Base Docker image (default: 'node:22-alpine') */
78
+ baseImage?: string;
79
+ /** Container port (default: 3000) */
80
+ port?: number;
81
+ /** docker-compose services to include */
82
+ compose?: {
83
+ /**
84
+ * Services to include in docker-compose.
85
+ * Can be an object with service configs or an array of service names (legacy).
86
+ *
87
+ * @example Object format (recommended)
88
+ * services: {
89
+ * postgres: { version: '15-alpine' },
90
+ * redis: true, // use default version
91
+ * }
92
+ *
93
+ * @example Array format (legacy, uses default versions)
94
+ * services: ['postgres', 'redis']
95
+ */
96
+ services?: ComposeServicesConfig | ComposeServiceName[];
97
+ };
21
98
  }
22
99
 
23
100
  export interface ServerConfig extends ProviderConfig {
24
- enableOpenApi?: boolean;
25
- port?: number;
101
+ enableOpenApi?: boolean;
102
+ port?: number;
103
+ /** Production build configuration */
104
+ production?: ProductionConfig;
26
105
  }
27
106
 
28
107
  export type Runtime = 'node' | 'bun';
29
108
 
30
109
  export interface TelescopeConfig {
31
- /** Enable/disable telescope (default: true in development) */
32
- enabled?: boolean;
33
- /** Port for telescope to use (defaults to server port) */
34
- port?: number;
35
- /** Path prefix for telescope UI (default: /__telescope) */
36
- path?: string;
37
- /** Ignore patterns for telescope (e.g., ['/health', '/metrics']) */
38
- ignore?: string[];
39
- /** Record request/response bodies (default: true) */
40
- recordBody?: boolean;
41
- /** Maximum entries to keep in memory (default: 1000) */
42
- maxEntries?: number;
43
- /** Enable WebSocket for real-time updates (default: true, requires @hono/node-ws for Node.js) */
44
- websocket?: boolean;
110
+ /** Enable/disable telescope (default: true in development) */
111
+ enabled?: boolean;
112
+ /** Port for telescope to use (defaults to server port) */
113
+ port?: number;
114
+ /** Path prefix for telescope UI (default: /__telescope) */
115
+ path?: string;
116
+ /** Ignore patterns for telescope (e.g., ['/health', '/metrics']) */
117
+ ignore?: string[];
118
+ /** Record request/response bodies (default: true) */
119
+ recordBody?: boolean;
120
+ /** Maximum entries to keep in memory (default: 1000) */
121
+ maxEntries?: number;
122
+ /** Enable WebSocket for real-time updates (default: true, requires @hono/node-ws for Node.js) */
123
+ websocket?: boolean;
45
124
  }
46
125
 
47
126
  export interface StudioConfig {
48
- /** Enable/disable studio (default: true in development) */
49
- enabled?: boolean;
50
- /** Path prefix for studio UI (default: /__studio) */
51
- path?: string;
52
- /** Schema to introspect (default: 'public') */
53
- schema?: string;
127
+ /** Enable/disable studio (default: true in development) */
128
+ enabled?: boolean;
129
+ /** Path prefix for studio UI (default: /__studio) */
130
+ path?: string;
131
+ /** Schema to introspect (default: 'public') */
132
+ schema?: string;
54
133
  }
55
134
 
56
135
  export interface OpenApiConfig {
57
- /** Enable OpenAPI generation (default: true) */
58
- enabled?: boolean;
59
- /** API title */
60
- title?: string;
61
- /** API version */
62
- version?: string;
63
- /** API description */
64
- description?: string;
136
+ /** Enable OpenAPI generation (default: true) */
137
+ enabled?: boolean;
138
+ /** API title */
139
+ title?: string;
140
+ /** API version */
141
+ version?: string;
142
+ /** API description */
143
+ description?: string;
65
144
  }
66
145
 
67
146
  export interface HooksConfig {
68
- /**
69
- * Path to a module exporting server lifecycle hooks.
70
- * The module should export `beforeSetup` and/or `afterSetup` functions.
71
- *
72
- * @example
73
- * ```typescript
74
- * // src/config/hooks.ts
75
- * import type { Hono } from 'hono';
76
- * import type { Logger } from '@geekmidas/logger';
77
- * import type { EnvironmentParser } from '@geekmidas/envkit';
78
- *
79
- * // Called BEFORE gkm endpoints are registered
80
- * export function beforeSetup(app: Hono, ctx: { envParser: EnvironmentParser; logger: Logger }) {
81
- * app.use('*', cors());
82
- * app.get('/custom/health', (c) => c.json({ status: 'ok' }));
83
- * }
84
- *
85
- * // Called AFTER gkm endpoints are registered
86
- * export function afterSetup(app: Hono, ctx: { envParser: EnvironmentParser; logger: Logger }) {
87
- * app.notFound((c) => c.json({ error: 'Not found' }, 404));
88
- * app.onError((err, c) => c.json({ error: err.message }, 500));
89
- * }
90
- * ```
91
- */
92
- server?: string;
147
+ /**
148
+ * Path to a module exporting server lifecycle hooks.
149
+ * The module should export `beforeSetup` and/or `afterSetup` functions.
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * // src/config/hooks.ts
154
+ * import type { Hono } from 'hono';
155
+ * import type { Logger } from '@geekmidas/logger';
156
+ * import type { EnvironmentParser } from '@geekmidas/envkit';
157
+ *
158
+ * // Called BEFORE gkm endpoints are registered
159
+ * export function beforeSetup(app: Hono, ctx: { envParser: EnvironmentParser; logger: Logger }) {
160
+ * app.use('*', cors());
161
+ * app.get('/custom/health', (c) => c.json({ status: 'ok' }));
162
+ * }
163
+ *
164
+ * // Called AFTER gkm endpoints are registered
165
+ * export function afterSetup(app: Hono, ctx: { envParser: EnvironmentParser; logger: Logger }) {
166
+ * app.notFound((c) => c.json({ error: 'Not found' }, 404));
167
+ * app.onError((err, c) => c.json({ error: err.message }, 500));
168
+ * }
169
+ * ```
170
+ */
171
+ server?: string;
172
+ }
173
+
174
+ /** Dokploy deployment configuration */
175
+ export interface DokployProviderConfig {
176
+ /** Dokploy API endpoint (e.g., 'https://dokploy.example.com') */
177
+ endpoint: string;
178
+ /** Project ID in Dokploy */
179
+ projectId: string;
180
+ /** Application ID in Dokploy */
181
+ applicationId: string;
182
+ /** Container registry (overrides docker.registry if set) */
183
+ registry?: string;
93
184
  }
94
185
 
95
186
  export interface ProvidersConfig {
96
- aws?: {
97
- apiGateway?: {
98
- v1?: boolean | AWSApiGatewayConfig;
99
- v2?: boolean | AWSApiGatewayConfig;
100
- };
101
- lambda?: {
102
- functions?: boolean | AWSLambdaConfig;
103
- crons?: boolean | AWSLambdaConfig;
104
- };
105
- };
106
- server?: boolean | ServerConfig;
187
+ aws?: {
188
+ apiGateway?: {
189
+ v1?: boolean | AWSApiGatewayConfig;
190
+ v2?: boolean | AWSApiGatewayConfig;
191
+ };
192
+ lambda?: {
193
+ functions?: boolean | AWSLambdaConfig;
194
+ crons?: boolean | AWSLambdaConfig;
195
+ };
196
+ };
197
+ server?: boolean | ServerConfig;
198
+ /** Dokploy deployment configuration */
199
+ dokploy?: boolean | DokployProviderConfig;
107
200
  }
108
201
 
109
202
  export interface GkmConfig {
110
- routes: Routes;
111
- functions?: Routes;
112
- crons?: Routes;
113
- subscribers?: Routes;
114
- envParser: string;
115
- logger: string;
116
- providers?: ProvidersConfig;
117
- /**
118
- * Server lifecycle hooks for customizing the Hono app.
119
- * Allows adding custom routes, middleware, error handlers, etc.
120
- *
121
- * @example
122
- * hooks: {
123
- * server: './src/config/hooks'
124
- * }
125
- */
126
- hooks?: HooksConfig;
127
- /**
128
- * Telescope configuration for debugging/monitoring.
129
- * Can be:
130
- * - A string path to a module that exports a Telescope instance (recommended)
131
- * - A boolean to enable/disable with defaults
132
- * - A TelescopeConfig object for inline configuration
133
- */
134
- telescope?: string | boolean | TelescopeConfig;
135
- /**
136
- * Studio configuration for database browsing.
137
- * Can be:
138
- * - A string path to a module that exports a Studio instance (recommended)
139
- * - A boolean to enable/disable with defaults
140
- * - A StudioConfig object for inline configuration
141
- *
142
- * Requires a database connection configured via services.
143
- */
144
- studio?: string | boolean | StudioConfig;
145
- /**
146
- * OpenAPI generation configuration.
147
- * Can be:
148
- * - A boolean to enable/disable with defaults (output: ./src/api/openapi.ts)
149
- * - An OpenApiConfig object for customization
150
- *
151
- * When enabled, OpenAPI spec is generated on startup and regenerated on route changes.
152
- *
153
- * @example
154
- * openapi: true
155
- *
156
- * @example
157
- * openapi: {
158
- * output: './src/api/openapi.ts',
159
- * title: 'My API',
160
- * version: '1.0.0',
161
- * }
162
- */
163
- openapi?: boolean | OpenApiConfig;
164
- /** Runtime to use for dev server (default: 'node') */
165
- runtime?: Runtime;
166
- /**
167
- * Environment file(s) to load for development.
168
- * Can be:
169
- * - A string path to a single env file (e.g., '.env.local')
170
- * - An array of paths to load in order (later files override earlier)
171
- * - Defaults to '.env' if not specified
172
- *
173
- * @example
174
- * env: '.env.local'
175
- *
176
- * @example
177
- * env: ['.env', '.env.local']
178
- */
179
- env?: string | string[];
203
+ routes: Routes;
204
+ functions?: Routes;
205
+ crons?: Routes;
206
+ subscribers?: Routes;
207
+ envParser: string;
208
+ logger: string;
209
+ providers?: ProvidersConfig;
210
+ /**
211
+ * Server lifecycle hooks for customizing the Hono app.
212
+ * Allows adding custom routes, middleware, error handlers, etc.
213
+ *
214
+ * @example
215
+ * hooks: {
216
+ * server: './src/config/hooks'
217
+ * }
218
+ */
219
+ hooks?: HooksConfig;
220
+ /**
221
+ * Telescope configuration for debugging/monitoring.
222
+ * Can be:
223
+ * - A string path to a module that exports a Telescope instance (recommended)
224
+ * - A boolean to enable/disable with defaults
225
+ * - A TelescopeConfig object for inline configuration
226
+ */
227
+ telescope?: string | boolean | TelescopeConfig;
228
+ /**
229
+ * Studio configuration for database browsing.
230
+ * Can be:
231
+ * - A string path to a module that exports a Studio instance (recommended)
232
+ * - A boolean to enable/disable with defaults
233
+ * - A StudioConfig object for inline configuration
234
+ *
235
+ * Requires a database connection configured via services.
236
+ */
237
+ studio?: string | boolean | StudioConfig;
238
+ /**
239
+ * OpenAPI generation configuration.
240
+ * Can be:
241
+ * - A boolean to enable/disable with defaults (output: ./src/api/openapi.ts)
242
+ * - An OpenApiConfig object for customization
243
+ *
244
+ * When enabled, OpenAPI spec is generated on startup and regenerated on route changes.
245
+ *
246
+ * @example
247
+ * openapi: true
248
+ *
249
+ * @example
250
+ * openapi: {
251
+ * output: './src/api/openapi.ts',
252
+ * title: 'My API',
253
+ * version: '1.0.0',
254
+ * }
255
+ */
256
+ openapi?: boolean | OpenApiConfig;
257
+ /** Runtime to use for dev server (default: 'node') */
258
+ runtime?: Runtime;
259
+ /**
260
+ * Environment file(s) to load for development.
261
+ * Can be:
262
+ * - A string path to a single env file (e.g., '.env.local')
263
+ * - An array of paths to load in order (later files override earlier)
264
+ * - Defaults to '.env' if not specified
265
+ *
266
+ * @example
267
+ * env: '.env.local'
268
+ *
269
+ * @example
270
+ * env: ['.env', '.env.local']
271
+ */
272
+ env?: string | string[];
273
+ /**
274
+ * Docker deployment configuration.
275
+ * Used by `gkm docker` and `gkm prepack` commands.
276
+ *
277
+ * @example
278
+ * docker: {
279
+ * registry: 'ghcr.io/myorg',
280
+ * imageName: 'my-api',
281
+ * compose: {
282
+ * services: ['postgres', 'redis']
283
+ * }
284
+ * }
285
+ */
286
+ docker?: DockerConfig;
180
287
  }
181
288
 
182
289
  export interface BuildOptions {
183
- provider?: MainProvider;
184
- // Legacy support - will be deprecated
185
- providers?: LegacyProvider[];
186
- enableOpenApi?: boolean;
290
+ provider?: MainProvider;
291
+ // Legacy support - will be deprecated
292
+ providers?: LegacyProvider[];
293
+ enableOpenApi?: boolean;
294
+ /** Build for production (no dev tools, bundled output) */
295
+ production?: boolean;
296
+ /** Skip bundling step in production build */
297
+ skipBundle?: boolean;
298
+ /** Stage for secrets injection (e.g., 'production', 'staging') */
299
+ stage?: string;
300
+ }
301
+
302
+ /** Result from build command when secrets are injected */
303
+ export interface BuildResult {
304
+ /** Ephemeral master key for deployment (only if stage was provided) */
305
+ masterKey?: string;
187
306
  }
188
307
 
189
308
  export interface RouteInfo {
190
- path: string;
191
- method: string;
192
- handler: string;
193
- timeout?: number;
194
- memorySize?: number;
195
- environment?: string[];
196
- authorizer: string;
309
+ path: string;
310
+ method: string;
311
+ handler: string;
312
+ timeout?: number;
313
+ memorySize?: number;
314
+ environment?: string[];
315
+ authorizer: string;
197
316
  }
198
317
 
199
318
  export interface FunctionInfo {
200
- name: string;
201
- handler: string;
202
- timeout?: number;
203
- memorySize?: number;
204
- environment?: string[];
319
+ name: string;
320
+ handler: string;
321
+ timeout?: number;
322
+ memorySize?: number;
323
+ environment?: string[];
205
324
  }
206
325
 
207
326
  export interface CronInfo {
208
- name: string;
209
- handler: string;
210
- schedule: string;
211
- timeout?: number;
212
- memorySize?: number;
213
- environment?: string[];
327
+ name: string;
328
+ handler: string;
329
+ schedule: string;
330
+ timeout?: number;
331
+ memorySize?: number;
332
+ environment?: string[];
214
333
  }
215
334
 
216
335
  export interface SubscriberInfo {
217
- name: string;
218
- handler: string;
219
- subscribedEvents: string[];
220
- timeout?: number;
221
- memorySize?: number;
222
- environment?: string[];
336
+ name: string;
337
+ handler: string;
338
+ subscribedEvents: string[];
339
+ timeout?: number;
340
+ memorySize?: number;
341
+ environment?: string[];
223
342
  }
224
343
 
225
344
  export interface RoutesManifest {
226
- routes: RouteInfo[];
345
+ routes: RouteInfo[];
227
346
  }
228
347
 
229
348
  export interface FunctionsManifest {
230
- functions: FunctionInfo[];
349
+ functions: FunctionInfo[];
231
350
  }
232
351
 
233
352
  export interface CronsManifest {
234
- crons: CronInfo[];
353
+ crons: CronInfo[];
235
354
  }
236
355
 
237
356
  export interface SubscribersManifest {
238
- subscribers: SubscriberInfo[];
357
+ subscribers: SubscriberInfo[];
239
358
  }
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src",
6
+ "composite": true
7
+ },
8
+ "include": ["src/**/*"]
9
+ }
package/tsdown.config.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  import { defineConfig } from 'tsdown';
2
2
 
3
3
  export default defineConfig({
4
- entry: [
5
- 'src/index.ts',
6
- 'src/config.ts',
7
- 'src/openapi.ts',
8
- 'src/openapi-react-query.ts',
9
- ],
10
- dts: true,
11
- format: ['cjs', 'esm'],
4
+ entry: [
5
+ 'src/index.ts',
6
+ 'src/config.ts',
7
+ 'src/openapi.ts',
8
+ 'src/openapi-react-query.ts',
9
+ ],
10
+ dts: true,
11
+ format: ['cjs', 'esm'],
12
+ outExtensions: (ctx) => ({
13
+ js: ctx.format === 'es' ? '.mjs' : '.cjs',
14
+ }),
12
15
  });
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-Bq72aj8e.mjs","names":["config: GkmConfig","configString: string","defaultAlias: string","cwd: string"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'path';\nimport type { GkmConfig } from './types.ts';\n\nexport type { GkmConfig } from './types.ts';\n/**\n * Define GKM configuration with full TypeScript support.\n * This is an identity function that provides type safety and autocomplete.\n *\n * @example\n * ```ts\n * // gkm.config.ts\n * import { defineConfig } from '@geekmidas/cli/config';\n *\n * export default defineConfig({\n * routes: './src/endpoints/**\\/*.ts',\n * envParser: './src/config/env',\n * logger: './src/config/logger',\n * telescope: true,\n * });\n * ```\n */\nexport function defineConfig(config: GkmConfig): GkmConfig {\n return config;\n}\n\nexport interface ParsedModuleConfig {\n path: string;\n importPattern: string;\n}\n\n/**\n * Parse a module config string into path and import pattern.\n *\n * @param configString - Config string in format \"./path/to/module\" or \"./path/to/module#exportName\"\n * @param defaultAlias - The default alias name to use if no export name specified\n * @returns Object with path and import pattern\n *\n * @example\n * parseModuleConfig('./src/config/env', 'envParser')\n * // { path: './src/config/env', importPattern: 'envParser' }\n *\n * parseModuleConfig('./src/config/env#envParser', 'envParser')\n * // { path: './src/config/env', importPattern: '{ envParser }' }\n *\n * parseModuleConfig('./src/config/env#myEnv', 'envParser')\n * // { path: './src/config/env', importPattern: '{ myEnv as envParser }' }\n */\nexport function parseModuleConfig(\n configString: string,\n defaultAlias: string,\n): ParsedModuleConfig {\n const [path, exportName] = configString.split('#');\n const importPattern = !exportName\n ? defaultAlias\n : exportName === defaultAlias\n ? `{ ${defaultAlias} }`\n : `{ ${exportName} as ${defaultAlias} }`;\n\n return { path, importPattern };\n}\n\nexport async function loadConfig(\n cwd: string = process.cwd(),\n): Promise<GkmConfig> {\n const files = ['gkm.config.json', 'gkm.config.ts', 'gkm.config.js'];\n let configPath = '';\n\n for (const file of files) {\n const path = join(cwd, file);\n if (existsSync(path)) {\n configPath = path;\n break;\n }\n }\n\n if (!configPath) {\n throw new Error(\n 'Configuration file not found. Please create gkm.config.json, gkm.config.ts, or gkm.config.js in the project root.',\n );\n }\n\n try {\n const config = await import(configPath);\n return config.default;\n } catch (error) {\n throw new Error(\n `Failed to load gkm.config.json: ${(error as Error).message}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,aAAaA,QAA8B;AACzD,QAAO;AACR;;;;;;;;;;;;;;;;;;AAwBD,SAAgB,kBACdC,cACAC,cACoB;CACpB,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,MAAM,IAAI;CAClD,MAAM,iBAAiB,aACnB,eACA,eAAe,gBACZ,IAAI,aAAa,OACjB,IAAI,WAAW,MAAM,aAAa;AAEzC,QAAO;EAAE;EAAM;CAAe;AAC/B;AAED,eAAsB,WACpBC,MAAc,QAAQ,KAAK,EACP;CACpB,MAAM,QAAQ;EAAC;EAAmB;EAAiB;CAAgB;CACnE,IAAI,aAAa;AAEjB,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,OAAO,KAAK,KAAK,KAAK;AAC5B,MAAI,WAAW,KAAK,EAAE;AACpB,gBAAa;AACb;EACD;CACF;AAED,MAAK,WACH,OAAM,IAAI,MACR;AAIJ,KAAI;EACF,MAAM,SAAS,MAAM,OAAO;AAC5B,SAAO,OAAO;CACf,SAAQ,OAAO;AACd,QAAM,IAAI,OACP,kCAAmC,MAAgB,QAAQ;CAE/D;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-CFls09Ey.cjs","names":["config: GkmConfig","configString: string","defaultAlias: string","path","cwd: string"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'path';\nimport type { GkmConfig } from './types.ts';\n\nexport type { GkmConfig } from './types.ts';\n/**\n * Define GKM configuration with full TypeScript support.\n * This is an identity function that provides type safety and autocomplete.\n *\n * @example\n * ```ts\n * // gkm.config.ts\n * import { defineConfig } from '@geekmidas/cli/config';\n *\n * export default defineConfig({\n * routes: './src/endpoints/**\\/*.ts',\n * envParser: './src/config/env',\n * logger: './src/config/logger',\n * telescope: true,\n * });\n * ```\n */\nexport function defineConfig(config: GkmConfig): GkmConfig {\n return config;\n}\n\nexport interface ParsedModuleConfig {\n path: string;\n importPattern: string;\n}\n\n/**\n * Parse a module config string into path and import pattern.\n *\n * @param configString - Config string in format \"./path/to/module\" or \"./path/to/module#exportName\"\n * @param defaultAlias - The default alias name to use if no export name specified\n * @returns Object with path and import pattern\n *\n * @example\n * parseModuleConfig('./src/config/env', 'envParser')\n * // { path: './src/config/env', importPattern: 'envParser' }\n *\n * parseModuleConfig('./src/config/env#envParser', 'envParser')\n * // { path: './src/config/env', importPattern: '{ envParser }' }\n *\n * parseModuleConfig('./src/config/env#myEnv', 'envParser')\n * // { path: './src/config/env', importPattern: '{ myEnv as envParser }' }\n */\nexport function parseModuleConfig(\n configString: string,\n defaultAlias: string,\n): ParsedModuleConfig {\n const [path, exportName] = configString.split('#');\n const importPattern = !exportName\n ? defaultAlias\n : exportName === defaultAlias\n ? `{ ${defaultAlias} }`\n : `{ ${exportName} as ${defaultAlias} }`;\n\n return { path, importPattern };\n}\n\nexport async function loadConfig(\n cwd: string = process.cwd(),\n): Promise<GkmConfig> {\n const files = ['gkm.config.json', 'gkm.config.ts', 'gkm.config.js'];\n let configPath = '';\n\n for (const file of files) {\n const path = join(cwd, file);\n if (existsSync(path)) {\n configPath = path;\n break;\n }\n }\n\n if (!configPath) {\n throw new Error(\n 'Configuration file not found. Please create gkm.config.json, gkm.config.ts, or gkm.config.js in the project root.',\n );\n }\n\n try {\n const config = await import(configPath);\n return config.default;\n } catch (error) {\n throw new Error(\n `Failed to load gkm.config.json: ${(error as Error).message}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,aAAaA,QAA8B;AACzD,QAAO;AACR;;;;;;;;;;;;;;;;;;AAwBD,SAAgB,kBACdC,cACAC,cACoB;CACpB,MAAM,CAACC,QAAM,WAAW,GAAG,aAAa,MAAM,IAAI;CAClD,MAAM,iBAAiB,aACnB,eACA,eAAe,gBACZ,IAAI,aAAa,OACjB,IAAI,WAAW,MAAM,aAAa;AAEzC,QAAO;EAAE;EAAM;CAAe;AAC/B;AAED,eAAsB,WACpBC,MAAc,QAAQ,KAAK,EACP;CACpB,MAAM,QAAQ;EAAC;EAAmB;EAAiB;CAAgB;CACnE,IAAI,aAAa;AAEjB,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAMD,SAAO,eAAK,KAAK,KAAK;AAC5B,MAAI,mBAAWA,OAAK,EAAE;AACpB,gBAAaA;AACb;EACD;CACF;AAED,MAAK,WACH,OAAM,IAAI,MACR;AAIJ,KAAI;EACF,MAAM,SAAS,MAAM,OAAO;AAC5B,SAAO,OAAO;CACf,SAAQ,OAAO;AACd,QAAM,IAAI,OACP,kCAAmC,MAAgB,QAAQ;CAE/D;AACF"}