Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] add option to run setup-ci after project is created #425

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-ghosts-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-expo-stack': patch
---

add option to run setup-ci after project is created
5 changes: 5 additions & 0 deletions cli/src/utilities/printOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getPackageManager, getPackageManagerRunnerX } from './getPackageManager
import { easConfigure } from './runEasConfigure';
import { ONLY_ERRORS, runSystemCommand } from './systemCommand';
import { generateNWUI } from './generateNWUI';
import { runSetupCI } from './runSetupCI';

export async function printOutput(
cliResults: CliResults,
Expand Down Expand Up @@ -128,6 +129,10 @@ export async function printOutput(
await easConfigure(cliResults, packageManager, toolbox);
}

if (process.env.RUN_SETUP_CI === 'true') {
await runSetupCI(toolbox, cliResults);
}

const printVexoSteps = () => {
info(``);
highlight('Head over to https://vexo.co to create a new Vexo project.');
Expand Down
21 changes: 21 additions & 0 deletions cli/src/utilities/runCLI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '../types';
import { loadConfigs, saveConfig } from './configStorage';
import { getDefaultPackageManagerVersion } from './getPackageManager';
import { isProjectCompatibleWithSetupCI } from './runSetupCI';

// based on eas default bun version https://docs.expo.dev/build-reference/infrastructure/#ios-server-images
const minBunVersion = '1.1.13'; // or greater
Expand Down Expand Up @@ -388,5 +389,25 @@ export async function runCLI(toolbox: Toolbox, projectName: string): Promise<Cli
await saveConfig({ name, cliResults });
}

// Ask whether setup-ci should be run after the project is created
if (isProjectCompatibleWithSetupCI(toolbox, cliResults)) {
const shouldRunSetupCI = await confirm({
message: 'Would you like to run setup-ci to bootstrap CI with Github Actions workflows?',
initialValue: false
});

if (isCancel(shouldRunSetupCI)) {
cancel('Cancelled... 👋');
return process.exit(0);
}

if (shouldRunSetupCI) {
process.env.RUN_SETUP_CI = 'true';
success(`We'll run setup-ci after the project is created.`);
} else {
success(`No problem, skipping setup-ci for now.`);
}
}

return cliResults;
}
29 changes: 29 additions & 0 deletions cli/src/utilities/runSetupCI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Toolbox } from 'gluegun/build/types/domain/toolbox';
import { getPackageManager } from './getPackageManager';
import { CliResults } from '../types';

const SUPPORTED_PACKAGE_MANAGERS = ['yarn', 'npm'];

export async function isProjectCompatibleWithSetupCI(toolbox: Toolbox, cliResults: CliResults) {
const packageManager = getPackageManager(toolbox, cliResults);
const { noGit, noInstall } = cliResults.flags;

return !noGit && !noInstall && SUPPORTED_PACKAGE_MANAGERS.includes(packageManager);
}

export async function runSetupCI(toolbox: Toolbox, cliResults: CliResults) {
const {
print: { info },
system
} = toolbox;

const { projectName } = cliResults;

info(``);
info('Running setup-ci...');

await system.spawn(`cd ${projectName} && npx setup-ci@latest`, {
shell: true,
stdio: 'inherit'
});
}