@backstage/plugin-scaffolder-backend 1.15.2-next.0 → 1.15.2-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,30 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.15.2-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 629cbd194a87: Use `coreServices.rootConfig` instead of `coreService.config`
8
+ - d3b31a791eb1: Deprecated `executeShellCommand`, `RunCommandOptions`, and `fetchContents` from `@backstage/plugin-scaffolder-backend`, since they are useful for Scaffolder modules (who should not be importing from the plugin package itself). You should now import these from `@backstage/plugin-scaffolder-backend-node` instead. `RunCommandOptions` was renamed in the Node package as `ExecuteShellCommandOptions`, for consistency.
9
+ - Updated dependencies
10
+ - @backstage/backend-common@0.19.2-next.1
11
+ - @backstage/plugin-catalog-backend@1.12.0-next.1
12
+ - @backstage/plugin-scaffolder-node@0.1.6-next.1
13
+ - @backstage/plugin-catalog-node@1.4.1-next.1
14
+ - @backstage/plugin-auth-node@0.2.17-next.1
15
+ - @backstage/backend-plugin-api@0.6.0-next.1
16
+ - @backstage/backend-tasks@0.5.5-next.1
17
+ - @backstage/plugin-permission-node@0.7.11-next.1
18
+ - @backstage/integration@1.5.1
19
+ - @backstage/catalog-client@1.4.3
20
+ - @backstage/catalog-model@1.4.1
21
+ - @backstage/config@1.0.8
22
+ - @backstage/errors@1.2.1
23
+ - @backstage/types@1.1.0
24
+ - @backstage/plugin-catalog-common@1.0.15
25
+ - @backstage/plugin-permission-common@0.7.7
26
+ - @backstage/plugin-scaffolder-common@1.3.2
27
+
3
28
  ## 1.15.2-next.0
4
29
 
5
30
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
- "version": "1.15.2-next.0",
3
+ "version": "1.15.2-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,22 +4,20 @@ 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-b514f9e5.cjs.js');
7
+ var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-1d387347.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');
11
11
  var integration = require('@backstage/integration');
12
12
  var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
13
- require('@backstage/errors');
14
- require('fs-extra');
15
13
  require('path');
14
+ require('@backstage/errors');
16
15
  require('globby');
16
+ require('fs-extra');
17
17
  require('isbinaryfile');
18
18
  require('isolated-vm');
19
19
  require('@backstage/catalog-model');
20
20
  require('lodash/get');
21
- require('child_process');
22
- require('stream');
23
21
  require('azure-devops-node-api');
24
22
  require('node-fetch');
25
23
  require('crypto');
@@ -42,6 +40,7 @@ require('luxon');
42
40
  require('uuid');
43
41
  require('winston');
44
42
  require('nunjucks');
43
+ require('stream');
45
44
  require('lodash');
46
45
  require('prom-client');
47
46
  require('@backstage/plugin-permission-common');
@@ -117,7 +116,7 @@ const scaffolderPlugin = backendPluginApi.createBackendPlugin(
117
116
  env.registerInit({
118
117
  deps: {
119
118
  logger: backendPluginApi.coreServices.logger,
120
- config: backendPluginApi.coreServices.config,
119
+ config: backendPluginApi.coreServices.rootConfig,
121
120
  reader: backendPluginApi.coreServices.urlReader,
122
121
  permissions: backendPluginApi.coreServices.permissions,
123
122
  database: backendPluginApi.coreServices.database,
@@ -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,GACH;AACF,CAAC;;ACfD,MAAM,2BAA2BC,2CAAuB,CAAA;AAAA,EACtD,QAAU,E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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.rootConfig,\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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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,0DAA0D,SAAS,CAAA,CAAA;AAAA,WACrE,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;;;;;;;;;"}
@@ -20,8 +20,6 @@ var isbinaryfile = require('isbinaryfile');
20
20
  var isolatedVm = require('isolated-vm');
21
21
  var get = require('lodash/get');
22
22
  var octokit = require('octokit');
23
- var child_process = require('child_process');
24
- var stream = require('stream');
25
23
  var Sodium = require('libsodium-wrappers');
26
24
  var webhooks = require('@octokit/webhooks');
27
25
  var azureDevopsNodeApi = require('azure-devops-node-api');
@@ -36,6 +34,7 @@ var ObservableImpl = require('zen-observable');
36
34
  var PQueue = require('p-queue');
37
35
  var winston = require('winston');
38
36
  var nunjucks = require('nunjucks');
37
+ var stream = require('stream');
39
38
  var lodash = require('lodash');
40
39
  var pluginPermissionNode = require('@backstage/plugin-permission-node');
41
40
  var promClient = require('prom-client');
@@ -575,62 +574,6 @@ function createWaitAction(options) {
575
574
  });
576
575
  }
577
576
 
578
- async function fetchContents(options) {
579
- const { reader, integrations, baseUrl, fetchUrl = ".", outputPath } = options;
580
- const fetchUrlIsAbsolute = isFetchUrlAbsolute(fetchUrl);
581
- if (!fetchUrlIsAbsolute && (baseUrl == null ? void 0 : baseUrl.startsWith("file://"))) {
582
- const basePath = baseUrl.slice("file://".length);
583
- const srcDir = backendCommon.resolveSafeChildPath(path__default["default"].dirname(basePath), fetchUrl);
584
- await fs__default["default"].copy(srcDir, outputPath);
585
- } else {
586
- const readUrl = getReadUrl(fetchUrl, baseUrl, integrations);
587
- const res = await reader.readTree(readUrl);
588
- await fs__default["default"].ensureDir(outputPath);
589
- await res.dir({ targetDir: outputPath });
590
- }
591
- }
592
- async function fetchFile(options) {
593
- const { reader, integrations, baseUrl, fetchUrl = ".", outputPath } = options;
594
- const fetchUrlIsAbsolute = isFetchUrlAbsolute(fetchUrl);
595
- if (!fetchUrlIsAbsolute && (baseUrl == null ? void 0 : baseUrl.startsWith("file://"))) {
596
- const basePath = baseUrl.slice("file://".length);
597
- const src = backendCommon.resolveSafeChildPath(path__default["default"].dirname(basePath), fetchUrl);
598
- await fs__default["default"].copyFile(src, outputPath);
599
- } else {
600
- const readUrl = getReadUrl(fetchUrl, baseUrl, integrations);
601
- const res = await reader.readUrl(readUrl);
602
- await fs__default["default"].ensureDir(path__default["default"].dirname(outputPath));
603
- const buffer = await res.buffer();
604
- await fs__default["default"].outputFile(outputPath, buffer.toString());
605
- }
606
- }
607
- function isFetchUrlAbsolute(fetchUrl) {
608
- let fetchUrlIsAbsolute = false;
609
- try {
610
- new URL(fetchUrl);
611
- fetchUrlIsAbsolute = true;
612
- } catch {
613
- }
614
- return fetchUrlIsAbsolute;
615
- }
616
- function getReadUrl(fetchUrl, baseUrl, integrations) {
617
- if (isFetchUrlAbsolute(fetchUrl)) {
618
- return fetchUrl;
619
- } else if (baseUrl) {
620
- const integration = integrations.byUrl(baseUrl);
621
- if (!integration) {
622
- throw new errors.InputError(`No integration found for location ${baseUrl}`);
623
- }
624
- return integration.resolveUrl({
625
- url: fetchUrl,
626
- base: baseUrl
627
- });
628
- }
629
- throw new errors.InputError(
630
- `Failed to fetch, template location could not be determined and the fetch URL is relative, ${fetchUrl}`
631
- );
632
- }
633
-
634
577
  function createFetchPlainAction(options) {
635
578
  const { reader, integrations } = options;
636
579
  return pluginScaffolderNode.createTemplateAction({
@@ -660,7 +603,7 @@ function createFetchPlainAction(options) {
660
603
  ctx.logger.info("Fetching plain content from remote URL");
661
604
  const targetPath = (_a = ctx.input.targetPath) != null ? _a : "./";
662
605
  const outputPath = backendCommon.resolveSafeChildPath(ctx.workspacePath, targetPath);
663
- await fetchContents({
606
+ await pluginScaffolderNode.fetchContents({
664
607
  reader,
665
608
  integrations,
666
609
  baseUrl: (_b = ctx.templateInfo) == null ? void 0 : _b.baseUrl,
@@ -702,7 +645,7 @@ function createFetchPlainFileAction(options) {
702
645
  ctx.workspacePath,
703
646
  ctx.input.targetPath
704
647
  );
705
- await fetchFile({
648
+ await pluginScaffolderNode.fetchFile({
706
649
  reader,
707
650
  integrations,
708
651
  baseUrl: (_a = ctx.templateInfo) == null ? void 0 : _a.baseUrl,
@@ -1050,7 +993,7 @@ function createFetchTemplateAction(options) {
1050
993
  extension = `.${extension}`;
1051
994
  }
1052
995
  }
1053
- await fetchContents({
996
+ await pluginScaffolderNode.fetchContents({
1054
997
  reader,
1055
998
  integrations,
1056
999
  baseUrl: (_b = ctx.templateInfo) == null ? void 0 : _b.baseUrl,
@@ -1267,34 +1210,6 @@ const createFilesystemRenameAction = () => {
1267
1210
  });
1268
1211
  };
1269
1212
 
1270
- const executeShellCommand = async (options) => {
1271
- const {
1272
- command,
1273
- args,
1274
- options: spawnOptions,
1275
- logStream = new stream.PassThrough()
1276
- } = options;
1277
- await new Promise((resolve, reject) => {
1278
- const process = child_process.spawn(command, args, spawnOptions);
1279
- process.stdout.on("data", (stream) => {
1280
- logStream.write(stream);
1281
- });
1282
- process.stderr.on("data", (stream) => {
1283
- logStream.write(stream);
1284
- });
1285
- process.on("error", (error) => {
1286
- return reject(error);
1287
- });
1288
- process.on("close", (code) => {
1289
- if (code !== 0) {
1290
- return reject(
1291
- new Error(`Command ${command} failed, exit code: ${code}`)
1292
- );
1293
- }
1294
- return resolve();
1295
- });
1296
- });
1297
- };
1298
1213
  async function initRepoAndPush({
1299
1214
  dir,
1300
1215
  remoteUrl,
@@ -6801,8 +6716,6 @@ exports.createPublishGitlabAction = createPublishGitlabAction;
6801
6716
  exports.createPublishGitlabMergeRequestAction = createPublishGitlabMergeRequestAction;
6802
6717
  exports.createRouter = createRouter;
6803
6718
  exports.createWaitAction = createWaitAction;
6804
- exports.executeShellCommand = executeShellCommand;
6805
- exports.fetchContents = fetchContents;
6806
6719
  exports.scaffolderActionRules = scaffolderActionRules;
6807
6720
  exports.scaffolderTemplateRules = scaffolderTemplateRules;
6808
- //# sourceMappingURL=ScaffolderEntitiesProcessor-b514f9e5.cjs.js.map
6721
+ //# sourceMappingURL=ScaffolderEntitiesProcessor-1d387347.cjs.js.map