X Tutup
Skip to content

Commit c53b1e7

Browse files
committed
Move .rush/package-deps.<command>.json files to .rush/temp/package-deps_<command>.json
1 parent 650066b commit c53b1e7

File tree

8 files changed

+41
-23
lines changed

8 files changed

+41
-23
lines changed

apps/rush-lib/assets/rush-init/[dot]gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ temp
6060

6161
# Rush files
6262
common/temp/**
63-
package-deps.json
63+
.rush/temp/**

apps/rush-lib/src/api/RushConfigurationProject.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import { RushConfiguration } from '../api/RushConfiguration';
1414
import { VersionPolicy, LockStepVersionPolicy } from './VersionPolicy';
1515
import { PackageJsonEditor } from './PackageJsonEditor';
16+
import { RushConstants } from '../logic/RushConstants';
1617

1718
/**
1819
* This represents the JSON data object for a project entry in the rush.json configuration file.
@@ -36,6 +37,7 @@ export class RushConfigurationProject {
3637
private _packageName: string;
3738
private _projectFolder: string;
3839
private _projectRelativeFolder: string;
40+
private _projectRushTempFolder: string;
3941
private _reviewCategory: string;
4042
private _packageJson: IPackageJson;
4143
private _packageJsonEditor: PackageJsonEditor;
@@ -50,9 +52,11 @@ export class RushConfigurationProject {
5052
private readonly _rushConfiguration: RushConfiguration;
5153

5254
/** @internal */
53-
constructor(projectJson: IRushConfigurationProjectJson,
54-
rushConfiguration: RushConfiguration,
55-
tempProjectName: string) {
55+
constructor(
56+
projectJson: IRushConfigurationProjectJson,
57+
rushConfiguration: RushConfiguration,
58+
tempProjectName: string
59+
) {
5660
this._rushConfiguration = rushConfiguration;
5761
this._packageName = projectJson.packageName;
5862
this._projectRelativeFolder = projectJson.projectFolder;
@@ -76,6 +80,12 @@ export class RushConfigurationProject {
7680
throw new Error(`Project folder not found: ${projectJson.projectFolder}`);
7781
}
7882

83+
this._projectRushTempFolder = path.join(
84+
this._projectFolder,
85+
RushConstants.projectRushFolderName,
86+
RushConstants.rushTempFolderName
87+
);
88+
7989
// Are we using a package review file?
8090
if (rushConfiguration.approvedPackagesPolicy.enabled) {
8191
// If so, then every project needs to have a reviewCategory that was defined
@@ -148,6 +158,15 @@ export class RushConfigurationProject {
148158
return this._projectRelativeFolder;
149159
}
150160

161+
/**
162+
* The project-specific Rush temp folder. This folder is used to store Rush-specific temporary files.
163+
*
164+
* Example: `C:\MyRepo\libraries\my-project\.rush\temp`
165+
*/
166+
public get projectRushTempFolder(): string {
167+
return this._projectRushTempFolder;
168+
}
169+
151170
/**
152171
* The review category name, or undefined if no category was assigned.
153172
* This name must be one of the valid choices listed in RushConfiguration.reviewCategories.

apps/rush-lib/src/cli/RushCommandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export class RushCommandLineParser extends CommandLineParser {
207207
+ ' source files that are tracked by Git and whose path is under the project folder. (For more details'
208208
+ ' about this algorithm, see the documentation for the "package-deps-hash" NPM package.) The incremental'
209209
+ ' build state is tracked in a folder called ".rush" which should NOT be added to Git. The build command is'
210-
+ ' tracked by the "arguments" field in the "package-deps.build.json" file contained therein; a full'
210+
+ ' tracked by the "arguments" field in the "package-deps_build.json" file contained therein; a full'
211211
+ ' rebuild is forced whenever the command has changed (e.g. "--production" or not).',
212212
parser: this,
213213
commandLineConfiguration: commandLineConfiguration,

apps/rush-lib/src/cli/test/__snapshots__/CommandLineHelp.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ whose path is under the project folder. (For more details about this
107107
algorithm, see the documentation for the \\"package-deps-hash\\" NPM package.)
108108
The incremental build state is tracked in a folder called \\".rush\\" which
109109
should NOT be added to Git. The build command is tracked by the \\"arguments\\"
110-
field in the \\"package-deps.build.json\\" file contained therein; a full rebuild
110+
field in the \\"package-deps_build.json\\" file contained therein; a full rebuild
111111
is forced whenever the command has changed (e.g. \\"--production\\" or not).
112112
113113
Optional arguments:

apps/rush-lib/src/logic/PackageChangeAnalyzer.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class PackageChangeAnalyzer {
7272
const excludes: string[] = commandLineConfiguration.commands.reduce(
7373
(filenames: string[], command: CommandJson) => {
7474
if (command.commandKind === 'bulk') {
75-
filenames.push(`package-deps.${command.name}.json`);
75+
filenames.push(`package-deps_${command.name}.json`);
7676
}
7777

7878
return filenames;
@@ -116,10 +116,10 @@ export class PackageChangeAnalyzer {
116116
*
117117
* Temporarily revert below code in favor of replacing this solution with something more
118118
* flexible. Idea is essentially that we should have gulp-core-build (or other build tool)
119-
* create the package-deps.json. The build tool would default to using the 'simple'
119+
* create the package-deps_<command>.json. The build tool would default to using the 'simple'
120120
* algorithm (e.g. only files that are in a project folder are associated with the project), however it would
121121
* also provide a hook which would allow certain tasks to modify the package-deps-hash before being written.
122-
* At the end of the build, a we would create a package-deps.json file like so:
122+
* At the end of the build, a we would create a package-deps_<command>.json file like so:
123123
*
124124
* {
125125
* commandLine: ["--production"],
@@ -141,7 +141,7 @@ export class PackageChangeAnalyzer {
141141
* Notes:
142142
* * We need to store the command line arguments, which is currently done by rush instead of GCB
143143
* * We need to store the hash/text of the a file which describes the state of the node_modules folder
144-
* * The package-deps.json should be a complete list of dependencies, and it should be extremely cheap
144+
* * The package-deps_<command>.json should be a complete list of dependencies, and it should be extremely cheap
145145
* to validate/check the file (even if creating it is more computationally costly).
146146
*/
147147

@@ -157,11 +157,10 @@ export class PackageChangeAnalyzer {
157157
const variant: string | undefined = this._rushConfiguration.currentInstalledVariant;
158158

159159
// Add the shrinkwrap file to every project's dependencies
160-
161-
const shrinkwrapFile: string =
162-
path.relative(this._rushConfiguration.rushJsonFolder,
163-
this._rushConfiguration.getCommittedShrinkwrapFilename(variant))
164-
.replace(/\\/g, '/');
160+
const shrinkwrapFile: string = path.relative(
161+
this._rushConfiguration.rushJsonFolder,
162+
this._rushConfiguration.getCommittedShrinkwrapFilename(variant)
163+
).replace(/\\/g, '/');
165164

166165
for (const project of this._rushConfiguration.projects) {
167166
const shrinkwrapHash: string | undefined = noProjectHashes[shrinkwrapFile];

apps/rush-lib/src/logic/RushConstants.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export namespace RushConstants {
4545
export const rushTempNpmScope: string = '@rush-temp';
4646

4747
/**
48-
* The folder name ("temp") under the common folder where temporary files will be stored.
48+
* The folder name ("temp") under the common folder, or under the .rush folder in each project's directory where
49+
* temporary files will be stored.
4950
* Example: `C:\MyRepo\common\temp`
5051
*/
5152
export const rushTempFolderName: string = 'temp';
@@ -114,10 +115,10 @@ export namespace RushConstants {
114115
export const commonVersionsFilename: string = 'common-versions.json';
115116

116117
/**
117-
* The name of the folder where package-deps files are stored, which are used
118-
* by commands to determine if a particular project needs to be rebuilt.
118+
* The name of the per-project folder where project-specific Rush files are stored. For example,
119+
* the package-deps files, which are used by commands to determine if a particular project needs to be rebuilt.
119120
*/
120-
export const packageDepsFolderName: string = '.rush';
121+
export const projectRushFolderName: string = '.rush';
121122

122123
/**
123124
* Custom command line configuration file, which is used by rush for implementing

apps/rush-lib/src/logic/taskRunner/ProjectTask.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { IPackageDeps } from '@microsoft/package-deps-hash';
99

1010
import { RushConfiguration } from '../../api/RushConfiguration';
1111
import { RushConfigurationProject } from '../../api/RushConfigurationProject';
12-
import { RushConstants } from '../../logic/RushConstants';
1312
import { Utilities } from '../../utilities/Utilities';
1413
import { TaskStatus } from './TaskStatus';
1514
import { TaskError } from './TaskError';
@@ -94,10 +93,9 @@ export class ProjectTask implements ITaskDefinition {
9493

9594
writer.writeLine(`>>> ${this.name}`);
9695

97-
const packageDepsFilename: string = `package-deps.${this._commandToRun}.json`;
96+
const packageDepsFilename: string = `package-deps_${this._commandToRun}.json`;
9897
const currentDepsPath: string = path.join(
99-
this._rushProject.projectFolder,
100-
RushConstants.packageDepsFolderName,
98+
this._rushProject.projectRushTempFolder,
10199
packageDepsFilename
102100
);
103101

common/reviews/api/rush-lib.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ export class RushConfigurationProject {
315315
readonly packageName: string;
316316
readonly projectFolder: string;
317317
readonly projectRelativeFolder: string;
318+
readonly projectRushTempFolder: string;
318319
readonly reviewCategory: string;
319320
readonly shouldPublish: boolean;
320321
readonly skipRushCheck: boolean;

0 commit comments

Comments
 (0)
X Tutup