feat(misc): remove handling of @nrwl scope (#28589)

This PR removes logic where we handle both `@nx/` and `@nrwl/` scope.
The latter scope has stopped being published in v20, and are no longer
relevant.

- Cleans up e2e
- Removes references to `@nrwl/` scope in our generators and executors
- Removes `@nrwl/` from `nx/package.json` `packageGroup`
- Cleans up documentation quality script
This commit is contained in:
Jack Hsu 2024-10-29 11:04:44 -04:00 committed by GitHub
parent fb9c5ede84
commit aec53a0406
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 23 additions and 94 deletions

View File

@ -359,7 +359,7 @@ module.exports = {
const esmapp = uniq('esmapp');
runCLI(
`generate @nrwl/node:app ${esmapp} --linter=eslint --framework=none --bundler=webpack`
`generate @nx/node:app ${esmapp} --linter=eslint --framework=none --bundler=webpack`
);
updateJson(`apps/${esmapp}/tsconfig.app.json`, (config) => {
config.module = 'esnext';

View File

@ -298,7 +298,7 @@ ${content}`;
it.skip('should CT vite projects importing other projects', () => {
const viteLibName = uniq('vite-lib');
runCLI(
`generate @nrwl/react:lib ${viteLibName} --bundler=vite --no-interactive`
`generate @nx/react:lib ${viteLibName} --bundler=vite --no-interactive`
);
updateFile(`libs/${viteLibName}/src/lib/${viteLibName}.tsx`, () => {
@ -316,7 +316,7 @@ export default MyComponent;`;
});
runCLI(
`generate @nrwl/react:cypress-component-configuration --project=${viteLibName} --generate-tests --bundler=vite --build-target=${appName}:build`
`generate @nx/react:cypress-component-configuration --project=${viteLibName} --generate-tests --bundler=vite --build-target=${appName}:build`
);
if (runE2ETests()) {
expect(runCLI(`component-test ${viteLibName}`)).toContain(

View File

@ -123,8 +123,7 @@ export function findLintTarget(
return Object.values(project.targets ?? {}).find(
(target) =>
target.executor === '@nx/eslint:lint' ||
target.executor === '@nx/linter:eslint' ||
target.executor === '@nrwl/linter:eslint'
target.executor === '@nx/linter:eslint'
);
}
@ -150,8 +149,6 @@ function migrateEslintFile(projectEslintPath: string, tree: Tree) {
config = removeCompatExtends(config, [
'plugin:@nx/typescript',
'plugin:@nx/javascript',
'plugin:@nrwl/typescript',
'plugin:@nrwl/javascript',
]);
config = removePredefinedConfigs(config, '@nx/eslint-plugin', 'nx', [
'flat/base',
@ -165,9 +162,7 @@ function migrateEslintFile(projectEslintPath: string, tree: Tree) {
delete json.root;
// remove nrwl/nx plugins
if (json.plugins) {
json.plugins = json.plugins.filter(
(p) => p !== '@nx' && p !== '@nrwl/nx'
);
json.plugins = json.plugins.filter((p) => p !== '@nx');
if (json.plugins.length === 0) {
delete json.plugins;
}
@ -193,9 +188,7 @@ function migrateEslintFile(projectEslintPath: string, tree: Tree) {
override.extends = override.extends.filter(
(ext) =>
ext !== 'plugin:@nx/typescript' &&
ext !== 'plugin:@nrwl/nx/typescript' &&
ext !== 'plugin:@nx/javascript' &&
ext !== 'plugin:@nrwl/nx/javascript'
ext !== 'plugin:@nx/javascript'
);
if (override.extends.length === 0) {
delete override.extends;

View File

@ -329,7 +329,7 @@ function isMigrationToMonorepoNeeded(tree: Tree, graph: ProjectGraph): boolean {
for (const targetConfig of Object.values(rootProject.data.targets ?? {})) {
if (
['@nx/eslint:lint', '@nrwl/linter:eslint', '@nx/linter:eslint'].includes(
['@nx/eslint:lint', '@nx/linter:eslint'].includes(
targetConfig.executor
) ||
(targetConfig.executor === 'nx:run-commands' &&

View File

@ -959,7 +959,7 @@ module.exports = [
rules: {}
})),
{ ignores: ["src/ignore/to/keep.ts"] },
...compat.config({ extends: ["plugin:@nrwl/javascript"] }).map(config => ({
...compat.config({ extends: ["plugin:@nx/javascript"] }).map(config => ({
files: ['*.js', '*.jsx'],
...config,
rules: {}
@ -969,8 +969,6 @@ module.exports = [
const result = removeCompatExtends(content, [
'plugin:@nx/typescript',
'plugin:@nx/javascript',
'plugin:@nrwl/typescript',
'plugin:@nrwl/javascript',
]);
expect(result).toMatchInlineSnapshot(`
"const { FlatCompat } = require("@eslint/eslintrc");

View File

@ -59,10 +59,7 @@ export async function* nodeExecutor(
const buildTargetExecutor =
project.data.targets[buildTarget.target]?.executor;
if (
buildTargetExecutor === 'nx:run-commands' ||
buildTargetExecutor === '@nrwl/workspace:run-commands'
) {
if (buildTargetExecutor === 'nx:run-commands') {
// Run commands does not emit build event, so we have to switch to run entire build through Nx CLI.
options.runBuildTargetDependencies = true;
}

View File

@ -51,11 +51,7 @@ function updateProjectBuildTargets(
let updated = false;
for (const target of projectTargets) {
const targetConfiguration = projectConfiguration.targets?.[target];
if (
!targetConfiguration ||
(targetConfiguration.executor !== '@nx/js:tsc' &&
targetConfiguration.executor !== '@nrwl/js:tsc')
)
if (!targetConfiguration || targetConfiguration.executor !== '@nx/js:tsc')
continue;
targetConfiguration.executor = '@nx/js:swc';
updated = true;

View File

@ -98,61 +98,35 @@
"migrations": "./migrations.json",
"packageGroup": [
"@nx/js",
"@nrwl/js",
"@nx/jest",
"@nrwl/jest",
"@nx/linter",
"@nx/eslint",
"@nrwl/linter",
"@nx/workspace",
"@nrwl/workspace",
"@nx/angular",
"@nrwl/angular",
"@nx/cypress",
"@nrwl/cypress",
"@nx/detox",
"@nrwl/detox",
"@nx/devkit",
"@nrwl/devkit",
"@nx/esbuild",
"@nrwl/esbuild",
"@nx/eslint-plugin",
"@nrwl/eslint-plugin-nx",
"@nx/expo",
"@nrwl/expo",
"@nx/express",
"@nrwl/express",
"@nx/gradle",
"@nx/nest",
"@nrwl/nest",
"@nx/next",
"@nrwl/next",
"@nx/node",
"@nrwl/node",
"@nx/nuxt",
"@nx/playwright",
"@nx/plugin",
"@nrwl/nx-plugin",
"@nx/react",
"@nrwl/react",
"@nx/react-native",
"@nrwl/react-native",
"@nx/rollup",
"@nrwl/rollup",
"@nx/remix",
"@nrwl/remix",
"@nx/rspack",
"@nrwl/rspack",
"@nx/storybook",
"@nrwl/storybook",
"@nrwl/tao",
"@nx/vite",
"@nrwl/vite",
"@nx/vue",
"@nx/web",
"@nrwl/web",
"@nx/webpack",
"@nrwl/webpack",
{
"package": "nx-cloud",
"version": "latest"

View File

@ -27,7 +27,7 @@ export function shouldMergeAngularProjects(
// Include projects from angular.json if explicitly required.
// e.g. when invoked from `packages/devkit/src/utils/convert-nx-executor.ts`
(includeProjectsFromAngularJson ||
// Or if a workspace has `@nrwl/angular`/`@nx/angular` installed then projects from `angular.json` to be considered by Nx.
// Or if a workspace has `@nx/angular` installed then projects from `angular.json` to be considered by Nx.
isAngularPluginInstalled())
) {
return true;
@ -42,12 +42,7 @@ export function isAngularPluginInstalled() {
require.resolve('@nx/angular');
return true;
} catch {
try {
require.resolve('@nrwl/angular');
return true;
} catch {
return false;
}
return false;
}
}

View File

@ -12,8 +12,7 @@ import { existsSync } from 'fs';
export function jsPluginConfig(
nxJson: NxJsonConfiguration
): Required<NrwlJsPluginConfig> {
const nxJsonConfig: NrwlJsPluginConfig =
nxJson?.pluginsConfig?.['@nx/js'] ?? nxJson?.pluginsConfig?.['@nrwl/js'];
const nxJsonConfig: NrwlJsPluginConfig = nxJson?.pluginsConfig?.['@nx/js'];
// using lerna _before_ installing deps is causing an issue when parsing lockfile.
// See: https://github.com/lerna/lerna/issues/3807
@ -58,14 +57,7 @@ export function jsPluginConfig(
packageJsonDeps['@nx/next'] ||
packageJsonDeps['@nx/react'] ||
packageJsonDeps['@nx/angular'] ||
packageJsonDeps['@nx/web'] ||
packageJsonDeps['@nrwl/workspace'] ||
packageJsonDeps['@nrwl/js'] ||
packageJsonDeps['@nrwl/node'] ||
packageJsonDeps['@nrwl/next'] ||
packageJsonDeps['@nrwl/react'] ||
packageJsonDeps['@nrwl/angular'] ||
packageJsonDeps['@nrwl/web']
packageJsonDeps['@nx/web']
) {
return {
analyzePackageJson: true,

View File

@ -173,9 +173,7 @@ function generateExecutorOverviewOutput({
{
text:
`${pluginName}:${name}` +
(pluginName.startsWith('@nrwl/')
? chalk.dim(` (v${nxVersion})`)
: ''),
(pluginName.startsWith('@nx/') ? chalk.dim(` (v${nxVersion})`) : ''),
padding: [1, 0, 0, 0],
},
]
@ -335,18 +333,12 @@ function generateLinkOutput({
type: 'generators' | 'executors';
}): string {
const nxPackagePrefix = '@nx/';
const nrwlPackagePrefix = '@nrwl/';
if (
!pluginName.startsWith(nxPackagePrefix) &&
!pluginName.startsWith(nrwlPackagePrefix)
) {
if (!pluginName.startsWith(nxPackagePrefix)) {
return '';
}
const link = `https://nx.dev/nx-api/${pluginName.substring(
pluginName.startsWith(nxPackagePrefix)
? nxPackagePrefix.length
: nrwlPackagePrefix.length
nxPackagePrefix.length
)}/${type}/${name}`;
return `\n\n${chalk.dim(

View File

@ -201,25 +201,20 @@ async function getGithubStars(repos: { owner: string; repo: string }[]) {
async function getNxVersion(data: any) {
const latest = data['dist-tags'].latest;
const nxPackages = [
'@nx/devkit',
'@nrwl/devkit',
'@nx/workspace',
'@nrwl/workspace',
];
const nxPackages = ['@nx/devkit', '@nx/workspace'];
let devkitVersion = '';
for (let i = 0; i < nxPackages.length && !devkitVersion; i++) {
const packageName = nxPackages[i];
if (data.versions[latest]?.dependencies) {
devkitVersion = data.versions[latest]?.dependencies[packageName];
if (devkitVersion) {
return await findNxRange(packageName, devkitVersion);
return await findNxRange(devkitVersion);
}
}
if (!devkitVersion && data.versions[latest]?.peerDependencies) {
devkitVersion = data.versions[latest]?.peerDependencies[packageName];
if (devkitVersion) {
return await findNxRange(packageName, devkitVersion);
return await findNxRange(devkitVersion);
}
}
}
@ -227,20 +222,17 @@ async function getNxVersion(data: any) {
return devkitVersion;
}
async function findNxRange(packageName: string, devkitVersion: string) {
async function findNxRange(devkitVersion: string) {
devkitVersion = devkitVersion
.replace('^', '')
.replace('>=', '')
.replace('>', '');
const lookupPackage = packageName.includes('@nx')
? '@nx/devkit'
: '@nrwl/devkit';
const { data: devkitData } = await axios.get(
`https://registry.npmjs.org/${lookupPackage}`
`https://registry.npmjs.org/@nx/devkit`
);
if (!devkitData.versions[devkitVersion]?.peerDependencies) {
const dependencies = devkitData.versions[devkitVersion]?.dependencies;
return dependencies && (dependencies?.nx || dependencies['@nrwl/tao']);
return dependencies?.nx;
}
return devkitData.versions[devkitVersion]?.peerDependencies.nx;
}