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
|
||||
|
||||
▸ **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`
|
||||
|
||||
Reads nx.json
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
"enquirer": "~2.3.6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"nx": ">= 19 <= 21"
|
||||
"nx": ">= 20 <= 22"
|
||||
},
|
||||
"publishConfig": {
|
||||
"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.`,
|
||||
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.
|
||||
*/
|
||||
default: true,
|
||||
|
||||
@ -453,39 +453,11 @@ export function findRegisteredPluginsBeingUsed(nxJson: NxJsonConfiguration) {
|
||||
export function findInstalledPackagesWeCareAbout() {
|
||||
const packagesWeMayCareAbout: Record<string, string> = {};
|
||||
// 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) {
|
||||
const v = readPackageVersion(pkg);
|
||||
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;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
packagesWeMayCareAbout[pkg] = v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,24 +1,12 @@
|
||||
import { workspaceRoot } from '../../utils/workspace-root';
|
||||
import { dirname, relative } from 'path';
|
||||
import { getFullOsSocketPath } from '../socket-utils';
|
||||
import { relative } from 'path';
|
||||
import { handleServerProcessTermination } from './shutdown-utils';
|
||||
import { Server } from 'net';
|
||||
import { normalizePath } from '../../utils/path';
|
||||
import {
|
||||
getAlwaysIgnore,
|
||||
getIgnoredGlobs,
|
||||
getIgnoreObject,
|
||||
} from '../../utils/ignore';
|
||||
import { platform } from 'os';
|
||||
import { getDaemonProcessIdSync, serverProcessJsonPath } from '../cache';
|
||||
import type { WatchEvent } from '../../native';
|
||||
import { openSockets } from './server';
|
||||
|
||||
const ALWAYS_IGNORE = [
|
||||
...getAlwaysIgnore(workspaceRoot),
|
||||
getFullOsSocketPath(),
|
||||
];
|
||||
|
||||
export type FileWatcherCallback = (
|
||||
err: Error | string | null,
|
||||
changeEvents: WatchEvent[] | null
|
||||
|
||||
@ -4,30 +4,19 @@ import type { NxJsonConfiguration } from '../../config/nx-json';
|
||||
import type { Tree } from '../tree';
|
||||
|
||||
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
|
||||
*/
|
||||
export function readNxJson(tree?: Tree): NxJsonConfiguration | null {
|
||||
if (tree) {
|
||||
if (!tree.exists('nx.json')) {
|
||||
return null;
|
||||
}
|
||||
let nxJson = readJson<NxJsonConfiguration>(tree, 'nx.json');
|
||||
if (nxJson.extends) {
|
||||
nxJson = { ...readNxJsonExtends(tree, nxJson.extends), ...nxJson };
|
||||
}
|
||||
return nxJson;
|
||||
} else {
|
||||
return readNxJsonFromDisk();
|
||||
export function readNxJson(tree: Tree): NxJsonConfiguration | null {
|
||||
if (!tree.exists('nx.json')) {
|
||||
return null;
|
||||
}
|
||||
let nxJson = readJson<NxJsonConfiguration>(tree, 'nx.json');
|
||||
if (nxJson.extends) {
|
||||
nxJson = { ...readNxJsonExtends(tree, nxJson.extends), ...nxJson };
|
||||
}
|
||||
return nxJson;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,48 +1,7 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import ignore from 'ignore';
|
||||
import { readFileIfExisting } from './fileutils';
|
||||
import { joinPathFragments } from './path';
|
||||
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(
|
||||
root: string = workspaceRoot
|
||||
): ReturnType<typeof ignore> {
|
||||
@ -51,28 +10,3 @@ export function getIgnoreObject(
|
||||
ig.add(readFileIfExisting(`${root}/.nxignore`));
|
||||
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