@mono-labs/cli 0.0.189 → 0.0.191
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 +1 -1
- package/src/project/index.ts +3 -0
- package/src/project/merge-env.ts +32 -0
package/package.json
CHANGED
package/src/project/index.ts
CHANGED
|
@@ -80,6 +80,7 @@ type DefaultDeployConfig = {
|
|
|
80
80
|
baseDomain?: string;
|
|
81
81
|
webSubdomain?: string;
|
|
82
82
|
apiSubdomain?: string;
|
|
83
|
+
defaultKeyPair?: string;
|
|
83
84
|
regions?: string[];
|
|
84
85
|
};
|
|
85
86
|
|
|
@@ -117,3 +118,5 @@ export function loadAppConfig<TCustom = unknown, TType extends string = 'app'>(
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
export const loadProjectConfig = loadAppConfig;
|
|
121
|
+
|
|
122
|
+
export { loadMergedEnv } from './merge-env.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import dotenv from 'dotenv';
|
|
4
|
+
|
|
5
|
+
export function loadMergedEnv(): NodeJS.ProcessEnv {
|
|
6
|
+
const ENV_PATH = path.resolve(process.cwd(), '.env');
|
|
7
|
+
const ENV_LOCAL_PATH = path.resolve(process.cwd(), '.env.local');
|
|
8
|
+
|
|
9
|
+
// Load base .env
|
|
10
|
+
const base =
|
|
11
|
+
fs.existsSync(ENV_PATH) ? dotenv.parse(fs.readFileSync(ENV_PATH)) : {};
|
|
12
|
+
|
|
13
|
+
// Load overrides .env.local
|
|
14
|
+
const local =
|
|
15
|
+
fs.existsSync(ENV_LOCAL_PATH) ?
|
|
16
|
+
dotenv.parse(fs.readFileSync(ENV_LOCAL_PATH))
|
|
17
|
+
: {};
|
|
18
|
+
|
|
19
|
+
// Merge: local overrides base
|
|
20
|
+
const merged = {
|
|
21
|
+
...base,
|
|
22
|
+
...local,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Inject into process.env (do NOT overwrite existing real env vars)
|
|
26
|
+
for (const [key, value] of Object.entries(merged)) {
|
|
27
|
+
if (process.env[key] === undefined) {
|
|
28
|
+
process.env[key] = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return process.env;
|
|
32
|
+
}
|