Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 14, 2025

Implementation Complete: PathProjectSelectorParser

Successfully implemented the PathProjectSelectorParser with the path: scheme as requested.

Latest Changes (addressing code review feedback):

  • Use Path.convertToSlashes helper (Comment 3544412936)
    • Replaced manual path separator conversion (relativePath.split(nodePath.sep).join('/')) with Path.convertToSlashes(relativePath)
    • Uses the standard utility from @rushstack/node-core-library
    • More idiomatic and consistent with the rest of the codebase

Complete Implementation Summary:

Code Changes:

  • PathProjectSelectorParser requires workingDirectory parameter (not optional)
  • RushCommandLineParser exposes cwd via public getter for consistent path resolution
  • SelectionParameterSet accepts cwd from parser and passes to PathProjectSelectorParser
  • Auto-detection: SelectionParameterSet automatically routes path-like selectors to path: parser
  • All actions (ListAction, InstallAction, UpdateAction, PhasedScriptAction) pass parser.cwd
  • Path normalization: Uses Path.convertToSlashes helper for cross-platform compatibility
  • Path matching using findChildPath (handles exact and containing matches)
  • Uses Set for collecting multiple projects
  • Single source of truth: process.cwd() called once in RushCommandLineParser, used consistently throughout

Test Changes:

  • PathProjectSelectorParser: 9 tests (including shared subfolder test)
  • VersionPolicyProjectSelectorParser: 3 tests (with actual version policies)
  • NamedProjectSelectorParser: 3 tests
  • TagProjectSelectorParser: 4 tests with real tag validation
  • SubspaceSelectorParser: 2 tests
  • Total: 21 tests across 5 test files

Test Fixture Updates:

  • Added apps/app1 and apps/app2 projects for nested structure testing
  • Created version-policies.json with testPolicy
  • Updated rush-npm.json to include 5 projects with version policies and tags
  • Fixed RushConfiguration.test.ts to expect 5 projects

Change Management:

  • Added Rush change file for minor version bump

Features:

  1. Path Resolution: Resolves input path against consistent working directory from Rush CLI (same cwd used to discover rush.json)
  2. Auto-detection: Automatically recognizes and routes path-like selectors without explicit path: prefix
  3. Cross-Platform: Uses Path.convertToSlashes for proper path normalization on Windows
  4. Flexible Selection:
    • Exact project match (path points to a project folder)
    • Containing project match (path points inside a project)
    • Multiple projects match (path points to a directory containing projects)
  5. Error Handling: Clear error messages for paths that don't match any project
  6. Integration: Works with all selection parameters (--only, --to, --from, --impacted-by, etc.)
  7. Consistent CWD: Both path resolution and Rush configuration discovery use the same working directory

Security Summary:

No security vulnerabilities introduced. The implementation:

  • Uses existing path normalization utilities from @rushstack/node-core-library
  • Follows established patterns from other selector parsers
  • Properly handles errors without exposing sensitive information
Original prompt

In @microsoft/rush-lib, define a new ISelectorParser alongside the existing implementations that has a scheme of path: and selects projects by resolving the input path against the working directory, relativizing it to the rushJsonFolder, then leveraging the LookupByPath instance returned by rushConfiguration.getProjectLookupForRoot to identify either the project that contains the relativized path, or all projects that are within the relativized path. This should be called PathProjectSelectorParser.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add PathProjectSelectorParser to rush-lib [rush-lib] Add PathProjectSelectorParser with path: scheme Nov 14, 2025
Copilot AI requested a review from dmichon-msft November 14, 2025 23:44
Copilot finished work on behalf of dmichon-msft November 14, 2025 23:44
Copilot finished work on behalf of dmichon-msft November 15, 2025 00:19
Copy link
Contributor

@dmichon-msft dmichon-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except for the missing change file.

@dmichon-msft
Copy link
Contributor

@copilot Need to run rush change --no-fetch --bulk --bump-type minor --message "${Insert description of the feature here}" to create the change file for Rush.

Copy link
Contributor Author

Copilot AI commented Nov 17, 2025

@copilot Need to run rush change --no-fetch --bulk --bump-type minor --message "${Insert description of the feature here}" to create the change file for Rush.

Fixed in b4f2e53. Created change file with minor bump type for the PathProjectSelectorParser feature at common/changes/@microsoft/rush/copilot-add-path-project-selector-parser_2025-11-17-22-30.json.

Looks good except for the missing change file.

Fixed in b4f2e53. Created change file with minor bump type for the PathProjectSelectorParser feature at common/changes/@microsoft/rush/copilot-add-path-project-selector-parser_2025-11-17-22-30.json.

Copilot AI requested a review from dmichon-msft November 17, 2025 22:34
Copilot finished work on behalf of dmichon-msft November 17, 2025 22:34
Copy link
Contributor Author

Copilot AI commented Nov 17, 2025

@copilot - Left some comments. It also looks like build or tests are failing on Windows.

Fixed Windows path issue in 4967774. The problem was that path.relative() returns backslashes on Windows, but LookupByPath expects forward slashes. Added normalization: relativePath.split(nodePath.sep).join('/') to convert path separators before querying LookupByPath.

Copilot finished work on behalf of iclanton November 17, 2025 23:33
Copilot AI requested a review from iclanton November 17, 2025 23:33
Copilot finished work on behalf of iclanton November 17, 2025 23:47
@dmichon-msft
Copy link
Contributor

@copilot Update _evaluateSelectorParser in SelectionParameterSet to generalize the special case of '.' to take anything that is obviously a relative path ('.', '..', or either of those followed by a '/' and more path) or an absolute POSIX path (a value starting with '/') and automatically route it to the path: selector parser

Copy link
Contributor Author

Copilot AI commented Nov 18, 2025

@copilot Update _evaluateSelectorParser in SelectionParameterSet to generalize the special case of '.' to take anything that is obviously a relative path ('.', '..', or either of those followed by a '...

Fixed in b70d1a7. Updated _evaluateProjectParameterAsync to automatically route path-like selectors to the path: parser:

  • Relative paths: ., .., ./..., ../...
  • Absolute POSIX paths: /...

Now users can use rush build --only . or rush build --only ./my-project without needing the explicit path: prefix. The special-case handling for . using PackageJsonLookup has been removed in favor of the unified path selector approach.

Copilot AI changed the title [rush-lib] Add PathProjectSelectorParser with path: scheme [rush-lib] Add PathProjectSelectorParser with path: scheme and auto-routing Nov 18, 2025
Copilot AI requested a review from dmichon-msft November 18, 2025 00:03
Copilot finished work on behalf of dmichon-msft November 18, 2025 00:03
@dmichon-msft
Copy link
Contributor

@copilot libraries/rush-lib/src/logic/selectors/PathProjectSelectorParser.ts:35
Call the Path.convertToSlashes helper for this.

Copy link
Contributor Author

Copilot AI commented Nov 18, 2025

@copilot libraries/rush-lib/src/logic/selectors/PathProjectSelectorParser.ts:35
Call the Path.convertToSlashes helper for this.

Fixed in 52c2340. Replaced manual path separator conversion with Path.convertToSlashes(relativePath) helper from @rushstack/node-core-library.

Copilot finished work on behalf of dmichon-msft November 18, 2025 00:19
@iclanton iclanton enabled auto-merge (squash) November 18, 2025 22:33
@iclanton iclanton merged commit 6e6df73 into main Nov 18, 2025
8 checks passed
@iclanton iclanton deleted the copilot/add-path-project-selector-parser branch November 18, 2025 22:53
@github-project-automation github-project-automation bot moved this from Needs triage to Closed in Bug Triage Nov 18, 2025
iclanton added a commit that referenced this pull request Nov 19, 2025
…ion-test (#5456)

* [rush-lib] fix bridge package command (#5411)

* rush change

* fix: enable prerelease version matching in bridge-package command

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Introduce an ESLint rule to coalesce imports. (#5414)

* Use the no-duplicate-imports rule.

* fixup! Use the no-duplicate-imports rule.

* fixup! Use the no-duplicate-imports rule.

* Fix duplicate import issues.

* Use the import/no-duplicates rule.

* Manual fixes.

* [eslint-plugin] Document the @rushstack/typedef-var rule and clarify scope (#5410)

* docs(eslint-plugin): document the @rushstack/typedef-var rule

* chore(changefile): add changefile for typedef-var documentation

* docs: remove for...of and for...in exception from typedef-var rule documentation

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Bump decpouled local dependencies. (#5415)

* [heft-rspack-plugin] Initial implementation of a Rspack Heft plugin. (#4015)

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Update changelogs [skip ci]

* Bump versions [skip ci]

* [rush] Fork npm-check into rush-lib (#5416)

* Fork npm-check

* rush update

* Update test scripts in package json

* rush update

* Fix test file

* Add and update readmes

* Update readme, update config

* Update readme

---------

Co-authored-by: cmalonzo <[email protected]>

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Fix an issue with the return type of Executable.waitForExitAsync. (#5417)

* Clean up the `repo-scripts bump-decoupled-local-dependencies` action. (#5418)

* Move files around in repo-toolbox.

* Don't bump allowed alternative dependencies.

* Include @rushstack/set-webpack-public-path-plugin@^4.1.16 in common-versions.json.

* [eslint-plugin] Introduce `@rushstack/import-requires-chunk-name` and `@rushstack/pair-react-dom-render-unmount` rules. (#5419)

* Include the @rushstack/import-requires-chunk-name rule.

* Include the @rushstack/pair-react-dom-render-unmount rule.

* fixup! Include the @rushstack/pair-react-dom-render-unmount rule.

* Include missing documentation.

* Rush change.

* Sort README entries.

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Extract CredentialCache from Rush into @rushstack/credential-cache (#5421)

* Add new credential-cache package

* Add test command

* Factor out CredentialCache

* Fix routing

* Fix API

* Update readme

* Update readme

* rush update

* Forward rush-user folder name

* Remove old credentials schema

* Restore caching in getHomeFolder

* Remove reexport of areDeepEqual

* Update API md

* Centralize polyfill

---------

Co-authored-by: David Michon <[email protected]>

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Fix an issue where suppressed rule violations still show up in the report in ESLint >=9.37.0. (#5422)

* Fix an issue where suppressed rule violations still show up in the report in ESLint >=9.37.0.

* Fix an issue where the ESLint process will crash when running in the ESLint VSCode extension in ESLint >=9.37.0.

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Bump decoupled local dependencies. (#5420)

* [heft-lint] Fix TypeScript program passing (#5428)

Co-authored-by: David Michon <[email protected]>

* [API Extractor] Add support for printing a diff of changed API reports in non-local builds. (#5427)

* Fix an issue where verbose API extractor messages may not be passed to the Heft plugin.

* Add diff printing to API Extractor's report issue logging.

* Expose an alwaysShowChangedApiReportDiffOnNonLocalBuild option in the api-extractor-heft-plugin configuration file.

* Use the alwaysShowChangedApiReportDiffOnNonLocalBuild in the local rig

* fixup! Add diff printing to API Extractor's report issue logging.

* Generate a JSON schemas artifact after publish. (#5429)

* Copy JSON schemas to projects' temp/json-schemas folders.

* Introduce a tool for collecting JSON schemas.

* Record JSON schemas during publish.

* Produce artifacts during CI.

* Fix publish. (#5430)

* Update changelogs [skip ci]

* Bump versions [skip ci]

* [heft-node-rig] Add lib-dts and lib-esm to cleanFiles glob (#5438)

* Initial plan

* Add lib-dts and lib-esm to cleanFiles in heft-node-rig

Co-authored-by: dmichon-msft <[email protected]>

* Add change file for heft-node-rig

Co-authored-by: dmichon-msft <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: dmichon-msft <[email protected]>

* Update changelogs [skip ci]

* Bump versions [skip ci]

* [eslint-plugin] Fix no-external-local-imports in editor (#5441)

* [eslint-plugin] Fix calculation of project folder in ESLint
* [heft-lint] Set parserOptions.tsconfigRootDir

---------

Co-authored-by: David Michon <[email protected]>

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Bump decoupled local dependencies. (#5440)

* Bump cyclic dependencies.

* Bump TSDoc dependencies.

* Rush update.

* [devx] Apply schemas to Rush/Heft config files in VS Code, add clean build launch config (#5445)

* Bind schemas in vscode

* Add clean build launch config

---------

Co-authored-by: David Michon <[email protected]>

* [heft-typescript] Support `${configDir}` token in tsconfig.json (#5444)

* Support ${configDir} in typescript file copier

* Use ${configDir} in local rigs

* Use const

* Fix a TSDoc link.

---------

Co-authored-by: David Michon <[email protected]>
Co-authored-by: Ian Clanton-Thuon <[email protected]>

* Update changelogs [skip ci]

* Bump versions [skip ci]

* [lint] Ensure correctness of SARIF output logs (#5443)

* [eslint-bulk] Report bulk suppressions as suppressions

* [heft-lint] Include suppressed results

* Enable sarif log for local rigs, add test

* Fix lint cache

* Fix typo in TSLint

---------

Co-authored-by: David Michon <[email protected]>

* Update changelogs [skip ci]

* Bump versions [skip ci]

* [rush] Add project-level parameter ignoring to prevent unnecessary cache invalidation (#5433)

* Initial plan

* Add parameter ignoring feature to rush-lib

Co-authored-by: dmichon-msft <[email protected]>

* Add tests for parameter ignoring feature

Co-authored-by: dmichon-msft <[email protected]>

* Refactor to eliminate code duplication in parameter collection

Co-authored-by: dmichon-msft <[email protected]>

* Improve documentation and add clarifying comments

Co-authored-by: dmichon-msft <[email protected]>

* Address PR feedback: use ignoredParameterValues and improve filtering

Co-authored-by: dmichon-msft <[email protected]>

* Address final PR feedback: improve logging and test coverage

Co-authored-by: dmichon-msft <[email protected]>

* Centralize parameter creation helper and share with BaseScriptAction

Co-authored-by: dmichon-msft <[email protected]>

* Ensure all parameter types are tested for filtering

Co-authored-by: dmichon-msft <[email protected]>

* Refactor parameter helpers into cli/parsing directory

Co-authored-by: dmichon-msft <[email protected]>

* Use CommandLineParser to parse parameter values in test

Co-authored-by: dmichon-msft <[email protected]>

* Use executeWithoutErrorHandlingAsync instead of executeAsync

Co-authored-by: dmichon-msft <[email protected]>

* Add rush change file for project-level parameter ignoring feature

Co-authored-by: iclanton <[email protected]>

* Adjust formatting of change file

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: dmichon-msft <[email protected]>
Co-authored-by: iclanton <[email protected]>
Co-authored-by: David Michon <[email protected]>

* [rush-lib] Add validation for parameterNamesToIgnore in rush-project.json (#5448)

* Initial plan

* Add validation for parameterNamesToIgnore in rush-project.json

Co-authored-by: iclanton <[email protected]>

* Remove unused test repository

* Address PR feedback: combine error messages and add malformed parameter test

Co-authored-by: iclanton <[email protected]>

* Add changelog entry for rush-lib

Co-authored-by: iclanton <[email protected]>

* Add tests for parameter validation with valid parameters

Co-authored-by: iclanton <[email protected]>

* Update libraries/rush-lib/src/api/test/RushProjectConfiguration.test.ts

Co-authored-by: David Michon <[email protected]>

* Update common/changes/@microsoft/rush-lib/copilot-validate-parameter-names-to-ignore_2025-11-13-23-26.json

* Fix changelog entry to use @microsoft/rush package name

Co-authored-by: iclanton <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: iclanton <[email protected]>
Co-authored-by: Ian Clanton-Thuon <[email protected]>
Co-authored-by: David Michon <[email protected]>

* [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]>

* Initial plan

* Generate changelogs for webpack version bump

Co-authored-by: iclanton <[email protected]>

---------

Co-authored-by: Lincoln <[email protected]>
Co-authored-by: Rushbot <[email protected]>
Co-authored-by: Ian Clanton-Thuon <[email protected]>
Co-authored-by: yuza🍊 <[email protected]>
Co-authored-by: Camille Malonzo <[email protected]>
Co-authored-by: cmalonzo <[email protected]>
Co-authored-by: David Michon <[email protected]>
Co-authored-by: David Michon <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: dmichon-msft <[email protected]>
Co-authored-by: iclanton <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

4 participants