Skip to content

Commit

Permalink
feat: improve prepareDrink messages
Browse files Browse the repository at this point in the history
  • Loading branch information
maneike committed Nov 25, 2024
1 parent 48d477d commit 8a30114
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
6 changes: 3 additions & 3 deletions packages/core/installMachine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ const createInstallMachine = (initialContext: InstallMachineContext) => {
deployVercelProjectActor: createStepMachine(
fromPromise<void, InstallMachineContext, AnyEventObject>(async ({ input }) => {
try {
await deployVercelProject();
await deployVercelProject(input.stateData);
input.stateData.stepsCompleted.deployVercelProject = true;
saveStateToRcFile(input.stateData, input.projectDir);
} catch (error) {
Expand All @@ -495,8 +495,8 @@ const createInstallMachine = (initialContext: InstallMachineContext) => {
prepareDrinkActor: createStepMachine(
fromPromise<void, InstallMachineContext, AnyEventObject>(async ({ input }) => {
try {
const { projectName } = input.stateData;
prepareDrink(projectName);
const { projectName, prettyDeploymentUrl } = input.stateData;
prepareDrink(projectName, prettyDeploymentUrl);
input.stateData.stepsCompleted.prepareDrink = true;
saveStateToRcFile(input.stateData, input.projectDir);
} catch (error) {
Expand Down
9 changes: 5 additions & 4 deletions packages/core/installMachine/installSteps/bar/prepareDrink.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import chalk from 'chalk';
import { delay } from '../../../utils/delay';

const getMessages = (name: string) => {
const getMessages = (name: string, prettyDeploymentUrl: string) => {
return [
'🍸 Filling a high ball glass with ice...',
'🍸 Adding gin and lime juice...',
`🍸 Topping with ${chalk.blue('Tonik')}...`,
'🍸 Garnishing with lime wedge...',
`🍸 ${chalk.green(`Your Stapled ${name} is ready!`)}`,
`🍸 You can now run: ${chalk.cyan(`cd ${name} && pnpm dev`)}`,
`🍸 Ready to explore? Jump into your project with: ${chalk.cyan(`cd ${name} && pnpm dev`)}`,
`🍸 Prefer to see it online? Check it out here: ${chalk.cyan(prettyDeploymentUrl)}`,
];
};

export const prepareDrink = async (name: string) => {
const messages = getMessages(name);
export const prepareDrink = async (name: string, prettyDeploymentUrl: string) => {
const messages = getMessages(name, prettyDeploymentUrl);

for (const message of messages) {
console.log(message);
Expand Down
15 changes: 6 additions & 9 deletions packages/core/installMachine/installSteps/vercel/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { execSync } from 'child_process';
import { execAsync } from '../../../utils/execAsync';
import { logger } from '../../../utils/logger';
import { getShortestVercelAlias } from './utils/getShortestVercelAlias';
import { type InstallMachineContext } from '../../../types';

export const deployVercelProject = async () => {
export const deployVercelProject = async (stateData: InstallMachineContext['stateData']) => {
await logger.withSpinner('vercel', 'Connecting Vercel to Git...', async (spinner) => {
try {
// Execute 'vercel git connect' and capture the output
Expand All @@ -25,13 +26,9 @@ export const deployVercelProject = async () => {

const shortestVercelAlias = await getShortestVercelAlias(productionUrl);

if (!productionUrl) {
logger.log('vercel', 'Failed to create production deployment.');
return;
}
if (!productionUrl) logger.log('vercel', 'Failed to create production deployment.');

if (shortestVercelAlias) {
logger.log('vercel', `You can access your production deployment at: \x1b[36m${shortestVercelAlias}\x1b[0m`);
return;
}
stateData.prettyDeploymentUrl = productionUrl;

if (shortestVercelAlias) stateData.prettyDeploymentUrl = shortestVercelAlias;
};
1 change: 1 addition & 0 deletions packages/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface StaplerState {
options: ProjectOptions;
githubCandidateName: string;
selectedAccount: string;
prettyDeploymentUrl: string;
}

export interface InstallMachineContext {
Expand Down
16 changes: 11 additions & 5 deletions packages/core/utils/rcFileManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,29 @@ export const initializeRcFile = (projectDir: string, name: string, usePayload: b
projectName: name,
stepsCompleted: {
initializeProject: false,
installPayload: false,
installTailwind: false,
modifyHomepage: false,
installSupabase: false,
prettifyCode: false,
installPayload: false,
createDocFiles: false,
prettifyCode: false,
prepareDrink: false,
initializeRepository: false,
pushToGitHub: false,
createSupabaseProject: false,
chooseVercelTeam: false,
linkVercelProject: false,
updateVercelProjectSettings: false,
connectSupabaseProject: false,
deployVercelProject: false,
prepareDrink: false,
initializeRepository: false,
pushToGitHub: false,
},
options: {
name: name,
usePayload: usePayload,
},
githubCandidateName: name,
selectedAccount: '',
prettyDeploymentUrl: '',
};
return initialState;
}
Expand Down

0 comments on commit 8a30114

Please sign in to comment.