@backstage/plugin-scaffolder-backend 1.21.0-next.0 → 1.21.0-next.2

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,88 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.21.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 5eb6882: New scaffolder module `@backstage/plugin-scaffolder-backend-module-bitbucket-server`.
8
+
9
+ Extracted from `@backstage/plugin-scaffolder-backend-module-bitbucket`
10
+ and replaces its actions related to Bitbucket Server.
11
+
12
+ - `publish:bitbucketServer`
13
+ - `publish:bitbucketServer:pull-request`
14
+
15
+ - 9aac2b0: Use `--cwd` as the first `yarn` argument
16
+ - 52ae6b9: Updated dependency `esbuild` to `^0.20.0`.
17
+ - 5eb6882: New scaffolder module `@backstage/plugin-scaffolder-backend-module-bitbucket-cloud`.
18
+
19
+ Extracted from `@backstage/plugin-scaffolder-backend-module-bitbucket`
20
+ and replaces its actions related to Bitbucket Cloud.
21
+
22
+ - `publish:bitbucketCloud`
23
+ - `bitbucket:pipelines:run`
24
+
25
+ - Updated dependencies
26
+ - @backstage/plugin-scaffolder-backend-module-bitbucket-server@0.1.0-next.0
27
+ - @backstage/backend-common@0.21.0-next.2
28
+ - @backstage/plugin-scaffolder-backend-module-bitbucket@0.2.0-next.2
29
+ - @backstage/plugin-scaffolder-backend-module-gitlab@0.2.13-next.2
30
+ - @backstage/backend-plugin-api@0.6.10-next.2
31
+ - @backstage/backend-tasks@0.5.15-next.2
32
+ - @backstage/plugin-auth-node@0.4.4-next.2
33
+ - @backstage/plugin-scaffolder-backend-module-bitbucket-cloud@0.1.0-next.0
34
+ - @backstage/plugin-scaffolder-backend-module-gerrit@0.1.2-next.2
35
+ - @backstage/plugin-permission-node@0.7.21-next.2
36
+ - @backstage/plugin-scaffolder-backend-module-azure@0.1.2-next.2
37
+ - @backstage/plugin-scaffolder-backend-module-github@0.2.0-next.2
38
+ - @backstage/plugin-scaffolder-node@0.3.0-next.2
39
+ - @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.1.7-next.2
40
+ - @backstage/plugin-catalog-node@1.6.2-next.2
41
+ - @backstage/config@1.1.1
42
+ - @backstage/catalog-client@1.6.0-next.1
43
+ - @backstage/catalog-model@1.4.4-next.0
44
+ - @backstage/errors@1.2.3
45
+ - @backstage/integration@1.9.0-next.0
46
+ - @backstage/types@1.1.1
47
+ - @backstage/plugin-permission-common@0.7.12
48
+ - @backstage/plugin-scaffolder-common@1.5.0-next.1
49
+
50
+ ## 1.21.0-next.1
51
+
52
+ ### Minor Changes
53
+
54
+ - 78c100b: Support providing an overriding token for `fetch:template`, `fetch:plain` and `fetch:file` when interacting with upstream integrations
55
+
56
+ ### Patch Changes
57
+
58
+ - 09f8b31: Simple typo fix in the fetch:template action example on the word 'skeleton'.
59
+ - f6792c6: Move the `NODE_OPTIONS` messaging for `--no-node-snapshot` to the `SecureTemplater` in order to get better messaging at runtime
60
+ - e1c479d: When using node 20+ the `scaffolder-backend` will now throw an error at startup if the `--no-node-snapshot` option was
61
+ not provided to node.
62
+ - e0e5afe: Add option to configure nunjucks with the `trimBlocks` and `lstripBlocks` options in the fetch:template action
63
+ - Updated dependencies
64
+ - @backstage/plugin-scaffolder-backend-module-github@0.2.0-next.1
65
+ - @backstage/catalog-model@1.4.4-next.0
66
+ - @backstage/catalog-client@1.6.0-next.1
67
+ - @backstage/backend-plugin-api@0.6.10-next.1
68
+ - @backstage/backend-common@0.21.0-next.1
69
+ - @backstage/integration@1.9.0-next.0
70
+ - @backstage/plugin-scaffolder-node@0.3.0-next.1
71
+ - @backstage/backend-tasks@0.5.15-next.1
72
+ - @backstage/config@1.1.1
73
+ - @backstage/errors@1.2.3
74
+ - @backstage/types@1.1.1
75
+ - @backstage/plugin-auth-node@0.4.4-next.1
76
+ - @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.1.7-next.1
77
+ - @backstage/plugin-catalog-node@1.6.2-next.1
78
+ - @backstage/plugin-permission-common@0.7.12
79
+ - @backstage/plugin-permission-node@0.7.21-next.1
80
+ - @backstage/plugin-scaffolder-backend-module-azure@0.1.2-next.1
81
+ - @backstage/plugin-scaffolder-backend-module-bitbucket@0.1.2-next.1
82
+ - @backstage/plugin-scaffolder-backend-module-gerrit@0.1.2-next.1
83
+ - @backstage/plugin-scaffolder-backend-module-gitlab@0.2.13-next.1
84
+ - @backstage/plugin-scaffolder-common@1.5.0-next.1
85
+
3
86
  ## 1.21.0-next.0
4
87
 
5
88
  ### Minor Changes
package/README.md CHANGED
@@ -21,7 +21,7 @@ restoring the plugin, if you previously removed it.
21
21
 
22
22
  ```bash
23
23
  # From your Backstage root directory
24
- yarn add --cwd packages/backend @backstage/plugin-scaffolder-backend
24
+ yarn --cwd packages/backend add @backstage/plugin-scaffolder-backend
25
25
  ```
26
26
 
27
27
  ### Adding the plugin to your `packages/backend`
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
- "version": "1.21.0-next.0",
3
+ "version": "1.21.0-next.2",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/alpha.cjs.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var alpha = require('@backstage/plugin-scaffolder-common/alpha');
6
6
  var pluginPermissionNode = require('@backstage/plugin-permission-node');
7
- var router = require('./cjs/router-842a762b.cjs.js');
7
+ var router = require('./cjs/router-eac0efea.cjs.js');
8
8
  var backendPluginApi = require('@backstage/backend-plugin-api');
9
9
  var backendCommon = require('@backstage/backend-common');
10
10
  var integration = require('@backstage/integration');
@@ -13,6 +13,8 @@ var alpha$1 = require('@backstage/plugin-scaffolder-node/alpha');
13
13
  require('@backstage/plugin-scaffolder-backend-module-github');
14
14
  require('@backstage/plugin-scaffolder-backend-module-azure');
15
15
  require('@backstage/plugin-scaffolder-backend-module-bitbucket');
16
+ require('@backstage/plugin-scaffolder-backend-module-bitbucket-cloud');
17
+ require('@backstage/plugin-scaffolder-backend-module-bitbucket-server');
16
18
  require('@backstage/plugin-scaffolder-backend-module-gerrit');
17
19
  require('@backstage/plugin-scaffolder-backend-module-gitlab');
18
20
  require('@backstage/errors');
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.cjs.js","sources":["../src/service/conditionExports.ts","../src/ScaffolderPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,\n RESOURCE_TYPE_SCAFFOLDER_ACTION,\n} from '@backstage/plugin-scaffolder-common/alpha';\nimport { createConditionExports } from '@backstage/plugin-permission-node';\nimport { scaffolderTemplateRules, scaffolderActionRules } from './rules';\n\nconst templateConditionExports = createConditionExports({\n pluginId: 'scaffolder',\n resourceType: RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,\n rules: scaffolderTemplateRules,\n});\n\nconst actionsConditionExports = createConditionExports({\n pluginId: 'scaffolder',\n resourceType: RESOURCE_TYPE_SCAFFOLDER_ACTION,\n rules: scaffolderActionRules,\n});\n\n/**\n * `createScaffolderTemplateConditionalDecision` can be used when authoring policies to\n * create conditional decisions. It requires a permission of type\n * `ResourcePermission<'scaffolder-template'>` to be passed as the first parameter.\n * It's recommended that you use the provided `isResourcePermission` and\n * `isPermission` helper methods to narrow the type of the permission passed to\n * the handle method as shown below.\n *\n * ```\n * // MyAuthorizationPolicy.ts\n * ...\n * import { createScaffolderPolicyDecision } from '@backstage/plugin-scaffolder-backend';\n * import { RESOURCE_TYPE_SCAFFOLDER_TEMPLATE } from '@backstage/plugin-scaffolder-common';\n *\n * class MyAuthorizationPolicy implements PermissionPolicy {\n * async handle(request, user) {\n * ...\n *\n * if (isResourcePermission(request.permission, RESOURCE_TYPE_SCAFFOLDER_TEMPLATE)) {\n * return createScaffolderConditionalDecision(\n * request.permission,\n * { anyOf: [...insert conditions here...] }\n * );\n * }\n *\n * ...\n * }\n *\n * ```\n *\n * @alpha\n */\nexport const createScaffolderTemplateConditionalDecision =\n templateConditionExports.createConditionalDecision;\n\n/**\n * These conditions are used when creating conditional decisions for scaffolder\n * templates that are returned by authorization policies.\n *\n * @alpha\n */\nexport const scaffolderTemplateConditions = templateConditionExports.conditions;\n\n/**\n * @alpha\n */\nexport const createScaffolderActionConditionalDecision =\n actionsConditionExports.createConditionalDecision;\n\n/**\n *\n * These conditions are used when creating conditional decisions for scaffolder\n * actions that are returned by authorization policies.\n *\n * @alpha\n */\nexport const scaffolderActionConditions = actionsConditionExports.conditions;\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\nimport {\n TaskBroker,\n TemplateAction,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport {\n scaffolderActionsExtensionPoint,\n scaffolderTaskBrokerExtensionPoint,\n scaffolderTemplatingExtensionPoint,\n} from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createCatalogRegisterAction,\n createCatalogWriteAction,\n createDebugLogAction,\n createFetchCatalogEntityAction,\n createFetchPlainAction,\n createFetchPlainFileAction,\n createFetchTemplateAction,\n createFilesystemDeleteAction,\n createFilesystemRenameAction,\n createWaitAction,\n} from './scaffolder';\nimport { createRouter } from './service/router';\n\n/**\n * Scaffolder plugin\n *\n * @alpha\n */\nexport const scaffolderPlugin = createBackendPlugin({\n pluginId: 'scaffolder',\n register(env) {\n const addedActions = new Array<TemplateAction<any, any>>();\n env.registerExtensionPoint(scaffolderActionsExtensionPoint, {\n addActions(...newActions: TemplateAction<any>[]) {\n addedActions.push(...newActions);\n },\n });\n\n let taskBroker: TaskBroker | undefined;\n env.registerExtensionPoint(scaffolderTaskBrokerExtensionPoint, {\n setTaskBroker(newTaskBroker) {\n if (taskBroker) {\n throw new Error('Task broker may only be set once');\n }\n taskBroker = newTaskBroker;\n },\n });\n\n const additionalTemplateFilters: Record<string, TemplateFilter> = {};\n const additionalTemplateGlobals: Record<string, TemplateGlobal> = {};\n env.registerExtensionPoint(scaffolderTemplatingExtensionPoint, {\n addTemplateFilters(newFilters) {\n Object.assign(additionalTemplateFilters, newFilters);\n },\n addTemplateGlobals(newGlobals) {\n Object.assign(additionalTemplateGlobals, newGlobals);\n },\n });\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n lifecycle: coreServices.rootLifecycle,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n catalogClient: catalogServiceRef,\n },\n async init({\n logger,\n config,\n lifecycle,\n reader,\n database,\n httpRouter,\n catalogClient,\n permissions,\n }) {\n const log = loggerToWinstonLogger(logger);\n const integrations = ScmIntegrations.fromConfig(config);\n\n const actions = [\n // actions provided from other modules\n ...addedActions,\n\n // built-in actions for the scaffolder\n createFetchPlainAction({\n reader,\n integrations,\n }),\n createFetchPlainFileAction({\n reader,\n integrations,\n }),\n createFetchTemplateAction({\n integrations,\n reader,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n }),\n createDebugLogAction(),\n createWaitAction(),\n // todo(blam): maybe these should be a -catalog module?\n createCatalogRegisterAction({ catalogClient, integrations }),\n createFetchCatalogEntityAction({ catalogClient }),\n createCatalogWriteAction(),\n createFilesystemDeleteAction(),\n createFilesystemRenameAction(),\n ];\n\n const actionIds = actions.map(action => action.id).join(', ');\n\n log.info(\n `Starting scaffolder with the following actions enabled ${actionIds}`,\n );\n\n const router = await createRouter({\n logger: log,\n config,\n database,\n catalogClient,\n reader,\n lifecycle,\n actions,\n taskBroker,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n permissions,\n });\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createConditionExports","RESOURCE_TYPE_SCAFFOLDER_TEMPLATE","scaffolderTemplateRules","RESOURCE_TYPE_SCAFFOLDER_ACTION","scaffolderActionRules","createBackendPlugin","scaffolderActionsExtensionPoint","scaffolderTaskBrokerExtensionPoint","scaffolderTemplatingExtensionPoint","coreServices","catalogServiceRef","loggerToWinstonLogger","ScmIntegrations","createFetchPlainAction","createFetchPlainFileAction","createFetchTemplateAction","createDebugLogAction","createWaitAction","createCatalogRegisterAction","createFetchCatalogEntityAction","createCatalogWriteAction","createFilesystemDeleteAction","createFilesystemRenameAction","router","createRouter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,2BAA2BA,2CAAuB,CAAA;AAAA,EACtD,QAAU,EAAA,YAAA;AAAA,EACV,YAAc,EAAAC,uCAAA;AAAA,EACd,KAAO,EAAAC,8BAAA;AACT,CAAC,CAAA,CAAA;AAED,MAAM,0BAA0BF,2CAAuB,CAAA;AAAA,EACrD,QAAU,EAAA,YAAA;AAAA,EACV,YAAc,EAAAG,qCAAA;AAAA,EACd,KAAO,EAAAC,4BAAA;AACT,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,SAAA,GAAY,QAAQ,GAAI,CAAA,CAAA,MAAA,KAAU,OAAO,EAAE,CAAA,CAAE,KAAK,IAAI,CAAA,CAAA;AAE5D,QAAI,GAAA,CAAA,IAAA;AAAA,UACF,0DAA0D,SAAS,CAAA,CAAA;AAAA,SACrE,CAAA;AAEA,QAAM,MAAAC,QAAA,GAAS,MAAMC,mBAAa,CAAA;AAAA,UAChC,MAAQ,EAAA,GAAA;AAAA,UACR,MAAA;AAAA,UACA,QAAA;AAAA,UACA,aAAA;AAAA,UACA,MAAA;AAAA,UACA,SAAA;AAAA,UACA,OAAA;AAAA,UACA,UAAA;AAAA,UACA,yBAAA;AAAA,UACA,yBAAA;AAAA,UACA,WAAA;AAAA,SACD,CAAA,CAAA;AACD,QAAA,UAAA,CAAW,IAAID,QAAM,CAAA,CAAA;AAAA,OACvB;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;;;"}
1
+ {"version":3,"file":"alpha.cjs.js","sources":["../src/service/conditionExports.ts","../src/ScaffolderPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,\n RESOURCE_TYPE_SCAFFOLDER_ACTION,\n} from '@backstage/plugin-scaffolder-common/alpha';\nimport { createConditionExports } from '@backstage/plugin-permission-node';\nimport { scaffolderTemplateRules, scaffolderActionRules } from './rules';\n\nconst templateConditionExports = createConditionExports({\n pluginId: 'scaffolder',\n resourceType: RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,\n rules: scaffolderTemplateRules,\n});\n\nconst actionsConditionExports = createConditionExports({\n pluginId: 'scaffolder',\n resourceType: RESOURCE_TYPE_SCAFFOLDER_ACTION,\n rules: scaffolderActionRules,\n});\n\n/**\n * `createScaffolderTemplateConditionalDecision` can be used when authoring policies to\n * create conditional decisions. It requires a permission of type\n * `ResourcePermission<'scaffolder-template'>` to be passed as the first parameter.\n * It's recommended that you use the provided `isResourcePermission` and\n * `isPermission` helper methods to narrow the type of the permission passed to\n * the handle method as shown below.\n *\n * ```\n * // MyAuthorizationPolicy.ts\n * ...\n * import { createScaffolderPolicyDecision } from '@backstage/plugin-scaffolder-backend';\n * import { RESOURCE_TYPE_SCAFFOLDER_TEMPLATE } from '@backstage/plugin-scaffolder-common';\n *\n * class MyAuthorizationPolicy implements PermissionPolicy {\n * async handle(request, user) {\n * ...\n *\n * if (isResourcePermission(request.permission, RESOURCE_TYPE_SCAFFOLDER_TEMPLATE)) {\n * return createScaffolderConditionalDecision(\n * request.permission,\n * { anyOf: [...insert conditions here...] }\n * );\n * }\n *\n * ...\n * }\n *\n * ```\n *\n * @alpha\n */\nexport const createScaffolderTemplateConditionalDecision =\n templateConditionExports.createConditionalDecision;\n\n/**\n * These conditions are used when creating conditional decisions for scaffolder\n * templates that are returned by authorization policies.\n *\n * @alpha\n */\nexport const scaffolderTemplateConditions = templateConditionExports.conditions;\n\n/**\n * @alpha\n */\nexport const createScaffolderActionConditionalDecision =\n actionsConditionExports.createConditionalDecision;\n\n/**\n *\n * These conditions are used when creating conditional decisions for scaffolder\n * actions that are returned by authorization policies.\n *\n * @alpha\n */\nexport const scaffolderActionConditions = actionsConditionExports.conditions;\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\nimport {\n TaskBroker,\n TemplateAction,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport {\n scaffolderActionsExtensionPoint,\n scaffolderTaskBrokerExtensionPoint,\n scaffolderTemplatingExtensionPoint,\n} from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createCatalogRegisterAction,\n createCatalogWriteAction,\n createDebugLogAction,\n createFetchCatalogEntityAction,\n createFetchPlainAction,\n createFetchPlainFileAction,\n createFetchTemplateAction,\n createFilesystemDeleteAction,\n createFilesystemRenameAction,\n createWaitAction,\n} from './scaffolder';\nimport { createRouter } from './service/router';\n\n/**\n * Scaffolder plugin\n *\n * @alpha\n */\nexport const scaffolderPlugin = createBackendPlugin({\n pluginId: 'scaffolder',\n register(env) {\n const addedActions = new Array<TemplateAction<any, any>>();\n env.registerExtensionPoint(scaffolderActionsExtensionPoint, {\n addActions(...newActions: TemplateAction<any>[]) {\n addedActions.push(...newActions);\n },\n });\n\n let taskBroker: TaskBroker | undefined;\n env.registerExtensionPoint(scaffolderTaskBrokerExtensionPoint, {\n setTaskBroker(newTaskBroker) {\n if (taskBroker) {\n throw new Error('Task broker may only be set once');\n }\n taskBroker = newTaskBroker;\n },\n });\n\n const additionalTemplateFilters: Record<string, TemplateFilter> = {};\n const additionalTemplateGlobals: Record<string, TemplateGlobal> = {};\n env.registerExtensionPoint(scaffolderTemplatingExtensionPoint, {\n addTemplateFilters(newFilters) {\n Object.assign(additionalTemplateFilters, newFilters);\n },\n addTemplateGlobals(newGlobals) {\n Object.assign(additionalTemplateGlobals, newGlobals);\n },\n });\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n lifecycle: coreServices.rootLifecycle,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n catalogClient: catalogServiceRef,\n },\n async init({\n logger,\n config,\n lifecycle,\n reader,\n database,\n httpRouter,\n catalogClient,\n permissions,\n }) {\n const log = loggerToWinstonLogger(logger);\n const integrations = ScmIntegrations.fromConfig(config);\n\n const actions = [\n // actions provided from other modules\n ...addedActions,\n\n // built-in actions for the scaffolder\n createFetchPlainAction({\n reader,\n integrations,\n }),\n createFetchPlainFileAction({\n reader,\n integrations,\n }),\n createFetchTemplateAction({\n integrations,\n reader,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n }),\n createDebugLogAction(),\n createWaitAction(),\n // todo(blam): maybe these should be a -catalog module?\n createCatalogRegisterAction({ catalogClient, integrations }),\n createFetchCatalogEntityAction({ catalogClient }),\n createCatalogWriteAction(),\n createFilesystemDeleteAction(),\n createFilesystemRenameAction(),\n ];\n\n const actionIds = actions.map(action => action.id).join(', ');\n\n log.info(\n `Starting scaffolder with the following actions enabled ${actionIds}`,\n );\n\n const router = await createRouter({\n logger: log,\n config,\n database,\n catalogClient,\n reader,\n lifecycle,\n actions,\n taskBroker,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n permissions,\n });\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createConditionExports","RESOURCE_TYPE_SCAFFOLDER_TEMPLATE","scaffolderTemplateRules","RESOURCE_TYPE_SCAFFOLDER_ACTION","scaffolderActionRules","createBackendPlugin","scaffolderActionsExtensionPoint","scaffolderTaskBrokerExtensionPoint","scaffolderTemplatingExtensionPoint","coreServices","catalogServiceRef","loggerToWinstonLogger","ScmIntegrations","createFetchPlainAction","createFetchPlainFileAction","createFetchTemplateAction","createDebugLogAction","createWaitAction","createCatalogRegisterAction","createFetchCatalogEntityAction","createCatalogWriteAction","createFilesystemDeleteAction","createFilesystemRenameAction","router","create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AA;AAAA,YACA,yBAAA;AAAA,YACA,yBAAA;AAAA,WACD,CAAA;AAAA,UACDC,2BAAqB,EAAA;AAAA,UACrBC,uBAAiB,EAAA;AAAA;AAAA,UAEjBC,kCAA4B,CAAA,EAAE,aAAe,EAAA,YAAA,EAAc,CAAA;AAAA,UAC3DC,qCAAA,CAA+B,EAAE,aAAA,EAAe,CAAA;AAAA,UAChDC,+BAAyB,EAAA;AAAA,UACzBC,mCAA6B,EAAA;AAAA,UAC7BC,mCAA6B,EAAA;AAAA,SAC/B,CAAA;AAEA,QAAM,MAAA,SAAA,GAAY,QAAQ,GAAI,CAAA,CAAA,MAAA,KAAU,OAAO,EAAE,CAAA,CAAE,KAAK,IAAI,CAAA,CAAA;AAE5D,QAAI,GAAA,CAAA,IAAA;AAAA,UACF,0DAA0D,SAAS,CAAA,CAAA;AAAA,SACrE,CAAA;AAEA,QAAM,MAAAC,QAAA,GAAS,MAAMC,mBAAa,CAAA;AAAA,UAChC,MAAQ,EAAA,GAAA;AAAA,UACR,MAAA;AAAA,UACA,QAAA;AAAA,UACA,aAAA;AAAA,UACA,MAAA;AAAA,UACA,SAAA;AAAA,UACA,OAAA;AAAA,UACA,UAAA;AAAA,UACA,yBAAA;AAAA,UACA,yBAAA;AAAA,UACA,WAAA;AAAA,SACD,CAAA,CAAA;AACD,QAAA,UAAA,CAAW,IAAID,QAAM,CAAA,CAAA;AAAA,OACvB;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;;;"}
@@ -23,6 +23,8 @@ var get = require('lodash/get');
23
23
  var github = require('@backstage/plugin-scaffolder-backend-module-github');
24
24
  var azure = require('@backstage/plugin-scaffolder-backend-module-azure');
25
25
  var bitbucket = require('@backstage/plugin-scaffolder-backend-module-bitbucket');
26
+ var bitbucketCloud = require('@backstage/plugin-scaffolder-backend-module-bitbucket-cloud');
27
+ var bitbucketServer = require('@backstage/plugin-scaffolder-backend-module-bitbucket-server');
26
28
  var gerrit = require('@backstage/plugin-scaffolder-backend-module-gerrit');
27
29
  var gitlab = require('@backstage/plugin-scaffolder-backend-module-gitlab');
28
30
  var uuid = require('uuid');
@@ -640,6 +642,11 @@ function createFetchPlainAction(options) {
640
642
  title: "Target Path",
641
643
  description: "Target path within the working directory to download the contents to.",
642
644
  type: "string"
645
+ },
646
+ token: {
647
+ title: "Token",
648
+ description: "An optional token to use for authentication when reading the resources.",
649
+ type: "string"
643
650
  }
644
651
  }
645
652
  }
@@ -655,7 +662,8 @@ function createFetchPlainAction(options) {
655
662
  integrations,
656
663
  baseUrl: (_b = ctx.templateInfo) == null ? void 0 : _b.baseUrl,
657
664
  fetchUrl: ctx.input.url,
658
- outputPath
665
+ outputPath,
666
+ token: ctx.input.token
659
667
  });
660
668
  }
661
669
  });
@@ -700,6 +708,11 @@ function createFetchPlainFileAction(options) {
700
708
  title: "Target Path",
701
709
  description: "Target path within the working directory to download the file as.",
702
710
  type: "string"
711
+ },
712
+ token: {
713
+ title: "Token",
714
+ description: "An optional token to use for authentication when reading the resources.",
715
+ type: "string"
703
716
  }
704
717
  }
705
718
  }
@@ -717,12 +730,22 @@ function createFetchPlainFileAction(options) {
717
730
  integrations,
718
731
  baseUrl: (_a = ctx.templateInfo) == null ? void 0 : _a.baseUrl,
719
732
  fetchUrl: ctx.input.url,
720
- outputPath
733
+ outputPath,
734
+ token: ctx.input.token
721
735
  });
722
736
  }
723
737
  });
724
738
  }
725
739
 
740
+ function isNoNodeSnapshotOptionProvided() {
741
+ var _a;
742
+ return ((_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot")) || process.argv.includes("--no-node-snapshot");
743
+ }
744
+ function getMajorNodeVersion() {
745
+ const version = process.versions.node;
746
+ return parseInt(version.split(".")[0], 10);
747
+ }
748
+
726
749
  const mkScript = (nunjucksSource) => `
727
750
  const { render, renderCompat } = (() => {
728
751
  const module = {};
@@ -733,6 +756,7 @@ const { render, renderCompat } = (() => {
733
756
 
734
757
  const env = module.exports.configure({
735
758
  autoescape: false,
759
+ ...JSON.parse(nunjucksConfigs),
736
760
  tags: {
737
761
  variableStart: '\${{',
738
762
  variableEnd: '}}',
@@ -741,6 +765,7 @@ const { render, renderCompat } = (() => {
741
765
 
742
766
  const compatEnv = module.exports.configure({
743
767
  autoescape: false,
768
+ ...JSON.parse(nunjucksConfigs),
744
769
  tags: {
745
770
  variableStart: '{{',
746
771
  variableEnd: '}}',
@@ -793,8 +818,16 @@ class SecureTemplater {
793
818
  const {
794
819
  cookiecutterCompat,
795
820
  templateFilters = {},
796
- templateGlobals = {}
821
+ templateGlobals = {},
822
+ nunjucksConfigs = {}
797
823
  } = options;
824
+ const nodeVersion = getMajorNodeVersion();
825
+ if (nodeVersion >= 20 && !isNoNodeSnapshotOptionProvided()) {
826
+ throw new Error(
827
+ `When using Node.js version 20 or newer, the scaffolder backend plugin requires that it be started with the --no-node-snapshot option.
828
+ Please make sure that you have NODE_OPTIONS=--no-node-snapshot in your environment.`
829
+ );
830
+ }
798
831
  const isolate = new isolatedVm.Isolate({ memoryLimit: 128 });
799
832
  const context = await isolate.createContext();
800
833
  const contextGlobal = context.global;
@@ -808,6 +841,7 @@ class SecureTemplater {
808
841
  const nunjucksScript = await isolate.compileScript(
809
842
  mkScript(nunjucksSource)
810
843
  );
844
+ await contextGlobal.set("nunjucksConfigs", JSON.stringify(nunjucksConfigs));
811
845
  const availableFilters = Object.keys(templateFilters);
812
846
  await contextGlobal.set(
813
847
  "availableTemplateFilters",
@@ -884,7 +918,7 @@ const createDefaultFilters = ({
884
918
 
885
919
  const examples$2 = [
886
920
  {
887
- description: "Downloads a skelaton directory that lives alongside the template file and fill it out with values.",
921
+ description: "Downloads a skeleton directory that lives alongside the template file and fill it out with values.",
888
922
  example: yaml__default["default"].stringify({
889
923
  steps: [
890
924
  {
@@ -969,6 +1003,11 @@ function createFetchTemplateAction(options) {
969
1003
  title: "Replace files",
970
1004
  description: "If set, replace files in targetPath instead of skipping existing ones.",
971
1005
  type: "boolean"
1006
+ },
1007
+ token: {
1008
+ title: "Token",
1009
+ description: "An optional token to use for authentication when reading the resources.",
1010
+ type: "string"
972
1011
  }
973
1012
  }
974
1013
  }
@@ -1020,7 +1059,8 @@ function createFetchTemplateAction(options) {
1020
1059
  integrations,
1021
1060
  baseUrl: (_b = ctx.templateInfo) == null ? void 0 : _b.baseUrl,
1022
1061
  fetchUrl: ctx.input.url,
1023
- outputPath: templateDir
1062
+ outputPath: templateDir,
1063
+ token: ctx.input.token
1024
1064
  });
1025
1065
  ctx.logger.info("Listing files and directories in template");
1026
1066
  const allEntriesInTemplate = await globby__default["default"](`**/*`, {
@@ -1053,7 +1093,11 @@ function createFetchTemplateAction(options) {
1053
1093
  ...defaultTemplateFilters,
1054
1094
  ...additionalTemplateFilters
1055
1095
  },
1056
- templateGlobals: additionalTemplateGlobals
1096
+ templateGlobals: additionalTemplateGlobals,
1097
+ nunjucksConfigs: {
1098
+ trimBlocks: ctx.input.trimBlocks,
1099
+ lstripBlocks: ctx.input.lstripBlocks
1100
+ }
1057
1101
  });
1058
1102
  for (const location of allEntriesInTemplate) {
1059
1103
  let renderContents;
@@ -1326,15 +1370,15 @@ const createBuiltinActions = (options) => {
1326
1370
  integrations,
1327
1371
  config
1328
1372
  }),
1329
- bitbucket.createPublishBitbucketCloudAction({
1373
+ bitbucketCloud.createPublishBitbucketCloudAction({
1330
1374
  integrations,
1331
1375
  config
1332
1376
  }),
1333
- bitbucket.createPublishBitbucketServerAction({
1377
+ bitbucketServer.createPublishBitbucketServerAction({
1334
1378
  integrations,
1335
1379
  config
1336
1380
  }),
1337
- bitbucket.createPublishBitbucketServerPullRequestAction({
1381
+ bitbucketServer.createPublishBitbucketServerPullRequestAction({
1338
1382
  integrations,
1339
1383
  config
1340
1384
  }),
@@ -1380,7 +1424,7 @@ const createBuiltinActions = (options) => {
1380
1424
  integrations,
1381
1425
  githubCredentialsProvider
1382
1426
  }),
1383
- bitbucket.createBitbucketPipelinesRunAction({
1427
+ bitbucketCloud.createBitbucketPipelinesRunAction({
1384
1428
  integrations
1385
1429
  })
1386
1430
  ];
@@ -3340,4 +3384,4 @@ exports.createRouter = createRouter;
3340
3384
  exports.createWaitAction = createWaitAction;
3341
3385
  exports.scaffolderActionRules = scaffolderActionRules;
3342
3386
  exports.scaffolderTemplateRules = scaffolderTemplateRules;
3343
- //# sourceMappingURL=router-842a762b.cjs.js.map
3387
+ //# sourceMappingURL=router-eac0efea.cjs.js.map