create-alta-app 4.0.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.
Files changed (2) hide show
  1. package/index.mjs +46 -29
  2. 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, push & create PR to trigger Vercel preview deploy ──
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
- // Push the new branch to GitHub
619
- spinnerDeploy.text = `Pushing branch ${branchName}...`;
620
- runVerbose(`git push -u origin ${branchName}`, monorepoRoot);
621
- spinnerDeploy.text = `Pushed branch: ${branchName}`;
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
- // Create PR via gh CLI this triggers Vercel preview deploy
624
- spinnerDeploy.text = 'Creating pull request...';
625
- let prUrl = '';
621
+ // Trigger Vercel preview deploy via API (no PR needed)
622
+ spinnerDeploy.text = 'Triggering Vercel preview deploy...';
626
623
  try {
627
- prUrl = runVerbose(
628
- `gh pr create --title "feat: add ${projectName}" --body "Auto-generated by create-alta-app" --base main --head ${branchName}`,
629
- monorepoRoot
630
- ).trim();
631
- spinnerDeploy.succeed(pc.green('PR created — Vercel preview deploy triggered'));
632
- console.log(` ${pc.dim('PR:')} ${pc.cyan(prUrl)}`);
633
- } catch (prErr) {
634
- // gh CLI might not be installed — push still succeeded
635
- spinnerDeploy.succeed(pc.green(`Pushed to GitHub (branch: ${branchName})`));
636
- console.log(` ${pc.dim('Could not create PR automatically: ' + prErr.message)}`);
637
- console.log(` ${pc.dim('Create PR manually:')} ${pc.cyan(`gh pr create --base main --head ${branchName}`)}`);
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('Vercel preview:')} ${pc.cyan(deployUrl)}`);
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 checkout -b feat/add-${projectName} && git add apps/ai-engineer/${projectName} && git commit -m "feat: add ${projectName}" && git push -u origin feat/add-${projectName}`)}`);
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-alta-app",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "Create a new Alta project",
5
5
  "bin": {
6
6
  "create-alta-app": "./index.mjs"