create-skateboard-app 1.0.2 → 1.0.3

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.
@@ -0,0 +1,11 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(git add:*)",
5
+ "Bash(git commit:*)",
6
+ "Bash(git push:*)"
7
+ ],
8
+ "deny": [],
9
+ "ask": []
10
+ }
11
+ }
package/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ 1.0.3
3
+
4
+ Add database selection
5
+ Auto-install dependencies
6
+ Include Stripe setup
7
+ Fix config formatting
8
+
2
9
  1.0.2
3
10
 
4
11
  Clarify prompt labels
package/bin/cli.js CHANGED
@@ -222,6 +222,23 @@ async function collectProjectConfig(projectName) {
222
222
 
223
223
  const selectedIcon = await askChoice('Choose an app icon:', iconChoices);
224
224
 
225
+ // Database selection
226
+ const databaseChoices = [
227
+ { label: '🗃️ SQLite (default)', value: 'sqlite', connectionString: `./databases/${appName.replace(/\s+/g, '')}.db` },
228
+ { label: '🐘 PostgreSQL', value: 'postgresql', connectionString: 'postgresql://user:password@localhost:5432/dbname' },
229
+ { label: '🍃 MongoDB', value: 'mongodb', connectionString: 'mongodb://localhost:27017/dbname' }
230
+ ];
231
+
232
+ const selectedDatabase = await askChoice('Choose your database:', databaseChoices, 0);
233
+
234
+ // Get connection string for non-SQLite databases
235
+ let connectionString = '';
236
+ if (selectedDatabase.value === 'postgresql') {
237
+ connectionString = await ask('PostgreSQL connection string (optional)', '');
238
+ } else if (selectedDatabase.value === 'mongodb') {
239
+ connectionString = await ask('MongoDB connection string (optional)', '');
240
+ }
241
+
225
242
  // Default values for removed questions
226
243
  const backendURL = 'https://api.example.com';
227
244
  const devBackendURL = 'http://localhost:8000';
@@ -232,7 +249,7 @@ async function collectProjectConfig(projectName) {
232
249
  ];
233
250
 
234
251
  // Installation preferences
235
- const installDeps = await askYesNo('Install dependencies automatically?', true);
252
+ const installDeps = true; // Always install dependencies
236
253
  const initGit = await askYesNo('Initialize git repository?', true);
237
254
 
238
255
  return {
@@ -241,6 +258,8 @@ async function collectProjectConfig(projectName) {
241
258
  tagline,
242
259
  appColor: selectedColor.value,
243
260
  appIcon: selectedIcon.value,
261
+ database: selectedDatabase,
262
+ connectionString,
244
263
  backendURL,
245
264
  devBackendURL,
246
265
  pages,
@@ -344,7 +363,51 @@ async function main() {
344
363
  success('App configuration updated');
345
364
  }
346
365
 
347
- // Step 5: Update app color in styles.css
366
+ // Step 5: Configure database settings
367
+ info('Configuring database...');
368
+ const backendConfigPath = join(projectName, 'backend', 'config.json');
369
+ if (existsSync(backendConfigPath)) {
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
+
374
+ configArray.forEach(configObj => {
375
+ configObj.dbType = config.database.value;
376
+ if (config.database.value === 'sqlite') {
377
+ configObj.connectionString = config.database.connectionString;
378
+ } else if (config.database.value === 'postgresql') {
379
+ // Always use environment variable placeholder in config.json
380
+ configObj.connectionString = '${POSTGRES_URL}';
381
+ } else if (config.database.value === 'mongodb') {
382
+ // Always use environment variable placeholder in config.json
383
+ configObj.connectionString = '${MONGODB_URL}';
384
+ }
385
+ });
386
+
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));
390
+ success(`Database configured: ${config.database.value}`);
391
+ }
392
+
393
+ // Create .env file if connection string provided
394
+ if (config.connectionString && (config.database.value === 'postgresql' || config.database.value === 'mongodb')) {
395
+ info('Creating .env file...');
396
+ const backendDir = join(projectName, 'backend');
397
+ const envPath = join(backendDir, '.env');
398
+
399
+ // Ensure backend directory exists
400
+ if (!existsSync(backendDir)) {
401
+ mkdirSync(backendDir, { recursive: true });
402
+ }
403
+
404
+ const envVar = config.database.value === 'postgresql' ? 'POSTGRES_URL' : 'MONGODB_URL';
405
+ const envContent = `${envVar}=${config.connectionString}\n`;
406
+ writeFileSync(envPath, envContent);
407
+ success('.env file created with database connection');
408
+ }
409
+
410
+ // Step 6: Update app color in styles.css
348
411
  info('Setting app color...');
349
412
  const stylesPath = join(projectName, 'src', 'assets', 'styles.css');
350
413
  if (existsSync(stylesPath)) {
@@ -358,14 +421,12 @@ async function main() {
358
421
  success(`App color set to ${config.appColor}`);
359
422
  }
360
423
 
361
- // Step 6: Install dependencies (if requested)
362
- if (config.installDeps) {
363
- info('Installing dependencies...');
364
- execSync(`cd ${projectName} && npm install`, { stdio: 'inherit' });
365
- success('Dependencies installed');
366
- }
424
+ // Step 7: Install dependencies
425
+ info('Installing dependencies...');
426
+ execSync(`cd ${projectName} && npm install`, { stdio: 'inherit' });
427
+ success('Dependencies installed');
367
428
 
368
- // Step 7: Initialize git (if requested)
429
+ // Step 8: Initialize git (if requested)
369
430
  if (config.initGit) {
370
431
  info('Initializing git repository...');
371
432
  execSync(`cd ${projectName} && git init`, { stdio: 'pipe' });
@@ -380,12 +441,28 @@ async function main() {
380
441
  log(` 💬 Tagline: ${config.tagline}`);
381
442
  log(` 🎨 Color: ${config.appColor}`);
382
443
  log(` 🎯 Icon: ${config.appIcon}`);
444
+ log(` 🗃️ Database: ${config.database.value}`);
445
+
446
+ // Database-specific instructions (only if connection string not provided)
447
+ if (config.database.value === 'postgresql' && !config.connectionString) {
448
+ log(`\n${colors.yellow}📝 PostgreSQL Setup:${colors.reset}`);
449
+ log(` Update the ${colors.cyan}backend/.env${colors.reset} file with:`);
450
+ log(` ${colors.green}POSTGRES_URL=postgresql://username:password@localhost:5432/dbname${colors.reset}`);
451
+ } else if (config.database.value === 'mongodb' && !config.connectionString) {
452
+ log(`\n${colors.yellow}📝 MongoDB Setup:${colors.reset}`);
453
+ log(` Update the ${colors.cyan}backend/.env${colors.reset} file with:`);
454
+ log(` ${colors.green}MONGODB_URL=mongodb://localhost:27017/dbname${colors.reset}`);
455
+ }
456
+
457
+ // Stripe setup instructions
458
+ log(`\n${colors.yellow}💳 Stripe Setup:${colors.reset}`);
459
+ log(` Update the ${colors.cyan}backend/.env${colors.reset} file with:`);
460
+ log(` ${colors.green}STRIPE_KEY=sk_test_your_stripe_secret_key_here${colors.reset}`);
461
+ log(` ${colors.green}STRIPE_ENDPOINT_SECRET=whsec_your_webhook_endpoint_secret_here${colors.reset}`);
462
+ log(` Get your keys from: ${colors.blue}https://dashboard.stripe.com/apikeys${colors.reset}`);
383
463
 
384
464
  log(`\n${colors.bold}Get started with:${colors.reset}`, 'yellow');
385
465
  log(`\n ${colors.cyan}cd ${projectName}${colors.reset}`);
386
- if (!config.installDeps) {
387
- log(` ${colors.cyan}npm install${colors.reset}`);
388
- }
389
466
  log(` ${colors.cyan}npm run start${colors.reset}`);
390
467
  log(`\n${colors.yellow}Happy coding! 🛹${colors.reset}\n`);
391
468
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skateboard-app",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Create a new Skateboard app with React, TailwindCSS, and more",
5
5
  "main": "index.js",
6
6
  "type": "module",