218 Commits

Author SHA1 Message Date
Jon Koops a7a14b78c1 chore: add DOM.AsyncIterable lib and use standard filesystem types
Add `DOM.AsyncIterable` to the shared TypeScript configuration in
`@backstage/cli`, making standard async iteration methods available on
DOM APIs like `FileSystemDirectoryHandle`. This aligns behavior with
TypeScript 6.0, where this lib is included in `DOM` by default.

With the async iterable types now available, replace the custom
`IterableDirectoryHandle` and `WritableFileHandle` types in the scaffolder
plugin with the standard `FileSystemDirectoryHandle` and
`FileSystemFileHandle` DOM types. Add type guard functions for
`FileSystemHandle` since it is not a discriminated union.

Signed-off-by: Jon Koops <jonkoops@gmail.com>
2026-03-26 16:23:46 +01:00
Patrik Oldsberg 4d081452b1 Address review feedback from freben
- Use cli-defaults instead of listing individual CLI modules in
  create-app template and root package.json
- Move nodeTransform config files from cli-module-build to cli-node
  to avoid cross-module direct imports
- Rename cli-module-create-github-app to cli-module-github
- Start createCliModule init chain with Promise.resolve()
- Deduplicate exitWithError in runCliModule.ts
- Extract shared isCommandNodeHidden to @internal/cli
- Add explanatory comment for fromArray deduplication field
- Restore error for cli role packages missing bin in runCliExtraction

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
2026-03-16 12:55:22 +01:00
Patrik Oldsberg 55f6eb8c64 Move config files to CLI modules with lazy proxies
Move jest config files to cli-module-test-jest/config and node
transform + webpack-public-path to cli-module-build/config. Replace
originals in @backstage/cli/config with lazy proxies that forward
to the appropriate module or throw if it is not installed.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
2026-03-15 22:11:43 +01:00
Patrik Oldsberg 18012b5802 Rename CliPlugin to CliModule and cli-plugin role to cli-module
Rename createCliPlugin to createCliModule, CliPlugin to CliModule, and
the cli-plugin package role to cli-module to better distinguish CLI
modules from other plugin types.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
2026-03-14 12:40:43 +01:00
Patrik Oldsberg 94a885a2ef Add cli-plugin package role
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-03-14 12:39:21 +01:00
Gabriel Dugny 0e5fd0fd27 Revert most changes
Signed-off-by: Gabriel Dugny <gabriel.dugny@believe.com>
2026-02-22 17:07:00 +01:00
Gabriel Dugny a9d23c4a32 fix: Support workspaces in CLIs
Signed-off-by: Gabriel Dugny <gabriel.dugny@believe.com>
2026-02-22 16:50:55 +01:00
Fredrik Adelöw 7455dae884 require the use of node prefix on native imports
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
2026-01-26 13:22:53 +01:00
Johan Persson cd0b8a11a3 chore: make jest a peer dependency with v29/v30 support
Move jest from dependencies to peer dependencies, allowing users to
choose between Jest 29 and Jest 30.

The CLI now detects the Jest version at runtime and uses the
appropriate environment:
- Jest 29: Uses standard jest-environment-jsdom
- Jest 30: Uses a custom environment based on @jest/environment-jsdom-abstract
  with fixes for Web API globals (fetch, streams, Error, etc.)

The cross-fetch polyfill is only injected for Jest 29, as with Jest 30+
our patched Jest environment is used. The network request blocker is made
MSW-compatible by checking if fetch was wrapped before blocking.

Jest 30 (with jsdom v27) fixes `Could not parse CSS stylesheet`
warnings/errors when testing components from @backstage/ui or other
packages using CSS `@layer` declarations.

New peer dependencies (install based on your Jest version):
- jest (required, ^29 or ^30)
- Jest 29 requires: jest-environment-jsdom
- Jest 30 requires: @jest/environment-jsdom-abstract, jsdom

Production code changes for jsdom 27 testability:
- AppIdentityProxy: extract navigateToUrl method for spying
- LiveReloadAddon: export utils.reloadPage for spying
- collect.ts: export internal.resolvePackagePath for mocking

MockFetchApi: evaluate global.fetch at call time instead of construction
time, allowing MSW to patch fetch after MockFetchApi is constructed.

Test adaptations for jsdom 27:
- Use RGB values instead of named colors in CSS assertions
- Update error format expectations (hyphenated type names, SyntaxError
  instead of FetchError for JSON parse errors)
- Simplify URL error assertions for cross-version compatibility
- Fix accessible name whitespace handling for external links
- Use history.replaceState for location mocking (non-configurable)
- Use fireEvent.blur for contentEditable elements
- Move async assertions inside waitFor for race conditions
- Remove Blob.prototype.text polyfill (now native)
- Remove test case using credentials in plugin:// URLs

Test adaptations for Jest 30:
- Replace `expect.objectContaining([...])` with direct array equality
- Replace `expect.objectContaining({ length: N })` with
  `expect.any(Array)` + separate `toHaveLength()` assertions
- Use child process for native Node.js module resolution in
  collect.test.ts to work around Jest 30's resolver behavior
- Update snapshot headers for new Jest format

Also removes the jest-haste-map patch which is no longer needed.

Signed-off-by: Johan Persson <johanopersson@gmail.com>
2025-12-11 18:06:55 +01:00
Patrik Oldsberg c07af9f966 cli: move back to ES2022 in tsconfig
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-12-10 20:46:08 +01:00
Fredrik Adelöw 2bae83ab2e Version Policy Update - Node 22 to 24
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
2025-12-08 10:53:38 +01:00
Patrik Oldsberg f8dff944fd cli: switch tsconfig to default to bundler resolution
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-12-02 22:25:00 +01:00
Patrik Oldsberg f2cf564518 cli: remove jest script module cache
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-09-29 14:00:10 +02:00
Patrik Oldsberg ead626f272 cli: add support for built-in type stripping in Node.js
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-08-10 11:23:41 +02:00
MT Lewis a6af7684a8 cli: allow js files to be processed by nodeTransform
Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
2025-07-25 15:38:48 +01:00
Patrik Oldsberg d8c4a54ff5 cli: disable caching Jest module loader for node
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-06-01 11:21:38 +02:00
Gabriel Dugny 72d019d663 chore(typos): Fix low-impact typos
Signed-off-by: Gabriel Dugny <gabriel.dugny@believe.com>
2025-04-23 17:56:22 +02:00
Paul Schultz 918c8831c2 update default react import eslint warning
Signed-off-by: Paul Schultz <pschultz@pobox.com>
2025-04-15 07:34:29 -05:00
Paul Schultz 5aa0d907ac modify eslint and tsconfig files to be nonbreaking
Signed-off-by: Paul Schultz <pschultz@pobox.com>
2025-04-08 07:59:09 -05:00
Paul Schultz 2e26579e06 chore: update react imports
Signed-off-by: Paul Schultz <pschultz@pobox.com>
2025-04-08 07:35:24 -05:00
Paul Schultz 5b7067966c feat: set lint --max-warnings to -1
Signed-off-by: Paul Schultz <pschultz@pobox.com>
2025-03-04 09:50:10 -06:00
Patrik Oldsberg 9638f6d3b0 cli: only pass through .mjs if ESM is supported
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-01-31 13:54:09 +01:00
Patrik Oldsberg c09845bb4e Apply suggestions from code review
Co-authored-by: Fredrik Adelöw <freben@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-01-15 17:38:56 +01:00
Patrik Oldsberg a8dc7f2a7a cli: explicit module type fallback for Node.js 22
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-12-26 21:51:05 +01:00
Patrik Oldsberg e6c049add0 cil: removed dead code in node transform
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-12-26 21:44:24 +01:00
Patrik Oldsberg be9a1f8dc7 cli: simplify Jest ESM support
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-12-26 21:29:00 +01:00
Patrik Oldsberg ce74d76262 cli: better runtime support for ESM dependencies in tests
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-12-26 21:29:00 +01:00
Patrik Oldsberg d7b0ef9515 cli: remove support for implicit module extensions + allow .?ts
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-12-26 21:28:59 +01:00
Patrik Oldsberg d36f7fd6f8 cli: use commonjs compat mode for .cts files
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-12-26 21:28:58 +01:00
Patrik Oldsberg 47407fc34c cli: add ESM support to Jest config + tests
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-12-23 11:39:35 +01:00
Patrik Oldsberg 22ce518325 cli: added initial module hooks
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-12-22 11:07:29 +01:00
Fredrik Adelöw 973dd6f25d fix some little things that vale was complaining about
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
2024-12-10 14:31:54 +01:00
Patrik Oldsberg 583f3d419e cli: provide prettier config
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-11-21 16:06:19 +01:00
Josip Antoliš e565f73e56 Fix .webp imports by expanding webpack loader config
Signed-off-by: Josip Antoliš <josip.antolis@protonmail.com>
2024-10-31 13:59:25 +01:00
Patrik Oldsberg b8683b83c1 Merge pull request #23610 from aramissennyeydd/openapi-tooling/generated-server
feat(openapi-tooling): stop inferring server types
2024-10-29 16:14:40 +01:00
aramissennyeydd c436950472 fix eslint config
Signed-off-by: aramissennyeydd <aramis.sennyey@doordash.com>
2024-10-29 09:41:54 -04:00
Patrik Oldsberg 6819f8cef2 cli: optimize repo test to filter out ununsed projects
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-10-26 11:59:38 +02:00
Patrik Oldsberg 62eaa4c310 cli: trim workspace dir from Jest transform hash input
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-10-24 20:03:29 +02:00
web-next-automation 92a7cc99a0 fix linting issues
Signed-off-by: web-next-automation <web-platform@doordash.com>
Signed-off-by: aramissennyeydd <aramis.sennyey@doordash.com>
2024-10-23 19:10:45 -04:00
Patrik Oldsberg 659d28e411 cli: use namespaced env var to communicate linked workspace
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-10-22 13:27:47 +02:00
Patrik Oldsberg d2e166cbb2 cli: add local linking of backend packages too
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-10-22 12:54:41 +02:00
Patrik Oldsberg eedc7a41c9 Merge pull request #27261 from backstage/rugvip/no-net
cli: add option to reject network requets in frontend tests
2024-10-21 14:37:06 +02:00
Patrik Oldsberg 28b60adbbe cli: fix react-dom/client check in Jest config
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-10-19 11:30:16 +02:00
Patrik Oldsberg a7f97e40b3 cli: add option to reject network requets in frontend tests
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-10-19 10:56:58 +02:00
Patrik Oldsberg f0514c72c3 cli: disable parsing of input source maps in tests
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-10-08 12:38:15 +02:00
Patrik Oldsberg 25943ab18b cli: move repot test result processing to runner, and by path
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-10-08 00:14:53 +02:00
Patrik Oldsberg 86d6c1d2bf cli: only configure jest result processor if success cache is used
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-10-07 18:55:26 +02:00
Patrik Oldsberg 3047813d42 cli: add --successCache option for repo test
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-10-07 16:54:11 +02:00
Patrik Oldsberg 55b8b84fa3 cli: rework jest configuration collection
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-09-27 16:02:55 +02:00
Patrik Oldsberg 1c8d7571c5 packages/cli: add support for runtime configuration of the webpack public path
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-08-30 15:31:45 +02:00