Skip to content

Commit

Permalink
feat: add vercel project linking instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
maneike committed Nov 5, 2024
1 parent 921f6af commit 19ec555
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 69 deletions.
4 changes: 1 addition & 3 deletions packages/core/utils/github/repositoryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ export const authenticateGitHub = async (): Promise<boolean> => {
};

export const fetchGitHubUsername = async (): Promise<string | null> => {
logWithColoredPrefix('github', `Retrieving username...`);
try {
const username = execSync('echo "$(gh api user --jq .login)"', { stdio: 'pipe' }).toString().trim();

logWithColoredPrefix('github', `Retrieved GitHub username: ${username}`);

if (username) {
logWithColoredPrefix('github', `Hello ${username}!`);
return username;
} else {
logWithColoredPrefix('github', 'No username returned or an error occurred.');
Expand Down
46 changes: 0 additions & 46 deletions packages/core/utils/vercel/connectWithGH.ts

This file was deleted.

20 changes: 4 additions & 16 deletions packages/core/utils/vercel/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
import fs from 'fs/promises';
import { execSync } from 'node:child_process';
import { connectWithGH } from './connectWithGH';
import { logWithColoredPrefix } from '../shared/logWithColoredPrefix';

export const deployVercelProject = async () => {
try {
await connectWithGH();
} catch (error: any) {
logWithColoredPrefix('vercel', ['An unexpected error occurred:', error, '\nFailed to connect GitHub with Vercel']);
}

logWithColoredPrefix('vercel', 'Creating vercel.json...');

const vercelConfig = {
buildCommand: 'pnpm build',
outputDirectory: 'apps/web',
};

await fs.writeFile('vercel.json', JSON.stringify(vercelConfig, null, 2));
execSync('npx vercel git connect', {
stdio: ['inherit', 'pipe', 'inherit'],
encoding: 'utf-8',
});

logWithColoredPrefix('vercel', 'Creating production deployment...');

Expand Down
10 changes: 6 additions & 4 deletions packages/core/utils/vercel/setupAndCreate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { execSync } from 'child_process';
import { logWithColoredPrefix } from '../shared/logWithColoredPrefix';
import chalk from 'chalk';

const getUserName = (): string | null => {
try {
Expand Down Expand Up @@ -37,9 +38,10 @@ export const setupAndCreateVercelProject = async () => {
logWithColoredPrefix('vercel', `You are logged as \x1b[36m${vercelUserName}\x1b[0m`);
}

logWithColoredPrefix('vercel', 'Initializing project...');
execSync('npx vercel init');

logWithColoredPrefix('vercel', '\nLinking project...');
logWithColoredPrefix('vercel', 'Linking project...');
logWithColoredPrefix(
'vercel',
`NOTE: You need to specify manually ${chalk.cyan('in which directory is your code located')}, should be: ${chalk.greenBright('./apps/web')}`,
);
execSync('npx vercel link', { stdio: 'inherit' });
};

0 comments on commit 19ec555

Please sign in to comment.