@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
@@ -1,400 +0,0 @@
1
- 'use strict';
2
-
3
- var cliNode = require('@backstage/cli-node');
4
- var fs = require('fs-extra');
5
- var path = require('node:path');
6
- var cliCommon = require('@backstage/cli-common');
7
-
8
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
9
-
10
- var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
11
-
12
- const SCRIPT_EXTS = [".js", ".jsx", ".ts", ".tsx", ".json"];
13
- async function readFixablePackages() {
14
- const packages = await cliNode.PackageGraph.listTargetPackages();
15
- return packages.map((pkg) => ({ ...pkg, changed: false }));
16
- }
17
- function printPackageFixHint(packages) {
18
- const changed = packages.filter((pkg) => pkg.changed);
19
- if (changed.length > 0) {
20
- const rootPkg = require(cliCommon.targetPaths.resolveRoot("package.json"));
21
- const fixCmd = rootPkg.scripts?.fix === "backstage-cli repo fix" ? "fix" : "backstage-cli repo fix";
22
- console.log(
23
- `The following packages are out of sync, run 'yarn ${fixCmd}' to fix them:`
24
- );
25
- for (const pkg of changed) {
26
- console.log(` ${pkg.packageJson.name}`);
27
- }
28
- return true;
29
- }
30
- return false;
31
- }
32
- async function writeFixedPackages(packages) {
33
- await Promise.all(
34
- packages.map(async (pkg) => {
35
- if (!pkg.changed) {
36
- return;
37
- }
38
- await fs__default.default.writeJson(
39
- path.resolve(pkg.dir, "package.json"),
40
- pkg.packageJson,
41
- {
42
- spaces: 2
43
- }
44
- );
45
- })
46
- );
47
- }
48
- function trimRelative(path) {
49
- if (path.startsWith("./")) {
50
- return path.slice(2);
51
- }
52
- return path;
53
- }
54
- function fixPackageExports(pkg) {
55
- let { exports: exp } = pkg.packageJson;
56
- if (!exp) {
57
- return;
58
- }
59
- if (Array.isArray(exp)) {
60
- throw new Error("Unexpected array in package.json exports field");
61
- }
62
- if (typeof exp === "string") {
63
- pkg.changed = true;
64
- exp = { ".": exp };
65
- pkg.packageJson.exports = exp;
66
- } else if (typeof exp !== "object") {
67
- return;
68
- }
69
- if (!exp["./package.json"]) {
70
- pkg.changed = true;
71
- exp["./package.json"] = "./package.json";
72
- }
73
- const existingTypesVersions = JSON.stringify(pkg.packageJson.typesVersions);
74
- const typeEntries = {};
75
- for (const [path$1, value] of Object.entries(exp)) {
76
- if (path$1 === ".") {
77
- continue;
78
- }
79
- const newPath = trimRelative(path$1);
80
- if (typeof value === "string") {
81
- if (SCRIPT_EXTS.includes(path.extname(value))) {
82
- typeEntries[newPath] = [trimRelative(value)];
83
- }
84
- } else if (value && typeof value === "object" && !Array.isArray(value)) {
85
- if (typeof value.types === "string") {
86
- typeEntries[newPath] = [trimRelative(value.types)];
87
- } else if (typeof value.default === "string" && SCRIPT_EXTS.includes(path.extname(value.default))) {
88
- typeEntries[newPath] = [trimRelative(value.default)];
89
- }
90
- }
91
- }
92
- const hasTypeEntries = Object.keys(typeEntries).length > 0;
93
- const typesVersions = hasTypeEntries ? { "*": typeEntries } : void 0;
94
- if (existingTypesVersions !== JSON.stringify(typesVersions)) {
95
- if (pkg.packageJson.typesVersions) {
96
- if (typesVersions) {
97
- pkg.packageJson.typesVersions = typesVersions;
98
- } else {
99
- delete pkg.packageJson.typesVersions;
100
- }
101
- } else if (typesVersions) {
102
- const newPkgEntries = Object.entries(pkg.packageJson);
103
- newPkgEntries.splice(
104
- newPkgEntries.findIndex(([name]) => name === "exports") + 1,
105
- 0,
106
- ["typesVersions", typesVersions]
107
- );
108
- pkg.packageJson = Object.fromEntries(
109
- newPkgEntries
110
- );
111
- }
112
- pkg.changed = true;
113
- }
114
- const publishConfig = pkg.packageJson.publishConfig;
115
- if (publishConfig) {
116
- for (const field of ["main", "module", "browser", "types"]) {
117
- if (publishConfig[field]) {
118
- delete publishConfig[field];
119
- pkg.changed = true;
120
- }
121
- }
122
- }
123
- }
124
- function fixSideEffects(pkg) {
125
- const role = cliNode.PackageRoles.getRoleFromPackage(pkg.packageJson);
126
- if (!role) {
127
- return;
128
- }
129
- const roleInfo = cliNode.PackageRoles.getRoleInfo(role);
130
- if (roleInfo.platform === "node") {
131
- return;
132
- }
133
- if (roleInfo.output.length === 1 && roleInfo.output[0] === "bundle") {
134
- return;
135
- }
136
- if ("sideEffects" in pkg.packageJson) {
137
- return;
138
- }
139
- const pkgEntries = Object.entries(pkg.packageJson);
140
- pkgEntries.splice(
141
- // Place it just above the scripts field
142
- pkgEntries.findIndex(([name]) => name === "scripts"),
143
- 0,
144
- ["sideEffects", false]
145
- );
146
- pkg.packageJson = Object.fromEntries(pkgEntries);
147
- pkg.changed = true;
148
- }
149
- function createRepositoryFieldFixer() {
150
- const rootPkg = require(cliCommon.targetPaths.resolveRoot("package.json"));
151
- const rootRepoField = rootPkg.repository;
152
- if (!rootRepoField) {
153
- return () => {
154
- };
155
- }
156
- const rootType = rootRepoField.type || "git";
157
- const rootUrl = rootRepoField.url;
158
- const rootDir = rootRepoField.directory || "";
159
- return (pkg) => {
160
- const expectedPath = path.posix.join(
161
- rootDir,
162
- path.relative(cliCommon.targetPaths.rootDir, pkg.dir)
163
- );
164
- const repoField = pkg.packageJson.repository;
165
- if (!repoField || typeof repoField === "string") {
166
- const pkgEntries = Object.entries(pkg.packageJson);
167
- pkgEntries.splice(
168
- // Place it just above the backstage field
169
- pkgEntries.findIndex(([name]) => name === "backstage"),
170
- 0,
171
- [
172
- "repository",
173
- {
174
- type: rootType,
175
- url: rootUrl,
176
- directory: expectedPath
177
- }
178
- ]
179
- );
180
- pkg.packageJson = Object.fromEntries(pkgEntries);
181
- pkg.changed = true;
182
- return;
183
- }
184
- if (repoField.type !== rootType || repoField.url !== rootUrl) {
185
- return;
186
- }
187
- if (repoField.directory !== expectedPath) {
188
- repoField.directory = expectedPath;
189
- pkg.changed = true;
190
- }
191
- };
192
- }
193
- function guessPluginId(role, pkgName) {
194
- switch (role) {
195
- case "frontend":
196
- case "frontend-plugin":
197
- return pkgName.match(/plugin-(.*)/)?.[1];
198
- case "frontend-plugin-module":
199
- return pkgName.match(/plugin-(.*)-module-/)?.[1];
200
- case "backend-plugin":
201
- return pkgName.match(/plugin-(.*)-backend$/)?.[1];
202
- case "backend-plugin-module":
203
- return pkgName.match(/plugin-(.*)-backend-module-/)?.[1];
204
- case "common-library":
205
- return pkgName.match(/plugin-(.*)-(?:common)$/)?.[1];
206
- case "web-library":
207
- return pkgName.match(/plugin-(.*)-(?:react|test-utils)/)?.[1];
208
- case "node-library":
209
- return pkgName.match(/plugin-(.*)-(?:node|backend)-?/)?.[1];
210
- default:
211
- throw new Error(
212
- `Invalid 'backstage.role' field in "${pkgName}", got '${role}'`
213
- );
214
- }
215
- }
216
- function fixPluginId(pkg) {
217
- const role = pkg.packageJson.backstage?.role;
218
- if (!role) {
219
- return;
220
- }
221
- if (role === "backend" || role === "frontend" || role === "cli") {
222
- return;
223
- }
224
- const currentId = pkg.packageJson.backstage?.pluginId;
225
- if (currentId !== void 0) {
226
- if (typeof currentId !== "string" && currentId !== null) {
227
- throw new Error(
228
- `Invalid 'backstage.pluginId' field in "${pkg.packageJson.name}", must be a string`
229
- );
230
- }
231
- return;
232
- }
233
- const guessedPluginId = guessPluginId(role, pkg.packageJson.name);
234
- if (!guessedPluginId && (role === "frontend-plugin" || role === "frontend-plugin-module" || role === "backend-plugin" || role === "backend-plugin-module")) {
235
- const path$1 = path.relative(
236
- cliCommon.targetPaths.rootDir,
237
- path.resolve(pkg.dir, "package.json")
238
- );
239
- const msg = `Failed to guess plugin ID for "${pkg.packageJson.name}", please set the 'backstage.pluginId' field manually in "${path$1}"`;
240
- if (role.endsWith("module")) {
241
- const suggestedRole = role.startsWith("frontend") ? "web-library" : "node-library";
242
- throw new Error(
243
- `${msg}. It is also possible that this package is not a module, and should use the '${suggestedRole}' role instead.`
244
- );
245
- } else {
246
- throw new Error(msg);
247
- }
248
- }
249
- if (guessedPluginId) {
250
- pkg.packageJson.backstage = {
251
- ...pkg.packageJson.backstage,
252
- pluginId: guessedPluginId
253
- };
254
- pkg.changed = true;
255
- }
256
- }
257
- const backendPluginPackageNameByPluginId = new Map(
258
- [
259
- "app",
260
- "auth",
261
- "catalog",
262
- "events",
263
- "kubernetes",
264
- "notifications",
265
- "permission",
266
- "scaffolder",
267
- "search",
268
- "signals",
269
- "techdocs"
270
- ].map((pluginId) => [pluginId, `@backstage/plugin-${pluginId}-backend`])
271
- );
272
- const pluginPackageRoles = [
273
- "frontend-plugin",
274
- "backend-plugin",
275
- "common-library",
276
- "web-library",
277
- "node-library"
278
- ];
279
- function fixPluginPackages(pkg, repoPackages) {
280
- const pkgBackstage = pkg.packageJson.backstage;
281
- const role = pkgBackstage?.role;
282
- if (!role) {
283
- return;
284
- }
285
- if (role === "backend" || role === "frontend" || role === "cli") {
286
- return;
287
- }
288
- const pluginId = pkgBackstage.pluginId;
289
- if (!pluginId) {
290
- if (role === "common-library" || role === "web-library" || role === "node-library" || role === "frontend-plugin-module") {
291
- return;
292
- }
293
- throw new Error(
294
- `Missing 'backstage.pluginId' field in "${pkg.packageJson.name}"`
295
- );
296
- }
297
- if (role === "backend-plugin-module" || role === "frontend-plugin-module") {
298
- const targetRole = role.replace("-module", "");
299
- const pluginPkgName = repoPackages.find(
300
- (p) => p.packageJson.backstage?.pluginId === pluginId && p.packageJson.backstage?.role === targetRole
301
- )?.packageJson.name ?? backendPluginPackageNameByPluginId.get(pluginId);
302
- if (!pluginPkgName) {
303
- if (pkgBackstage.pluginPackage) {
304
- return;
305
- }
306
- const path$1 = path.relative(
307
- cliCommon.targetPaths.rootDir,
308
- path.resolve(pkg.dir, "package.json")
309
- );
310
- const suggestedRole = role === "frontend-plugin-module" ? "web-library" : "node-library";
311
- throw new Error(
312
- `Failed to find plugin package for "${pkg.packageJson.name}", please declare the name of the plugin package that this package is a module for in the 'backstage.pluginPackage' field in "${path$1}". It is also possible that this package is not a module, and should use the '${suggestedRole}' role instead.`
313
- );
314
- }
315
- if (pkgBackstage.pluginPackage !== pluginPkgName) {
316
- pkgBackstage.pluginPackage = pluginPkgName;
317
- pkg.changed = true;
318
- }
319
- } else {
320
- let pluginPackages = repoPackages.filter(
321
- (p) => p.packageJson.backstage?.pluginId === pluginId && pluginPackageRoles.includes(p.packageJson.backstage?.role)
322
- ).map((p) => p.packageJson.name).sort();
323
- if (pluginPackages.length === 0) {
324
- pluginPackages = void 0;
325
- }
326
- if (pkgBackstage.pluginPackages?.join(",") !== pluginPackages?.join(",")) {
327
- pkgBackstage.pluginPackages = pluginPackages;
328
- pkg.changed = true;
329
- }
330
- }
331
- }
332
- function fixPeerModules(pkg) {
333
- const pkgBackstage = pkg.packageJson.backstage;
334
- const role = pkgBackstage?.role;
335
- if (!role) {
336
- return;
337
- }
338
- const peerModules = pkgBackstage.peerModules;
339
- if (peerModules === void 0) {
340
- return;
341
- }
342
- const packagePath = path.relative(
343
- cliCommon.targetPaths.rootDir,
344
- path.resolve(pkg.dir, "package.json")
345
- );
346
- if (role !== "backend-plugin" && role !== "frontend-plugin") {
347
- throw new Error(
348
- `The 'backstage.peerModules' field in "${pkg.packageJson.name}" can only be used on plugin packages (backend-plugin or frontend-plugin), but package has role '${role}' in "${packagePath}"`
349
- );
350
- }
351
- if (!Array.isArray(peerModules)) {
352
- throw new Error(
353
- `Invalid 'backstage.peerModules' field in "${pkg.packageJson.name}", must be an array of package names in "${packagePath}"`
354
- );
355
- }
356
- for (const entry of peerModules) {
357
- if (typeof entry !== "string" || entry.length === 0) {
358
- throw new Error(
359
- `Invalid entry in 'backstage.peerModules' field in "${pkg.packageJson.name}", all entries must be non-empty package name strings in "${packagePath}"`
360
- );
361
- }
362
- }
363
- }
364
- async function command(opts) {
365
- const packages = await readFixablePackages();
366
- const fixRepositoryField = createRepositoryFieldFixer();
367
- const fixers = [fixPackageExports, fixSideEffects];
368
- if (opts.publish) {
369
- fixers.push(
370
- fixRepositoryField,
371
- fixPluginId,
372
- fixPluginPackages,
373
- fixPeerModules
374
- );
375
- }
376
- for (const fixer of fixers) {
377
- for (const pkg of packages) {
378
- fixer(pkg, packages);
379
- }
380
- }
381
- if (opts.check) {
382
- if (printPackageFixHint(packages)) {
383
- process.exit(1);
384
- }
385
- } else {
386
- await writeFixedPackages(packages);
387
- }
388
- }
389
-
390
- exports.command = command;
391
- exports.createRepositoryFieldFixer = createRepositoryFieldFixer;
392
- exports.fixPackageExports = fixPackageExports;
393
- exports.fixPeerModules = fixPeerModules;
394
- exports.fixPluginId = fixPluginId;
395
- exports.fixPluginPackages = fixPluginPackages;
396
- exports.fixSideEffects = fixSideEffects;
397
- exports.printPackageFixHint = printPackageFixHint;
398
- exports.readFixablePackages = readFixablePackages;
399
- exports.writeFixedPackages = writeFixedPackages;
400
- //# sourceMappingURL=fix.cjs.js.map
@@ -1,74 +0,0 @@
1
- 'use strict';
2
-
3
- var chalk = require('chalk');
4
- var eslint = require('eslint');
5
- var path = require('node:path');
6
- var cliNode = require('@backstage/cli-node');
7
- var cliCommon = require('@backstage/cli-common');
8
-
9
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
-
11
- var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
12
-
13
- async function command(opts) {
14
- const packages = await cliNode.PackageGraph.listTargetPackages();
15
- const eslint$1 = new eslint.ESLint({
16
- cwd: cliCommon.targetPaths.dir,
17
- overrideConfig: {
18
- plugins: ["deprecation"],
19
- rules: {
20
- "deprecation/deprecation": "error"
21
- },
22
- parserOptions: {
23
- project: [cliCommon.targetPaths.resolveRoot("tsconfig.json")]
24
- }
25
- },
26
- extensions: ["jsx", "ts", "tsx", "mjs", "cjs"]
27
- });
28
- const { stderr } = process;
29
- if (stderr.isTTY) {
30
- stderr.write("Initializing TypeScript...");
31
- }
32
- const deprecations = [];
33
- for (const [index, pkg] of packages.entries()) {
34
- const results = await eslint$1.lintFiles(pkg.dir);
35
- for (const result of results) {
36
- for (const message of result.messages) {
37
- if (message.ruleId !== "deprecation/deprecation") {
38
- continue;
39
- }
40
- const path$1 = path.relative(cliCommon.targetPaths.rootDir, result.filePath);
41
- deprecations.push({
42
- path: path$1,
43
- message: message.message,
44
- line: message.line,
45
- column: message.column
46
- });
47
- }
48
- }
49
- if (stderr.isTTY) {
50
- stderr.clearLine(0);
51
- stderr.cursorTo(0);
52
- stderr.write(`Scanning packages ${index + 1}/${packages.length}`);
53
- }
54
- }
55
- if (stderr.isTTY) {
56
- stderr.clearLine(0);
57
- stderr.cursorTo(0);
58
- }
59
- if (opts.json) {
60
- console.log(JSON.stringify(deprecations, null, 2));
61
- } else {
62
- for (const d of deprecations) {
63
- const location = `${d.path}:${d.line}:${d.column}`;
64
- const wrappedMessage = d.message.replace(/\r?\n\s*/g, " ");
65
- console.log(`${location} - ${chalk__default.default.yellow(wrappedMessage)}`);
66
- }
67
- }
68
- if (deprecations.length > 0) {
69
- process.exit(1);
70
- }
71
- }
72
-
73
- exports.command = command;
74
- //# sourceMappingURL=list-deprecations.cjs.js.map
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var commander = require('commander');
6
- var factory = require('../../wiring/factory.cjs.js');
7
- var lazy = require('../../wiring/lazy.cjs.js');
8
-
9
- var index = factory.createCliPlugin({
10
- pluginId: "maintenance",
11
- init: async (reg) => {
12
- reg.addCommand({
13
- path: ["repo", "fix"],
14
- description: "Automatically fix packages in the project",
15
- execute: async ({ args }) => {
16
- const command = new commander.Command();
17
- const defaultCommand = command.option(
18
- "--publish",
19
- "Enable additional fixes that only apply when publishing packages"
20
- ).option(
21
- "--check",
22
- "Fail if any packages would have been changed by the command"
23
- ).action(lazy.lazy(() => import('./commands/repo/fix.cjs.js'), "command"));
24
- await defaultCommand.parseAsync(args, { from: "user" });
25
- }
26
- });
27
- reg.addCommand({
28
- path: ["repo", "list-deprecations"],
29
- description: "List deprecations",
30
- execute: async ({ args }) => {
31
- const command = new commander.Command();
32
- const defaultCommand = command.option("--json", "Output as JSON").action(
33
- lazy.lazy(() => import('./commands/repo/list-deprecations.cjs.js'), "command")
34
- );
35
- await defaultCommand.parseAsync(args, { from: "user" });
36
- }
37
- });
38
- }
39
- });
40
-
41
- exports.default = index;
42
- //# sourceMappingURL=index.cjs.js.map
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var cleye = require('cleye');
6
-
7
- var packageExports = async ({ args, info }) => {
8
- cleye.cli({ help: info }, void 0, args);
9
- throw new Error(
10
- "The `migrate package-exports` command has been removed, use `repo fix` instead."
11
- );
12
- };
13
-
14
- exports.default = packageExports;
15
- //# sourceMappingURL=packageExports.cjs.js.map
@@ -1,77 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var cleye = require('cleye');
6
- var fs = require('fs-extra');
7
- var path = require('node:path');
8
- var cliNode = require('@backstage/cli-node');
9
- var cliCommon = require('@backstage/cli-common');
10
-
11
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
12
-
13
- var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
14
-
15
- const PREFIX = `module.exports = require('@backstage/cli/config/eslint-factory')`;
16
- var packageLintConfigs = async ({ args, info }) => {
17
- cleye.cli({ help: info }, void 0, args);
18
- const packages = await cliNode.PackageGraph.listTargetPackages();
19
- const oldConfigs = [
20
- require.resolve("@backstage/cli/config/eslint.js"),
21
- require.resolve("@backstage/cli/config/eslint.backend.js")
22
- ];
23
- const configPaths = new Array();
24
- await Promise.all(
25
- packages.map(async ({ dir, packageJson }) => {
26
- const configPath = path.resolve(dir, ".eslintrc.js");
27
- if (!await fs__default.default.pathExists(configPath)) {
28
- console.log(`Skipping ${packageJson.name}, missing .eslintrc.js`);
29
- return;
30
- }
31
- let existingConfig;
32
- try {
33
- existingConfig = require(configPath);
34
- } catch (error) {
35
- console.log(
36
- `Skipping ${packageJson.name}, failed to load .eslintrc.js, ${error}`
37
- );
38
- return;
39
- }
40
- const extendsArray = existingConfig.extends ?? [];
41
- const extendIndex = extendsArray.findIndex((p) => oldConfigs.includes(p));
42
- if (extendIndex === -1) {
43
- console.log(
44
- `Skipping ${packageJson.name}, .eslintrc.js does not extend the legacy config`
45
- );
46
- return;
47
- }
48
- extendsArray.splice(extendIndex, 1);
49
- if (extendsArray.length === 0) {
50
- delete existingConfig.extends;
51
- }
52
- if (Object.keys(existingConfig).length > 0) {
53
- await fs__default.default.writeFile(
54
- configPath,
55
- `${PREFIX}(__dirname, ${JSON.stringify(existingConfig, null, 2)});
56
- `
57
- );
58
- } else {
59
- await fs__default.default.writeFile(configPath, `${PREFIX}(__dirname);
60
- `);
61
- }
62
- configPaths.push(configPath);
63
- })
64
- );
65
- let hasPrettier = false;
66
- try {
67
- require.resolve("prettier");
68
- hasPrettier = true;
69
- } catch {
70
- }
71
- if (hasPrettier) {
72
- await cliCommon.runOutput(["prettier", "--write", ...configPaths]);
73
- }
74
- };
75
-
76
- exports.default = packageLintConfigs;
77
- //# sourceMappingURL=packageLintConfigs.cjs.js.map
@@ -1,57 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var cleye = require('cleye');
6
- var fs = require('fs-extra');
7
- var path = require('node:path');
8
- var getPackages = require('@manypkg/get-packages');
9
- var cliNode = require('@backstage/cli-node');
10
- var cliCommon = require('@backstage/cli-common');
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 packageRole = async ({ args, info }) => {
17
- cleye.cli({ help: info }, void 0, args);
18
- const { packages } = await getPackages.getPackages(cliCommon.targetPaths.dir);
19
- await Promise.all(
20
- packages.map(async ({ dir, packageJson: pkg }) => {
21
- const { name } = pkg;
22
- const existingRole = cliNode.PackageRoles.getRoleFromPackage(pkg);
23
- if (existingRole) {
24
- return;
25
- }
26
- const detectedRole = cliNode.PackageRoles.detectRoleFromPackage(pkg);
27
- if (!detectedRole) {
28
- console.error(`No role detected for package ${name}`);
29
- return;
30
- }
31
- console.log(`Detected package role of ${name} as ${detectedRole}`);
32
- let newPkg = pkg;
33
- const pkgKeys = Object.keys(pkg);
34
- if (pkgKeys.includes("backstage")) {
35
- newPkg.backstage = {
36
- ...newPkg.backstage,
37
- role: detectedRole
38
- };
39
- } else {
40
- const index = Math.max(
41
- pkgKeys.indexOf("version"),
42
- pkgKeys.indexOf("private"),
43
- pkgKeys.indexOf("publishConfig")
44
- ) + 1 || pkgKeys.length;
45
- const pkgEntries = Object.entries(pkg);
46
- pkgEntries.splice(index, 0, ["backstage", { role: detectedRole }]);
47
- newPkg = Object.fromEntries(pkgEntries);
48
- }
49
- await fs__default.default.writeJson(path.resolve(dir, "package.json"), newPkg, {
50
- spaces: 2
51
- });
52
- })
53
- );
54
- };
55
-
56
- exports.default = packageRole;
57
- //# sourceMappingURL=packageRole.cjs.js.map