@backstage/cli 0.36.0-next.2 → 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 (276) hide show
  1. package/CHANGELOG.md +95 -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 -11
  20. package/dist/wiring/CliInitializer.cjs.js +61 -30
  21. package/dist/wiring/CommandGraph.cjs.js +81 -23
  22. package/dist/wiring/discoverCliModules.cjs.js +44 -0
  23. package/package.json +27 -160
  24. package/dist/modules/auth/commands/list.cjs.js +0 -23
  25. package/dist/modules/auth/commands/login.cjs.js +0 -316
  26. package/dist/modules/auth/commands/logout.cjs.js +0 -55
  27. package/dist/modules/auth/commands/printToken.cjs.js +0 -41
  28. package/dist/modules/auth/commands/select.cjs.js +0 -32
  29. package/dist/modules/auth/commands/show.cjs.js +0 -59
  30. package/dist/modules/auth/index.cjs.js +0 -44
  31. package/dist/modules/auth/lib/auth.cjs.js +0 -60
  32. package/dist/modules/auth/lib/http.cjs.js +0 -26
  33. package/dist/modules/auth/lib/localServer.cjs.js +0 -80
  34. package/dist/modules/auth/lib/pkce.cjs.js +0 -23
  35. package/dist/modules/auth/lib/prompt.cjs.js +0 -44
  36. package/dist/modules/auth/lib/secretStore.cjs.js +0 -81
  37. package/dist/modules/auth/lib/storage.cjs.js +0 -152
  38. package/dist/modules/build/commands/buildWorkspace.cjs.js +0 -53
  39. package/dist/modules/build/commands/package/build/command.cjs.js +0 -136
  40. package/dist/modules/build/commands/package/build/index.cjs.js +0 -10
  41. package/dist/modules/build/commands/package/clean.cjs.js +0 -21
  42. package/dist/modules/build/commands/package/postpack.cjs.js +0 -15
  43. package/dist/modules/build/commands/package/prepack.cjs.js +0 -29
  44. package/dist/modules/build/commands/package/start/command.cjs.js +0 -80
  45. package/dist/modules/build/commands/package/start/index.cjs.js +0 -10
  46. package/dist/modules/build/commands/package/start/resolveLinkedWorkspace.cjs.js +0 -34
  47. package/dist/modules/build/commands/package/start/startBackend.cjs.js +0 -46
  48. package/dist/modules/build/commands/package/start/startFrontend.cjs.js +0 -50
  49. package/dist/modules/build/commands/package/start/startPackage.cjs.js +0 -53
  50. package/dist/modules/build/commands/repo/build.cjs.js +0 -149
  51. package/dist/modules/build/commands/repo/clean.cjs.js +0 -41
  52. package/dist/modules/build/commands/repo/start.cjs.js +0 -199
  53. package/dist/modules/build/index.cjs.js +0 -68
  54. package/dist/modules/build/lib/buildBackend.cjs.js +0 -81
  55. package/dist/modules/build/lib/buildFrontend.cjs.js +0 -50
  56. package/dist/modules/build/lib/builder/config.cjs.js +0 -257
  57. package/dist/modules/build/lib/builder/packager.cjs.js +0 -131
  58. package/dist/modules/build/lib/builder/plugins.cjs.js +0 -125
  59. package/dist/modules/build/lib/builder/types.cjs.js +0 -10
  60. package/dist/modules/build/lib/bundler/ConfigInjectingHtmlWebpackPlugin.cjs.js +0 -43
  61. package/dist/modules/build/lib/bundler/bundle.cjs.js +0 -189
  62. package/dist/modules/build/lib/bundler/config.cjs.js +0 -308
  63. package/dist/modules/build/lib/bundler/hasReactDomClient.cjs.js +0 -17
  64. package/dist/modules/build/lib/bundler/linkWorkspaces.cjs.js +0 -34
  65. package/dist/modules/build/lib/bundler/moduleFederation.cjs.js +0 -135
  66. package/dist/modules/build/lib/bundler/optimization.cjs.js +0 -68
  67. package/dist/modules/build/lib/bundler/packageDetection.cjs.js +0 -124
  68. package/dist/modules/build/lib/bundler/paths.cjs.js +0 -62
  69. package/dist/modules/build/lib/bundler/server.cjs.js +0 -231
  70. package/dist/modules/build/lib/bundler/transforms.cjs.js +0 -145
  71. package/dist/modules/build/lib/config.cjs.js +0 -94
  72. package/dist/modules/build/lib/entryPoints.cjs.js +0 -49
  73. package/dist/modules/build/lib/ipc/IpcServer.cjs.js +0 -60
  74. package/dist/modules/build/lib/ipc/ServerDataStore.cjs.js +0 -36
  75. package/dist/modules/build/lib/optionsParser.cjs.js +0 -22
  76. package/dist/modules/build/lib/packager/createDistWorkspace.cjs.js +0 -235
  77. package/dist/modules/build/lib/packager/productionPack.cjs.js +0 -160
  78. package/dist/modules/build/lib/publishing.cjs.js +0 -40
  79. package/dist/modules/build/lib/role.cjs.js +0 -24
  80. package/dist/modules/build/lib/runner/runBackend.cjs.js +0 -136
  81. package/dist/modules/build/lib/typeDistProject.cjs.js +0 -89
  82. package/dist/modules/build/lib/urls.cjs.js +0 -13
  83. package/dist/modules/config/commands/docs.cjs.js +0 -63
  84. package/dist/modules/config/commands/print.cjs.js +0 -81
  85. package/dist/modules/config/commands/schema.cjs.js +0 -56
  86. package/dist/modules/config/commands/validate.cjs.js +0 -50
  87. package/dist/modules/config/index.cjs.js +0 -51
  88. package/dist/modules/config/lib/config.cjs.js +0 -94
  89. package/dist/modules/create-github-app/commands/create-github-app/GithubCreateAppServer.cjs.js +0 -127
  90. package/dist/modules/create-github-app/commands/create-github-app/index.cjs.js +0 -126
  91. package/dist/modules/create-github-app/index.cjs.js +0 -19
  92. package/dist/modules/info/commands/info.cjs.js +0 -182
  93. package/dist/modules/info/index.cjs.js +0 -19
  94. package/dist/modules/lint/commands/package/lint.cjs.js +0 -78
  95. package/dist/modules/lint/commands/repo/lint.cjs.js +0 -282
  96. package/dist/modules/lint/index.cjs.js +0 -24
  97. package/dist/modules/lint/lib/optionsParser.cjs.js +0 -22
  98. package/dist/modules/maintenance/commands/repo/fix.cjs.js +0 -426
  99. package/dist/modules/maintenance/commands/repo/list-deprecations.cjs.js +0 -90
  100. package/dist/modules/maintenance/index.cjs.js +0 -24
  101. package/dist/modules/migrate/commands/packageExports.cjs.js +0 -15
  102. package/dist/modules/migrate/commands/packageLintConfigs.cjs.js +0 -77
  103. package/dist/modules/migrate/commands/packageRole.cjs.js +0 -57
  104. package/dist/modules/migrate/commands/packageScripts.cjs.js +0 -87
  105. package/dist/modules/migrate/commands/reactRouterDeps.cjs.js +0 -51
  106. package/dist/modules/migrate/commands/versions/bump.cjs.js +0 -403
  107. package/dist/modules/migrate/commands/versions/migrate.cjs.js +0 -133
  108. package/dist/modules/migrate/index.cjs.js +0 -59
  109. package/dist/modules/migrate/lib/utils.cjs.js +0 -44
  110. package/dist/modules/migrate/lib/versioning/packages.cjs.js +0 -71
  111. package/dist/modules/migrate/lib/versioning/yarn.cjs.js +0 -28
  112. package/dist/modules/new/commands/new.cjs.js +0 -115
  113. package/dist/modules/new/index.cjs.js +0 -40
  114. package/dist/modules/new/lib/codeowners/codeowners.cjs.js +0 -92
  115. package/dist/modules/new/lib/createNewPackage.cjs.js +0 -32
  116. package/dist/modules/new/lib/defaultTemplates.cjs.js +0 -17
  117. package/dist/modules/new/lib/execution/PortableTemplater.cjs.js +0 -89
  118. package/dist/modules/new/lib/execution/executePortableTemplate.cjs.js +0 -66
  119. package/dist/modules/new/lib/execution/installNewPackage.cjs.js +0 -127
  120. package/dist/modules/new/lib/execution/writeTemplateContents.cjs.js +0 -116
  121. package/dist/modules/new/lib/preparation/collectPortableTemplateInput.cjs.js +0 -157
  122. package/dist/modules/new/lib/preparation/loadPortableTemplate.cjs.js +0 -81
  123. package/dist/modules/new/lib/preparation/loadPortableTemplateConfig.cjs.js +0 -132
  124. package/dist/modules/new/lib/preparation/resolvePackageParams.cjs.js +0 -40
  125. package/dist/modules/new/lib/preparation/selectTemplateInteractively.cjs.js +0 -38
  126. package/dist/modules/new/lib/tasks.cjs.js +0 -51
  127. package/dist/modules/new/lib/types.cjs.js +0 -19
  128. package/dist/modules/new/lib/version.cjs.js +0 -91
  129. package/dist/modules/test/commands/package/test.cjs.js +0 -59
  130. package/dist/modules/test/commands/repo/test.cjs.js +0 -299
  131. package/dist/modules/test/index.cjs.js +0 -24
  132. package/dist/modules/translations/commands/export.cjs.js +0 -128
  133. package/dist/modules/translations/commands/import.cjs.js +0 -165
  134. package/dist/modules/translations/index.cjs.js +0 -24
  135. package/dist/modules/translations/lib/discoverPackages.cjs.js +0 -121
  136. package/dist/modules/translations/lib/extractTranslations.cjs.js +0 -71
  137. package/dist/modules/translations/lib/messageFilePath.cjs.js +0 -43
  138. package/dist/packages/backend-defaults/package.json.cjs.js +0 -6
  139. package/dist/packages/backend-plugin-api/package.json.cjs.js +0 -6
  140. package/dist/packages/backend-test-utils/package.json.cjs.js +0 -6
  141. package/dist/packages/catalog-client/package.json.cjs.js +0 -6
  142. package/dist/packages/cli/package.json.cjs.js +0 -159
  143. package/dist/packages/config/package.json.cjs.js +0 -6
  144. package/dist/packages/core-app-api/package.json.cjs.js +0 -6
  145. package/dist/packages/core-components/package.json.cjs.js +0 -6
  146. package/dist/packages/core-plugin-api/package.json.cjs.js +0 -6
  147. package/dist/packages/dev-utils/package.json.cjs.js +0 -6
  148. package/dist/packages/errors/package.json.cjs.js +0 -6
  149. package/dist/packages/frontend-defaults/package.json.cjs.js +0 -6
  150. package/dist/packages/frontend-plugin-api/package.json.cjs.js +0 -6
  151. package/dist/packages/frontend-plugin-api/src/routing/describeParentCallSite.cjs.js +0 -26
  152. package/dist/packages/frontend-test-utils/package.json.cjs.js +0 -6
  153. package/dist/packages/test-utils/package.json.cjs.js +0 -6
  154. package/dist/packages/theme/package.json.cjs.js +0 -6
  155. package/dist/packages/types/package.json.cjs.js +0 -6
  156. package/dist/plugins/auth-backend/package.json.cjs.js +0 -6
  157. package/dist/plugins/auth-backend-module-guest-provider/package.json.cjs.js +0 -6
  158. package/dist/plugins/catalog-node/package.json.cjs.js +0 -6
  159. package/dist/plugins/scaffolder-node/package.json.cjs.js +0 -6
  160. package/dist/plugins/scaffolder-node-test-utils/package.json.cjs.js +0 -6
  161. package/dist/wiring/CommandRegistry.cjs.js +0 -14
  162. package/dist/wiring/factory.cjs.js +0 -15
  163. package/dist/wiring/types.cjs.js +0 -11
  164. package/templates/backend-plugin/.eslintrc.js.hbs +0 -1
  165. package/templates/backend-plugin/README.md.hbs +0 -28
  166. package/templates/backend-plugin/dev/index.ts.hbs +0 -60
  167. package/templates/backend-plugin/package.json.hbs +0 -44
  168. package/templates/backend-plugin/portable-template.yaml +0 -5
  169. package/templates/backend-plugin/src/index.ts.hbs +0 -1
  170. package/templates/backend-plugin/src/plugin.test.ts.hbs +0 -129
  171. package/templates/backend-plugin/src/plugin.ts.hbs +0 -32
  172. package/templates/backend-plugin/src/router.test.ts +0 -67
  173. package/templates/backend-plugin/src/router.ts +0 -51
  174. package/templates/backend-plugin/src/services/TodoListService.ts +0 -155
  175. package/templates/backend-plugin/src/setupTests.ts +0 -1
  176. package/templates/backend-plugin-module/.eslintrc.js.hbs +0 -1
  177. package/templates/backend-plugin-module/README.md.hbs +0 -5
  178. package/templates/backend-plugin-module/package.json.hbs +0 -34
  179. package/templates/backend-plugin-module/portable-template.yaml +0 -5
  180. package/templates/backend-plugin-module/src/index.ts.hbs +0 -8
  181. package/templates/backend-plugin-module/src/module.ts.hbs +0 -17
  182. package/templates/catalog-provider-module/.eslintrc.js.hbs +0 -1
  183. package/templates/catalog-provider-module/README.md.hbs +0 -5
  184. package/templates/catalog-provider-module/config.d.ts.hbs +0 -34
  185. package/templates/catalog-provider-module/package.json.hbs +0 -36
  186. package/templates/catalog-provider-module/portable-template.yaml +0 -9
  187. package/templates/catalog-provider-module/src/index.ts.hbs +0 -8
  188. package/templates/catalog-provider-module/src/module.ts.hbs +0 -29
  189. package/templates/catalog-provider-module/src/provider/readProviderConfigs.ts.hbs +0 -78
  190. package/templates/catalog-provider-module/src/provider/{{providerClass}}.test.ts.hbs +0 -18
  191. package/templates/catalog-provider-module/src/provider/{{providerClass}}.ts.hbs +0 -109
  192. package/templates/frontend-plugin/.eslintrc.js.hbs +0 -1
  193. package/templates/frontend-plugin/README.md.hbs +0 -13
  194. package/templates/frontend-plugin/dev/index.tsx.hbs +0 -11
  195. package/templates/frontend-plugin/package.json.hbs +0 -54
  196. package/templates/frontend-plugin/portable-template.yaml +0 -6
  197. package/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +0 -28
  198. package/templates/frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs +0 -37
  199. package/templates/frontend-plugin/src/components/ExampleComponent/index.ts +0 -1
  200. package/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +0 -19
  201. package/templates/frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs +0 -308
  202. package/templates/frontend-plugin/src/components/ExampleFetchComponent/index.ts +0 -1
  203. package/templates/frontend-plugin/src/index.ts.hbs +0 -1
  204. package/templates/frontend-plugin/src/plugin.test.ts.hbs +0 -7
  205. package/templates/frontend-plugin/src/plugin.ts.hbs +0 -22
  206. package/templates/frontend-plugin/src/routes.ts.hbs +0 -5
  207. package/templates/frontend-plugin/src/setupTests.ts +0 -1
  208. package/templates/new-frontend-plugin/.eslintrc.js.hbs +0 -1
  209. package/templates/new-frontend-plugin/README.md.hbs +0 -20
  210. package/templates/new-frontend-plugin/dev/index.tsx +0 -10
  211. package/templates/new-frontend-plugin/package.json.hbs +0 -49
  212. package/templates/new-frontend-plugin/portable-template.yaml +0 -5
  213. package/templates/new-frontend-plugin/src/components/ExampleComponent/ExampleComponent.test.tsx.hbs +0 -28
  214. package/templates/new-frontend-plugin/src/components/ExampleComponent/ExampleComponent.tsx.hbs +0 -37
  215. package/templates/new-frontend-plugin/src/components/ExampleComponent/index.ts +0 -1
  216. package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx.hbs +0 -19
  217. package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx.hbs +0 -308
  218. package/templates/new-frontend-plugin/src/components/ExampleFetchComponent/index.ts +0 -1
  219. package/templates/new-frontend-plugin/src/index.ts.hbs +0 -1
  220. package/templates/new-frontend-plugin/src/plugin.test.ts.hbs +0 -7
  221. package/templates/new-frontend-plugin/src/plugin.tsx.hbs +0 -25
  222. package/templates/new-frontend-plugin/src/routes.ts +0 -3
  223. package/templates/new-frontend-plugin/src/setupTests.ts +0 -1
  224. package/templates/new-frontend-plugin-module/.eslintrc.js.hbs +0 -1
  225. package/templates/new-frontend-plugin-module/README.md.hbs +0 -5
  226. package/templates/new-frontend-plugin-module/package.json.hbs +0 -35
  227. package/templates/new-frontend-plugin-module/portable-template.yaml +0 -5
  228. package/templates/new-frontend-plugin-module/src/index.ts.hbs +0 -1
  229. package/templates/new-frontend-plugin-module/src/module.tsx.hbs +0 -8
  230. package/templates/new-frontend-plugin-module/src/setupTests.ts +0 -1
  231. package/templates/node-library/.eslintrc.js.hbs +0 -1
  232. package/templates/node-library/README.md.hbs +0 -12
  233. package/templates/node-library/package.json.hbs +0 -29
  234. package/templates/node-library/portable-template.yaml +0 -3
  235. package/templates/node-library/src/index.ts.hbs +0 -1
  236. package/templates/node-library/src/setupTests.ts +0 -1
  237. package/templates/plugin-common-library/.eslintrc.js.hbs +0 -1
  238. package/templates/plugin-common-library/README.md.hbs +0 -5
  239. package/templates/plugin-common-library/package.json.hbs +0 -31
  240. package/templates/plugin-common-library/portable-template.yaml +0 -3
  241. package/templates/plugin-common-library/src/index.ts.hbs +0 -19
  242. package/templates/plugin-common-library/src/setupTests.ts +0 -1
  243. package/templates/plugin-node-library/.eslintrc.js.hbs +0 -1
  244. package/templates/plugin-node-library/README.md.hbs +0 -5
  245. package/templates/plugin-node-library/package.json.hbs +0 -30
  246. package/templates/plugin-node-library/portable-template.yaml +0 -3
  247. package/templates/plugin-node-library/src/index.ts.hbs +0 -18
  248. package/templates/plugin-node-library/src/setupTests.ts +0 -1
  249. package/templates/plugin-web-library/.eslintrc.js.hbs +0 -1
  250. package/templates/plugin-web-library/README.md.hbs +0 -5
  251. package/templates/plugin-web-library/package.json.hbs +0 -42
  252. package/templates/plugin-web-library/portable-template.yaml +0 -3
  253. package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.test.tsx +0 -17
  254. package/templates/plugin-web-library/src/components/ExampleComponent/ExampleComponent.tsx +0 -28
  255. package/templates/plugin-web-library/src/components/ExampleComponent/index.ts +0 -2
  256. package/templates/plugin-web-library/src/components/index.ts +0 -5
  257. package/templates/plugin-web-library/src/hooks/index.ts +0 -5
  258. package/templates/plugin-web-library/src/hooks/useExample/index.ts +0 -1
  259. package/templates/plugin-web-library/src/hooks/useExample/useExample.ts +0 -15
  260. package/templates/plugin-web-library/src/index.ts.hbs +0 -12
  261. package/templates/plugin-web-library/src/setupTests.ts +0 -1
  262. package/templates/scaffolder-backend-module/.eslintrc.js.hbs +0 -1
  263. package/templates/scaffolder-backend-module/README.md.hbs +0 -5
  264. package/templates/scaffolder-backend-module/package.json.hbs +0 -36
  265. package/templates/scaffolder-backend-module/portable-template.yaml +0 -6
  266. package/templates/scaffolder-backend-module/src/actions/example.test.ts +0 -24
  267. package/templates/scaffolder-backend-module/src/actions/example.ts +0 -39
  268. package/templates/scaffolder-backend-module/src/index.ts.hbs +0 -8
  269. package/templates/scaffolder-backend-module/src/module.ts +0 -21
  270. package/templates/web-library/.eslintrc.js.hbs +0 -1
  271. package/templates/web-library/README.md.hbs +0 -12
  272. package/templates/web-library/package.json.hbs +0 -30
  273. package/templates/web-library/portable-template.yaml +0 -3
  274. package/templates/web-library/src/index.ts.hbs +0 -1
  275. package/templates/web-library/src/setupTests.ts +0 -1
  276. /package/dist/{packages/opaque-internal → opaque-internal}/src/OpaqueType.cjs.js +0 -0
@@ -14,18 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- // This script is used to pick up and set the public path of the Webpack bundle
18
- // at runtime. The meta tag is injected by the app build, but only present in
19
- // the `index.html.tmpl` file. The runtime value of the meta tag is populated by
20
- // the app backend, when it templates the final `index.html` file.
21
- //
22
- // This is needed for additional chunks to use the correct public path, and it
23
- // is not possible to set the `__webpack_public_path__` variable outside of the
24
- // build itself. The Webpack output also does not read any <base> tags or
25
- // similar, this seems to be the only way to dynamically configure the public
26
- // path at runtime.
27
- const el = document.querySelector('meta[name="backstage-public-path"]');
28
- const path = el?.getAttribute('content');
29
- if (path) {
30
- __webpack_public_path__ = path;
17
+ try {
18
+ require('@backstage/cli-module-build/config/webpack-public-path');
19
+ } catch (e) {
20
+ if (e.code === 'MODULE_NOT_FOUND') {
21
+ throw new Error(
22
+ '@backstage/cli-module-build is required to use the webpack public path configuration. ' +
23
+ 'Please install it as a dependency.',
24
+ );
25
+ }
26
+ throw e;
31
27
  }
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var OpaqueType = require('../../opaque-internal/src/OpaqueType.cjs.js');
4
+
5
+ const OpaqueCliModule = OpaqueType.OpaqueType.create({
6
+ type: "@backstage/CliModule",
7
+ versions: ["v1"]
8
+ });
9
+
10
+ exports.OpaqueCliModule = OpaqueCliModule;
11
+ //# sourceMappingURL=InternalCliModule.cjs.js.map
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var OpaqueType = require('../../opaque-internal/src/OpaqueType.cjs.js');
4
+
5
+ const OpaqueCommandTreeNode = OpaqueType.OpaqueType.create({
6
+ type: "@backstage/CommandTreeNode",
7
+ versions: ["v1"]
8
+ });
9
+ const OpaqueCommandLeafNode = OpaqueType.OpaqueType.create({
10
+ type: "@backstage/CommandLeafNode",
11
+ versions: ["v1"]
12
+ });
13
+ function isCommandNodeHidden(node) {
14
+ if (OpaqueCommandLeafNode.isType(node)) {
15
+ const { command } = OpaqueCommandLeafNode.toInternal(node);
16
+ return !!command.deprecated || !!command.experimental;
17
+ }
18
+ const { children } = OpaqueCommandTreeNode.toInternal(node);
19
+ return children.every((child) => isCommandNodeHidden(child));
20
+ }
21
+
22
+ exports.OpaqueCommandLeafNode = OpaqueCommandLeafNode;
23
+ exports.OpaqueCommandTreeNode = OpaqueCommandTreeNode;
24
+ exports.isCommandNodeHidden = isCommandNodeHidden;
25
+ //# sourceMappingURL=InternalCommandNode.cjs.js.map
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ const knownBackendPluginIds = [
4
+ "app",
5
+ "auth",
6
+ "catalog",
7
+ "events",
8
+ "kubernetes",
9
+ "notifications",
10
+ "permission",
11
+ "proxy",
12
+ "scaffolder",
13
+ "search",
14
+ "signals",
15
+ "techdocs"
16
+ ];
17
+ const knownFrontendPluginIds = [
18
+ "app",
19
+ "auth",
20
+ "catalog",
21
+ "kubernetes",
22
+ "notifications",
23
+ "scaffolder",
24
+ "search",
25
+ "signals",
26
+ "techdocs"
27
+ ];
28
+ Object.fromEntries(
29
+ knownBackendPluginIds.map((pluginId) => [
30
+ pluginId,
31
+ `@backstage/plugin-${pluginId}-backend`
32
+ ])
33
+ );
34
+ Object.fromEntries(
35
+ knownFrontendPluginIds.map((pluginId) => [
36
+ pluginId,
37
+ `@backstage/plugin-${pluginId}`
38
+ ])
39
+ );
40
+ //# sourceMappingURL=knownPluginPackages.cjs.js.map
package/dist/index.cjs.js CHANGED
@@ -1,20 +1,30 @@
1
1
  'use strict';
2
2
 
3
+ var chalk = require('chalk');
3
4
  var CliInitializer = require('./wiring/CliInitializer.cjs.js');
5
+ var discoverCliModules = require('./wiring/discoverCliModules.cjs.js');
6
+
7
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
8
+
9
+ var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
4
10
 
5
11
  (async () => {
6
12
  const initializer = new CliInitializer.CliInitializer();
7
- initializer.add(import('./modules/build/index.cjs.js'));
8
- initializer.add(import('./modules/config/index.cjs.js'));
9
- initializer.add(import('./modules/create-github-app/index.cjs.js'));
10
- initializer.add(import('./modules/info/index.cjs.js'));
11
- initializer.add(import('./modules/lint/index.cjs.js'));
12
- initializer.add(import('./modules/maintenance/index.cjs.js'));
13
- initializer.add(import('./modules/migrate/index.cjs.js'));
14
- initializer.add(import('./modules/new/index.cjs.js'));
15
- initializer.add(import('./modules/test/index.cjs.js'));
16
- initializer.add(import('./modules/translations/index.cjs.js'));
17
- initializer.add(import('./modules/auth/index.cjs.js'));
13
+ const discoveredModules = discoverCliModules.discoverCliModules();
14
+ if (discoveredModules.length > 0) {
15
+ for (const resolvedPath of discoveredModules) {
16
+ initializer.add(import(resolvedPath));
17
+ }
18
+ } else {
19
+ console.error(
20
+ chalk__default.default.yellow(
21
+ `No CLI modules found in the project root dependencies. Falling back to the built-in set of modules.
22
+ This fallback will be removed in a future release. Please add @backstage/cli-defaults as a devDependency in your root package.json, or install individual @backstage/cli-module-* packages for fine-grained control.
23
+ `
24
+ )
25
+ );
26
+ initializer.add(import('@backstage/cli-defaults'));
27
+ }
18
28
  await initializer.run();
19
29
  })();
20
30
  //# sourceMappingURL=index.cjs.js.map
@@ -1,8 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  var CommandGraph = require('./CommandGraph.cjs.js');
4
- var types$1 = require('./types.cjs.js');
5
- var CommandRegistry = require('./CommandRegistry.cjs.js');
4
+ var InternalCliModule = require('../cli-internal/src/InternalCliModule.cjs.js');
5
+ var InternalCommandNode = require('../cli-internal/src/InternalCommandNode.cjs.js');
6
+ require('node:fs');
7
+ require('node:os');
8
+ require('node:path');
9
+ require('../cli-internal/src/knownPluginPackages.cjs.js');
6
10
  var commander = require('commander');
7
11
  var version = require('./version.cjs.js');
8
12
  var chalk = require('chalk');
@@ -14,36 +18,58 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
14
18
 
15
19
  var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
16
20
 
17
- function isNodeHidden(node) {
18
- if (node.$$type === "@tree/leaf") {
19
- return !!node.command.deprecated || !!node.command.experimental;
20
- }
21
- return node.children.every((child) => isNodeHidden(child));
22
- }
23
21
  class CliInitializer {
24
22
  graph = new CommandGraph.CommandGraph();
25
- commandRegistry = new CommandRegistry.CommandRegistry(this.graph);
26
23
  #uninitiazedFeatures = [];
27
24
  add(feature) {
28
25
  if (types.isPromise(feature)) {
29
26
  this.#uninitiazedFeatures.push(
30
- feature.then((f) => unwrapFeature(f.default))
27
+ feature.then((f) => {
28
+ const unwrapped = unwrapFeature(f.default);
29
+ if (Array.isArray(unwrapped)) {
30
+ return unwrapped.map((m) => ({ feature: m, fromArray: true }));
31
+ }
32
+ return [{ feature: unwrapped, fromArray: false }];
33
+ })
34
+ );
35
+ } else if (Array.isArray(feature)) {
36
+ this.#uninitiazedFeatures.push(
37
+ Promise.resolve(feature.map((m) => ({ feature: m, fromArray: true })))
31
38
  );
32
39
  } else {
33
- this.#uninitiazedFeatures.push(Promise.resolve(feature));
40
+ this.#uninitiazedFeatures.push(
41
+ Promise.resolve([{ feature, fromArray: false }])
42
+ );
34
43
  }
35
44
  }
36
45
  async #register(feature) {
37
- if (types$1.OpaqueCliPlugin.isType(feature)) {
38
- const internal = types$1.OpaqueCliPlugin.toInternal(feature);
39
- await internal.init(this.commandRegistry);
46
+ if (InternalCliModule.OpaqueCliModule.isType(feature)) {
47
+ for (const command of await InternalCliModule.OpaqueCliModule.toInternal(feature).commands) {
48
+ this.graph.add(command, feature);
49
+ }
40
50
  } else {
41
51
  throw new Error(`Unsupported feature type: ${feature.$$type}`);
42
52
  }
43
53
  }
44
54
  async #doInit() {
45
- const features = await Promise.all(this.#uninitiazedFeatures);
46
- for (const feature of features) {
55
+ const resolvedGroups = await Promise.all(this.#uninitiazedFeatures);
56
+ const allFeatures = resolvedGroups.flat();
57
+ const individualPaths = /* @__PURE__ */ new Set();
58
+ for (const { feature, fromArray } of allFeatures) {
59
+ if (!fromArray && InternalCliModule.OpaqueCliModule.isType(feature)) {
60
+ const cmds = await InternalCliModule.OpaqueCliModule.toInternal(feature).commands;
61
+ for (const cmd of cmds) {
62
+ individualPaths.add(cmd.path.join(" "));
63
+ }
64
+ }
65
+ }
66
+ for (const { feature, fromArray } of allFeatures) {
67
+ if (fromArray && InternalCliModule.OpaqueCliModule.isType(feature)) {
68
+ const cmds = await InternalCliModule.OpaqueCliModule.toInternal(feature).commands;
69
+ if (cmds.some((cmd) => individualPaths.has(cmd.path.join(" ")))) {
70
+ continue;
71
+ }
72
+ }
47
73
  await this.#register(feature);
48
74
  }
49
75
  }
@@ -61,27 +87,29 @@ class CliInitializer {
61
87
  }));
62
88
  while (queue.length) {
63
89
  const { node, argParser } = queue.shift();
64
- if (node.$$type === "@tree/root") {
65
- const treeParser = argParser.command(`${node.name} [command]`, {
66
- hidden: isNodeHidden(node)
67
- }).description(node.name);
90
+ if (InternalCommandNode.OpaqueCommandTreeNode.isType(node)) {
91
+ const internal = InternalCommandNode.OpaqueCommandTreeNode.toInternal(node);
92
+ const treeParser = argParser.command(`${internal.name} [command]`, {
93
+ hidden: InternalCommandNode.isCommandNodeHidden(node)
94
+ }).description(internal.name);
68
95
  queue.push(
69
- ...node.children.map((child) => ({
96
+ ...internal.children.map((child) => ({
70
97
  node: child,
71
98
  argParser: treeParser
72
99
  }))
73
100
  );
74
101
  } else {
75
- argParser.command(node.name, {
76
- hidden: !!node.command.deprecated || !!node.command.experimental
77
- }).description(node.command.description).helpOption(false).allowUnknownOption(true).allowExcessArguments(true).action(async () => {
102
+ const internal = InternalCommandNode.OpaqueCommandLeafNode.toInternal(node);
103
+ argParser.command(internal.name, {
104
+ hidden: !!internal.command.deprecated || !!internal.command.experimental
105
+ }).description(internal.command.description).helpOption(false).allowUnknownOption(true).allowExcessArguments(true).action(async () => {
78
106
  try {
79
107
  const args = program.parseOptions(process.argv);
80
108
  const nonProcessArgs = args.operands.slice(2);
81
109
  const positionalArgs = [];
82
110
  let index = 0;
83
111
  for (let argIndex = 0; argIndex < nonProcessArgs.length; argIndex++) {
84
- if (argIndex === index && node.command.path[argIndex] === nonProcessArgs[argIndex]) {
112
+ if (argIndex === index && internal.command.path[argIndex] === nonProcessArgs[argIndex]) {
85
113
  index += 1;
86
114
  continue;
87
115
  }
@@ -90,14 +118,14 @@ class CliInitializer {
90
118
  const context = {
91
119
  args: [...positionalArgs, ...args.unknown],
92
120
  info: {
93
- usage: [programName, ...node.command.path].join(" "),
94
- description: node.command.description
121
+ usage: [programName, ...internal.command.path].join(" "),
122
+ name: internal.command.path.join(" ")
95
123
  }
96
124
  };
97
- if (typeof node.command.execute === "function") {
98
- await node.command.execute(context);
125
+ if (typeof internal.command.execute === "function") {
126
+ await internal.command.execute(context);
99
127
  } else {
100
- const mod = await node.command.execute.loader();
128
+ const mod = await internal.command.execute.loader();
101
129
  const fn = typeof mod.default === "function" ? mod.default : mod.default.default;
102
130
  await fn(context);
103
131
  }
@@ -122,6 +150,9 @@ class CliInitializer {
122
150
  }
123
151
  }
124
152
  function unwrapFeature(feature) {
153
+ if (Array.isArray(feature)) {
154
+ return feature;
155
+ }
125
156
  if ("$$type" in feature) {
126
157
  return feature;
127
158
  }
@@ -1,38 +1,66 @@
1
1
  'use strict';
2
2
 
3
+ var InternalCliModule = require('../cli-internal/src/InternalCliModule.cjs.js');
4
+ var InternalCommandNode = require('../cli-internal/src/InternalCommandNode.cjs.js');
5
+ require('node:fs');
6
+ require('node:os');
7
+ require('node:path');
8
+ require('../cli-internal/src/knownPluginPackages.cjs.js');
9
+
3
10
  class CommandGraph {
4
11
  graph = [];
5
12
  /**
6
13
  * Adds a command to the graph. The graph is sparse, so we use the path to determine the nodes
7
14
  * to traverse. Only leaf nodes should have a command/action.
8
15
  */
9
- add(command) {
16
+ add(command, module) {
10
17
  const path = command.path;
11
18
  let current = this.graph;
12
19
  for (let i = 0; i < path.length - 1; i++) {
13
20
  const name = path[i];
14
- let next = current.find((n) => n.name === name);
21
+ let next = current.find(
22
+ (n) => InternalCommandNode.OpaqueCommandTreeNode.isType(n) && InternalCommandNode.OpaqueCommandTreeNode.toInternal(n).name === name || InternalCommandNode.OpaqueCommandLeafNode.isType(n) && InternalCommandNode.OpaqueCommandLeafNode.toInternal(n).name === name
23
+ );
15
24
  if (!next) {
16
- next = { $$type: "@tree/root", name, children: [] };
25
+ next = InternalCommandNode.OpaqueCommandTreeNode.createInstance("v1", {
26
+ name,
27
+ children: []
28
+ });
17
29
  current.push(next);
18
- } else if (next.$$type === "@tree/leaf") {
30
+ } else if (InternalCommandNode.OpaqueCommandLeafNode.isType(next)) {
19
31
  throw new Error(
20
- `Command already exists at path: "${path.slice(0, i).join(" ")}"`
32
+ formatConflictError(
33
+ path,
34
+ module,
35
+ InternalCommandNode.OpaqueCommandLeafNode.toInternal(next).module
36
+ )
21
37
  );
22
38
  }
23
- current = next.children;
39
+ current = InternalCommandNode.OpaqueCommandTreeNode.toInternal(next).children;
24
40
  }
25
- const last = current.find((n) => n.name === path[path.length - 1]);
26
- if (last && last.$$type === "@tree/leaf") {
41
+ const lastName = path[path.length - 1];
42
+ const last = current.find((n) => {
43
+ if (InternalCommandNode.OpaqueCommandTreeNode.isType(n)) {
44
+ return InternalCommandNode.OpaqueCommandTreeNode.toInternal(n).name === lastName;
45
+ }
46
+ return InternalCommandNode.OpaqueCommandLeafNode.toInternal(n).name === lastName;
47
+ });
48
+ if (last && InternalCommandNode.OpaqueCommandLeafNode.isType(last)) {
27
49
  throw new Error(
28
- `Command already exists at path: "${path.slice(0, -1).join(" ")}"`
50
+ formatConflictError(
51
+ path,
52
+ module,
53
+ InternalCommandNode.OpaqueCommandLeafNode.toInternal(last).module
54
+ )
29
55
  );
30
56
  } else {
31
- current.push({
32
- $$type: "@tree/leaf",
33
- name: path[path.length - 1],
34
- command
35
- });
57
+ current.push(
58
+ InternalCommandNode.OpaqueCommandLeafNode.createInstance("v1", {
59
+ name: lastName,
60
+ command,
61
+ module
62
+ })
63
+ );
36
64
  }
37
65
  }
38
66
  /**
@@ -42,30 +70,60 @@ class CommandGraph {
42
70
  let current = this.graph;
43
71
  for (let i = 0; i < path.length - 1; i++) {
44
72
  const name = path[i];
45
- const next = current.find((n) => n.name === name);
46
- if (!next) {
47
- return void 0;
48
- } else if (next.$$type === "@tree/leaf") {
73
+ const next = current.find((n) => {
74
+ if (InternalCommandNode.OpaqueCommandTreeNode.isType(n)) {
75
+ return InternalCommandNode.OpaqueCommandTreeNode.toInternal(n).name === name;
76
+ }
77
+ return InternalCommandNode.OpaqueCommandLeafNode.toInternal(n).name === name;
78
+ });
79
+ if (!next || InternalCommandNode.OpaqueCommandLeafNode.isType(next)) {
49
80
  return void 0;
50
81
  }
51
- current = next.children;
82
+ current = InternalCommandNode.OpaqueCommandTreeNode.toInternal(next).children;
52
83
  }
53
- const last = current.find((n) => n.name === path[path.length - 1]);
54
- if (!last || last.$$type === "@tree/root") {
84
+ const lastName = path[path.length - 1];
85
+ const last = current.find((n) => {
86
+ if (InternalCommandNode.OpaqueCommandTreeNode.isType(n)) {
87
+ return InternalCommandNode.OpaqueCommandTreeNode.toInternal(n).name === lastName;
88
+ }
89
+ return InternalCommandNode.OpaqueCommandLeafNode.toInternal(n).name === lastName;
90
+ });
91
+ if (!last || InternalCommandNode.OpaqueCommandTreeNode.isType(last)) {
55
92
  return void 0;
56
93
  }
57
- return last?.command;
94
+ return InternalCommandNode.OpaqueCommandLeafNode.toInternal(last).command;
58
95
  }
59
96
  atDepth(depth) {
60
97
  let current = this.graph;
61
98
  for (let i = 0; i < depth; i++) {
62
99
  current = current.flatMap(
63
- (n) => n.$$type === "@tree/root" ? n.children : []
100
+ (n) => InternalCommandNode.OpaqueCommandTreeNode.isType(n) ? InternalCommandNode.OpaqueCommandTreeNode.toInternal(n).children : []
64
101
  );
65
102
  }
66
103
  return current;
67
104
  }
68
105
  }
106
+ function getModuleName(module) {
107
+ if (module && InternalCliModule.OpaqueCliModule.isType(module)) {
108
+ return InternalCliModule.OpaqueCliModule.toInternal(module).packageName;
109
+ }
110
+ return void 0;
111
+ }
112
+ function formatConflictError(path, newModule, existingModule) {
113
+ const cmd = path.join(" ");
114
+ const newPkg = getModuleName(newModule);
115
+ const existingPkg = getModuleName(existingModule);
116
+ if (newPkg && existingPkg) {
117
+ return `Command "${cmd}" from "${newPkg}" conflicts with an existing command from "${existingPkg}"`;
118
+ }
119
+ if (newPkg) {
120
+ return `Command "${cmd}" from "${newPkg}" conflicts with an existing command`;
121
+ }
122
+ if (existingPkg) {
123
+ return `Command "${cmd}" conflicts with an existing command from "${existingPkg}"`;
124
+ }
125
+ return `Command "${cmd}" conflicts with an existing command`;
126
+ }
69
127
 
70
128
  exports.CommandGraph = CommandGraph;
71
129
  //# sourceMappingURL=CommandGraph.cjs.js.map
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ var cliCommon = require('@backstage/cli-common');
4
+ var cliNode = require('@backstage/cli-node');
5
+ var fs = require('node:fs');
6
+ var path = require('node:path');
7
+ var node_url = require('node:url');
8
+
9
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
+
11
+ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
12
+
13
+ function discoverCliModules() {
14
+ const rootDir = cliCommon.targetPaths.rootDir;
15
+ const pkgJsonPath = path.resolve(rootDir, "package.json");
16
+ let projectPkg;
17
+ try {
18
+ projectPkg = JSON.parse(fs__default.default.readFileSync(pkgJsonPath, "utf8"));
19
+ } catch {
20
+ return [];
21
+ }
22
+ const allDeps = {
23
+ ...projectPkg.dependencies,
24
+ ...projectPkg.devDependencies
25
+ };
26
+ const modules = [];
27
+ for (const depName of Object.keys(allDeps)) {
28
+ try {
29
+ const depPkgPath = require.resolve(`${depName}/package.json`, {
30
+ paths: [rootDir]
31
+ });
32
+ const depPkg = JSON.parse(fs__default.default.readFileSync(depPkgPath, "utf8"));
33
+ if (cliNode.PackageRoles.getRoleFromPackage(depPkg) === "cli-module") {
34
+ const resolvedPath = require.resolve(depName, { paths: [rootDir] });
35
+ modules.push(node_url.pathToFileURL(resolvedPath).href);
36
+ }
37
+ } catch {
38
+ }
39
+ }
40
+ return modules;
41
+ }
42
+
43
+ exports.discoverCliModules = discoverCliModules;
44
+ //# sourceMappingURL=discoverCliModules.cjs.js.map