@geekmidas/cli 9.0.2 → 9.2.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 (38) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/config.d.cts +1 -1
  3. package/dist/config.d.mts +1 -1
  4. package/dist/{index-DTpkeFb8.d.cts → index-CoVW_fFS.d.cts} +2 -2
  5. package/dist/{index-Bw548Bta.d.mts.map → index-CoVW_fFS.d.cts.map} +1 -1
  6. package/dist/{index-Bw548Bta.d.mts → index-oWibAYQY.d.mts} +2 -2
  7. package/dist/{index-DTpkeFb8.d.cts.map → index-oWibAYQY.d.mts.map} +1 -1
  8. package/dist/index.cjs +31 -29
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.mjs +31 -29
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/{openapi-BzNOC7_i.cjs → openapi-B_IGZDVu.cjs} +8 -4
  13. package/dist/openapi-B_IGZDVu.cjs.map +1 -0
  14. package/dist/{openapi-Cfwi0fqF.mjs → openapi-C5rXJTtj.mjs} +8 -4
  15. package/dist/openapi-C5rXJTtj.mjs.map +1 -0
  16. package/dist/openapi.cjs +1 -1
  17. package/dist/openapi.mjs +1 -1
  18. package/dist/types-BWQDiooe.d.cts.map +1 -1
  19. package/dist/workspace/index.d.cts +1 -1
  20. package/dist/workspace/index.d.mts +1 -1
  21. package/dist/workspace-CQTT7HJQ.cjs.map +1 -1
  22. package/dist/workspace-D-37Ylqo.mjs.map +1 -1
  23. package/package.json +9 -9
  24. package/src/__tests__/test-helpers.ts +9 -10
  25. package/src/docker/__tests__/compose.spec.ts +3 -3
  26. package/src/docker/compose.ts +8 -4
  27. package/src/generators/CronGenerator.ts +1 -0
  28. package/src/generators/EndpointGenerator.ts +13 -0
  29. package/src/generators/FunctionGenerator.ts +1 -0
  30. package/src/generators/__tests__/CronGenerator.spec.ts +45 -1
  31. package/src/generators/__tests__/EndpointGenerator.spec.ts +80 -2
  32. package/src/generators/__tests__/FunctionGenerator.spec.ts +20 -0
  33. package/src/init/__tests__/generators.spec.ts +3 -1
  34. package/src/init/generators/docker.ts +1 -1
  35. package/src/init/versions.ts +19 -19
  36. package/src/workspace/types.ts +1 -1
  37. package/dist/openapi-BzNOC7_i.cjs.map +0 -1
  38. package/dist/openapi-Cfwi0fqF.mjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/cli",
3
- "version": "9.0.2",
3
+ "version": "9.2.0",
4
4
  "description": "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs",
5
5
  "private": false,
6
6
  "type": "module",
@@ -81,12 +81,12 @@
81
81
  "prompts": "~2.4.2",
82
82
  "tsx": "~4.20.3",
83
83
  "yaml": "~2.8.2",
84
- "@geekmidas/constructs": "~9.0.2",
85
- "@geekmidas/envkit": "~9.0.2",
86
- "@geekmidas/errors": "~9.0.2",
87
- "@geekmidas/logger": "~9.0.2",
88
- "@geekmidas/manifest": "9.0.2",
89
- "@geekmidas/schema": "~9.0.2"
84
+ "@geekmidas/constructs": "~9.2.0",
85
+ "@geekmidas/envkit": "~9.2.0",
86
+ "@geekmidas/errors": "~9.2.0",
87
+ "@geekmidas/logger": "~9.2.0",
88
+ "@geekmidas/manifest": "9.2.0",
89
+ "@geekmidas/schema": "~9.2.0"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@types/lodash.kebabcase": "^4.1.9",
@@ -96,10 +96,10 @@
96
96
  "typescript": "^5.8.2",
97
97
  "vitest": "^3.2.4",
98
98
  "zod": "~4.1.13",
99
- "@geekmidas/testkit": "9.0.2"
99
+ "@geekmidas/testkit": "9.2.0"
100
100
  },
101
101
  "peerDependencies": {
102
- "@geekmidas/telescope": "~9.0.2"
102
+ "@geekmidas/telescope": "^9.2.0"
103
103
  },
104
104
  "peerDependenciesMeta": {
105
105
  "@geekmidas/telescope": {
@@ -119,16 +119,15 @@ export const ${exportName} = new CronBuilder()
119
119
  export function createTestEndpoint(path: string, method: HttpMethod = 'GET') {
120
120
  const m = method.toLowerCase() as Lowercase<HttpMethod>;
121
121
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
122
- const builder = (e as any)[m](path);
123
- builder.output(z.object({ message: z.string() }));
122
+ const builder = (e as any)[m](path).output(z.object({ message: z.string() }));
124
123
  return builder.handle(async () => ({ message: `Hello from ${path}` }));
125
124
  }
126
125
 
127
126
  export function createTestFunction(timeout: number = 30) {
128
- const builder = new FunctionBuilder();
129
- builder.input(z.object({ name: z.string() }));
130
- builder.output(z.object({ greeting: z.string() }));
131
- builder.timeout(timeout);
127
+ const builder = new FunctionBuilder()
128
+ .input(z.object({ name: z.string() }))
129
+ .output(z.object({ greeting: z.string() }))
130
+ .timeout(timeout);
132
131
  return builder.handle(async ({ input }: any) => ({
133
132
  greeting: `Hello, ${input.name}!`,
134
133
  }));
@@ -138,10 +137,10 @@ export function createTestCron(
138
137
  schedule: ScheduleExpression = 'rate(1 hour)',
139
138
  timeout: number = 30,
140
139
  ) {
141
- const builder = new CronBuilder();
142
- builder.schedule(schedule);
143
- builder.output(z.object({ processed: z.number() }));
144
- builder.timeout(timeout);
140
+ const builder = new CronBuilder()
141
+ .schedule(schedule)
142
+ .output(z.object({ processed: z.number() }))
143
+ .timeout(timeout);
145
144
  return builder.handle(async () => {
146
145
  return { processed: 10 };
147
146
  });
@@ -383,7 +383,7 @@ describe('generateDockerCompose', () => {
383
383
  services: { minio: { version: 'RELEASE.2024-01-01' } },
384
384
  });
385
385
 
386
- expect(yaml).toContain('image: minio/minio:RELEASE.2024-01-01');
386
+ expect(yaml).toContain('image: pgsty/minio:RELEASE.2024-01-01');
387
387
  });
388
388
 
389
389
  it('should configure minio credentials', () => {
@@ -1067,7 +1067,7 @@ describe('generateWorkspaceCompose', () => {
1067
1067
  const yaml = generateWorkspaceCompose(workspace);
1068
1068
 
1069
1069
  expect(yaml).toContain('minio:');
1070
- expect(yaml).toContain('image: minio/minio:latest');
1070
+ expect(yaml).toContain('image: pgsty/minio:RELEASE.2026-08-04T00-00-00Z');
1071
1071
  expect(yaml).toContain('container_name: test-workspace-minio');
1072
1072
  });
1073
1073
 
@@ -1108,7 +1108,7 @@ describe('generateWorkspaceCompose', () => {
1108
1108
  });
1109
1109
  const yaml = generateWorkspaceCompose(workspace);
1110
1110
 
1111
- expect(yaml).toContain('image: minio/minio:RELEASE.2024-01-01');
1111
+ expect(yaml).toContain('image: pgsty/minio:RELEASE.2024-01-01');
1112
1112
  });
1113
1113
  });
1114
1114
 
@@ -13,7 +13,7 @@ export const DEFAULT_SERVICE_IMAGES: Record<ComposeServiceName, string> = {
13
13
  postgres: 'postgres',
14
14
  redis: 'redis',
15
15
  rabbitmq: 'rabbitmq',
16
- minio: 'minio/minio',
16
+ minio: 'pgsty/minio',
17
17
  mailpit: 'axllent/mailpit',
18
18
  localstack: 'localstack/localstack',
19
19
  };
@@ -23,7 +23,11 @@ export const DEFAULT_SERVICE_VERSIONS: Record<ComposeServiceName, string> = {
23
23
  postgres: '18-alpine',
24
24
  redis: '7-alpine',
25
25
  rabbitmq: '3-management-alpine',
26
- minio: 'latest',
26
+ // Pinned, unlike its neighbours, and deliberately: MinIO took their images
27
+ // off Docker Hub and then put Quay behind a login. The image is pgsty's
28
+ // community build of the same binary, and a pin means a move like that
29
+ // breaks one version bump rather than every project that pulls.
30
+ minio: 'RELEASE.2026-08-04T00-00-00Z',
27
31
  mailpit: 'latest',
28
32
  localstack: 'latest',
29
33
  };
@@ -647,7 +651,7 @@ function getInfraServiceImage(
647
651
  const defaults: Record<'postgres' | 'redis' | 'minio', string> = {
648
652
  postgres: 'postgres:18-alpine',
649
653
  redis: 'redis:7-alpine',
650
- minio: 'minio/minio:latest',
654
+ minio: 'pgsty/minio:RELEASE.2026-08-04T00-00-00Z',
651
655
  };
652
656
 
653
657
  if (!config || config === true) {
@@ -662,7 +666,7 @@ function getInfraServiceImage(
662
666
  const baseImages: Record<'postgres' | 'redis' | 'minio', string> = {
663
667
  postgres: 'postgres',
664
668
  redis: 'redis',
665
- minio: 'minio/minio',
669
+ minio: 'pgsty/minio',
666
670
  };
667
671
  return `${baseImages[serviceName]}:${config.version}`;
668
672
  }
@@ -54,6 +54,7 @@ export class CronGenerator extends ConstructGenerator<
54
54
  environment: await construct.getEnvironment({
55
55
  markOptional: context.markOptional,
56
56
  }),
57
+ monitoring: construct.getMonitoring(),
57
58
  });
58
59
 
59
60
  logger.log(`Generated cron handler: ${key}`);
@@ -95,11 +95,22 @@ export class EndpointGenerator extends ConstructGenerator<
95
95
  await this.generateEndpointsFile(outputDir, constructs, context);
96
96
  const appFile = await this.generateAppFile(outputDir, context);
97
97
 
98
+ // One process serves every endpoint, so its monitors are the distinct
99
+ // ones across them: endpoints reading the same variable share its URL.
100
+ const monitoring = [
101
+ ...new Map(
102
+ constructs
103
+ .flatMap(({ construct }) => construct.getMonitoring() ?? [])
104
+ .map((monitor) => [JSON.stringify(monitor), monitor]),
105
+ ).values(),
106
+ ];
107
+
98
108
  routes.push({
99
109
  path: '*',
100
110
  method: 'ALL',
101
111
  handler: relative(process.cwd(), appFile),
102
112
  authorizer: 'none',
113
+ ...(monitoring.length ? { monitoring } : {}),
103
114
  });
104
115
 
105
116
  logger.log(
@@ -134,6 +145,7 @@ export class EndpointGenerator extends ConstructGenerator<
134
145
  markOptional: context.markOptional,
135
146
  }),
136
147
  authorizer: construct.authorizer?.name ?? 'none',
148
+ monitoring: construct.getMonitoring(),
137
149
  };
138
150
 
139
151
  routes.push(routeInfo);
@@ -166,6 +178,7 @@ export class EndpointGenerator extends ConstructGenerator<
166
178
  markOptional: context.markOptional,
167
179
  }),
168
180
  authorizer: construct.authorizer?.name ?? 'none',
181
+ monitoring: construct.getMonitoring(),
169
182
  };
170
183
 
171
184
  routes.push(routeInfo);
@@ -72,6 +72,7 @@ export class FunctionGenerator extends ConstructGenerator<
72
72
  environment: await construct.getEnvironment({
73
73
  markOptional: context.markOptional,
74
74
  }),
75
+ monitoring: construct.getMonitoring(),
75
76
  });
76
77
 
77
78
  logger.log(`Generated function handler: ${key}`);
@@ -1,6 +1,11 @@
1
1
  import { mkdir, readFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
- import type { Cron, ScheduleExpression } from '@geekmidas/constructs/crons';
3
+ import {
4
+ type Cron,
5
+ CronBuilder,
6
+ type ScheduleExpression,
7
+ } from '@geekmidas/constructs/crons';
8
+ import { heartbeat } from '@geekmidas/constructs/monitors';
4
9
  import { itWithDir } from '@geekmidas/testkit/os';
5
10
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
6
11
  import {
@@ -145,6 +150,45 @@ describe('CronGenerator', () => {
145
150
  expect(hourlyCleanupContent).toContain('import { hourlyCleanup }');
146
151
  });
147
152
 
153
+ it('records the cron’s monitors in its manifest entry', async () => {
154
+ const monitored = new CronBuilder()
155
+ .schedule('cron(0 8 * * ? *)')
156
+ .monitor(heartbeat.betterStack('MONITORING_URL'))
157
+ .handle(async () => ({}));
158
+ const plain = createTestCron();
159
+
160
+ const cronInfos = await generator.build(
161
+ context,
162
+ [
163
+ {
164
+ key: 'monitored',
165
+ name: 'monitored',
166
+ construct: monitored,
167
+ path: {
168
+ absolute: join(tempDir, 'monitored.ts'),
169
+ relative: 'monitored.ts',
170
+ },
171
+ },
172
+ {
173
+ key: 'plain',
174
+ name: 'plain',
175
+ construct: plain,
176
+ path: {
177
+ absolute: join(tempDir, 'plain.ts'),
178
+ relative: 'plain.ts',
179
+ },
180
+ },
181
+ ],
182
+ outputDir,
183
+ { provider: 'aws-lambda' },
184
+ );
185
+
186
+ expect(cronInfos[0].monitoring).toEqual([
187
+ { type: 'heartbeat', provider: 'betterStack', env: 'MONITORING_URL' },
188
+ ]);
189
+ expect(cronInfos[1].monitoring).toBeUndefined();
190
+ });
191
+
148
192
  it('should use default schedule when none provided', async () => {
149
193
  // Create a cron with empty schedule that will use default
150
194
  const cronWithDefaultSchedule = createTestCron(undefined, 30);
@@ -1,7 +1,9 @@
1
- import { mkdir, readFile } from 'node:fs/promises';
1
+ import { mkdir, mkdtemp, readFile, rm } from 'node:fs/promises';
2
+ import { tmpdir } from 'node:os';
2
3
  import { join } from 'node:path';
3
4
  import type { HttpMethod } from '@geekmidas/constructs';
4
- import type { Endpoint } from '@geekmidas/constructs/endpoints';
5
+ import { type Endpoint, e } from '@geekmidas/constructs/endpoints';
6
+ import { heartbeat } from '@geekmidas/constructs/monitors';
5
7
  import { itWithDir } from '@geekmidas/testkit/os';
6
8
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
7
9
  import {
@@ -51,6 +53,82 @@ describe('EndpointGenerator', () => {
51
53
  },
52
54
  });
53
55
 
56
+ describe('monitoring', () => {
57
+ const MONITOR = {
58
+ type: 'heartbeat',
59
+ provider: 'betterStack',
60
+ env: 'MONITORING_URL',
61
+ };
62
+ let dir: string;
63
+
64
+ beforeEach(async () => {
65
+ dir = await mkdtemp(join(tmpdir(), 'endpoint-monitoring-'));
66
+ await mkdir(join(dir, 'output'), { recursive: true });
67
+ });
68
+
69
+ afterEach(async () => {
70
+ await rm(dir, { recursive: true, force: true });
71
+ });
72
+
73
+ const monitoredAt = (key: string, path: string) => {
74
+ const construct = createTestEndpointConstruct(key, path, 'GET', dir);
75
+ construct.construct = e
76
+ .monitor(heartbeat.betterStack('MONITORING_URL'))
77
+ .get(path)
78
+ .handle(async () => ({}));
79
+ return construct;
80
+ };
81
+
82
+ it.each([
83
+ 'aws-lambda',
84
+ 'aws-apigatewayv2',
85
+ ] as const)('records each route’s monitors (%s)', async (provider) => {
86
+ const routes = await generator.build(
87
+ context,
88
+ [
89
+ monitoredAt('monitored', '/monitored'),
90
+ createTestEndpointConstruct('plain', '/plain', 'GET', dir),
91
+ ],
92
+ join(dir, 'output'),
93
+ { provider },
94
+ );
95
+
96
+ expect(routes.find((r) => r.path === '/monitored')?.monitoring).toEqual([
97
+ MONITOR,
98
+ ]);
99
+ expect(
100
+ routes.find((r) => r.path === '/plain')?.monitoring,
101
+ ).toBeUndefined();
102
+ });
103
+
104
+ it('records the distinct monitors across endpoints on the server route', async () => {
105
+ const routes = await generator.build(
106
+ context,
107
+ [
108
+ monitoredAt('first', '/first'),
109
+ monitoredAt('second', '/second'),
110
+ createTestEndpointConstruct('plain', '/plain', 'GET', dir),
111
+ ],
112
+ join(dir, 'output'),
113
+ { provider: 'server' },
114
+ );
115
+
116
+ expect(routes).toHaveLength(1);
117
+ expect(routes[0].monitoring).toEqual([MONITOR]);
118
+ });
119
+
120
+ it('records no monitoring on a server whose endpoints have none', async () => {
121
+ const routes = await generator.build(
122
+ context,
123
+ [createTestEndpointConstruct('plain', '/plain', 'GET', dir)],
124
+ join(dir, 'output'),
125
+ { provider: 'server' },
126
+ );
127
+
128
+ expect(routes[0].monitoring).toBeUndefined();
129
+ });
130
+ });
131
+
54
132
  itWithDir('should generate a single server app file', async ({ dir }) => {
55
133
  const outputDir = join(dir, 'output');
56
134
  const routesDir = join(dir, 'routes');
@@ -2,6 +2,7 @@ import { readFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import type { Function } from '@geekmidas/constructs/functions';
4
4
  import { f } from '@geekmidas/constructs/functions';
5
+ import { heartbeat } from '@geekmidas/constructs/monitors';
5
6
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
6
7
  import { z } from 'zod';
7
8
  import {
@@ -120,6 +121,25 @@ describe('FunctionGenerator', () => {
120
121
  expect(sendEmailContent).toContain('import { sendEmail }');
121
122
  });
122
123
 
124
+ it('records the function’s monitors in its manifest entry', async () => {
125
+ const monitored = createTestFunctionConstruct('monitored');
126
+ monitored.construct = f
127
+ .monitor(heartbeat.betterStack('MONITORING_URL'))
128
+ .handle(async () => ({}));
129
+
130
+ const functionInfos = await generator.build(
131
+ context,
132
+ [monitored, createTestFunctionConstruct('plain')],
133
+ outputDir,
134
+ { provider: 'aws-lambda' },
135
+ );
136
+
137
+ expect(functionInfos[0].monitoring).toEqual([
138
+ { type: 'heartbeat', provider: 'betterStack', env: 'MONITORING_URL' },
139
+ ]);
140
+ expect(functionInfos[1].monitoring).toBeUndefined();
141
+ });
142
+
123
143
  it('should generate correct relative import paths', async () => {
124
144
  const construct: GeneratedConstruct<Function<any, any, any, any>> = {
125
145
  key: 'deepFunction',
@@ -263,7 +263,9 @@ describe('generateDockerFiles', () => {
263
263
  };
264
264
  const files = generateDockerFiles(options, minimalTemplate);
265
265
  expect(files[0].content).toContain('minio');
266
- expect(files[0].content).toContain('minio/minio:latest');
266
+ expect(files[0].content).toContain(
267
+ 'pgsty/minio:RELEASE.2026-08-04T00-00-00Z',
268
+ );
267
269
  expect(files[0].content).toContain("'${MINIO_API_HOST_PORT:-9000}:9000'");
268
270
  expect(files[0].content).toContain(
269
271
  "'${MINIO_CONSOLE_HOST_PORT:-9001}:9001'",
@@ -163,7 +163,7 @@ export function generateDockerFiles(
163
163
  // MinIO for S3-compatible object storage
164
164
  if (options.services?.storage) {
165
165
  services.push(` minio:
166
- image: minio/minio:latest
166
+ image: pgsty/minio:RELEASE.2026-08-04T00-00-00Z
167
167
  container_name: ${options.name}-minio
168
168
  restart: unless-stopped
169
169
  entrypoint: sh
@@ -27,25 +27,25 @@ export const CLI_VERSION = `~${pkg.version}`;
27
27
  * Run: pnpm --filter @geekmidas/cli sync-versions
28
28
  */
29
29
  export const GEEKMIDAS_VERSIONS = {
30
- '@geekmidas/audit': '~9.0.1',
31
- '@geekmidas/auth': '~9.0.1',
32
- '@geekmidas/cache': '~9.0.1',
33
- '@geekmidas/client': '~9.0.1',
34
- '@geekmidas/cloud': '~9.0.1',
35
- '@geekmidas/constructs': '~9.0.1',
36
- '@geekmidas/db': '~9.0.1',
37
- '@geekmidas/emailkit': '~9.0.1',
38
- '@geekmidas/envkit': '~9.0.1',
39
- '@geekmidas/errors': '~9.0.1',
40
- '@geekmidas/events': '~9.0.1',
41
- '@geekmidas/logger': '~9.0.1',
42
- '@geekmidas/rate-limit': '~9.0.1',
43
- '@geekmidas/schema': '~9.0.1',
44
- '@geekmidas/services': '~9.0.1',
45
- '@geekmidas/storage': '~9.0.1',
46
- '@geekmidas/studio': '~9.0.1',
47
- '@geekmidas/telescope': '~9.0.1',
48
- '@geekmidas/testkit': '~9.0.1',
30
+ '@geekmidas/audit': '~9.1.0',
31
+ '@geekmidas/auth': '~9.1.0',
32
+ '@geekmidas/cache': '~9.1.0',
33
+ '@geekmidas/client': '~9.1.0',
34
+ '@geekmidas/cloud': '~9.1.0',
35
+ '@geekmidas/constructs': '~9.1.0',
36
+ '@geekmidas/db': '~9.1.0',
37
+ '@geekmidas/emailkit': '~9.1.0',
38
+ '@geekmidas/envkit': '~9.1.0',
39
+ '@geekmidas/errors': '~9.1.0',
40
+ '@geekmidas/events': '~9.1.0',
41
+ '@geekmidas/logger': '~9.1.0',
42
+ '@geekmidas/rate-limit': '~9.1.0',
43
+ '@geekmidas/schema': '~9.1.0',
44
+ '@geekmidas/services': '~9.1.0',
45
+ '@geekmidas/storage': '~9.1.0',
46
+ '@geekmidas/studio': '~9.1.0',
47
+ '@geekmidas/telescope': '~9.1.0',
48
+ '@geekmidas/testkit': '~9.1.0',
49
49
  '@geekmidas/cli': CLI_VERSION,
50
50
  } as const;
51
51
 
@@ -147,7 +147,7 @@ export interface ServicesConfig {
147
147
  cache?: boolean | ServiceImageConfig;
148
148
  /** Mail service (mailpit for dev) */
149
149
  mail?: boolean | MailServiceConfig;
150
- /** MinIO S3-compatible object storage (default: minio/minio:latest) */
150
+ /** MinIO S3-compatible object storage (default: pgsty/minio:RELEASE.2026-08-04T00-00-00Z) */
151
151
  storage?: boolean | ServiceImageConfig;
152
152
  /** Event backend: pgboss (reuses postgres), sns (LocalStack), or rabbitmq */
153
153
  events?: import('../types.js').EventsBackend;