Skip to content

chore(util-user-agent-node): read typescript package.json version from process.cwd() - #7802

Merged
trivikr merged 9 commits into
mainfrom
trivikr/typescript-process-cwd
Mar 3, 2026
Merged

chore(util-user-agent-node): read typescript package.json version from process.cwd()#7802
trivikr merged 9 commits into
mainfrom
trivikr/typescript-process-cwd

Conversation

@trivikr

@trivikr trivikr commented Mar 2, 2026

Copy link
Copy Markdown
Member

Issue

Internal JS-6675

Description

If version can't be derived from typescript package.json path from current directory, attempt to read is from typescript package.json version derived from process.cwd()

Testing

CI

Checklist

  • If the PR is a feature, add integration tests (*.integ.spec.ts) or E2E tests.
  • My E2E tests are resilient to concurrent i/o.
    • I didn't write any E2E tests.
  • I added access level annotations e.g. @public, @internal tags and enabled doc generation on the package. Remember that access level annotations go below the description, not above.
    • I didn't add any public functions.
  • Streams - how do they work?? My WebStream readers/locks are properly lifecycled. Node.js stream backpressure is handled. Error handling.
    • No streams here.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@trivikr
trivikr marked this pull request as ready for review March 2, 2026 16:40
@trivikr
trivikr requested a review from a team as a code owner March 2, 2026 16:40
@trivikr
trivikr requested a review from Copilot March 2, 2026 16:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates TypeScript version detection for the Node user-agent helper by trying multiple candidate typescript/package.json locations, including one derived from process.cwd(), and adjusts tests accordingly.

Changes:

  • Replace single-path TypeScript package.json resolution with multi-path lookup (process.cwd() + path derived from __dirname).
  • Add getTypeScriptPackageJsonPaths helper (and unit tests) and remove the old single-path helper.
  • Expand getTypeScriptUserAgentPair unit tests to cover multi-path and caching behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages-internal/util-user-agent-node/src/getTypeScriptUserAgentPair.ts Tries multiple typescript/package.json paths and caches the resolved version (or failure).
packages-internal/util-user-agent-node/src/getTypeScriptUserAgentPair.spec.ts Adds coverage for multi-path success/failure and caching semantics.
packages-internal/util-user-agent-node/src/getTypeScriptPackageJsonPaths.ts New helper that returns candidate typescript/package.json paths (cwd + derived-from-dirname).
packages-internal/util-user-agent-node/src/getTypeScriptPackageJsonPaths.spec.ts New unit tests for the path derivation logic and deduping behavior.
packages-internal/util-user-agent-node/src/getTypeScriptPackageJsonPath.ts Removed in favor of the new multi-path helper.
packages-internal/util-user-agent-node/src/getTypeScriptPackageJsonPath.spec.ts Removed alongside the deprecated helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages-internal/util-user-agent-node/src/getTypeScriptPackageJsonPaths.ts Outdated
Comment thread packages-internal/util-user-agent-node/src/getTypeScriptPackageJsonPaths.ts Outdated
Comment thread packages-internal/util-user-agent-node/src/getTypeScriptPackageJsonPaths.spec.ts Outdated
@trivikr

This comment was marked as outdated.

Comment thread packages-internal/util-user-agent-node/src/getTypeScriptPackageJsonPaths.ts Outdated
@trivikr
trivikr merged commit d152394 into main Mar 3, 2026
7 checks passed
@trivikr
trivikr deleted the trivikr/typescript-process-cwd branch March 6, 2026 06:16
@github-actions

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants