create-alta-app 2.2.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 +51 -20
- 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)}`);
|
|
@@ -461,26 +465,49 @@ async function main() {
|
|
|
461
465
|
}
|
|
462
466
|
}
|
|
463
467
|
|
|
464
|
-
// ── Step 6b:
|
|
465
|
-
if (credentials) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
468
|
+
// ── Step 6b: Set Vercel token & link project ──
|
|
469
|
+
if (credentials?.vercelToken) {
|
|
470
|
+
const spinnerVercel = ora({ text: 'Configuring Vercel...', indent: 2 }).start();
|
|
471
|
+
try {
|
|
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
|
+
}
|
|
487
|
+
|
|
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...';
|
|
491
|
+
|
|
492
|
+
// Source ~/.zshrc to load the token into spawned shell subprocesses
|
|
469
493
|
try {
|
|
470
|
-
execSync(
|
|
494
|
+
execSync(`. ${zshrc}`, { shell: '/bin/zsh', stdio: 'ignore', env: { ...process.env, HOME: os.homedir() } });
|
|
495
|
+
spinnerVercel.text = 'Sourced ~/.zshrc — VERCEL_TOKEN loaded';
|
|
471
496
|
} catch {
|
|
472
|
-
|
|
497
|
+
spinnerVercel.text = 'Could not source ~/.zshrc — using process.env instead';
|
|
473
498
|
}
|
|
474
|
-
}
|
|
475
499
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
run(`npx vercel link --project ${projectName} --yes`, targetDir);
|
|
479
|
-
spinnerVercel.succeed(pc.green('Vercel
|
|
480
|
-
} catch {
|
|
481
|
-
spinnerVercel.warn(pc.yellow('Could not
|
|
482
|
-
console.log(` ${pc.dim('
|
|
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')}`);
|
|
483
508
|
}
|
|
509
|
+
} else {
|
|
510
|
+
console.log(` ${pc.yellow('⚠')} No Vercel token received from server — skipping Vercel setup`);
|
|
484
511
|
}
|
|
485
512
|
|
|
486
513
|
// ── Step 7: Write project-specific MCP config ──
|
|
@@ -542,15 +569,19 @@ async function main() {
|
|
|
542
569
|
}
|
|
543
570
|
|
|
544
571
|
// ── Step 9: Deploy to Vercel ──
|
|
545
|
-
if (credentials?.
|
|
572
|
+
if (credentials?.vercelToken) {
|
|
546
573
|
const spinnerDeploy = ora({ text: 'Deploying to Vercel...', indent: 2 }).start();
|
|
547
574
|
try {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
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) {
|
|
551
579
|
spinnerDeploy.warn(pc.yellow('Could not deploy to Vercel'));
|
|
552
|
-
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')}`);
|
|
553
582
|
}
|
|
583
|
+
} else {
|
|
584
|
+
console.log(` ${pc.dim('Skipping Vercel deploy — no token available')}`);
|
|
554
585
|
}
|
|
555
586
|
|
|
556
587
|
// ── Step 10: Start dev server ──
|