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

fix(node): update node migrations to use forEachExecutorOptions #9471

Merged
merged 1 commit into from Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,20 +1,21 @@
import {
formatFiles,
getProjects,
readProjectConfiguration,
Tree,
updateProjectConfiguration,
} from '@nrwl/devkit';
import { forEachExecutorOptions } from '@nrwl/workspace/src/utilities/executor-options-utils';

export default async function update(host: Tree) {
const projects = getProjects(host);

for (const [name, config] of projects.entries()) {
if (config?.targets?.build?.executor !== '@nrwl/node:build') continue;

config.targets.build.executor = '@nrwl/node:webpack';

updateProjectConfiguration(host, name, config);
}
forEachExecutorOptions(
host,
'@nrwl/node:build',
(_, projectName, targetName) => {
const projectConfiguration = readProjectConfiguration(host, projectName);
projectConfiguration.targets[targetName].executor = '@nrwl/node:webpack';
updateProjectConfiguration(host, projectName, projectConfiguration);
}
);

await formatFiles(host);
}
@@ -1,20 +1,21 @@
import {
formatFiles,
getProjects,
readProjectConfiguration,
Tree,
updateProjectConfiguration,
} from '@nrwl/devkit';
import { forEachExecutorOptions } from '@nrwl/workspace/src/utilities/executor-options-utils';

export default async function update(host: Tree) {
const projects = getProjects(host);
export default async function update(tree: Tree) {
forEachExecutorOptions(
tree,
'@nrwl/node:execute',
(_, projectName, targetName) => {
const projectConfiguration = readProjectConfiguration(tree, projectName);
projectConfiguration.targets[targetName].executor = '@nrwl/node:node';
updateProjectConfiguration(tree, projectName, projectConfiguration);
}
);

for (const [name, config] of projects.entries()) {
if (config?.targets?.serve?.executor !== '@nrwl/node:execute') continue;

config.targets.serve.executor = '@nrwl/node:node';

updateProjectConfiguration(host, name, config);
}

await formatFiles(host);
await formatFiles(tree);
}
Expand Up @@ -2,29 +2,36 @@ import {
addDependenciesToPackageJson,
formatFiles,
getProjects,
readProjectConfiguration,
Tree,
updateProjectConfiguration,
} from '@nrwl/devkit';
import { forEachExecutorOptions } from '@nrwl/workspace/src/utilities/executor-options-utils';
import { nxVersion } from '@nrwl/workspace/src/utils/versions';

export default async function update(host: Tree) {
const projects = getProjects(host);
let installNeeded = false;

for (const [name, config] of projects.entries()) {
if (config?.targets?.build?.executor !== '@nrwl/node:package') continue;
forEachExecutorOptions(
host,
'@nrwl/node:package',
(_, projectName, targetName) => {
installNeeded = true;
const projectConfiguration = readProjectConfiguration(host, projectName);

config.targets.build.executor = '@nrwl/js:tsc';
projectConfiguration.targets[targetName].executor = '@nrwl/js:tsc';

const transformers = config.targets.build.options?.tsPlugins;
if (transformers) {
delete config.targets.build.options.tsPlugins;
config.targets.build.options.transformers = transformers;
}
const transformers =
projectConfiguration.targets[targetName].options?.tsPlugins;
if (transformers) {
delete projectConfiguration.targets[targetName].options.tsPlugins;
projectConfiguration.targets[targetName].options.transformers =
transformers;
}

installNeeded = true;
updateProjectConfiguration(host, name, config);
}
updateProjectConfiguration(host, projectName, projectConfiguration);
}
);

const task = installNeeded
? addDependenciesToPackageJson(
Expand Down