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, updateJson,
} from '@nrwl/devkit'; } from '@nrwl/devkit';
import { Linter, lintProjectGenerator } from '@nrwl/linter'; 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'; import { join } from 'path';
// app // app
@ -102,7 +102,7 @@ async function addLinter(host: Tree, options: CypressProjectSchema) {
return json; return json;
}); });
return parallelizeTasks(installTask, installTask2); return runTasksInSerial(installTask, installTask2);
} }
export async function cypressProjectGenerator(host: Tree, schema: Schema) { export async function cypressProjectGenerator(host: Tree, schema: Schema) {

View File

@ -4,7 +4,7 @@ import {
GeneratorCallback, GeneratorCallback,
Tree, Tree,
} from '@nrwl/devkit'; } 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 { gatsbyInitGenerator } from '../init/init';
import { Schema } from './schema'; import { Schema } from './schema';
@ -39,7 +39,7 @@ export async function applicationGenerator(host: Tree, schema: Schema) {
addGitIgnoreEntry(host, options); addGitIgnoreEntry(host, options);
await formatFiles(host); await formatFiles(host);
return parallelizeTasks( return runTasksInSerial(
initTask, initTask,
styledTask, styledTask,
lintTask, lintTask,

View File

@ -1,5 +1,5 @@
import { Tree } from '@nrwl/tao/src/shared/tree'; 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 { Linter, lintProjectGenerator } from '@nrwl/linter';
import { import {
addDependenciesToPackageJson, addDependenciesToPackageJson,
@ -43,5 +43,5 @@ export async function addLinting(host: Tree, options: NormalizedSchema) {
extraEslintDependencies.devDependencies 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 { componentGenerator as reactComponentGenerator } from '@nrwl/react';
import { convertNxGenerator, Tree } from '@nrwl/devkit'; import { convertNxGenerator, Tree } from '@nrwl/devkit';
import { addStyleDependencies } from '../../utils/styles'; 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 { interface Schema {
name: string; name: string;
@ -29,7 +29,7 @@ export async function componentGenerator(host: Tree, options: Schema) {
const styledTask = addStyleDependencies(host, options.style); const styledTask = addStyleDependencies(host, options.style);
return parallelizeTasks(componentTask, styledTask); return runTasksInSerial(componentTask, styledTask);
} }
export default componentGenerator; export default componentGenerator;

View File

@ -30,7 +30,7 @@ import {
} from '../../utils/versions'; } from '../../utils/versions';
import { InitSchema } from './schema'; 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) { function updateDependencies(host: Tree) {
const isPnpm = host.exists('pnpm-lock.yaml'); const isPnpm = host.exists('pnpm-lock.yaml');
@ -81,7 +81,7 @@ export async function gatsbyInitGenerator(host: Tree, schema: InitSchema) {
const installTask = updateDependencies(host); const installTask = updateDependencies(host);
tasks.push(installTask); tasks.push(installTask);
return parallelizeTasks(...tasks); return runTasksInSerial(...tasks);
} }
export default gatsbyInitGenerator; export default gatsbyInitGenerator;

View File

@ -5,7 +5,7 @@ import {
import { convertNxGenerator, Tree } from '@nrwl/devkit'; import { convertNxGenerator, Tree } from '@nrwl/devkit';
import { addStyleDependencies } from '../../utils/styles'; 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 { interface Schema {
name: string; name: string;
@ -33,7 +33,7 @@ export async function pageGenerator(host: Tree, options: Schema) {
const styledTask = addStyleDependencies(host, options.style); const styledTask = addStyleDependencies(host, options.style);
return parallelizeTasks(componentTask, styledTask); return runTasksInSerial(componentTask, styledTask);
} }
export default pageGenerator; export default pageGenerator;

View File

@ -12,7 +12,7 @@ import { updateJestConfig } from './lib/update-jest-config';
import { nextInitGenerator } from '../init/init'; import { nextInitGenerator } from '../init/init';
import { addStyleDependencies } from '../../utils/styles'; import { addStyleDependencies } from '../../utils/styles';
import { addLinting } from './lib/add-linting'; 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) { export async function applicationGenerator(host: Tree, schema: Schema) {
const options = normalizeOptions(host, schema); const options = normalizeOptions(host, schema);
@ -35,7 +35,7 @@ export async function applicationGenerator(host: Tree, schema: Schema) {
await formatFiles(host); await formatFiles(host);
} }
return parallelizeTasks( return runTasksInSerial(
nextTask, nextTask,
cypressTask, cypressTask,
jestTask, jestTask,

View File

@ -8,7 +8,7 @@ import {
} from '@nrwl/devkit'; } from '@nrwl/devkit';
import { extraEslintDependencies, reactEslintJson } from '@nrwl/react'; import { extraEslintDependencies, reactEslintJson } from '@nrwl/react';
import { NormalizedSchema } from './normalize-options'; 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( export async function addLinting(
host: Tree, host: Tree,
@ -41,5 +41,5 @@ export async function addLinting(
extraEslintDependencies.devDependencies 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 type { SupportedStyles } from '@nrwl/react';
import { componentGenerator as reactComponentGenerator } from '@nrwl/react'; import { componentGenerator as reactComponentGenerator } from '@nrwl/react';
import { convertNxGenerator, Tree } from '@nrwl/devkit'; 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 { interface Schema {
name: string; name: string;
@ -28,7 +28,7 @@ export async function componentGenerator(host: Tree, options: Schema) {
const styledInstall = addStyleDependencies(host, options.style); const styledInstall = addStyleDependencies(host, options.style);
return parallelizeTasks(styledInstall, componentInstall); return runTasksInSerial(styledInstall, componentInstall);
} }
export default componentGenerator; export default componentGenerator;

View File

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

View File

@ -3,7 +3,7 @@ import { convertNxGenerator, Tree } from '@nrwl/devkit';
import { addStyleDependencies } from '../../utils/styles'; import { addStyleDependencies } from '../../utils/styles';
import { Schema } from './schema'; 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 * 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); const styledTask = addStyleDependencies(host, options.style);
return parallelizeTasks(componentTask, styledTask); return runTasksInSerial(componentTask, styledTask);
} }
export default pageGenerator; export default pageGenerator;

View File

@ -18,7 +18,7 @@ import {
Tree, Tree,
updateJson, updateJson,
} from '@nrwl/devkit'; } 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 reactInitGenerator from '../init/init';
import { lintProjectGenerator } from '@nrwl/linter'; import { lintProjectGenerator } from '@nrwl/linter';
@ -51,7 +51,7 @@ async function addLinting(host: Tree, options: NormalizedSchema) {
); );
tasks.push(installTask); tasks.push(installTask);
return parallelizeTasks(...tasks); return runTasksInSerial(...tasks);
} }
export async function applicationGenerator(host: Tree, schema: Schema) { export async function applicationGenerator(host: Tree, schema: Schema) {
@ -76,7 +76,7 @@ export async function applicationGenerator(host: Tree, schema: Schema) {
await formatFiles(host); await formatFiles(host);
} }
return parallelizeTasks( return runTasksInSerial(
initTask, initTask,
lintTask, lintTask,
cypressTask, cypressTask,

View File

@ -20,7 +20,7 @@ import {
toJS, toJS,
Tree, Tree,
} from '@nrwl/devkit'; } 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'; import { addImport } from '../../utils/ast-utils';
interface NormalizedSchema extends Schema { interface NormalizedSchema extends Schema {
@ -53,7 +53,7 @@ export async function componentGenerator(host: Tree, schema: Schema) {
await formatFiles(host); await formatFiles(host);
return parallelizeTasks(...tasks); return runTasksInSerial(...tasks);
} }
function createComponentFiles(host: Tree, options: NormalizedSchema) { function createComponentFiles(host: Tree, options: NormalizedSchema) {

View File

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

View File

@ -35,7 +35,7 @@ import {
Tree, Tree,
updateJson, updateJson,
} from '@nrwl/devkit'; } 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 init from '../init/init';
import { Linter, lintProjectGenerator } from '@nrwl/linter'; import { Linter, lintProjectGenerator } from '@nrwl/linter';
import { jestProjectGenerator } from '@nrwl/jest'; import { jestProjectGenerator } from '@nrwl/jest';
@ -137,7 +137,7 @@ export async function libraryGenerator(host: Tree, schema: Schema) {
await formatFiles(host); await formatFiles(host);
} }
return parallelizeTasks(...tasks); return runTasksInSerial(...tasks);
} }
async function addLinting(host: Tree, options: NormalizedSchema) { async function addLinting(host: Tree, options: NormalizedSchema) {
@ -170,7 +170,7 @@ async function addLinting(host: Tree, options: NormalizedSchema) {
extraEslintDependencies.devDependencies extraEslintDependencies.devDependencies
); );
return parallelizeTasks(lintTask, installTask); return runTasksInSerial(lintTask, installTask);
} }
function addProject(host: Tree, options: NormalizedSchema) { function addProject(host: Tree, options: NormalizedSchema) {

View File

@ -14,7 +14,7 @@ import {
updateProjectConfiguration, updateProjectConfiguration,
writeJson, writeJson,
} from '@nrwl/devkit'; } 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 { Linter } from '@nrwl/linter';
import { join } from 'path'; import { join } from 'path';
@ -72,7 +72,7 @@ export async function configurationGenerator(
await formatFiles(tree); await formatFiles(tree);
return parallelizeTasks(...tasks); return runTasksInSerial(...tasks);
} }
function normalizeSchema(schema: StorybookConfigureSchema) { function normalizeSchema(schema: StorybookConfigureSchema) {

View File

@ -15,7 +15,7 @@ import {
Tree, Tree,
updateWorkspaceConfiguration, updateWorkspaceConfiguration,
} from '@nrwl/devkit'; } 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 { join } from 'path';
@ -228,7 +228,7 @@ export async function applicationGenerator(host: Tree, schema: Schema) {
if (!schema.skipFormat) { if (!schema.skipFormat) {
await formatFiles(host); await formatFiles(host);
} }
return parallelizeTasks(...tasks); return runTasksInSerial(...tasks);
} }
function normalizeOptions(host: Tree, options: Schema): NormalizedSchema { function normalizeOptions(host: Tree, options: Schema): NormalizedSchema {

View File

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

View File

@ -12,7 +12,7 @@ import {
GeneratorCallback, GeneratorCallback,
joinPathFragments, joinPathFragments,
} from '@nrwl/devkit'; } 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 { join } from 'path';
import { Schema } from './schema'; import { Schema } from './schema';
@ -164,7 +164,7 @@ export async function libraryGenerator(tree: Tree, schema: Schema) {
await formatFiles(tree); await formatFiles(tree);
} }
return parallelizeTasks(...tasks); return runTasksInSerial(...tasks);
} }
export default libraryGenerator; export default libraryGenerator;

View File

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