create-skateboard-app 1.0.5 → 1.0.6

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/bin/cli.js +33 -13
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ 1.0.6
3
+
4
+ Update config format
5
+ Support databases array
6
+ Add backward compatibility
7
+
2
8
  1.0.5
3
9
 
4
10
  Remove env setup references
package/bin/cli.js CHANGED
@@ -368,25 +368,45 @@ async function main() {
368
368
  const backendConfigPath = join(projectName, 'backend', 'config.json');
369
369
  if (existsSync(backendConfigPath)) {
370
370
  const backendConfig = JSON.parse(readFileSync(backendConfigPath, 'utf8'));
371
- // Handle both array and single object formats defensively
372
- const configArray = Array.isArray(backendConfig) ? backendConfig : [backendConfig];
373
371
 
374
- configArray.forEach(configObj => {
375
- configObj.dbType = config.database.value;
372
+ // Handle new format with databases array
373
+ if (backendConfig.databases && Array.isArray(backendConfig.databases) && backendConfig.databases.length > 0) {
374
+ const dbConfig = backendConfig.databases[0];
375
+
376
+ // Set database configuration
377
+ dbConfig.dbType = config.database.value;
378
+ dbConfig.db = config.appName.replace(/\s+/g, '');
379
+ dbConfig.origin = config.devBackendURL;
380
+
376
381
  if (config.database.value === 'sqlite') {
377
- configObj.connectionString = config.database.connectionString;
382
+ dbConfig.connectionString = config.database.connectionString;
378
383
  } else if (config.database.value === 'postgresql') {
379
- // Always use environment variable placeholder in config.json
380
- configObj.connectionString = '${POSTGRES_URL}';
384
+ dbConfig.connectionString = '${POSTGRES_URL}';
381
385
  } else if (config.database.value === 'mongodb') {
382
- // Always use environment variable placeholder in config.json
383
- configObj.connectionString = '${MONGODB_URL}';
386
+ dbConfig.connectionString = '${MONGODB_URL}';
384
387
  }
385
- });
388
+ } else {
389
+ // Fallback for old format - handle both array and single object formats defensively
390
+ const configArray = Array.isArray(backendConfig) ? backendConfig : [backendConfig];
391
+
392
+ configArray.forEach(configObj => {
393
+ configObj.dbType = config.database.value;
394
+ if (config.database.value === 'sqlite') {
395
+ configObj.connectionString = config.database.connectionString;
396
+ } else if (config.database.value === 'postgresql') {
397
+ configObj.connectionString = '${POSTGRES_URL}';
398
+ } else if (config.database.value === 'mongodb') {
399
+ configObj.connectionString = '${MONGODB_URL}';
400
+ }
401
+ });
402
+
403
+ // Update backendConfig reference for old format
404
+ if (!Array.isArray(backendConfig)) {
405
+ Object.assign(backendConfig, configArray[0]);
406
+ }
407
+ }
386
408
 
387
- // Write back the original format (array or single object)
388
- const finalConfig = Array.isArray(backendConfig) ? configArray : configArray[0];
389
- writeFileSync(backendConfigPath, JSON.stringify(finalConfig, null, 2));
409
+ writeFileSync(backendConfigPath, JSON.stringify(backendConfig, null, 2));
390
410
  success(`Database configured: ${config.database.value}`);
391
411
  }
392
412
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skateboard-app",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Create a new Skateboard app with React, TailwindCSS, and more",
5
5
  "main": "index.js",
6
6
  "type": "module",