-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(core): update API to pre/post tasks execution and for it to run…
… via the daemon
- Loading branch information
1 parent
7060411
commit 50e6965
Showing
23 changed files
with
331 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
docs/generated/devkit/PostRunContext.md → ...rated/devkit/PostTasksExecutionContext.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
docs/generated/devkit/PreRunContext.md → ...erated/devkit/PreTasksExecutionContext.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/nx/src/daemon/message-types/run-tasks-execution-hooks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { | ||
PostTasksExecutionContext, | ||
PreTasksExecutionContext, | ||
} from '../../project-graph/plugins'; | ||
|
||
export const PRE_TASKS_EXECUTION = 'PRE_TASKS_EXECUTION' as const; | ||
export const POST_TASKS_EXECUTION = 'POST_TASKS_EXECUTION' as const; | ||
|
||
export type HandlePreTasksExecutionMessage = { | ||
type: typeof PRE_TASKS_EXECUTION; | ||
context: PreTasksExecutionContext; | ||
}; | ||
export type HandlePostTasksExecutionMessage = { | ||
type: typeof POST_TASKS_EXECUTION; | ||
context: PostTasksExecutionContext; | ||
}; | ||
|
||
export function isHandlePreTasksExecutionMessage( | ||
message: unknown | ||
): message is HandlePreTasksExecutionMessage { | ||
return ( | ||
typeof message === 'object' && | ||
message !== null && | ||
'type' in message && | ||
message['type'] === PRE_TASKS_EXECUTION | ||
); | ||
} | ||
|
||
export function isHandlePostTasksExecutionMessage( | ||
message: unknown | ||
): message is HandlePostTasksExecutionMessage { | ||
return ( | ||
typeof message === 'object' && | ||
message !== null && | ||
'type' in message && | ||
message['type'] === POST_TASKS_EXECUTION | ||
); | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/nx/src/daemon/server/handle-tasks-execution-hooks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import type { | ||
PostTasksExecutionContext, | ||
PreTasksExecutionContext, | ||
} from '../../project-graph/plugins/public-api'; | ||
import { | ||
runPostTasksExecution, | ||
runPreTasksExecution, | ||
} from '../../project-graph/plugins/tasks-execution-hooks'; | ||
|
||
export async function handleRunPreTasksExecution( | ||
context: PreTasksExecutionContext | ||
) { | ||
try { | ||
const envs = await runPreTasksExecution(context); | ||
return { | ||
response: JSON.stringify(envs), | ||
description: 'handleRunPreTasksExecution', | ||
}; | ||
} catch (e) { | ||
return { | ||
error: e, | ||
description: `Error when running preTasksExecution.`, | ||
}; | ||
} | ||
} | ||
export async function handleRunPostTasksExecution( | ||
context: PostTasksExecutionContext | ||
) { | ||
try { | ||
await runPostTasksExecution(context); | ||
return { | ||
response: 'true', | ||
description: 'handleRunPostTasksExecution', | ||
}; | ||
} catch (e) { | ||
return { | ||
error: e, | ||
description: `Error when running postTasksExecution.`, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.