@mono-labs/cli 0.0.184 → 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 +29 -7
package/package.json
CHANGED
package/src/project/index.ts
CHANGED
|
@@ -76,12 +76,32 @@ type DefaultAppConfig = {
|
|
|
76
76
|
regions?: string[];
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
type DefaultDeployConfig = {
|
|
80
|
+
baseDomain?: string;
|
|
81
|
+
webSubdomain?: string;
|
|
82
|
+
apiSubdomain?: string;
|
|
83
|
+
regions?: string[];
|
|
84
|
+
};
|
|
85
|
+
|
|
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>(
|
|
81
100
|
startDir: string = process.cwd(),
|
|
82
|
-
|
|
83
|
-
): { config:
|
|
84
|
-
const
|
|
101
|
+
configType: TType
|
|
102
|
+
): { config: ResolveConfig<TType>; meta: WorkspaceDetectResult } {
|
|
103
|
+
const fileName = `${configType}.config.json`;
|
|
104
|
+
const meta = detectWorkspaceAndConfigPath(startDir, fileName);
|
|
85
105
|
|
|
86
106
|
if (!fs.existsSync(meta.configPath)) {
|
|
87
107
|
const where =
|
|
@@ -89,10 +109,12 @@ export function loadAppConfig<T = DefaultAppConfig>(
|
|
|
89
109
|
`workspace root: ${meta.workspaceRoot}`
|
|
90
110
|
: `cwd: ${meta.cwd}`;
|
|
91
111
|
throw new Error(
|
|
92
|
-
`Could not find ${
|
|
112
|
+
`Could not find ${fileName} at ${meta.configPath} (detected from ${where}).`
|
|
93
113
|
);
|
|
94
114
|
}
|
|
95
115
|
|
|
96
116
|
const raw = fs.readFileSync(meta.configPath, 'utf8');
|
|
97
|
-
return { config: JSON.parse(raw) as
|
|
117
|
+
return { config: JSON.parse(raw) as ResolveConfig<TType>, meta };
|
|
98
118
|
}
|
|
119
|
+
|
|
120
|
+
export const loadProjectConfig = loadAppConfig;
|