@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mono-labs/cli",
3
- "version": "0.0.185",
3
+ "version": "0.0.186",
4
4
  "description": "A CLI tool for building and deploying projects",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -83,14 +83,23 @@ type DefaultDeployConfig = {
83
83
  regions?: string[];
84
84
  };
85
85
 
86
- /** Convenience: load the JSON config using the resolution logic above. */
87
- export function loadAppConfig<
88
- X extends string = string,
89
- T = X extends 'app' ? DefaultAppConfig : DefaultDeployConfig,
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: X = 'app' as X
93
- ): { config: T; meta: WorkspaceDetectResult } {
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 T, meta };
117
+ return { config: JSON.parse(raw) as ResolveConfig<TType>, meta };
109
118
  }
110
119
 
111
120
  export const loadProjectConfig = loadAppConfig;