Skip to content

Commit

Permalink
feat(core): enable ci generation
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Apr 19, 2022
1 parent 8209ad0 commit f0cea57
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions packages/create-nx-workspace/bin/create-nx-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,21 @@ async function main(parsedArgs: yargs.Arguments<Arguments>) {
packageManager as PackageManager
);
}
if (ci && ci.length) {
await setupCI(
name,
ci,
packageManager as PackageManager,
nxCloud && nxCloudInstallRes.code === 0
);
}

showNxWarning(name);
pointToTutorialAndCourse(preset as Preset);

if (nxCloud && nxCloudInstallRes.code === 0) {
printNxCloudSuccessMessage(nxCloudInstallRes.stdout);
}

if (ci && ci.length) {
await setupCI(name, ci, packageManager as PackageManager);
}
}

async function getConfiguration(
Expand Down Expand Up @@ -673,9 +677,9 @@ async function determineCI(
message: `Autogenerate CI workflow file (multi-select)?`,
type: 'multiselect',
choices: [
{ name: 'GitHub Actions', value: 'github' },
{ name: 'Circle CI', value: 'circleci' },
{ name: 'Azure DevOps', value: 'azure' },
{ message: 'GitHub Actions', name: 'github' },
{ message: 'Circle CI', name: 'circleci' },
{ message: 'Azure DevOps', name: 'azure' },
],
},
])
Expand Down Expand Up @@ -802,21 +806,30 @@ async function setupNxCloud(name: string, packageManager: PackageManager) {
async function setupCI(
name: string,
ci: string[],
packageManager: PackageManager
packageManager: PackageManager,
nxCloudSuccessfullyInstalled: boolean
) {
if (!nxCloudSuccessfullyInstalled) {
output.error({
title: `CI workflow(s) generation skipped`,
bodyLines: [
`Nx Cloud was not (successfully) installed`,
`The autogenerated CI workflows require Nx Cloud to be set-up.`,
],
});
}
const ciSpinner = ora(`Generating CI workflow(s)`).start();
try {
const pmc = getPackageManagerCommand(packageManager);
// GENERATE WORKFLOWS HERE based on `ci` and `packageManager`
const res = Promise.allSettled(
// ci.map(
// async (ciProvider) =>
// await execAndWait(
// `${pmc.exec} nx g @nrwl/workspace:init-ci ${ciProvider} --no-analytics`,
// path.join(process.cwd(), name)
// )
// )
[]
ci.map(
async (provider) =>
await execAndWait(
`${pmc.exec} nx g @nrwl/workspace:ci-workflow --ci=${provider}`,
path.join(process.cwd(), name)
)
)
);
ciSpinner.succeed('CI workflow(s) have been generated successfully');
return res;
Expand Down

0 comments on commit f0cea57

Please sign in to comment.