Comparing version 0.0.0-pr-26898-984dfaf to 0.0.0-pr-26898-bf1fe0e
{ | ||
"name": "nx", | ||
"version": "0.0.0-pr-26898-984dfaf", | ||
"version": "0.0.0-pr-26898-bf1fe0e", | ||
"private": false, | ||
@@ -74,3 +74,3 @@ "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.", | ||
"ora": "5.3.0", | ||
"@nrwl/tao": "0.0.0-pr-26898-984dfaf" | ||
"@nrwl/tao": "0.0.0-pr-26898-bf1fe0e" | ||
}, | ||
@@ -90,12 +90,12 @@ "peerDependencies": { | ||
"optionalDependencies": { | ||
"@nx/nx-darwin-x64": "0.0.0-pr-26898-984dfaf", | ||
"@nx/nx-darwin-arm64": "0.0.0-pr-26898-984dfaf", | ||
"@nx/nx-linux-x64-gnu": "0.0.0-pr-26898-984dfaf", | ||
"@nx/nx-linux-x64-musl": "0.0.0-pr-26898-984dfaf", | ||
"@nx/nx-win32-x64-msvc": "0.0.0-pr-26898-984dfaf", | ||
"@nx/nx-linux-arm64-gnu": "0.0.0-pr-26898-984dfaf", | ||
"@nx/nx-linux-arm64-musl": "0.0.0-pr-26898-984dfaf", | ||
"@nx/nx-linux-arm-gnueabihf": "0.0.0-pr-26898-984dfaf", | ||
"@nx/nx-win32-arm64-msvc": "0.0.0-pr-26898-984dfaf", | ||
"@nx/nx-freebsd-x64": "0.0.0-pr-26898-984dfaf" | ||
"@nx/nx-darwin-x64": "0.0.0-pr-26898-bf1fe0e", | ||
"@nx/nx-darwin-arm64": "0.0.0-pr-26898-bf1fe0e", | ||
"@nx/nx-linux-x64-gnu": "0.0.0-pr-26898-bf1fe0e", | ||
"@nx/nx-linux-x64-musl": "0.0.0-pr-26898-bf1fe0e", | ||
"@nx/nx-win32-x64-msvc": "0.0.0-pr-26898-bf1fe0e", | ||
"@nx/nx-linux-arm64-gnu": "0.0.0-pr-26898-bf1fe0e", | ||
"@nx/nx-linux-arm64-musl": "0.0.0-pr-26898-bf1fe0e", | ||
"@nx/nx-linux-arm-gnueabihf": "0.0.0-pr-26898-bf1fe0e", | ||
"@nx/nx-win32-arm64-msvc": "0.0.0-pr-26898-bf1fe0e", | ||
"@nx/nx-freebsd-x64": "0.0.0-pr-26898-bf1fe0e" | ||
}, | ||
@@ -102,0 +102,0 @@ "nx-migrations": { |
@@ -83,3 +83,2 @@ "use strict"; | ||
} | ||
(0, task_graph_utils_1.validateAtomizedTasks)(taskGraph, projectGraph); | ||
return taskGraph; | ||
@@ -86,0 +85,0 @@ } |
import { ProjectGraph } from '../config/project-graph'; | ||
import { TaskGraph } from '../config/task-graph'; | ||
import { Task, TaskGraph } from '../config/task-graph'; | ||
export declare function findCycle(graph: { | ||
@@ -10,2 +10,7 @@ dependencies: Record<string, string[]>; | ||
}): void; | ||
export declare function validateAtomizedTasks(taskGraph: TaskGraph, projectGraph: ProjectGraph): void; | ||
export declare function getAtomizedRootTask(task: Task, taskGraph: TaskGraph, projectGraph: ProjectGraph): { | ||
project: string; | ||
target: string; | ||
configuration?: string; | ||
} | undefined; | ||
export declare function getAtomizerError(atomizedRootTaskId: string, nonAtomizedTask: string): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateAtomizedTasks = exports.makeAcyclic = exports.findCycle = void 0; | ||
const path_1 = require("path"); | ||
const output_1 = require("../utils/output"); | ||
const fs_1 = require("fs"); | ||
const fs_extra_1 = require("fs-extra"); | ||
const workspace_root_1 = require("../utils/workspace-root"); | ||
exports.getAtomizerError = exports.getAtomizedRootTask = exports.makeAcyclic = exports.findCycle = void 0; | ||
const configuration_1 = require("../config/configuration"); | ||
const nx_cloud_utils_1 = require("../utils/nx-cloud-utils"); | ||
const configuration_1 = require("../config/configuration"); | ||
const serialize_target_1 = require("../utils/serialize-target"); | ||
function _findCycle(graph, id, visited, path) { | ||
@@ -63,52 +59,39 @@ if (visited[id]) | ||
exports.makeAcyclic = makeAcyclic; | ||
function validateAtomizedTasks(taskGraph, projectGraph) { | ||
if (process.env['NX_SKIP_ATOMIZER_VALIDATION']) { | ||
return; | ||
function getAtomizedRootTask(task, taskGraph, projectGraph) { | ||
const project = projectGraph.nodes[task.target.project]?.data; | ||
const target = project.targets[task.target.target]; | ||
// default case, e2e-ci targets should fail in default task runner | ||
if (target.metadata?.nonAtomizedTarget !== undefined) { | ||
return task.target; | ||
} | ||
const getNonAtomizedTargetForTask = (task) => projectGraph.nodes[task.target.project]?.data?.targets?.[task.target.target] | ||
?.metadata?.nonAtomizedTarget; | ||
const tasksWithAtomizer = Object.values(taskGraph.tasks).filter((task) => getNonAtomizedTargetForTask(task) !== undefined); | ||
if (tasksWithAtomizer.length > 0 && !isInDTE()) { | ||
const usingNxCloud = (0, nx_cloud_utils_1.isNxCloudUsed)((0, configuration_1.readNxJson)()); | ||
const nonAtomizedTasks = tasksWithAtomizer | ||
.map((t) => getNonAtomizedTargetForTask(t)) | ||
.filter((item, index, arr) => arr.indexOf(item) === index); | ||
const moreInfoLines = [ | ||
`Please enable ${usingNxCloud ? 'distribution with Nx Agents' : 'Nx Cloud'} or use the slower ${nonAtomizedTasks.join('/')} task${nonAtomizedTasks.length > 1 ? 's' : ''}.`, | ||
'Learn more at https://nx.dev/ci/features/split-e2e-tasks#use-atomizer-only-with-nx-cloud-distribution', | ||
]; | ||
if (tasksWithAtomizer.length === 1) { | ||
output_1.output.error({ | ||
title: `The ${tasksWithAtomizer[0].id} task uses the atomizer and should only be run with ${usingNxCloud ? 'distribution' : 'Nx Cloud'}.`, | ||
bodyLines: [...moreInfoLines], | ||
}); | ||
const targetGroups = project.metadata?.targetGroups; | ||
if (!targetGroups) { | ||
return undefined; | ||
} | ||
// checking target groups to see if the target is part of at atomized group | ||
for (const group in targetGroups) { | ||
if (targetGroups[group].includes(task.target.target)) { | ||
const rootTarget = targetGroups[group]?.find((t) => task.target.target.startsWith(`${t}--`)); | ||
// we want to fail individual atomized targets only if the root target is also being run | ||
const rootTaskId = (0, serialize_target_1.serializeTarget)(task.target.project, rootTarget, task.target.configuration); | ||
if (rootTarget && | ||
project.targets[rootTarget].metadata?.nonAtomizedTarget !== undefined && | ||
!!taskGraph.tasks[rootTaskId]) { | ||
return taskGraph.tasks[rootTaskId].target; | ||
} | ||
} | ||
else { | ||
output_1.output.error({ | ||
title: `The following tasks use the atomizer and should only be run with ${usingNxCloud ? 'distribution' : 'Nx Cloud'}:`, | ||
bodyLines: [ | ||
`${tasksWithAtomizer.map((task) => task.id).join(', ')}`, | ||
...moreInfoLines, | ||
], | ||
}); | ||
} | ||
process.exit(1); | ||
} | ||
return undefined; | ||
} | ||
exports.validateAtomizedTasks = validateAtomizedTasks; | ||
function isInDTE() { | ||
if (process.env['NX_CLOUD_DISTRIBUTED_EXECUTION_ID'] || | ||
process.env['NX_AGENT_NAME']) { | ||
return true; | ||
} | ||
// checks for DTE marker file - needed so we can check for DTE on the main nx job | ||
const nxCacheDirectory = process.env.NX_CACHE_DIRECTORY | ||
? [process.env['NX_CACHE_DIRECTORY']] | ||
: ['node_modules', '.cache', 'nx']; | ||
const dir = (0, path_1.join)(workspace_root_1.workspaceRoot, ...nxCacheDirectory); | ||
const dteMarker = (0, path_1.join)(dir, 'NX_CLOUD_DISTRIBUTED_EXECUTION'); | ||
if ((0, fs_1.existsSync)(dteMarker) && (0, fs_extra_1.readFileSync)(dteMarker, 'utf-8') === 'true') { | ||
return true; | ||
} | ||
return false; | ||
exports.getAtomizedRootTask = getAtomizedRootTask; | ||
function getAtomizerError(atomizedRootTaskId, nonAtomizedTask) { | ||
const usingNxCloud = (0, nx_cloud_utils_1.isNxCloudUsed)((0, configuration_1.readNxJson)()); | ||
const outputLines = [ | ||
`The ${atomizedRootTaskId} task should only be run with ${usingNxCloud ? 'distribution' : 'Nx Cloud'}.`, | ||
'', | ||
`Please enable ${usingNxCloud ? 'distribution with Nx Agents' : 'Nx Cloud'} or use the slower ${nonAtomizedTask} task.`, | ||
'Learn more at https://nx.dev/ci/features/split-e2e-tasks#nx-cloud-is-required-to-run-atomized-tasks', | ||
]; | ||
return outputLines.join('\n'); | ||
} | ||
exports.getAtomizerError = getAtomizerError; |
@@ -18,2 +18,4 @@ "use strict"; | ||
const params_1 = require("../utils/params"); | ||
const task_graph_utils_1 = require("./task-graph-utils"); | ||
const serialize_target_1 = require("../utils/serialize-target"); | ||
class TaskOrchestrator { | ||
@@ -215,3 +217,28 @@ // endregion internal state | ||
const targetConfiguration = (0, utils_1.getTargetConfigurationForTask)(task, this.projectGraph); | ||
if (process.env.NX_RUN_COMMANDS_DIRECTLY !== 'false' && | ||
const atomizedRootTask = (0, task_graph_utils_1.getAtomizedRootTask)(task, this.taskGraph, this.projectGraph); | ||
// disallow running atomized tasks outside of DTE | ||
if (atomizedRootTask && | ||
!process.env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID && | ||
!env.NX_CLOUD_DISTRIBUTED_EXECUTION_ID && | ||
!process.env.NX_AGENT_NAME && | ||
!env.NX_AGENT_NAME) { | ||
let terminalOutput = (0, task_graph_utils_1.getAtomizerError)((0, serialize_target_1.serializeTarget)(atomizedRootTask.project, atomizedRootTask.target, atomizedRootTask.configuration), this.projectGraph.nodes[atomizedRootTask.project]?.data.targets[atomizedRootTask.target]?.metadata.nonAtomizedTarget); | ||
console.error(terminalOutput); | ||
terminalOutput += `\n process env: ${JSON.stringify(process.env)} \n task env: ${JSON.stringify(env)} \n task graph: ${JSON.stringify(this.taskGraph)} \n project graph: ${JSON.stringify(this.projectGraph)}`; | ||
(0, fs_1.writeFileSync)(temporaryOutputPath, terminalOutput); | ||
results.push({ | ||
task, | ||
status: 'failure', | ||
terminalOutput: terminalOutput, | ||
}); | ||
} | ||
else if (targetConfiguration.executor === 'nx:noop') { | ||
(0, fs_1.writeFileSync)(temporaryOutputPath, ''); | ||
results.push({ | ||
task, | ||
status: 'success', | ||
terminalOutput: '', | ||
}); | ||
} | ||
else if (process.env.NX_RUN_COMMANDS_DIRECTLY !== 'false' && | ||
targetConfiguration.executor === 'nx:run-commands' && | ||
@@ -269,10 +296,2 @@ !shouldPrefix) { | ||
} | ||
else if (targetConfiguration.executor === 'nx:noop') { | ||
(0, fs_1.writeFileSync)(temporaryOutputPath, ''); | ||
results.push({ | ||
task, | ||
status: 'success', | ||
terminalOutput: '', | ||
}); | ||
} | ||
else { | ||
@@ -279,0 +298,0 @@ // cache prep |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
7186250
49219
390
+ Added@nrwl/tao@0.0.0-pr-26898-bf1fe0e(transitive)
+ Added@nx/nx-darwin-arm64@0.0.0-pr-26898-bf1fe0e(transitive)
+ Added@nx/nx-darwin-x64@0.0.0-pr-26898-bf1fe0e(transitive)
+ Added@nx/nx-freebsd-x64@0.0.0-pr-26898-bf1fe0e(transitive)
+ Added@nx/nx-linux-arm-gnueabihf@0.0.0-pr-26898-bf1fe0e(transitive)
+ Added@nx/nx-linux-arm64-gnu@0.0.0-pr-26898-bf1fe0e(transitive)
+ Added@nx/nx-linux-arm64-musl@0.0.0-pr-26898-bf1fe0e(transitive)
+ Added@nx/nx-linux-x64-gnu@0.0.0-pr-26898-bf1fe0e(transitive)
+ Added@nx/nx-linux-x64-musl@0.0.0-pr-26898-bf1fe0e(transitive)
+ Added@nx/nx-win32-arm64-msvc@0.0.0-pr-26898-bf1fe0e(transitive)
+ Added@nx/nx-win32-x64-msvc@0.0.0-pr-26898-bf1fe0e(transitive)
- Removed@nrwl/tao@0.0.0-pr-26898-984dfaf(transitive)
- Removed@nx/nx-darwin-arm64@0.0.0-pr-26898-984dfaf(transitive)
- Removed@nx/nx-darwin-x64@0.0.0-pr-26898-984dfaf(transitive)
- Removed@nx/nx-freebsd-x64@0.0.0-pr-26898-984dfaf(transitive)
- Removed@nx/nx-linux-arm-gnueabihf@0.0.0-pr-26898-984dfaf(transitive)
- Removed@nx/nx-linux-arm64-gnu@0.0.0-pr-26898-984dfaf(transitive)
- Removed@nx/nx-linux-arm64-musl@0.0.0-pr-26898-984dfaf(transitive)
- Removed@nx/nx-linux-x64-gnu@0.0.0-pr-26898-984dfaf(transitive)
- Removed@nx/nx-linux-x64-musl@0.0.0-pr-26898-984dfaf(transitive)
- Removed@nx/nx-win32-arm64-msvc@0.0.0-pr-26898-984dfaf(transitive)
- Removed@nx/nx-win32-x64-msvc@0.0.0-pr-26898-984dfaf(transitive)