Skip to content

Commit 6e6df73

Browse files
Copilotdmichon-msfticlanton
authored
[rush-lib] Add PathProjectSelectorParser with path: scheme and auto-routing (#5451)
* Initial plan * Add PathProjectSelectorParser implementation with path: scheme Co-authored-by: dmichon-msft <[email protected]> * Address code review feedback and add comprehensive unit tests for selector parsers Co-authored-by: dmichon-msft <[email protected]> * Add tests for VersionPolicyProjectSelectorParser and SubspaceSelectorParser Co-authored-by: dmichon-msft <[email protected]> * Refactor tests into separate files and improve PathProjectSelectorParser testability Co-authored-by: dmichon-msft <[email protected]> * Add change file for PathProjectSelectorParser feature Co-authored-by: dmichon-msft <[email protected]> * Update common/changes/@microsoft/rush/copilot-add-path-project-selector-parser_2025-11-17-22-30.json * Address code review feedback: make workingDirectory required and add comprehensive tests Co-authored-by: iclanton <[email protected]> * Fix Windows path separator issue by normalizing to forward slashes for LookupByPath Co-authored-by: iclanton <[email protected]> * Use consistent cwd from RushCommandLineParser for path resolution Co-authored-by: iclanton <[email protected]> * Auto-route relative and absolute POSIX paths to path: selector Co-authored-by: dmichon-msft <[email protected]> * Use Path.convertToSlashes helper instead of manual path separator conversion Co-authored-by: dmichon-msft <[email protected]> * Rush change. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: dmichon-msft <[email protected]> Co-authored-by: David Michon <[email protected]> Co-authored-by: iclanton <[email protected]> Co-authored-by: Ian Clanton-Thuon <[email protected]>
1 parent 1001da0 commit 6e6df73

18 files changed

+518
-41
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "Added the ability to select projects via path, e.g. `rush build --to path:./my-project` or `rush build --only path:/some/absolute/path`",
5+
"type": "minor",
6+
"packageName": "@microsoft/rush"
7+
}
8+
],
9+
"packageName": "@microsoft/rush",
10+
"email": "[email protected]"
11+
}

libraries/rush-lib/src/api/test/RushConfiguration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe(RushConfiguration.name, () => {
7777
expect(rushConfiguration.projectFolderMinDepth).toEqual(1);
7878
expect(rushConfiguration.hotfixChangeEnabled).toEqual(true);
7979

80-
expect(rushConfiguration.projects).toHaveLength(3);
80+
expect(rushConfiguration.projects).toHaveLength(5);
8181

8282
// "approvedPackagesPolicy" feature
8383
const approvedPackagesPolicy: ApprovedPackagesPolicy = rushConfiguration.approvedPackagesPolicy;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "app1",
3+
"version": "1.0.0",
4+
"description": "Test app 1"
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "app2",
3+
"version": "1.0.0",
4+
"description": "Test app 2"
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{
3+
"definitionName": "lockStepVersion",
4+
"policyName": "testPolicy",
5+
"version": "1.0.0",
6+
"nextBump": "minor"
7+
}
8+
]

libraries/rush-lib/src/api/test/repo/rush-npm.json

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,37 @@
2727
{
2828
"packageName": "project1",
2929
"projectFolder": "project1",
30-
"reviewCategory": "third-party"
30+
"reviewCategory": "third-party",
31+
"tags": ["frontend", "ui"],
32+
"versionPolicyName": "testPolicy"
3133
},
3234

3335
{
3436
"packageName": "project2",
3537
"projectFolder": "project2",
3638
"reviewCategory": "third-party",
37-
"skipRushCheck": true
39+
"skipRushCheck": true,
40+
"tags": ["backend"]
3841
},
3942

4043
{
4144
"packageName": "project3",
4245
"projectFolder": "project3",
43-
"reviewCategory": "prototype"
46+
"reviewCategory": "prototype",
47+
"tags": ["frontend"],
48+
"versionPolicyName": "testPolicy"
49+
},
50+
51+
{
52+
"packageName": "app1",
53+
"projectFolder": "apps/app1",
54+
"reviewCategory": "first-party"
55+
},
56+
57+
{
58+
"packageName": "app2",
59+
"projectFolder": "apps/app2",
60+
"reviewCategory": "first-party"
4461
}
4562
]
4663
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ export class RushCommandLineParser extends CommandLineParser {
8888
private readonly _terminal: Terminal;
8989
private readonly _autocreateBuildCommand: boolean;
9090

91+
/**
92+
* The current working directory that was used to find the Rush configuration.
93+
*/
94+
public get cwd(): string {
95+
return this._rushOptions.cwd;
96+
}
97+
9198
public constructor(options?: Partial<IRushCommandLineParserOptions>) {
9299
super({
93100
toolFilename: 'rush',

libraries/rush-lib/src/cli/actions/InstallAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ export class InstallAction extends BaseInstallAction {
4141
// Disable filtering because rush-project.json is riggable and therefore may not be available
4242
enableFiltering: false
4343
},
44-
includeSubspaceSelector: true
44+
includeSubspaceSelector: true,
45+
cwd: this.parser.cwd
4546
});
4647

4748
this._checkOnlyParameter = this.defineFlagParameter({

libraries/rush-lib/src/cli/actions/ListAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export class ListAction extends BaseRushAction {
116116
// Disable filtering because rush-project.json is riggable and therefore may not be available
117117
enableFiltering: false
118118
},
119-
includeSubspaceSelector: false
119+
includeSubspaceSelector: false,
120+
cwd: this.parser.cwd
120121
});
121122
}
122123

libraries/rush-lib/src/cli/actions/UpdateAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export class UpdateAction extends BaseInstallAction {
4545
// Disable filtering because rush-project.json is riggable and therefore may not be available
4646
enableFiltering: false
4747
},
48-
includeSubspaceSelector: true
48+
includeSubspaceSelector: true,
49+
cwd: this.parser.cwd
4950
});
5051
}
5152

0 commit comments

Comments
 (0)