feat(core): bump devkit support range and remove some deprecated APIs (#30840)
This commit is contained in:
parent
ac6d2beac0
commit
e5dc244e66
@ -1,15 +1,5 @@
|
|||||||
# Function: readNxJson
|
# Function: readNxJson
|
||||||
|
|
||||||
▸ **readNxJson**(): [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration) \| `null`
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
[`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration) \| `null`
|
|
||||||
|
|
||||||
**`Deprecated`**
|
|
||||||
|
|
||||||
You must pass a [Tree](../../devkit/documents/Tree). This will be removed in Nx 21.
|
|
||||||
|
|
||||||
▸ **readNxJson**(`tree`): [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration) \| `null`
|
▸ **readNxJson**(`tree`): [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration) \| `null`
|
||||||
|
|
||||||
Reads nx.json
|
Reads nx.json
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
"enquirer": "~2.3.6"
|
"enquirer": "~2.3.6"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"nx": ">= 19 <= 21"
|
"nx": ">= 20 <= 22"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
|||||||
@ -43,7 +43,7 @@ function withFormatOptions(yargs: Argv): Argv {
|
|||||||
describe: `Ensure the workspace's tsconfig compilerOptions.paths are sorted. Warning: This will cause comments in the tsconfig to be lost.`,
|
describe: `Ensure the workspace's tsconfig compilerOptions.paths are sorted. Warning: This will cause comments in the tsconfig to be lost.`,
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
/**
|
/**
|
||||||
* TODO(v21): Stop sorting tsconfig paths by default, paths are now less common/important
|
* TODO(v22): Stop sorting tsconfig paths by default, paths are now less common/important
|
||||||
* in Nx workspace setups, and the sorting causes comments to be lost.
|
* in Nx workspace setups, and the sorting causes comments to be lost.
|
||||||
*/
|
*/
|
||||||
default: true,
|
default: true,
|
||||||
|
|||||||
@ -453,40 +453,12 @@ export function findRegisteredPluginsBeingUsed(nxJson: NxJsonConfiguration) {
|
|||||||
export function findInstalledPackagesWeCareAbout() {
|
export function findInstalledPackagesWeCareAbout() {
|
||||||
const packagesWeMayCareAbout: Record<string, string> = {};
|
const packagesWeMayCareAbout: Record<string, string> = {};
|
||||||
// TODO (v20): Remove workaround for hiding @nrwl packages when matching @nx package is found.
|
// TODO (v20): Remove workaround for hiding @nrwl packages when matching @nx package is found.
|
||||||
const packageChangeMap: Record<string, string> = {
|
|
||||||
'@nrwl/nx-plugin': '@nx/plugin',
|
|
||||||
'@nx/plugin': '@nrwl/nx-plugin',
|
|
||||||
'@nrwl/eslint-plugin-nx': '@nx/eslint-plugin',
|
|
||||||
'@nx/eslint-plugin': '@nrwl/eslint-plugin-nx',
|
|
||||||
'@nrwl/nx-cloud': 'nx-cloud',
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const pkg of packagesWeCareAbout) {
|
for (const pkg of packagesWeCareAbout) {
|
||||||
const v = readPackageVersion(pkg);
|
const v = readPackageVersion(pkg);
|
||||||
if (v) {
|
if (v) {
|
||||||
// If its a @nrwl scoped package, keep the version if there is no
|
|
||||||
// corresponding @nx scoped package, or it has a different version.
|
|
||||||
if (pkg.startsWith('@nrwl/')) {
|
|
||||||
const otherPackage =
|
|
||||||
packageChangeMap[pkg] ?? pkg.replace('@nrwl/', '@nx/');
|
|
||||||
const otherVersion = packagesWeMayCareAbout[otherPackage];
|
|
||||||
if (!otherVersion || v !== otherVersion) {
|
|
||||||
packagesWeMayCareAbout[pkg] = v;
|
packagesWeMayCareAbout[pkg] = v;
|
||||||
}
|
}
|
||||||
// If its a @nx scoped package, always keep the version, and
|
|
||||||
// remove the corresponding @nrwl scoped package if it exists.
|
|
||||||
} else if (pkg.startsWith('@nx/')) {
|
|
||||||
const otherPackage =
|
|
||||||
packageChangeMap[pkg] ?? pkg.replace('@nx/', '@nrwl/');
|
|
||||||
const otherVersion = packagesWeMayCareAbout[otherPackage];
|
|
||||||
if (otherVersion && v === otherVersion) {
|
|
||||||
delete packagesWeMayCareAbout[otherPackage];
|
|
||||||
}
|
|
||||||
packagesWeMayCareAbout[pkg] = v;
|
|
||||||
} else {
|
|
||||||
packagesWeMayCareAbout[pkg] = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Object.entries(packagesWeMayCareAbout).map(([pkg, version]) => ({
|
return Object.entries(packagesWeMayCareAbout).map(([pkg, version]) => ({
|
||||||
|
|||||||
@ -1,24 +1,12 @@
|
|||||||
import { workspaceRoot } from '../../utils/workspace-root';
|
import { workspaceRoot } from '../../utils/workspace-root';
|
||||||
import { dirname, relative } from 'path';
|
import { relative } from 'path';
|
||||||
import { getFullOsSocketPath } from '../socket-utils';
|
|
||||||
import { handleServerProcessTermination } from './shutdown-utils';
|
import { handleServerProcessTermination } from './shutdown-utils';
|
||||||
import { Server } from 'net';
|
import { Server } from 'net';
|
||||||
import { normalizePath } from '../../utils/path';
|
import { normalizePath } from '../../utils/path';
|
||||||
import {
|
|
||||||
getAlwaysIgnore,
|
|
||||||
getIgnoredGlobs,
|
|
||||||
getIgnoreObject,
|
|
||||||
} from '../../utils/ignore';
|
|
||||||
import { platform } from 'os';
|
|
||||||
import { getDaemonProcessIdSync, serverProcessJsonPath } from '../cache';
|
import { getDaemonProcessIdSync, serverProcessJsonPath } from '../cache';
|
||||||
import type { WatchEvent } from '../../native';
|
import type { WatchEvent } from '../../native';
|
||||||
import { openSockets } from './server';
|
import { openSockets } from './server';
|
||||||
|
|
||||||
const ALWAYS_IGNORE = [
|
|
||||||
...getAlwaysIgnore(workspaceRoot),
|
|
||||||
getFullOsSocketPath(),
|
|
||||||
];
|
|
||||||
|
|
||||||
export type FileWatcherCallback = (
|
export type FileWatcherCallback = (
|
||||||
err: Error | string | null,
|
err: Error | string | null,
|
||||||
changeEvents: WatchEvent[] | null
|
changeEvents: WatchEvent[] | null
|
||||||
|
|||||||
@ -4,19 +4,11 @@ import type { NxJsonConfiguration } from '../../config/nx-json';
|
|||||||
import type { Tree } from '../tree';
|
import type { Tree } from '../tree';
|
||||||
|
|
||||||
import { readJson, updateJson } from './json';
|
import { readJson, updateJson } from './json';
|
||||||
import { readNxJson as readNxJsonFromDisk } from '../../config/nx-json';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated You must pass a {@link Tree}. This will be removed in Nx 21.
|
|
||||||
*/
|
|
||||||
export function readNxJson(): NxJsonConfiguration | null;
|
|
||||||
export function readNxJson(tree: Tree): NxJsonConfiguration | null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads nx.json
|
* Reads nx.json
|
||||||
*/
|
*/
|
||||||
export function readNxJson(tree?: Tree): NxJsonConfiguration | null {
|
export function readNxJson(tree: Tree): NxJsonConfiguration | null {
|
||||||
if (tree) {
|
|
||||||
if (!tree.exists('nx.json')) {
|
if (!tree.exists('nx.json')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -25,9 +17,6 @@ export function readNxJson(tree?: Tree): NxJsonConfiguration | null {
|
|||||||
nxJson = { ...readNxJsonExtends(tree, nxJson.extends), ...nxJson };
|
nxJson = { ...readNxJsonExtends(tree, nxJson.extends), ...nxJson };
|
||||||
}
|
}
|
||||||
return nxJson;
|
return nxJson;
|
||||||
} else {
|
|
||||||
return readNxJsonFromDisk();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,48 +1,7 @@
|
|||||||
import { readFileSync } from 'node:fs';
|
|
||||||
import ignore from 'ignore';
|
import ignore from 'ignore';
|
||||||
import { readFileIfExisting } from './fileutils';
|
import { readFileIfExisting } from './fileutils';
|
||||||
import { joinPathFragments } from './path';
|
|
||||||
import { workspaceRoot } from './workspace-root';
|
import { workspaceRoot } from './workspace-root';
|
||||||
|
|
||||||
/**
|
|
||||||
* An array of glob patterns that should always be ignored.
|
|
||||||
*/
|
|
||||||
export const ALWAYS_IGNORE = getAlwaysIgnore();
|
|
||||||
|
|
||||||
export function getIgnoredGlobs(
|
|
||||||
root: string = workspaceRoot,
|
|
||||||
prependRoot: boolean = true
|
|
||||||
) {
|
|
||||||
const files = ['.gitignore', '.nxignore'];
|
|
||||||
if (prependRoot) {
|
|
||||||
return [
|
|
||||||
...getAlwaysIgnore(root),
|
|
||||||
...files.flatMap((f) =>
|
|
||||||
getIgnoredGlobsFromFile(joinPathFragments(root, f), root)
|
|
||||||
),
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
return [
|
|
||||||
...getAlwaysIgnore(),
|
|
||||||
...files.flatMap((f) =>
|
|
||||||
getIgnoredGlobsFromFile(joinPathFragments(root, f))
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAlwaysIgnore(root?: string) {
|
|
||||||
const paths = [
|
|
||||||
'node_modules',
|
|
||||||
'**/node_modules',
|
|
||||||
'.git',
|
|
||||||
'.nx',
|
|
||||||
'.vscode',
|
|
||||||
'.yarn/cache',
|
|
||||||
];
|
|
||||||
return root ? paths.map((x) => joinPathFragments(root, x)) : paths;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getIgnoreObject(
|
export function getIgnoreObject(
|
||||||
root: string = workspaceRoot
|
root: string = workspaceRoot
|
||||||
): ReturnType<typeof ignore> {
|
): ReturnType<typeof ignore> {
|
||||||
@ -51,28 +10,3 @@ export function getIgnoreObject(
|
|||||||
ig.add(readFileIfExisting(`${root}/.nxignore`));
|
ig.add(readFileIfExisting(`${root}/.nxignore`));
|
||||||
return ig;
|
return ig;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIgnoredGlobsFromFile(file: string, root?: string): string[] {
|
|
||||||
try {
|
|
||||||
const results = [];
|
|
||||||
const contents = readFileSync(file, 'utf-8');
|
|
||||||
const lines = contents.split('\n');
|
|
||||||
for (const line of lines) {
|
|
||||||
const trimmed = line.trim();
|
|
||||||
if (!trimmed || trimmed.startsWith('#')) {
|
|
||||||
continue;
|
|
||||||
} else if (trimmed.startsWith('/')) {
|
|
||||||
if (root) {
|
|
||||||
results.push(joinPathFragments(root, trimmed));
|
|
||||||
} else {
|
|
||||||
results.push(joinPathFragments('.', trimmed));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
results.push(trimmed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
} catch (e) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user