@crossdelta/platform-sdk 0.4.42 → 0.4.44
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": "@crossdelta/platform-sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.44",
|
|
4
4
|
"description": "CLI toolkit for scaffolding Turborepo workspaces with Pulumi infrastructure and Hono/NestJS microservices",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -55,8 +55,7 @@
|
|
|
55
55
|
"prepublishOnly": "npm run build",
|
|
56
56
|
"lint": "biome lint --fix",
|
|
57
57
|
"test": "vitest run",
|
|
58
|
-
"test:watch": "vitest watch"
|
|
59
|
-
"postinstall": "npm run build"
|
|
58
|
+
"test:watch": "vitest watch"
|
|
60
59
|
},
|
|
61
60
|
"schematics": "./dist/schematics/collection.json",
|
|
62
61
|
"esbuild": {
|
|
@@ -104,7 +103,7 @@
|
|
|
104
103
|
"zx": "^8.5.3"
|
|
105
104
|
},
|
|
106
105
|
"peerDependencies": {
|
|
107
|
-
"@crossdelta/infrastructure": "
|
|
106
|
+
"@crossdelta/infrastructure": "*",
|
|
108
107
|
"@nestjs/schematics": "^11.0.5",
|
|
109
108
|
"turbo": "^2.0.0"
|
|
110
109
|
},
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate .env.local from infra/services/*.ts configurations.
|
|
3
|
-
*
|
|
4
|
-
* This script parses service config files (without importing them to avoid Pulumi deps)
|
|
5
|
-
* and generates environment variables for local development.
|
|
6
|
-
*
|
|
7
|
-
* Run with: bun run generate-env
|
|
8
|
-
*/
|
|
9
|
-
import { readdirSync, readFileSync } from 'node:fs'
|
|
10
|
-
import { join } from 'node:path'
|
|
11
|
-
|
|
12
|
-
interface MinimalServiceConfig {
|
|
13
|
-
name: string
|
|
14
|
-
port?: number
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const toEnvKey = (name: string): string => name.toUpperCase().replace(/-/g, '_')
|
|
18
|
-
|
|
19
|
-
const resolveNumber = (value: string, fileContent: string): number | undefined => {
|
|
20
|
-
const literal = Number.parseInt(value, 10)
|
|
21
|
-
if (!Number.isNaN(literal)) return literal
|
|
22
|
-
|
|
23
|
-
const varMatch = fileContent.match(new RegExp(`(?:const|let|var)\\s+${value}\\s*=\\s*(\\d+)`))
|
|
24
|
-
return varMatch?.[1] ? Number.parseInt(varMatch[1], 10) : undefined
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const discoverServices = (servicesDir: string): MinimalServiceConfig[] => {
|
|
28
|
-
const files = readdirSync(servicesDir).filter(
|
|
29
|
-
(file) => file.endsWith('.ts') && file !== 'index.ts'
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
return files.map((file) => {
|
|
33
|
-
const content = readFileSync(join(servicesDir, file), 'utf-8')
|
|
34
|
-
const nameMatch = content.match(/name:\s*['"]([^'"]+)['"]/)
|
|
35
|
-
// Try containerPort first, then httpPort (legacy)
|
|
36
|
-
const containerPortMatch = content.match(/containerPort:\s*(\w+)/)
|
|
37
|
-
const httpPortMatch = content.match(/httpPort:\s*(\w+)/)
|
|
38
|
-
const portMatch = containerPortMatch || httpPortMatch
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
name: nameMatch?.[1] ?? file.replace('.ts', ''),
|
|
42
|
-
port: portMatch?.[1] ? resolveNumber(portMatch[1], content) : undefined,
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const main = async () => {
|
|
48
|
-
const scriptsDir = import.meta.dirname
|
|
49
|
-
const infraDir = join(scriptsDir, '..')
|
|
50
|
-
const servicesDir = join(infraDir, 'services')
|
|
51
|
-
const workspaceRoot = join(infraDir, '..')
|
|
52
|
-
|
|
53
|
-
const envLines = ['# Generated .env.local', '']
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
const services = discoverServices(servicesDir)
|
|
57
|
-
|
|
58
|
-
if (services.length > 0) {
|
|
59
|
-
envLines.push('# Service URLs')
|
|
60
|
-
for (const svc of services) {
|
|
61
|
-
if (svc.containerPort) {
|
|
62
|
-
envLines.push(`${toEnvKey(svc.name)}_URL=http://localhost:${svc.containerPort}`)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
envLines.push('', '# Service Ports')
|
|
67
|
-
for (const svc of services) {
|
|
68
|
-
if (svc.containerPort) {
|
|
69
|
-
envLines.push(`${toEnvKey(svc.name)}_PORT=${svc.containerPort}`)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
console.log(`✅ Discovered ${services.length} services`)
|
|
75
|
-
} catch (err) {
|
|
76
|
-
console.warn('⚠️ Could not discover services:', err)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
await Bun.write(join(workspaceRoot, '.env.local'), `${envLines.join('\n')}\n`)
|
|
80
|
-
console.log('✅ .env.local generated')
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
main()
|