@backstage/plugin-scaffolder-backend 1.5.0-next.2 → 1.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c4b452e16a: Starting the implementation of the Wizard page for the `next` scaffolder plugin
8
+ - 593dea6710: Add support for Basic Auth for Bitbucket Server.
9
+ - 3b7930b3e5: Add support for Bearer Authorization header / token-based auth at Git commands.
10
+ - 3f1316f1c5: User Bearer Authorization header at Git commands with token-based auth at Bitbucket Server.
11
+ - eeff5046ae: Updated `publish:gitlab:merge-request` action to allow commit updates and deletes
12
+ - 692d5d3405: Added `reviewers` and `teamReviewers` parameters to `publish:github:pull-request` action to add reviewers on the pull request created by the action
13
+
14
+ ### Patch Changes
15
+
16
+ - fc8a5f797b: Add a `publish:gerrit:review` scaffolder action
17
+ - c971afbf21: The `publish:file` action has been deprecated in favor of testing templates using the template editor instead. Note that this action is not and was never been installed by default.
18
+ - b10b6c4aa4: Fix issue on Windows where templated files where not properly skipped as intended.
19
+ - 56e1b4b89c: Fixed typos in alpha types.
20
+ - dad0f65494: Fail gracefully if an invalid `Authorization` header is passed to `POST /v2/tasks`
21
+ - 014b3b7776: Add missing `res.end()` in scaffolder backend `EventStream` usage
22
+ - Updated dependencies
23
+ - @backstage/backend-common@0.15.0
24
+ - @backstage/backend-plugin-api@0.1.1
25
+ - @backstage/plugin-catalog-node@1.0.1
26
+ - @backstage/integration@1.3.0
27
+ - @backstage/plugin-catalog-backend@1.3.1
28
+
3
29
  ## 1.5.0-next.2
4
30
 
5
31
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
- "version": "1.5.0-next.2",
3
+ "version": "1.5.0",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  /// <reference types="node" />
8
8
 
9
- import { BackendRegistrable } from '@backstage/backend-plugin-api';
9
+ import { BackendFeature } from '@backstage/backend-plugin-api';
10
10
  import { CatalogApi } from '@backstage/catalog-client';
11
11
  import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
12
12
  import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
@@ -419,6 +419,7 @@ token?: string | undefined;
419
419
  * production, as it writes the files to the local filesystem of the scaffolder.
420
420
  *
421
421
  * @public
422
+ * @deprecated This action will be removed, prefer testing templates using the template editor instead.
422
423
  */
423
424
  export declare function createPublishFileAction(): TemplateAction< {
424
425
  path: string;
@@ -721,7 +722,7 @@ export declare type RunCommandOptions = {
721
722
  * @alpha
722
723
  * Registers the ScaffolderEntitiesProcessor with the catalog processing extension point.
723
724
  */
724
- export declare const scaffolderCatalogModule: (option: unknown) => BackendRegistrable;
725
+ export declare const scaffolderCatalogModule: (options?: unknown) => BackendFeature;
725
726
 
726
727
  /** @public */
727
728
  export declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
@@ -6,7 +6,7 @@
6
6
 
7
7
  /// <reference types="node" />
8
8
 
9
- import { BackendRegistrable } from '@backstage/backend-plugin-api';
9
+ import { BackendFeature } from '@backstage/backend-plugin-api';
10
10
  import { CatalogApi } from '@backstage/catalog-client';
11
11
  import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
12
12
  import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
@@ -419,6 +419,7 @@ token?: string | undefined;
419
419
  * production, as it writes the files to the local filesystem of the scaffolder.
420
420
  *
421
421
  * @public
422
+ * @deprecated This action will be removed, prefer testing templates using the template editor instead.
422
423
  */
423
424
  export declare function createPublishFileAction(): TemplateAction< {
424
425
  path: string;
package/dist/index.cjs.js CHANGED
@@ -673,7 +673,7 @@ function createFetchTemplateAction(options) {
673
673
  });
674
674
  }
675
675
  function containsSkippedContent(localOutputPath) {
676
- return localOutputPath === "" || path__default["default"].isAbsolute(localOutputPath) || localOutputPath.includes(`${path__default["default"].sep}${path__default["default"].sep}`);
676
+ return localOutputPath === "" || localOutputPath.startsWith("/") || localOutputPath.includes("//");
677
677
  }
678
678
 
679
679
  const createFilesystemDeleteAction = () => {
@@ -2561,6 +2561,9 @@ function createPublishFileAction() {
2561
2561
  }
2562
2562
  },
2563
2563
  async handler(ctx) {
2564
+ ctx.logger.warn(
2565
+ "[DEPRECATED] This action will be removed, prefer testing templates using the template editor instead."
2566
+ );
2564
2567
  const { path: path$1 } = ctx.input;
2565
2568
  const exists = await fs__default["default"].pathExists(path$1);
2566
2569
  if (exists) {
@@ -4506,7 +4509,10 @@ async function createRouter(options) {
4506
4509
  async (req, res) => {
4507
4510
  var _a, _b;
4508
4511
  const { namespace, kind, name } = req.params;
4509
- const { token } = parseBearerToken(req.headers.authorization);
4512
+ const { token } = parseBearerToken({
4513
+ header: req.headers.authorization,
4514
+ logger
4515
+ });
4510
4516
  const template = await findTemplate({
4511
4517
  catalogApi: catalogClient,
4512
4518
  entityRef: { kind, namespace, name },
@@ -4547,9 +4553,10 @@ async function createRouter(options) {
4547
4553
  const { kind, namespace, name } = catalogModel.parseEntityRef(templateRef, {
4548
4554
  defaultKind: "template"
4549
4555
  });
4550
- const { token, entityRef: userEntityRef } = parseBearerToken(
4551
- req.headers.authorization
4552
- );
4556
+ const { token, entityRef: userEntityRef } = parseBearerToken({
4557
+ header: req.headers.authorization,
4558
+ logger
4559
+ });
4553
4560
  const userEntity = userEntityRef ? await catalogClient.getEntityByRef(userEntityRef, { token }) : void 0;
4554
4561
  let auditLog = `Scaffolding task for ${templateRef}`;
4555
4562
  if (userEntityRef) {
@@ -4711,7 +4718,10 @@ data: ${JSON.stringify(event)}
4711
4718
  if (!await pluginScaffolderCommon.templateEntityV1beta3Validator.check(template)) {
4712
4719
  throw new errors.InputError("Input template is not a template");
4713
4720
  }
4714
- const { token } = parseBearerToken(req.headers.authorization);
4721
+ const { token } = parseBearerToken({
4722
+ header: req.headers.authorization,
4723
+ logger
4724
+ });
4715
4725
  for (const parameters of [(_a = template.spec.parameters) != null ? _a : []].flat()) {
4716
4726
  const result2 = jsonschema.validate(body.values, parameters);
4717
4727
  if (!result2.valid) {
@@ -4758,7 +4768,10 @@ data: ${JSON.stringify(event)}
4758
4768
  app.use("/", router);
4759
4769
  return app;
4760
4770
  }
4761
- function parseBearerToken(header) {
4771
+ function parseBearerToken({
4772
+ header,
4773
+ logger
4774
+ }) {
4762
4775
  var _a;
4763
4776
  if (!header) {
4764
4777
  return {};
@@ -4779,9 +4792,11 @@ function parseBearerToken(header) {
4779
4792
  if (typeof sub !== "string") {
4780
4793
  throw new TypeError("Expected string sub claim");
4781
4794
  }
4795
+ catalogModel.parseEntityRef(sub);
4782
4796
  return { entityRef: sub, token };
4783
4797
  } catch (e) {
4784
- throw new errors.InputError(`Invalid authorization header: ${errors.stringifyError(e)}`);
4798
+ logger.error(`Invalid authorization header: ${errors.stringifyError(e)}`);
4799
+ return {};
4785
4800
  }
4786
4801
  }
4787
4802
 
@@ -4844,12 +4859,10 @@ const scaffolderCatalogModule = backendPluginApi.createBackendModule({
4844
4859
  register(env) {
4845
4860
  env.registerInit({
4846
4861
  deps: {
4847
- catalogProcessingExtensionPoint: pluginCatalogNode.catalogProcessingExtentionPoint
4862
+ catalog: pluginCatalogNode.catalogProcessingExtensionPoint
4848
4863
  },
4849
- async init({ catalogProcessingExtensionPoint }) {
4850
- catalogProcessingExtensionPoint.addProcessor(
4851
- new ScaffolderEntitiesProcessor()
4852
- );
4864
+ async init({ catalog }) {
4865
+ catalog.addProcessor(new ScaffolderEntitiesProcessor());
4853
4866
  }
4854
4867
  });
4855
4868
  }