@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mono-labs/cli",
3
- "version": "0.0.185",
3
+ "version": "0.0.187",
4
4
  "description": "A CLI tool for building and deploying projects",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -83,14 +83,22 @@ 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
- >(
91
- startDir: string = process.cwd(),
92
- configType: X = 'app' as X
93
- ): { config: T; meta: WorkspaceDetectResult } {
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 T, meta };
116
+ return { config: JSON.parse(raw) as ResolveConfig<TType, TCustom>, meta };
109
117
  }
110
118
 
111
119
  export const loadProjectConfig = loadAppConfig;