create-alta-app 4.1.0 → 4.2.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 +46 -29
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -583,18 +583,12 @@ async function main() {
|
|
|
583
583
|
console.log('');
|
|
584
584
|
}
|
|
585
585
|
|
|
586
|
-
// ── Step 9: Commit
|
|
586
|
+
// ── Step 9: Commit & trigger Vercel preview deploy via API ──
|
|
587
587
|
if (credentials) {
|
|
588
588
|
const spinnerDeploy = ora({ text: 'Preparing deploy...', indent: 2 }).start();
|
|
589
589
|
try {
|
|
590
590
|
const relAppPath = path.relative(process.cwd(), targetDir);
|
|
591
591
|
const monorepoRoot = process.cwd();
|
|
592
|
-
const branchName = `feat/add-${projectName}`;
|
|
593
|
-
|
|
594
|
-
// Create a new branch for the PR
|
|
595
|
-
spinnerDeploy.text = `Creating branch: ${branchName}...`;
|
|
596
|
-
runVerbose(`git checkout -b ${branchName}`, monorepoRoot);
|
|
597
|
-
spinnerDeploy.text = `On branch: ${branchName}`;
|
|
598
592
|
|
|
599
593
|
// Format files to pass pre-commit prettier check
|
|
600
594
|
spinnerDeploy.text = 'Formatting files with Prettier...';
|
|
@@ -615,37 +609,60 @@ async function main() {
|
|
|
615
609
|
runVerbose(`git commit --no-verify -m "feat: add ${projectName}"`, monorepoRoot);
|
|
616
610
|
spinnerDeploy.text = `Committed: feat: add ${projectName}`;
|
|
617
611
|
|
|
618
|
-
//
|
|
619
|
-
|
|
620
|
-
runVerbose(
|
|
621
|
-
|
|
612
|
+
// Get the current branch name and commit SHA
|
|
613
|
+
const currentBranch = runVerbose('git rev-parse --abbrev-ref HEAD', monorepoRoot).trim();
|
|
614
|
+
const commitSha = runVerbose('git rev-parse HEAD', monorepoRoot).trim();
|
|
615
|
+
|
|
616
|
+
// Push to the current branch
|
|
617
|
+
spinnerDeploy.text = `Pushing to ${currentBranch}...`;
|
|
618
|
+
runVerbose('git push origin HEAD', monorepoRoot);
|
|
619
|
+
spinnerDeploy.text = `Pushed to ${currentBranch}`;
|
|
622
620
|
|
|
623
|
-
//
|
|
624
|
-
spinnerDeploy.text = '
|
|
625
|
-
let prUrl = '';
|
|
621
|
+
// Trigger Vercel preview deploy via API (no PR needed)
|
|
622
|
+
spinnerDeploy.text = 'Triggering Vercel preview deploy...';
|
|
626
623
|
try {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
624
|
+
const deployRes = await fetch('https://api.vercel.com/v13/deployments?teamId=alta-ai', {
|
|
625
|
+
method: 'POST',
|
|
626
|
+
headers: {
|
|
627
|
+
Authorization: `Bearer ${credentials.vercelToken}`,
|
|
628
|
+
'Content-Type': 'application/json',
|
|
629
|
+
},
|
|
630
|
+
body: JSON.stringify({
|
|
631
|
+
name: projectName,
|
|
632
|
+
project: credentials.vercelProjectId,
|
|
633
|
+
gitSource: {
|
|
634
|
+
type: 'github',
|
|
635
|
+
org: 'altahq',
|
|
636
|
+
repo: 'alta',
|
|
637
|
+
ref: currentBranch,
|
|
638
|
+
sha: commitSha,
|
|
639
|
+
},
|
|
640
|
+
}),
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
if (deployRes.ok) {
|
|
644
|
+
const deployData = await deployRes.json();
|
|
645
|
+
const previewUrl = deployData.url ? `https://${deployData.url}` : credentials.vercelUrl;
|
|
646
|
+
spinnerDeploy.succeed(pc.green('Pushed & Vercel preview deploy triggered'));
|
|
647
|
+
console.log(` ${pc.dim('Branch:')} ${pc.cyan(currentBranch)}`);
|
|
648
|
+
console.log(` ${pc.dim('Preview:')} ${pc.cyan(previewUrl)}`);
|
|
649
|
+
} else {
|
|
650
|
+
const errText = await deployRes.text();
|
|
651
|
+
spinnerDeploy.succeed(pc.green(`Pushed to ${currentBranch}`));
|
|
652
|
+
console.log(` ${pc.dim('Vercel deploy API error: ' + errText)}`);
|
|
653
|
+
}
|
|
654
|
+
} catch (deployErr) {
|
|
655
|
+
spinnerDeploy.succeed(pc.green(`Pushed to ${currentBranch}`));
|
|
656
|
+
console.log(` ${pc.dim('Could not trigger Vercel deploy: ' + deployErr.message)}`);
|
|
638
657
|
}
|
|
639
658
|
|
|
640
659
|
const deployUrl = credentials.vercelUrl || `https://${projectName}.vercel.app`;
|
|
641
|
-
console.log(` ${pc.dim('
|
|
642
|
-
console.log(` ${pc.dim('Production deploy will happen when PR is merged to main')}`);
|
|
660
|
+
console.log(` ${pc.dim('Production URL:')} ${pc.cyan(deployUrl)}`);
|
|
643
661
|
} catch (err) {
|
|
644
662
|
spinnerDeploy.warn(pc.yellow('Could not push to GitHub'));
|
|
645
663
|
console.log(` ${pc.dim('Error: ' + err.message)}`);
|
|
646
664
|
console.log(` ${pc.dim('Push manually:')}`);
|
|
647
|
-
console.log(` ${pc.cyan(`git
|
|
648
|
-
console.log(` ${pc.cyan(`gh pr create --base main --head feat/add-${projectName}`)}`);
|
|
665
|
+
console.log(` ${pc.cyan(`git add apps/ai-engineer/${projectName} && git commit -m "feat: add ${projectName}" && git push origin HEAD`)}`);
|
|
649
666
|
}
|
|
650
667
|
}
|
|
651
668
|
|