@backstage/plugin-scaffolder-backend 1.6.0-next.3 → 1.7.0-next.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,82 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.7.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 253453fa14: Added a new property called `additionalTemplateGlobals` which allows you to add global functions to the scaffolder nunjucks templates.
8
+ - 304305dd20: Add `allowAutoMerge` option for `publish:github` action
9
+ - 694bfe2d61: Add functionality to shutdown scaffolder tasks if they are stale
10
+
11
+ ### Patch Changes
12
+
13
+ - b681275e69: Ignore .git directories in Template Editor, increase upload limit for dry-runs to 10MB.
14
+ - Updated dependencies
15
+ - @backstage/catalog-model@1.1.2-next.0
16
+ - @backstage/backend-plugin-api@0.1.3-next.0
17
+ - @backstage/plugin-catalog-backend@1.4.1-next.0
18
+ - @backstage/catalog-client@1.1.1-next.0
19
+ - @backstage/plugin-catalog-node@1.1.1-next.0
20
+ - @backstage/plugin-scaffolder-common@1.2.1-next.0
21
+ - @backstage/backend-common@0.15.2-next.0
22
+ - @backstage/backend-tasks@0.3.6-next.0
23
+ - @backstage/plugin-auth-node@0.2.6-next.0
24
+ - @backstage/config@1.0.3-next.0
25
+ - @backstage/errors@1.1.2-next.0
26
+ - @backstage/integration@1.3.2-next.0
27
+ - @backstage/types@1.0.0
28
+
29
+ ## 1.6.0
30
+
31
+ ### Minor Changes
32
+
33
+ - ea2eee9e6a: Add the option for a homepage when using the `github:publish` action
34
+ - 8872cc735d: Fixed a bug in plugin-scaffolder-backend where it ignores the skip migration database options.
35
+
36
+ To use this new implementation you need to create the instance of `DatabaseTaskStore` using the `PluginDatabaseManager` instead of `Knex`;
37
+
38
+ ```
39
+ import { DatabaseManager, getRootLogger, loadBackendConfig } from '@backstage/backend-common';
40
+ import { DatabaseTaskStore } from '@backstage/plugin-scaffolder-backend';
41
+
42
+ const config = await loadBackendConfig({ argv: process.argv, logger: getRootLogger() });
43
+ const databaseManager = DatabaseManager.fromConfig(config, { migrations: { skip: true } });
44
+ const databaseTaskStore = await DatabaseTaskStore.create(databaseManager);
45
+ ```
46
+
47
+ - 7db9613671: Added `projectId` for gitlab projects to be displayed in the `gitlab:publish` output
48
+ - d1f7ba58e3: Added `repositoryId` output when create a repository in Azure
49
+ - 1ff817b3f0: add entity metadata to the template info type
50
+
51
+ ### Patch Changes
52
+
53
+ - eadf56bbbf: Bump `git-url-parse` version to `^13.0.0`
54
+ - de8ee4afe3: Provide information about the user into scaffolder template action's context
55
+ - 096631e571: Added support for handling broken symlinks within the scaffolder backend. This is intended for templates that may hold a symlink that is invalid at build time but valid within the destination repo.
56
+ - 0d8d650e32: Applied the fix from version 1.5.1 of this package, which is part of the v1.5.1 release of Backstage.
57
+ - 667d917488: Updated dependency `msw` to `^0.47.0`.
58
+ - 87ec2ba4d6: Updated dependency `msw` to `^0.46.0`.
59
+ - bf5e9030eb: Updated dependency `msw` to `^0.45.0`.
60
+ - 2df9955f4a: Removed the depreacated `publish:file` action, use the template editor to test templates instead.
61
+ - 0ecc9a6784: Properly set `ctx.isDryRun` when running actions in dry run mode. Also always log action inputs for debugging purposes when running in dry run mode.
62
+ - 6b9f6c0a4d: Added alpha `scaffolderPlugin` to be used with experimental backend system.
63
+ - 83c037cd46: Disable octokit throttling in publish:github:pull-request
64
+ - 2cbd533426: Uptake the `IdentityApi` change to use `getIdentity` instead of `authenticate` for retrieving the logged in users identity.
65
+ - ef9ab322de: Minor API signatures cleanup
66
+ - 50467bc15b: The number of task workers used to execute templates now default to 3, rather than 1.
67
+ - Updated dependencies
68
+ - @backstage/backend-plugin-api@0.1.2
69
+ - @backstage/backend-common@0.15.1
70
+ - @backstage/plugin-auth-node@0.2.5
71
+ - @backstage/plugin-catalog-node@1.1.0
72
+ - @backstage/integration@1.3.1
73
+ - @backstage/plugin-catalog-backend@1.4.0
74
+ - @backstage/catalog-client@1.1.0
75
+ - @backstage/catalog-model@1.1.1
76
+ - @backstage/config@1.0.2
77
+ - @backstage/errors@1.1.1
78
+ - @backstage/plugin-scaffolder-common@1.2.0
79
+
3
80
  ## 1.6.0-next.3
4
81
 
5
82
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
- "version": "1.6.0-next.3",
3
+ "version": "1.7.0-next.0",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -24,6 +24,7 @@ import { Logger } from 'winston';
24
24
  import { Observable } from '@backstage/types';
25
25
  import { Octokit } from 'octokit';
26
26
  import { PluginDatabaseManager } from '@backstage/backend-common';
27
+ import { PluginTaskScheduler } from '@backstage/backend-tasks';
27
28
  import { Schema } from 'jsonschema';
28
29
  import { ScmIntegrationRegistry } from '@backstage/integration';
29
30
  import { ScmIntegrations } from '@backstage/integration';
@@ -32,6 +33,7 @@ import { TaskSpec } from '@backstage/plugin-scaffolder-common';
32
33
  import { TaskSpecV1beta3 } from '@backstage/plugin-scaffolder-common';
33
34
  import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
34
35
  import { UrlReader } from '@backstage/backend-common';
36
+ import { UserEntity } from '@backstage/catalog-model';
35
37
  import { Writable } from 'stream';
36
38
 
37
39
  /**
@@ -55,6 +57,19 @@ export declare type ActionContext<Input extends JsonObject> = {
55
57
  * This will only ever be true if the actions as marked as supporting dry-runs.
56
58
  */
57
59
  isDryRun?: boolean;
60
+ /**
61
+ * The user which triggered the action.
62
+ */
63
+ user?: {
64
+ /**
65
+ * The decorated entity from the Catalog
66
+ */
67
+ entity?: UserEntity;
68
+ /**
69
+ * An entity ref for the author of the task
70
+ */
71
+ ref?: string;
72
+ };
58
73
  };
59
74
 
60
75
  /**
@@ -92,6 +107,7 @@ export declare interface CreateBuiltInActionsOptions {
92
107
  * Template Manifests and also template skeleton files when using `fetch:template`.
93
108
  */
94
109
  additionalTemplateFilters?: Record<string, TemplateFilter>;
110
+ additionalTemplateGlobals?: Record<string, TemplateGlobal>;
95
111
  }
96
112
 
97
113
  /**
@@ -158,6 +174,7 @@ export declare function createFetchTemplateAction(options: {
158
174
  reader: UrlReader;
159
175
  integrations: ScmIntegrations;
160
176
  additionalTemplateFilters?: Record<string, TemplateFilter>;
177
+ additionalTemplateGlobals?: Record<string, TemplateGlobal>;
161
178
  }): TemplateAction< {
162
179
  url: string;
163
180
  targetPath?: string | undefined;
@@ -273,6 +290,7 @@ gitAuthorEmail?: string | undefined;
273
290
  allowRebaseMerge?: boolean | undefined;
274
291
  allowSquashMerge?: boolean | undefined;
275
292
  allowMergeCommit?: boolean | undefined;
293
+ allowAutoMerge?: boolean | undefined;
276
294
  requireCodeOwnerReviews?: boolean | undefined;
277
295
  requiredStatusCheckContexts?: string[] | undefined;
278
296
  repoVisibility?: "internal" | "private" | "public" | undefined;
@@ -470,6 +488,7 @@ gitAuthorEmail?: string | undefined;
470
488
  allowRebaseMerge?: boolean | undefined;
471
489
  allowSquashMerge?: boolean | undefined;
472
490
  allowMergeCommit?: boolean | undefined;
491
+ allowAutoMerge?: boolean | undefined;
473
492
  sourcePath?: string | undefined;
474
493
  requireCodeOwnerReviews?: boolean | undefined;
475
494
  requiredStatusCheckContexts?: string[] | undefined;
@@ -572,6 +591,7 @@ export declare type CreateWorkerOptions = {
572
591
  workingDirectory: string;
573
592
  logger: Logger;
574
593
  additionalTemplateFilters?: Record<string, TemplateFilter>;
594
+ additionalTemplateGlobals?: Record<string, TemplateGlobal>;
575
595
  };
576
596
 
577
597
  /**
@@ -636,6 +656,7 @@ export declare class DatabaseTaskStore implements TaskStore {
636
656
  listEvents(options: TaskStoreListEventsOptions): Promise<{
637
657
  events: SerializedTaskEvent[];
638
658
  }>;
659
+ shutdownTask({ taskId }: TaskStoreShutDownTaskOptions): Promise<void>;
639
660
  }
640
661
 
641
662
  /**
@@ -689,10 +710,12 @@ export declare interface RouterOptions {
689
710
  reader: UrlReader;
690
711
  database: PluginDatabaseManager;
691
712
  catalogClient: CatalogApi;
713
+ scheduler?: PluginTaskScheduler;
692
714
  actions?: TemplateAction<any>[];
693
715
  taskWorkers?: number;
694
716
  taskBroker?: TaskBroker;
695
717
  additionalTemplateFilters?: Record<string, TemplateFilter>;
718
+ additionalTemplateGlobals?: Record<string, TemplateGlobal>;
696
719
  identity?: IdentityApi;
697
720
  }
698
721
 
@@ -737,6 +760,7 @@ export declare type ScaffolderPluginOptions = {
737
760
  taskWorkers?: number;
738
761
  taskBroker?: TaskBroker;
739
762
  additionalTemplateFilters?: Record<string, TemplateFilter>;
763
+ additionalTemplateGlobals?: Record<string, TemplateGlobal>;
740
764
  };
741
765
 
742
766
  /**
@@ -913,6 +937,7 @@ export declare interface TaskStore {
913
937
  listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
914
938
  events: SerializedTaskEvent[];
915
939
  }>;
940
+ shutdownTask?({ taskId }: TaskStoreShutDownTaskOptions): Promise<void>;
916
941
  }
917
942
 
918
943
  /**
@@ -953,6 +978,15 @@ export declare type TaskStoreListEventsOptions = {
953
978
  after?: number | undefined;
954
979
  };
955
980
 
981
+ /**
982
+ * TaskStoreShutDownTaskOptions
983
+ *
984
+ * @public
985
+ */
986
+ export declare type TaskStoreShutDownTaskOptions = {
987
+ taskId: string;
988
+ };
989
+
956
990
  /**
957
991
  * TaskWorker
958
992
  *
@@ -992,4 +1026,7 @@ export declare class TemplateActionRegistry {
992
1026
  /** @public */
993
1027
  export declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
994
1028
 
1029
+ /** @public */
1030
+ export declare type TemplateGlobal = ((...args: JsonValue[]) => JsonValue | undefined) | JsonValue;
1031
+
995
1032
  export { }
@@ -24,6 +24,7 @@ import { Logger } from 'winston';
24
24
  import { Observable } from '@backstage/types';
25
25
  import { Octokit } from 'octokit';
26
26
  import { PluginDatabaseManager } from '@backstage/backend-common';
27
+ import { PluginTaskScheduler } from '@backstage/backend-tasks';
27
28
  import { Schema } from 'jsonschema';
28
29
  import { ScmIntegrationRegistry } from '@backstage/integration';
29
30
  import { ScmIntegrations } from '@backstage/integration';
@@ -32,6 +33,7 @@ import { TaskSpec } from '@backstage/plugin-scaffolder-common';
32
33
  import { TaskSpecV1beta3 } from '@backstage/plugin-scaffolder-common';
33
34
  import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
34
35
  import { UrlReader } from '@backstage/backend-common';
36
+ import { UserEntity } from '@backstage/catalog-model';
35
37
  import { Writable } from 'stream';
36
38
 
37
39
  /**
@@ -55,6 +57,19 @@ export declare type ActionContext<Input extends JsonObject> = {
55
57
  * This will only ever be true if the actions as marked as supporting dry-runs.
56
58
  */
57
59
  isDryRun?: boolean;
60
+ /**
61
+ * The user which triggered the action.
62
+ */
63
+ user?: {
64
+ /**
65
+ * The decorated entity from the Catalog
66
+ */
67
+ entity?: UserEntity;
68
+ /**
69
+ * An entity ref for the author of the task
70
+ */
71
+ ref?: string;
72
+ };
58
73
  };
59
74
 
60
75
  /**
@@ -92,6 +107,7 @@ export declare interface CreateBuiltInActionsOptions {
92
107
  * Template Manifests and also template skeleton files when using `fetch:template`.
93
108
  */
94
109
  additionalTemplateFilters?: Record<string, TemplateFilter>;
110
+ additionalTemplateGlobals?: Record<string, TemplateGlobal>;
95
111
  }
96
112
 
97
113
  /**
@@ -158,6 +174,7 @@ export declare function createFetchTemplateAction(options: {
158
174
  reader: UrlReader;
159
175
  integrations: ScmIntegrations;
160
176
  additionalTemplateFilters?: Record<string, TemplateFilter>;
177
+ additionalTemplateGlobals?: Record<string, TemplateGlobal>;
161
178
  }): TemplateAction< {
162
179
  url: string;
163
180
  targetPath?: string | undefined;
@@ -273,6 +290,7 @@ gitAuthorEmail?: string | undefined;
273
290
  allowRebaseMerge?: boolean | undefined;
274
291
  allowSquashMerge?: boolean | undefined;
275
292
  allowMergeCommit?: boolean | undefined;
293
+ allowAutoMerge?: boolean | undefined;
276
294
  requireCodeOwnerReviews?: boolean | undefined;
277
295
  requiredStatusCheckContexts?: string[] | undefined;
278
296
  repoVisibility?: "internal" | "private" | "public" | undefined;
@@ -470,6 +488,7 @@ gitAuthorEmail?: string | undefined;
470
488
  allowRebaseMerge?: boolean | undefined;
471
489
  allowSquashMerge?: boolean | undefined;
472
490
  allowMergeCommit?: boolean | undefined;
491
+ allowAutoMerge?: boolean | undefined;
473
492
  sourcePath?: string | undefined;
474
493
  requireCodeOwnerReviews?: boolean | undefined;
475
494
  requiredStatusCheckContexts?: string[] | undefined;
@@ -572,6 +591,7 @@ export declare type CreateWorkerOptions = {
572
591
  workingDirectory: string;
573
592
  logger: Logger;
574
593
  additionalTemplateFilters?: Record<string, TemplateFilter>;
594
+ additionalTemplateGlobals?: Record<string, TemplateGlobal>;
575
595
  };
576
596
 
577
597
  /**
@@ -636,6 +656,7 @@ export declare class DatabaseTaskStore implements TaskStore {
636
656
  listEvents(options: TaskStoreListEventsOptions): Promise<{
637
657
  events: SerializedTaskEvent[];
638
658
  }>;
659
+ shutdownTask({ taskId }: TaskStoreShutDownTaskOptions): Promise<void>;
639
660
  }
640
661
 
641
662
  /**
@@ -689,10 +710,12 @@ export declare interface RouterOptions {
689
710
  reader: UrlReader;
690
711
  database: PluginDatabaseManager;
691
712
  catalogClient: CatalogApi;
713
+ scheduler?: PluginTaskScheduler;
692
714
  actions?: TemplateAction<any>[];
693
715
  taskWorkers?: number;
694
716
  taskBroker?: TaskBroker;
695
717
  additionalTemplateFilters?: Record<string, TemplateFilter>;
718
+ additionalTemplateGlobals?: Record<string, TemplateGlobal>;
696
719
  identity?: IdentityApi;
697
720
  }
698
721
 
@@ -896,6 +919,7 @@ export declare interface TaskStore {
896
919
  listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
897
920
  events: SerializedTaskEvent[];
898
921
  }>;
922
+ shutdownTask?({ taskId }: TaskStoreShutDownTaskOptions): Promise<void>;
899
923
  }
900
924
 
901
925
  /**
@@ -936,6 +960,15 @@ export declare type TaskStoreListEventsOptions = {
936
960
  after?: number | undefined;
937
961
  };
938
962
 
963
+ /**
964
+ * TaskStoreShutDownTaskOptions
965
+ *
966
+ * @public
967
+ */
968
+ export declare type TaskStoreShutDownTaskOptions = {
969
+ taskId: string;
970
+ };
971
+
939
972
  /**
940
973
  * TaskWorker
941
974
  *
@@ -975,4 +1008,7 @@ export declare class TemplateActionRegistry {
975
1008
  /** @public */
976
1009
  export declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
977
1010
 
1011
+ /** @public */
1012
+ export declare type TemplateGlobal = ((...args: JsonValue[]) => JsonValue | undefined) | JsonValue;
1013
+
978
1014
  export { }