create-alta-app 1.7.0 → 1.7.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.
Files changed (2) hide show
  1. package/index.mjs +33 -10
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -322,6 +322,8 @@ async function main() {
322
322
  if (fs.existsSync(packagesDir) && fs.readdirSync(packagesDir).length === 0) {
323
323
  fs.rmSync(packagesDir, { recursive: true, force: true });
324
324
  }
325
+ const scriptsDir = path.join(targetDir, 'scripts');
326
+ if (fs.existsSync(scriptsDir)) fs.rmSync(scriptsDir, { recursive: true, force: true });
325
327
 
326
328
  const rootPkgPath = path.join(targetDir, 'package.json');
327
329
  const rootPkg = JSON.parse(fs.readFileSync(rootPkgPath, 'utf-8'));
@@ -463,20 +465,29 @@ async function main() {
463
465
  // ── Step 6: Setup shell credentials (like AWS sandbox keys in ~/.zshrc) ──
464
466
  const shellRc = path.join(os.homedir(), '.zshrc');
465
467
  const tokensToSet = {
466
- SUPABASE_ACCESS_TOKEN: 'sbp_85c565540fbc50b75873cf643226881cd4f58af5',
468
+ SUPABASE_ACCESS_TOKEN: 'sbp_66e351be37d4e570fe4347ea7c78bbebc8988219',
467
469
  };
468
470
 
469
471
  try {
470
- const rcContent = fs.existsSync(shellRc) ? fs.readFileSync(shellRc, 'utf-8') : '';
471
- const missing = Object.entries(tokensToSet).filter(([key]) => !rcContent.includes(`export ${key}=`));
472
+ let rcContent = fs.existsSync(shellRc) ? fs.readFileSync(shellRc, 'utf-8') : '';
473
+ let changed = false;
472
474
 
473
- if (missing.length > 0) {
474
- const spinnerShell = ora({ text: 'Setting up shell credentials...', indent: 2 }).start();
475
- const lines = ['\n# Alta'];
476
- for (const [key, value] of missing) {
477
- lines.push(`export ${key}=${value}`);
475
+ for (const [key, value] of Object.entries(tokensToSet)) {
476
+ const regex = new RegExp(`^export ${key}=.*$`, 'm');
477
+ const line = `export ${key}=${value}`;
478
+
479
+ if (regex.test(rcContent)) {
480
+ rcContent = rcContent.replace(regex, line);
481
+ } else {
482
+ rcContent += `\n# Alta\n${line}\n`;
478
483
  }
479
- fs.appendFileSync(shellRc, lines.join('\n') + '\n');
484
+ process.env[key] = value;
485
+ }
486
+ changed = true;
487
+
488
+ if (changed) {
489
+ const spinnerShell = ora({ text: 'Setting up shell credentials...', indent: 2 }).start();
490
+ fs.writeFileSync(shellRc, rcContent);
480
491
  spinnerShell.succeed(pc.green('Shell credentials configured'));
481
492
  }
482
493
  } catch {
@@ -541,7 +552,19 @@ async function main() {
541
552
  console.log('');
542
553
  }
543
554
 
544
- // ── Step 9: Start dev server ──
555
+ // ── Step 9: Deploy to Vercel ──
556
+ if (credentials?.vercelProjectName) {
557
+ const spinnerDeploy = ora({ text: 'Deploying to Vercel...', indent: 2 }).start();
558
+ try {
559
+ run('pnpm run deploy', targetDir);
560
+ spinnerDeploy.succeed(pc.green('Deployed to Vercel'));
561
+ } catch {
562
+ spinnerDeploy.warn(pc.yellow('Could not deploy to Vercel'));
563
+ console.log(` ${pc.dim('Deploy manually: cd ' + projectName + ' && pnpm deploy')}`);
564
+ }
565
+ }
566
+
567
+ // ── Step 10: Start dev server ──
545
568
  console.log(` ${pc.bold('Starting dev server...')}`);
546
569
  console.log('');
547
570
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-alta-app",
3
- "version": "1.7.0",
3
+ "version": "1.7.3",
4
4
  "description": "Create a new Alta project",
5
5
  "bin": {
6
6
  "create-alta-app": "./index.mjs"