Skip to content

fix(check:policy): Use relative paths in package.json repository field #24887

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tylerbutler
Copy link
Member

The resolver for the package.json repository.directory field was using absolute paths instead of relative ones. That is now fixed.

@tylerbutler tylerbutler requested review from Copilot and a team June 20, 2025 23:53
@github-actions github-actions bot added area: build Build related issues base: main PRs targeted against main branch labels Jun 20, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the repository.directory field in generated package.json files by switching from absolute to relative paths.

  • Updated the resolver function to accept the repository root (gitRoot)
  • Changed relativePkgDir computation to use path.relative against gitRoot
Comments suppressed due to low confidence (1)

build-tools/packages/build-cli/src/library/repoPolicyCheck/npmPackages.ts:841

  • Add or update unit tests to cover this new relative path resolution logic, including edge cases like files at the repo root and nested directories.
				const relativePkgDir = path.dirname(path.relative(gitRoot, file)).replace(/\\/g, "/");

@@ -832,13 +832,13 @@ export const handlers: Handler[] = [

return undefined;
},
resolver: (file: string): { resolved: boolean } => {
resolver: (file: string, gitRoot: string): { resolved: boolean } => {
Copy link
Preview

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

The resolver signature was changed to include gitRoot, but the Handler interface and any call sites need to be updated accordingly to prevent type mismatches or runtime errors.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: build Build related issues base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant