fabrica-e-commerce 0.1.6 → 0.1.8

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 (3) hide show
  1. package/package.json +1 -1
  2. package/src/deploy.js +28 -5
  3. package/src/ui.js +11 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fabrica-e-commerce",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Orange themed CMD launcher for deploying Fabrica e-commerce stores with Supabase and Vercel.",
5
5
  "type": "module",
6
6
  "bin": {
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
- const spin = spinner(`Connecting Vercel project to ${githubRepo.repoUrl}`);
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);
package/src/ui.js CHANGED
@@ -16,7 +16,17 @@ export function banner() {
16
16
  }
17
17
  export function section(title) { console.log('\n' + orange(`◆ ${title}`)); }
18
18
  export function kv(key, value) { console.log(`${dimOrange('>')} ${bold(key)} ${dimOrange('→')} ${value}`); }
19
- export function spinner(text) { process.stdout.write(dimOrange('> ') + text); return { succeed(msg) { process.stdout.write(`\r${orange('✓')} ${msg}\n`); }, fail(msg) { process.stdout.write(`\r${orange('✗')} ${msg}\n`); } }; }
19
+ // Clear the rest of the line (\x1b[K) before writing the final message so a
20
+ // shorter success/fail message never leaves leftover characters from the
21
+ // longer spinner text trailing after it (e.g. "✓ Git foundGit").
22
+ const CLEAR_LINE = '\x1b[K';
23
+ export function spinner(text) {
24
+ process.stdout.write(dimOrange('> ') + text);
25
+ return {
26
+ succeed(msg) { process.stdout.write(`\r${CLEAR_LINE}${orange('✓')} ${msg}\n`); },
27
+ fail(msg) { process.stdout.write(`\r${CLEAR_LINE}${orange('✗')} ${msg}\n`); }
28
+ };
29
+ }
20
30
  export function help() {
21
31
  banner();
22
32
  console.log(`