@backstage/plugin-scaffolder-backend 1.14.1-next.0 → 1.15.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 +37 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.cjs.js +2 -1
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/cjs/{ScaffolderEntitiesProcessor-c40021d1.cjs.js → ScaffolderEntitiesProcessor-70d9fced.cjs.js} +67 -4
- package/dist/cjs/ScaffolderEntitiesProcessor-70d9fced.cjs.js.map +1 -0
- package/dist/index.cjs.js +2 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/package.json +20 -18
- package/dist/cjs/ScaffolderEntitiesProcessor-c40021d1.cjs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend
|
|
2
2
|
|
|
3
|
+
## 1.15.0-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 11e0f625583f: Fix wrong gitlabUrl format in repoUrl input description
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/config@1.0.7
|
|
10
|
+
|
|
11
|
+
## 1.15.0-next.1
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 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`
|
|
16
|
+
|
|
17
|
+
Upgrade octokit introduces some breaking changes.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @backstage/backend-common@0.19.0-next.1
|
|
23
|
+
- @backstage/plugin-catalog-backend@1.9.2-next.1
|
|
24
|
+
- @backstage/integration@1.5.0-next.0
|
|
25
|
+
- @backstage/errors@1.2.0-next.0
|
|
26
|
+
- @backstage/backend-plugin-api@0.5.3-next.1
|
|
27
|
+
- @backstage/catalog-model@1.4.0-next.0
|
|
28
|
+
- @backstage/backend-tasks@0.5.3-next.1
|
|
29
|
+
- @backstage/plugin-auth-node@0.2.15-next.1
|
|
30
|
+
- @backstage/plugin-catalog-node@1.3.7-next.1
|
|
31
|
+
- @backstage/plugin-permission-node@0.7.9-next.1
|
|
32
|
+
- @backstage/catalog-client@1.4.2-next.1
|
|
33
|
+
- @backstage/plugin-permission-common@0.7.6-next.0
|
|
34
|
+
- @backstage/plugin-scaffolder-node@0.1.4-next.1
|
|
35
|
+
- @backstage/plugin-catalog-common@1.0.14-next.0
|
|
36
|
+
- @backstage/plugin-scaffolder-common@1.3.1-next.0
|
|
37
|
+
- @backstage/config@1.0.7
|
|
38
|
+
- @backstage/types@1.0.2
|
|
39
|
+
|
|
3
40
|
## 1.14.1-next.0
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
package/alpha/package.json
CHANGED
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-
|
|
7
|
+
var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-70d9fced.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');
|
package/dist/alpha.cjs.js.map
CHANGED
|
@@ -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,EAA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AI,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;;;;;;;;;"}
|
|
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","logger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A,YAClC,GAAG,iBAAkB,CAAA,OAAA;AAAA,YACrB,GAAGC,gDAAqB,CAAA;AAAA,cACtB,YAAA,EAAcC,2BAAgB,CAAA,UAAA,CAAW,MAAM,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);
|
|
@@ -1464,7 +1466,7 @@ async function getOctokitOptions(options) {
|
|
|
1464
1466
|
previews: ["nebula-preview"]
|
|
1465
1467
|
};
|
|
1466
1468
|
}
|
|
1467
|
-
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) {
|
|
1468
1470
|
const user = await client.rest.users.getByUsername({
|
|
1469
1471
|
username: owner
|
|
1470
1472
|
});
|
|
@@ -1475,6 +1477,7 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
|
|
|
1475
1477
|
name: repo,
|
|
1476
1478
|
org: owner,
|
|
1477
1479
|
private: repoVisibility === "private",
|
|
1480
|
+
// @ts-ignore
|
|
1478
1481
|
visibility: repoVisibility,
|
|
1479
1482
|
description,
|
|
1480
1483
|
delete_branch_on_merge: deleteBranchOnMerge,
|
|
@@ -1575,6 +1578,43 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
|
|
|
1575
1578
|
logger.warn(`Skipping topics ${topics.join(" ")}, ${e.message}`);
|
|
1576
1579
|
}
|
|
1577
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
|
+
}
|
|
1578
1618
|
return newRepo;
|
|
1579
1619
|
}
|
|
1580
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) {
|
|
@@ -2022,6 +2062,16 @@ const requiredCommitSigning = {
|
|
|
2022
2062
|
type: "boolean",
|
|
2023
2063
|
description: `Require commit signing so that you must sign commits on this branch.`
|
|
2024
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
|
+
};
|
|
2025
2075
|
|
|
2026
2076
|
const remoteUrl = {
|
|
2027
2077
|
title: "A URL to the repository with the provider",
|
|
@@ -2071,6 +2121,8 @@ function createGithubRepoCreateAction(options) {
|
|
|
2071
2121
|
hasIssues: hasIssues,
|
|
2072
2122
|
token: token,
|
|
2073
2123
|
topics: topics,
|
|
2124
|
+
repoVariables: repoVariables,
|
|
2125
|
+
secrets: secrets,
|
|
2074
2126
|
requiredCommitSigning: requiredCommitSigning
|
|
2075
2127
|
}
|
|
2076
2128
|
},
|
|
@@ -2101,6 +2153,8 @@ function createGithubRepoCreateAction(options) {
|
|
|
2101
2153
|
hasWiki = void 0,
|
|
2102
2154
|
hasIssues = void 0,
|
|
2103
2155
|
topics,
|
|
2156
|
+
repoVariables,
|
|
2157
|
+
secrets,
|
|
2104
2158
|
token: providedToken
|
|
2105
2159
|
} = ctx.input;
|
|
2106
2160
|
const octokitOptions = await getOctokitOptions({
|
|
@@ -2134,6 +2188,8 @@ function createGithubRepoCreateAction(options) {
|
|
|
2134
2188
|
hasWiki,
|
|
2135
2189
|
hasIssues,
|
|
2136
2190
|
topics,
|
|
2191
|
+
repoVariables,
|
|
2192
|
+
secrets,
|
|
2137
2193
|
ctx.logger
|
|
2138
2194
|
);
|
|
2139
2195
|
ctx.output("remoteUrl", newRepo.clone_url);
|
|
@@ -3521,6 +3577,8 @@ function createPublishGithubAction(options) {
|
|
|
3521
3577
|
hasIssues: hasIssues,
|
|
3522
3578
|
token: token,
|
|
3523
3579
|
topics: topics,
|
|
3580
|
+
repoVariables: repoVariables,
|
|
3581
|
+
secrets: secrets,
|
|
3524
3582
|
requiredCommitSigning: requiredCommitSigning
|
|
3525
3583
|
}
|
|
3526
3584
|
},
|
|
@@ -3566,6 +3624,8 @@ function createPublishGithubAction(options) {
|
|
|
3566
3624
|
hasWiki = void 0,
|
|
3567
3625
|
hasIssues = void 0,
|
|
3568
3626
|
topics,
|
|
3627
|
+
repoVariables,
|
|
3628
|
+
secrets,
|
|
3569
3629
|
token: providedToken,
|
|
3570
3630
|
requiredCommitSigning = false
|
|
3571
3631
|
} = ctx.input;
|
|
@@ -3600,6 +3660,8 @@ function createPublishGithubAction(options) {
|
|
|
3600
3660
|
hasWiki,
|
|
3601
3661
|
hasIssues,
|
|
3602
3662
|
topics,
|
|
3663
|
+
repoVariables,
|
|
3664
|
+
secrets,
|
|
3603
3665
|
ctx.logger
|
|
3604
3666
|
);
|
|
3605
3667
|
const remoteUrl = newRepo.clone_url;
|
|
@@ -3950,7 +4012,8 @@ function createPublishGitlabAction(options) {
|
|
|
3950
4012
|
properties: {
|
|
3951
4013
|
repoUrl: {
|
|
3952
4014
|
title: "Repository Location",
|
|
3953
|
-
type: "string"
|
|
4015
|
+
type: "string",
|
|
4016
|
+
description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`
|
|
3954
4017
|
},
|
|
3955
4018
|
repoVisibility: {
|
|
3956
4019
|
title: "Repository Visibility",
|
|
@@ -4112,7 +4175,7 @@ const createPublishGitlabMergeRequestAction = (options) => {
|
|
|
4112
4175
|
repoUrl: {
|
|
4113
4176
|
type: "string",
|
|
4114
4177
|
title: "Repository Location",
|
|
4115
|
-
description: `Accepts the format 'gitlab.com
|
|
4178
|
+
description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`
|
|
4116
4179
|
},
|
|
4117
4180
|
/** @deprecated projectID is passed as query parameters in the repoUrl */
|
|
4118
4181
|
projectid: {
|
|
@@ -6182,4 +6245,4 @@ exports.executeShellCommand = executeShellCommand;
|
|
|
6182
6245
|
exports.fetchContents = fetchContents;
|
|
6183
6246
|
exports.scaffolderActionRules = scaffolderActionRules;
|
|
6184
6247
|
exports.scaffolderTemplateRules = scaffolderTemplateRules;
|
|
6185
|
-
//# sourceMappingURL=ScaffolderEntitiesProcessor-
|
|
6248
|
+
//# sourceMappingURL=ScaffolderEntitiesProcessor-70d9fced.cjs.js.map
|