-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rush] Add support for common/temp/.rush-override #5000
Conversation
I've just learned about https://rushjs.io/pages/contributing/#testing-rush-builds (right on time haha!) But still, IMHO .rush-override could make it much easier (for example I tend to put a lot of commands in VSCode tasks.json, testing them against custom rush installation would require replacing all occurrences of rush and rushx). |
@dmichon-msft / @D4N14L have a potential concern about dropping this file in |
After using it for a while, I do too - turns out Overall, I don't think it's going to be widely used that much (most probably only by contributors) to put it in already .gitignored place. So perhaps storing it right next to rush.json should be fine, what do you think? |
Yeah I think putting it at the repo root is a better approach. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just using an environment variable to override the rush installation/@microsoft/rush-lib
package location?
const overrideVersion: string = overridePackageJson.version; | ||
|
||
const lines: string[] = []; | ||
lines.push( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a printInBox
utility function in @rushstack/terminal
.
path.dirname(configuration.rushJsonFilename), | ||
rushLib.RushConstants.commonFolderName, | ||
rushLib.RushConstants.rushTempFolderName, | ||
'.rush-override' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stick this in a constant.
|
||
if (configuration) { | ||
const rushOverrideFilePath: string = path.join( | ||
path.dirname(configuration.rushJsonFilename), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path.dirname(configuration.rushJsonFilename), | |
configuration.rushJsonFolder, |
const rushOverrideFilePath: string = path.join( | ||
path.dirname(configuration.rushJsonFilename), | ||
rushLib.RushConstants.commonFolderName, | ||
rushLib.RushConstants.rushTempFolderName, | ||
'.rush-override' | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const rushOverrideFilePath: string = path.join( | |
path.dirname(configuration.rushJsonFilename), | |
rushLib.RushConstants.commonFolderName, | |
rushLib.RushConstants.rushTempFolderName, | |
'.rush-override' | |
); | |
const rushOverrideFilePath: string = `${configuration.rushJsonFolder}/.rush-override`; |
As per discussion.
Also stick .rush-override
in a RushConstants.
'.rush-override' | ||
); | ||
|
||
if (fs.existsSync(rushOverrideFilePath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use FileSystem
from node-core-library
, and do a try-catch on reading the file and gracefully handle it not existing. See FileSystem.isNotExistError
); | ||
|
||
if (fs.existsSync(rushOverrideFilePath)) { | ||
const overridePath: string = fs.readFileSync(rushOverrideFilePath, 'utf8').trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use FileSystem.readFile
const overridePackageJson: IPackageJson | undefined = PackageJsonLookup.instance.tryLoadPackageJsonFor(overridePath); | ||
|
||
if (overridePackageJson === undefined) { | ||
console.log(Colorize.red(`Cannot use common/temp/.rush-override file as it doesn't point to valid Rush package`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use constants here.
public get rushJsonFilename(): string { | ||
return this._rushJsonFilename; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.
Summary
While contributing to Rush, I've discovered that there's no easy way to test it with other repos on my PC (I was manually replacing installation in AppData/.rush directory) so I've decided to create this PR that hopefully makes it easier.
Details
PR introduces support for common/temp/.rush-override file that can contain path to the custom rush installation. This way, contributors can override the Rush installation used by the repository and test any changes that are being made to Rush.
.rush-override shouldn't be ever tracked by git so I've decided to use common/temp directory as it should be added to .gitignore in every Rush monorepo.
If common/temp/.rush-override is present, user is presented with warning similar to the one that is displayed when using RUSH_PREVIEW_VERSION environment variable.
(one potential thing I would like to include here is for a warning to display the path to custom Rush installation)
If common/temp/.rush-override points to invalid Rush installation (the only check for now is verifying that package.json exists), command terminates with following error:
How it was tested
I've created common/temp/.rush-override that points to custom Rush installation and executed
node apps\rush\bin\rush build --help
- seems to be working.Impacted documentation