nx 21.0.0-beta.7 → 21.0.0-beta.9
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/migrations.json +5 -35
- package/package.json +11 -11
- package/schemas/nx-schema.json +34 -38
- package/schemas/project-schema.json +5 -0
- package/src/command-line/migrate/migrate-ui-api.d.ts +2 -0
- package/src/command-line/migrate/migrate-ui-api.js +39 -0
- package/src/command-line/migrate/migrate.d.ts +0 -4
- package/src/command-line/migrate/migrate.js +8 -21
- package/src/command-line/release/command-object.d.ts +6 -0
- package/src/command-line/release/config/config.js +15 -8
- package/src/command-line/release/config/use-legacy-versioning.js +4 -4
- package/src/command-line/release/version/release-group-processor.d.ts +10 -9
- package/src/command-line/release/version/release-group-processor.js +25 -8
- package/src/command-line/release/version/test-utils.d.ts +2 -4
- package/src/command-line/release/version/test-utils.js +13 -14
- package/src/command-line/release/version/version-actions.d.ts +9 -8
- package/src/command-line/release/version/version-actions.js +21 -9
- package/src/command-line/release/version.js +6 -2
- package/src/command-line/repair/repair.js +0 -1
- package/src/command-line/run/executor-utils.d.ts +6 -1
- package/src/command-line/run/executor-utils.js +10 -1
- package/src/command-line/run/run.js +1 -1
- package/src/config/misc-interfaces.d.ts +1 -1
- package/src/config/nx-json.d.ts +15 -9
- package/src/config/workspace-json-project-json.d.ts +2 -2
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.css +1 -1
- package/src/devkit-internals.d.ts +1 -1
- package/src/devkit-internals.js +2 -1
- package/src/migrations/{update-17-0-0/rm-default-collection-npm-scope.d.ts → update-21-0-0/release-version-config-changes.d.ts} +1 -1
- package/src/migrations/update-21-0-0/release-version-config-changes.js +111 -0
- package/src/native/index.d.ts +2 -0
- package/src/native/native-bindings.js +1 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/lock-file/utils/package-json.js +6 -5
- package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -3
- package/src/plugins/package-json/create-nodes.js +1 -1
- package/src/project-graph/file-utils.d.ts +1 -10
- package/src/project-graph/file-utils.js +2 -77
- package/src/project-graph/plugins/public-api.d.ts +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +2 -2
- package/src/project-graph/utils/project-configuration-utils.js +29 -10
- package/src/tasks-runner/batch/run-batch.js +1 -1
- package/src/tasks-runner/create-task-graph.d.ts +0 -1
- package/src/tasks-runner/create-task-graph.js +0 -1
- package/src/tasks-runner/init-tasks-runner.d.ts +1 -1
- package/src/tasks-runner/init-tasks-runner.js +8 -2
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.d.ts +2 -0
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +8 -5
- package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +5 -0
- package/src/tasks-runner/life-cycles/task-history-life-cycle.js +29 -4
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +2 -0
- package/src/tasks-runner/run-command.d.ts +1 -0
- package/src/tasks-runner/run-command.js +4 -6
- package/src/tasks-runner/task-orchestrator.d.ts +2 -1
- package/src/tasks-runner/task-orchestrator.js +12 -6
- package/src/tasks-runner/utils.js +1 -1
- package/src/utils/package-json.d.ts +1 -1
- package/src/utils/package-json.js +16 -2
- package/src/migrations/update-17-0-0/move-cache-directory.d.ts +0 -2
- package/src/migrations/update-17-0-0/move-cache-directory.js +0 -35
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +0 -72
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +0 -2
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +0 -122
- package/src/migrations/update-17-2-0/move-default-base.d.ts +0 -5
- package/src/migrations/update-17-2-0/move-default-base.js +0 -21
- package/src/migrations/update-17-3-0/nx-release-path.d.ts +0 -3
- package/src/migrations/update-17-3-0/nx-release-path.js +0 -47
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +0 -2
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +0 -11
@@ -66,9 +66,9 @@ export declare function isCompatibleTarget(a: TargetConfiguration, b: TargetConf
|
|
66
66
|
export declare function resolveNxTokensInOptions<T extends Object | Array<unknown>>(object: T, project: ProjectConfiguration, key: string): T;
|
67
67
|
export declare function readTargetDefaultsForTarget(targetName: string, targetDefaults: TargetDefaults, executor?: string): TargetDefaults[string];
|
68
68
|
/**
|
69
|
-
* Expand's `command` syntactic sugar
|
69
|
+
* Expand's `command` syntactic sugar, replaces tokens in options, and adds information from executor schema.
|
70
70
|
* @param target The target to normalize
|
71
71
|
* @param project The project that the target belongs to
|
72
72
|
* @returns The normalized target configuration
|
73
73
|
*/
|
74
|
-
export declare function normalizeTarget(target: TargetConfiguration, project: ProjectConfiguration): TargetConfiguration<any>;
|
74
|
+
export declare function normalizeTarget(target: TargetConfiguration, project: ProjectConfiguration, workspaceRoot: string, projectsMap: Record<string, ProjectConfiguration>): TargetConfiguration<any>;
|
@@ -21,6 +21,7 @@ const perf_hooks_1 = require("perf_hooks");
|
|
21
21
|
const error_types_1 = require("../error-types");
|
22
22
|
const globs_1 = require("../../utils/globs");
|
23
23
|
const delayed_spinner_1 = require("../../utils/delayed-spinner");
|
24
|
+
const executor_utils_1 = require("../../command-line/run/executor-utils");
|
24
25
|
function mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInformation,
|
25
26
|
// This function is used when reading project configuration
|
26
27
|
// in generators, where we don't want to do this.
|
@@ -294,7 +295,7 @@ plugins) {
|
|
294
295
|
}
|
295
296
|
return Promise.all(results).then((results) => {
|
296
297
|
spinner?.cleanup();
|
297
|
-
const { projectRootMap, externalNodes, rootMap, configurationSourceMaps } = mergeCreateNodesResults(results, nxJson, errors);
|
298
|
+
const { projectRootMap, externalNodes, rootMap, configurationSourceMaps } = mergeCreateNodesResults(results, nxJson, root, errors);
|
298
299
|
perf_hooks_1.performance.mark('build-project-configs:end');
|
299
300
|
perf_hooks_1.performance.measure('build-project-configs', 'build-project-configs:start', 'build-project-configs:end');
|
300
301
|
if (errors.length === 0) {
|
@@ -317,7 +318,7 @@ plugins) {
|
|
317
318
|
}
|
318
319
|
});
|
319
320
|
}
|
320
|
-
function mergeCreateNodesResults(results, nxJsonConfiguration, errors) {
|
321
|
+
function mergeCreateNodesResults(results, nxJsonConfiguration, workspaceRoot, errors) {
|
321
322
|
perf_hooks_1.performance.mark('createNodes:merge - start');
|
322
323
|
const projectRootMap = {};
|
323
324
|
const externalNodes = {};
|
@@ -350,7 +351,7 @@ function mergeCreateNodesResults(results, nxJsonConfiguration, errors) {
|
|
350
351
|
Object.assign(externalNodes, pluginExternalNodes);
|
351
352
|
}
|
352
353
|
try {
|
353
|
-
validateAndNormalizeProjectRootMap(projectRootMap, nxJsonConfiguration, configurationSourceMaps);
|
354
|
+
validateAndNormalizeProjectRootMap(workspaceRoot, projectRootMap, nxJsonConfiguration, configurationSourceMaps);
|
354
355
|
}
|
355
356
|
catch (e) {
|
356
357
|
if ((0, error_types_1.isProjectsWithNoNameError)(e) ||
|
@@ -428,7 +429,7 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
|
|
428
429
|
}
|
429
430
|
return projects;
|
430
431
|
}
|
431
|
-
function validateAndNormalizeProjectRootMap(projectRootMap, nxJsonConfiguration, sourceMaps = {}) {
|
432
|
+
function validateAndNormalizeProjectRootMap(workspaceRoot, projectRootMap, nxJsonConfiguration, sourceMaps = {}) {
|
432
433
|
// Name -> Project, used to validate that all projects have unique names
|
433
434
|
const projects = {};
|
434
435
|
// If there are projects that have the same name, that is an error.
|
@@ -461,7 +462,7 @@ function validateAndNormalizeProjectRootMap(projectRootMap, nxJsonConfiguration,
|
|
461
462
|
throw e;
|
462
463
|
}
|
463
464
|
}
|
464
|
-
normalizeTargets(project, sourceMaps, nxJsonConfiguration);
|
465
|
+
normalizeTargets(project, sourceMaps, nxJsonConfiguration, workspaceRoot, projects);
|
465
466
|
}
|
466
467
|
if (conflicts.size > 0) {
|
467
468
|
throw new error_types_1.MultipleProjectsWithSameNameError(conflicts, projects);
|
@@ -471,15 +472,19 @@ function validateAndNormalizeProjectRootMap(projectRootMap, nxJsonConfiguration,
|
|
471
472
|
}
|
472
473
|
return projectRootMap;
|
473
474
|
}
|
474
|
-
function normalizeTargets(project, sourceMaps, nxJsonConfiguration
|
475
|
+
function normalizeTargets(project, sourceMaps, nxJsonConfiguration, workspaceRoot,
|
476
|
+
/**
|
477
|
+
* Project configurations keyed by project name
|
478
|
+
*/
|
479
|
+
projects) {
|
475
480
|
for (const targetName in project.targets) {
|
476
|
-
project.targets[targetName] = normalizeTarget(project.targets[targetName], project);
|
481
|
+
project.targets[targetName] = normalizeTarget(project.targets[targetName], project, workspaceRoot, projects);
|
477
482
|
const projectSourceMaps = sourceMaps[project.root];
|
478
483
|
const targetConfig = project.targets[targetName];
|
479
484
|
const targetDefaults = deepClone(readTargetDefaultsForTarget(targetName, nxJsonConfiguration.targetDefaults, targetConfig.executor));
|
480
485
|
// We only apply defaults if they exist
|
481
486
|
if (targetDefaults && isCompatibleTarget(targetConfig, targetDefaults)) {
|
482
|
-
project.targets[targetName] = mergeTargetDefaultWithTargetDefinition(targetName, project, normalizeTarget(targetDefaults, project), projectSourceMaps);
|
487
|
+
project.targets[targetName] = mergeTargetDefaultWithTargetDefinition(targetName, project, normalizeTarget(targetDefaults, project, workspaceRoot, projects), projectSourceMaps);
|
483
488
|
}
|
484
489
|
if (
|
485
490
|
// If the target has no executor or command, it doesn't do anything
|
@@ -789,12 +794,12 @@ function resolveCommandSyntacticSugar(target, key) {
|
|
789
794
|
}
|
790
795
|
}
|
791
796
|
/**
|
792
|
-
* Expand's `command` syntactic sugar
|
797
|
+
* Expand's `command` syntactic sugar, replaces tokens in options, and adds information from executor schema.
|
793
798
|
* @param target The target to normalize
|
794
799
|
* @param project The project that the target belongs to
|
795
800
|
* @returns The normalized target configuration
|
796
801
|
*/
|
797
|
-
function normalizeTarget(target, project) {
|
802
|
+
function normalizeTarget(target, project, workspaceRoot, projectsMap) {
|
798
803
|
target = {
|
799
804
|
...target,
|
800
805
|
configurations: {
|
@@ -807,5 +812,19 @@ function normalizeTarget(target, project) {
|
|
807
812
|
target.configurations[configuration] = resolveNxTokensInOptions(target.configurations[configuration], project, `${project.root}:${target}:${configuration}`);
|
808
813
|
}
|
809
814
|
target.parallelism ??= true;
|
815
|
+
if (target.executor && !('continuous' in target)) {
|
816
|
+
try {
|
817
|
+
const [executorNodeModule, executorName] = (0, executor_utils_1.parseExecutor)(target.executor);
|
818
|
+
const { schema } = (0, executor_utils_1.getExecutorInformation)(executorNodeModule, executorName, workspaceRoot, projectsMap);
|
819
|
+
if (schema.continuous) {
|
820
|
+
target.continuous ??= schema.continuous;
|
821
|
+
}
|
822
|
+
}
|
823
|
+
catch (e) {
|
824
|
+
// If the executor is not found, we assume that it is not a valid executor.
|
825
|
+
// This means that we should not set the continuous property.
|
826
|
+
// We could throw an error here, but it would be better to just ignore it.
|
827
|
+
}
|
828
|
+
}
|
810
829
|
return target;
|
811
830
|
}
|
@@ -8,7 +8,7 @@ const configuration_1 = require("../../config/configuration");
|
|
8
8
|
const async_iterator_1 = require("../../utils/async-iterator");
|
9
9
|
const executor_utils_1 = require("../../command-line/run/executor-utils");
|
10
10
|
function getBatchExecutor(executorName, projects) {
|
11
|
-
const [nodeModule, exportName] =
|
11
|
+
const [nodeModule, exportName] = (0, executor_utils_1.parseExecutor)(executorName);
|
12
12
|
return (0, executor_utils_1.getExecutorInformation)(nodeModule, exportName, workspace_root_1.workspaceRoot, projects);
|
13
13
|
}
|
14
14
|
async function runTasks(executorName, projectGraph, batchTaskGraph, fullTaskGraph) {
|
@@ -40,4 +40,3 @@ export declare function filterDummyTasks(dependencies: {
|
|
40
40
|
export declare function getNonDummyDeps(currentTask: string, dependencies: {
|
41
41
|
[k: string]: string[];
|
42
42
|
}, cycles?: Set<string>, seen?: Set<string>): string[];
|
43
|
-
export declare function createTaskId(project: string, target: string, configuration: string | undefined): string;
|
@@ -5,7 +5,6 @@ exports.createTaskGraph = createTaskGraph;
|
|
5
5
|
exports.mapTargetDefaultsToDependencies = mapTargetDefaultsToDependencies;
|
6
6
|
exports.filterDummyTasks = filterDummyTasks;
|
7
7
|
exports.getNonDummyDeps = getNonDummyDeps;
|
8
|
-
exports.createTaskId = createTaskId;
|
9
8
|
const utils_1 = require("./utils");
|
10
9
|
const project_graph_utils_1 = require("../utils/project-graph-utils");
|
11
10
|
const output_1 = require("../utils/output");
|
@@ -1,8 +1,8 @@
|
|
1
|
+
import type { NxJsonConfiguration } from '../config/nx-json';
|
1
2
|
import { NxArgs } from '../utils/command-line-utils';
|
2
3
|
import { Task, TaskGraph } from '../config/task-graph';
|
3
4
|
import { LifeCycle, TaskResult } from './life-cycle';
|
4
5
|
import type { ProjectGraph } from '../config/project-graph';
|
5
|
-
import type { NxJsonConfiguration } from '../config/nx-json';
|
6
6
|
import { RunningTask } from './running-tasks/running-task';
|
7
7
|
/**
|
8
8
|
* This function is deprecated. Do not use this
|
@@ -99,9 +99,15 @@ async function createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJs
|
|
99
99
|
return acc;
|
100
100
|
}, {}),
|
101
101
|
};
|
102
|
-
const
|
102
|
+
const nxArgs = {
|
103
|
+
...options,
|
104
|
+
parallel: tasks.length,
|
105
|
+
lifeCycle: compositedLifeCycle,
|
106
|
+
};
|
107
|
+
(0, run_command_1.setEnvVarsBasedOnArgs)(nxArgs, true);
|
108
|
+
const orchestrator = new task_orchestrator_1.TaskOrchestrator(hasher, null, [], projectGraph, taskGraph, nxJson, nxArgs, false, client_1.daemonClient, undefined, taskGraphForHashing);
|
103
109
|
await orchestrator.init();
|
104
|
-
|
110
|
+
orchestrator.processTasks(tasks.map((task) => task.id));
|
105
111
|
return orchestrator;
|
106
112
|
}
|
107
113
|
async function runDiscreteTasks(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle) {
|
@@ -3,7 +3,9 @@ import { LifeCycle, TaskResult } from '../life-cycle';
|
|
3
3
|
export declare class LegacyTaskHistoryLifeCycle implements LifeCycle {
|
4
4
|
private startTimings;
|
5
5
|
private taskRuns;
|
6
|
+
private flakyTasks;
|
6
7
|
startTasks(tasks: Task[]): void;
|
7
8
|
endTasks(taskResults: TaskResult[]): Promise<void>;
|
8
9
|
endCommand(): Promise<void>;
|
10
|
+
printFlakyTasksMessage(): void;
|
9
11
|
}
|
@@ -31,24 +31,27 @@ class LegacyTaskHistoryLifeCycle {
|
|
31
31
|
async endCommand() {
|
32
32
|
await (0, legacy_task_history_1.writeTaskRunsToHistory)(this.taskRuns);
|
33
33
|
const history = await (0, legacy_task_history_1.getHistoryForHashes)(this.taskRuns.map((t) => t.hash));
|
34
|
-
|
34
|
+
this.flakyTasks = [];
|
35
35
|
// check if any hash has different exit codes => flaky
|
36
36
|
for (let hash in history) {
|
37
37
|
if (history[hash].length > 1 &&
|
38
38
|
history[hash].some((run) => run.code !== history[hash][0].code)) {
|
39
|
-
flakyTasks.push((0, serialize_target_1.serializeTarget)(history[hash][0].project, history[hash][0].target, history[hash][0].configuration));
|
39
|
+
this.flakyTasks.push((0, serialize_target_1.serializeTarget)(history[hash][0].project, history[hash][0].target, history[hash][0].configuration));
|
40
40
|
}
|
41
41
|
}
|
42
42
|
// Do not directly print output when using the TUI
|
43
43
|
if ((0, is_tui_enabled_1.isTuiEnabled)()) {
|
44
44
|
return;
|
45
45
|
}
|
46
|
-
|
46
|
+
this.printFlakyTasksMessage();
|
47
|
+
}
|
48
|
+
printFlakyTasksMessage() {
|
49
|
+
if (this.flakyTasks.length > 0) {
|
47
50
|
output_1.output.warn({
|
48
|
-
title: `Nx detected ${flakyTasks.length === 1 ? 'a flaky task' : ' flaky tasks'}`,
|
51
|
+
title: `Nx detected ${this.flakyTasks.length === 1 ? 'a flaky task' : ' flaky tasks'}`,
|
49
52
|
bodyLines: [
|
50
53
|
,
|
51
|
-
...flakyTasks.map((t) => ` ${t}`),
|
54
|
+
...this.flakyTasks.map((t) => ` ${t}`),
|
52
55
|
'',
|
53
56
|
`Flaky tasks can disrupt your CI pipeline. Automatically retry them with Nx Cloud. Learn more at https://nx.dev/ci/features/flaky-tasks`,
|
54
57
|
],
|
@@ -1,10 +1,15 @@
|
|
1
1
|
import { Task } from '../../config/task-graph';
|
2
2
|
import { LifeCycle, TaskResult } from '../life-cycle';
|
3
|
+
import { LegacyTaskHistoryLifeCycle } from './task-history-life-cycle-old';
|
4
|
+
export declare function getTasksHistoryLifeCycle(): TaskHistoryLifeCycle | LegacyTaskHistoryLifeCycle | null;
|
3
5
|
export declare class TaskHistoryLifeCycle implements LifeCycle {
|
4
6
|
private startTimings;
|
5
7
|
private taskRuns;
|
6
8
|
private taskHistory;
|
9
|
+
private flakyTasks;
|
10
|
+
constructor();
|
7
11
|
startTasks(tasks: Task[]): void;
|
8
12
|
endTasks(taskResults: TaskResult[]): Promise<void>;
|
9
13
|
endCommand(): Promise<void>;
|
14
|
+
printFlakyTasksMessage(): void;
|
10
15
|
}
|
@@ -1,15 +1,37 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.TaskHistoryLifeCycle = void 0;
|
4
|
+
exports.getTasksHistoryLifeCycle = getTasksHistoryLifeCycle;
|
5
|
+
const native_1 = require("../../native");
|
4
6
|
const output_1 = require("../../utils/output");
|
5
7
|
const serialize_target_1 = require("../../utils/serialize-target");
|
6
8
|
const task_history_1 = require("../../utils/task-history");
|
7
9
|
const is_tui_enabled_1 = require("../is-tui-enabled");
|
10
|
+
const task_history_life_cycle_old_1 = require("./task-history-life-cycle-old");
|
11
|
+
const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
|
12
|
+
const nx_json_1 = require("../../config/nx-json");
|
13
|
+
let tasksHistoryLifeCycle;
|
14
|
+
function getTasksHistoryLifeCycle() {
|
15
|
+
if (!(0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)())) {
|
16
|
+
if (!tasksHistoryLifeCycle) {
|
17
|
+
tasksHistoryLifeCycle =
|
18
|
+
process.env.NX_DISABLE_DB !== 'true' && !native_1.IS_WASM
|
19
|
+
? new TaskHistoryLifeCycle()
|
20
|
+
: new task_history_life_cycle_old_1.LegacyTaskHistoryLifeCycle();
|
21
|
+
}
|
22
|
+
return tasksHistoryLifeCycle;
|
23
|
+
}
|
24
|
+
return null;
|
25
|
+
}
|
8
26
|
class TaskHistoryLifeCycle {
|
9
27
|
constructor() {
|
10
28
|
this.startTimings = {};
|
11
29
|
this.taskRuns = new Map();
|
12
30
|
this.taskHistory = (0, task_history_1.getTaskHistory)();
|
31
|
+
if (tasksHistoryLifeCycle) {
|
32
|
+
throw new Error('TaskHistoryLifeCycle is a singleton and should not be instantiated multiple times');
|
33
|
+
}
|
34
|
+
tasksHistoryLifeCycle = this;
|
13
35
|
}
|
14
36
|
startTasks(tasks) {
|
15
37
|
for (let task of tasks) {
|
@@ -36,17 +58,20 @@ class TaskHistoryLifeCycle {
|
|
36
58
|
return;
|
37
59
|
}
|
38
60
|
await this.taskHistory.recordTaskRuns(entries.map(([_, v]) => v));
|
39
|
-
|
61
|
+
this.flakyTasks = await this.taskHistory.getFlakyTasks(entries.map(([hash]) => hash));
|
40
62
|
// Do not directly print output when using the TUI
|
41
63
|
if ((0, is_tui_enabled_1.isTuiEnabled)()) {
|
42
64
|
return;
|
43
65
|
}
|
44
|
-
|
66
|
+
this.printFlakyTasksMessage();
|
67
|
+
}
|
68
|
+
printFlakyTasksMessage() {
|
69
|
+
if (this.flakyTasks.length > 0) {
|
45
70
|
output_1.output.warn({
|
46
|
-
title: `Nx detected ${flakyTasks.length === 1 ? 'a flaky task' : ' flaky tasks'}`,
|
71
|
+
title: `Nx detected ${this.flakyTasks.length === 1 ? 'a flaky task' : ' flaky tasks'}`,
|
47
72
|
bodyLines: [
|
48
73
|
,
|
49
|
-
...flakyTasks.map((hash) => {
|
74
|
+
...this.flakyTasks.map((hash) => {
|
50
75
|
const taskRun = this.taskRuns.get(hash);
|
51
76
|
return ` ${(0, serialize_target_1.serializeTarget)(taskRun.target.project, taskRun.target.target, taskRun.target.configuration)}`;
|
52
77
|
}),
|
@@ -7,6 +7,7 @@ const formatting_utils_1 = require("./formatting-utils");
|
|
7
7
|
const pretty_time_1 = require("./pretty-time");
|
8
8
|
const view_logs_utils_1 = require("./view-logs-utils");
|
9
9
|
const figures = require("figures");
|
10
|
+
const task_history_life_cycle_1 = require("./task-history-life-cycle");
|
10
11
|
const LEFT_PAD = ` `;
|
11
12
|
const SPACER = ` `;
|
12
13
|
const EXTENDED_LEFT_PAD = ` `;
|
@@ -78,6 +79,7 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, args, overrides,
|
|
78
79
|
else {
|
79
80
|
printRunManySummary();
|
80
81
|
}
|
82
|
+
(0, task_history_life_cycle_1.getTasksHistoryLifeCycle)()?.printFlakyTasksMessage();
|
81
83
|
};
|
82
84
|
const printRunOneSummary = () => {
|
83
85
|
let lines = [];
|
@@ -17,6 +17,7 @@ export declare function runCommandForTasks(projectsToRun: ProjectGraphProjectNod
|
|
17
17
|
excludeTaskDependencies: boolean;
|
18
18
|
loadDotEnvFiles: boolean;
|
19
19
|
}): Promise<TaskResults>;
|
20
|
+
export declare function setEnvVarsBasedOnArgs(nxArgs: NxArgs, loadDotEnvFiles: boolean): void;
|
20
21
|
export declare function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nxJson, nxArgs, loadDotEnvFiles, initiatingProject, initiatingTasks, }: {
|
21
22
|
tasks: Task[];
|
22
23
|
projectGraph: ProjectGraph;
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.runCommand = runCommand;
|
4
4
|
exports.runCommandForTasks = runCommandForTasks;
|
5
|
+
exports.setEnvVarsBasedOnArgs = setEnvVarsBasedOnArgs;
|
5
6
|
exports.invokeTasksRunner = invokeTasksRunner;
|
6
7
|
exports.constructLifeCycles = constructLifeCycles;
|
7
8
|
exports.getRunner = getRunner;
|
@@ -14,7 +15,6 @@ const nx_json_1 = require("../config/nx-json");
|
|
14
15
|
const client_1 = require("../daemon/client/client");
|
15
16
|
const create_task_hasher_1 = require("../hasher/create-task-hasher");
|
16
17
|
const hash_task_1 = require("../hasher/hash-task");
|
17
|
-
const native_1 = require("../native");
|
18
18
|
const tasks_execution_hooks_1 = require("../project-graph/plugins/tasks-execution-hooks");
|
19
19
|
const project_graph_1 = require("../project-graph/project-graph");
|
20
20
|
const fileutils_1 = require("../utils/fileutils");
|
@@ -34,7 +34,6 @@ const static_run_many_terminal_output_life_cycle_1 = require("./life-cycles/stat
|
|
34
34
|
const static_run_one_terminal_output_life_cycle_1 = require("./life-cycles/static-run-one-terminal-output-life-cycle");
|
35
35
|
const store_run_information_life_cycle_1 = require("./life-cycles/store-run-information-life-cycle");
|
36
36
|
const task_history_life_cycle_1 = require("./life-cycles/task-history-life-cycle");
|
37
|
-
const task_history_life_cycle_old_1 = require("./life-cycles/task-history-life-cycle-old");
|
38
37
|
const task_profiling_life_cycle_1 = require("./life-cycles/task-profiling-life-cycle");
|
39
38
|
const task_results_life_cycle_1 = require("./life-cycles/task-results-life-cycle");
|
40
39
|
const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle");
|
@@ -633,10 +632,9 @@ function constructLifeCycles(lifeCycle) {
|
|
633
632
|
if (process.env.NX_PROFILE) {
|
634
633
|
lifeCycles.push(new task_profiling_life_cycle_1.TaskProfilingLifeCycle(process.env.NX_PROFILE));
|
635
634
|
}
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
: new task_history_life_cycle_old_1.LegacyTaskHistoryLifeCycle());
|
635
|
+
const historyLifeCycle = (0, task_history_life_cycle_1.getTasksHistoryLifeCycle)();
|
636
|
+
if (historyLifeCycle) {
|
637
|
+
lifeCycles.push(historyLifeCycle);
|
640
638
|
}
|
641
639
|
return lifeCycles;
|
642
640
|
}
|
@@ -42,7 +42,8 @@ export declare class TaskOrchestrator {
|
|
42
42
|
[id: string]: TaskStatus;
|
43
43
|
}>;
|
44
44
|
private executeNextBatchOfTasksUsingTaskSchedule;
|
45
|
-
|
45
|
+
processTasks(taskIds: string[]): void;
|
46
|
+
private processTask;
|
46
47
|
private processScheduledBatch;
|
47
48
|
private processAllScheduledTasks;
|
48
49
|
private applyCachedResults;
|
@@ -124,6 +124,14 @@ class TaskOrchestrator {
|
|
124
124
|
// block until some other task completes, then try again
|
125
125
|
return new Promise((res) => this.waitingForTasks.push(res)).then(() => this.executeNextBatchOfTasksUsingTaskSchedule());
|
126
126
|
}
|
127
|
+
processTasks(taskIds) {
|
128
|
+
for (const taskId of taskIds) {
|
129
|
+
// Task is already handled or being handled
|
130
|
+
if (!this.processedTasks.has(taskId)) {
|
131
|
+
this.processedTasks.set(taskId, this.processTask(taskId));
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
127
135
|
// region Processing Scheduled Tasks
|
128
136
|
async processTask(taskId) {
|
129
137
|
const task = this.taskGraph.tasks[taskId];
|
@@ -147,12 +155,7 @@ class TaskOrchestrator {
|
|
147
155
|
for (const batch of scheduledBatches) {
|
148
156
|
this.processedBatches.set(batch, this.processScheduledBatch(batch));
|
149
157
|
}
|
150
|
-
|
151
|
-
// Task is already handled or being handled
|
152
|
-
if (!this.processedTasks.has(taskId)) {
|
153
|
-
this.processedTasks.set(taskId, this.processTask(taskId));
|
154
|
-
}
|
155
|
-
}
|
158
|
+
this.processTasks(scheduledTasks);
|
156
159
|
}
|
157
160
|
// endregion Processing Scheduled Tasks
|
158
161
|
// region Applying Cache
|
@@ -545,6 +548,9 @@ class TaskOrchestrator {
|
|
545
548
|
for (const { taskId, status } of taskResults) {
|
546
549
|
if (this.completedTasks[taskId] === undefined) {
|
547
550
|
this.completedTasks[taskId] = status;
|
551
|
+
if (this.tuiEnabled) {
|
552
|
+
this.options.lifeCycle.setTaskStatus(taskId, (0, native_1.parseTaskStatus)(status));
|
553
|
+
}
|
548
554
|
if (status === 'failure' || status === 'skipped') {
|
549
555
|
if (this.bail) {
|
550
556
|
// mark the execution as bailed which will stop all further execution
|
@@ -294,7 +294,7 @@ function getExecutorNameForTask(task, projectGraph) {
|
|
294
294
|
}
|
295
295
|
function getExecutorForTask(task, projectGraph) {
|
296
296
|
const executor = getExecutorNameForTask(task, projectGraph);
|
297
|
-
const [nodeModule, executorName] =
|
297
|
+
const [nodeModule, executorName] = (0, executor_utils_1.parseExecutor)(executor);
|
298
298
|
return (0, executor_utils_1.getExecutorInformation)(nodeModule, executorName, workspace_root_1.workspaceRoot, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph).projects);
|
299
299
|
}
|
300
300
|
function getCustomHasher(task, projectGraph) {
|
@@ -74,7 +74,7 @@ export declare function readNxMigrateConfig(json: Partial<PackageJson>): NxMigra
|
|
74
74
|
export declare function buildTargetFromScript(script: string, scripts: Record<string, string>, packageManagerCommand: PackageManagerCommands): TargetConfiguration;
|
75
75
|
export declare function getMetadataFromPackageJson(packageJson: PackageJson, isInPackageManagerWorkspaces: boolean): ProjectMetadata;
|
76
76
|
export declare function getTagsFromPackageJson(packageJson: PackageJson): string[];
|
77
|
-
export declare function readTargetsFromPackageJson(packageJson: PackageJson, nxJson: NxJsonConfiguration): Record<string, TargetConfiguration<any>>;
|
77
|
+
export declare function readTargetsFromPackageJson(packageJson: PackageJson, nxJson: NxJsonConfiguration, projectRoot: string, workspaceRoot: string): Record<string, TargetConfiguration<any>>;
|
78
78
|
/**
|
79
79
|
* Uses `require.resolve` to read the package.json for a module.
|
80
80
|
*
|
@@ -83,7 +83,7 @@ function getTagsFromPackageJson(packageJson) {
|
|
83
83
|
}
|
84
84
|
return tags;
|
85
85
|
}
|
86
|
-
function readTargetsFromPackageJson(packageJson, nxJson) {
|
86
|
+
function readTargetsFromPackageJson(packageJson, nxJson, projectRoot, workspaceRoot) {
|
87
87
|
const { scripts, nx, private: isPrivate } = packageJson ?? {};
|
88
88
|
const res = {};
|
89
89
|
const includedScripts = nx?.includedScripts || Object.keys(scripts ?? {});
|
@@ -102,7 +102,9 @@ function readTargetsFromPackageJson(packageJson, nxJson) {
|
|
102
102
|
* Any targetDefaults for the nx-release-publish target set by the user should
|
103
103
|
* be merged with the implicit target.
|
104
104
|
*/
|
105
|
-
if (!isPrivate &&
|
105
|
+
if (!isPrivate &&
|
106
|
+
!res['nx-release-publish'] &&
|
107
|
+
hasNxJsPlugin(projectRoot, workspaceRoot)) {
|
106
108
|
const nxReleasePublishTargetDefaults = nxJson?.targetDefaults?.['nx-release-publish'] ?? {};
|
107
109
|
res['nx-release-publish'] = {
|
108
110
|
executor: '@nx/js:release-publish',
|
@@ -119,6 +121,18 @@ function readTargetsFromPackageJson(packageJson, nxJson) {
|
|
119
121
|
}
|
120
122
|
return res;
|
121
123
|
}
|
124
|
+
function hasNxJsPlugin(projectRoot, workspaceRoot) {
|
125
|
+
try {
|
126
|
+
// nx-ignore-next-line
|
127
|
+
require.resolve('@nx/js', {
|
128
|
+
paths: [projectRoot, ...(0, installation_directory_1.getNxRequirePaths)(workspaceRoot), __dirname],
|
129
|
+
});
|
130
|
+
return true;
|
131
|
+
}
|
132
|
+
catch {
|
133
|
+
return false;
|
134
|
+
}
|
135
|
+
}
|
122
136
|
/**
|
123
137
|
* Uses `require.resolve` to read the package.json for a module.
|
124
138
|
*
|
@@ -1,35 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = moveCacheDirectory;
|
4
|
-
const ignore_1 = require("ignore");
|
5
|
-
function moveCacheDirectory(tree) {
|
6
|
-
// If nx.json doesn't exist the repo can't utilize
|
7
|
-
// caching, so .nx/cache is less relevant. Lerna users
|
8
|
-
// that don't want to fully opt in to Nx at this time
|
9
|
-
// may also be caught off guard by the appearance of
|
10
|
-
// a .nx directory, so we are going to special case
|
11
|
-
// this for the time being.
|
12
|
-
if (tree.exists('lerna.json') && !tree.exists('nx.json')) {
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
updateGitIgnore(tree);
|
16
|
-
if (tree.exists('.prettierignore')) {
|
17
|
-
const ignored = tree.read('.prettierignore', 'utf-8');
|
18
|
-
if (!ignored.includes('.nx/cache')) {
|
19
|
-
tree.write('.prettierignore', [ignored, '/.nx/cache'].join('\n'));
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
function updateGitIgnore(tree) {
|
24
|
-
const gitignore = tree.exists('.gitignore')
|
25
|
-
? tree.read('.gitignore', 'utf-8')
|
26
|
-
: '';
|
27
|
-
const ig = (0, ignore_1.default)();
|
28
|
-
ig.add(gitignore);
|
29
|
-
if (!ig.ignores('.nx/cache')) {
|
30
|
-
const updatedLines = gitignore.length
|
31
|
-
? [gitignore, '.nx/cache']
|
32
|
-
: ['.nx/cache'];
|
33
|
-
tree.write('.gitignore', updatedLines.join('\n'));
|
34
|
-
}
|
35
|
-
}
|
@@ -1,72 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = update;
|
4
|
-
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
5
|
-
const nx_json_1 = require("../../generators/utils/nx-json");
|
6
|
-
const json_1 = require("../../generators/utils/json");
|
7
|
-
const output_1 = require("../../utils/output");
|
8
|
-
const path_1 = require("../../utils/path");
|
9
|
-
async function update(tree) {
|
10
|
-
if (!tree.exists('nx.json')) {
|
11
|
-
return;
|
12
|
-
}
|
13
|
-
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
14
|
-
delete nxJson.cli?.['defaultCollection'];
|
15
|
-
if (nxJson?.cli && Object.keys(nxJson.cli).length < 1) {
|
16
|
-
delete nxJson.cli;
|
17
|
-
}
|
18
|
-
warnNpmScopeHasChanged(tree, nxJson);
|
19
|
-
delete nxJson['npmScope'];
|
20
|
-
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
21
|
-
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
|
22
|
-
}
|
23
|
-
function warnNpmScopeHasChanged(tree, nxJson) {
|
24
|
-
const originalScope = nxJson['npmScope'];
|
25
|
-
// There was no original scope
|
26
|
-
if (!originalScope) {
|
27
|
-
return false;
|
28
|
-
}
|
29
|
-
// package.json does not exist
|
30
|
-
if (!tree.exists('package.json')) {
|
31
|
-
return false;
|
32
|
-
}
|
33
|
-
const newScope = getNpmScopeFromPackageJson(tree);
|
34
|
-
// New and Original scope are the same.
|
35
|
-
if (originalScope === newScope) {
|
36
|
-
return false;
|
37
|
-
}
|
38
|
-
const packageJsonName = (0, json_1.readJson)(tree, 'package.json').name;
|
39
|
-
if (newScope) {
|
40
|
-
output_1.output.warn({
|
41
|
-
title: 'npmScope has been removed from nx.json',
|
42
|
-
bodyLines: [
|
43
|
-
'This will now be read from package.json',
|
44
|
-
`Old value which was in nx.json: ${originalScope}`,
|
45
|
-
`New value from package.json: ${newScope}`,
|
46
|
-
`Typescript path mappings for new libraries will now be generated as such: @${newScope}/new-lib instead of @${originalScope}/new-lib`,
|
47
|
-
`If you would like to change this back, change the name in package.json to ${packageJsonName.replace(newScope, originalScope)}`,
|
48
|
-
],
|
49
|
-
});
|
50
|
-
}
|
51
|
-
else {
|
52
|
-
// There is no scope in package.json
|
53
|
-
output_1.output.warn({
|
54
|
-
title: 'npmScope has been removed from nx.json',
|
55
|
-
bodyLines: [
|
56
|
-
'This will now be read from package.json',
|
57
|
-
`Old value which was in nx.json: ${originalScope}`,
|
58
|
-
`New value from package.json: null`,
|
59
|
-
`Typescript path mappings for new libraries will now be generated as such: new-lib instead of @${originalScope}/new-lib`,
|
60
|
-
`If you would like to change this back, change the name in package.json to ${(0, path_1.joinPathFragments)(`@${originalScope}`, packageJsonName)}`,
|
61
|
-
],
|
62
|
-
});
|
63
|
-
}
|
64
|
-
}
|
65
|
-
function getNpmScopeFromPackageJson(tree) {
|
66
|
-
const { name } = tree.exists('package.json')
|
67
|
-
? (0, json_1.readJson)(tree, 'package.json')
|
68
|
-
: { name: null };
|
69
|
-
if (name?.startsWith('@')) {
|
70
|
-
return name.split('/')[0].substring(1);
|
71
|
-
}
|
72
|
-
}
|