fix(core): change running tasks in parallel to running in serial (#4785)

This commit is contained in:
Jason Jean 2021-02-12 16:39:55 -05:00 committed by GitHub
parent 33acb41afb
commit 18c8b2b30d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 44 additions and 42 deletions

View File

@ -13,7 +13,7 @@ import {
updateJson,
} from '@nrwl/devkit';
import { Linter, lintProjectGenerator } from '@nrwl/linter';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { join } from 'path';
// app
@ -102,7 +102,7 @@ async function addLinter(host: Tree, options: CypressProjectSchema) {
return json;
});
return parallelizeTasks(installTask, installTask2);
return runTasksInSerial(installTask, installTask2);
}
export async function cypressProjectGenerator(host: Tree, schema: Schema) {

View File

@ -4,7 +4,7 @@ import {
GeneratorCallback,
Tree,
} from '@nrwl/devkit';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { gatsbyInitGenerator } from '../init/init';
import { Schema } from './schema';
@ -39,7 +39,7 @@ export async function applicationGenerator(host: Tree, schema: Schema) {
addGitIgnoreEntry(host, options);
await formatFiles(host);
return parallelizeTasks(
return runTasksInSerial(
initTask,
styledTask,
lintTask,

View File

@ -1,5 +1,5 @@
import { Tree } from '@nrwl/tao/src/shared/tree';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { Linter, lintProjectGenerator } from '@nrwl/linter';
import {
addDependenciesToPackageJson,
@ -43,5 +43,5 @@ export async function addLinting(host: Tree, options: NormalizedSchema) {
extraEslintDependencies.devDependencies
);
return parallelizeTasks(lintTask, installTask);
return runTasksInSerial(lintTask, installTask);
}

View File

@ -2,7 +2,7 @@ import type { SupportedStyles } from '@nrwl/react';
import { componentGenerator as reactComponentGenerator } from '@nrwl/react';
import { convertNxGenerator, Tree } from '@nrwl/devkit';
import { addStyleDependencies } from '../../utils/styles';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
interface Schema {
name: string;
@ -29,7 +29,7 @@ export async function componentGenerator(host: Tree, options: Schema) {
const styledTask = addStyleDependencies(host, options.style);
return parallelizeTasks(componentTask, styledTask);
return runTasksInSerial(componentTask, styledTask);
}
export default componentGenerator;

View File

@ -30,7 +30,7 @@ import {
} from '../../utils/versions';
import { InitSchema } from './schema';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
function updateDependencies(host: Tree) {
const isPnpm = host.exists('pnpm-lock.yaml');
@ -81,7 +81,7 @@ export async function gatsbyInitGenerator(host: Tree, schema: InitSchema) {
const installTask = updateDependencies(host);
tasks.push(installTask);
return parallelizeTasks(...tasks);
return runTasksInSerial(...tasks);
}
export default gatsbyInitGenerator;

View File

@ -5,7 +5,7 @@ import {
import { convertNxGenerator, Tree } from '@nrwl/devkit';
import { addStyleDependencies } from '../../utils/styles';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
interface Schema {
name: string;
@ -33,7 +33,7 @@ export async function pageGenerator(host: Tree, options: Schema) {
const styledTask = addStyleDependencies(host, options.style);
return parallelizeTasks(componentTask, styledTask);
return runTasksInSerial(componentTask, styledTask);
}
export default pageGenerator;

View File

@ -12,7 +12,7 @@ import { updateJestConfig } from './lib/update-jest-config';
import { nextInitGenerator } from '../init/init';
import { addStyleDependencies } from '../../utils/styles';
import { addLinting } from './lib/add-linting';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
export async function applicationGenerator(host: Tree, schema: Schema) {
const options = normalizeOptions(host, schema);
@ -35,7 +35,7 @@ export async function applicationGenerator(host: Tree, schema: Schema) {
await formatFiles(host);
}
return parallelizeTasks(
return runTasksInSerial(
nextTask,
cypressTask,
jestTask,

View File

@ -8,7 +8,7 @@ import {
} from '@nrwl/devkit';
import { extraEslintDependencies, reactEslintJson } from '@nrwl/react';
import { NormalizedSchema } from './normalize-options';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
export async function addLinting(
host: Tree,
@ -41,5 +41,5 @@ export async function addLinting(
extraEslintDependencies.devDependencies
);
return parallelizeTasks(lintTask, installTask);
return runTasksInSerial(lintTask, installTask);
}

View File

@ -2,7 +2,7 @@ import { addStyleDependencies } from '../../utils/styles';
import type { SupportedStyles } from '@nrwl/react';
import { componentGenerator as reactComponentGenerator } from '@nrwl/react';
import { convertNxGenerator, Tree } from '@nrwl/devkit';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
interface Schema {
name: string;
@ -28,7 +28,7 @@ export async function componentGenerator(host: Tree, options: Schema) {
const styledInstall = addStyleDependencies(host, options.style);
return parallelizeTasks(styledInstall, componentInstall);
return runTasksInSerial(styledInstall, componentInstall);
}
export default componentGenerator;

View File

@ -5,7 +5,7 @@ import {
Tree,
} from '@nrwl/devkit';
import { setDefaultCollection } from '@nrwl/workspace/src/utilities/set-default-collection';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { jestInitGenerator } from '@nrwl/jest';
import { cypressInitGenerator } from '@nrwl/cypress';
import { reactDomVersion, reactInitGenerator, reactVersion } from '@nrwl/react';
@ -46,7 +46,7 @@ export async function nextInitGenerator(host: Tree, schema: InitSchema) {
const installTask = updateDependencies(host);
tasks.push(installTask);
return parallelizeTasks(...tasks);
return runTasksInSerial(...tasks);
}
export default nextInitGenerator;

View File

@ -3,7 +3,7 @@ import { convertNxGenerator, Tree } from '@nrwl/devkit';
import { addStyleDependencies } from '../../utils/styles';
import { Schema } from './schema';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
/*
* This schematic is basically the React component one, but for Next we need
@ -24,7 +24,7 @@ export async function pageGenerator(host: Tree, options: Schema) {
const styledTask = addStyleDependencies(host, options.style);
return parallelizeTasks(componentTask, styledTask);
return runTasksInSerial(componentTask, styledTask);
}
export default pageGenerator;

View File

@ -18,7 +18,7 @@ import {
Tree,
updateJson,
} from '@nrwl/devkit';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import reactInitGenerator from '../init/init';
import { lintProjectGenerator } from '@nrwl/linter';
@ -51,7 +51,7 @@ async function addLinting(host: Tree, options: NormalizedSchema) {
);
tasks.push(installTask);
return parallelizeTasks(...tasks);
return runTasksInSerial(...tasks);
}
export async function applicationGenerator(host: Tree, schema: Schema) {
@ -76,7 +76,7 @@ export async function applicationGenerator(host: Tree, schema: Schema) {
await formatFiles(host);
}
return parallelizeTasks(
return runTasksInSerial(
initTask,
lintTask,
cypressTask,

View File

@ -20,7 +20,7 @@ import {
toJS,
Tree,
} from '@nrwl/devkit';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { addImport } from '../../utils/ast-utils';
interface NormalizedSchema extends Schema {
@ -53,7 +53,7 @@ export async function componentGenerator(host: Tree, schema: Schema) {
await formatFiles(host);
return parallelizeTasks(...tasks);
return runTasksInSerial(...tasks);
}
function createComponentFiles(host: Tree, options: NormalizedSchema) {

View File

@ -11,7 +11,7 @@ import { jestInitGenerator } from '@nrwl/jest';
import { cypressInitGenerator } from '@nrwl/cypress';
import { webInitGenerator } from '@nrwl/web';
import { setDefaultCollection } from '@nrwl/workspace/src/utilities/set-default-collection';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import {
nxVersion,
reactDomVersion,
@ -74,7 +74,7 @@ export async function reactInitGenerator(host: Tree, schema: InitSchema) {
);
tasks.push(installTask);
return parallelizeTasks(...tasks);
return runTasksInSerial(...tasks);
}
export default reactInitGenerator;

View File

@ -35,7 +35,7 @@ import {
Tree,
updateJson,
} from '@nrwl/devkit';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import init from '../init/init';
import { Linter, lintProjectGenerator } from '@nrwl/linter';
import { jestProjectGenerator } from '@nrwl/jest';
@ -137,7 +137,7 @@ export async function libraryGenerator(host: Tree, schema: Schema) {
await formatFiles(host);
}
return parallelizeTasks(...tasks);
return runTasksInSerial(...tasks);
}
async function addLinting(host: Tree, options: NormalizedSchema) {
@ -170,7 +170,7 @@ async function addLinting(host: Tree, options: NormalizedSchema) {
extraEslintDependencies.devDependencies
);
return parallelizeTasks(lintTask, installTask);
return runTasksInSerial(lintTask, installTask);
}
function addProject(host: Tree, options: NormalizedSchema) {

View File

@ -14,7 +14,7 @@ import {
updateProjectConfiguration,
writeJson,
} from '@nrwl/devkit';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { Linter } from '@nrwl/linter';
import { join } from 'path';
@ -72,7 +72,7 @@ export async function configurationGenerator(
await formatFiles(tree);
return parallelizeTasks(...tasks);
return runTasksInSerial(...tasks);
}
function normalizeSchema(schema: StorybookConfigureSchema) {

View File

@ -15,7 +15,7 @@ import {
Tree,
updateWorkspaceConfiguration,
} from '@nrwl/devkit';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { join } from 'path';
@ -228,7 +228,7 @@ export async function applicationGenerator(host: Tree, schema: Schema) {
if (!schema.skipFormat) {
await formatFiles(host);
}
return parallelizeTasks(...tasks);
return runTasksInSerial(...tasks);
}
function normalizeOptions(host: Tree, options: Schema): NormalizedSchema {

View File

@ -8,7 +8,7 @@ import {
writeJson,
} from '@nrwl/devkit';
import { setDefaultCollection } from '@nrwl/workspace/src/utilities/set-default-collection';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { Schema } from './schema';
import {
documentRegisterElementVersion,
@ -65,7 +65,7 @@ export async function webInitGenerator(tree: Tree, schema: Schema) {
if (!schema.skipFormat) {
await formatFiles(tree);
}
return parallelizeTasks(...tasks);
return runTasksInSerial(...tasks);
}
export default webInitGenerator;

View File

@ -12,7 +12,7 @@ import {
GeneratorCallback,
joinPathFragments,
} from '@nrwl/devkit';
import { parallelizeTasks } from '@nrwl/workspace/src/utilities/parallelize-tasks';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { join } from 'path';
import { Schema } from './schema';
@ -164,7 +164,7 @@ export async function libraryGenerator(tree: Tree, schema: Schema) {
await formatFiles(tree);
}
return parallelizeTasks(...tasks);
return runTasksInSerial(...tasks);
}
export default libraryGenerator;

View File

@ -1,9 +1,11 @@
import { GeneratorCallback } from '@nrwl/devkit';
export function parallelizeTasks(
export function runTasksInSerial(
...tasks: GeneratorCallback[]
): GeneratorCallback {
return async () => {
await Promise.all(tasks.map((task) => task()));
for (const task of tasks) {
await task();
}
};
}