@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mono-labs/cli",
3
- "version": "0.0.184",
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",
@@ -76,12 +76,32 @@ type DefaultAppConfig = {
76
76
  regions?: string[];
77
77
  };
78
78
 
79
- /** Convenience: load the JSON config using the resolution logic above. */
80
- export function loadAppConfig<T = DefaultAppConfig>(
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
- configFileName: string = 'app.config.json'
83
- ): { config: T; meta: WorkspaceDetectResult } {
84
- const meta = detectWorkspaceAndConfigPath(startDir, configFileName);
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 ${configFileName} at ${meta.configPath} (detected from ${where}).`
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 T, meta };
117
+ return { config: JSON.parse(raw) as ResolveConfig<TType>, meta };
98
118
  }
119
+
120
+ export const loadProjectConfig = loadAppConfig;