Commit Graph

3233 Commits

Author SHA1 Message Date
github-actions[bot] 4bd6a3a1af Version Packages (next) 2026-02-24 19:24:06 +00:00
Patrik Oldsberg 641d88cb07 Address PR review comments
- Remove cli-node/src/paths.ts compat layer, migrate all cli-node
  internal usage to import targetPaths from @backstage/cli-common
- Use single-arg overrideTargetPaths('/root') where dir === rootDir
- Scope mockDir to each describe block in bump.test.ts to avoid
  shared state issues with overrideTargetPaths
- Remove unnecessary overrideTargetPaths from plugin-manager.test.ts
- Remove stale findPaths mock from createApp.test.ts
- Use overrideTargetPaths in getWorkspaceRoot.test.ts and cli-node tests

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-23 21:01:27 +01:00
Patrik Oldsberg ebc01ef04d Add overrideTargetPaths test utility and fix rebase issues
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>
2026-02-23 17:25:31 +01:00
Patrik Oldsberg 553e727d5f Fix lint errors: add eslint-disable for __dirname, fix no-use-before-define
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-23 14:44:11 +01:00
Patrik Oldsberg 6fa63d411f Fix prettier formatting
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-23 14:44:11 +01:00
Patrik Oldsberg 07816d67f3 Address PR review comments
- 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>
2026-02-23 14:44:11 +01:00
Patrik Oldsberg 70fc178697 Replace findPaths with targetPaths and findOwnPaths
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>
2026-02-23 14:44:10 +01:00
Patrik Oldsberg 29e91e9159 Give each CLI module its own paths instead of importing from lib/
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>
2026-02-23 14:44:10 +01:00
Patrik Oldsberg 56bd494b0c Give each CLI module its own paths instead of importing from lib/
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>
2026-02-23 14:44:10 +01:00
Patrik Oldsberg 158bfe8a69 Give each CLI module its own paths instead of importing from lib/
Each module now has a local paths.ts that calls findPaths(__dirname) directly.
This makes modules fully independent of lib/paths.ts, and the pattern will
continue to work when modules are extracted into separate packages since each
package's __dirname will resolve to its own root.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-23 14:44:10 +01:00
Patrik Oldsberg ce676fea2f Merge pull request #32904 from backstage/rugvip/translation-export-import
cli: add translations export and import commands
2026-02-23 13:18:03 +01:00
Patrik Oldsberg f467a4126e Return object from runWorkerQueueThreads
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-23 11:38:23 +01:00
Patrik Oldsberg 1dfc3436d9 cli: address review feedback from freben
Fix whitespace alignment in CLI command summary, improve export command
description to clarify it operates from an app context, and update the
corresponding docs section.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-23 01:05:15 +01:00
Patrik Oldsberg 4f0c7ec86a Address PR review feedback
- Rename runParallelWorkers to runConcurrentTasks, return void
- Rename ParallelWorkerOptions to ConcurrentTasksOptions
- Rename parallelismFactor to concurrencyFactor
- Remove unused runWorkerThreads and WorkerThreadsOptions
- Rename workerData to context in WorkerQueueThreadsOptions
- Drop threadCount from public API types
- Rename env var to BACKSTAGE_CLI_CONCURRENCY
- Make cli-node changeset a patch

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-23 00:41:17 +01:00
Patrik Oldsberg 649d3ca3b6 Remove dead parallelism options and narrow public API
The parallelism fields on bundler types (BundlingOptions, BuildOptions,
BackendBundlingOptions) and createDistWorkspace Options were defined but
never read — fully dead code. Likewise the parallelismSetting option on
ParallelWorkerOptions was never passed by any caller.

Also narrows the cli-node public API to only export the three runner
functions and their option types, keeping getEnvironmentParallelism and
parseParallelismOption as internal utilities.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-22 16:49:55 +01:00
Patrik Oldsberg 06c2015e5b Move parallel worker utilities to @backstage/cli-node
Moves `runParallelWorkers`, `runWorkerQueueThreads`, `runWorkerThreads`,
`parseParallelismOption`, and `getEnvironmentParallelism` from the CLI
internal lib to the shared `@backstage/cli-node` package.

This is part of the ongoing effort to make CLI modules independent of
each other and the shared lib code.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-22 16:19:49 +01:00
Patrik Oldsberg eeb74ffe79 Merge pull request #32934 from soapraj/soapraj/bump-bfj-v9
cli: bump bfj dependency from ^8.0.0 to ^9.0.2
2026-02-21 17:33:13 +01:00
Patrik Oldsberg bba2e496a6 Move single-consumer lib files into the build module
Moved `entryPoints.ts` and `role.ts` (+ test) from the shared `src/lib/`
directory into `src/modules/build/lib/`, since the build module is their
only consumer. This is part of making CLI modules independent of each
other and of shared code outside the modules.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-20 23:38:58 +01:00
Fredrik Adelöw d95cf37ce3 Merge pull request #32583 from Believe-SA/commander-14
chore: update dependency commander to v14
2026-02-20 21:04:31 +01:00
Raghunandan Balachandran 5e10165839 cli: bump bfj dependency from ^8.0.0 to ^9.0.2
The only usage of bfj in @backstage/cli is `bfj.write(path, data)` in
bundle.ts for writing bundle-stats.json. The write API is unchanged in
v9 and v9.0.0/v9.0.1 are deprecated, so the range starts at ^9.0.2.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Raghunandan Balachandran <raghunandan@spotify.com>
2026-02-20 10:57:52 +01:00
renovate[bot] 092b41f397 chore(deps): update dependency webpack to ~5.105.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-19 09:16:46 +00:00
dependabot[bot] 6738cf0842 build(deps): bump minimatch from 9.0.5 to 10.2.1 (#32915)
Bumps [minimatch](https://github.com/isaacs/minimatch) from 9.0.5 to 10.2.1.
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v9.0.5...v10.2.1)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-version: 10.2.1
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-19 08:58:00 +01:00
Patrik Oldsberg 90f19f6164 cli: address review feedback on translations commands
- Fix Windows path separators in import by splitting on path.sep
- Make extractTranslations test less brittle by not pinning exact
  message strings or total count
- Remove unnecessary `as any` cast for devDependencies
- Validate pattern in export command to fail fast on invalid patterns

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-18 23:04:32 +01:00
Patrik Oldsberg 00472ed0be cli: update CLI report for translations commands
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-18 15:06:41 +01:00
Patrik Oldsberg dd5f052017 cli: make messages/ part of the configurable --pattern flag
Moves the messages/ path segment from being hardcoded into the export
and import commands to being part of the pattern itself. The default
pattern is now messages/{id}.{lang}.json, giving full control over the
directory structure under the translations output directory.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-18 12:32:51 +01:00
Patrik Oldsberg a808c9ef3f cli: use PackageRoles for role detection and remove redundant import --pattern
Uses PackageRoles.getRoleInfo from cli-node to determine frontend packages
by platform instead of a hardcoded role list. Removes the --pattern option
from the import command since the pattern is always read from the manifest.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-18 12:22:26 +01:00
Patrik Oldsberg 356cff278f cli: add configurable --pattern option for translation message files
Adds a --pattern option to both translations export and import commands
that controls the file path layout of message files within the messages/
directory. The default pattern is {id}.{lang}.json (unchanged behavior),
but users can pass e.g. --pattern '{lang}/{id}.json' for language-based
directory grouping. The pattern is stored in the manifest so that import
picks it up automatically.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-18 00:31:18 +01:00
Patrik Oldsberg d404ab30ca cli: walk transitive deps and resolve npm packages for translation export
The package discovery for the translations export command previously only
looked at direct dependencies and only workspace packages. This changes
it to recursively walk the full transitive dependency tree and resolve
packages from node_modules when they aren't found in the workspace.
Entry point resolution now also prefers .d.ts type declarations for
npm-installed packages.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 23:29:31 +01:00
Patrik Oldsberg a8a853eb1c Add translations export and translations import CLI commands
Adds tooling for exporting and importing translation strings to enable
integration with external TMS tools like Smartling. The export command
uses the TypeScript compiler API (ts-morph) to discover TranslationRef
exports from all frontend plugin dependencies of the current package,
extracting message keys and default values from the type system. The
import command generates TranslationResource wiring from translated
JSON files downloaded from a TMS.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:36:19 +01:00
github-actions[bot] e6df5d52ce Version Packages 2026-02-17 16:06:18 +00:00
Gabriel Dugny e6f7ab105d fix: Revert some un-necessary allowExcessArguments
Signed-off-by: Gabriel Dugny <gabriel.dugny@believe.com>
2026-02-16 18:21:49 +01:00
Gabriel Dugny de62a9d322 chore: update dependency commander to v14, remove old @types/commander
Signed-off-by: Gabriel Dugny <gabriel.dugny@believe.com>
2026-02-16 17:29:25 +01:00
Patrik Oldsberg fdbd40488e module-federation-common: followup to initial implementation
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-13 13:47:35 +01:00
Patrik Oldsberg 903a854ebc Merge branch 'master' into runtime-module-federation-enablement
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-12 23:46:00 +01:00
github-actions[bot] 7c41134684 Version Packages (next) 2026-02-10 16:14:59 +00:00
Patrik Oldsberg 9848734ce6 Merge pull request #32761 from backstage/rugvip/css-exports-support
cli: add support for CSS exports in package build
2026-02-10 13:23:02 +01:00
Patrik Oldsberg ae08712748 Fix repo fix to not add typesVersions for non-script exports
Only CSS and other non-script, non-JSON exports should be excluded from
typesVersions. The package.json export still needs to be included.

Also preserves field order when updating existing typesVersions.

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>
2026-02-10 09:23:12 +01:00
Patrik Oldsberg 5a09d9bdb6 Add unit tests for cssEntryPoints plugin
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>
2026-02-09 23:29:33 +01:00
Patrik Oldsberg 269fc0c7a1 Fix CSS entry points plugin to avoid duplicate emissions
- Add deduplication logic to only emit CSS once per output directory
- Only emit during write phase, not during generate
- Fix comment describing the path transformation

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 23:18:32 +01:00
Patrik Oldsberg 9274eb3dba Merge pull request #32705 from backstage/renovate/npm-webpack-vulnerability
chore(deps): update dependency webpack to ~5.104.0 [security]
2026-02-09 21:32:01 +01:00
Patrik Oldsberg 5040fdaa55 Fix lint error in types.d.ts
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 20:42:47 +01:00
Patrik Oldsberg 5c95133efa Add type declaration for postcss-import
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 20:27:30 +01:00
Patrik Oldsberg cad0b68d9c cli: Integrate CSS bundling as a Rollup plugin
Instead of having a separate post-build step for CSS entry points,
the CSS bundling is now integrated directly into the Rollup build
as a plugin. This is cleaner and will enable better watch mode
support in the future.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 17:30:35 +01:00
Patrik Oldsberg fb3bc36690 cli: Switch CSS bundling from lightningcss to postcss-import
postcss-import naturally preserves @layer declarations during bundling,
eliminating the need for custom layer parsing and restoration logic.
This simplifies the implementation while also preserving source comments.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 16:01:16 +01:00
Patrik Oldsberg 4f9d980943 cli: Add support for CSS exports in package build
This adds support for CSS entry points in package exports. When a package
declares a CSS file in its exports field, the CLI will now automatically
bundle it during `backstage-cli package build` and rewrite the export
path from src/ to dist/ at publish time.

The CSS bundling uses lightningcss to resolve @import statements and
preserves @layer declarations that would otherwise be stripped during
bundling.

This allows packages like @backstage/ui to use the standard build command
instead of custom build scripts for CSS bundling.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 13:53:05 +01:00
Andre Wanlin 6ce4a13bf4 docs - Writing Custom Actions Corrections
Signed-off-by: Andre Wanlin <awanlin@spotify.com>
2026-02-08 12:39:13 -06:00
renovate[bot] 73351c2736 chore(deps): update dependency webpack to ~5.104.0 [security]
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-05 20:44:36 +00:00
github-actions[bot] 1ea737c1e2 Version Packages (next) 2026-02-03 14:24:29 +00:00
Patrik Oldsberg 5e3ef57e4e switch from backstage.integrationFor to backstage.peerModules
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-02 22:57:06 +01:00
Patrik Oldsberg 0e10859c62 Compute packagePath once in fixIntegrationFor
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-02 22:48:05 +01:00