genbox 1.0.13 → 1.0.15

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.
@@ -56,9 +56,11 @@ class ProfileResolver {
56
56
  }
57
57
  /**
58
58
  * Resolve configuration from options (CLI flags, profile, interactive)
59
+ * Supports both v3 and v4 configs
59
60
  */
60
61
  async resolve(config, options) {
61
62
  const warnings = [];
63
+ const isV4Config = (0, config_loader_1.isV4)(config);
62
64
  // Step 1: Get base profile (if specified)
63
65
  let profile = {};
64
66
  if (options.profile) {
@@ -107,13 +109,13 @@ class ProfileResolver {
107
109
  size,
108
110
  project: {
109
111
  name: config.project.name,
110
- structure: config.project.structure,
112
+ structure: (config.project.structure === '$detect' ? 'single-app' : config.project.structure),
111
113
  },
112
114
  apps,
113
115
  infrastructure,
114
116
  database,
115
117
  repos: this.resolveRepos(config, apps),
116
- env: this.resolveEnvVars(config, apps, infrastructure, database, profile.connect_to),
118
+ env: this.resolveEnvVars(config, apps, infrastructure, database, (0, config_loader_1.getProfileConnection)(profile)),
117
119
  hooks: config.hooks || {},
118
120
  profile: options.profile,
119
121
  warnings,
@@ -150,8 +152,8 @@ class ProfileResolver {
150
152
  const resolvedInfra = [];
151
153
  const warnings = [];
152
154
  const processedDeps = new Set();
153
- // Default environment for dependencies
154
- const defaultEnv = profile.connect_to || options.api;
155
+ // Default environment for dependencies (v3: connect_to, v4: default_connection)
156
+ const defaultEnv = (0, config_loader_1.getProfileConnection)(profile) || options.api;
155
157
  for (const appName of selectedApps) {
156
158
  const appConfig = config.apps[appName];
157
159
  if (!appConfig) {
@@ -161,12 +163,13 @@ class ProfileResolver {
161
163
  const resolvedApp = await this.resolveApp(config, appName, appConfig, selectedApps, defaultEnv, options, processedDeps);
162
164
  resolvedApps.push(resolvedApp);
163
165
  }
164
- // Collect infrastructure needs
166
+ // Collect infrastructure needs (v3: infrastructure, v4: provides)
167
+ const infrastructure = (0, config_loader_1.getInfrastructure)(config);
165
168
  for (const app of resolvedApps) {
166
169
  for (const [depName, depConfig] of Object.entries(app.dependencies)) {
167
170
  if (processedDeps.has(depName))
168
171
  continue;
169
- const infraConfig = config.infrastructure?.[depName];
172
+ const infraConfig = infrastructure?.[depName];
170
173
  if (infraConfig) {
171
174
  resolvedInfra.push({
172
175
  name: depName,
@@ -188,14 +191,19 @@ class ProfileResolver {
188
191
  */
189
192
  async resolveApp(config, appName, appConfig, selectedApps, defaultEnv, options, processedDeps) {
190
193
  const dependencies = {};
191
- // Process each dependency
192
- for (const [depName, requirement] of Object.entries(appConfig.requires || {})) {
193
- if (requirement === 'none')
194
+ const infrastructure = (0, config_loader_1.getInfrastructure)(config);
195
+ // Process each dependency (v3: requires, v4: connects_to)
196
+ const appDeps = (0, config_loader_1.isV4)(config)
197
+ ? Object.entries(appConfig.connects_to || {})
198
+ : Object.entries(appConfig.requires || {});
199
+ for (const [depName, requirement] of appDeps) {
200
+ // v3 uses 'none', v4 uses { required: false }
201
+ if (requirement === 'none' || (typeof requirement === 'object' && !requirement.required))
194
202
  continue;
195
203
  // Check if dependency is already in selected apps
196
204
  const isLocalApp = selectedApps.includes(depName);
197
205
  // Check if it's infrastructure
198
- const isInfra = config.infrastructure?.[depName];
206
+ const isInfra = infrastructure?.[depName];
199
207
  if (isLocalApp) {
200
208
  // Dependency is included locally
201
209
  dependencies[depName] = { mode: 'local' };
@@ -210,12 +218,12 @@ class ProfileResolver {
210
218
  url,
211
219
  };
212
220
  }
213
- else if (requirement === 'required' && !options.yes) {
221
+ else if ((requirement === 'required' || (typeof requirement === 'object' && requirement.required)) && !options.yes) {
214
222
  // Prompt user for resolution
215
223
  const resolution = await this.promptDependencyResolution(config, appName, depName, isInfra ? 'infrastructure' : 'app');
216
224
  dependencies[depName] = resolution;
217
225
  }
218
- else if (requirement === 'optional') {
226
+ else if (requirement === 'optional' || (typeof requirement === 'object' && !requirement.required)) {
219
227
  // Skip optional dependencies if not explicitly included
220
228
  continue;
221
229
  }
@@ -325,13 +333,18 @@ class ProfileResolver {
325
333
  source: profile.database.source,
326
334
  };
327
335
  }
328
- // If connect_to is set, use remote
329
- if (profile.connect_to) {
330
- const envConfig = config.environments?.[profile.connect_to];
336
+ // If connect_to (v3) or default_connection (v4) is set, use remote
337
+ const profileConnection = (0, config_loader_1.getProfileConnection)(profile);
338
+ if (profileConnection) {
339
+ const envConfig = config.environments?.[profileConnection];
340
+ // v4 uses urls.mongodb, v3 uses mongodb.url
341
+ const mongoUrl = (0, config_loader_1.isV4)(config)
342
+ ? envConfig?.urls?.mongodb
343
+ : envConfig?.mongodb?.url;
331
344
  return {
332
345
  mode: 'remote',
333
- source: profile.connect_to,
334
- url: envConfig?.mongodb?.url,
346
+ source: profileConnection,
347
+ url: mongoUrl,
335
348
  };
336
349
  }
337
350
  // Interactive mode
@@ -385,10 +398,14 @@ class ProfileResolver {
385
398
  else if (answer.startsWith('remote-')) {
386
399
  const source = answer.replace('remote-', '');
387
400
  const envConfig = config.environments?.[source];
401
+ // v4 uses urls.mongodb, v3 uses mongodb.url
402
+ const mongoUrl = (0, config_loader_1.isV4)(config)
403
+ ? envConfig?.urls?.mongodb
404
+ : envConfig?.mongodb?.url;
388
405
  return {
389
406
  mode: 'remote',
390
407
  source,
391
- url: envConfig?.mongodb?.url,
408
+ url: mongoUrl,
392
409
  };
393
410
  }
394
411
  return { mode: 'local' };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genbox",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Genbox CLI - AI-Powered Development Environments",
5
5
  "main": "dist/index.js",
6
6
  "bin": {