Each file now has a default export matching the CommandExecuteFn
pattern, removing the need for import wrapping in the loader.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
Switch the prepack and postpack commands from using a direct
dynamic import() to the execute.loader pattern, which properly
handles CJS double-wrapping of module exports.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
Remove fragile process.stdout._handle.setBlocking calls from CLI test
commands. Revert the preload workaround in repo-tools since the root
cause is removed.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
Add cleye-based --help handling to all commands using the loader pattern.
Update the CLI report parser to support cleye's USAGE: and FLAGS: sections.
Revert accidental backstage.role addition to eslint-plugin.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Extend `BackstageCommand.execute` to accept either a direct function or a
`{ loader }` object for lazy loading command implementations. Convert
several build and migrate commands to use the new pattern. Switch from
`program.parse` to `program.parseAsync` to properly await async actions.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Move the transform tests from packages/cli/src/tests/transforms/ into
packages/cli/src/modules/build/tests/transforms/ so that the build
module is self-contained and can eventually become its own package.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Split version.ts into two locations:
- Template version provider moved to modules/new/lib/version.ts
- CLI version info moved to wiring/version.ts
Remove publishPreflightCheck from repo fix command (still runs during
package prepack). Fix build module self-references to use shorter
within-module paths.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Move `getHasYarnPlugin` and `SuccessCache` from `@backstage/cli` internal
modules to `@backstage/cli-node` as public exports, making them available
for reuse by other CLI tooling.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
The file was moved from maintenance to build on master, so the
cross-module import is no longer needed.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Split the shared loadCliConfig function into two separate implementations
to remove the cross-module dependency from build to config.
The build module's version keeps the watch/streaming capability needed by
the dev server, while the config module's version is simplified to
one-shot loading since no config commands need watching.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Add separate breaking changeset for the removal of `migrate package-exports`,
and fix a pre-existing bug where the restore assignments in
`createScriptOptionsParser` were swapped.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Move typeDistProject.ts into the build module, duplicate optionsParser.ts
into build and lint modules, inline configOption in the build module,
and simplify the deprecated migrate package-exports command to remove
cross-module dependencies.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
These are CLI framework infrastructure files that belong alongside
createCliPlugin and CliInitializer rather than in the general lib/
directory.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Move the `package clean`, `package prepack`, `package postpack`, and
`repo clean` commands from the internal maintenance module to the build
module, along with the publishing preflight check utility.
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
- 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>
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>
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>
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>
- 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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>