Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/nx/src/command-line/release/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ProjectGraph,
ProjectGraphProjectNode,
} from '../../config/project-graph';
import { hashArray } from '../../native';
import { createProjectFileMapUsingProjectGraph } from '../../project-graph/file-map-utils';
import {
runPostTasksExecution,
Expand Down Expand Up @@ -272,11 +273,14 @@ async function runPublishOnProjects(
].join('\n')}\n`
);
}
const taskId = hashArray([...process.argv, Date.now().toString()]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please call this a tasksExecutionId or executionId... or even just id. Just definitely not task.id

await runPreTasksExecution({
taskId,
workspaceRoot,
nxJsonConfiguration: nxJson,
argv: process.argv,
});
const startTime = Date.now();

/**
* Run the relevant nx-release-publish executor on each of the selected projects.
Expand All @@ -299,6 +303,7 @@ async function runPublishOnProjects(
{},
extraOptions
);
const endTime = Date.now();

const publishProjectsResult: PublishProjectsResult = {};
for (const taskData of Object.values(taskResults)) {
Expand All @@ -307,10 +312,13 @@ async function runPublishOnProjects(
};
}
await runPostTasksExecution({
taskId,
taskResults,
workspaceRoot,
nxJsonConfiguration: nxJson,
argv: process.argv,
startTime,
endTime,
});

return publishProjectsResult;
Expand Down
3 changes: 1 addition & 2 deletions packages/nx/src/project-graph/plugins/loaded-nx-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ProjectGraph } from '../../config/project-graph';
import { readNxJson, type PluginConfiguration } from '../../config/nx-json';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are unused

import { type PluginConfiguration } from '../../config/nx-json';
import {
AggregateCreateNodesError,
isAggregateCreateNodesError,
Expand All @@ -15,7 +15,6 @@ import type {
PreTasksExecutionContext,
ProjectsMetadata,
} from './public-api';
import { createNodesFromFiles } from './utils';
import { isIsolationEnabled } from './isolation/enabled';
import { isDaemonEnabled } from '../../daemon/client/client';

Expand Down
4 changes: 4 additions & 0 deletions packages/nx/src/project-graph/plugins/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,19 @@ export type NxPluginV2<TOptions = unknown> = {
};

export type PreTasksExecutionContext = {
readonly taskId: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make this just id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to just id.

readonly workspaceRoot: string;
readonly nxJsonConfiguration: NxJsonConfiguration;
readonly argv: string[];
};
export type PostTasksExecutionContext = {
readonly taskId: string;
readonly workspaceRoot: string;
readonly nxJsonConfiguration: NxJsonConfiguration;
readonly taskResults: TaskResults;
readonly argv: string[];
readonly startTime: number;
readonly endTime: number;
};

export type PreTasksExecution<TOptions = unknown> = (
Expand Down
8 changes: 0 additions & 8 deletions packages/nx/src/tasks-runner/life-cycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ export interface TaskMetadata {
groupId: number;
}

interface RustRunningTask extends RunningTask {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was unused

getResults(): Promise<{ code: number; terminalOutput: string }>;

onExit(cb: (code: number, terminalOutput: string) => void): void;

kill(signal?: NodeJS.Signals): Promise<void> | void;
}

export interface LifeCycle {
startCommand?(parallel?: number): void | Promise<void>;

Expand Down
12 changes: 9 additions & 3 deletions packages/nx/src/tasks-runner/run-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
getTaskDetails,
hashTasksThatDoNotDependOnOutputsOfOtherTasks,
} from '../hasher/hash-task';
import { logDebug, RunMode } from '../native';
import { hashArray, logDebug, RunMode } from '../native';
import {
runPostTasksExecution,
runPreTasksExecution,
Expand Down Expand Up @@ -68,6 +68,7 @@ import { TasksRunner, TaskStatus } from './tasks-runner';
import { shouldStreamOutput } from './utils';
import { signalToCode } from '../utils/exit-codes';
import chalk = require('chalk');
import { randomUUID } from 'node:crypto';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look to be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, AI autocomplete leftover. Let me kick that out.


const originalStdoutWrite = process.stdout.write.bind(process.stdout);
const originalStderrWrite = process.stderr.write.bind(process.stderr);
Expand Down Expand Up @@ -133,8 +134,6 @@ async function getTerminalOutputLifeCycle(
const isRunOne = initiatingProject != null;

const pinnedTasks: string[] = [];
const taskText = tasks.length === 1 ? 'task' : 'tasks';
const projectText = projectNames.length === 1 ? 'project' : 'projects';
let titleText = '';

if (isRunOne) {
Expand Down Expand Up @@ -439,12 +438,15 @@ export async function runCommand(
const status = await handleErrors(
process.env.NX_VERBOSE_LOGGING === 'true',
async () => {
const taskId = hashArray([...process.argv, Date.now().toString()]);
await runPreTasksExecution({
taskId,
workspaceRoot,
nxJsonConfiguration: nxJson,
argv: process.argv,
});

const startTime = Date.now();
const { taskResults, completed } = await runCommandForTasks(
projectsToRun,
currentProjectGraph,
Expand All @@ -461,6 +463,7 @@ export async function runCommand(
extraTargetDependencies,
extraOptions
);
const endTime = Date.now();

const exitCode = !completed
? signalToCode('SIGINT')
Expand All @@ -472,10 +475,13 @@ export async function runCommand(
: 0;

await runPostTasksExecution({
taskId,
taskResults,
workspaceRoot,
nxJsonConfiguration: nxJson,
argv: process.argv,
startTime,
endTime,
});

return exitCode;
Expand Down
Loading