Skip to content

Commit 39824cb

Browse files
committed
[heft] Create parent temp folder for phase
1 parent 11e3967 commit 39824cb

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

apps/heft/src/operations/runners/PhaseOperationRunner.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
import { deleteFilesAsync, type IDeleteOperation } from '../../plugins/DeleteFilesPlugin';
1111
import type { HeftPhase } from '../../pluginFramework/HeftPhase';
1212
import type { HeftPhaseSession } from '../../pluginFramework/HeftPhaseSession';
13-
import type { HeftTaskSession } from '../../pluginFramework/HeftTaskSession';
1413
import type { InternalHeftSession } from '../../pluginFramework/InternalHeftSession';
1514

1615
export interface IPhaseOperationRunnerOptions {
@@ -53,10 +52,14 @@ export class PhaseOperationRunner implements IOperationRunner {
5352
const deleteOperations: IDeleteOperation[] = Array.from(phase.cleanFiles);
5453

5554
// Delete all temp folders for tasks by default
56-
for (const task of phase.tasks) {
57-
const taskSession: HeftTaskSession = phaseSession.getSessionForTask(task);
58-
deleteOperations.push({ sourcePath: taskSession.tempFolderPath });
59-
}
55+
const tempFolderGlobs: string[] = [
56+
/* heft@>0.60.0 */ phase.phaseName,
57+
/* heft@<=0.60.0 */ `${phase.phaseName}.*`
58+
];
59+
deleteOperations.push({
60+
sourcePath: internalHeftSession.heftConfiguration.tempFolderPath,
61+
includeGlobs: tempFolderGlobs
62+
});
6063

6164
// Delete the files if any were specified
6265
if (deleteOperations.length) {

apps/heft/src/pluginFramework/HeftTaskSession.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,14 @@ export class HeftTaskSession implements IHeftTaskSession {
287287
};
288288

289289
// Guaranteed to be unique since phases are uniquely named, tasks are uniquely named within
290-
// phases, and neither can have '.' in their names. We will also use the phase name and
290+
// phases, and neither can have '/' in their names. We will also use the phase name and
291291
// task name as the folder name (instead of the plugin name) since we want to enable re-use
292292
// of plugins in multiple phases and tasks while maintaining unique temp/cache folders for
293293
// each task.
294-
const uniqueTaskFolderName: string = `${phase.phaseName}.${task.taskName}`;
294+
// Having a parent folder for the phase simplifies interaction with the Rush build cache.
295+
const uniqueTaskFolderName: string = `${phase.phaseName}/${task.taskName}`;
295296

296-
// <projectFolder>/temp/<phaseName>.<taskName>
297+
// <projectFolder>/temp/<phaseName>/<taskName>
297298
this.tempFolderPath = path.join(tempFolder, uniqueTaskFolderName);
298299

299300
this._options = options;

build-tests/heft-parameter-plugin-test/src/test/customParameter.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { FileSystem } from '@rushstack/node-core-library';
44
describe('CustomParameterOutput', () => {
55
it('parses command line arguments and prints output.', async () => {
66
const outputContent: string = await FileSystem.readFileAsync(
7-
`${dirname(dirname(__dirname))}/temp/test.write-parameters/custom_output.txt`
7+
`${dirname(dirname(__dirname))}/temp/test/write-parameters/custom_output.txt`
88
);
99
expect(outputContent).toBe(
1010
'customIntegerParameter: 5\n' +
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/heft",
5+
"comment": "(BREAKING CHANGE): Rename task temp folder from \"<phase>.<task>\" to \"<phase>/<task>\" to simplify caching phase outputs.",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@rushstack/heft"
10+
}

0 commit comments

Comments
 (0)