@backstage/plugin-scaffolder-backend 1.10.1 → 1.11.0-next.1

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/dist/index.cjs.js CHANGED
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var errors = require('@backstage/errors');
6
6
  var catalogModel = require('@backstage/catalog-model');
7
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
7
8
  var yaml = require('yaml');
8
9
  var fs = require('fs-extra');
9
10
  var backendCommon = require('@backstage/backend-common');
@@ -78,10 +79,6 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
78
79
  var Router__default = /*#__PURE__*/_interopDefaultLegacy(Router);
79
80
  var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
80
81
 
81
- const createTemplateAction = (templateAction) => {
82
- return templateAction;
83
- };
84
-
85
82
  const id$3 = "catalog:register";
86
83
  const examples$3 = [
87
84
  {
@@ -102,7 +99,7 @@ const examples$3 = [
102
99
  ];
103
100
  function createCatalogRegisterAction(options) {
104
101
  const { catalogClient, integrations } = options;
105
- return createTemplateAction({
102
+ return pluginScaffolderNode.createTemplateAction({
106
103
  id: id$3,
107
104
  description: "Registers entities from a catalog descriptor file in the workspace into the software catalog.",
108
105
  examples: examples$3,
@@ -254,7 +251,7 @@ const examples$2 = [
254
251
  }
255
252
  ];
256
253
  function createCatalogWriteAction() {
257
- return createTemplateAction({
254
+ return pluginScaffolderNode.createTemplateAction({
258
255
  id: id$2,
259
256
  description: "Writes the catalog-info.yaml for your template",
260
257
  examples: examples$2,
@@ -308,7 +305,7 @@ const examples$1 = [
308
305
  ];
309
306
  function createFetchCatalogEntityAction(options) {
310
307
  const { catalogClient } = options;
311
- return createTemplateAction({
308
+ return pluginScaffolderNode.createTemplateAction({
312
309
  id: id$1,
313
310
  description: "Returns entity from the catalog by entity reference",
314
311
  examples: examples$1,
@@ -392,7 +389,7 @@ const examples = [
392
389
  }
393
390
  ];
394
391
  function createDebugLogAction() {
395
- return createTemplateAction({
392
+ return pluginScaffolderNode.createTemplateAction({
396
393
  id,
397
394
  description: "Writes a message into the log or lists all files in the workspace.",
398
395
  examples,
@@ -480,7 +477,7 @@ async function fetchContents(options) {
480
477
 
481
478
  function createFetchPlainAction(options) {
482
479
  const { reader, integrations } = options;
483
- return createTemplateAction({
480
+ return pluginScaffolderNode.createTemplateAction({
484
481
  id: "fetch:plain",
485
482
  description: "Downloads content and places it in the workspace, or optionally in a subdirectory specified by the `targetPath` input option.",
486
483
  schema: {
@@ -665,7 +662,7 @@ function createFetchTemplateAction(options) {
665
662
  additionalTemplateFilters,
666
663
  additionalTemplateGlobals
667
664
  } = options;
668
- return createTemplateAction({
665
+ return pluginScaffolderNode.createTemplateAction({
669
666
  id: "fetch:template",
670
667
  description: "Downloads a skeleton, templates variables into file and directory names and content, and places the result in the workspace, or optionally in a subdirectory specified by the `targetPath` input option.",
671
668
  schema: {
@@ -713,6 +710,11 @@ function createFetchTemplateAction(options) {
713
710
  title: "Template File Extension",
714
711
  description: "If set, only files with the given extension will be templated. If set to `true`, the default extension `.njk` is used.",
715
712
  type: ["string", "boolean"]
713
+ },
714
+ replace: {
715
+ title: "Replace files",
716
+ description: "If set, replace files in targetPath instead of skipping existing ones.",
717
+ type: "boolean"
716
718
  }
717
719
  }
718
720
  }
@@ -821,7 +823,7 @@ function createFetchTemplateAction(options) {
821
823
  continue;
822
824
  }
823
825
  const outputPath = backendCommon.resolveSafeChildPath(outputDir, localOutputPath);
824
- if (fs__default["default"].existsSync(outputPath)) {
826
+ if (fs__default["default"].existsSync(outputPath) && !ctx.input.replace) {
825
827
  continue;
826
828
  }
827
829
  if (!renderContents && !extension) {
@@ -865,7 +867,7 @@ function containsSkippedContent(localOutputPath) {
865
867
  }
866
868
 
867
869
  const createFilesystemDeleteAction = () => {
868
- return createTemplateAction({
870
+ return pluginScaffolderNode.createTemplateAction({
869
871
  id: "fs:delete",
870
872
  description: "Deletes files and directories from the workspace",
871
873
  schema: {
@@ -905,7 +907,7 @@ const createFilesystemDeleteAction = () => {
905
907
  };
906
908
 
907
909
  const createFilesystemRenameAction = () => {
908
- return createTemplateAction({
910
+ return pluginScaffolderNode.createTemplateAction({
909
911
  id: "fs:rename",
910
912
  description: "Renames files and directories within the workspace",
911
913
  schema: {
@@ -1428,7 +1430,7 @@ function extractCollaboratorName(collaborator) {
1428
1430
 
1429
1431
  function createGithubActionsDispatchAction(options) {
1430
1432
  const { integrations, githubCredentialsProvider } = options;
1431
- return createTemplateAction({
1433
+ return pluginScaffolderNode.createTemplateAction({
1432
1434
  id: "github:actions:dispatch",
1433
1435
  description: "Dispatches a GitHub Action workflow for a given branch or tag",
1434
1436
  schema: {
@@ -1501,7 +1503,7 @@ function createGithubActionsDispatchAction(options) {
1501
1503
 
1502
1504
  function createGithubIssuesLabelAction(options) {
1503
1505
  const { integrations, githubCredentialsProvider } = options;
1504
- return createTemplateAction({
1506
+ return pluginScaffolderNode.createTemplateAction({
1505
1507
  id: "github:issues:label",
1506
1508
  description: "Adds labels to a pull request or issue on GitHub.",
1507
1509
  schema: {
@@ -1814,7 +1816,7 @@ const repoContentsUrl = {
1814
1816
 
1815
1817
  function createGithubRepoCreateAction(options) {
1816
1818
  const { integrations, githubCredentialsProvider } = options;
1817
- return createTemplateAction({
1819
+ return pluginScaffolderNode.createTemplateAction({
1818
1820
  id: "github:repo:create",
1819
1821
  description: "Creates a GitHub repository.",
1820
1822
  schema: {
@@ -1919,7 +1921,7 @@ function createGithubRepoCreateAction(options) {
1919
1921
 
1920
1922
  function createGithubRepoPushAction(options) {
1921
1923
  const { integrations, config, githubCredentialsProvider } = options;
1922
- return createTemplateAction({
1924
+ return pluginScaffolderNode.createTemplateAction({
1923
1925
  id: "github:repo:push",
1924
1926
  description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
1925
1927
  schema: {
@@ -2024,7 +2026,7 @@ function createGithubRepoPushAction(options) {
2024
2026
  function createGithubWebhookAction(options) {
2025
2027
  const { integrations, defaultWebhookSecret, githubCredentialsProvider } = options;
2026
2028
  const eventNames = webhooks.emitterEventNames.filter((event) => !event.includes("."));
2027
- return createTemplateAction({
2029
+ return pluginScaffolderNode.createTemplateAction({
2028
2030
  id: "github:webhook",
2029
2031
  description: "Creates webhook for a repository on GitHub.",
2030
2032
  schema: {
@@ -2141,7 +2143,7 @@ function createGithubWebhookAction(options) {
2141
2143
 
2142
2144
  function createPublishAzureAction(options) {
2143
2145
  const { integrations, config } = options;
2144
- return createTemplateAction({
2146
+ return pluginScaffolderNode.createTemplateAction({
2145
2147
  id: "publish:azure",
2146
2148
  description: "Initializes a git repository of the content in the workspace, and publishes it to Azure.",
2147
2149
  schema: {
@@ -2404,7 +2406,7 @@ const performEnableLFS$1 = async (opts) => {
2404
2406
  };
2405
2407
  function createPublishBitbucketAction(options) {
2406
2408
  const { integrations, config } = options;
2407
- return createTemplateAction({
2409
+ return pluginScaffolderNode.createTemplateAction({
2408
2410
  id: "publish:bitbucket",
2409
2411
  description: "Initializes a git repository of the content in the workspace, and publishes it to Bitbucket.",
2410
2412
  schema: {
@@ -2631,7 +2633,7 @@ const getAuthorizationHeader = (config) => {
2631
2633
  };
2632
2634
  function createPublishBitbucketCloudAction(options) {
2633
2635
  const { integrations, config } = options;
2634
- return createTemplateAction({
2636
+ return pluginScaffolderNode.createTemplateAction({
2635
2637
  id: "publish:bitbucketCloud",
2636
2638
  description: "Initializes a git repository of the content in the workspace, and publishes it to Bitbucket Cloud.",
2637
2639
  schema: {
@@ -2825,7 +2827,7 @@ const performEnableLFS = async (opts) => {
2825
2827
  };
2826
2828
  function createPublishBitbucketServerAction(options) {
2827
2829
  const { integrations, config } = options;
2828
- return createTemplateAction({
2830
+ return pluginScaffolderNode.createTemplateAction({
2829
2831
  id: "publish:bitbucketServer",
2830
2832
  description: "Initializes a git repository of the content in the workspace, and publishes it to Bitbucket Server.",
2831
2833
  schema: {
@@ -3005,7 +3007,7 @@ Change-Id: I${changeId}`;
3005
3007
  };
3006
3008
  function createPublishGerritAction(options) {
3007
3009
  const { integrations, config } = options;
3008
- return createTemplateAction({
3010
+ return pluginScaffolderNode.createTemplateAction({
3009
3011
  id: "publish:gerrit",
3010
3012
  description: "Initializes a git repository of the content in the workspace, and publishes it to Gerrit.",
3011
3013
  schema: {
@@ -3124,7 +3126,7 @@ const generateGerritChangeId = () => {
3124
3126
  };
3125
3127
  function createPublishGerritReviewAction(options) {
3126
3128
  const { integrations, config } = options;
3127
- return createTemplateAction({
3129
+ return pluginScaffolderNode.createTemplateAction({
3128
3130
  id: "publish:gerrit:review",
3129
3131
  description: "Creates a new Gerrit review.",
3130
3132
  schema: {
@@ -3229,7 +3231,7 @@ Change-Id: ${changeId}`;
3229
3231
 
3230
3232
  function createPublishGithubAction(options) {
3231
3233
  const { integrations, config, githubCredentialsProvider } = options;
3232
- return createTemplateAction({
3234
+ return pluginScaffolderNode.createTemplateAction({
3233
3235
  id: "publish:github",
3234
3236
  description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
3235
3237
  schema: {
@@ -3478,7 +3480,7 @@ const createPublishGithubPullRequestAction = ({
3478
3480
  githubCredentialsProvider,
3479
3481
  clientFactory = defaultClientFactory
3480
3482
  }) => {
3481
- return createTemplateAction({
3483
+ return pluginScaffolderNode.createTemplateAction({
3482
3484
  id: "publish:github:pull-request",
3483
3485
  schema: {
3484
3486
  input: {
@@ -3680,7 +3682,7 @@ const createPublishGithubPullRequestAction = ({
3680
3682
 
3681
3683
  function createPublishGitlabAction(options) {
3682
3684
  const { integrations, config } = options;
3683
- return createTemplateAction({
3685
+ return pluginScaffolderNode.createTemplateAction({
3684
3686
  id: "publish:gitlab",
3685
3687
  description: "Initializes a git repository of the content in the workspace, and publishes it to GitLab.",
3686
3688
  schema: {
@@ -3837,7 +3839,7 @@ function createPublishGitlabAction(options) {
3837
3839
 
3838
3840
  const createPublishGitlabMergeRequestAction = (options) => {
3839
3841
  const { integrations } = options;
3840
- return createTemplateAction({
3842
+ return pluginScaffolderNode.createTemplateAction({
3841
3843
  id: "publish:gitlab:merge-request",
3842
3844
  schema: {
3843
3845
  input: {
@@ -5055,7 +5057,7 @@ function createDryRunner(options) {
5055
5057
  const workflowRunner = new NunjucksWorkflowRunner({
5056
5058
  ...options,
5057
5059
  actionRegistry: new DecoratedActionsRegistry(options.actionRegistry, [
5058
- createTemplateAction({
5060
+ pluginScaffolderNode.createTemplateAction({
5059
5061
  id: "dry-run:extract",
5060
5062
  supportsDryRun: true,
5061
5063
  async handler(ctx) {
@@ -5620,9 +5622,9 @@ class ScaffolderEntitiesProcessor {
5620
5622
  }
5621
5623
  }
5622
5624
 
5623
- const scaffolderCatalogModule = backendPluginApi.createBackendModule({
5625
+ const catalogModuleTemplateKind = backendPluginApi.createBackendModule({
5624
5626
  moduleId: "scaffolder",
5625
- pluginId: "catalog",
5627
+ pluginId: "templateKind",
5626
5628
  register(env) {
5627
5629
  env.registerInit({
5628
5630
  deps: {
@@ -5661,16 +5663,13 @@ class ScaffolderActionsExtensionPointImpl {
5661
5663
  }
5662
5664
  }
5663
5665
  _actions = new WeakMap();
5664
- const scaffolderActionsExtensionPoint = backendPluginApi.createExtensionPoint({
5665
- id: "scaffolder.actions"
5666
- });
5667
5666
  const scaffolderPlugin = backendPluginApi.createBackendPlugin(
5668
5667
  (options) => ({
5669
5668
  id: "scaffolder",
5670
5669
  register(env) {
5671
5670
  const actionsExtensions = new ScaffolderActionsExtensionPointImpl();
5672
5671
  env.registerExtensionPoint(
5673
- scaffolderActionsExtensionPoint,
5672
+ pluginScaffolderNode.scaffolderActionsExtensionPoint,
5674
5673
  actionsExtensions
5675
5674
  );
5676
5675
  env.registerInit({
@@ -5732,11 +5731,14 @@ const scaffolderPlugin = backendPluginApi.createBackendPlugin(
5732
5731
  })
5733
5732
  );
5734
5733
 
5734
+ const createTemplateAction = pluginScaffolderNode.createTemplateAction;
5735
+
5735
5736
  exports.DatabaseTaskStore = DatabaseTaskStore;
5736
5737
  exports.ScaffolderEntitiesProcessor = ScaffolderEntitiesProcessor;
5737
5738
  exports.TaskManager = TaskManager;
5738
5739
  exports.TaskWorker = TaskWorker;
5739
5740
  exports.TemplateActionRegistry = TemplateActionRegistry;
5741
+ exports.catalogModuleTemplateKind = catalogModuleTemplateKind;
5740
5742
  exports.createBuiltinActions = createBuiltinActions;
5741
5743
  exports.createCatalogRegisterAction = createCatalogRegisterAction;
5742
5744
  exports.createCatalogWriteAction = createCatalogWriteAction;
@@ -5765,6 +5767,5 @@ exports.createRouter = createRouter;
5765
5767
  exports.createTemplateAction = createTemplateAction;
5766
5768
  exports.executeShellCommand = executeShellCommand;
5767
5769
  exports.fetchContents = fetchContents;
5768
- exports.scaffolderCatalogModule = scaffolderCatalogModule;
5769
5770
  exports.scaffolderPlugin = scaffolderPlugin;
5770
5771
  //# sourceMappingURL=index.cjs.js.map