@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,32 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var cleye = require('cleye');
6
- var storage = require('../lib/storage.cjs.js');
7
- var prompt = require('../lib/prompt.cjs.js');
8
-
9
- var select = async ({ args, info }) => {
10
- const {
11
- flags: { instance: instanceFlag }
12
- } = cleye.cli(
13
- {
14
- help: info,
15
- flags: {
16
- instance: {
17
- type: String,
18
- description: "Name of the instance to select"
19
- }
20
- }
21
- },
22
- void 0,
23
- args
24
- );
25
- const instance = await prompt.pickInstance(instanceFlag);
26
- await storage.setSelectedInstance(instance.name);
27
- process.stderr.write(`Selected instance '${instance.name}'
28
- `);
29
- };
30
-
31
- exports.default = select;
32
- //# sourceMappingURL=select.cjs.js.map
@@ -1,59 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var cleye = require('cleye');
6
- var http = require('../lib/http.cjs.js');
7
- var storage = require('../lib/storage.cjs.js');
8
- var auth = require('../lib/auth.cjs.js');
9
- var secretStore = require('../lib/secretStore.cjs.js');
10
-
11
- var show = async ({ args, info }) => {
12
- const {
13
- flags: { instance: instanceFlag }
14
- } = cleye.cli(
15
- {
16
- help: info,
17
- flags: {
18
- instance: {
19
- type: String,
20
- description: "Name of the instance to show"
21
- }
22
- }
23
- },
24
- void 0,
25
- args
26
- );
27
- let instance = await storage.getSelectedInstance(instanceFlag);
28
- if (auth.accessTokenNeedsRefresh(instance)) {
29
- process.stdout.write("Refreshing access token...\n");
30
- instance = await auth.refreshAccessToken(instance.name);
31
- }
32
- const authBase = new URL("/api/auth", instance.baseUrl).toString().replace(/\/$/, "");
33
- const secretStore$1 = await secretStore.getSecretStore();
34
- const service = `backstage-cli:auth-instance:${instance.name}`;
35
- const accessToken = await secretStore$1.get(service, "accessToken");
36
- if (!accessToken) {
37
- throw new Error('No access token found. Run "auth login" to authenticate.');
38
- }
39
- const userinfo = await http.httpJson(
40
- `${authBase}/v1/userinfo`,
41
- {
42
- headers: { Authorization: `Bearer ${accessToken}` },
43
- signal: AbortSignal.timeout(3e4)
44
- }
45
- );
46
- process.stdout.write(`User: ${userinfo.claims.sub}
47
- `);
48
- process.stdout.write(`
49
- `);
50
- process.stdout.write(`Ownership:
51
- `);
52
- for (const ent of userinfo.claims.ent ?? []) {
53
- process.stdout.write(` - ${ent}
54
- `);
55
- }
56
- };
57
-
58
- exports.default = show;
59
- //# sourceMappingURL=show.cjs.js.map
@@ -1,44 +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: "auth",
9
- init: async (reg) => {
10
- reg.addCommand({
11
- path: ["auth", "login"],
12
- description: "Log in the CLI to a Backstage instance",
13
- execute: { loader: () => import('./commands/login.cjs.js') }
14
- });
15
- reg.addCommand({
16
- path: ["auth", "logout"],
17
- description: "Log out the CLI and clear stored credentials",
18
- execute: { loader: () => import('./commands/logout.cjs.js') }
19
- });
20
- reg.addCommand({
21
- path: ["auth", "show"],
22
- description: "Show details of an authenticated instance",
23
- execute: { loader: () => import('./commands/show.cjs.js') }
24
- });
25
- reg.addCommand({
26
- path: ["auth", "list"],
27
- description: "List authenticated instances",
28
- execute: { loader: () => import('./commands/list.cjs.js') }
29
- });
30
- reg.addCommand({
31
- path: ["auth", "print-token"],
32
- description: "Print an access token to stdout (auto-refresh if needed)",
33
- execute: { loader: () => import('./commands/printToken.cjs.js') }
34
- });
35
- reg.addCommand({
36
- path: ["auth", "select"],
37
- description: "Select the default instance",
38
- execute: { loader: () => import('./commands/select.cjs.js') }
39
- });
40
- }
41
- });
42
-
43
- exports.default = index;
44
- //# sourceMappingURL=index.cjs.js.map
@@ -1,60 +0,0 @@
1
- 'use strict';
2
-
3
- var zod = require('zod');
4
- var storage = require('./storage.cjs.js');
5
- var secretStore = require('./secretStore.cjs.js');
6
- var http = require('./http.cjs.js');
7
-
8
- const TokenResponseSchema = zod.z.object({
9
- access_token: zod.z.string().min(1),
10
- token_type: zod.z.string().min(1),
11
- expires_in: zod.z.number().positive().finite(),
12
- refresh_token: zod.z.string().min(1).optional()
13
- });
14
- function accessTokenNeedsRefresh(instance) {
15
- return instance.accessTokenExpiresAt <= Date.now() + 2 * 6e4;
16
- }
17
- async function refreshAccessToken(instanceName) {
18
- const secretStore$1 = await secretStore.getSecretStore();
19
- return storage.withMetadataLock(async () => {
20
- const instance = await storage.getInstanceByName(instanceName);
21
- const service = `backstage-cli:auth-instance:${instanceName}`;
22
- const refreshToken = await secretStore$1.get(service, "refreshToken") ?? "";
23
- if (!refreshToken) {
24
- throw new Error(
25
- "Access token is expired and no refresh token is available"
26
- );
27
- }
28
- const response = await http.httpJson(
29
- `${instance.baseUrl}/api/auth/v1/token`,
30
- {
31
- method: "POST",
32
- body: {
33
- grant_type: "refresh_token",
34
- refresh_token: refreshToken
35
- },
36
- signal: AbortSignal.timeout(3e4)
37
- }
38
- );
39
- const parsed = TokenResponseSchema.safeParse(response);
40
- if (!parsed.success) {
41
- throw new Error(`Invalid token response: ${parsed.error.message}`);
42
- }
43
- const token = parsed.data;
44
- await secretStore$1.set(service, "accessToken", token.access_token);
45
- if (token.refresh_token) {
46
- await secretStore$1.set(service, "refreshToken", token.refresh_token);
47
- }
48
- const newInstance = {
49
- ...instance,
50
- issuedAt: Date.now(),
51
- accessTokenExpiresAt: Date.now() + token.expires_in * 1e3
52
- };
53
- await storage.upsertInstance(newInstance);
54
- return newInstance;
55
- });
56
- }
57
-
58
- exports.accessTokenNeedsRefresh = accessTokenNeedsRefresh;
59
- exports.refreshAccessToken = refreshAccessToken;
60
- //# sourceMappingURL=auth.cjs.js.map
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- var fetch = require('cross-fetch');
4
- var errors = require('@backstage/errors');
5
-
6
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
7
-
8
- var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
9
-
10
- async function httpJson(url, init) {
11
- const res = await fetch__default.default(url, {
12
- ...init,
13
- body: init?.body ? JSON.stringify(init.body) : void 0,
14
- headers: {
15
- ...init?.body ? { "Content-Type": "application/json" } : {},
16
- ...init?.headers
17
- }
18
- });
19
- if (!res.ok) {
20
- throw await errors.ResponseError.fromResponse(res);
21
- }
22
- return await res.json();
23
- }
24
-
25
- exports.httpJson = httpJson;
26
- //# sourceMappingURL=http.cjs.js.map
@@ -1,80 +0,0 @@
1
- 'use strict';
2
-
3
- var http = require('node:http');
4
- var node_url = require('node:url');
5
-
6
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
7
-
8
- var http__default = /*#__PURE__*/_interopDefaultCompat(http);
9
-
10
- const CALLBACK_PORT = 8055;
11
- async function startCallbackServer(options) {
12
- const server = http__default.default.createServer();
13
- let resolveResult;
14
- const resultPromise = new Promise(
15
- (resolve) => {
16
- resolveResult = resolve;
17
- }
18
- );
19
- server.on("request", (req, res) => {
20
- if (!req.url) {
21
- res.statusCode = 400;
22
- res.end("Bad Request");
23
- return;
24
- }
25
- const u = new node_url.URL(req.url, "http://127.0.0.1");
26
- if (u.pathname !== "/callback") {
27
- res.statusCode = 404;
28
- res.end("Not Found");
29
- return;
30
- }
31
- const code = u.searchParams.get("code") ?? void 0;
32
- const state = u.searchParams.get("state") ?? void 0;
33
- if (!code) {
34
- res.statusCode = 400;
35
- res.end("Missing code");
36
- return;
37
- }
38
- if (state !== options.state) {
39
- res.statusCode = 400;
40
- res.end("State mismatch");
41
- return;
42
- }
43
- res.statusCode = 200;
44
- res.setHeader("Content-Type", "text/plain; charset=utf-8");
45
- res.end("You may now close this window.");
46
- resolveResult?.({ code, state });
47
- });
48
- const port = await new Promise((resolve, reject) => {
49
- server.on("error", (err) => {
50
- if (err.code === "EADDRINUSE") {
51
- reject(
52
- new Error(
53
- `Port ${CALLBACK_PORT} is already in use. Close the application using it and try again.`
54
- )
55
- );
56
- } else {
57
- reject(err);
58
- }
59
- });
60
- server.listen(CALLBACK_PORT, "127.0.0.1", () => {
61
- const address = server.address();
62
- if (typeof address === "object" && address && "port" in address) {
63
- resolve(address.port);
64
- } else {
65
- reject(new Error("Failed to bind local server"));
66
- }
67
- });
68
- });
69
- return {
70
- url: `http://127.0.0.1:${port}/callback`,
71
- waitForCode: () => resultPromise,
72
- close: async () => {
73
- server.closeAllConnections();
74
- return new Promise((resolve) => server.close(() => resolve()));
75
- }
76
- };
77
- }
78
-
79
- exports.startCallbackServer = startCallbackServer;
80
- //# sourceMappingURL=localServer.cjs.js.map
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- var crypto = require('node:crypto');
4
-
5
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
-
7
- var crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
8
-
9
- function base64url(input) {
10
- return input.toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
11
- }
12
- function generateVerifier(length = 64) {
13
- const bytes = crypto__default.default.randomBytes(Math.max(32, Math.min(96, length)));
14
- return base64url(bytes);
15
- }
16
- function challengeFromVerifier(verifier) {
17
- const hash = crypto__default.default.createHash("sha256").update(verifier).digest();
18
- return base64url(hash);
19
- }
20
-
21
- exports.challengeFromVerifier = challengeFromVerifier;
22
- exports.generateVerifier = generateVerifier;
23
- //# sourceMappingURL=pkce.cjs.js.map
@@ -1,44 +0,0 @@
1
- 'use strict';
2
-
3
- var inquirer = require('inquirer');
4
- var storage = require('./storage.cjs.js');
5
-
6
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
7
-
8
- var inquirer__default = /*#__PURE__*/_interopDefaultCompat(inquirer);
9
-
10
- async function pickInstance(name) {
11
- if (name) {
12
- return storage.getInstanceByName(name);
13
- }
14
- const { instances, selected } = await storage.getAllInstances();
15
- if (instances.length === 0) {
16
- throw new Error(
17
- 'No instances found. Run "auth login" to authenticate first.'
18
- );
19
- }
20
- return await promptForInstance(instances, selected);
21
- }
22
- async function promptForInstance(instances, selected) {
23
- const choices = instances.map((i) => ({
24
- name: `${i.name === selected?.name ? "* " : " "}${i.name} (${i.baseUrl})`,
25
- value: i.name
26
- }));
27
- const { choice } = await inquirer__default.default.prompt([
28
- {
29
- type: "list",
30
- name: "choice",
31
- message: "Select instance:",
32
- choices,
33
- default: selected?.name
34
- }
35
- ]);
36
- const instance = instances.find((i) => i.name === choice);
37
- if (!instance) {
38
- throw new Error(`Instance '${choice}' not found`);
39
- }
40
- return instance;
41
- }
42
-
43
- exports.pickInstance = pickInstance;
44
- //# sourceMappingURL=prompt.cjs.js.map
@@ -1,81 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('fs-extra');
4
- var os = require('node:os');
5
- var path = require('node:path');
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
- var os__default = /*#__PURE__*/_interopDefaultCompat(os);
11
- var path__default = /*#__PURE__*/_interopDefaultCompat(path);
12
-
13
- async function loadKeytar() {
14
- try {
15
- const keytar = require("keytar");
16
- if (keytar && typeof keytar.getPassword === "function") {
17
- return keytar;
18
- }
19
- } catch {
20
- }
21
- return void 0;
22
- }
23
- class KeytarSecretStore {
24
- keytar;
25
- constructor(keytar) {
26
- this.keytar = keytar;
27
- }
28
- async get(service, account) {
29
- const result = await this.keytar.getPassword(service, account);
30
- return result ?? void 0;
31
- }
32
- async set(service, account, secret) {
33
- await this.keytar.setPassword(service, account, secret);
34
- }
35
- async delete(service, account) {
36
- await this.keytar.deletePassword(service, account);
37
- }
38
- }
39
- class FileSecretStore {
40
- baseDir;
41
- constructor() {
42
- const root = process.env.XDG_DATA_HOME || (process.platform === "win32" ? process.env.APPDATA || path__default.default.join(os__default.default.homedir(), "AppData", "Roaming") : path__default.default.join(os__default.default.homedir(), ".local", "share"));
43
- this.baseDir = path__default.default.join(root, "backstage-cli", "auth-secrets");
44
- }
45
- filePath(service, account) {
46
- return path__default.default.join(
47
- this.baseDir,
48
- encodeURIComponent(service),
49
- `${encodeURIComponent(account)}.secret`
50
- );
51
- }
52
- async get(service, account) {
53
- const file = this.filePath(service, account);
54
- if (!await fs__default.default.pathExists(file)) return void 0;
55
- return await fs__default.default.readFile(file, "utf8");
56
- }
57
- async set(service, account, secret) {
58
- const file = this.filePath(service, account);
59
- await fs__default.default.ensureDir(path__default.default.dirname(file));
60
- await fs__default.default.writeFile(file, secret, { encoding: "utf8", mode: 384 });
61
- }
62
- async delete(service, account) {
63
- const file = this.filePath(service, account);
64
- await fs__default.default.remove(file);
65
- }
66
- }
67
- let singleton;
68
- async function getSecretStore() {
69
- if (!singleton) {
70
- const keytar = await loadKeytar();
71
- if (keytar) {
72
- singleton = new KeytarSecretStore(keytar);
73
- } else {
74
- singleton = new FileSecretStore();
75
- }
76
- }
77
- return singleton;
78
- }
79
-
80
- exports.getSecretStore = getSecretStore;
81
- //# sourceMappingURL=secretStore.cjs.js.map
@@ -1,152 +0,0 @@
1
- 'use strict';
2
-
3
- var errors = require('@backstage/errors');
4
- var fs = require('fs-extra');
5
- var os = require('node:os');
6
- var path = require('node:path');
7
- var lockfile = require('proper-lockfile');
8
- var YAML = require('yaml');
9
- var zod = require('zod');
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
- var os__default = /*#__PURE__*/_interopDefaultCompat(os);
15
- var path__default = /*#__PURE__*/_interopDefaultCompat(path);
16
- var lockfile__default = /*#__PURE__*/_interopDefaultCompat(lockfile);
17
- var YAML__default = /*#__PURE__*/_interopDefaultCompat(YAML);
18
-
19
- const METADATA_FILE = "auth-instances.yaml";
20
- const INSTANCE_NAME_PATTERN = /^[a-zA-Z0-9._:@-]+$/;
21
- const storedInstanceSchema = zod.z.object({
22
- name: zod.z.string().min(1).regex(INSTANCE_NAME_PATTERN, "Instance name contains invalid characters"),
23
- baseUrl: zod.z.string().url(),
24
- clientId: zod.z.string().min(1),
25
- issuedAt: zod.z.number().int().nonnegative(),
26
- accessTokenExpiresAt: zod.z.number().int().nonnegative(),
27
- selected: zod.z.boolean().optional()
28
- });
29
- const authYamlSchema = zod.z.object({
30
- instances: zod.z.array(storedInstanceSchema).default([])
31
- });
32
- function getMetadataFilePath() {
33
- const root = process.env.XDG_CONFIG_HOME || (process.platform === "win32" ? process.env.APPDATA || path__default.default.join(os__default.default.homedir(), "AppData", "Roaming") : path__default.default.join(os__default.default.homedir(), ".config"));
34
- return path__default.default.join(root, "backstage-cli", METADATA_FILE);
35
- }
36
- async function readAll() {
37
- const file = getMetadataFilePath();
38
- if (!await fs__default.default.pathExists(file)) {
39
- return { instances: [] };
40
- }
41
- const text = await fs__default.default.readFile(file, "utf8");
42
- if (!text.trim()) {
43
- return { instances: [] };
44
- }
45
- try {
46
- const doc = YAML__default.default.parse(text);
47
- const parsed = authYamlSchema.safeParse(doc);
48
- if (parsed.success) {
49
- return parsed.data;
50
- }
51
- return { instances: [] };
52
- } catch {
53
- return { instances: [] };
54
- }
55
- }
56
- async function writeAll(data) {
57
- const file = getMetadataFilePath();
58
- await fs__default.default.ensureDir(path__default.default.dirname(file));
59
- const yaml = YAML__default.default.stringify(authYamlSchema.parse(data), { indentSeq: false });
60
- await fs__default.default.writeFile(file, yaml, { encoding: "utf8", mode: 384 });
61
- }
62
- async function getAllInstances() {
63
- const { instances } = await readAll();
64
- const selected = instances.find((i) => i.selected) ?? instances[0];
65
- return {
66
- // Normalize selection prop
67
- instances: instances.map((i) => ({
68
- ...i,
69
- selected: i.name === selected.name
70
- })),
71
- selected
72
- };
73
- }
74
- async function getSelectedInstance(instanceName) {
75
- if (instanceName) {
76
- return await getInstanceByName(instanceName);
77
- }
78
- const { selected } = await getAllInstances();
79
- if (!selected) {
80
- throw new Error(
81
- 'No instances found. Run "auth login" to authenticate first.'
82
- );
83
- }
84
- return selected;
85
- }
86
- async function getInstanceByName(name) {
87
- const { instances } = await readAll();
88
- const instance = instances.find((i) => i.name === name);
89
- if (!instance) {
90
- throw new errors.NotFoundError(`Instance '${name}' not found`);
91
- }
92
- return instance;
93
- }
94
- async function upsertInstance(instance) {
95
- const data = await readAll();
96
- const idx = data.instances.findIndex((i) => i.name === instance.name);
97
- if (idx === -1) {
98
- data.instances.push(instance);
99
- } else {
100
- data.instances[idx] = instance;
101
- }
102
- await writeAll(data);
103
- }
104
- async function removeInstance(name) {
105
- const data = await readAll();
106
- const next = data.instances.filter((i) => i.name !== name);
107
- if (next.length !== data.instances.length) {
108
- await writeAll({ instances: next });
109
- }
110
- }
111
- async function setSelectedInstance(name) {
112
- return withMetadataLock(async () => {
113
- const data = await readAll();
114
- let found = false;
115
- data.instances = data.instances.map((i) => {
116
- if (i.name === name) {
117
- found = true;
118
- return { ...i, selected: true };
119
- }
120
- const { selected, ...rest } = i;
121
- return { ...rest, selected: false };
122
- });
123
- if (!found) {
124
- throw new Error(`Unknown instance '${name}'`);
125
- }
126
- await writeAll(data);
127
- });
128
- }
129
- async function withMetadataLock(fn) {
130
- const file = getMetadataFilePath();
131
- await fs__default.default.ensureDir(path__default.default.dirname(file));
132
- if (!await fs__default.default.pathExists(file)) {
133
- await fs__default.default.writeFile(file, "", { encoding: "utf8", mode: 384 });
134
- }
135
- const release = await lockfile__default.default.lock(file, {
136
- retries: { retries: 5, factor: 1.5, minTimeout: 100, maxTimeout: 1e3 }
137
- });
138
- try {
139
- return await fn();
140
- } finally {
141
- await release();
142
- }
143
- }
144
-
145
- exports.getAllInstances = getAllInstances;
146
- exports.getInstanceByName = getInstanceByName;
147
- exports.getSelectedInstance = getSelectedInstance;
148
- exports.removeInstance = removeInstance;
149
- exports.setSelectedInstance = setSelectedInstance;
150
- exports.upsertInstance = upsertInstance;
151
- exports.withMetadataLock = withMetadataLock;
152
- //# sourceMappingURL=storage.cjs.js.map
@@ -1,53 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var fs = require('fs-extra');
6
- var cleye = require('cleye');
7
- var createDistWorkspace = require('../lib/packager/createDistWorkspace.cjs.js');
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
- var buildWorkspace = async ({ args, info }) => {
14
- const normalizedArgs = args.map((a) => {
15
- if (a === "--alwaysYarnPack") {
16
- return "--always-pack";
17
- }
18
- if (a.startsWith("--alwaysYarnPack=")) {
19
- return `--always-pack${a.substring("--alwaysYarnPack".length)}`;
20
- }
21
- return a;
22
- });
23
- const {
24
- flags: { alwaysPack },
25
- _: positionals
26
- } = cleye.cli(
27
- {
28
- help: { ...info, usage: `${info.usage} <workspace-dir> [packages...]` },
29
- booleanFlagNegation: true,
30
- parameters: ["<workspace-dir>", "[packages...]"],
31
- flags: {
32
- alwaysPack: {
33
- type: Boolean,
34
- description: "Force workspace output to be a result of running `yarn pack` on each package (warning: very slow)"
35
- }
36
- }
37
- },
38
- void 0,
39
- normalizedArgs
40
- );
41
- const [dir, ...packages] = positionals;
42
- if (!await fs__default.default.pathExists(dir)) {
43
- throw new Error(`Target workspace directory doesn't exist, '${dir}'`);
44
- }
45
- await createDistWorkspace.createDistWorkspace(packages, {
46
- targetDir: dir,
47
- alwaysPack,
48
- enableFeatureDetection: true
49
- });
50
- };
51
-
52
- exports.default = buildWorkspace;
53
- //# sourceMappingURL=buildWorkspace.cjs.js.map