create-alta-app 2.1.0 → 2.5.0
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/index.mjs +52 -27
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { execSync } from 'node:child_process';
|
|
4
4
|
import fs from 'node:fs';
|
|
5
|
+
import os from 'node:os';
|
|
5
6
|
import path from 'node:path';
|
|
6
7
|
import prompts from 'prompts';
|
|
7
8
|
import ora from 'ora';
|
|
@@ -362,6 +363,9 @@ async function main() {
|
|
|
362
363
|
try {
|
|
363
364
|
credentials = await createProject(projectName, response.password);
|
|
364
365
|
spinnerCloud.succeed(pc.green('Cloud projects created'));
|
|
366
|
+
console.log(` ${pc.dim('Supabase:')} ${credentials.supabaseUrl || 'N/A'}`);
|
|
367
|
+
console.log(` ${pc.dim('Vercel:')} ${credentials.vercelUrl || 'N/A'}`);
|
|
368
|
+
console.log(` ${pc.dim('Vercel token:')} ${credentials.vercelToken ? credentials.vercelToken.slice(0, 8) + '...' : pc.red('NOT RECEIVED')}`);
|
|
365
369
|
} catch (err) {
|
|
366
370
|
spinnerCloud.fail(pc.yellow('Could not create cloud projects'));
|
|
367
371
|
console.log(` ${pc.dim(err.message)}`);
|
|
@@ -448,7 +452,7 @@ async function main() {
|
|
|
448
452
|
}
|
|
449
453
|
|
|
450
454
|
|
|
451
|
-
// ── Step 6: Login & link Supabase
|
|
455
|
+
// ── Step 6: Login & link Supabase ──
|
|
452
456
|
if (credentials) {
|
|
453
457
|
const spinnerLink = ora({ text: 'Linking Supabase project...', indent: 2 }).start();
|
|
454
458
|
try {
|
|
@@ -459,34 +463,51 @@ async function main() {
|
|
|
459
463
|
spinnerLink.warn(pc.yellow('Could not link Supabase project'));
|
|
460
464
|
console.log(` ${pc.dim(`Run manually: npx supabase login && npx supabase link --project-ref ${credentials.supabaseProjectRef}`)}`);
|
|
461
465
|
}
|
|
466
|
+
}
|
|
462
467
|
|
|
463
|
-
|
|
468
|
+
// ── Step 6b: Set Vercel token & link project ──
|
|
469
|
+
if (credentials?.vercelToken) {
|
|
470
|
+
const spinnerVercel = ora({ text: 'Configuring Vercel...', indent: 2 }).start();
|
|
464
471
|
try {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
472
|
+
const tokenPreview = credentials.vercelToken.slice(0, 8) + '...';
|
|
473
|
+
|
|
474
|
+
// Write VERCEL_TOKEN to ~/.zshrc for future shell sessions
|
|
475
|
+
const zshrc = path.join(os.homedir(), '.zshrc');
|
|
476
|
+
const zshrcContent = fs.existsSync(zshrc) ? fs.readFileSync(zshrc, 'utf-8') : '';
|
|
477
|
+
const exportLine = `export VERCEL_TOKEN="${credentials.vercelToken}"`;
|
|
478
|
+
|
|
479
|
+
if (zshrcContent.includes('export VERCEL_TOKEN=')) {
|
|
480
|
+
const updated = zshrcContent.replace(/export VERCEL_TOKEN=.*/, exportLine);
|
|
481
|
+
fs.writeFileSync(zshrc, updated);
|
|
482
|
+
spinnerVercel.text = `Vercel token updated in ~/.zshrc (${tokenPreview})`;
|
|
483
|
+
} else {
|
|
484
|
+
fs.appendFileSync(zshrc, `\n# Vercel CLI token (set by create-alta-app)\n${exportLine}\n`);
|
|
485
|
+
spinnerVercel.text = `Vercel token written to ~/.zshrc (${tokenPreview})`;
|
|
486
|
+
}
|
|
468
487
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
);
|
|
488
|
+
// Set in current process so child commands (vercel link, deploy) work immediately
|
|
489
|
+
process.env.VERCEL_TOKEN = credentials.vercelToken;
|
|
490
|
+
spinnerVercel.text = 'Vercel token set in process.env...';
|
|
473
491
|
|
|
474
|
-
//
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
492
|
+
// Source ~/.zshrc to load the token into spawned shell subprocesses
|
|
493
|
+
try {
|
|
494
|
+
execSync(`. ${zshrc}`, { shell: '/bin/zsh', stdio: 'ignore', env: { ...process.env, HOME: os.homedir() } });
|
|
495
|
+
spinnerVercel.text = 'Sourced ~/.zshrc — VERCEL_TOKEN loaded';
|
|
496
|
+
} catch {
|
|
497
|
+
spinnerVercel.text = 'Could not source ~/.zshrc — using process.env instead';
|
|
479
498
|
}
|
|
480
|
-
vercelConfig.currentTeam = credentials.vercelTeamId;
|
|
481
|
-
fs.writeFileSync(configPath, JSON.stringify(vercelConfig, null, 2) + '\n');
|
|
482
499
|
|
|
483
|
-
// Link the project
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
500
|
+
// Link the Vercel project
|
|
501
|
+
spinnerVercel.text = `Linking Vercel project: ${projectName}...`;
|
|
502
|
+
run(`npx vercel link --project ${projectName} --yes --token ${credentials.vercelToken}`, targetDir);
|
|
503
|
+
spinnerVercel.succeed(pc.green('Vercel configured & linked'));
|
|
504
|
+
} catch (err) {
|
|
505
|
+
spinnerVercel.warn(pc.yellow('Could not configure Vercel'));
|
|
506
|
+
console.log(` ${pc.dim('Error: ' + err.message)}`);
|
|
507
|
+
console.log(` ${pc.dim('Run manually: vercel link --project ' + projectName + ' --token $VERCEL_TOKEN')}`);
|
|
489
508
|
}
|
|
509
|
+
} else {
|
|
510
|
+
console.log(` ${pc.yellow('⚠')} No Vercel token received from server — skipping Vercel setup`);
|
|
490
511
|
}
|
|
491
512
|
|
|
492
513
|
// ── Step 7: Write project-specific MCP config ──
|
|
@@ -548,15 +569,19 @@ async function main() {
|
|
|
548
569
|
}
|
|
549
570
|
|
|
550
571
|
// ── Step 9: Deploy to Vercel ──
|
|
551
|
-
if (credentials?.
|
|
572
|
+
if (credentials?.vercelToken) {
|
|
552
573
|
const spinnerDeploy = ora({ text: 'Deploying to Vercel...', indent: 2 }).start();
|
|
553
574
|
try {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
575
|
+
spinnerDeploy.text = `Running: vercel --token ${credentials.vercelToken.slice(0, 8)}... in ${targetDir}`;
|
|
576
|
+
run(`npx vercel --token ${credentials.vercelToken}`, targetDir);
|
|
577
|
+
spinnerDeploy.succeed(pc.green(`Deployed to Vercel → ${credentials.vercelUrl || projectName + '.vercel.app'}`));
|
|
578
|
+
} catch (err) {
|
|
557
579
|
spinnerDeploy.warn(pc.yellow('Could not deploy to Vercel'));
|
|
558
|
-
console.log(` ${pc.dim('
|
|
580
|
+
console.log(` ${pc.dim('Error: ' + err.message)}`);
|
|
581
|
+
console.log(` ${pc.dim('Deploy manually: cd ' + projectName + ' && vercel --token $VERCEL_TOKEN')}`);
|
|
559
582
|
}
|
|
583
|
+
} else {
|
|
584
|
+
console.log(` ${pc.dim('Skipping Vercel deploy — no token available')}`);
|
|
560
585
|
}
|
|
561
586
|
|
|
562
587
|
// ── Step 10: Start dev server ──
|