fix(node): apply migration patch to 16.0.0 and 14.7.6 migrations as well (#17419)
This commit is contained in:
parent
1bc7965278
commit
b8cfbcc625
@ -1,21 +1,23 @@
|
||||
import {
|
||||
formatFiles,
|
||||
getProjects,
|
||||
readProjectConfiguration,
|
||||
Tree,
|
||||
updateProjectConfiguration,
|
||||
} from '@nx/devkit';
|
||||
import { forEachExecutorOptions } from '@nx/devkit/src/generators/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:webpack') {
|
||||
config.targets.build.executor = '@nrwl/webpack:webpack';
|
||||
config.targets.build.options.target = 'node';
|
||||
config.targets.build.options.compiler = 'tsc';
|
||||
updateProjectConfiguration(host, name, config);
|
||||
export default async function update(tree: Tree) {
|
||||
forEachExecutorOptions(
|
||||
tree,
|
||||
'@nrwl/node:webpack',
|
||||
(options, projectName, targetName) => {
|
||||
const projectConfig = readProjectConfiguration(tree, projectName);
|
||||
projectConfig.targets[targetName].executor = '@nrwl/webpack:webpack';
|
||||
projectConfig.targets[targetName].options.compiler = 'tsc';
|
||||
projectConfig.targets[targetName].options.target = 'node';
|
||||
updateProjectConfiguration(tree, projectName, projectConfig);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
await formatFiles(host);
|
||||
await formatFiles(tree);
|
||||
}
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
import { addProjectConfiguration, readProjectConfiguration } from '@nx/devkit';
|
||||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
||||
|
||||
import update from './update-webpack-executor';
|
||||
|
||||
describe('Migration: @nrwl/webpack', () => {
|
||||
it(`should update usage of webpack executor`, async () => {
|
||||
let tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
||||
|
||||
addProjectConfiguration(tree, 'myapp', {
|
||||
root: 'apps/myapp',
|
||||
sourceRoot: 'apps/myapp/src',
|
||||
projectType: 'application',
|
||||
targets: {
|
||||
foo: {
|
||||
executor: '@nrwl/node:webpack',
|
||||
options: {},
|
||||
},
|
||||
bar: {
|
||||
executor: '@nx/node:webpack',
|
||||
options: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await update(tree);
|
||||
|
||||
expect(readProjectConfiguration(tree, 'myapp')).toEqual({
|
||||
$schema: '../../node_modules/nx/schemas/project-schema.json',
|
||||
name: 'myapp',
|
||||
root: 'apps/myapp',
|
||||
sourceRoot: 'apps/myapp/src',
|
||||
projectType: 'application',
|
||||
targets: {
|
||||
foo: {
|
||||
executor: '@nx/webpack:webpack',
|
||||
options: {
|
||||
compiler: 'tsc',
|
||||
target: 'node',
|
||||
},
|
||||
},
|
||||
bar: {
|
||||
executor: '@nx/webpack:webpack',
|
||||
options: {
|
||||
compiler: 'tsc',
|
||||
target: 'node',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,21 +1,22 @@
|
||||
import {
|
||||
formatFiles,
|
||||
getProjects,
|
||||
readProjectConfiguration,
|
||||
Tree,
|
||||
updateProjectConfiguration,
|
||||
} from '@nx/devkit';
|
||||
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';
|
||||
|
||||
export default async function update(host: Tree) {
|
||||
const projects = getProjects(host);
|
||||
export default async function update(tree: Tree) {
|
||||
const migrateProject = (options, projectName, targetName) => {
|
||||
const projectConfig = readProjectConfiguration(tree, projectName);
|
||||
projectConfig.targets[targetName].executor = '@nx/webpack:webpack';
|
||||
projectConfig.targets[targetName].options.compiler = 'tsc';
|
||||
projectConfig.targets[targetName].options.target = 'node';
|
||||
updateProjectConfiguration(tree, projectName, projectConfig);
|
||||
};
|
||||
|
||||
for (const [name, config] of projects.entries()) {
|
||||
if (config?.targets?.build?.executor === '@nrwl/node:webpack') {
|
||||
config.targets.build.executor = '@nx/webpack:webpack';
|
||||
config.targets.build.options.target = 'node';
|
||||
config.targets.build.options.compiler = 'tsc';
|
||||
updateProjectConfiguration(host, name, config);
|
||||
}
|
||||
}
|
||||
forEachExecutorOptions(tree, '@nx/node:webpack', migrateProject);
|
||||
forEachExecutorOptions(tree, '@nrwl/node:webpack', migrateProject);
|
||||
|
||||
await formatFiles(host);
|
||||
await formatFiles(tree);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user