fabrica-e-commerce 0.1.6 → 0.1.7
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/package.json +1 -1
- package/src/deploy.js +28 -5
package/package.json
CHANGED
package/src/deploy.js
CHANGED
|
@@ -4,7 +4,7 @@ import crypto from 'node:crypto';
|
|
|
4
4
|
import { HARDCODED_ENV, REQUIRED_ENV_KEYS, STORE_REPO } from './config.js';
|
|
5
5
|
import { buildsDir, saveProject } from './store.js';
|
|
6
6
|
import { runCommand, runCommandCapture } from './system.js';
|
|
7
|
-
import { kv, section, spinner } from './ui.js';
|
|
7
|
+
import { dimOrange, kv, section, spinner } from './ui.js';
|
|
8
8
|
import { ask, choose } from './prompt.js';
|
|
9
9
|
|
|
10
10
|
const VERCEL_ENVIRONMENTS = ['production', 'preview', 'development'];
|
|
@@ -60,6 +60,32 @@ async function setEnvEverywhere(project, env) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
// Vercel's GitHub App integration indexes newly created/forked repos on its
|
|
64
|
+
// own delay, separate from GitHub itself being aware of the repo. Right after
|
|
65
|
+
// a fork, `vercel git connect` can fail simply because Vercel hasn't synced
|
|
66
|
+
// yet — not because anything is actually wrong. Retry with backoff before
|
|
67
|
+
// giving up, then fall back to a direct deploy with clear next steps.
|
|
68
|
+
async function connectGithubRepo(project, repoUrl) {
|
|
69
|
+
const spin = spinner(`Connecting Vercel project to ${repoUrl}`);
|
|
70
|
+
const attempts = 6;
|
|
71
|
+
let lastError = '';
|
|
72
|
+
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
73
|
+
const connect = await runCommandCapture('npx', ['--yes', 'vercel@latest', 'git', 'connect', repoUrl, '--yes'], { cwd: project.target });
|
|
74
|
+
if (connect.code === 0) {
|
|
75
|
+
spin.succeed('Vercel project connected to GitHub repo (future pushes auto-deploy)');
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
lastError = (connect.stderr || connect.stdout || '').trim();
|
|
79
|
+
if (attempt < attempts) await new Promise((resolve) => setTimeout(resolve, attempt * 3000));
|
|
80
|
+
}
|
|
81
|
+
spin.fail('Could not auto-connect Git — continuing with a direct deploy');
|
|
82
|
+
console.log(dimOrange(' This usually means one of two things:'));
|
|
83
|
+
console.log(dimOrange(` 1) Vercel hasn't finished indexing the new fork yet (run "fabrica list" in a minute and re-link manually with: npx vercel git connect ${repoUrl})`));
|
|
84
|
+
console.log(dimOrange(' 2) The "Vercel" GitHub App is set to "Only select repositories" and was never granted access to the new fork — fix at https://github.com/settings/installations'));
|
|
85
|
+
if (lastError) console.log(dimOrange(` Last error: ${lastError}`));
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
63
89
|
export async function deployToVercel(project, env, githubRepo) {
|
|
64
90
|
section('Vercel deployment');
|
|
65
91
|
await ensureVercelLogin();
|
|
@@ -67,10 +93,7 @@ export async function deployToVercel(project, env, githubRepo) {
|
|
|
67
93
|
await runCommand('npx', ['vercel@latest', 'link', '--yes', '--project', project.projectName], { cwd: project.target });
|
|
68
94
|
|
|
69
95
|
if (githubRepo?.repoUrl) {
|
|
70
|
-
|
|
71
|
-
const connect = await runCommandCapture('npx', ['--yes', 'vercel@latest', 'git', 'connect', githubRepo.repoUrl, '--yes'], { cwd: project.target });
|
|
72
|
-
if (connect.code === 0) spin.succeed('Vercel project connected to GitHub repo (future pushes auto-deploy)');
|
|
73
|
-
else spin.fail('Could not auto-connect Git — continuing with a direct deploy');
|
|
96
|
+
await connectGithubRepo(project, githubRepo.repoUrl);
|
|
74
97
|
}
|
|
75
98
|
|
|
76
99
|
await setEnvEverywhere(project, env);
|