@crossdelta/infrastructure 0.10.0 → 0.10.1
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/README.md +4 -0
- package/bin/generate-env.mjs +3 -1
- package/bin/generate-env.ts +5 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,6 +99,10 @@ const provider = createK8sProviderFromKubeconfig(
|
|
|
99
99
|
)
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
+
## generate-env
|
|
103
|
+
|
|
104
|
+
Generates `.env.local` from Pulumi secrets (default: `stage` stack) and discovered services. Override with `--stack=production` or `--no-pulumi`.
|
|
105
|
+
|
|
102
106
|
## License
|
|
103
107
|
|
|
104
108
|
MIT © [crossdelta](https://crossdelta.de)
|
package/bin/generate-env.mjs
CHANGED
|
@@ -162,12 +162,14 @@ var discoverServices = (servicesDirectory) => {
|
|
|
162
162
|
};
|
|
163
163
|
var main = async () => {
|
|
164
164
|
const noPulumi = process.argv.includes("--no-pulumi");
|
|
165
|
+
const stackArg = process.argv.find((arg) => arg.startsWith("--stack="));
|
|
166
|
+
const stack = stackArg?.split("=")[1] ?? "stage";
|
|
165
167
|
const workspaceRootDirectory = findWorkspaceRoot();
|
|
166
168
|
const infraDirectory = join(workspaceRootDirectory, "infra");
|
|
167
169
|
const servicesDirectory = join(infraDirectory, "services");
|
|
168
170
|
const envLines = ["# Generated .env.local"];
|
|
169
171
|
if (!noPulumi && existsSync(join(infraDirectory, "Pulumi.yaml"))) {
|
|
170
|
-
const pulumiEntries = await loadPulumiConfig(infraDirectory,
|
|
172
|
+
const pulumiEntries = await loadPulumiConfig(infraDirectory, stack);
|
|
171
173
|
if (pulumiEntries.length > 0) {
|
|
172
174
|
envLines.push("", "# Pulumi Secrets");
|
|
173
175
|
envLines.push(...pulumiEntries);
|
package/bin/generate-env.ts
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* Generate environment variables for local development.
|
|
4
4
|
*
|
|
5
5
|
* This script:
|
|
6
|
-
* 1. Loads secrets from Pulumi config (
|
|
6
|
+
* 1. Loads secrets from Pulumi config (defaults to stage stack) if available
|
|
7
7
|
* 2. Discovers services from infra/services/*.ts (parses files without importing)
|
|
8
8
|
* 3. Generates service URLs and ports for localhost
|
|
9
9
|
* 4. Writes .env.local to the workspace root
|
|
10
10
|
*
|
|
11
|
-
* Usage: generate-env [--no-pulumi]
|
|
11
|
+
* Usage: generate-env [--stack=<name>] [--no-pulumi]
|
|
12
12
|
*/
|
|
13
13
|
import { execSync } from 'node:child_process'
|
|
14
14
|
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
@@ -177,13 +177,15 @@ const discoverServices = (servicesDirectory: string): MinimalServiceConfig[] =>
|
|
|
177
177
|
|
|
178
178
|
const main = async () => {
|
|
179
179
|
const noPulumi = process.argv.includes('--no-pulumi')
|
|
180
|
+
const stackArg = process.argv.find((arg) => arg.startsWith('--stack='))
|
|
181
|
+
const stack = stackArg?.split('=')[1] ?? 'stage'
|
|
180
182
|
const workspaceRootDirectory = findWorkspaceRoot()
|
|
181
183
|
const infraDirectory = join(workspaceRootDirectory, 'infra')
|
|
182
184
|
const servicesDirectory = join(infraDirectory, 'services')
|
|
183
185
|
const envLines: string[] = ['# Generated .env.local']
|
|
184
186
|
|
|
185
187
|
if (!noPulumi && existsSync(join(infraDirectory, 'Pulumi.yaml'))) {
|
|
186
|
-
const pulumiEntries = await loadPulumiConfig(infraDirectory,
|
|
188
|
+
const pulumiEntries = await loadPulumiConfig(infraDirectory, stack)
|
|
187
189
|
if (pulumiEntries.length > 0) {
|
|
188
190
|
envLines.push('', '# Pulumi Secrets')
|
|
189
191
|
envLines.push(...pulumiEntries)
|