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