@backstage/plugin-scaffolder-backend 1.14.0 → 1.15.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/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.15.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - df8411779da1: Add support for Repository Variables and Secrets to the `publish:github` and `github:repo:create` scaffolder actions. You will need to add `read/write` permissions to your GITHUB_TOKEN and/or Github Backstage App for Repository `Secrets` and `Variables`
8
+
9
+ Upgrade octokit introduces some breaking changes.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+ - @backstage/backend-common@0.19.0-next.1
15
+ - @backstage/plugin-catalog-backend@1.9.2-next.1
16
+ - @backstage/integration@1.5.0-next.0
17
+ - @backstage/errors@1.2.0-next.0
18
+ - @backstage/backend-plugin-api@0.5.3-next.1
19
+ - @backstage/catalog-model@1.4.0-next.0
20
+ - @backstage/backend-tasks@0.5.3-next.1
21
+ - @backstage/plugin-auth-node@0.2.15-next.1
22
+ - @backstage/plugin-catalog-node@1.3.7-next.1
23
+ - @backstage/plugin-permission-node@0.7.9-next.1
24
+ - @backstage/catalog-client@1.4.2-next.1
25
+ - @backstage/plugin-permission-common@0.7.6-next.0
26
+ - @backstage/plugin-scaffolder-node@0.1.4-next.1
27
+ - @backstage/plugin-catalog-common@1.0.14-next.0
28
+ - @backstage/plugin-scaffolder-common@1.3.1-next.0
29
+ - @backstage/config@1.0.7
30
+ - @backstage/types@1.0.2
31
+
32
+ ## 1.14.1-next.0
33
+
34
+ ### Patch Changes
35
+
36
+ - cc936b529676: Fix handling of `optional` property in `catalog:register` scaffolder action
37
+ - b269da39ac2d: Clearer error messages for action `publish:gitlab:merge-request`
38
+ - Updated dependencies
39
+ - @backstage/catalog-client@1.4.2-next.0
40
+ - @backstage/plugin-catalog-backend@1.9.2-next.0
41
+ - @backstage/plugin-catalog-node@1.3.7-next.0
42
+ - @backstage/backend-common@0.18.6-next.0
43
+ - @backstage/integration@1.4.5
44
+ - @backstage/config@1.0.7
45
+ - @backstage/backend-plugin-api@0.5.3-next.0
46
+ - @backstage/backend-tasks@0.5.3-next.0
47
+ - @backstage/catalog-model@1.3.0
48
+ - @backstage/errors@1.1.5
49
+ - @backstage/types@1.0.2
50
+ - @backstage/plugin-auth-node@0.2.15-next.0
51
+ - @backstage/plugin-catalog-common@1.0.13
52
+ - @backstage/plugin-permission-common@0.7.5
53
+ - @backstage/plugin-permission-node@0.7.9-next.0
54
+ - @backstage/plugin-scaffolder-common@1.3.0
55
+ - @backstage/plugin-scaffolder-node@0.1.4-next.0
56
+
3
57
  ## 1.14.0
4
58
 
5
59
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
- "version": "1.14.0",
3
+ "version": "1.15.0-next.1",
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 backendPluginApi = require('@backstage/backend-plugin-api');
6
6
  var alpha = require('@backstage/plugin-catalog-node/alpha');
7
- var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-021c5dcb.cjs.js');
7
+ var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-9c1b2955.cjs.js');
8
8
  var alpha$1 = require('@backstage/plugin-scaffolder-common/alpha');
9
9
  var pluginPermissionNode = require('@backstage/plugin-permission-node');
10
10
  var backendCommon = require('@backstage/backend-common');
@@ -24,6 +24,7 @@ require('azure-devops-node-api');
24
24
  require('node-fetch');
25
25
  require('crypto');
26
26
  require('octokit');
27
+ require('libsodium-wrappers');
27
28
  require('octokit-plugin-create-pull-request');
28
29
  require('fs');
29
30
  require('p-limit');
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.cjs.js","sources":["../src/modules/catalogModuleTemplateKind.ts","../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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';\nimport { ScaffolderEntitiesProcessor } from '../processor';\n\n/**\n * Registers support for the Template kind to the catalog backend plugin.\n *\n * @alpha\n */\nexport const catalogModuleTemplateKind = createBackendModule({\n moduleId: 'scaffolder',\n pluginId: 'templateKind',\n register(env) {\n env.registerInit({\n deps: {\n catalog: catalogProcessingExtensionPoint,\n },\n async init({ catalog }) {\n catalog.addProcessor(new ScaffolderEntitiesProcessor());\n },\n });\n },\n});\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 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 scaffolderActionsExtensionPoint,\n ScaffolderActionsExtensionPoint,\n TemplateAction,\n} from '@backstage/plugin-scaffolder-node';\nimport {\n TemplateFilter,\n TemplateGlobal,\n TaskBroker,\n} from '@backstage/plugin-scaffolder-backend';\nimport { createBuiltinActions } from './scaffolder';\nimport { createRouter } from './service/router';\n\n/**\n * Catalog plugin options\n *\n * @alpha\n */\nexport type ScaffolderPluginOptions = {\n actions?: TemplateAction<any, any>[];\n taskWorkers?: number;\n taskBroker?: TaskBroker;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n};\n\nclass ScaffolderActionsExtensionPointImpl\n implements ScaffolderActionsExtensionPoint\n{\n #actions = new Array<TemplateAction<any, any>>();\n\n addActions(...actions: TemplateAction<any>[]): void {\n this.#actions.push(...actions);\n }\n\n get actions() {\n return this.#actions;\n }\n}\n\n/**\n * Catalog plugin\n *\n * @alpha\n */\nexport const scaffolderPlugin = createBackendPlugin(\n (options?: ScaffolderPluginOptions) => ({\n pluginId: 'scaffolder',\n register(env) {\n const actionsExtensions = new ScaffolderActionsExtensionPointImpl();\n\n env.registerExtensionPoint(\n scaffolderActionsExtensionPoint,\n actionsExtensions,\n );\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.config,\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 reader,\n database,\n httpRouter,\n catalogClient,\n permissions,\n }) {\n const {\n additionalTemplateFilters,\n taskBroker,\n taskWorkers,\n additionalTemplateGlobals,\n } = options ?? {};\n const log = loggerToWinstonLogger(logger);\n\n const actions = options?.actions || [\n ...actionsExtensions.actions,\n ...createBuiltinActions({\n integrations: ScmIntegrations.fromConfig(config),\n catalogClient,\n reader,\n config,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n }),\n ];\n\n const actionIds = actions.map(action => action.id).join(', ');\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 actions,\n taskBroker,\n taskWorkers,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n permissions,\n });\n httpRouter.use(router);\n },\n });\n },\n }),\n);\n"],"names":["createBackendModule","catalogProcessingExtensionPoint","ScaffolderEntitiesProcessor","createConditionExports","RESOURCE_TYPE_SCAFFOLDER_TEMPLATE","scaffolderTemplateRules","RESOURCE_TYPE_SCAFFOLDER_ACTION","scaffolderActionRules","createBackendPlugin","scaffolderActionsExtensionPoint","coreServices","catalogServiceRef","loggerToWinstonLogger","createBuiltinActions","ScmIntegrations","createRouter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,4BAA4BA,oCAAoB,CAAA;AAAA,EAC3D,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,cAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,OAAS,EAAAC,qCAAA;AAAA,OACX;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,OAAA,EAAW,EAAA;AACtB,QAAQ,OAAA,CAAA,YAAA,CAAa,IAAIC,uDAAA,EAA6B,CAAA,CAAA;AAAA,OACxD;AAAA,KACD,CAAA,CAAA;AAAA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,MAAMC,wCAAa,CAAA;AAAA,YAChC,MAAQ,EAAA,GAAA;AAAA,YACR,MAAA;AAAA,YACA,QAAA;AAAA,YACA,aAAA;AAAA,YACA,MAAA;AAAA,YACA,OAAA;AAAA,YACA,UAAA;AAAA,YACA,WAAA;AAAA,YACA,yBAAA;AAAA,YACA,yBAAA;AAAA,YACA,WAAA;AAAA,WACD,CAAA,CAAA;AACD,UAAA,UAAA,CAAW,IAAI,MAAM,CAAA,CAAA;AAAA,SACvB;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,GACF,CAAA;AACF;;;;;;;;;"}
1
+ {"version":3,"file":"alpha.cjs.js","sources":["../src/modules/catalogModuleTemplateKind.ts","../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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';\nimport { ScaffolderEntitiesProcessor } from '../processor';\n\n/**\n * Registers support for the Template kind to the catalog backend plugin.\n *\n * @alpha\n */\nexport const catalogModuleTemplateKind = createBackendModule({\n moduleId: 'scaffolder',\n pluginId: 'templateKind',\n register(env) {\n env.registerInit({\n deps: {\n catalog: catalogProcessingExtensionPoint,\n },\n async init({ catalog }) {\n catalog.addProcessor(new ScaffolderEntitiesProcessor());\n },\n });\n },\n});\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 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 scaffolderActionsExtensionPoint,\n ScaffolderActionsExtensionPoint,\n TemplateAction,\n} from '@backstage/plugin-scaffolder-node';\nimport {\n TemplateFilter,\n TemplateGlobal,\n TaskBroker,\n} from '@backstage/plugin-scaffolder-backend';\nimport { createBuiltinActions } from './scaffolder';\nimport { createRouter } from './service/router';\n\n/**\n * Catalog plugin options\n *\n * @alpha\n */\nexport type ScaffolderPluginOptions = {\n actions?: TemplateAction<any, any>[];\n taskWorkers?: number;\n taskBroker?: TaskBroker;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n};\n\nclass ScaffolderActionsExtensionPointImpl\n implements ScaffolderActionsExtensionPoint\n{\n #actions = new Array<TemplateAction<any, any>>();\n\n addActions(...actions: TemplateAction<any>[]): void {\n this.#actions.push(...actions);\n }\n\n get actions() {\n return this.#actions;\n }\n}\n\n/**\n * Catalog plugin\n *\n * @alpha\n */\nexport const scaffolderPlugin = createBackendPlugin(\n (options?: ScaffolderPluginOptions) => ({\n pluginId: 'scaffolder',\n register(env) {\n const actionsExtensions = new ScaffolderActionsExtensionPointImpl();\n\n env.registerExtensionPoint(\n scaffolderActionsExtensionPoint,\n actionsExtensions,\n );\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.config,\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 reader,\n database,\n httpRouter,\n catalogClient,\n permissions,\n }) {\n const {\n additionalTemplateFilters,\n taskBroker,\n taskWorkers,\n additionalTemplateGlobals,\n } = options ?? {};\n const log = loggerToWinstonLogger(logger);\n\n const actions = options?.actions || [\n ...actionsExtensions.actions,\n ...createBuiltinActions({\n integrations: ScmIntegrations.fromConfig(config),\n catalogClient,\n reader,\n config,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n }),\n ];\n\n const actionIds = actions.map(action => action.id).join(', ');\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 actions,\n taskBroker,\n taskWorkers,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n permissions,\n });\n httpRouter.use(router);\n },\n });\n },\n }),\n);\n"],"names":["createBackendModule","catalogProcessingExtensionPoint","ScaffolderEntitiesProcessor","createConditionExports","RESOURCE_TYPE_SCAFFOLDER_TEMPLATE","scaffolderTemplateRules","RESOURCE_TYPE_SCAFFOLDER_ACTION","scaffolderActionRules","createBackendPlugin","scaffolderActionsExtensionPoint","coreServices","catalogServiceRef","loggerToWinstonLogger","createBuiltinActions","ScmIntegrations","createRouter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,4BAA4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CAAA;AAAA,cAC/C,aAAA;AAAA,cACA,MAAA;AAAA,cACA,MAAA;AAAA,cACA,yBAAA;AAAA,cACA,yBAAA;AAAA,aACD,CAAA;AAAA,WACH,CAAA;AAEA,UAAM,MAAA,SAAA,GAAY,QAAQ,GAAI,CAAA,CAAA,MAAA,KAAU,OAAO,EAAE,CAAA,CAAE,KAAK,IAAI,CAAA,CAAA;AAC5D,UAAI,GAAA,CAAA,IAAA;AAAA,YACF,CAA0D,uDAAA,EAAA,SAAA,CAAA,CAAA;AAAA,WAC5D,CAAA;AAEA,UAAM,MAAA,MAAA,GAAS,MAAMC,wCAAa,CAAA;AAAA,YAChC,MAAQ,EAAA,GAAA;AAAA,YACR,MAAA;AAAA,YACA,QAAA;AAAA,YACA,aAAA;AAAA,YACA,MAAA;AAAA,YACA,OAAA;AAAA,YACA,UAAA;AAAA,YACA,WAAA;AAAA,YACA,yBAAA;AAAA,YACA,yBAAA;AAAA,YACA,WAAA;AAAA,WACD,CAAA,CAAA;AACD,UAAA,UAAA,CAAW,IAAI,MAAM,CAAA,CAAA;AAAA,SACvB;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,GACF,CAAA;AACF;;;;;;;;;"}
@@ -22,6 +22,7 @@ var get = require('lodash/get');
22
22
  var octokit = require('octokit');
23
23
  var child_process = require('child_process');
24
24
  var stream = require('stream');
25
+ var Sodium = require('libsodium-wrappers');
25
26
  var webhooks = require('@octokit/webhooks');
26
27
  var azureDevopsNodeApi = require('azure-devops-node-api');
27
28
  var fetch = require('node-fetch');
@@ -71,6 +72,7 @@ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
71
72
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
72
73
  var globby__default = /*#__PURE__*/_interopDefaultLegacy(globby);
73
74
  var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
75
+ var Sodium__default = /*#__PURE__*/_interopDefaultLegacy(Sodium);
74
76
  var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
75
77
  var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
76
78
  var limiterFactory__default = /*#__PURE__*/_interopDefaultLegacy(limiterFactory);
@@ -179,13 +181,19 @@ function createCatalogRegisterAction(options) {
179
181
  });
180
182
  }
181
183
  ctx.logger.info(`Registering ${catalogInfoUrl} in the catalog`);
182
- await catalogClient.addLocation(
183
- {
184
- type: "url",
185
- target: catalogInfoUrl
186
- },
187
- ((_a = ctx.secrets) == null ? void 0 : _a.backstageToken) ? { token: ctx.secrets.backstageToken } : {}
188
- );
184
+ try {
185
+ await catalogClient.addLocation(
186
+ {
187
+ type: "url",
188
+ target: catalogInfoUrl
189
+ },
190
+ ((_a = ctx.secrets) == null ? void 0 : _a.backstageToken) ? { token: ctx.secrets.backstageToken } : {}
191
+ );
192
+ } catch (e) {
193
+ if (!input.optional) {
194
+ throw e;
195
+ }
196
+ }
189
197
  try {
190
198
  const result = await catalogClient.addLocation(
191
199
  {
@@ -195,7 +203,7 @@ function createCatalogRegisterAction(options) {
195
203
  },
196
204
  ((_b = ctx.secrets) == null ? void 0 : _b.backstageToken) ? { token: ctx.secrets.backstageToken } : {}
197
205
  );
198
- if (result.entities.length > 0) {
206
+ if (result.entities.length) {
199
207
  const { entities } = result;
200
208
  let entity;
201
209
  entity = entities.find(
@@ -1458,7 +1466,7 @@ async function getOctokitOptions(options) {
1458
1466
  previews: ["nebula-preview"]
1459
1467
  };
1460
1468
  }
1461
- async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, repoVisibility, description, homepage, deleteBranchOnMerge, allowMergeCommit, allowSquashMerge, squashMergeCommitTitle, squashMergeCommitMessage, allowRebaseMerge, allowAutoMerge, access, collaborators, hasProjects, hasWiki, hasIssues, topics, logger) {
1469
+ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, repoVisibility, description, homepage, deleteBranchOnMerge, allowMergeCommit, allowSquashMerge, squashMergeCommitTitle, squashMergeCommitMessage, allowRebaseMerge, allowAutoMerge, access, collaborators, hasProjects, hasWiki, hasIssues, topics, repoVariables, secrets, logger) {
1462
1470
  const user = await client.rest.users.getByUsername({
1463
1471
  username: owner
1464
1472
  });
@@ -1469,6 +1477,7 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
1469
1477
  name: repo,
1470
1478
  org: owner,
1471
1479
  private: repoVisibility === "private",
1480
+ // @ts-ignore
1472
1481
  visibility: repoVisibility,
1473
1482
  description,
1474
1483
  delete_branch_on_merge: deleteBranchOnMerge,
@@ -1569,6 +1578,43 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
1569
1578
  logger.warn(`Skipping topics ${topics.join(" ")}, ${e.message}`);
1570
1579
  }
1571
1580
  }
1581
+ for (const [key, value] of Object.entries(repoVariables != null ? repoVariables : {})) {
1582
+ await client.rest.actions.createRepoVariable({
1583
+ owner,
1584
+ repo,
1585
+ name: key,
1586
+ value
1587
+ });
1588
+ }
1589
+ if (secrets) {
1590
+ const publicKeyResponse = await client.rest.actions.getRepoPublicKey({
1591
+ owner,
1592
+ repo
1593
+ });
1594
+ await Sodium__default["default"].ready;
1595
+ const binaryKey = Sodium__default["default"].from_base64(
1596
+ publicKeyResponse.data.key,
1597
+ Sodium__default["default"].base64_variants.ORIGINAL
1598
+ );
1599
+ for (const [key, value] of Object.entries(secrets)) {
1600
+ const binarySecret = Sodium__default["default"].from_string(value);
1601
+ const encryptedBinarySecret = Sodium__default["default"].crypto_box_seal(
1602
+ binarySecret,
1603
+ binaryKey
1604
+ );
1605
+ const encryptedBase64Secret = Sodium__default["default"].to_base64(
1606
+ encryptedBinarySecret,
1607
+ Sodium__default["default"].base64_variants.ORIGINAL
1608
+ );
1609
+ await client.rest.actions.createOrUpdateRepoSecret({
1610
+ owner,
1611
+ repo,
1612
+ secret_name: key,
1613
+ encrypted_value: encryptedBase64Secret,
1614
+ key_id: publicKeyResponse.data.key_id
1615
+ });
1616
+ }
1617
+ }
1572
1618
  return newRepo;
1573
1619
  }
1574
1620
  async function initRepoPushAndProtect(remoteUrl, password, workspacePath, sourcePath, defaultBranch, protectDefaultBranch, protectEnforceAdmins, owner, client, repo, requireCodeOwnerReviews, bypassPullRequestAllowances, requiredApprovingReviewCount, restrictions, requiredStatusCheckContexts, requireBranchesToBeUpToDate, requiredConversationResolution, config, logger, gitCommitMessage, gitAuthorName, gitAuthorEmail, dismissStaleReviews, requiredCommitSigning) {
@@ -2016,6 +2062,16 @@ const requiredCommitSigning = {
2016
2062
  type: "boolean",
2017
2063
  description: `Require commit signing so that you must sign commits on this branch.`
2018
2064
  };
2065
+ const repoVariables = {
2066
+ title: "Repository Variables",
2067
+ description: `Variables attached to the repository`,
2068
+ type: "object"
2069
+ };
2070
+ const secrets = {
2071
+ title: "Repository Secrets",
2072
+ description: `Secrets attached to the repository`,
2073
+ type: "object"
2074
+ };
2019
2075
 
2020
2076
  const remoteUrl = {
2021
2077
  title: "A URL to the repository with the provider",
@@ -2065,6 +2121,8 @@ function createGithubRepoCreateAction(options) {
2065
2121
  hasIssues: hasIssues,
2066
2122
  token: token,
2067
2123
  topics: topics,
2124
+ repoVariables: repoVariables,
2125
+ secrets: secrets,
2068
2126
  requiredCommitSigning: requiredCommitSigning
2069
2127
  }
2070
2128
  },
@@ -2095,6 +2153,8 @@ function createGithubRepoCreateAction(options) {
2095
2153
  hasWiki = void 0,
2096
2154
  hasIssues = void 0,
2097
2155
  topics,
2156
+ repoVariables,
2157
+ secrets,
2098
2158
  token: providedToken
2099
2159
  } = ctx.input;
2100
2160
  const octokitOptions = await getOctokitOptions({
@@ -2128,6 +2188,8 @@ function createGithubRepoCreateAction(options) {
2128
2188
  hasWiki,
2129
2189
  hasIssues,
2130
2190
  topics,
2191
+ repoVariables,
2192
+ secrets,
2131
2193
  ctx.logger
2132
2194
  );
2133
2195
  ctx.output("remoteUrl", newRepo.clone_url);
@@ -3515,6 +3577,8 @@ function createPublishGithubAction(options) {
3515
3577
  hasIssues: hasIssues,
3516
3578
  token: token,
3517
3579
  topics: topics,
3580
+ repoVariables: repoVariables,
3581
+ secrets: secrets,
3518
3582
  requiredCommitSigning: requiredCommitSigning
3519
3583
  }
3520
3584
  },
@@ -3560,6 +3624,8 @@ function createPublishGithubAction(options) {
3560
3624
  hasWiki = void 0,
3561
3625
  hasIssues = void 0,
3562
3626
  topics,
3627
+ repoVariables,
3628
+ secrets,
3563
3629
  token: providedToken,
3564
3630
  requiredCommitSigning = false
3565
3631
  } = ctx.input;
@@ -3594,6 +3660,8 @@ function createPublishGithubAction(options) {
3594
3660
  hasWiki,
3595
3661
  hasIssues,
3596
3662
  topics,
3663
+ repoVariables,
3664
+ secrets,
3597
3665
  ctx.logger
3598
3666
  );
3599
3667
  const remoteUrl = newRepo.clone_url;
@@ -4250,13 +4318,15 @@ const createPublishGitlabMergeRequestAction = (options) => {
4250
4318
  try {
4251
4319
  await api.Branches.create(repoID, branchName, String(defaultBranch));
4252
4320
  } catch (e) {
4253
- throw new errors.InputError(`The branch creation failed ${e}`);
4321
+ throw new errors.InputError(
4322
+ `The branch creation failed. Please check that your repo does not already contain a branch named '${branchName}'. ${e}`
4323
+ );
4254
4324
  }
4255
4325
  try {
4256
4326
  await api.Commits.create(repoID, branchName, ctx.input.title, actions);
4257
4327
  } catch (e) {
4258
4328
  throw new errors.InputError(
4259
- `Committing the changes to ${branchName} failed ${e}`
4329
+ `Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${e}`
4260
4330
  );
4261
4331
  }
4262
4332
  try {
@@ -6174,4 +6244,4 @@ exports.executeShellCommand = executeShellCommand;
6174
6244
  exports.fetchContents = fetchContents;
6175
6245
  exports.scaffolderActionRules = scaffolderActionRules;
6176
6246
  exports.scaffolderTemplateRules = scaffolderTemplateRules;
6177
- //# sourceMappingURL=ScaffolderEntitiesProcessor-021c5dcb.cjs.js.map
6247
+ //# sourceMappingURL=ScaffolderEntitiesProcessor-9c1b2955.cjs.js.map