nx 18.1.0 → 18.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/init-local.js +13 -1
- package/package.json +12 -12
- package/release/changelog-renderer/index.d.ts +2 -0
- package/release/changelog-renderer/index.js +4 -18
- package/schemas/nx-schema.json +62 -1
- package/schemas/project-schema.json +20 -0
- package/src/adapter/angular-json.d.ts +1 -2
- package/src/adapter/angular-json.js +0 -1
- package/src/adapter/ngcli-adapter.js +3 -3
- package/src/command-line/generate/generator-utils.js +2 -2
- package/src/command-line/init/implementation/add-nx-to-nest.js +2 -2
- package/src/command-line/init/implementation/add-nx-to-npm-repo.js +2 -2
- package/src/command-line/init/implementation/utils.d.ts +1 -3
- package/src/command-line/init/implementation/utils.js +9 -16
- package/src/command-line/init/init-v2.js +3 -2
- package/src/command-line/release/changelog.js +17 -14
- package/src/command-line/release/command-object.d.ts +1 -0
- package/src/command-line/release/config/config.d.ts +12 -15
- package/src/command-line/release/config/config.js +151 -22
- package/src/command-line/release/config/conventional-commits.d.ts +2 -0
- package/src/command-line/release/config/conventional-commits.js +98 -0
- package/src/command-line/release/publish.js +4 -3
- package/src/command-line/release/release.js +12 -11
- package/src/command-line/release/utils/git.js +30 -1
- package/src/command-line/release/utils/resolve-semver-specifier.d.ts +2 -1
- package/src/command-line/release/utils/resolve-semver-specifier.js +2 -13
- package/src/command-line/release/utils/semver.d.ts +2 -8
- package/src/command-line/release/utils/semver.js +4 -1
- package/src/command-line/release/utils/shared.d.ts +5 -1
- package/src/command-line/release/version.d.ts +6 -1
- package/src/command-line/release/version.js +71 -19
- package/src/command-line/run/executor-utils.js +2 -2
- package/src/command-line/run/run.js +16 -6
- package/src/config/nx-json.d.ts +31 -0
- package/src/config/schema-utils.js +2 -2
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/polyfills.js +1 -1
- package/src/core/graph/styles.css +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +1 -0
- package/src/devkit-exports.d.ts +1 -2
- package/src/devkit-internals.d.ts +0 -1
- package/src/devkit-internals.js +1 -3
- package/src/executors/run-commands/run-commands.impl.d.ts +7 -1
- package/src/executors/run-commands/run-commands.impl.js +120 -55
- package/src/executors/run-script/run-script.impl.js +6 -6
- package/src/generators/utils/project-configuration.js +2 -2
- package/src/hasher/hash-task.js +2 -2
- package/src/migrations/update-15-1-0/set-project-names.js +2 -4
- package/src/migrations/update-17-2-0/move-default-base.d.ts +1 -1
- package/src/migrations/update-17-2-0/move-default-base.js +3 -1
- package/src/migrations/update-17-3-0/nx-release-path.js +0 -1
- package/src/native/index.d.ts +14 -11
- package/src/native/index.js +3 -4
- package/src/plugins/js/index.d.ts +1 -1
- package/src/plugins/js/index.js +1 -1
- package/src/plugins/js/lock-file/lock-file.d.ts +2 -2
- package/src/plugins/js/lock-file/lock-file.js +15 -3
- package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
- package/src/plugins/js/utils/register.js +3 -1
- package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
- package/src/plugins/package-json-workspaces/create-nodes.js +31 -24
- package/src/plugins/package-json-workspaces/index.d.ts +0 -1
- package/src/plugins/package-json-workspaces/index.js +0 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +1 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +0 -1
- package/src/plugins/project-json/build-nodes/project-json.d.ts +1 -2
- package/src/plugins/project-json/build-nodes/project-json.js +0 -1
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +1 -2
- package/src/plugins/target-defaults/target-defaults-plugin.js +0 -1
- package/src/project-graph/affected/locators/project-glob-changes.js +3 -2
- package/src/project-graph/build-project-graph.js +8 -11
- package/src/project-graph/file-utils.js +6 -4
- package/src/project-graph/project-graph-builder.d.ts +1 -1
- package/src/project-graph/project-graph.js +3 -0
- package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +4 -4
- package/src/project-graph/utils/project-configuration-utils.js +58 -17
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +4 -8
- package/src/project-graph/utils/retrieve-workspace-files.js +18 -20
- package/src/tasks-runner/fork.js +7 -7
- package/src/tasks-runner/forked-process-task-runner.d.ts +4 -5
- package/src/tasks-runner/forked-process-task-runner.js +28 -21
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +16 -13
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +8 -7
- package/src/tasks-runner/{psuedo-ipc.d.ts → pseudo-ipc.d.ts} +7 -7
- package/src/tasks-runner/{psuedo-ipc.js → pseudo-ipc.js} +9 -9
- package/src/tasks-runner/pseudo-terminal.d.ts +43 -0
- package/src/tasks-runner/pseudo-terminal.js +159 -0
- package/src/tasks-runner/task-orchestrator.js +49 -31
- package/src/tasks-runner/tasks-schedule.js +3 -3
- package/src/tasks-runner/utils.d.ts +7 -6
- package/src/tasks-runner/utils.js +11 -7
- package/src/utils/ignore.js +1 -1
- package/src/utils/logger.d.ts +0 -1
- package/src/utils/logger.js +0 -5
- package/src/{project-graph/plugins/public-api.d.ts → utils/nx-plugin.d.ts} +45 -7
- package/src/utils/nx-plugin.deprecated.d.ts +2 -4
- package/src/utils/nx-plugin.deprecated.js +4 -4
- package/src/utils/nx-plugin.js +293 -0
- package/src/utils/output.js +1 -1
- package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
- package/src/utils/plugins/plugin-capabilities.js +7 -8
- package/src/project-graph/plugins/index.d.ts +0 -2
- package/src/project-graph/plugins/index.js +0 -8
- package/src/project-graph/plugins/internal-api.d.ts +0 -18
- package/src/project-graph/plugins/internal-api.js +0 -48
- package/src/project-graph/plugins/messaging.d.ts +0 -94
- package/src/project-graph/plugins/messaging.js +0 -23
- package/src/project-graph/plugins/plugin-pool.d.ts +0 -4
- package/src/project-graph/plugins/plugin-pool.js +0 -216
- package/src/project-graph/plugins/plugin-worker.d.ts +0 -1
- package/src/project-graph/plugins/plugin-worker.js +0 -115
- package/src/project-graph/plugins/public-api.js +0 -4
- package/src/project-graph/plugins/utils.d.ts +0 -9
- package/src/project-graph/plugins/utils.js +0 -55
- package/src/project-graph/plugins/worker-api.d.ts +0 -26
- package/src/project-graph/plugins/worker-api.js +0 -177
package/src/native/index.d.ts
CHANGED
@@ -21,12 +21,6 @@ export function expandOutputs(directory: string, entries: Array<string>): Array<
|
|
21
21
|
export function getFilesForOutputs(directory: string, entries: Array<string>): Array<string>
|
22
22
|
export function remove(src: string): void
|
23
23
|
export function copy(src: string, dest: string): void
|
24
|
-
export function runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, quiet?: boolean | undefined | null): ChildProcess
|
25
|
-
/**
|
26
|
-
* This allows us to run a pseudoterminal with a fake node ipc channel
|
27
|
-
* this makes it possible to be backwards compatible with the old implementation
|
28
|
-
*/
|
29
|
-
export function nxFork(id: string, forkScript: string, psuedoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record<string, string> | undefined | null, quiet: boolean): ChildProcess
|
30
24
|
export function hashArray(input: Array<string>): string
|
31
25
|
export function hashFile(file: string): string | null
|
32
26
|
export function findImports(projectFileMap: Record<string, Array<string>>): Array<ImportResult>
|
@@ -146,17 +140,26 @@ export interface FileMap {
|
|
146
140
|
nonProjectFiles: Array<FileData>
|
147
141
|
}
|
148
142
|
export function testOnlyTransferFileMap(projectFiles: Record<string, Array<FileData>>, nonProjectFiles: Array<FileData>): NxWorkspaceFilesExternals
|
149
|
-
export class ChildProcess {
|
150
|
-
kill(): void
|
151
|
-
onExit(callback: (message: string) => void): void
|
152
|
-
onOutput(callback: (message: string) => void): void
|
153
|
-
}
|
154
143
|
export class ImportResult {
|
155
144
|
file: string
|
156
145
|
sourceProject: string
|
157
146
|
dynamicImportExpressions: Array<string>
|
158
147
|
staticImportExpressions: Array<string>
|
159
148
|
}
|
149
|
+
export class ChildProcess {
|
150
|
+
kill(): void
|
151
|
+
onExit(callback: (message: string) => void): void
|
152
|
+
onOutput(callback: (message: string) => void): void
|
153
|
+
}
|
154
|
+
export class RustPseudoTerminal {
|
155
|
+
constructor()
|
156
|
+
runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, quiet?: boolean | undefined | null): ChildProcess
|
157
|
+
/**
|
158
|
+
* This allows us to run a pseudoterminal with a fake node ipc channel
|
159
|
+
* this makes it possible to be backwards compatible with the old implementation
|
160
|
+
*/
|
161
|
+
fork(id: string, forkScript: string, pseudoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record<string, string> | undefined | null, quiet: boolean): ChildProcess
|
162
|
+
}
|
160
163
|
export class HashPlanner {
|
161
164
|
constructor(nxJson: NxJson, projectGraph: ExternalObject<ProjectGraph>)
|
162
165
|
getPlans(taskIds: Array<string>, taskGraph: TaskGraph): Record<string, string[]>
|
package/src/native/index.js
CHANGED
@@ -246,20 +246,19 @@ if (!nativeBinding) {
|
|
246
246
|
throw new Error(`Failed to load native binding`)
|
247
247
|
}
|
248
248
|
|
249
|
-
const { expandOutputs, getFilesForOutputs, remove, copy,
|
249
|
+
const { expandOutputs, getFilesForOutputs, remove, copy, hashArray, hashFile, ImportResult, findImports, transferProjectGraph, ChildProcess, RustPseudoTerminal, HashPlanner, TaskHasher, EventType, Watcher, WorkspaceContext, WorkspaceErrors, testOnlyTransferFileMap } = nativeBinding
|
250
250
|
|
251
251
|
module.exports.expandOutputs = expandOutputs
|
252
252
|
module.exports.getFilesForOutputs = getFilesForOutputs
|
253
253
|
module.exports.remove = remove
|
254
254
|
module.exports.copy = copy
|
255
|
-
module.exports.ChildProcess = ChildProcess
|
256
|
-
module.exports.runCommand = runCommand
|
257
|
-
module.exports.nxFork = nxFork
|
258
255
|
module.exports.hashArray = hashArray
|
259
256
|
module.exports.hashFile = hashFile
|
260
257
|
module.exports.ImportResult = ImportResult
|
261
258
|
module.exports.findImports = findImports
|
262
259
|
module.exports.transferProjectGraph = transferProjectGraph
|
260
|
+
module.exports.ChildProcess = ChildProcess
|
261
|
+
module.exports.RustPseudoTerminal = RustPseudoTerminal
|
263
262
|
module.exports.HashPlanner = HashPlanner
|
264
263
|
module.exports.TaskHasher = TaskHasher
|
265
264
|
module.exports.EventType = EventType
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CreateDependencies, CreateNodes } from '../../
|
1
|
+
import { CreateDependencies, CreateNodes } from '../../utils/nx-plugin';
|
2
2
|
export declare const name = "nx/js/dependencies-and-lockfile";
|
3
3
|
export declare const createNodes: CreateNodes;
|
4
4
|
export declare const createDependencies: CreateDependencies;
|
package/src/plugins/js/index.js
CHANGED
@@ -39,7 +39,7 @@ exports.createNodes = [
|
|
39
39
|
externalNodes: nodes,
|
40
40
|
};
|
41
41
|
}
|
42
|
-
const externalNodes = (0, lock_file_1.getLockFileNodes)(packageManager, lockFileContents, lockFileHash);
|
42
|
+
const externalNodes = (0, lock_file_1.getLockFileNodes)(packageManager, lockFileContents, lockFileHash, context);
|
43
43
|
parsedLockFile.externalNodes = externalNodes;
|
44
44
|
return {
|
45
45
|
externalNodes,
|
@@ -6,12 +6,12 @@ import { PackageManager } from '../../../utils/package-manager';
|
|
6
6
|
import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
|
7
7
|
import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
|
8
8
|
import { PackageJson } from '../../../utils/package-json';
|
9
|
-
import { CreateDependenciesContext } from '../../../
|
9
|
+
import { CreateDependenciesContext, CreateNodesContext } from '../../../utils/nx-plugin';
|
10
10
|
export declare const LOCKFILES: string[];
|
11
11
|
/**
|
12
12
|
* Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
|
13
13
|
*/
|
14
|
-
export declare function getLockFileNodes(packageManager: PackageManager, contents: string, lockFileHash: string): Record<string, ProjectGraphExternalNode>;
|
14
|
+
export declare function getLockFileNodes(packageManager: PackageManager, contents: string, lockFileHash: string, context: CreateNodesContext): Record<string, ProjectGraphExternalNode>;
|
15
15
|
/**
|
16
16
|
* Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
|
17
17
|
*/
|
@@ -26,10 +26,10 @@ const PNPM_LOCK_PATH = (0, path_1.join)(workspace_root_1.workspaceRoot, PNPM_LOC
|
|
26
26
|
/**
|
27
27
|
* Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
|
28
28
|
*/
|
29
|
-
function getLockFileNodes(packageManager, contents, lockFileHash) {
|
29
|
+
function getLockFileNodes(packageManager, contents, lockFileHash, context) {
|
30
30
|
try {
|
31
31
|
if (packageManager === 'yarn') {
|
32
|
-
const packageJson = (0, fileutils_1.readJsonFile)('package.json');
|
32
|
+
const packageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(context.workspaceRoot, 'package.json'));
|
33
33
|
return (0, yarn_parser_1.getYarnLockfileNodes)(contents, lockFileHash, packageJson);
|
34
34
|
}
|
35
35
|
if (packageManager === 'pnpm') {
|
@@ -109,6 +109,18 @@ function getLockFileName(packageManager) {
|
|
109
109
|
throw new Error(`Unknown package manager: ${packageManager}`);
|
110
110
|
}
|
111
111
|
exports.getLockFileName = getLockFileName;
|
112
|
+
function getLockFilePath(packageManager) {
|
113
|
+
if (packageManager === 'yarn') {
|
114
|
+
return YARN_LOCK_PATH;
|
115
|
+
}
|
116
|
+
if (packageManager === 'pnpm') {
|
117
|
+
return PNPM_LOCK_PATH;
|
118
|
+
}
|
119
|
+
if (packageManager === 'npm') {
|
120
|
+
return NPM_LOCK_PATH;
|
121
|
+
}
|
122
|
+
throw new Error(`Unknown package manager: ${packageManager}`);
|
123
|
+
}
|
112
124
|
/**
|
113
125
|
* Create lock file based on the root level lock file and (pruned) package.json
|
114
126
|
*
|
@@ -119,7 +131,7 @@ exports.getLockFileName = getLockFileName;
|
|
119
131
|
*/
|
120
132
|
function createLockFile(packageJson, graph, packageManager = (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot)) {
|
121
133
|
const normalizedPackageJson = (0, package_json_1.normalizePackageJson)(packageJson);
|
122
|
-
const content = (0, fs_1.readFileSync)(
|
134
|
+
const content = (0, fs_1.readFileSync)(getLockFilePath(packageManager), 'utf8');
|
123
135
|
try {
|
124
136
|
if (packageManager === 'yarn') {
|
125
137
|
const prunedGraph = (0, project_graph_pruning_1.pruneProjectGraph)(graph, packageJson);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { NormalizedPackageJson } from './utils/package-json';
|
2
2
|
import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
|
3
3
|
import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
|
4
|
-
import { CreateDependenciesContext } from '../../../
|
4
|
+
import { CreateDependenciesContext } from '../../../utils/nx-plugin';
|
5
5
|
export declare function getNpmLockfileNodes(lockFileContent: string, lockFileHash: string): Record<string, ProjectGraphExternalNode>;
|
6
6
|
export declare function getNpmLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
|
7
7
|
export declare function stringifyNpmLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson): string;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { NormalizedPackageJson } from './utils/package-json';
|
2
2
|
import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
|
3
3
|
import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
|
4
|
-
import { CreateDependenciesContext } from '../../../
|
4
|
+
import { CreateDependenciesContext } from '../../../utils/nx-plugin';
|
5
5
|
export declare function getPnpmLockfileNodes(lockFileContent: string, lockFileHash: string): Record<string, ProjectGraphExternalNode>;
|
6
6
|
export declare function getPnpmLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
|
7
7
|
export declare function stringifyPnpmLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson): string;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { NormalizedPackageJson } from './utils/package-json';
|
2
2
|
import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
|
3
3
|
import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
|
4
|
-
import { CreateDependenciesContext } from '../../../
|
4
|
+
import { CreateDependenciesContext } from '../../../utils/nx-plugin';
|
5
5
|
export declare function getYarnLockfileNodes(lockFileContent: string, lockFileHash: string, packageJson: NormalizedPackageJson): Record<string, ProjectGraphExternalNode>;
|
6
6
|
export declare function getYarnLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
|
7
7
|
export declare function stringifyYarnLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson): string;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CreateDependenciesContext } from '../../../../
|
1
|
+
import { CreateDependenciesContext } from '../../../../utils/nx-plugin';
|
2
2
|
import { RawProjectGraphDependency } from '../../../../project-graph/project-graph-builder';
|
3
3
|
export declare function buildExplicitDependencies(jsPluginConfig: {
|
4
4
|
analyzeSourceFiles?: boolean;
|
package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import { CreateDependenciesContext } from '../../../../
|
1
|
+
import { CreateDependenciesContext } from '../../../../utils/nx-plugin';
|
2
2
|
import { RawProjectGraphDependency } from '../../../../project-graph/project-graph-builder';
|
3
3
|
export declare function buildExplicitPackageJsonDependencies(ctx: CreateDependenciesContext): RawProjectGraphDependency[];
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { CreateDependenciesContext } from '../../../../
|
1
|
+
import { CreateDependenciesContext } from '../../../../utils/nx-plugin';
|
2
2
|
import { RawProjectGraphDependency } from '../../../../project-graph/project-graph-builder';
|
3
3
|
export declare function buildExplicitTypeScriptDependencies(ctx: CreateDependenciesContext): RawProjectGraphDependency[];
|
@@ -67,7 +67,9 @@ function getTranspiler(compilerOptions) {
|
|
67
67
|
}
|
68
68
|
compilerOptions.lib = ['es2021'];
|
69
69
|
compilerOptions.module = ts.ModuleKind.CommonJS;
|
70
|
-
|
70
|
+
// use NodeJs module resolution until support for TS 4.x is dropped and then
|
71
|
+
// we can switch to Node10
|
72
|
+
compilerOptions.moduleResolution = ts.ModuleResolutionKind.NodeJs;
|
71
73
|
compilerOptions.target = ts.ScriptTarget.ES2021;
|
72
74
|
compilerOptions.inlineSourceMap = true;
|
73
75
|
compilerOptions.skipLibCheck = true;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
2
2
|
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
3
|
+
import { NxPluginV2 } from '../../utils/nx-plugin';
|
3
4
|
import { PackageJson } from '../../utils/package-json';
|
4
|
-
|
5
|
-
export declare const createNodes: CreateNodes;
|
5
|
+
export declare function getNxPackageJsonWorkspacesPlugin(root: string): NxPluginV2;
|
6
6
|
export declare function createNodeFromPackageJson(pkgJsonPath: string, root: string): {
|
7
7
|
projects: {
|
8
8
|
[x: string]: ProjectConfiguration & {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.createNodeFromPackageJson = exports.
|
3
|
+
exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.createNodeFromPackageJson = exports.getNxPackageJsonWorkspacesPlugin = void 0;
|
4
4
|
const minimatch_1 = require("minimatch");
|
5
5
|
const node_fs_1 = require("node:fs");
|
6
6
|
const node_path_1 = require("node:path");
|
@@ -12,30 +12,37 @@ const logger_1 = require("../../utils/logger");
|
|
12
12
|
const output_1 = require("../../utils/output");
|
13
13
|
const package_json_1 = require("../../utils/package-json");
|
14
14
|
const path_1 = require("../../utils/path");
|
15
|
-
|
16
|
-
const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(
|
17
|
-
const patterns = getGlobPatternsFromPackageManagerWorkspaces(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
//
|
24
|
-
|
25
|
-
//
|
26
|
-
(positivePatterns.length ===
|
27
|
-
|
15
|
+
function getNxPackageJsonWorkspacesPlugin(root) {
|
16
|
+
const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, f));
|
17
|
+
const patterns = getGlobPatternsFromPackageManagerWorkspaces(root, readJson);
|
18
|
+
// If the user only specified a negative pattern, we should find all package.json
|
19
|
+
// files and only return those that don't match a negative pattern.
|
20
|
+
const negativePatterns = patterns.filter((p) => p.startsWith('!'));
|
21
|
+
let positivePatterns = patterns.filter((p) => !p.startsWith('!'));
|
22
|
+
if (
|
23
|
+
// There are some negative patterns
|
24
|
+
negativePatterns.length > 0 &&
|
25
|
+
// No positive patterns
|
26
|
+
(positivePatterns.length === 0 ||
|
27
|
+
// Or only a single positive pattern that is the default coming from root package
|
28
|
+
(positivePatterns.length === 1 && positivePatterns[0] === 'package.json'))) {
|
29
|
+
positivePatterns.push('**/package.json');
|
30
|
+
}
|
31
|
+
return {
|
32
|
+
name: 'nx/core/package-json-workspaces',
|
33
|
+
createNodes: [
|
34
|
+
(0, globs_1.combineGlobPatterns)(positivePatterns),
|
35
|
+
(p) => {
|
36
|
+
if (!negativePatterns.some((negative) => (0, minimatch_1.minimatch)(p, negative))) {
|
37
|
+
return createNodeFromPackageJson(p, root);
|
38
|
+
}
|
39
|
+
// A negative pattern matched, so we should not create a node for this package.json
|
40
|
+
return {};
|
41
|
+
},
|
42
|
+
],
|
43
|
+
};
|
28
44
|
}
|
29
|
-
exports.
|
30
|
-
(0, globs_1.combineGlobPatterns)(positivePatterns),
|
31
|
-
(p, _, { workspaceRoot }) => {
|
32
|
-
if (!negativePatterns.some((negative) => (0, minimatch_1.minimatch)(p, negative))) {
|
33
|
-
return createNodeFromPackageJson(p, workspaceRoot);
|
34
|
-
}
|
35
|
-
// A negative pattern matched, so we should not create a node for this package.json
|
36
|
-
return {};
|
37
|
-
},
|
38
|
-
];
|
45
|
+
exports.getNxPackageJsonWorkspacesPlugin = getNxPackageJsonWorkspacesPlugin;
|
39
46
|
function createNodeFromPackageJson(pkgJsonPath, root) {
|
40
47
|
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, pkgJsonPath));
|
41
48
|
const project = buildProjectConfigurationFromPackageJson(json, pkgJsonPath, (0, nx_json_1.readNxJson)(root));
|
@@ -24,7 +24,6 @@ exports.PackageJsonProjectsNextToProjectJsonPlugin = {
|
|
24
24
|
},
|
25
25
|
],
|
26
26
|
};
|
27
|
-
exports.default = exports.PackageJsonProjectsNextToProjectJsonPlugin;
|
28
27
|
function createProjectFromPackageJsonNextToProjectJson(projectJsonPath, workspaceRoot) {
|
29
28
|
const root = (0, path_1.dirname)(projectJsonPath);
|
30
29
|
const packageJsonPath = (0, path_1.join)(workspaceRoot, root, 'package.json');
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { ProjectConfiguration } from '../../../config/workspace-json-project-json';
|
2
|
-
import { NxPluginV2 } from '../../../
|
2
|
+
import { NxPluginV2 } from '../../../utils/nx-plugin';
|
3
3
|
export declare const ProjectJsonProjectsPlugin: NxPluginV2;
|
4
|
-
export default ProjectJsonProjectsPlugin;
|
5
4
|
export declare function buildProjectFromProjectJson(json: Partial<ProjectConfiguration>, path: string): ProjectConfiguration;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { TargetConfiguration } from '../../config/workspace-json-project-json';
|
2
|
-
import { NxPluginV2 } from '../../
|
2
|
+
import { NxPluginV2 } from '../../utils/nx-plugin';
|
3
3
|
/**
|
4
4
|
* This marks that a target provides information which should modify a target already registered
|
5
5
|
* on the project via other plugins. If the target has not already been registered, and this symbol is true,
|
@@ -18,7 +18,6 @@ export declare const ONLY_MODIFIES_EXISTING_TARGET = "NX_ONLY_MODIFIES_EXISTING_
|
|
18
18
|
*/
|
19
19
|
export declare const OVERRIDE_SOURCE_FILE = "NX_OVERRIDE_SOURCE_FILE";
|
20
20
|
export declare const TargetDefaultsPlugin: NxPluginV2;
|
21
|
-
export default TargetDefaultsPlugin;
|
22
21
|
/**
|
23
22
|
* This fn gets target info that would make a target uniquely compatible
|
24
23
|
* with what is described by project.json or package.json. As the merge process
|
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTouchedProjectsFromProjectGlobChanges = void 0;
|
4
4
|
const minimatch_1 = require("minimatch");
|
5
5
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
6
|
+
const installation_directory_1 = require("../../../utils/installation-directory");
|
6
7
|
const path_1 = require("path");
|
7
8
|
const fs_1 = require("fs");
|
8
9
|
const retrieve_workspace_files_1 = require("../../utils/retrieve-workspace-files");
|
9
|
-
const
|
10
|
+
const nx_plugin_1 = require("../../../utils/nx-plugin");
|
10
11
|
const globs_1 = require("../../../utils/globs");
|
11
12
|
const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGraphNodes, nxJson) => {
|
12
|
-
const globPattern = (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(await (0,
|
13
|
+
const globPattern = (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(await (0, nx_plugin_1.loadNxPlugins)(nxJson?.plugins, (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot), workspace_root_1.workspaceRoot)));
|
13
14
|
const touchedProjects = new Set();
|
14
15
|
for (const touchedFile of touchedFiles) {
|
15
16
|
const isProjectFile = (0, minimatch_1.minimatch)(touchedFile.file, globPattern, {
|
@@ -8,15 +8,14 @@ const assert_workspace_validity_1 = require("../utils/assert-workspace-validity"
|
|
8
8
|
const nx_deps_cache_1 = require("./nx-deps-cache");
|
9
9
|
const implicit_project_dependencies_1 = require("./utils/implicit-project-dependencies");
|
10
10
|
const normalize_project_nodes_1 = require("./utils/normalize-project-nodes");
|
11
|
-
const
|
12
|
-
const utils_1 = require("./plugins/utils");
|
11
|
+
const nx_plugin_1 = require("../utils/nx-plugin");
|
13
12
|
const typescript_1 = require("../plugins/js/utils/typescript");
|
14
13
|
const fileutils_1 = require("../utils/fileutils");
|
15
14
|
const project_graph_builder_1 = require("./project-graph-builder");
|
16
15
|
const configuration_1 = require("../config/configuration");
|
17
16
|
const fs_1 = require("fs");
|
17
|
+
const installation_directory_1 = require("../utils/installation-directory");
|
18
18
|
const output_1 = require("../utils/output");
|
19
|
-
const plugin_pool_1 = require("./plugins/plugin-pool");
|
20
19
|
let storedFileMap = null;
|
21
20
|
let storedAllWorkspaceFiles = null;
|
22
21
|
let storedRustReferences = null;
|
@@ -71,7 +70,6 @@ async function buildProjectGraphUsingProjectFileMap(projects, externalNodes, fil
|
|
71
70
|
if (shouldWriteCache) {
|
72
71
|
(0, nx_deps_cache_1.writeCache)(projectFileMapCache, projectGraph);
|
73
72
|
}
|
74
|
-
await (0, plugin_pool_1.shutdownPluginWorkers)();
|
75
73
|
return {
|
76
74
|
projectGraph,
|
77
75
|
projectFileMapCache,
|
@@ -142,11 +140,11 @@ function createContext(projects, nxJson, externalNodes, fileMap, filesToProcess)
|
|
142
140
|
};
|
143
141
|
}
|
144
142
|
async function updateProjectGraphWithPlugins(context, initProjectGraph) {
|
145
|
-
const plugins = await (0,
|
143
|
+
const plugins = await (0, nx_plugin_1.loadNxPlugins)(context.nxJsonConfiguration?.plugins, (0, installation_directory_1.getNxRequirePaths)(), context.workspaceRoot, context.projects);
|
146
144
|
let graph = initProjectGraph;
|
147
|
-
for (const plugin of plugins) {
|
145
|
+
for (const { plugin } of plugins) {
|
148
146
|
try {
|
149
|
-
if ((0,
|
147
|
+
if ((0, nx_plugin_1.isNxPluginV1)(plugin) &&
|
150
148
|
plugin.processProjectGraph &&
|
151
149
|
!plugin.createDependencies) {
|
152
150
|
output_1.output.warn({
|
@@ -184,12 +182,11 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph) {
|
|
184
182
|
}
|
185
183
|
}
|
186
184
|
const builder = new project_graph_builder_1.ProjectGraphBuilder(graph, context.fileMap.projectFileMap, context.fileMap.nonProjectFiles);
|
187
|
-
const createDependencyPlugins = plugins.filter((plugin) => (0,
|
188
|
-
await Promise.all(createDependencyPlugins.map(async (plugin) => {
|
185
|
+
const createDependencyPlugins = plugins.filter(({ plugin }) => (0, nx_plugin_1.isNxPluginV2)(plugin) && plugin.createDependencies);
|
186
|
+
await Promise.all(createDependencyPlugins.map(async ({ plugin, options }) => {
|
189
187
|
perf_hooks_1.performance.mark(`${plugin.name}:createDependencies - start`);
|
190
188
|
try {
|
191
|
-
|
192
|
-
const dependencies = await plugin.createDependencies(null, {
|
189
|
+
const dependencies = await plugin.createDependencies(options, {
|
193
190
|
...context,
|
194
191
|
});
|
195
192
|
for (const dep of dependencies) {
|
@@ -147,23 +147,25 @@ Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: funct
|
|
147
147
|
* TODO(v19): Remove this function.
|
148
148
|
*/
|
149
149
|
function getProjectsSyncNoInference(root, nxJson) {
|
150
|
-
const
|
150
|
+
const allConfigFiles = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(root, (0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root));
|
151
151
|
const plugins = [
|
152
152
|
{ plugin: package_json_next_to_project_json_1.PackageJsonProjectsNextToProjectJsonPlugin },
|
153
153
|
...(0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root),
|
154
154
|
];
|
155
155
|
const projectRootMap = new Map();
|
156
156
|
// We iterate over plugins first - this ensures that plugins specified first take precedence.
|
157
|
-
for (const { plugin } of plugins) {
|
157
|
+
for (const { plugin, options } of plugins) {
|
158
158
|
const [pattern, createNodes] = plugin.createNodes ?? [];
|
159
159
|
if (!pattern) {
|
160
160
|
continue;
|
161
161
|
}
|
162
|
-
|
162
|
+
const matchingConfigFiles = allConfigFiles.filter((file) => (0, minimatch_1.minimatch)(file, pattern, { dot: true }));
|
163
|
+
for (const file of matchingConfigFiles) {
|
163
164
|
if ((0, minimatch_1.minimatch)(file, pattern, { dot: true })) {
|
164
|
-
let r = createNodes(file,
|
165
|
+
let r = createNodes(file, options, {
|
165
166
|
nxJsonConfiguration: nxJson,
|
166
167
|
workspaceRoot: root,
|
168
|
+
configFiles: matchingConfigFiles,
|
167
169
|
});
|
168
170
|
for (const node in r.projects) {
|
169
171
|
const project = {
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* Builder for adding nodes and dependencies to a {@link ProjectGraph}
|
3
3
|
*/
|
4
4
|
import { DependencyType, FileMap, ProjectFileMap, ProjectGraph, ProjectGraphExternalNode, ProjectGraphProjectNode } from '../config/project-graph';
|
5
|
-
import { CreateDependenciesContext } from '
|
5
|
+
import { CreateDependenciesContext } from '../utils/nx-plugin';
|
6
6
|
/**
|
7
7
|
* A class which builds up a project graph
|
8
8
|
* @deprecated The {@link ProjectGraphProcessor} has been deprecated. Use a {@link CreateNodes} and/or a {@link CreateDependencies} instead. This will be removed in Nx 19.
|
@@ -12,6 +12,7 @@ const workspace_root_1 = require("../utils/workspace-root");
|
|
12
12
|
const perf_hooks_1 = require("perf_hooks");
|
13
13
|
const retrieve_workspace_files_1 = require("./utils/retrieve-workspace-files");
|
14
14
|
const nx_json_1 = require("../config/nx-json");
|
15
|
+
const nx_plugin_1 = require("../utils/nx-plugin");
|
15
16
|
/**
|
16
17
|
* Synchronously reads the latest cached copy of the workspace's ProjectGraph.
|
17
18
|
* @throws {Error} if there is no cached ProjectGraph to read from
|
@@ -65,6 +66,7 @@ function readProjectsConfigurationFromProjectGraph(projectGraph) {
|
|
65
66
|
}
|
66
67
|
exports.readProjectsConfigurationFromProjectGraph = readProjectsConfigurationFromProjectGraph;
|
67
68
|
async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
69
|
+
// Set this globally to allow plugins to know if they are being called from the project graph creation
|
68
70
|
global.NX_GRAPH_CREATION = true;
|
69
71
|
const nxJson = (0, nx_json_1.readNxJson)();
|
70
72
|
perf_hooks_1.performance.mark('retrieve-project-configurations:start');
|
@@ -77,6 +79,7 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
|
77
79
|
perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:start');
|
78
80
|
const projectGraph = (await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, cacheEnabled ? (0, nx_deps_cache_1.readFileMapCache)() : null, cacheEnabled)).projectGraph;
|
79
81
|
perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:end');
|
82
|
+
(0, nx_plugin_1.unregisterPluginTSTranspiler)();
|
80
83
|
delete global.NX_GRAPH_CREATION;
|
81
84
|
return { projectGraph, sourceMaps };
|
82
85
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ProjectGraphProjectNode } from '../../config/project-graph';
|
2
2
|
import { ProjectGraphBuilder } from '../project-graph-builder';
|
3
3
|
import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
|
4
|
-
import { CreateDependenciesContext } from '
|
4
|
+
import { CreateDependenciesContext } from '../../utils/nx-plugin';
|
5
5
|
export declare function normalizeProjectNodes(ctx: CreateDependenciesContext, builder: ProjectGraphBuilder): Promise<void>;
|
6
6
|
/**
|
7
7
|
* Apply target defaults and normalization
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { NxJsonConfiguration, TargetDefaults } from '../../config/nx-json';
|
2
2
|
import { ProjectGraphExternalNode } from '../../config/project-graph';
|
3
3
|
import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
|
4
|
+
import { LoadedNxPlugin } from '../../utils/nx-plugin';
|
4
5
|
import { ONLY_MODIFIES_EXISTING_TARGET } from '../../plugins/target-defaults/target-defaults-plugin';
|
5
|
-
import { RemotePlugin } from '../plugins/internal-api';
|
6
6
|
export type SourceInformation = [file: string, plugin: string];
|
7
7
|
export type ConfigurationSourceMaps = Record<string, Record<string, SourceInformation>>;
|
8
8
|
export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Map<string, ProjectConfiguration>, project: ProjectConfiguration & {
|
@@ -20,12 +20,12 @@ export type ConfigurationResult = {
|
|
20
20
|
* Transforms a list of project paths into a map of project configurations.
|
21
21
|
*
|
22
22
|
* @param nxJson The NxJson configuration
|
23
|
-
* @param
|
23
|
+
* @param workspaceFiles A list of non-ignored workspace files
|
24
24
|
* @param plugins The plugins that should be used to infer project configuration
|
25
25
|
* @param root The workspace root
|
26
26
|
*/
|
27
|
-
export declare function buildProjectsConfigurationsFromProjectPathsAndPlugins(nxJson: NxJsonConfiguration,
|
28
|
-
plugins:
|
27
|
+
export declare function buildProjectsConfigurationsFromProjectPathsAndPlugins(nxJson: NxJsonConfiguration, workspaceFiles: string[], // making this parameter allows devkit to pick up newly created projects
|
28
|
+
plugins: LoadedNxPlugin[], root?: string): Promise<ConfigurationResult>;
|
29
29
|
export declare function readProjectConfigurationsFromRootMap(projectRootMap: Map<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
|
30
30
|
/**
|
31
31
|
* Merges two targets.
|