@mono-labs/cli 0.0.185 → 0.0.187
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 +17 -9
package/package.json
CHANGED
package/src/project/index.ts
CHANGED
|
@@ -83,14 +83,22 @@ type DefaultDeployConfig = {
|
|
|
83
83
|
regions?: string[];
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
type ConfigTypeMap = {
|
|
87
|
+
app: DefaultAppConfig;
|
|
88
|
+
deployment: DefaultDeployConfig;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* If TType is a known key, use the mapped type.
|
|
93
|
+
* Otherwise use TCustom (default = unknown).
|
|
94
|
+
*/
|
|
95
|
+
type ResolveConfig<TType extends string, TCustom = unknown> =
|
|
96
|
+
TType extends keyof ConfigTypeMap ? ConfigTypeMap[TType] : TCustom;
|
|
97
|
+
|
|
98
|
+
export function loadAppConfig<TCustom = unknown, TType extends string = string>(
|
|
99
|
+
configType: TType,
|
|
100
|
+
startDir: string = process.cwd()
|
|
101
|
+
): { config: ResolveConfig<TType, TCustom>; meta: WorkspaceDetectResult } {
|
|
94
102
|
const fileName = `${configType}.config.json`;
|
|
95
103
|
const meta = detectWorkspaceAndConfigPath(startDir, fileName);
|
|
96
104
|
|
|
@@ -105,7 +113,7 @@ export function loadAppConfig<
|
|
|
105
113
|
}
|
|
106
114
|
|
|
107
115
|
const raw = fs.readFileSync(meta.configPath, 'utf8');
|
|
108
|
-
return { config: JSON.parse(raw) as
|
|
116
|
+
return { config: JSON.parse(raw) as ResolveConfig<TType, TCustom>, meta };
|
|
109
117
|
}
|
|
110
118
|
|
|
111
119
|
export const loadProjectConfig = loadAppConfig;
|