@backstage/cli 0.36.0-next.1 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/config/eslint-factory.js +1 -0
  3. package/config/getJestEnvironment.js +7 -29
  4. package/config/jest-environment-jsdom/index.js +9 -43
  5. package/config/jest.js +7 -401
  6. package/config/jestCacheResultProcessor.cjs +10 -6
  7. package/config/jestCachingModuleLoader.js +11 -19
  8. package/config/jestFileTransform.js +11 -28
  9. package/config/jestRejectNetworkRequests.js +10 -53
  10. package/config/jestSucraseTransform.js +10 -70
  11. package/config/jestSwcTransform.js +10 -27
  12. package/config/jestYamlTransform.js +11 -24
  13. package/config/nodeTransform.cjs +10 -70
  14. package/config/nodeTransformHooks.mjs +4 -278
  15. package/config/webpack-public-path.js +10 -14
  16. package/dist/cli-internal/src/InternalCliModule.cjs.js +11 -0
  17. package/dist/cli-internal/src/InternalCommandNode.cjs.js +25 -0
  18. package/dist/cli-internal/src/knownPluginPackages.cjs.js +40 -0
  19. package/dist/index.cjs.js +21 -10
  20. package/dist/wiring/CliInitializer.cjs.js +61 -20
  21. package/dist/wiring/CommandGraph.cjs.js +81 -23
  22. package/dist/wiring/discoverCliModules.cjs.js +44 -0
  23. package/package.json +27 -154
  24. package/dist/modules/build/commands/buildWorkspace.cjs.js +0 -24
  25. package/dist/modules/build/commands/package/build/command.cjs.js +0 -89
  26. package/dist/modules/build/commands/package/build/index.cjs.js +0 -8
  27. package/dist/modules/build/commands/package/clean.cjs.js +0 -21
  28. package/dist/modules/build/commands/package/postpack.cjs.js +0 -15
  29. package/dist/modules/build/commands/package/prepack.cjs.js +0 -29
  30. package/dist/modules/build/commands/package/start/command.cjs.js +0 -23
  31. package/dist/modules/build/commands/package/start/index.cjs.js +0 -8
  32. package/dist/modules/build/commands/package/start/resolveLinkedWorkspace.cjs.js +0 -34
  33. package/dist/modules/build/commands/package/start/startBackend.cjs.js +0 -46
  34. package/dist/modules/build/commands/package/start/startFrontend.cjs.js +0 -50
  35. package/dist/modules/build/commands/package/start/startPackage.cjs.js +0 -53
  36. package/dist/modules/build/commands/repo/build.cjs.js +0 -114
  37. package/dist/modules/build/commands/repo/clean.cjs.js +0 -41
  38. package/dist/modules/build/commands/repo/start.cjs.js +0 -150
  39. package/dist/modules/build/index.cjs.js +0 -192
  40. package/dist/modules/build/lib/buildBackend.cjs.js +0 -81
  41. package/dist/modules/build/lib/buildFrontend.cjs.js +0 -50
  42. package/dist/modules/build/lib/builder/config.cjs.js +0 -257
  43. package/dist/modules/build/lib/builder/packager.cjs.js +0 -131
  44. package/dist/modules/build/lib/builder/plugins.cjs.js +0 -125
  45. package/dist/modules/build/lib/builder/types.cjs.js +0 -10
  46. package/dist/modules/build/lib/bundler/ConfigInjectingHtmlWebpackPlugin.cjs.js +0 -43
  47. package/dist/modules/build/lib/bundler/bundle.cjs.js +0 -189
  48. package/dist/modules/build/lib/bundler/config.cjs.js +0 -308
  49. package/dist/modules/build/lib/bundler/hasReactDomClient.cjs.js +0 -17
  50. package/dist/modules/build/lib/bundler/linkWorkspaces.cjs.js +0 -34
  51. package/dist/modules/build/lib/bundler/moduleFederation.cjs.js +0 -135
  52. package/dist/modules/build/lib/bundler/optimization.cjs.js +0 -68
  53. package/dist/modules/build/lib/bundler/packageDetection.cjs.js +0 -124
  54. package/dist/modules/build/lib/bundler/paths.cjs.js +0 -62
  55. package/dist/modules/build/lib/bundler/server.cjs.js +0 -231
  56. package/dist/modules/build/lib/bundler/transforms.cjs.js +0 -145
  57. package/dist/modules/build/lib/config.cjs.js +0 -94
  58. package/dist/modules/build/lib/entryPoints.cjs.js +0 -49
  59. package/dist/modules/build/lib/ipc/IpcServer.cjs.js +0 -60
  60. package/dist/modules/build/lib/ipc/ServerDataStore.cjs.js +0 -36
  61. package/dist/modules/build/lib/optionsParser.cjs.js +0 -37
  62. package/dist/modules/build/lib/packager/createDistWorkspace.cjs.js +0 -235
  63. package/dist/modules/build/lib/packager/productionPack.cjs.js +0 -160
  64. package/dist/modules/build/lib/publishing.cjs.js +0 -40
  65. package/dist/modules/build/lib/role.cjs.js +0 -24
  66. package/dist/modules/build/lib/runner/runBackend.cjs.js +0 -136
  67. package/dist/modules/build/lib/typeDistProject.cjs.js +0 -89
  68. package/dist/modules/build/lib/urls.cjs.js +0 -13
  69. package/dist/modules/config/commands/docs.cjs.js +0 -62
  70. package/dist/modules/config/commands/print.cjs.js +0 -80
  71. package/dist/modules/config/commands/schema.cjs.js +0 -55
  72. package/dist/modules/config/commands/validate.cjs.js +0 -49
  73. package/dist/modules/config/index.cjs.js +0 -51
  74. package/dist/modules/config/lib/config.cjs.js +0 -94
  75. package/dist/modules/create-github-app/commands/create-github-app/GithubCreateAppServer.cjs.js +0 -127
  76. package/dist/modules/create-github-app/commands/create-github-app/index.cjs.js +0 -115
  77. package/dist/modules/create-github-app/index.cjs.js +0 -27
  78. package/dist/modules/info/commands/info.cjs.js +0 -181
  79. package/dist/modules/info/index.cjs.js +0 -19
  80. package/dist/modules/lint/commands/package/lint.cjs.js +0 -46
  81. package/dist/modules/lint/commands/repo/lint.cjs.js +0 -212
  82. package/dist/modules/lint/index.cjs.js +0 -82
  83. package/dist/modules/lint/lib/optionsParser.cjs.js +0 -37
  84. package/dist/modules/maintenance/commands/repo/fix.cjs.js +0 -400
  85. package/dist/modules/maintenance/commands/repo/list-deprecations.cjs.js +0 -74
  86. package/dist/modules/maintenance/index.cjs.js +0 -42
  87. package/dist/modules/migrate/commands/packageExports.cjs.js +0 -15
  88. package/dist/modules/migrate/commands/packageLintConfigs.cjs.js +0 -77
  89. package/dist/modules/migrate/commands/packageRole.cjs.js +0 -57
  90. package/dist/modules/migrate/commands/packageScripts.cjs.js +0 -87
  91. package/dist/modules/migrate/commands/reactRouterDeps.cjs.js +0 -51
  92. package/dist/modules/migrate/commands/versions/bump.cjs.js +0 -373
  93. package/dist/modules/migrate/commands/versions/migrate.cjs.js +0 -112
  94. package/dist/modules/migrate/index.cjs.js +0 -82
  95. package/dist/modules/migrate/lib/utils.cjs.js +0 -44
  96. package/dist/modules/migrate/lib/versioning/packages.cjs.js +0 -71
  97. package/dist/modules/migrate/lib/versioning/yarn.cjs.js +0 -28
  98. package/dist/modules/new/commands/new.cjs.js +0 -60
  99. package/dist/modules/new/index.cjs.js +0 -68
  100. package/dist/modules/new/lib/codeowners/codeowners.cjs.js +0 -92
  101. package/dist/modules/new/lib/createNewPackage.cjs.js +0 -32
  102. package/dist/modules/new/lib/defaultTemplates.cjs.js +0 -17
  103. package/dist/modules/new/lib/execution/PortableTemplater.cjs.js +0 -89
  104. package/dist/modules/new/lib/execution/executePortableTemplate.cjs.js +0 -66
  105. package/dist/modules/new/lib/execution/installNewPackage.cjs.js +0 -127
  106. package/dist/modules/new/lib/execution/writeTemplateContents.cjs.js +0 -116
  107. package/dist/modules/new/lib/preparation/collectPortableTemplateInput.cjs.js +0 -157
  108. package/dist/modules/new/lib/preparation/loadPortableTemplate.cjs.js +0 -81
  109. package/dist/modules/new/lib/preparation/loadPortableTemplateConfig.cjs.js +0 -132
  110. package/dist/modules/new/lib/preparation/resolvePackageParams.cjs.js +0 -40
  111. package/dist/modules/new/lib/preparation/selectTemplateInteractively.cjs.js +0 -38
  112. package/dist/modules/new/lib/tasks.cjs.js +0 -51
  113. package/dist/modules/new/lib/types.cjs.js +0 -19
  114. package/dist/modules/new/lib/version.cjs.js +0 -91
  115. package/dist/modules/test/commands/package/test.cjs.js +0 -65
  116. package/dist/modules/test/commands/repo/test.cjs.js +0 -288
  117. package/dist/modules/test/index.cjs.js +0 -54
  118. package/dist/modules/translations/commands/export.cjs.js +0 -127
  119. package/dist/modules/translations/commands/import.cjs.js +0 -164
  120. package/dist/modules/translations/index.cjs.js +0 -24
  121. package/dist/modules/translations/lib/discoverPackages.cjs.js +0 -121
  122. package/dist/modules/translations/lib/extractTranslations.cjs.js +0 -71
  123. package/dist/modules/translations/lib/messageFilePath.cjs.js +0 -43
  124. package/dist/packages/backend-defaults/package.json.cjs.js +0 -6
  125. package/dist/packages/backend-plugin-api/package.json.cjs.js +0 -6
  126. package/dist/packages/backend-test-utils/package.json.cjs.js +0 -6
  127. package/dist/packages/catalog-client/package.json.cjs.js +0 -6
  128. package/dist/packages/cli/package.json.cjs.js +0 -156
  129. package/dist/packages/config/package.json.cjs.js +0 -6
  130. package/dist/packages/core-app-api/package.json.cjs.js +0 -6
  131. package/dist/packages/core-components/package.json.cjs.js +0 -6
  132. package/dist/packages/core-plugin-api/package.json.cjs.js +0 -6
  133. package/dist/packages/dev-utils/package.json.cjs.js +0 -6
  134. package/dist/packages/errors/package.json.cjs.js +0 -6
  135. package/dist/packages/frontend-defaults/package.json.cjs.js +0 -6
  136. package/dist/packages/frontend-plugin-api/package.json.cjs.js +0 -6
  137. package/dist/packages/frontend-plugin-api/src/routing/describeParentCallSite.cjs.js +0 -26
  138. package/dist/packages/frontend-test-utils/package.json.cjs.js +0 -6
  139. package/dist/packages/test-utils/package.json.cjs.js +0 -6
  140. package/dist/packages/theme/package.json.cjs.js +0 -6
  141. package/dist/packages/types/package.json.cjs.js +0 -6
  142. package/dist/plugins/auth-backend/package.json.cjs.js +0 -6
  143. package/dist/plugins/auth-backend-module-guest-provider/package.json.cjs.js +0 -6
  144. package/dist/plugins/catalog-node/package.json.cjs.js +0 -6
  145. package/dist/plugins/scaffolder-node/package.json.cjs.js +0 -6
  146. package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +0 -6
  147. package/dist/wiring/CommandRegistry.cjs.js +0 -14
  148. package/dist/wiring/factory.cjs.js +0 -15
  149. package/dist/wiring/lazy.cjs.js +0 -22
  150. package/dist/wiring/types.cjs.js +0 -11
  151. package/templates/backend-plugin/.eslintrc.js.hbs +0 -1
  152. package/templates/backend-plugin/README.md.hbs +0 -28
  153. package/templates/backend-plugin/dev/index.ts.hbs +0 -60
  154. package/templates/backend-plugin/package.json.hbs +0 -44
  155. package/templates/backend-plugin/portable-template.yaml +0 -5
  156. package/templates/backend-plugin/src/index.ts.hbs +0 -1
  157. package/templates/backend-plugin/src/plugin.test.ts.hbs +0 -129
  158. package/templates/backend-plugin/src/plugin.ts.hbs +0 -32
  159. package/templates/backend-plugin/src/router.test.ts +0 -67
  160. package/templates/backend-plugin/src/router.ts +0 -51
  161. package/templates/backend-plugin/src/services/TodoListService.ts +0 -155
  162. package/templates/backend-plugin/src/setupTests.ts +0 -1
  163. package/templates/backend-plugin-module/.eslintrc.js.hbs +0 -1
  164. package/templates/backend-plugin-module/README.md.hbs +0 -5
  165. package/templates/backend-plugin-module/package.json.hbs +0 -34
  166. package/templates/backend-plugin-module/portable-template.yaml +0 -5
  167. package/templates/backend-plugin-module/src/index.ts.hbs +0 -8
  168. package/templates/backend-plugin-module/src/module.ts.hbs +0 -17
  169. package/templates/catalog-provider-module/.eslintrc.js.hbs +0 -1
  170. package/templates/catalog-provider-module/README.md.hbs +0 -5
  171. package/templates/catalog-provider-module/config.d.ts.hbs +0 -34
  172. package/templates/catalog-provider-module/package.json.hbs +0 -36
  173. package/templates/catalog-provider-module/portable-template.yaml +0 -9
  174. package/templates/catalog-provider-module/src/index.ts.hbs +0 -8
  175. package/templates/catalog-provider-module/src/module.ts.hbs +0 -29
  176. package/templates/catalog-provider-module/src/provider/readProviderConfigs.ts.hbs +0 -78
  177. package/templates/catalog-provider-module/src/provider/{{providerClass}}.test.ts.hbs +0 -18
  178. package/templates/catalog-provider-module/src/provider/{{providerClass}}.ts.hbs +0 -109
  179. package/templates/frontend-plugin/.eslintrc.js.hbs +0 -1
  180. package/templates/frontend-plugin/README.md.hbs +0 -13
  181. package/templates/frontend-plugin/dev/index.tsx.hbs +0 -11
  182. package/templates/frontend-plugin/package.json.hbs +0 -54
  183. package/templates/frontend-plugin/portable-template.yaml +0 -6
  184. package/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +0 -28
  185. package/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs +0 -37
  186. package/templates/frontend-plugin/src/components/ExampleComponent/index.ts +0 -1
  187. package/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +0 -19
  188. package/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs +0 -308
  189. package/templates/frontend-plugin/src/components/ExampleFetchComponent/index.ts +0 -1
  190. package/templates/frontend-plugin/src/index.ts.hbs +0 -1
  191. package/templates/frontend-plugin/src/plugin.test.ts.hbs +0 -7
  192. package/templates/frontend-plugin/src/plugin.ts.hbs +0 -22
  193. package/templates/frontend-plugin/src/routes.ts.hbs +0 -5
  194. package/templates/frontend-plugin/src/setupTests.ts +0 -1
  195. package/templates/new-frontend-plugin/.eslintrc.js.hbs +0 -1
  196. package/templates/new-frontend-plugin/README.md.hbs +0 -20
  197. package/templates/new-frontend-plugin/dev/index.tsx +0 -10
  198. package/templates/new-frontend-plugin/package.json.hbs +0 -49
  199. package/templates/new-frontend-plugin/portable-template.yaml +0 -5
  200. package/templates/new-frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +0 -28
  201. package/templates/new-frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs +0 -37
  202. package/templates/new-frontend-plugin/src/components/ExampleComponent/index.ts +0 -1
  203. package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +0 -19
  204. package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs +0 -308
  205. package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/index.ts +0 -1
  206. package/templates/new-frontend-plugin/src/index.ts.hbs +0 -1
  207. package/templates/new-frontend-plugin/src/plugin.test.ts.hbs +0 -7
  208. package/templates/new-frontend-plugin/src/plugin.tsx.hbs +0 -25
  209. package/templates/new-frontend-plugin/src/routes.ts +0 -3
  210. package/templates/new-frontend-plugin/src/setupTests.ts +0 -1
  211. package/templates/new-frontend-plugin-module/.eslintrc.js.hbs +0 -1
  212. package/templates/new-frontend-plugin-module/README.md.hbs +0 -5
  213. package/templates/new-frontend-plugin-module/package.json.hbs +0 -35
  214. package/templates/new-frontend-plugin-module/portable-template.yaml +0 -5
  215. package/templates/new-frontend-plugin-module/src/index.ts.hbs +0 -1
  216. package/templates/new-frontend-plugin-module/src/module.tsx.hbs +0 -8
  217. package/templates/new-frontend-plugin-module/src/setupTests.ts +0 -1
  218. package/templates/node-library/.eslintrc.js.hbs +0 -1
  219. package/templates/node-library/README.md.hbs +0 -12
  220. package/templates/node-library/package.json.hbs +0 -29
  221. package/templates/node-library/portable-template.yaml +0 -3
  222. package/templates/node-library/src/index.ts.hbs +0 -1
  223. package/templates/node-library/src/setupTests.ts +0 -1
  224. package/templates/plugin-common-library/.eslintrc.js.hbs +0 -1
  225. package/templates/plugin-common-library/README.md.hbs +0 -5
  226. package/templates/plugin-common-library/package.json.hbs +0 -31
  227. package/templates/plugin-common-library/portable-template.yaml +0 -3
  228. package/templates/plugin-common-library/src/index.ts.hbs +0 -19
  229. package/templates/plugin-common-library/src/setupTests.ts +0 -1
  230. package/templates/plugin-node-library/.eslintrc.js.hbs +0 -1
  231. package/templates/plugin-node-library/README.md.hbs +0 -5
  232. package/templates/plugin-node-library/package.json.hbs +0 -30
  233. package/templates/plugin-node-library/portable-template.yaml +0 -3
  234. package/templates/plugin-node-library/src/index.ts.hbs +0 -18
  235. package/templates/plugin-node-library/src/setupTests.ts +0 -1
  236. package/templates/plugin-web-library/.eslintrc.js.hbs +0 -1
  237. package/templates/plugin-web-library/README.md.hbs +0 -5
  238. package/templates/plugin-web-library/package.json.hbs +0 -42
  239. package/templates/plugin-web-library/portable-template.yaml +0 -3
  240. package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.test.tsx +0 -17
  241. package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.tsx +0 -28
  242. package/templates/plugin-web-library/src/components/ExampleComponent/index.ts +0 -2
  243. package/templates/plugin-web-library/src/components/index.ts +0 -5
  244. package/templates/plugin-web-library/src/hooks/index.ts +0 -5
  245. package/templates/plugin-web-library/src/hooks/useExample/index.ts +0 -1
  246. package/templates/plugin-web-library/src/hooks/useExample/useExample.ts +0 -15
  247. package/templates/plugin-web-library/src/index.ts.hbs +0 -12
  248. package/templates/plugin-web-library/src/setupTests.ts +0 -1
  249. package/templates/scaffolder-backend-module/.eslintrc.js.hbs +0 -1
  250. package/templates/scaffolder-backend-module/README.md.hbs +0 -5
  251. package/templates/scaffolder-backend-module/package.json.hbs +0 -36
  252. package/templates/scaffolder-backend-module/portable-template.yaml +0 -6
  253. package/templates/scaffolder-backend-module/src/actions/example.test.ts +0 -24
  254. package/templates/scaffolder-backend-module/src/actions/example.ts +0 -39
  255. package/templates/scaffolder-backend-module/src/index.ts.hbs +0 -8
  256. package/templates/scaffolder-backend-module/src/module.ts +0 -21
  257. package/templates/web-library/.eslintrc.js.hbs +0 -1
  258. package/templates/web-library/README.md.hbs +0 -12
  259. package/templates/web-library/package.json.hbs +0 -30
  260. package/templates/web-library/portable-template.yaml +0 -3
  261. package/templates/web-library/src/index.ts.hbs +0 -1
  262. package/templates/web-library/src/setupTests.ts +0 -1
  263. /package/dist/{packages/opaque-internal → opaque-internal}/src/OpaqueType.cjs.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,115 @@
1
1
  # @backstage/cli
2
2
 
3
+ ## 0.36.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d0f4cd2: Added new `auth` command group for authenticating the CLI with Backstage instances using OAuth 2.0 with a pre-registered client metadata document. Commands include `login`, `logout`, `list`, `show`, `print-token`, and `select` for managing multiple authenticated instances.
8
+ - d806b0c: The CLI now automatically discovers CLI modules from the project root's `dependencies` and `devDependencies`. Any installed package with the `cli-module` Backstage role will be loaded automatically without needing to be hardcoded in the CLI itself.
9
+
10
+ If no CLI modules are found in the project dependencies, the CLI falls back to the built-in set of modules and prints a deprecation warning. This fallback will be removed in a future release. To prepare for this, add `@backstage/cli-defaults` as a `devDependency` in your root `package.json`:
11
+
12
+ ```json
13
+ {
14
+ "devDependencies": {
15
+ "@backstage/cli-defaults": "backstage:^"
16
+ }
17
+ }
18
+ ```
19
+
20
+ If you are not using the Backstage Yarn plugin, run the following instead:
21
+
22
+ ```sh
23
+ yarn workspace root add --dev @backstage/cli-defaults
24
+ ```
25
+
26
+ For fine-grained control you can instead install individual CLI modules:
27
+
28
+ ```json
29
+ {
30
+ "devDependencies": {
31
+ "@backstage/cli-module-auth": "backstage:^",
32
+ "@backstage/cli-module-build": "backstage:^",
33
+ "@backstage/cli-module-config": "backstage:^",
34
+ "@backstage/cli-module-github": "backstage:^",
35
+ "@backstage/cli-module-info": "backstage:^",
36
+ "@backstage/cli-module-lint": "backstage:^",
37
+ "@backstage/cli-module-maintenance": "backstage:^",
38
+ "@backstage/cli-module-migrate": "backstage:^",
39
+ "@backstage/cli-module-new": "backstage:^",
40
+ "@backstage/cli-module-test-jest": "backstage:^",
41
+ "@backstage/cli-module-translations": "backstage:^"
42
+ }
43
+ }
44
+ ```
45
+
46
+ - 08d9770: **BREAKING**: The CLI templates for frontend plugins have been renamed:
47
+
48
+ - `new-frontend-plugin` → `frontend-plugin`
49
+ - `new-frontend-plugin-module` → `frontend-plugin-module`
50
+ - `frontend-plugin` (legacy) → `legacy-frontend-plugin`
51
+
52
+ To smooth out this breaking change, the CLI now auto-detects which frontend system your app uses based on the dependencies in `packages/app/package.json`. When using the default templates (no explicit `templates` configuration):
53
+
54
+ - Apps using `@backstage/frontend-defaults` will see the new frontend system templates (`frontend-plugin`, `frontend-plugin-module`)
55
+ - Apps using `@backstage/app-defaults` will see the legacy template (displayed as `frontend-plugin`)
56
+
57
+ This means existing projects that haven't migrated to the new frontend system will continue to create legacy plugins by default, while new projects will get the new frontend system templates. If you have explicit template configuration in your `package.json`, it will be used as-is without any auto-detection.
58
+
59
+ - b36a60d: **BREAKING**: The `migrate package-exports` command has been removed. Use `repo fix` instead.
60
+
61
+ ### Patch Changes
62
+
63
+ - edf2b77: Added a new `cli-module` template for creating CLI module packages.
64
+ - 246877a: Updated dependency `bfj` to `^9.0.2`.
65
+ - 0d2d0f2: Internal refactor of CLI modularization, moving individual commands to be implemented with cleye.
66
+ - a4e5902: Internal refactor of the CLI command registration
67
+ - bba2e49: Internal refactor to use new concurrency utilities from `@backstage/cli-node`.
68
+ - 2fcba39: Internal refactor to move shared utilities into their consuming modules, reducing cross-module dependencies.
69
+ - c85ac86: Internal refactor to split `loadCliConfig` into separate implementations for the build and config CLI modules, removing a cross-module dependency.
70
+ - 94a885a: Added support for the new `cli-module` package role in the build system, ESLint configuration, Jest configuration, and maintenance commands.
71
+ - fd50cb3: Added `translations export` and `translations import` commands for managing translation files.
72
+
73
+ The `translations export` command discovers all `TranslationRef` definitions across frontend plugin dependencies and exports their default messages as JSON files. The `translations import` command generates `TranslationResource` wiring code from translated JSON files, ready to be plugged into the app.
74
+
75
+ Both commands support a `--pattern` option for controlling the message file layout, for example `--pattern '{lang}/{id}.json'` for language-based directory grouping.
76
+
77
+ - 0be3eab: Migrated CLI plugin modules to use `createCliModule` from `@backstage/cli-node`.
78
+ - 61cb976: Migrated internal versioning utilities to use `@backstage/cli-node` instead of a local implementation.
79
+ - 6738cf0: build(deps): bump `minimatch` from 9.0.5 to 10.2.1
80
+ - ff4a45a: Migrated remaining CLI command handlers from `commander` to `cleye` for argument parsing. Several camelCase CLI flags have been deprecated in favor of their kebab-case equivalents (e.g. `--successCache` → `--success-cache`). The old camelCase forms still work but will now log a deprecation warning. Please update any scripts or CI configurations to use the kebab-case versions.
81
+ - 70fc178: Migrated from deprecated `findPaths` to `targetPaths` and `findOwnPaths` from `@backstage/cli-common`.
82
+ - 825c81d: Internal refactor of CLI command modules.
83
+ - ea90ab0: The built-in `yarn new` templates have been moved to `@backstage/cli-module-new`. Existing references to `@backstage/cli/templates/*` in your root `package.json` will continue to work through a backwards compatibility rewrite in the `new` command.
84
+ - ebeb0d4: Updated the new frontend plugin template to use `@backstage/frontend-dev-utils` in its `dev/` entry point instead of wiring `createApp` manually. Generated plugins now get the same dev app helper setup as the built-in examples.
85
+ - 971cc94: The `new` command now prompts for the plugin package name when creating plugin modules, in order to properly populate the `package.json` file.
86
+ - de62a9d: Upgraded `commander` dependency from `^12.0.0` to `^14.0.3` across all CLI packages.
87
+ - 092b41f: Updated dependency `webpack` to `~5.105.0`.
88
+ - 4a75544: Updated dependency `react-refresh` to `^0.18.0`.
89
+ - a9d23c4: Properly support `package.json` `workspaces` field
90
+ - Updated dependencies
91
+ - @backstage/cli-node@0.3.0
92
+ - @backstage/cli-common@0.2.0
93
+ - @backstage/cli-defaults@0.1.0
94
+ - @backstage/cli-module-build@0.1.0
95
+ - @backstage/eslint-plugin@0.2.2
96
+ - @backstage/cli-module-test-jest@0.1.0
97
+
98
+ ## 0.36.0-next.2
99
+
100
+ ### Minor Changes
101
+
102
+ - d0f4cd2: Added new `auth` command group for authenticating the CLI with Backstage instances using OAuth 2.0 with a pre-registered client metadata document. Commands include `login`, `logout`, `list`, `show`, `print-token`, and `select` for managing multiple authenticated instances.
103
+
104
+ ### Patch Changes
105
+
106
+ - a4e5902: Internal refactor of the CLI command registration
107
+ - ff4a45a: Migrated remaining CLI command handlers from `commander` to `cleye` for argument parsing. Several camelCase CLI flags have been deprecated in favor of their kebab-case equivalents (e.g. `--successCache` → `--success-cache`). The old camelCase forms still work but will now log a deprecation warning. Please update any scripts or CI configurations to use the kebab-case versions.
108
+ - 4a75544: Updated dependency `react-refresh` to `^0.18.0`.
109
+ - Updated dependencies
110
+ - @backstage/cli-common@0.2.0-next.2
111
+ - @backstage/integration@2.0.0-next.2
112
+
3
113
  ## 0.36.0-next.1
4
114
 
5
115
  ### Minor Changes
@@ -269,6 +269,7 @@ function createConfigForRole(dir, role, extraConfig = {}) {
269
269
  });
270
270
 
271
271
  case 'cli':
272
+ case 'cli-module':
272
273
  case 'node-library':
273
274
  case 'backend':
274
275
  case 'backend-plugin':
@@ -14,36 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- function getJestMajorVersion() {
18
- const jestVersion = require('jest/package.json').version;
19
- const majorVersion = parseInt(jestVersion.split('.')[0], 10);
20
- return majorVersion;
21
- }
22
-
23
- function getJestEnvironment() {
24
- const majorVersion = getJestMajorVersion();
25
-
26
- if (majorVersion >= 30) {
27
- try {
28
- require.resolve('@jest/environment-jsdom-abstract');
29
- require.resolve('jsdom');
30
- } catch {
31
- throw new Error(
32
- 'Jest 30+ requires @jest/environment-jsdom-abstract and jsdom. ' +
33
- 'Please install them as dev dependencies.',
34
- );
35
- }
36
- return require.resolve('./jest-environment-jsdom');
37
- }
38
- try {
39
- require.resolve('jest-environment-jsdom');
40
- } catch {
17
+ try {
18
+ module.exports = require('@backstage/cli-module-test-jest/config/getJestEnvironment');
19
+ } catch (e) {
20
+ if (e.code === 'MODULE_NOT_FOUND') {
41
21
  throw new Error(
42
- 'Jest 29 requires jest-environment-jsdom. ' +
43
- 'Please install it as a dev dependency.',
22
+ '@backstage/cli-module-test-jest is required to use the jest environment configuration. ' +
23
+ 'Please install it as a dependency.',
44
24
  );
45
25
  }
46
- return require.resolve('jest-environment-jsdom');
26
+ throw e;
47
27
  }
48
-
49
- module.exports = { getJestMajorVersion, getJestEnvironment };
@@ -14,48 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- const JSDOMEnvironment = require('@jest/environment-jsdom-abstract').default;
18
- const jsdom = require('jsdom');
19
-
20
- /**
21
- * A custom JSDOM environment that extends the abstract base and applies
22
- * fixes for Web API globals that are missing or incorrectly implemented
23
- * in JSDOM.
24
- *
25
- * Based on https://github.com/mswjs/jest-fixed-jsdom
26
- */
27
- class FixedJSDOMEnvironment extends JSDOMEnvironment {
28
- constructor(config, context) {
29
- super(config, context, jsdom);
30
-
31
- // Fix Web API globals that JSDOM doesn't properly expose
32
- this.global.TextDecoder = TextDecoder;
33
- this.global.TextEncoder = TextEncoder;
34
- this.global.TextDecoderStream = TextDecoderStream;
35
- this.global.TextEncoderStream = TextEncoderStream;
36
- this.global.ReadableStream = ReadableStream;
37
-
38
- this.global.Blob = Blob;
39
- this.global.Headers = Headers;
40
- this.global.FormData = FormData;
41
- this.global.Request = Request;
42
- this.global.Response = Response;
43
- this.global.fetch = fetch;
44
- this.global.AbortController = AbortController;
45
- this.global.AbortSignal = AbortSignal;
46
- this.global.structuredClone = structuredClone;
47
- this.global.URL = URL;
48
- this.global.URLSearchParams = URLSearchParams;
49
-
50
- this.global.BroadcastChannel = BroadcastChannel;
51
- this.global.TransformStream = TransformStream;
52
- this.global.WritableStream = WritableStream;
53
-
54
- // Needed to ensure `e instanceof Error` works as expected with errors thrown from
55
- // any of the native APIs above. Without this, the JSDOM `Error` is what the test
56
- // code will use for comparison with `e`, which fails the instanceof check.
57
- this.global.Error = Error;
17
+ try {
18
+ module.exports = require('@backstage/cli-module-test-jest/config/jest-environment-jsdom');
19
+ } catch (e) {
20
+ if (e.code === 'MODULE_NOT_FOUND') {
21
+ throw new Error(
22
+ '@backstage/cli-module-test-jest is required to use the jest JSDOM environment. ' +
23
+ 'Please install it as a dependency.',
24
+ );
58
25
  }
26
+ throw e;
59
27
  }
60
-
61
- module.exports = FixedJSDOMEnvironment;
package/config/jest.js CHANGED
@@ -14,408 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- const fs = require('fs-extra');
18
- const path = require('node:path');
19
- const crypto = require('node:crypto');
20
- const glob = require('node:util').promisify(require('glob'));
21
- const { version } = require('../package.json');
22
- const paths = require('@backstage/cli-common').findPaths(process.cwd());
23
- const {
24
- getJestEnvironment,
25
- getJestMajorVersion,
26
- } = require('./getJestEnvironment');
27
-
28
- const SRC_EXTS = ['ts', 'js', 'tsx', 'jsx', 'mts', 'cts', 'mjs', 'cjs'];
29
-
30
- const FRONTEND_ROLES = [
31
- 'frontend',
32
- 'web-library',
33
- 'common-library',
34
- 'frontend-plugin',
35
- 'frontend-plugin-module',
36
- ];
37
-
38
- const NODE_ROLES = [
39
- 'backend',
40
- 'cli',
41
- 'node-library',
42
- 'backend-plugin',
43
- 'backend-plugin-module',
44
- ];
45
-
46
- const envOptions = {
47
- oldTests: Boolean(process.env.BACKSTAGE_OLD_TESTS),
48
- };
49
-
50
17
  try {
51
- require.resolve('react-dom/client', {
52
- paths: [paths.targetRoot],
53
- });
54
- process.env.HAS_REACT_DOM_CLIENT = true;
55
- } catch {
56
- /* ignored */
57
- }
58
-
59
- /**
60
- * A list of config keys that are valid for project-level config.
61
- * Jest will complain if we forward any other root configuration to the projects.
62
- *
63
- * @type {Array<keyof import('@jest/types').Config.ProjectConfig>}
64
- */
65
- const projectConfigKeys = [
66
- 'automock',
67
- 'cache',
68
- 'cacheDirectory',
69
- 'clearMocks',
70
- 'collectCoverageFrom',
71
- 'coverageDirectory',
72
- 'coveragePathIgnorePatterns',
73
- 'cwd',
74
- 'dependencyExtractor',
75
- 'detectLeaks',
76
- 'detectOpenHandles',
77
- 'displayName',
78
- 'errorOnDeprecated',
79
- 'extensionsToTreatAsEsm',
80
- 'fakeTimers',
81
- 'filter',
82
- 'forceCoverageMatch',
83
- 'globalSetup',
84
- 'globalTeardown',
85
- 'globals',
86
- 'haste',
87
- 'id',
88
- 'injectGlobals',
89
- 'moduleDirectories',
90
- 'moduleFileExtensions',
91
- 'moduleNameMapper',
92
- 'modulePathIgnorePatterns',
93
- 'modulePaths',
94
- 'openHandlesTimeout',
95
- 'preset',
96
- 'prettierPath',
97
- 'resetMocks',
98
- 'resetModules',
99
- 'resolver',
100
- 'restoreMocks',
101
- 'rootDir',
102
- 'roots',
103
- 'runner',
104
- 'runtime',
105
- 'sandboxInjectedGlobals',
106
- 'setupFiles',
107
- 'setupFilesAfterEnv',
108
- 'skipFilter',
109
- 'skipNodeResolution',
110
- 'slowTestThreshold',
111
- 'snapshotResolver',
112
- 'snapshotSerializers',
113
- 'snapshotFormat',
114
- 'testEnvironment',
115
- 'testEnvironmentOptions',
116
- 'testMatch',
117
- 'testLocationInResults',
118
- 'testPathIgnorePatterns',
119
- 'testRegex',
120
- 'testRunner',
121
- 'transform',
122
- 'transformIgnorePatterns',
123
- 'watchPathIgnorePatterns',
124
- 'unmockedModulePathPatterns',
125
- 'workerIdleMemoryLimit',
126
- ];
127
-
128
- const transformIgnorePattern = [
129
- '@material-ui',
130
- 'ajv',
131
- 'core-js',
132
- 'jest-.*',
133
- 'jsdom',
134
- 'knex',
135
- 'react',
136
- 'react-dom',
137
- 'highlight\\.js',
138
- 'prismjs',
139
- 'json-schema',
140
- 'react-use/lib',
141
- 'typescript',
142
- ].join('|');
143
-
144
- // Provides additional config that's based on the role of the target package
145
- function getRoleConfig(role, pkgJson) {
146
- // Only Node.js package roles support native ESM modules, frontend and common
147
- // packages are always transpiled to CommonJS.
148
- const moduleOpts = NODE_ROLES.includes(role)
149
- ? {
150
- module: {
151
- ignoreDynamic: true,
152
- exportInteropAnnotation: true,
153
- },
154
- }
155
- : undefined;
156
-
157
- const transform = {
158
- '\\.(mjs|cjs|js)$': [
159
- require.resolve('./jestSwcTransform'),
160
- {
161
- ...moduleOpts,
162
- jsc: {
163
- parser: {
164
- syntax: 'ecmascript',
165
- },
166
- },
167
- },
168
- ],
169
- '\\.jsx$': [
170
- require.resolve('./jestSwcTransform'),
171
- {
172
- jsc: {
173
- parser: {
174
- syntax: 'ecmascript',
175
- jsx: true,
176
- },
177
- transform: {
178
- react: {
179
- runtime: 'automatic',
180
- },
181
- },
182
- },
183
- },
184
- ],
185
- '\\.(mts|cts|ts)$': [
186
- require.resolve('./jestSwcTransform'),
187
- {
188
- ...moduleOpts,
189
- jsc: {
190
- parser: {
191
- syntax: 'typescript',
192
- },
193
- },
194
- },
195
- ],
196
- '\\.tsx$': [
197
- require.resolve('./jestSwcTransform'),
198
- {
199
- jsc: {
200
- parser: {
201
- syntax: 'typescript',
202
- tsx: true,
203
- },
204
- transform: {
205
- react: {
206
- runtime: 'automatic',
207
- },
208
- },
209
- },
210
- },
211
- ],
212
- '\\.(bmp|gif|jpg|jpeg|png|ico|webp|frag|xml|svg|eot|woff|woff2|ttf)$':
213
- require.resolve('./jestFileTransform.js'),
214
- '\\.(yaml)$': require.resolve('./jestYamlTransform'),
215
- };
216
- if (FRONTEND_ROLES.includes(role)) {
217
- return {
218
- testEnvironment: getJestEnvironment(),
219
- // The caching module loader is only used to speed up frontend tests,
220
- // as it breaks real dynamic imports of ESM modules.
221
- runtime: envOptions.oldTests
222
- ? undefined
223
- : require.resolve('./jestCachingModuleLoader'),
224
- transform,
225
- };
226
- }
227
- return {
228
- testEnvironment: require.resolve('jest-environment-node'),
229
- moduleFileExtensions: [...SRC_EXTS, 'json', 'node'],
230
- // Jest doesn't let us dynamically detect type=module per transformed file,
231
- // so we have to assume that if the entry point is ESM, all TS files are
232
- // ESM.
233
- //
234
- // This means you can't switch a package to type=module until all of its
235
- // monorepo dependencies are also type=module or does not contain any .ts
236
- // files.
237
- extensionsToTreatAsEsm:
238
- pkgJson.type === 'module' ? ['.ts', '.mts'] : ['.mts'],
239
- transform,
240
- };
241
- }
242
-
243
- async function getProjectConfig(targetPath, extraConfig, extraOptions) {
244
- const configJsPath = path.resolve(targetPath, 'jest.config.js');
245
- const configTsPath = path.resolve(targetPath, 'jest.config.ts');
246
- // If the package has it's own jest config, we use that instead.
247
- if (await fs.pathExists(configJsPath)) {
248
- return require(configJsPath);
249
- } else if (await fs.pathExists(configTsPath)) {
250
- return require(configTsPath);
251
- }
252
-
253
- // Jest config can be defined both in the root package.json and within each package. The root config
254
- // gets forwarded to us through the `extraConfig` parameter, while the package config is read here.
255
- // If they happen to be the same the keys will simply override each other.
256
- // The merging of the configs is shallow, meaning e.g. all transforms are replaced if new ones are defined.
257
- const pkgJson = await fs.readJson(path.resolve(targetPath, 'package.json'));
258
-
259
- const options = {
260
- ...extraConfig,
261
- rootDir: path.resolve(targetPath, 'src'),
262
- moduleNameMapper: {
263
- '\\.(css|less|scss|sss|styl)$': require.resolve('jest-css-modules'),
264
- },
265
-
266
- // A bit more opinionated
267
- testMatch: [`**/*.test.{${SRC_EXTS.join(',')}}`],
268
-
269
- transformIgnorePatterns: [`/node_modules/(?:${transformIgnorePattern})/`],
270
- ...getRoleConfig(pkgJson.backstage?.role, pkgJson),
271
- };
272
-
273
- options.setupFilesAfterEnv = options.setupFilesAfterEnv || [];
274
-
275
- if (
276
- extraOptions.rejectFrontendNetworkRequests &&
277
- FRONTEND_ROLES.includes(pkgJson.backstage?.role)
278
- ) {
279
- // By adding this first we ensure that it's possible to for example override
280
- // fetch with a mock in a custom setup file
281
- options.setupFilesAfterEnv.unshift(
282
- require.resolve('./jestRejectNetworkRequests.js'),
283
- );
284
- }
285
-
286
- if (
287
- options.testEnvironment === getJestEnvironment() &&
288
- getJestMajorVersion() < 30 // Only needed when not running the custom env for Jest 30+
289
- ) {
290
- // FIXME https://github.com/jsdom/jsdom/issues/1724
291
- options.setupFilesAfterEnv.unshift(require.resolve('cross-fetch/polyfill'));
292
- }
293
-
294
- // Use src/setupTests.* as the default location for configuring test env
295
- for (const ext of SRC_EXTS) {
296
- if (fs.existsSync(path.resolve(targetPath, `src/setupTests.${ext}`))) {
297
- options.setupFilesAfterEnv.push(`<rootDir>/setupTests.${ext}`);
298
- break;
299
- }
300
- }
301
-
302
- const config = Object.assign(options, pkgJson.jest);
303
-
304
- // The config id is a cache key that lets us share the jest cache across projects.
305
- // If no explicit id was configured, generated one based on the configuration.
306
- if (!config.id) {
307
- const configHash = crypto
308
- .createHash('sha256')
309
- .update(version)
310
- .update(Buffer.alloc(1))
311
- .update(JSON.stringify(config.transform).replaceAll(paths.targetRoot, ''))
312
- .digest('hex');
313
- config.id = `backstage_cli_${configHash}`;
314
- }
315
-
316
- return config;
317
- }
318
-
319
- // This loads the root jest config, which in turn will either refer to a single
320
- // configuration for the current package, or a collection of configurations for
321
- // the target workspace packages
322
- async function getRootConfig() {
323
- const rootPkgJson = await fs.readJson(
324
- paths.resolveTargetRoot('package.json'),
325
- );
326
-
327
- const baseCoverageConfig = {
328
- coverageDirectory: paths.resolveTarget('coverage'),
329
- coverageProvider: envOptions.oldTests ? 'v8' : 'babel',
330
- collectCoverageFrom: ['**/*.{js,jsx,ts,tsx,mjs,cjs}', '!**/*.d.ts'],
331
- };
332
-
333
- const { rejectFrontendNetworkRequests, ...rootOptions } =
334
- rootPkgJson.jest ?? {};
335
- const extraRootOptions = {
336
- rejectFrontendNetworkRequests,
337
- };
338
-
339
- const ws = rootPkgJson.workspaces;
340
- const workspacePatterns = Array.isArray(ws) ? ws : ws?.packages;
341
-
342
- // Check if we're running within a specific monorepo package. In that case just get the single project config.
343
- if (!workspacePatterns || paths.targetRoot !== paths.targetDir) {
344
- return getProjectConfig(
345
- paths.targetDir,
346
- {
347
- ...baseCoverageConfig,
348
- ...rootOptions,
349
- },
350
- extraRootOptions,
18
+ module.exports = require('@backstage/cli-module-test-jest/config/jest');
19
+ } catch (e) {
20
+ if (e.code === 'MODULE_NOT_FOUND') {
21
+ throw new Error(
22
+ '@backstage/cli-module-test-jest is required to use this jest configuration. ' +
23
+ 'Please install it as a dependency.',
351
24
  );
352
25
  }
353
-
354
- const globalRootConfig = { ...baseCoverageConfig };
355
- const globalProjectConfig = {};
356
-
357
- for (const [key, value] of Object.entries(rootOptions)) {
358
- if (projectConfigKeys.includes(key)) {
359
- globalProjectConfig[key] = value;
360
- } else {
361
- globalRootConfig[key] = value;
362
- }
363
- }
364
-
365
- // If the target package is a workspace root, we find all packages in the
366
- // workspace and load those in as separate jest projects instead.
367
- const projectPaths = await Promise.all(
368
- workspacePatterns.map(pattern =>
369
- glob(path.join(paths.targetRoot, pattern)),
370
- ),
371
- ).then(_ => _.flat());
372
-
373
- let projects = await Promise.all(
374
- projectPaths.flat().map(async projectPath => {
375
- const packagePath = path.resolve(projectPath, 'package.json');
376
- if (!(await fs.pathExists(packagePath))) {
377
- return undefined;
378
- }
379
-
380
- // We check for the presence of "backstage-cli test" in the package test
381
- // script to determine whether a given package should be tested
382
- const packageData = await fs.readJson(packagePath);
383
- const testScript = packageData.scripts && packageData.scripts.test;
384
- const isSupportedTestScript =
385
- testScript?.includes('backstage-cli test') ||
386
- testScript?.includes('backstage-cli package test');
387
- if (testScript && isSupportedTestScript) {
388
- return await getProjectConfig(
389
- projectPath,
390
- {
391
- ...globalProjectConfig,
392
- displayName: packageData.name,
393
- },
394
- extraRootOptions,
395
- );
396
- }
397
-
398
- return undefined;
399
- }),
400
- ).then(cs => cs.filter(Boolean));
401
-
402
- const cache = global.__backstageCli_jestSuccessCache;
403
- if (cache) {
404
- projects = await cache.filterConfigs(projects, globalRootConfig);
405
- }
406
- const watchProjectFilter = global.__backstageCli_watchProjectFilter;
407
- if (watchProjectFilter) {
408
- projects = await watchProjectFilter.filter(projects);
409
- }
410
-
411
- return {
412
- rootDir: paths.targetRoot,
413
- projects,
414
- testResultsProcessor: cache
415
- ? require.resolve('./jestCacheResultProcessor.cjs')
416
- : undefined,
417
- ...globalRootConfig,
418
- };
26
+ throw e;
419
27
  }
420
-
421
- module.exports = getRootConfig();
@@ -14,10 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- module.exports = async results => {
18
- const cache = global.__backstageCli_jestSuccessCache;
19
- if (cache) {
20
- await cache.reportResults(results);
17
+ try {
18
+ module.exports = require('@backstage/cli-module-test-jest/config/jestCacheResultProcessor.cjs');
19
+ } catch (e) {
20
+ if (e.code === 'MODULE_NOT_FOUND') {
21
+ throw new Error(
22
+ '@backstage/cli-module-test-jest is required to use the jest cache result processor. ' +
23
+ 'Please install it as a dependency.',
24
+ );
21
25
  }
22
- return results;
23
- };
26
+ throw e;
27
+ }