@geekmidas/cli 1.0.0 → 1.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs",
5
5
  "private": false,
6
6
  "type": "module",
@@ -79,6 +79,8 @@
79
79
  },
80
80
  "scripts": {
81
81
  "ts": "tsc --noEmit --skipLibCheck src/**/*.ts",
82
+ "sync-versions": "tsx scripts/sync-versions.ts",
83
+ "prebuild": "pnpm sync-versions",
82
84
  "test": "vitest",
83
85
  "test:once": "vitest run",
84
86
  "test:coverage": "vitest run --coverage"
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env tsx
2
+ /**
3
+ * Sync package versions from monorepo package.json files
4
+ *
5
+ * Run: pnpm --filter @geekmidas/cli sync-versions
6
+ */
7
+
8
+ import { readFileSync, writeFileSync } from 'node:fs';
9
+ import { dirname, join } from 'node:path';
10
+ import { fileURLToPath } from 'node:url';
11
+
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
+ const packagesDir = join(__dirname, '../../'); // packages/cli/scripts -> packages/
14
+
15
+ const PACKAGES = [
16
+ 'audit',
17
+ 'auth',
18
+ 'cache',
19
+ 'client',
20
+ 'cloud',
21
+ 'constructs',
22
+ 'db',
23
+ 'emailkit',
24
+ 'envkit',
25
+ 'errors',
26
+ 'events',
27
+ 'logger',
28
+ 'rate-limit',
29
+ 'schema',
30
+ 'services',
31
+ 'storage',
32
+ 'studio',
33
+ 'telescope',
34
+ 'testkit',
35
+ ] as const;
36
+
37
+ function getPackageVersion(pkgName: string): string {
38
+ const pkgJsonPath = join(packagesDir, pkgName, 'package.json');
39
+ try {
40
+ const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));
41
+ return pkgJson.version;
42
+ } catch (error) {
43
+ console.error(`Failed to read version for ${pkgName}:`, error);
44
+ throw error;
45
+ }
46
+ }
47
+
48
+ function generateVersionsFile(): string {
49
+ const versions: Record<string, string> = {};
50
+
51
+ for (const pkg of PACKAGES) {
52
+ const version = getPackageVersion(pkg);
53
+ versions[`@geekmidas/${pkg}`] = `~${version}`;
54
+ }
55
+
56
+ const content = `import { createRequire } from 'node:module';
57
+
58
+ const require = createRequire(import.meta.url);
59
+
60
+ // Load package.json - handles both bundled (flat dist/) and source (nested src/init/)
61
+ function loadPackageJson(): { version: string } {
62
+ try {
63
+ // Try flat dist path first (../package.json from dist/)
64
+ return require('../package.json');
65
+ } catch {
66
+ // Fall back to nested source path (../../package.json from src/init/)
67
+ return require('../../package.json');
68
+ }
69
+ }
70
+
71
+ const pkg = loadPackageJson();
72
+
73
+ /**
74
+ * CLI version resolved from package.json at runtime
75
+ */
76
+ export const CLI_VERSION = \`~\${pkg.version}\`;
77
+
78
+ /**
79
+ * Package versions for @geekmidas packages
80
+ *
81
+ * AUTO-GENERATED (except CLI) - Do not edit manually
82
+ * Run: pnpm --filter @geekmidas/cli sync-versions
83
+ */
84
+ export const GEEKMIDAS_VERSIONS = {
85
+ ${Object.entries(versions)
86
+ .map(([pkg, version]) => `\t'${pkg}': '${version}',`)
87
+ .join('\n')}
88
+ '@geekmidas/cli': CLI_VERSION,
89
+ } as const;
90
+
91
+ export type GeekmidasPackage = keyof typeof GEEKMIDAS_VERSIONS;
92
+ `;
93
+
94
+ return content;
95
+ }
96
+
97
+ // Main
98
+ const versionsPath = join(__dirname, '../src/init/versions.ts');
99
+ const content = generateVersionsFile();
100
+ writeFileSync(versionsPath, content);
101
+ console.log('✓ Updated packages/cli/src/init/versions.ts');
102
+
103
+ // Show versions
104
+ console.log('\nPackage versions:');
105
+ for (const pkg of PACKAGES) {
106
+ const version = getPackageVersion(pkg);
107
+ console.log(` @geekmidas/${pkg}: ${version}`);
108
+ }
@@ -16,43 +16,37 @@ function loadPackageJson(): { version: string } {
16
16
  const pkg = loadPackageJson();
17
17
 
18
18
  /**
19
- * CLI version from package.json (used for scaffolded projects)
19
+ * CLI version resolved from package.json at runtime
20
20
  */
21
21
  export const CLI_VERSION = `~${pkg.version}`;
22
22
 
23
23
  /**
24
- * Current released versions of @geekmidas packages
25
- * Update these when publishing new versions
26
- * Note: CLI version is read from package.json via CLI_VERSION
24
+ * Package versions for @geekmidas packages
25
+ *
26
+ * AUTO-GENERATED (except CLI) - Do not edit manually
27
+ * Run: pnpm --filter @geekmidas/cli sync-versions
27
28
  */
28
29
  export const GEEKMIDAS_VERSIONS = {
29
- '@geekmidas/audit': '~0.2.0',
30
- '@geekmidas/auth': '~0.2.0',
31
- '@geekmidas/cache': '~0.2.0',
30
+ '@geekmidas/audit': '~1.0.0',
31
+ '@geekmidas/auth': '~1.0.0',
32
+ '@geekmidas/cache': '~1.0.0',
33
+ '@geekmidas/client': '~1.0.0',
34
+ '@geekmidas/cloud': '~1.0.0',
35
+ '@geekmidas/constructs': '~1.0.0',
36
+ '@geekmidas/db': '~1.0.0',
37
+ '@geekmidas/emailkit': '~1.0.0',
38
+ '@geekmidas/envkit': '~1.0.0',
39
+ '@geekmidas/errors': '~1.0.0',
40
+ '@geekmidas/events': '~1.0.0',
41
+ '@geekmidas/logger': '~1.0.0',
42
+ '@geekmidas/rate-limit': '~1.0.0',
43
+ '@geekmidas/schema': '~1.0.0',
44
+ '@geekmidas/services': '~1.0.0',
45
+ '@geekmidas/storage': '~1.0.0',
46
+ '@geekmidas/studio': '~1.0.0',
47
+ '@geekmidas/telescope': '~1.0.0',
48
+ '@geekmidas/testkit': '~1.0.0',
32
49
  '@geekmidas/cli': CLI_VERSION,
33
- '@geekmidas/client': '~0.5.0',
34
- '@geekmidas/cloud': '~0.2.0',
35
- '@geekmidas/constructs': '~0.8.0',
36
- '@geekmidas/db': '~0.3.0',
37
- '@geekmidas/emailkit': '~0.2.0',
38
- '@geekmidas/envkit': '~0.7.0',
39
- '@geekmidas/errors': '~0.1.0',
40
- '@geekmidas/events': '~0.2.0',
41
- '@geekmidas/logger': '~0.4.0',
42
- '@geekmidas/rate-limit': '~0.3.0',
43
- '@geekmidas/schema': '~0.1.0',
44
- '@geekmidas/services': '~0.2.0',
45
- '@geekmidas/storage': '~0.1.0',
46
- '@geekmidas/studio': '~0.4.0',
47
- '@geekmidas/telescope': '~0.6.0',
48
- '@geekmidas/testkit': '~0.6.0',
49
- };
50
+ } as const;
50
51
 
51
52
  export type GeekmidasPackage = keyof typeof GEEKMIDAS_VERSIONS;
52
-
53
- /**
54
- * Get the version for a @geekmidas package
55
- */
56
- export function getPackageVersion(pkg: GeekmidasPackage): string {
57
- return GEEKMIDAS_VERSIONS[pkg]!;
58
- }