@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
@@ -1,165 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var cleye = require('cleye');
6
- var cliCommon = require('@backstage/cli-common');
7
- var fs = require('fs-extra');
8
- var path = require('node:path');
9
- var discoverPackages = require('../lib/discoverPackages.cjs.js');
10
- var messageFilePath = require('../lib/messageFilePath.cjs.js');
11
-
12
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
13
-
14
- var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
15
-
16
- var _import = async ({ args, info }) => {
17
- const {
18
- flags: { input, output }
19
- } = cleye.cli(
20
- {
21
- help: info,
22
- booleanFlagNegation: true,
23
- flags: {
24
- input: {
25
- type: String,
26
- default: "translations",
27
- description: "Input directory containing the manifest and translated message files"
28
- },
29
- output: {
30
- type: String,
31
- default: "src/translations/resources.ts",
32
- description: "Output path for the generated wiring module"
33
- }
34
- }
35
- },
36
- void 0,
37
- args
38
- );
39
- const options = { input, output };
40
- await discoverPackages.readTargetPackage(cliCommon.targetPaths.dir, cliCommon.targetPaths.rootDir);
41
- const inputDir = path.resolve(cliCommon.targetPaths.dir, options.input);
42
- const manifestPath = path.resolve(inputDir, "manifest.json");
43
- const outputPath = path.resolve(cliCommon.targetPaths.dir, options.output);
44
- if (!await fs__default.default.pathExists(manifestPath)) {
45
- throw new Error(
46
- `No manifest.json found at ${manifestPath}. Run "backstage-cli translations export" first.`
47
- );
48
- }
49
- const manifest = await fs__default.default.readJson(manifestPath);
50
- if (!manifest.pattern) {
51
- throw new Error(
52
- 'No pattern found in manifest.json. Re-run "backstage-cli translations export" to regenerate it.'
53
- );
54
- }
55
- const pattern = manifest.pattern;
56
- const parsePath = messageFilePath.createMessagePathParser(pattern);
57
- const allFiles = (await collectJsonFiles(inputDir)).filter(
58
- (f) => f !== "manifest.json"
59
- );
60
- const translationsByRef = /* @__PURE__ */ new Map();
61
- let skipped = 0;
62
- for (const relPath of allFiles) {
63
- const parsed = parsePath(relPath);
64
- if (!parsed) {
65
- skipped++;
66
- continue;
67
- }
68
- if (parsed.lang === messageFilePath.DEFAULT_LANGUAGE) {
69
- continue;
70
- }
71
- if (!manifest.refs[parsed.id]) {
72
- console.warn(
73
- ` Warning: skipping ${relPath} - ref '${parsed.id}' not found in manifest`
74
- );
75
- continue;
76
- }
77
- const existing = translationsByRef.get(parsed.id) ?? [];
78
- existing.push({ lang: parsed.lang, relPath });
79
- translationsByRef.set(parsed.id, existing);
80
- }
81
- if (skipped > 0) {
82
- console.warn(
83
- ` Warning: ${skipped} file(s) did not match the pattern '${pattern}'`
84
- );
85
- }
86
- if (translationsByRef.size === 0) {
87
- console.log("No translated message files found.");
88
- const example = messageFilePath.formatMessagePath(pattern, "<ref-id>", "sv");
89
- console.log(
90
- `Add translated files as ${example} in the translations directory.`
91
- );
92
- return;
93
- }
94
- const importLines = [];
95
- const resourceLines = [];
96
- importLines.push(
97
- "import { createTranslationResource } from '@backstage/frontend-plugin-api';"
98
- );
99
- for (const [refId, entries] of [...translationsByRef.entries()].sort(
100
- ([a], [b]) => a.localeCompare(b)
101
- )) {
102
- const refEntry = manifest.refs[refId];
103
- const importPath = refEntry.exportPath === "." ? refEntry.package : `${refEntry.package}/${refEntry.exportPath.replace(/^\.\//, "")}`;
104
- importLines.push(`import { ${refEntry.exportName} } from '${importPath}';`);
105
- const translationEntries = entries.sort((a, b) => a.lang.localeCompare(b.lang)).map(({ lang, relPath }) => {
106
- const jsonRelPath = path.relative(
107
- path.resolve(outputPath, ".."),
108
- path.resolve(inputDir, relPath)
109
- ).split(path.sep).join("/");
110
- return ` ${JSON.stringify(lang)}: () => import('./${jsonRelPath}'),`;
111
- }).join("\n");
112
- resourceLines.push(
113
- [
114
- ` createTranslationResource({`,
115
- ` ref: ${refEntry.exportName},`,
116
- ` translations: {`,
117
- translationEntries,
118
- ` },`,
119
- ` }),`
120
- ].join("\n")
121
- );
122
- }
123
- const fileContent = [
124
- "// This file is auto-generated by backstage-cli translations import",
125
- "// Do not edit manually.",
126
- "",
127
- ...importLines,
128
- "",
129
- "export default [",
130
- ...resourceLines,
131
- "];",
132
- ""
133
- ].join("\n");
134
- await fs__default.default.ensureDir(path.resolve(outputPath, ".."));
135
- await fs__default.default.writeFile(outputPath, fileContent, "utf8");
136
- const totalFiles = [...translationsByRef.values()].reduce(
137
- (sum, e) => sum + e.length,
138
- 0
139
- );
140
- console.log(`Generated translation resources at ${options.output}`);
141
- console.log(
142
- ` ${translationsByRef.size} ref(s), ${totalFiles} translation file(s)`
143
- );
144
- console.log(
145
- "\nImport this file in your app and pass the resources to your translation API setup."
146
- );
147
- };
148
- async function collectJsonFiles(dir, prefix = "") {
149
- const entries = await fs__default.default.readdir(dir, { withFileTypes: true });
150
- const results = [];
151
- for (const entry of entries) {
152
- const relPath = prefix ? `${prefix}/${entry.name}` : entry.name;
153
- if (entry.isDirectory()) {
154
- results.push(
155
- ...await collectJsonFiles(path.resolve(dir, entry.name), relPath)
156
- );
157
- } else if (entry.isFile() && entry.name.endsWith(".json")) {
158
- results.push(relPath);
159
- }
160
- }
161
- return results;
162
- }
163
-
164
- exports.default = _import;
165
- //# sourceMappingURL=import.cjs.js.map
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var factory = require('../../wiring/factory.cjs.js');
6
-
7
- var index = factory.createCliPlugin({
8
- pluginId: "translations",
9
- init: async (reg) => {
10
- reg.addCommand({
11
- path: ["translations", "export"],
12
- description: "Export translation messages from an app and all of its frontend plugins to JSON files",
13
- execute: { loader: () => import('./commands/export.cjs.js') }
14
- });
15
- reg.addCommand({
16
- path: ["translations", "import"],
17
- description: "Generate translation resource wiring from translated JSON files",
18
- execute: { loader: () => import('./commands/import.cjs.js') }
19
- });
20
- }
21
- });
22
-
23
- exports.default = index;
24
- //# sourceMappingURL=index.cjs.js.map
@@ -1,121 +0,0 @@
1
- 'use strict';
2
-
3
- var cliNode = require('@backstage/cli-node');
4
- var path = require('node:path');
5
- var fs = require('fs-extra');
6
-
7
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
8
-
9
- var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
10
-
11
- async function readTargetPackage(packageDir, repoRoot) {
12
- const packageJsonPath = path.resolve(packageDir, "package.json");
13
- if (!await fs__default.default.pathExists(packageJsonPath)) {
14
- throw new Error(
15
- "No package.json found in the current directory. The translations commands must be run from within a package directory."
16
- );
17
- }
18
- if (path.resolve(packageDir) === path.resolve(repoRoot)) {
19
- throw new Error(
20
- "The translations commands must be run from within a package directory, not from the repository root. For example: cd packages/app && backstage-cli translations export"
21
- );
22
- }
23
- return fs__default.default.readJson(packageJsonPath);
24
- }
25
- async function discoverFrontendPackages(targetPackageJson, targetDir) {
26
- let workspaceByName;
27
- try {
28
- const workspacePackages = await cliNode.PackageGraph.listTargetPackages();
29
- workspaceByName = new Map(
30
- workspacePackages.map((p) => [p.packageJson.name, p])
31
- );
32
- } catch {
33
- workspaceByName = /* @__PURE__ */ new Map();
34
- }
35
- const visited = /* @__PURE__ */ new Set();
36
- const result = [];
37
- async function visit(packageJson, pkgDir, includeDevDeps) {
38
- const deps = {
39
- ...packageJson.dependencies,
40
- ...includeDevDeps ? packageJson.devDependencies ?? {} : {}
41
- };
42
- for (const depName of Object.keys(deps)) {
43
- if (visited.has(depName)) {
44
- continue;
45
- }
46
- visited.add(depName);
47
- let depPkgJson;
48
- let depDir;
49
- let isWorkspace;
50
- const workspacePkg = workspaceByName.get(depName);
51
- if (workspacePkg) {
52
- depPkgJson = workspacePkg.packageJson;
53
- depDir = workspacePkg.dir;
54
- isWorkspace = true;
55
- } else {
56
- try {
57
- const pkgJsonPath = require.resolve(`${depName}/package.json`, {
58
- paths: [pkgDir]
59
- });
60
- depPkgJson = await fs__default.default.readJson(pkgJsonPath);
61
- depDir = path.dirname(pkgJsonPath);
62
- isWorkspace = false;
63
- } catch {
64
- continue;
65
- }
66
- }
67
- if (!depPkgJson.backstage) {
68
- continue;
69
- }
70
- const role = depPkgJson.backstage?.role;
71
- if (role && isFrontendRole(role)) {
72
- const entryPoints = resolveEntryPoints(depPkgJson, depDir, isWorkspace);
73
- if (entryPoints.size > 0) {
74
- result.push({ name: depName, dir: depDir, entryPoints });
75
- }
76
- }
77
- await visit(depPkgJson, depDir, false);
78
- }
79
- }
80
- await visit(targetPackageJson, targetDir, true);
81
- return result;
82
- }
83
- function resolveEntryPoints(packageJson, packageDir, isWorkspace) {
84
- const entryPoints = /* @__PURE__ */ new Map();
85
- const exports$1 = packageJson.exports;
86
- if (exports$1) {
87
- for (const [subpath, target] of Object.entries(exports$1)) {
88
- if (subpath === "./package.json") {
89
- continue;
90
- }
91
- let filePath;
92
- if (typeof target === "string") {
93
- filePath = target;
94
- } else if (isWorkspace) {
95
- filePath = target?.import ?? target?.types ?? target?.default;
96
- } else {
97
- filePath = target?.types ?? target?.import ?? target?.default;
98
- }
99
- if (typeof filePath === "string") {
100
- entryPoints.set(subpath, path.resolve(packageDir, filePath));
101
- }
102
- }
103
- } else {
104
- const main = isWorkspace ? packageJson.main ?? packageJson.types : packageJson.types ?? packageJson.main;
105
- if (main) {
106
- entryPoints.set(".", path.resolve(packageDir, main));
107
- }
108
- }
109
- return entryPoints;
110
- }
111
- function isFrontendRole(role) {
112
- try {
113
- return cliNode.PackageRoles.getRoleInfo(role).platform === "web";
114
- } catch {
115
- return false;
116
- }
117
- }
118
-
119
- exports.discoverFrontendPackages = discoverFrontendPackages;
120
- exports.readTargetPackage = readTargetPackage;
121
- //# sourceMappingURL=discoverPackages.cjs.js.map
@@ -1,71 +0,0 @@
1
- 'use strict';
2
-
3
- var tsMorph = require('ts-morph');
4
-
5
- function extractTranslationRefsFromSourceFile(sourceFile, packageName, exportPath) {
6
- const results = [];
7
- for (const exportSymbol of sourceFile.getExportSymbols()) {
8
- const declarations = exportSymbol.getDeclarations();
9
- if (declarations.length === 0) {
10
- continue;
11
- }
12
- const declaration = declarations[0];
13
- const exportType = declaration.getType();
14
- const refInfo = extractTranslationRefFromType(exportType, declaration);
15
- if (!refInfo) {
16
- continue;
17
- }
18
- results.push({
19
- ...refInfo,
20
- packageName,
21
- exportPath,
22
- exportName: exportSymbol.getName()
23
- });
24
- }
25
- return results;
26
- }
27
- function extractTranslationRefFromType(type, declaration) {
28
- const resolvedType = type.getTargetType() ?? type;
29
- const $$typeProperty = resolvedType.getProperties().find((p) => p.getName() === "$$type");
30
- if (!$$typeProperty) {
31
- return void 0;
32
- }
33
- const $$typeDecl = $$typeProperty.getValueDeclaration();
34
- if (!$$typeDecl) {
35
- return void 0;
36
- }
37
- if (!$$typeDecl.getText().includes("'@backstage/TranslationRef'")) {
38
- return void 0;
39
- }
40
- const typeArgs = type.getTypeArguments();
41
- if (typeArgs.length < 2) {
42
- return void 0;
43
- }
44
- const [idType, messagesType] = typeArgs;
45
- if (!idType.isStringLiteral()) {
46
- return void 0;
47
- }
48
- const id = idType.getLiteralValueOrThrow();
49
- const messages = {};
50
- for (const messageProp of messagesType.getProperties()) {
51
- const key = messageProp.getName();
52
- const propType = messageProp.getTypeAtLocation(declaration);
53
- if (propType.isStringLiteral()) {
54
- messages[key] = propType.getLiteralValueOrThrow();
55
- }
56
- }
57
- if (Object.keys(messages).length === 0) {
58
- return void 0;
59
- }
60
- return { id, messages };
61
- }
62
- function createTranslationProject(tsconfigPath) {
63
- return new tsMorph.Project({
64
- tsConfigFilePath: tsconfigPath,
65
- skipAddingFilesFromTsConfig: true
66
- });
67
- }
68
-
69
- exports.createTranslationProject = createTranslationProject;
70
- exports.extractTranslationRefsFromSourceFile = extractTranslationRefsFromSourceFile;
71
- //# sourceMappingURL=extractTranslations.cjs.js.map
@@ -1,43 +0,0 @@
1
- 'use strict';
2
-
3
- const DEFAULT_LANGUAGE = "en";
4
- const DEFAULT_MESSAGE_PATTERN = "messages/{id}.{lang}.json";
5
- function formatMessagePath(pattern, id, lang) {
6
- return pattern.replace(/\{id\}/g, id).replace(/\{lang\}/g, lang);
7
- }
8
- function createMessagePathParser(pattern) {
9
- validatePattern(pattern);
10
- const escaped = pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\\{id\\}/g, "(?<id>[^/]+)").replace(/\\{lang\\}/g, "(?<lang>[a-z]{2})");
11
- const regex = new RegExp(`^${escaped}$`);
12
- return (relPath) => {
13
- const match = relPath.match(regex);
14
- if (!match?.groups) {
15
- return void 0;
16
- }
17
- return { id: match.groups.id, lang: match.groups.lang };
18
- };
19
- }
20
- function validatePattern(pattern) {
21
- if (!pattern.includes("{id}")) {
22
- throw new Error(
23
- `Invalid message file pattern: must contain {id} placeholder. Got: ${pattern}`
24
- );
25
- }
26
- if (!pattern.includes("{lang}")) {
27
- throw new Error(
28
- `Invalid message file pattern: must contain {lang} placeholder. Got: ${pattern}`
29
- );
30
- }
31
- if (!pattern.endsWith(".json")) {
32
- throw new Error(
33
- `Invalid message file pattern: must end with .json. Got: ${pattern}`
34
- );
35
- }
36
- }
37
-
38
- exports.DEFAULT_LANGUAGE = DEFAULT_LANGUAGE;
39
- exports.DEFAULT_MESSAGE_PATTERN = DEFAULT_MESSAGE_PATTERN;
40
- exports.createMessagePathParser = createMessagePathParser;
41
- exports.formatMessagePath = formatMessagePath;
42
- exports.validatePattern = validatePattern;
43
- //# sourceMappingURL=messageFilePath.cjs.js.map
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "0.16.0-next.2";
4
-
5
- exports.version = version;
6
- //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "1.8.0-next.1";
4
-
5
- exports.version = version;
6
- //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "1.11.1-next.2";
4
-
5
- exports.version = version;
6
- //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "1.14.0-next.2";
4
-
5
- exports.version = version;
6
- //# sourceMappingURL=package.json.cjs.js.map
@@ -1,159 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "0.36.0-next.2";
4
- var dependencies = {
5
- "@backstage/catalog-model": "workspace:^",
6
- "@backstage/cli-common": "workspace:^",
7
- "@backstage/cli-node": "workspace:^",
8
- "@backstage/config": "workspace:^",
9
- "@backstage/config-loader": "workspace:^",
10
- "@backstage/errors": "workspace:^",
11
- "@backstage/eslint-plugin": "workspace:^",
12
- "@backstage/integration": "workspace:^",
13
- "@backstage/module-federation-common": "workspace:^",
14
- "@backstage/release-manifests": "workspace:^",
15
- "@backstage/types": "workspace:^",
16
- "@manypkg/get-packages": "^1.1.3",
17
- "@module-federation/enhanced": "^0.21.6",
18
- "@octokit/request": "^8.0.0",
19
- "@rollup/plugin-commonjs": "^26.0.0",
20
- "@rollup/plugin-json": "^6.0.0",
21
- "@rollup/plugin-node-resolve": "^15.0.0",
22
- "@rollup/plugin-yaml": "^4.0.0",
23
- "@rspack/core": "^1.4.11",
24
- "@rspack/dev-server": "^1.1.4",
25
- "@rspack/plugin-react-refresh": "^1.4.3",
26
- "@spotify/eslint-config-base": "^15.0.0",
27
- "@spotify/eslint-config-react": "^15.0.0",
28
- "@spotify/eslint-config-typescript": "^15.0.0",
29
- "@swc/core": "^1.15.6",
30
- "@swc/helpers": "^0.5.17",
31
- "@swc/jest": "^0.2.39",
32
- "@types/webpack-env": "^1.15.2",
33
- "@typescript-eslint/eslint-plugin": "^8.17.0",
34
- "@typescript-eslint/parser": "^8.16.0",
35
- bfj: "^9.0.2",
36
- buffer: "^6.0.3",
37
- chalk: "^4.0.0",
38
- chokidar: "^3.3.1",
39
- cleye: "^2.3.0",
40
- commander: "^14.0.3",
41
- "cross-fetch": "^4.0.0",
42
- "cross-spawn": "^7.0.3",
43
- "css-loader": "^6.5.1",
44
- "ctrlc-windows": "^2.1.0",
45
- esbuild: "^0.27.0",
46
- eslint: "^8.6.0",
47
- "eslint-config-prettier": "^9.0.0",
48
- "eslint-formatter-friendly": "^7.0.0",
49
- "eslint-plugin-deprecation": "^3.0.0",
50
- "eslint-plugin-import": "^2.31.0",
51
- "eslint-plugin-jest": "^28.9.0",
52
- "eslint-plugin-jsx-a11y": "^6.10.2",
53
- "eslint-plugin-react": "^7.37.2",
54
- "eslint-plugin-react-hooks": "^5.0.0",
55
- "eslint-plugin-unused-imports": "^4.1.4",
56
- "eslint-rspack-plugin": "^4.2.1",
57
- express: "^4.22.0",
58
- "fs-extra": "^11.2.0",
59
- "git-url-parse": "^15.0.0",
60
- glob: "^7.1.7",
61
- "global-agent": "^3.0.0",
62
- globby: "^11.1.0",
63
- handlebars: "^4.7.3",
64
- "html-webpack-plugin": "^5.6.3",
65
- inquirer: "^8.2.0",
66
- "jest-css-modules": "^2.1.0",
67
- "json-schema": "^0.4.0",
68
- lodash: "^4.17.21",
69
- minimatch: "^10.2.1",
70
- "node-stdlib-browser": "^1.3.1",
71
- "npm-packlist": "^5.0.0",
72
- ora: "^5.3.0",
73
- "p-queue": "^6.6.2",
74
- pirates: "^4.0.6",
75
- postcss: "^8.1.0",
76
- "postcss-import": "^16.1.0",
77
- process: "^0.11.10",
78
- "proper-lockfile": "^4.1.2",
79
- "raw-loader": "^4.0.2",
80
- "react-dev-utils": "^12.0.0-next.60",
81
- "react-refresh": "^0.18.0",
82
- "recursive-readdir": "^2.2.2",
83
- "replace-in-file": "^7.1.0",
84
- rollup: "^4.27.3",
85
- "rollup-plugin-dts": "^6.1.0",
86
- "rollup-plugin-esbuild": "^6.1.1",
87
- "rollup-plugin-postcss": "^4.0.0",
88
- "rollup-pluginutils": "^2.8.2",
89
- semver: "^7.5.3",
90
- "shell-quote": "^1.8.1",
91
- "style-loader": "^3.3.1",
92
- sucrase: "^3.20.2",
93
- "swc-loader": "^0.2.3",
94
- tar: "^7.5.6",
95
- "ts-checker-rspack-plugin": "^1.1.5",
96
- "ts-morph": "^24.0.0",
97
- undici: "^7.2.3",
98
- util: "^0.12.3",
99
- yaml: "^2.0.0",
100
- yargs: "^16.2.0",
101
- "yml-loader": "^2.1.0",
102
- yn: "^4.0.0",
103
- zod: "^3.25.76",
104
- "zod-validation-error": "^4.0.2"
105
- };
106
- var devDependencies = {
107
- "@backstage/backend-plugin-api": "workspace:^",
108
- "@backstage/backend-test-utils": "workspace:^",
109
- "@backstage/catalog-client": "workspace:^",
110
- "@backstage/config": "workspace:^",
111
- "@backstage/core-app-api": "workspace:^",
112
- "@backstage/core-components": "workspace:^",
113
- "@backstage/core-plugin-api": "workspace:^",
114
- "@backstage/dev-utils": "workspace:^",
115
- "@backstage/errors": "workspace:^",
116
- "@backstage/plugin-auth-backend": "workspace:^",
117
- "@backstage/plugin-auth-backend-module-guest-provider": "workspace:^",
118
- "@backstage/plugin-catalog-node": "workspace:^",
119
- "@backstage/plugin-scaffolder-node": "workspace:^",
120
- "@backstage/plugin-scaffolder-node-test-utils": "workspace:^",
121
- "@backstage/test-utils": "workspace:^",
122
- "@backstage/theme": "workspace:^",
123
- "@jest/environment-jsdom-abstract": "^30.0.0",
124
- "@pmmmwh/react-refresh-webpack-plugin": "^0.6.0",
125
- "@types/cross-spawn": "^6.0.2",
126
- "@types/ejs": "^3.1.3",
127
- "@types/express": "^4.17.6",
128
- "@types/fs-extra": "^11.0.0",
129
- "@types/http-proxy": "^1.17.4",
130
- "@types/inquirer": "^8.1.3",
131
- "@types/jest": "^30.0.0",
132
- "@types/node": "^22.13.14",
133
- "@types/npm-packlist": "^3.0.0",
134
- "@types/proper-lockfile": "^4",
135
- "@types/recursive-readdir": "^2.2.0",
136
- "@types/rollup-plugin-peer-deps-external": "^2.2.0",
137
- "@types/rollup-plugin-postcss": "^3.1.4",
138
- "@types/shell-quote": "^1.7.5",
139
- "@types/svgo": "^2.6.2",
140
- "@types/terser-webpack-plugin": "^5.0.4",
141
- "@types/webpack-sources": "^3.2.3",
142
- del: "^8.0.0",
143
- "esbuild-loader": "^4.0.0",
144
- "eslint-webpack-plugin": "^4.2.0",
145
- "fork-ts-checker-webpack-plugin": "^9.0.0",
146
- jest: "^30.2.0",
147
- jsdom: "^27.1.0",
148
- "mini-css-extract-plugin": "^2.4.2",
149
- msw: "^1.0.0",
150
- nodemon: "^3.0.1",
151
- "terser-webpack-plugin": "^5.1.3",
152
- webpack: "~5.105.0",
153
- "webpack-dev-server": "^5.0.0"
154
- };
155
-
156
- exports.dependencies = dependencies;
157
- exports.devDependencies = devDependencies;
158
- exports.version = version;
159
- //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "1.3.6";
4
-
5
- exports.version = version;
6
- //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "1.19.6-next.1";
4
-
5
- exports.version = version;
6
- //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "0.18.8-next.1";
4
-
5
- exports.version = version;
6
- //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "1.12.4-next.1";
4
-
5
- exports.version = version;
6
- //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "1.1.21-next.1";
4
-
5
- exports.version = version;
6
- //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "1.2.7";
4
-
5
- exports.version = version;
6
- //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "0.5.0-next.1";
4
-
5
- exports.version = version;
6
- //# sourceMappingURL=package.json.cjs.js.map
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var version = "0.15.0-next.1";
4
-
5
- exports.version = version;
6
- //# sourceMappingURL=package.json.cjs.js.map