Node.js 22.21.0+ and 24.5.0+ support proxy configuration natively
via NODE_USE_ENV_PROXY=1 and --use-env-proxy, making the legacy
global-agent and undici proxy workarounds unnecessary.
Rather than removing the function immediately, deprecate it with
context-aware runtime warnings that guide users based on their
current configuration:
- Users with GLOBAL_AGENT_* vars are told to switch to standard
HTTP_PROXY/HTTPS_PROXY and set NODE_USE_ENV_PROXY=1.
- Users with HTTP_PROXY/HTTPS_PROXY but no NODE_USE_ENV_PROXY are
told to set it.
- Users who have already opted in to Node.js built-in proxy see no
warning, and the legacy bootstrap is skipped entirely.
See #33444
Signed-off-by: Jon Koops <jonkoops@gmail.com>
Add a `toError` utility function to `@backstage/errors` that converts
unknown values to `ErrorLike` objects. If the value is already error-like
it is returned as-is. Strings are used directly as the error message, and
other values are stringified with a fallback to JSON.stringify to avoid
unhelpful `[object Object]` messages.
Non-error causes passed to `CustomErrorBase` are now converted and stored
using `toError` rather than discarded. Existing `assertError` call sites
across the codebase are migrated to `toError`.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
Addresses review feedback from PR #32939:
- Remove the `findOwnDir` function which is no longer needed
- Add validation to `findOwnRootDir` to verify the resolved path
actually contains a monorepo root with a `package.json` that has
a `workspaces` field
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Adds `overrideTargetPaths` to `@backstage/cli-common/testUtils` for
cleanly mocking `targetPaths` in tests without `jest.mock` or
`jest.spyOn`. Migrates all existing test mocks to use the new utility.
Also fixes translations module imports broken by the rebase.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
- Refactor targetPaths/findOwnPaths to class-based implementations with
unified caching and .dir/.rootDir properties alongside resolve methods
- Replace jest.mock with jest.spyOn in plugin-manager.test.ts
- Remove paths compatibility wrapper from repo-tools, migrate all internal
consumers to use targetPaths from @backstage/cli-common directly
- Fix changeset package name (@techdocs/cli not @backstage/techdocs-cli)
- Add migration examples to cli-common changeset
- Update API report for cli-common
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Split the path resolution API in @backstage/cli-common into
targetPaths (cwd-based singleton) and findOwnPaths (package-relative).
Migrate all consumers across the repo away from the deprecated findPaths.
Rename TargetPaths/OwnPaths properties to resolve/resolveRoot,
removing the redundant type prefix from property names.
Make findOwnPaths calls lazy in modules - called inside functions
rather than at module scope.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Split the paths API in @backstage/cli-common into targetPaths (a lazily
initialized singleton for cwd-based paths) and findOwnPaths (a cached function
for package-relative paths). Most CLI module files only need target paths, which
can now be imported directly without __dirname. The few files that need own paths
use findOwnPaths(__dirname).
Added hierarchical caching to findOwnDir so the filesystem walk only happens
once per package. targetPaths re-resolves automatically if process.cwd() changes.
The deprecated findPaths function is preserved for backward compatibility,
delegating to the new primitives internally.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Each module file that needs paths now calls findPaths(__dirname) directly from
@backstage/cli-common. This removes the coupling between modules and lib/paths,
and will continue to work when modules are extracted into separate packages since
each package's __dirname resolves to its own root.
Added hierarchical caching to findOwnDir in cli-common so that the filesystem
walk only happens once per package - subsequent calls from sibling directories
hit the cache at a common ancestor.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>