@backstage/plugin-scaffolder-backend 4.2.2 → 4.2.3
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 +3 -57
- package/dist/ScaffolderPlugin.cjs.js.map +1 -1
- package/dist/actions/createDryRunTemplateAction.cjs.js.map +1 -1
- package/dist/actions/createExecuteTemplateAction.cjs.js.map +1 -1
- package/dist/actions/createGetScaffolderTaskLogsAction.cjs.js.map +1 -1
- package/dist/actions/createListScaffolderActionsAction.cjs.js.map +1 -1
- package/dist/actions/index.cjs.js.map +1 -1
- package/dist/actions/listScaffolderTasksAction.cjs.js.map +1 -1
- package/dist/lib/defaultEnvironment.cjs.js.map +1 -1
- package/dist/lib/templating/filters/createDefaultFilters.cjs.js.map +1 -1
- package/dist/lib/templating/filters/parseEntityRef/examples.cjs.js.map +1 -1
- package/dist/lib/templating/filters/parseEntityRef/filter.cjs.js.map +1 -1
- package/dist/lib/templating/filters/parseRepoUrl/examples.cjs.js.map +1 -1
- package/dist/lib/templating/filters/parseRepoUrl/filter.cjs.js.map +1 -1
- package/dist/lib/templating/filters/pick/examples.cjs.js.map +1 -1
- package/dist/lib/templating/filters/pick/filter.cjs.js.map +1 -1
- package/dist/lib/templating/filters/projectSlug/examples.cjs.js.map +1 -1
- package/dist/lib/templating/filters/projectSlug/filter.cjs.js.map +1 -1
- package/dist/scaffolder/actions/TemplateActionRegistry.cjs.js +0 -2
- package/dist/scaffolder/actions/TemplateActionRegistry.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/catalog/fetch.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/catalog/fetch.examples.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/catalog/register.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/catalog/register.examples.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/catalog/write.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/catalog/write.examples.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/debug/log.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/debug/log.examples.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/debug/wait.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/debug/wait.examples.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/assertScmUserCredentials.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/plain.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/plain.examples.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/plainFile.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/plainFile.examples.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/template.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/template.examples.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/templateActionHandler.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/templateFile.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/templateFile.examples.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/templateFileActionHandler.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/workspaceTemplate.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/fetch/workspaceTemplateFile.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/filesystem/delete.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/filesystem/delete.examples.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/filesystem/read.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/filesystem/read.examples.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/filesystem/rename.cjs.js.map +1 -1
- package/dist/scaffolder/actions/builtin/filesystem/rename.examples.cjs.js.map +1 -1
- package/dist/scaffolder/dryrun/DecoratedActionsRegistry.cjs.js.map +1 -1
- package/dist/scaffolder/dryrun/createDryRunner.cjs.js.map +1 -1
- package/dist/scaffolder/tasks/DatabaseTaskStore.cjs.js.map +1 -1
- package/dist/scaffolder/tasks/NunjucksWorkflowRunner.cjs.js +1 -3
- package/dist/scaffolder/tasks/NunjucksWorkflowRunner.cjs.js.map +1 -1
- package/dist/scaffolder/tasks/StorageTaskBroker.cjs.js.map +1 -1
- package/dist/scaffolder/tasks/TaskWorker.cjs.js.map +1 -1
- package/dist/scaffolder/tasks/WorkspaceService.cjs.js.map +1 -1
- package/dist/scaffolder/tasks/dbUtil.cjs.js.map +1 -1
- package/dist/scaffolder/tasks/helper.cjs.js.map +1 -1
- package/dist/scaffolder/tasks/logger.cjs.js.map +1 -1
- package/dist/scaffolder/tasks/taskRecoveryHelper.cjs.js.map +1 -1
- package/dist/schema/openapi/generated/router.cjs.js.map +1 -1
- package/dist/service/alpha.cjs.js.map +1 -1
- package/dist/service/helpers.cjs.js.map +1 -1
- package/dist/service/permissions.cjs.js.map +1 -1
- package/dist/service/router.cjs.js.map +1 -1
- package/dist/service/rules.cjs.js.map +1 -1
- package/dist/util/checkPermissions.cjs.js.map +1 -1
- package/dist/util/loggerToWinstonLogger.cjs.js.map +1 -1
- package/dist/util/metrics.cjs.js.map +1 -1
- package/dist/util/templating.cjs.js.map +1 -1
- package/package.json +19 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/catalog/register.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { InputError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { stringifyEntityRef, Entity } from '@backstage/catalog-model';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { examples } from './register.examples';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\n\nconst id = 'catalog:register';\n\n/**\n * Registers entities from a catalog descriptor file in the workspace into the software catalog.\n * @public\n */\nexport function createCatalogRegisterAction(options: {\n catalog: CatalogService;\n integrations: ScmIntegrations;\n}) {\n const { catalog, integrations } = options;\n\n return createTemplateAction({\n id,\n description:\n 'Registers entities from a catalog descriptor file in the workspace into the software catalog.',\n examples,\n schema: {\n input: z =>\n z.union([\n z.object({\n catalogInfoUrl: z.string({\n description:\n 'An absolute URL pointing to the catalog info file location',\n }),\n optional: z\n .boolean({\n description:\n 'Permit the registered location to optionally exist. Default: false',\n })\n .optional(),\n }),\n z.object({\n repoContentsUrl: z.string({\n description:\n 'An absolute URL pointing to the root of a repository directory tree',\n }),\n catalogInfoPath: z\n .string({\n description:\n 'A relative path from the repo root pointing to the catalog info file, defaults to /catalog-info.yaml',\n })\n .optional(),\n optional: z\n .boolean({\n description:\n 'Permit the registered location to optionally exist. Default: false',\n })\n .optional(),\n }),\n ]),\n },\n async handler(ctx) {\n const { input } = ctx;\n\n let catalogInfoUrl;\n if ('catalogInfoUrl' in input) {\n catalogInfoUrl = input.catalogInfoUrl;\n } else {\n const { repoContentsUrl, catalogInfoPath = '/catalog-info.yaml' } =\n input;\n const integration = integrations.byUrl(repoContentsUrl);\n if (!integration) {\n throw new InputError(\n `No integration found for host ${repoContentsUrl}`,\n );\n }\n\n catalogInfoUrl = integration.resolveUrl({\n base: repoContentsUrl,\n url: catalogInfoPath,\n });\n }\n\n ctx.logger.info(`Registering ${catalogInfoUrl} in the catalog`);\n\n try {\n // 1st try to register the location, this will throw an error if the location already exists (see catch)\n await catalog.addLocation(\n {\n type: 'url',\n target: catalogInfoUrl,\n },\n { credentials: await ctx.getInitiatorCredentials() },\n );\n } catch (e) {\n if (!input.optional) {\n // if optional is false or unset, it is not allowed to register the same location twice, we rethrow the error\n throw e;\n }\n }\n\n try {\n // 2nd retry the registration as a dry run, this will not throw an error if the location already exists\n const result = await catalog.addLocation(\n {\n dryRun: true,\n type: 'url',\n target: catalogInfoUrl,\n },\n { credentials: await ctx.getInitiatorCredentials() },\n );\n\n if (result.entities.length) {\n const { entities } = result;\n let entity: Entity | undefined;\n // prioritise 'Component' type as it is the most central kind of entity\n entity = entities.find(\n e =>\n !e.metadata.name.startsWith('generated-') &&\n e.kind === 'Component',\n );\n if (!entity) {\n entity = entities.find(\n e => !e.metadata.name.startsWith('generated-'),\n );\n }\n if (!entity) {\n entity = entities[0];\n }\n\n ctx.output('entityRef', stringifyEntityRef(entity));\n }\n } catch (e) {\n if (!input.optional) {\n throw e;\n }\n }\n\n ctx.output('catalogInfoUrl', catalogInfoUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","InputError","stringifyEntityRef"],"mappings":";;;;;;;AAuBA,MAAM,EAAA,GAAK,kBAAA;AAMJ,SAAS,4BAA4B,OAAA,EAGzC;AACD,EAAA,MAAM,EAAE,OAAA,EAAS,YAAA,EAAa,GAAI,OAAA;AAElC,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA;AAAA,IACA,WAAA,EACE,+FAAA;AAAA,cACFC,0BAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CAAE,KAAA,CAAM;AAAA,QACN,EAAE,MAAA,CAAO;AAAA,UACP,cAAA,EAAgB,EAAE,MAAA,CAAO;AAAA,YACvB,WAAA,EACE;AAAA,WACH,CAAA;AAAA,UACD,QAAA,EAAU,EACP,OAAA,CAAQ;AAAA,YACP,WAAA,EACE;AAAA,WACH,EACA,QAAA;AAAS,SACb,CAAA;AAAA,QACD,EAAE,MAAA,CAAO;AAAA,UACP,eAAA,EAAiB,EAAE,MAAA,CAAO;AAAA,YACxB,WAAA,EACE;AAAA,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AEA,MAAA,IAAI;AAEF,QAAA,MAAM,MAAA,GAAS,MAAM,OAAA,CAAQ,WAAA;AAAA,UAC3B;AAAA,YACE,MAAA,EAAQ,IAAA;AAAA,YACR,IAAA,EAAM,KAAA;AAAA,YACN,MAAA,EAAQ;AAAA,WACV;AAAA,UACA,EAAE,WAAA,EAAa,MAAM,GAAA,CAAI,yBAAwB;AAAE,SACrD;AAEA,QAAA,IAAI,MAAA,CAAO,SAAS,MAAA,EAAQ;AAC1B,UAAA,MAAM,EAAE,UAAS,GAAI,MAAA;AACrB,UAAA,IAAI,MAAA;AAEJ,UAAA,MAAA,GAAS,QAAA,CAAS,IAAA;AAAA,YAChB,CAAA,CAAA,KACE,CAAC,CAAA,CAAE,QAAA,CAAS,KAAK,UAAA,CAAW,YAAY,CAAA,IACxC,CAAA,CAAE,IAAA,KAAS;AAAA,WACf;AACA,UAAA,IAAI,CAAC,MAAA,EAAQ;AACX,YAAA,MAAA,GAAS,QAAA,CAAS,IAAA;AAAA,cAChB,OAAK,CAAC,CAAA,CAAE,QAAA,CAAS,IAAA,CAAK,WAAW,YAAY;AAAA,aAC/C;AAAA,UACF;AACA,UAAA,IAAI,CAAC,MAAA,EAAQ;AACX,YAAA,MAAA,GAAS,SAAS,CAAC,CAAA;AAAA,UACrB;AAEA,UAAA,GAAA,CAAI,MAAA,CAAO,WAAA,EAAaC,+BAAA,CAAmB,MAAM,CAAC,CAAA;AAAA,QACpD;AAAA,MACF,SAAS,CAAA,EAAG;AACV,QAAA,IAAI,CAAC,MAAM,QAAA,EAAU;AACnB,UAAA,MAAM,CAAA;AAAA,QACR;AAAA,MACF;AAEA,MAAA,GAAA,CAAI,MAAA,CAAO,kBAAkB,cAAc,CAAA;AAAA,IAC7C;AAAA,GACD,CAAA;AACH
|
|
1
|
+
{"version":3,"file":"register.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/catalog/register.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { InputError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { stringifyEntityRef, Entity } from '@backstage/catalog-model';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { examples } from './register.examples';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\n\nconst id = 'catalog:register';\n\n/**\n * Registers entities from a catalog descriptor file in the workspace into the software catalog.\n * @public\n */\nexport function createCatalogRegisterAction(options: {\n catalog: CatalogService;\n integrations: ScmIntegrations;\n}) {\n const { catalog, integrations } = options;\n\n return createTemplateAction({\n id,\n description:\n 'Registers entities from a catalog descriptor file in the workspace into the software catalog.',\n examples,\n schema: {\n input: z =>\n z.union([\n z.object({\n catalogInfoUrl: z.string({\n description:\n 'An absolute URL pointing to the catalog info file location',\n }),\n optional: z\n .boolean({\n description:\n 'Permit the registered location to optionally exist. Default: false',\n })\n .optional(),\n }),\n z.object({\n repoContentsUrl: z.string({\n description:\n 'An absolute URL pointing to the root of a repository directory tree',\n }),\n catalogInfoPath: z\n .string({\n description:\n 'A relative path from the repo root pointing to the catalog info file, defaults to /catalog-info.yaml',\n })\n .optional(),\n optional: z\n .boolean({\n description:\n 'Permit the registered location to optionally exist. Default: false',\n })\n .optional(),\n }),\n ]),\n },\n async handler(ctx) {\n const { input } = ctx;\n\n let catalogInfoUrl;\n if ('catalogInfoUrl' in input) {\n catalogInfoUrl = input.catalogInfoUrl;\n } else {\n const { repoContentsUrl, catalogInfoPath = '/catalog-info.yaml' } =\n input;\n const integration = integrations.byUrl(repoContentsUrl);\n if (!integration) {\n throw new InputError(\n `No integration found for host ${repoContentsUrl}`,\n );\n }\n\n catalogInfoUrl = integration.resolveUrl({\n base: repoContentsUrl,\n url: catalogInfoPath,\n });\n }\n\n ctx.logger.info(`Registering ${catalogInfoUrl} in the catalog`);\n\n try {\n // 1st try to register the location, this will throw an error if the location already exists (see catch)\n await catalog.addLocation(\n {\n type: 'url',\n target: catalogInfoUrl,\n },\n { credentials: await ctx.getInitiatorCredentials() },\n );\n } catch (e) {\n if (!input.optional) {\n // if optional is false or unset, it is not allowed to register the same location twice, we rethrow the error\n throw e;\n }\n }\n\n try {\n // 2nd retry the registration as a dry run, this will not throw an error if the location already exists\n const result = await catalog.addLocation(\n {\n dryRun: true,\n type: 'url',\n target: catalogInfoUrl,\n },\n { credentials: await ctx.getInitiatorCredentials() },\n );\n\n if (result.entities.length) {\n const { entities } = result;\n let entity: Entity | undefined;\n // prioritise 'Component' type as it is the most central kind of entity\n entity = entities.find(\n e =>\n !e.metadata.name.startsWith('generated-') &&\n e.kind === 'Component',\n );\n if (!entity) {\n entity = entities.find(\n e => !e.metadata.name.startsWith('generated-'),\n );\n }\n if (!entity) {\n entity = entities[0];\n }\n\n ctx.output('entityRef', stringifyEntityRef(entity));\n }\n } catch (e) {\n if (!input.optional) {\n throw e;\n }\n }\n\n ctx.output('catalogInfoUrl', catalogInfoUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","InputError","stringifyEntityRef"],"mappings":";;;;;;;AAuBA,MAAM,EAAA,GAAK,kBAAA;AAMJ,SAAS,4BAA4B,OAAA,EAGzC;AACD,EAAA,MAAM,EAAE,OAAA,EAAS,YAAA,EAAa,GAAI,OAAA;AAElC,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA;AAAA,IACA,WAAA,EACE,+FAAA;AAAA,cACFC,0BAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CAAE,KAAA,CAAM;AAAA,QACN,EAAE,MAAA,CAAO;AAAA,UACP,cAAA,E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,UAAA,MAAM,CAAA;AAAA,QACR;AAAA,MACF;AAEA,MAAA,GAAA,CAAI,MAAA,CAAO,kBAAkB,cAAc,CAAA;AAAA,IAC7C;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/catalog/register.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Register with the catalog',\n example: yaml.stringify({\n steps: [\n {\n action: 'catalog:register',\n id: 'register-with-catalog',\n name: 'Register with the catalog',\n input: {\n catalogInfoUrl:\n 'http://github.com/backstage/backstage/blob/master/catalog-info.yaml',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,2BAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,kBAAA;AAAA,UACR,EAAA,EAAI,uBAAA;AAAA,UACJ,IAAA,EAAM,2BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,cAAA,EACE;AAAA;AACJ;AACF;AACF,KACD;AAAA;AAEL
|
|
1
|
+
{"version":3,"file":"register.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/catalog/register.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Register with the catalog',\n example: yaml.stringify({\n steps: [\n {\n action: 'catalog:register',\n id: 'register-with-catalog',\n name: 'Register with the catalog',\n input: {\n catalogInfoUrl:\n 'http://github.com/backstage/backstage/blob/master/catalog-info.yaml',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,2BAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,kBAAA;AAAA,UACR,EAAA,EAAI,uBAAA;AAAA,UACJ,IAAA,EAAM,2BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,cAAA,EACE;AAAA;AACJ;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/catalog/write.ts"],"sourcesContent":["/*\n * Copyright 2021 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 fs from 'fs-extra';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport * as yaml from 'yaml';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { examples } from './write.examples';\n\nconst id = 'catalog:write';\n\n/**\n * Writes a catalog descriptor file containing the provided entity to a path in the workspace.\n * @public\n */\n\nexport function createCatalogWriteAction() {\n return createTemplateAction({\n id,\n description: 'Writes the catalog-info.yaml for your template',\n schema: {\n input: {\n filePath: z =>\n z.string().optional().describe('Defaults to catalog-info.yaml'),\n // TODO: this should reference an zod entity validator if it existed.\n entity: z =>\n z\n .record(z.any())\n .describe(\n 'You can provide the same values used in the Entity schema.',\n ),\n },\n },\n examples,\n supportsDryRun: true,\n async handler(ctx) {\n const { filePath, entity } = ctx.input;\n const entityRef = ctx.templateInfo?.entityRef;\n const path = filePath ?? 'catalog-info.yaml';\n ctx.logger.info(`Writing ${path}`);\n\n await fs.outputFile(\n resolveSafeChildPath(ctx.workspacePath, path),\n yaml.stringify({\n ...entity,\n metadata: {\n ...entity.metadata,\n ...(entityRef\n ? {\n annotations: {\n ...entity.metadata.annotations,\n 'backstage.io/source-template': entityRef,\n },\n }\n : undefined),\n },\n }),\n );\n },\n });\n}\n"],"names":["createTemplateAction","examples","fs","resolveSafeChildPath","yaml"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,EAAA,GAAK,eAAA;AAOJ,SAAS,wBAAA,GAA2B;AACzC,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA;AAAA,IACA,WAAA,EAAa,gDAAA;AAAA,IACb,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,QAAA,EAAU,OACR,CAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,+BAA+B,CAAA;AAAA;AAAA,QAEhE,QAAQ,CAAA,CAAA,KACN,CAAA,CACG,OAAO,CAAA,CAAE,GAAA,EAAK,CAAA,CACd,QAAA;AAAA,UACC;AAAA;AACF;AACN,KACF;AAAA,cACAC,uBAAA;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,MAAM,EAAE,QAAA,EAAU,MAAA,EAAO,GAAI,GAAA,CAAI,KAAA;AACjC,MAAA,MAAM,SAAA,GAAY,IAAI,YAAA,EAAc,SAAA;AACpC,MAAA,MAAM,OAAO,QAAA,IAAY,mBAAA;AACzB,MAAA,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,CAAA,QAAA,EAAW,IAAI,CAAA,CAAE,CAAA;AAEjC,MAAA,MAAMC,mBAAA,CAAG,UAAA;AAAA,QACPC,qCAAA,CAAqB,GAAA,CAAI,aAAA,EAAe,IAAI,CAAA;AAAA,QAC5CC,gBAAK,SAAA,CAAU;AAAA,UACb,GAAG,MAAA;AAAA,UACH,QAAA,EAAU;AAAA,YACR,GAAG,MAAA,CAAO,QAAA;AAAA,YACV,GAAI,SAAA,GACA;AAAA,cACE,WAAA,EAAa;AAAA,gBACX,GAAG,OAAO,QAAA,CAAS,WAAA;AAAA,gBACnB,8BAAA,EAAgC;AAAA;AAClC,aACF,GACA;AAAA;AACN,SACD;AAAA,OACH;AAAA,IACF;AAAA,GACD,CAAA;AACH
|
|
1
|
+
{"version":3,"file":"write.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/catalog/write.ts"],"sourcesContent":["/*\n * Copyright 2021 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 fs from 'fs-extra';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport * as yaml from 'yaml';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { examples } from './write.examples';\n\nconst id = 'catalog:write';\n\n/**\n * Writes a catalog descriptor file containing the provided entity to a path in the workspace.\n * @public\n */\n\nexport function createCatalogWriteAction() {\n return createTemplateAction({\n id,\n description: 'Writes the catalog-info.yaml for your template',\n schema: {\n input: {\n filePath: z =>\n z.string().optional().describe('Defaults to catalog-info.yaml'),\n // TODO: this should reference an zod entity validator if it existed.\n entity: z =>\n z\n .record(z.any())\n .describe(\n 'You can provide the same values used in the Entity schema.',\n ),\n },\n },\n examples,\n supportsDryRun: true,\n async handler(ctx) {\n const { filePath, entity } = ctx.input;\n const entityRef = ctx.templateInfo?.entityRef;\n const path = filePath ?? 'catalog-info.yaml';\n ctx.logger.info(`Writing ${path}`);\n\n await fs.outputFile(\n resolveSafeChildPath(ctx.workspacePath, path),\n yaml.stringify({\n ...entity,\n metadata: {\n ...entity.metadata,\n ...(entityRef\n ? {\n annotations: {\n ...entity.metadata.annotations,\n 'backstage.io/source-template': entityRef,\n },\n }\n : undefined),\n },\n }),\n );\n },\n });\n}\n"],"names":["createTemplateAction","examples","fs","resolveSafeChildPath","yaml"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,EAAA,GAAK,eAAA;AAOJ,SAAS,wBAAA,GAA2B;AACzC,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA;AAAA,IACA,WAAA,EAAa,gDAAA;AAAA,IACb,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,QAAA,EAAU,OACR,CAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,+BAA+B,CAAA;AAAA;AAAA,QAEhE,QAAQ,CAAA,CAAA,KACN,CAAA,CACG,OAAO,CAAA,CAAE,GAAA,EAAK,CAAA,CACd,QAAA;AAAA,UACC;AAAA;AACF;AACN,KACF;AAAA,cACAC,uBAAA;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,MAAM,EAAE,QAAA,EAAU,MAAA,EAAO,GAAI,GAAA,CAAI,KAAA;AACjC,MAAA,MAAM,SAAA,GAAY,IAAI,YAAA,EAAc,SAAA;AACpC,MAAA,MAAM,OAAO,QAAA,IAAY,mBAAA;AACzB,MAAA,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,CAAA,QAAA,EAAW,IAAI,CAAA,CAAE,CAAA;AAEjC,MAAA,MAAMC,mBAAA,CAAG,UAAA;AAAA,QACPC,qCAAA,CAAqB,GAAA,CAAI,aAAA,EAAe,IAAI,CAAA;AAAA,QAC5CC,gBAAK,SAAA,CAAU;AAAA,UACb,GAAG,MAAA;AAAA,UACH,QAAA,EAAU;AAAA,YACR,GAAG,MAAA,CAAO,QAAA;AAAA,YACV,GAAI,SAAA,GACA;AAAA,cACE,WAAA,EAAa;AAAA,gBACX,GAAG,OAAO,QAAA,CAAS,WAAA;AAAA,gBACnB,8BAAA,EAAgC;AAAA;AAClC,aACF,GACA;AAAA;AACN,SACD;AAAA,OACH;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/catalog/write.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport * as yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Write a catalog yaml file',\n example: yaml.stringify({\n steps: [\n {\n action: 'catalog:write',\n id: 'create-catalog-info-file',\n name: 'Create catalog file',\n input: {\n entity: {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'Component',\n metadata: {\n name: 'test',\n annotations: {},\n },\n spec: {\n type: 'service',\n lifecycle: 'production',\n owner: 'default/owner',\n },\n },\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,2BAAA;AAAA,IACb,OAAA,EAASA,gBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,eAAA;AAAA,UACR,EAAA,EAAI,0BAAA;AAAA,UACJ,IAAA,EAAM,qBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,MAAA,EAAQ;AAAA,cACN,UAAA,EAAY,uBAAA;AAAA,cACZ,IAAA,EAAM,WAAA;AAAA,cACN,QAAA,EAAU;AAAA,gBACR,IAAA,EAAM,MAAA;AAAA,gBACN,aAAa;AAAC,eAChB;AAAA,cACA,IAAA,EAAM;AAAA,gBACJ,IAAA,EAAM,SAAA;AAAA,gBACN,SAAA,EAAW,YAAA;AAAA,gBACX,KAAA,EAAO;AAAA;AACT;AACF;AACF;AACF;AACF,KACD;AAAA;AAEL
|
|
1
|
+
{"version":3,"file":"write.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/catalog/write.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport * as yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Write a catalog yaml file',\n example: yaml.stringify({\n steps: [\n {\n action: 'catalog:write',\n id: 'create-catalog-info-file',\n name: 'Create catalog file',\n input: {\n entity: {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'Component',\n metadata: {\n name: 'test',\n annotations: {},\n },\n spec: {\n type: 'service',\n lifecycle: 'production',\n owner: 'default/owner',\n },\n },\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,2BAAA;AAAA,IACb,OAAA,EAASA,gBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,eAAA;AAAA,UACR,EAAA,EAAI,0BAAA;AAAA,UACJ,IAAA,EAAM,qBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,MAAA,EAAQ;AAAA,cACN,UAAA,EAAY,uBAAA;AAAA,cACZ,IAAA,EAAM,WAAA;AAAA,cACN,QAAA,EAAU;AAAA,gBACR,IAAA,EAAM,MAAA;AAAA,gBACN,aAAa;AAAC,eAChB;AAAA,cACA,IAAA,EAAM;AAAA,gBACJ,IAAA,EAAM,SAAA;AAAA,gBACN,SAAA,EAAW,YAAA;AAAA,gBACX,KAAA,EAAO;AAAA;AACT;AACF;AACF;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/debug/log.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { readdir, stat } from 'fs-extra';\nimport { join, relative } from 'node:path';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { examples } from './log.examples';\nimport fs from 'node:fs';\n\nconst id = 'debug:log';\n\n/**\n * Writes a message into the log or lists all files in the workspace\n *\n * @remarks\n *\n * This task is useful for local development and testing of both the scaffolder\n * and scaffolder templates.\n *\n * @public\n */\nexport function createDebugLogAction() {\n return createTemplateAction({\n id,\n description:\n 'Writes a message into the log and/or lists all files in the workspace.',\n examples,\n schema: {\n input: {\n message: z =>\n z.string({ description: 'Message to output.' }).optional(),\n listWorkspace: z =>\n z\n .union([z.boolean(), z.enum(['with-filenames', 'with-contents'])], {\n description:\n 'List all files in the workspace. If used with \"with-contents\", also the file contents are listed.',\n })\n .optional(),\n },\n },\n supportsDryRun: true,\n async handler(ctx) {\n ctx.logger.info(JSON.stringify(ctx.input, null, 2));\n\n if (ctx.input?.message) {\n ctx.logger.info(ctx.input.message);\n }\n\n if (ctx.input?.listWorkspace) {\n const files = await recursiveReadDir(ctx.workspacePath);\n ctx.logger.info(\n `Workspace:\\n${files\n .map(f => {\n const relativePath = relative(ctx.workspacePath, f);\n if (ctx.input?.listWorkspace === 'with-contents') {\n try {\n const safePath = resolveSafeChildPath(\n ctx.workspacePath,\n relativePath,\n );\n const content = fs.readFileSync(safePath, 'utf-8');\n return ` - ${relativePath}:\\n\\n ${content}`;\n } catch {\n return ` - ${relativePath}: [skipped]`;\n }\n }\n return ` - ${relativePath}`;\n })\n .join('\\n')}`,\n );\n }\n },\n });\n}\n\nexport async function recursiveReadDir(dir: string): Promise<string[]> {\n const subdirs = await readdir(dir);\n const files = await Promise.all(\n subdirs.map(async subdir => {\n const res = join(dir, subdir);\n return (await stat(res)).isDirectory() ? recursiveReadDir(res) : [res];\n }),\n );\n return files.reduce((a, f) => a.concat(f), []);\n}\n"],"names":["createTemplateAction","examples","relative","resolveSafeChildPath","fs","readdir","join","stat"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,EAAA,GAAK,WAAA;AAYJ,SAAS,oBAAA,GAAuB;AACrC,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA;AAAA,IACA,WAAA,EACE,wEAAA;AAAA,cACFC,qBAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,OACP,CAAA,CAAE,MAAA,CAAO,EAAE,WAAA,EAAa,oBAAA,EAAsB,CAAA,CAAE,QAAA,EAAS;AAAA,QAC3D,aAAA,EAAe,CAAA,CAAA,KACb,CAAA,CACG,KAAA,CAAM,CAAC,CAAA,CAAE,OAAA,EAAQ,EAAG,CAAA,CAAE,KAAK,CAAC,gBAAA,EAAkB,eAAe,CAAC,CAAC,CAAA,EAAG;AAAA,UACjE,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,GAAA,CAAI,MAAA,CAAO,KAAK,IAAA,CAAK,SAAA,CAAU,IAAI,KAAA,EAAO,IAAA,EAAM,CAAC,CAAC,CAAA;AAElD,MAAA,IAAI,GAAA,CAAI,OAAO,OAAA,EAAS;AACtB,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,GAAA,CAAI,KAAA,CAAM,OAAO,CAAA;AAAA,MACnC;AAEA,MAAA,IAAI,GAAA,CAAI,OAAO,aAAA,EAAe;AAC5B,QAAA,MAAM,KAAA,GAAQ,MAAM,gBAAA,CA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C;AAAA,GACH;AACA,EAAA,OAAO,KAAA,CAAM,MAAA,CAAO,CAAC,CAAA,EAAG,CAAA,KAAM,EAAE,MAAA,CAAO,CAAC,CAAA,EAAG,EAAE,CAAA;AAC/C
|
|
1
|
+
{"version":3,"file":"log.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/debug/log.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { readdir, stat } from 'fs-extra';\nimport { join, relative } from 'node:path';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { examples } from './log.examples';\nimport fs from 'node:fs';\n\nconst id = 'debug:log';\n\n/**\n * Writes a message into the log or lists all files in the workspace\n *\n * @remarks\n *\n * This task is useful for local development and testing of both the scaffolder\n * and scaffolder templates.\n *\n * @public\n */\nexport function createDebugLogAction() {\n return createTemplateAction({\n id,\n description:\n 'Writes a message into the log and/or lists all files in the workspace.',\n examples,\n schema: {\n input: {\n message: z =>\n z.string({ description: 'Message to output.' }).optional(),\n listWorkspace: z =>\n z\n .union([z.boolean(), z.enum(['with-filenames', 'with-contents'])], {\n description:\n 'List all files in the workspace. If used with \"with-contents\", also the file contents are listed.',\n })\n .optional(),\n },\n },\n supportsDryRun: true,\n async handler(ctx) {\n ctx.logger.info(JSON.stringify(ctx.input, null, 2));\n\n if (ctx.input?.message) {\n ctx.logger.info(ctx.input.message);\n }\n\n if (ctx.input?.listWorkspace) {\n const files = await recursiveReadDir(ctx.workspacePath);\n ctx.logger.info(\n `Workspace:\\n${files\n .map(f => {\n const relativePath = relative(ctx.workspacePath, f);\n if (ctx.input?.listWorkspace === 'with-contents') {\n try {\n const safePath = resolveSafeChildPath(\n ctx.workspacePath,\n relativePath,\n );\n const content = fs.readFileSync(safePath, 'utf-8');\n return ` - ${relativePath}:\\n\\n ${content}`;\n } catch {\n return ` - ${relativePath}: [skipped]`;\n }\n }\n return ` - ${relativePath}`;\n })\n .join('\\n')}`,\n );\n }\n },\n });\n}\n\nexport async function recursiveReadDir(dir: string): Promise<string[]> {\n const subdirs = await readdir(dir);\n const files = await Promise.all(\n subdirs.map(async subdir => {\n const res = join(dir, subdir);\n return (await stat(res)).isDirectory() ? recursiveReadDir(res) : [res];\n }),\n );\n return files.reduce((a, f) => a.concat(f), []);\n}\n"],"names":["createTemplateAction","examples","relative","resolveSafeChildPath","fs","readdir","join","stat"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,EAAA,GAAK,WAAA;AAYJ,SAAS,oBAAA,GAAuB;AACrC,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA;AAAA,IACA,WAAA,EACE,wEAAA;AAAA,cACFC,qBAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,OACP,CAAA,CAAE,MAAA,CAAO,EAAE,WAAA,EAAa,oBAAA,EAAsB,CAAA,CAAE,QAAA,EAAS;AAAA,QAC3D,aAAA,EAAe,CAAA,CAAA,KACb,CAAA,CACG,KAAA,CAAM,CAAC,CAAA,CAAE,OAAA,EAAQ,EAAG,CAAA,CAAE,KAAK,CAAC,gBAAA,EAAkB,eAAe,CAAC,CAAC,CAAA,EAAG;AAAA,UACjE,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,GAAA,CAAI,MAAA,CAAO,KAAK,IAAA,CAAK,SAAA,CAAU,IAAI,KAA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AQ,GAAA;AAAA,IAC1B,OAAA,CAAQ,GAAA,CAAI,OAAM,MAAA,KAAU;AAC1B,MAAA,MAAM,GAAA,GAAMC,SAAA,CAAK,GAAA,EAAK,MAAM,CAAA;AAC5B,MAAA,OAAA,CAAQ,MAAMC,SAAA,CAAK,GAAG,CAAA,EAAG,WAAA,KAAgB,gBAAA,CAAiB,GAAG,CAAA,GAAI,CAAC,GAAG,CAAA;AAAA,IACvE,CAAC;AAAA,GACH;AACA,EAAA,OAAO,KAAA,CAAM,MAAA,CAAO,CAAC,CAAA,EAAG,CAAA,KAAM,EAAE,MAAA,CAAO,CAAC,CAAA,EAAG,EAAE,CAAA;AAC/C;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/debug/log.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Write a debug message',\n example: yaml.stringify({\n steps: [\n {\n action: 'debug:log',\n id: 'write-debug-line',\n name: 'Write \"Hello Backstage!\" log line',\n input: {\n message: 'Hello Backstage!',\n },\n },\n ],\n }),\n },\n {\n description: 'List the workspace directory',\n example: yaml.stringify({\n steps: [\n {\n action: 'debug:log',\n id: 'write-workspace-directory',\n name: 'List the workspace directory',\n input: {\n listWorkspace: true,\n },\n },\n ],\n }),\n },\n {\n description: 'List the workspace directory with file contents',\n example: yaml.stringify({\n steps: [\n {\n action: 'debug:log',\n id: 'write-workspace-directory',\n name: 'List the workspace directory with file contents',\n input: {\n listWorkspace: 'with-contents',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,uBAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,WAAA;AAAA,UACR,EAAA,EAAI,kBAAA;AAAA,UACJ,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,8BAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,WAAA;AAAA,UACR,EAAA,EAAI,2BAAA;AAAA,UACJ,IAAA,EAAM,8BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,aAAA,EAAe;AAAA;AACjB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,iDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,WAAA;AAAA,UACR,EAAA,EAAI,2BAAA;AAAA,UACJ,IAAA,EAAM,iDAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,aAAA,EAAe;AAAA;AACjB;AACF;AACF,KACD;AAAA;AAEL
|
|
1
|
+
{"version":3,"file":"log.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/debug/log.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Write a debug message',\n example: yaml.stringify({\n steps: [\n {\n action: 'debug:log',\n id: 'write-debug-line',\n name: 'Write \"Hello Backstage!\" log line',\n input: {\n message: 'Hello Backstage!',\n },\n },\n ],\n }),\n },\n {\n description: 'List the workspace directory',\n example: yaml.stringify({\n steps: [\n {\n action: 'debug:log',\n id: 'write-workspace-directory',\n name: 'List the workspace directory',\n input: {\n listWorkspace: true,\n },\n },\n ],\n }),\n },\n {\n description: 'List the workspace directory with file contents',\n example: yaml.stringify({\n steps: [\n {\n action: 'debug:log',\n id: 'write-workspace-directory',\n name: 'List the workspace directory with file contents',\n input: {\n listWorkspace: 'with-contents',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,uBAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,WAAA;AAAA,UACR,EAAA,EAAI,kBAAA;AAAA,UACJ,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,8BAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,WAAA;AAAA,UACR,EAAA,EAAI,2BAAA;AAAA,UACJ,IAAA,EAAM,8BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,aAAA,EAAe;AAAA;AACjB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,iDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,WAAA;AAAA,UACR,EAAA,EAAI,2BAAA;AAAA,UACJ,IAAA,EAAM,iDAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,aAAA,EAAe;AAAA;AACjB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/debug/wait.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { HumanDuration } from '@backstage/types';\nimport { Duration } from 'luxon';\nimport { examples } from './wait.examples';\n\nconst id = 'debug:wait';\n\nconst MAX_WAIT_TIME_IN_ISO = 'T00:10:00';\n\n/**\n * Waits for a certain period of time.\n *\n * @remarks\n *\n * This task is useful to give some waiting time for manual intervention.\n * Has to be used in a combination with other actions.\n *\n * @public\n */\nexport function createWaitAction(options?: {\n maxWaitTime?: Duration | HumanDuration;\n}) {\n const toDuration = (\n maxWaitTime: Duration | HumanDuration | undefined,\n ): Duration => {\n if (maxWaitTime) {\n if (maxWaitTime instanceof Duration) {\n return maxWaitTime;\n }\n return Duration.fromObject(maxWaitTime);\n }\n return Duration.fromISOTime(MAX_WAIT_TIME_IN_ISO);\n };\n\n return createTemplateAction({\n id,\n description: 'Waits for a certain period of time.',\n examples,\n schema: {\n input: {\n minutes: z =>\n z\n .number({\n description: 'Waiting period in minutes.',\n })\n .optional(),\n seconds: z =>\n z\n .number({\n description: 'Waiting period in seconds.',\n })\n .optional(),\n milliseconds: z =>\n z\n .number({\n description: 'Waiting period in milliseconds.',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const delayTime = Duration.fromObject(ctx.input);\n const maxWait = toDuration(options?.maxWaitTime);\n\n if (delayTime.minus(maxWait).toMillis() > 0) {\n throw new Error(\n `Waiting duration is longer than the maximum threshold of ${maxWait.toHuman()}`,\n );\n }\n\n await new Promise<void>(resolve => {\n const timeoutHandle = setTimeout(abort, delayTime.toMillis());\n ctx.signal?.addEventListener('abort', abort);\n\n function abort() {\n ctx.signal?.removeEventListener('abort', abort);\n clearTimeout(timeoutHandle);\n resolve();\n }\n });\n },\n });\n}\n"],"names":["Duration","createTemplateAction","examples"],"mappings":";;;;;;AAqBA,MAAM,EAAA,GAAK,YAAA;AAEX,MAAM,oBAAA,GAAuB,WAAA;AAYtB,SAAS,iBAAiB,OAAA,EAE9B;AACD,EAAA,MAAM,UAAA,GAAa,CACjB,WAAA,KACa;AACb,IAAA,IAAI,WAAA,EAAa;AACf,MAAA,IAAI,uBAAuBA,cAAA,EAAU;AACnC,QAAA,OAAO,WAAA;AAAA,MACT;AACA,MAAA,OAAOA,cAAA,CAAS,WAAW,WAAW,CAAA;AAAA,IACxC;AACA,IAAA,OAAOA,cAAA,CAAS,YAAY,oBAAoB,CAAA;AAAA,EAClD,CAAA;AAEA,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA;AAAA,IACA,WAAA,EAAa,qCAAA;AAAA,cACbC,sBAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA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Copyright 2021 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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { HumanDuration } from '@backstage/types';\nimport { Duration } from 'luxon';\nimport { examples } from './wait.examples';\n\nconst id = 'debug:wait';\n\nconst MAX_WAIT_TIME_IN_ISO = 'T00:10:00';\n\n/**\n * Waits for a certain period of time.\n *\n * @remarks\n *\n * This task is useful to give some waiting time for manual intervention.\n * Has to be used in a combination with other actions.\n *\n * @public\n */\nexport function createWaitAction(options?: {\n maxWaitTime?: Duration | HumanDuration;\n}) {\n const toDuration = (\n maxWaitTime: Duration | HumanDuration | undefined,\n ): Duration => {\n if (maxWaitTime) {\n if (maxWaitTime instanceof Duration) {\n return maxWaitTime;\n }\n return Duration.fromObject(maxWaitTime);\n }\n return Duration.fromISOTime(MAX_WAIT_TIME_IN_ISO);\n };\n\n return createTemplateAction({\n id,\n description: 'Waits for a certain period of time.',\n examples,\n schema: {\n input: {\n minutes: z =>\n z\n .number({\n description: 'Waiting period in minutes.',\n })\n .optional(),\n seconds: z =>\n z\n .number({\n description: 'Waiting period in seconds.',\n })\n .optional(),\n milliseconds: z =>\n z\n .number({\n description: 'Waiting period in milliseconds.',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const delayTime = Duration.fromObject(ctx.input);\n const maxWait = toDuration(options?.maxWaitTime);\n\n if (delayTime.minus(maxWait).toMillis() > 0) {\n throw new Error(\n `Waiting duration is longer than the maximum threshold of ${maxWait.toHuman()}`,\n );\n }\n\n await new Promise<void>(resolve => {\n const timeoutHandle = setTimeout(abort, delayTime.toMillis());\n ctx.signal?.addEventListener('abort', abort);\n\n function abort() {\n ctx.signal?.removeEventListener('abort', abort);\n clearTimeout(timeoutHandle);\n resolve();\n }\n });\n },\n });\n}\n"],"names":["Duration","createTemplateAction","examples"],"mappings":";;;;;;AAqBA,MAAM,EAAA,GAAK,YAAA;AAEX,MAAM,oBAAA,GAAuB,WAAA;AAYtB,SAAS,iBAAiB,OAAA,EAE9B;AACD,EAAA,MAAM,UAAA,GAAa,CACjB,WAAA,KACa;AACb,IAAA,IAAI,WAAA,EAAa;AACf,MAAA,IAAI,uBAAuBA,cAAA,EAAU;AACnC,QAAA,OAAO,WAAA;AAAA,MACT;AACA,MAAA,OAAOA,cAAA,CAAS,WAAW,WAAW,CAAA;AAAA,IACxC;AACA,IAAA,OAAOA,cAAA,CAAS,YAAY,oBAAoB,CAAA;AAAA,EAClD,CAAA;AAEA,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA;AAAA,IACA,WAAA,EAAa,qCAAA;AAAA,cACbC,sBAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,YAAA,EAAc,CAAA,CAAA,KACZ,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,MAAM,SAAA,GAAYF,cAAA,CAAS,UAAA,CAAW,GAAA,CAAI,KAAK,CAAA;AAC/C,MAAA,MAAM,OAAA,GAAU,UAAA,CAAW,OAAA,EAAS,WAAW,CAAA;AAE/C,MAAA,IAAI,UAAU,KAAA,CAAM,OAAO,CAAA,CAAE,QAAA,KAAa,CAAA,EAAG;AAC3C,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,CAAA,yDAAA,EAA4D,OAAA,CAAQ,OAAA,EAAS,CAAA;AAAA,SAC/E;AAAA,MACF;AAEA,MAAA,MAAM,IAAI,QAAc,CAAA,OAAA,KAAW;AACjC,QAAA,MAAM,aAAA,GAAgB,UAAA,CAAW,KAAA,EAAO,SAAA,CAAU,UAAU,CAAA;AAC5D,QAAA,GAAA,CAAI,MAAA,EAAQ,gBAAA,CAAiB,OAAA,EAAS,KAAK,CAAA;AAE3C,QAAA,SAAS,KAAA,GAAQ;AACf,UAAA,GAAA,CAAI,MAAA,EAAQ,mBAAA,CAAoB,OAAA,EAAS,KAAK,CAAA;AAC9C,UAAA,YAAA,CAAa,aAAa,CAAA;AAC1B,UAAA,OAAA,EAAQ;AAAA,QACV;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/debug/wait.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Waiting for 50 milliseconds',\n example: yaml.stringify({\n steps: [\n {\n action: 'debug:wait',\n id: 'wait-milliseconds',\n name: 'Waiting for 50 milliseconds',\n input: {\n milliseconds: 50,\n },\n },\n ],\n }),\n },\n {\n description: 'Waiting for 5 seconds',\n example: yaml.stringify({\n steps: [\n {\n action: 'debug:wait',\n id: 'wait-5sec',\n name: 'Waiting for 5 seconds',\n input: {\n seconds: 5,\n },\n },\n ],\n }),\n },\n {\n description: 'Waiting for 1 minutes',\n example: yaml.stringify({\n steps: [\n {\n action: 'debug:wait',\n id: 'wait-1min',\n name: 'Waiting for 1 minutes',\n input: {\n minutes: 1,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,6BAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,YAAA;AAAA,UACR,EAAA,EAAI,mBAAA;AAAA,UACJ,IAAA,EAAM,6BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,YAAA,EAAc;AAAA;AAChB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,uBAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,YAAA;AAAA,UACR,EAAA,EAAI,WAAA;AAAA,UACJ,IAAA,EAAM,uBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,uBAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,YAAA;AAAA,UACR,EAAA,EAAI,WAAA;AAAA,UACJ,IAAA,EAAM,uBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA;AAEL
|
|
1
|
+
{"version":3,"file":"wait.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/debug/wait.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Waiting for 50 milliseconds',\n example: yaml.stringify({\n steps: [\n {\n action: 'debug:wait',\n id: 'wait-milliseconds',\n name: 'Waiting for 50 milliseconds',\n input: {\n milliseconds: 50,\n },\n },\n ],\n }),\n },\n {\n description: 'Waiting for 5 seconds',\n example: yaml.stringify({\n steps: [\n {\n action: 'debug:wait',\n id: 'wait-5sec',\n name: 'Waiting for 5 seconds',\n input: {\n seconds: 5,\n },\n },\n ],\n }),\n },\n {\n description: 'Waiting for 1 minutes',\n example: yaml.stringify({\n steps: [\n {\n action: 'debug:wait',\n id: 'wait-1min',\n name: 'Waiting for 1 minutes',\n input: {\n minutes: 1,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,6BAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,YAAA;AAAA,UACR,EAAA,EAAI,mBAAA;AAAA,UACJ,IAAA,EAAM,6BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,YAAA,EAAc;AAAA;AAChB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,uBAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,YAAA;AAAA,UACR,EAAA,EAAI,WAAA;AAAA,UACJ,IAAA,EAAM,uBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,uBAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,YAAA;AAAA,UACR,EAAA,EAAI,WAAA;AAAA,UACJ,IAAA,EAAM,uBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertScmUserCredentials.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/assertScmUserCredentials.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { InputError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\n\nconst USER_TOKEN_SUPPORTED_INTEGRATION_TYPES = new Set(['github', 'gitlab']);\n\nexport function assertScmUserCredentials(options: {\n integrations: ScmIntegrations;\n requireScmUserCredentials?: boolean;\n url: string;\n baseUrl?: string;\n token?: string;\n}) {\n const { integrations, requireScmUserCredentials, url, baseUrl, token } =\n options;\n\n if (!requireScmUserCredentials || token) {\n return;\n }\n\n let sourceUrl: URL | undefined;\n try {\n sourceUrl = new URL(url);\n } catch {\n if (baseUrl) {\n try {\n sourceUrl = new URL(baseUrl);\n } catch {\n // Invalid URLs are reported by the fetch helpers.\n }\n }\n }\n\n if (!sourceUrl) {\n return;\n }\n\n const integration = integrations.byUrl(sourceUrl);\n if (\n integration &&\n USER_TOKEN_SUPPORTED_INTEGRATION_TYPES.has(integration.type)\n ) {\n throw new InputError(\n `No user credentials provided for host ${sourceUrl.host}, but scaffolder.requireScmUserCredentials is enabled`,\n );\n }\n}\n"],"names":["InputError"],"mappings":";;;;AAmBA,MAAM,yDAAyC,IAAI,GAAA,CAAI,CAAC,QAAA,EAAU,QAAQ,CAAC,CAAA;AAEpE,SAAS,yBAAyB,OAAA,EAMtC;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA2B,GAAA,EAAK,OAAA,EAAS,OAAM,GACnE,OAAA;AAEF,EAAA,IAAI,CAAC,6BAA6B,KAAA,EAAO;AACvC,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,SAAA;AACJ,EAAA,IAAI;AACF,IAAA,SAAA,GAAY,IAAI,IAAI,GAAG,CAAA;AAAA,EACzB,CAAA,CAAA,MAAQ;AACN,IAAA,IAAI,OAAA,EAAS;AACX,MAAA,IAAI;AACF,QAAA,SAAA,GAAY,IAAI,IAAI,OAAO,CAAA;AAAA,MAC7B,CAAA,CAAA,MAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF;AAEA,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,WAAA,GAAc,YAAA,CAAa,KAAA,CAAM,SAAS,CAAA;AAChD,EAAA,IACE,WAAA,IACA,sCAAA,CAAuC,GAAA,CAAI,WAAA,CAAY,IAAI,CAAA,EAC3D;AACA,IAAA,MAAM,IAAIA,iBAAA;AAAA,MACR,CAAA,sCAAA,EAAyC,UAAU,IAAI,CAAA,qDAAA;AAAA,KACzD;AAAA,EACF;AACF
|
|
1
|
+
{"version":3,"file":"assertScmUserCredentials.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/assertScmUserCredentials.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { InputError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\n\nconst USER_TOKEN_SUPPORTED_INTEGRATION_TYPES = new Set(['github', 'gitlab']);\n\nexport function assertScmUserCredentials(options: {\n integrations: ScmIntegrations;\n requireScmUserCredentials?: boolean;\n url: string;\n baseUrl?: string;\n token?: string;\n}) {\n const { integrations, requireScmUserCredentials, url, baseUrl, token } =\n options;\n\n if (!requireScmUserCredentials || token) {\n return;\n }\n\n let sourceUrl: URL | undefined;\n try {\n sourceUrl = new URL(url);\n } catch {\n if (baseUrl) {\n try {\n sourceUrl = new URL(baseUrl);\n } catch {\n // Invalid URLs are reported by the fetch helpers.\n }\n }\n }\n\n if (!sourceUrl) {\n return;\n }\n\n const integration = integrations.byUrl(sourceUrl);\n if (\n integration &&\n USER_TOKEN_SUPPORTED_INTEGRATION_TYPES.has(integration.type)\n ) {\n throw new InputError(\n `No user credentials provided for host ${sourceUrl.host}, but scaffolder.requireScmUserCredentials is enabled`,\n );\n }\n}\n"],"names":["InputError"],"mappings":";;;;AAmBA,MAAM,yDAAyC,IAAI,GAAA,CAAI,CAAC,QAAA,EAAU,QAAQ,CAAC,CAAA;AAEpE,SAAS,yBAAyB,OAAA,EAMtC;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA2B,GAAA,EAAK,OAAA,EAAS,OAAM,GACnE,OAAA;AAEF,EAAA,IAAI,CAAC,6BAA6B,KAAA,EAAO;AACvC,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,SAAA;AACJ,EAAA,IAAI;AACF,IAAA,SAAA,GAAY,IAAI,IAAI,GAAG,CAAA;AAAA,EACzB,CAAA,CAAA,MAAQ;AACN,IAAA,IAAI,OAAA,EAAS;AACX,MAAA,IAAI;AACF,QAAA,SAAA,GAAY,IAAI,IAAI,OAAO,CAAA;AAAA,MAC7B,CAAA,CAAA,MAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF;AAEA,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,WAAA,GAAc,YAAA,CAAa,KAAA,CAAM,SAAS,CAAA;AAChD,EAAA,IACE,WAAA,IACA,sCAAA,CAAuC,GAAA,CAAI,WAAA,CAAY,IAAI,CAAA,EAC3D;AACA,IAAA,MAAM,IAAIA,iBAAA;AAAA,MACR,CAAA,sCAAA,EAAyC,UAAU,IAAI,CAAA,qDAAA;AAAA,KACzD;AAAA,EACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plain.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/plain.ts"],"sourcesContent":["/*\n * Copyright 2021 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 resolveSafeChildPath,\n UrlReaderService,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { examples } from './plain.examples';\nimport { assertScmUserCredentials } from './assertScmUserCredentials';\n\nimport {\n createTemplateAction,\n fetchContents,\n} from '@backstage/plugin-scaffolder-node';\n\nexport const ACTION_ID = 'fetch:plain';\n\n/**\n * Downloads content and places it in the workspace, or optionally\n * in a subdirectory specified by the 'targetPath' input option.\n * @public\n */\nexport function createFetchPlainAction(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n requireScmUserCredentials?: boolean;\n}) {\n const { reader, integrations, requireScmUserCredentials } = options;\n\n return createTemplateAction({\n id: ACTION_ID,\n examples,\n description:\n 'Downloads content and places it in the workspace, or optionally in a subdirectory specified by the `targetPath` input option.',\n schema: {\n input: {\n url: z =>\n z.string({\n description:\n 'Relative path or absolute URL pointing to the directory tree to fetch',\n }),\n targetPath: z =>\n z\n .string({\n description:\n 'Target path within the working directory to download the contents to.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'An optional token to use for authentication when reading the resources.',\n })\n .optional(),\n },\n },\n supportsDryRun: true,\n async handler(ctx) {\n ctx.logger.info('Fetching plain content from remote URL');\n\n // Finally move the template result into the task workspace\n const targetPath = ctx.input.targetPath ?? './';\n const outputPath = resolveSafeChildPath(ctx.workspacePath, targetPath);\n\n assertScmUserCredentials({\n integrations,\n requireScmUserCredentials,\n url: ctx.input.url,\n baseUrl: ctx.templateInfo?.baseUrl,\n token: ctx.input.token,\n });\n\n await fetchContents({\n reader,\n integrations,\n baseUrl: ctx.templateInfo?.baseUrl,\n fetchUrl: ctx.input.url,\n outputPath,\n token: ctx.input.token,\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","resolveSafeChildPath","assertScmUserCredentials","fetchContents"],"mappings":";;;;;;;AA6BO,MAAM,SAAA,GAAY;AAOlB,SAAS,uBAAuB,OAAA,EAIpC;AACD,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAE5D,EAAA,OAAOA,yC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ACD,CAAA;AACH
|
|
1
|
+
{"version":3,"file":"plain.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/plain.ts"],"sourcesContent":["/*\n * Copyright 2021 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 resolveSafeChildPath,\n UrlReaderService,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { examples } from './plain.examples';\nimport { assertScmUserCredentials } from './assertScmUserCredentials';\n\nimport {\n createTemplateAction,\n fetchContents,\n} from '@backstage/plugin-scaffolder-node';\n\nexport const ACTION_ID = 'fetch:plain';\n\n/**\n * Downloads content and places it in the workspace, or optionally\n * in a subdirectory specified by the 'targetPath' input option.\n * @public\n */\nexport function createFetchPlainAction(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n requireScmUserCredentials?: boolean;\n}) {\n const { reader, integrations, requireScmUserCredentials } = options;\n\n return createTemplateAction({\n id: ACTION_ID,\n examples,\n description:\n 'Downloads content and places it in the workspace, or optionally in a subdirectory specified by the `targetPath` input option.',\n schema: {\n input: {\n url: z =>\n z.string({\n description:\n 'Relative path or absolute URL pointing to the directory tree to fetch',\n }),\n targetPath: z =>\n z\n .string({\n description:\n 'Target path within the working directory to download the contents to.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'An optional token to use for authentication when reading the resources.',\n })\n .optional(),\n },\n },\n supportsDryRun: true,\n async handler(ctx) {\n ctx.logger.info('Fetching plain content from remote URL');\n\n // Finally move the template result into the task workspace\n const targetPath = ctx.input.targetPath ?? './';\n const outputPath = resolveSafeChildPath(ctx.workspacePath, targetPath);\n\n assertScmUserCredentials({\n integrations,\n requireScmUserCredentials,\n url: ctx.input.url,\n baseUrl: ctx.templateInfo?.baseUrl,\n token: ctx.input.token,\n });\n\n await fetchContents({\n reader,\n integrations,\n baseUrl: ctx.templateInfo?.baseUrl,\n fetchUrl: ctx.input.url,\n outputPath,\n token: ctx.input.token,\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","resolveSafeChildPath","assertScmUserCredentials","fetchContents"],"mappings":";;;;;;;AA6BO,MAAM,SAAA,GAAY;AAOlB,SAAS,uBAAuB,OAAA,EAIpC;AACD,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAE5D,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,SAAA;AAAA,cACJC,uBAAA;AAAA,IACA,WAAA,EACE,+HAAA;AAAA,IACF,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,GAAA,EAAK,CAAA,CAAA,KACH,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,GAAA,CAAI,MAAA,CAAO,KAAK,wCAAwC,CAAA;AAGxD,MAAA,MAAM,UAAA,GAAa,GAAA,CAAI,KAAA,CAAM,UAAA,IAAc,IAAA;AAC3C,MAAA,MAAM,UAAA,GAAaC,qCAAA,CAAqB,GAAA,CAAI,aAAA,EAAe,UAAU,CAAA;AAErE,MAAAC,iDAAA,CAAyB;AAAA,QACvB,YAAA;AAAA,QACA,yBAAA;AAAA,QACA,GAAA,EAAK,IAAI,KAAA,CAAM,GAAA;AAAA,QACf,OAAA,EAAS,IAAI,YAAA,EAAc,OAAA;AAAA,QAC3B,KAAA,EAAO,IAAI,KAAA,CAAM;AAAA,OAClB,CAAA;AAED,MAAA,MAAMC,kCAAA,CAAc;AAAA,QAClB,MAAA;AAAA,QACA,YAAA;AAAA,QACA,OAAA,EAAS,IAAI,YAAA,EAAc,OAAA;AAAA,QAC3B,QAAA,EAAU,IAAI,KAAA,CAAM,GAAA;AAAA,QACpB,UAAA;AAAA,QACA,KAAA,EAAO,IAAI,KAAA,CAAM;AAAA,OAClB,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plain.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/plain.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Downloads content and places it in the workspace.',\n example: yaml.stringify({\n steps: [\n {\n action: 'fetch:plain',\n id: 'fetch-plain',\n name: 'Fetch plain',\n input: {\n url: 'https://github.com/backstage/community/tree/main/backstage-community-sessions/assets',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Optionally, if you would prefer the data to be downloaded to a subdirectory in the workspace you may specify the ‘targetPath’ input option.',\n example: yaml.stringify({\n steps: [\n {\n action: 'fetch:plain',\n id: 'fetch-plain',\n name: 'Fetch plain',\n input: {\n url: 'https://github.com/backstage/community/tree/main/backstage-community-sessions/assets',\n targetPath: 'fetched-data',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,mDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,aAAA;AAAA,UACR,EAAA,EAAI,aAAA;AAAA,UACJ,IAAA,EAAM,aAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,GAAA,EAAK;AAAA;AACP;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,uJAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,aAAA;AAAA,UACR,EAAA,EAAI,aAAA;AAAA,UACJ,IAAA,EAAM,aAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,GAAA,EAAK,sFAAA;AAAA,YACL,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA;AAEL
|
|
1
|
+
{"version":3,"file":"plain.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/plain.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Downloads content and places it in the workspace.',\n example: yaml.stringify({\n steps: [\n {\n action: 'fetch:plain',\n id: 'fetch-plain',\n name: 'Fetch plain',\n input: {\n url: 'https://github.com/backstage/community/tree/main/backstage-community-sessions/assets',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Optionally, if you would prefer the data to be downloaded to a subdirectory in the workspace you may specify the ‘targetPath’ input option.',\n example: yaml.stringify({\n steps: [\n {\n action: 'fetch:plain',\n id: 'fetch-plain',\n name: 'Fetch plain',\n input: {\n url: 'https://github.com/backstage/community/tree/main/backstage-community-sessions/assets',\n targetPath: 'fetched-data',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,mDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,aAAA;AAAA,UACR,EAAA,EAAI,aAAA;AAAA,UACJ,IAAA,EAAM,aAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,GAAA,EAAK;AAAA;AACP;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,uJAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,aAAA;AAAA,UACR,EAAA,EAAI,aAAA;AAAA,UACJ,IAAA,EAAM,aAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,GAAA,EAAK,sFAAA;AAAA,YACL,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plainFile.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/plainFile.ts"],"sourcesContent":["/*\n * Copyright 2021 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 resolveSafeChildPath,\n UrlReaderService,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { examples } from './plainFile.examples';\nimport { assertScmUserCredentials } from './assertScmUserCredentials';\n\nimport {\n createTemplateAction,\n fetchFile,\n} from '@backstage/plugin-scaffolder-node';\n\n/**\n * Downloads a single file and places it in the workspace.\n * @public\n */\nexport function createFetchPlainFileAction(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n requireScmUserCredentials?: boolean;\n}) {\n const { reader, integrations, requireScmUserCredentials } = options;\n\n return createTemplateAction({\n id: 'fetch:plain:file',\n description: 'Downloads single file and places it in the workspace.',\n examples,\n schema: {\n input: {\n url: z =>\n z.string({\n description:\n 'Relative path or absolute URL pointing to the single file to fetch.',\n }),\n targetPath: z =>\n z.string({\n description:\n 'Target path within the working directory to download the file as.',\n }),\n token: z =>\n z\n .string({\n description:\n 'An optional token to use for authentication when reading the resources.',\n })\n .optional(),\n },\n },\n supportsDryRun: true,\n async handler(ctx) {\n ctx.logger.info('Fetching plain content from remote URL');\n\n // Finally move the template result into the task workspace\n const outputPath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.targetPath,\n );\n\n assertScmUserCredentials({\n integrations,\n requireScmUserCredentials,\n url: ctx.input.url,\n baseUrl: ctx.templateInfo?.baseUrl,\n token: ctx.input.token,\n });\n\n await fetchFile({\n reader,\n integrations,\n baseUrl: ctx.templateInfo?.baseUrl,\n fetchUrl: ctx.input.url,\n outputPath,\n token: ctx.input.token,\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","resolveSafeChildPath","assertScmUserCredentials","fetchFile"],"mappings":";;;;;;;AAiCO,SAAS,2BAA2B,OAAA,EAIxC;AACD,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAE5D,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,kBAAA;AAAA,IACJ,WAAA,EAAa,uDAAA;AAAA,cACbC,2BAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,GAAA,EAAK,CAAA,CAAA,KACH,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,GAAA,CAAI,MAAA,CAAO,KAAK,wCAAwC,CAAA;AAGxD,MAAA,MAAM,UAAA,GAAaC,qCAAA;AAAA,QACjB,GAAA,CAAI,aAAA;AAAA,QACJ,IAAI,KAAA,CAAM;AAAA,OACZ;AAEA,MAAAC,iDAAA,CAAyB;AAAA,QACvB,YAAA;AAAA,QACA,yBAAA;AAAA,QACA,GAAA,EAAK,IAAI,KAAA,CAAM,GAAA;AAAA,QACf,OAAA,EAAS,IAAI,YAAA,EAAc,OAAA;AAAA,QAC3B,KAAA,EAAO,IAAI,KAAA,CAAM;AAAA,OAClB,CAAA;AAED,MAAA,MAAMC,8BAAA,CAAU;AAAA,QACd,MAAA;AAAA,QACA,YAAA;AAAA,QACA,OAAA,EAAS,IAAI,YAAA,EAAc,OAAA;AAAA,QAC3B,QAAA,EAAU,IAAI,KAAA,CAAM,GAAA;AAAA,QACpB,UAAA;AAAA,QACA,KAAA,EAAO,IAAI,KAAA,CAAM;AAAA,OAClB,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH
|
|
1
|
+
{"version":3,"file":"plainFile.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/plainFile.ts"],"sourcesContent":["/*\n * Copyright 2021 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 resolveSafeChildPath,\n UrlReaderService,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { examples } from './plainFile.examples';\nimport { assertScmUserCredentials } from './assertScmUserCredentials';\n\nimport {\n createTemplateAction,\n fetchFile,\n} from '@backstage/plugin-scaffolder-node';\n\n/**\n * Downloads a single file and places it in the workspace.\n * @public\n */\nexport function createFetchPlainFileAction(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n requireScmUserCredentials?: boolean;\n}) {\n const { reader, integrations, requireScmUserCredentials } = options;\n\n return createTemplateAction({\n id: 'fetch:plain:file',\n description: 'Downloads single file and places it in the workspace.',\n examples,\n schema: {\n input: {\n url: z =>\n z.string({\n description:\n 'Relative path or absolute URL pointing to the single file to fetch.',\n }),\n targetPath: z =>\n z.string({\n description:\n 'Target path within the working directory to download the file as.',\n }),\n token: z =>\n z\n .string({\n description:\n 'An optional token to use for authentication when reading the resources.',\n })\n .optional(),\n },\n },\n supportsDryRun: true,\n async handler(ctx) {\n ctx.logger.info('Fetching plain content from remote URL');\n\n // Finally move the template result into the task workspace\n const outputPath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.targetPath,\n );\n\n assertScmUserCredentials({\n integrations,\n requireScmUserCredentials,\n url: ctx.input.url,\n baseUrl: ctx.templateInfo?.baseUrl,\n token: ctx.input.token,\n });\n\n await fetchFile({\n reader,\n integrations,\n baseUrl: ctx.templateInfo?.baseUrl,\n fetchUrl: ctx.input.url,\n outputPath,\n token: ctx.input.token,\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","resolveSafeChildPath","assertScmUserCredentials","fetchFile"],"mappings":";;;;;;;AAiCO,SAAS,2BAA2B,OAAA,EAIxC;AACD,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAE5D,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,kBAAA;AAAA,IACJ,WAAA,EAAa,uDAAA;AAAA,cACbC,2BAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,GAAA,EAAK,CAAA,CAAA,KACH,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,GAAA,CAAI,MAAA,CAAO,KAAK,wCAAwC,CAAA;AAGxD,MAAA,MAAM,UAAA,GAAaC,qCAAA;AAAA,QACjB,GAAA,CAAI,aAAA;AAAA,QACJ,IAAI,KAAA,CAAM;AAAA,OACZ;AAEA,MAAAC,iDAAA,CAAyB;AAAA,QACvB,YAAA;AAAA,QACA,yBAAA;AAAA,QACA,GAAA,EAAK,IAAI,KAAA,CAAM,GAAA;AAAA,QACf,OAAA,EAAS,IAAI,YAAA,EAAc,OAAA;AAAA,QAC3B,KAAA,EAAO,IAAI,KAAA,CAAM;AAAA,OAClB,CAAA;AAED,MAAA,MAAMC,8BAAA,CAAU;AAAA,QACd,MAAA;AAAA,QACA,YAAA;AAAA,QACA,OAAA,EAAS,IAAI,YAAA,EAAc,OAAA;AAAA,QAC3B,QAAA,EAAU,IAAI,KAAA,CAAM,GAAA;AAAA,QACpB,UAAA;AAAA,QACA,KAAA,EAAO,IAAI,KAAA,CAAM;AAAA,OAClB,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plainFile.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/plainFile.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Downloads a file and places it in the workspace.',\n example: yaml.stringify({\n steps: [\n {\n action: 'fetch:plain:file',\n id: 'fetch-plain-file',\n name: 'Fetch plain file',\n input: {\n url: 'https://github.com/backstage/community/tree/main/backstage-community-sessions/assets/Backstage%20Community%20Sessions.png',\n targetPath: 'target-path',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,kDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,kBAAA;AAAA,UACR,EAAA,EAAI,kBAAA;AAAA,UACJ,IAAA,EAAM,kBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,GAAA,EAAK,2HAAA;AAAA,YACL,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA;AAEL
|
|
1
|
+
{"version":3,"file":"plainFile.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/plainFile.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Downloads a file and places it in the workspace.',\n example: yaml.stringify({\n steps: [\n {\n action: 'fetch:plain:file',\n id: 'fetch-plain-file',\n name: 'Fetch plain file',\n input: {\n url: 'https://github.com/backstage/community/tree/main/backstage-community-sessions/assets/Backstage%20Community%20Sessions.png',\n targetPath: 'target-path',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,kDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,kBAAA;AAAA,UACR,EAAA,EAAI,kBAAA;AAAA,UACJ,IAAA,EAAM,kBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,GAAA,EAAK,2HAAA;AAAA,YACL,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/template.ts"],"sourcesContent":["/*\n * Copyright 2021 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 resolveSafeChildPath,\n UrlReaderService,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n createTemplateAction,\n fetchContents,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './template.examples';\nimport { assertScmUserCredentials } from './assertScmUserCredentials';\nimport {\n collectActionTemplateCapabilities,\n createTemplateActionHandler,\n} from './templateActionHandler';\n\n/**\n * Downloads a skeleton, templates variables into file and directory names and content.\n * Then places the result in the workspace, or optionally in a subdirectory\n * specified by the 'targetPath' input option.\n *\n * @public\n */\nexport function createFetchTemplateAction(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n requireScmUserCredentials?: boolean;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n}) {\n const templateCapabilities = collectActionTemplateCapabilities(options);\n\n return createTemplateAction({\n id: 'fetch:template',\n description:\n 'Downloads a skeleton, templates variables into file and directory names and content, and places the result in the workspace, or optionally in a subdirectory specified by the `targetPath` input option.',\n examples,\n schema: {\n input: {\n url: z =>\n z.string({\n description:\n 'Relative path or absolute URL pointing to the directory tree to fetch',\n }),\n targetPath: z =>\n z\n .string({\n description:\n 'Target path within the working directory to download the contents to. Defaults to the working directory root.',\n })\n .optional(),\n values: z =>\n z\n .record(z.any(), {\n description: 'Values to pass on to the templating engine',\n })\n .optional(),\n copyWithoutRender: z =>\n z\n .array(z.string(), {\n description:\n 'An array of glob patterns. Any files or directories which match are copied without being processed as templates.',\n })\n .optional(),\n copyWithoutTemplating: z =>\n z\n .array(z.string(), {\n description:\n 'An array of glob patterns. Contents of matched files or directories are copied without being processed, but paths are subject to rendering.',\n })\n .optional(),\n cookiecutterCompat: z =>\n z\n .boolean({\n description:\n 'Enable features to maximise compatibility with templates built for fetch:cookiecutter',\n })\n .optional(),\n templateFileExtension: z =>\n z\n .union([z.string(), z.boolean()], {\n description:\n 'If set, only files with the given extension will be templated. If set to `true`, the default extension `.njk` is used.',\n })\n .optional(),\n replace: z =>\n z\n .boolean({\n description:\n 'If set, replace files in targetPath instead of skipping existing ones.',\n })\n .optional(),\n trimBlocks: z =>\n z\n .boolean({\n description:\n 'If set, the first newline after a block is removed (block, not variable tag).',\n })\n .optional(),\n lstripBlocks: z =>\n z\n .boolean({\n description:\n 'If set, leading spaces and tabs are stripped from the start of a line to a block.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'An optional token to use for authentication when reading the resources.',\n })\n .optional(),\n },\n },\n supportsDryRun: true,\n handler: ctx =>\n createTemplateActionHandler({\n ctx,\n resolveTemplate: async () => {\n ctx.logger.info('Fetching template content from remote URL');\n\n assertScmUserCredentials({\n integrations: options.integrations,\n requireScmUserCredentials: options.requireScmUserCredentials,\n url: ctx.input.url,\n baseUrl: ctx.templateInfo?.baseUrl,\n token: ctx.input.token,\n });\n\n const workDir = await ctx.createTemporaryDirectory();\n const templateDir = resolveSafeChildPath(workDir, 'template');\n\n await fetchContents({\n baseUrl: ctx.templateInfo?.baseUrl,\n fetchUrl: ctx.input.url,\n outputPath: templateDir,\n token: ctx.input.token,\n ...options,\n });\n\n return templateDir;\n },\n ...options,\n templateCapabilities,\n }),\n });\n}\n"],"names":["collectActionTemplateCapabilities","createTemplateAction","examples","createTemplateActionHandler","assertScmUserCredentials","resolveSafeChildPath","fetchContents"],"mappings":";;;;;;;;AAyCO,SAAS,0BAA0B,OAAA,EAMvC;AACD,EAAA,MAAM,oBAAA,GAAuBA,wDAAkC,OAAO,CAAA;AAEtE,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,gBAAA;AAAA,IACJ,WAAA,EACE,0MAAA;AAAA,cACFC,0BAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,GAAA,EAAK,CAAA,CAAA,KACH,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,QAAQ,CAAA,CAAA,KACN,CAAA,CACG,MAAA,CAAO,CAAA,CAAE,KAAI,EAAG;AAAA,UACf,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,mBAAmB,CAAA,CAAA,KACjB,CAAA,CACG,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UACjB,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,uBAAuB,CAAA,CAAA,KACrB,CAAA,CACG,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UACjB,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,kBAAA,EAAoB,CAAA,CAAA,KAClB,CAAA,CACG,OAAA,CAAQ;AAAA,UACP,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,qBAAA,EAAuB,CAAA,CAAA,KACrB,CAAA,CACG,KA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AAA,EAAc,OAAA;AAAA,UAC3B,QAAA,EAAU,IAAI,KAAA,CAAM,GAAA;AAAA,UACpB,UAAA,EAAY,WAAA;AAAA,UACZ,KAAA,EAAO,IAAI,KAAA,CAAM,KAAA;AAAA,UACjB,GAAG;AAAA,SACJ,CAAA;AAED,QAAA,OAAO,WAAA;AAAA,MACT,CAAA;AAAA,MACA,GAAG,OAAA;AAAA,MACH;AAAA,KACD;AAAA,GACJ,CAAA;AACH
|
|
1
|
+
{"version":3,"file":"template.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/template.ts"],"sourcesContent":["/*\n * Copyright 2021 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 resolveSafeChildPath,\n UrlReaderService,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n createTemplateAction,\n fetchContents,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './template.examples';\nimport { assertScmUserCredentials } from './assertScmUserCredentials';\nimport {\n collectActionTemplateCapabilities,\n createTemplateActionHandler,\n} from './templateActionHandler';\n\n/**\n * Downloads a skeleton, templates variables into file and directory names and content.\n * Then places the result in the workspace, or optionally in a subdirectory\n * specified by the 'targetPath' input option.\n *\n * @public\n */\nexport function createFetchTemplateAction(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n requireScmUserCredentials?: boolean;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n}) {\n const templateCapabilities = collectActionTemplateCapabilities(options);\n\n return createTemplateAction({\n id: 'fetch:template',\n description:\n 'Downloads a skeleton, templates variables into file and directory names and content, and places the result in the workspace, or optionally in a subdirectory specified by the `targetPath` input option.',\n examples,\n schema: {\n input: {\n url: z =>\n z.string({\n description:\n 'Relative path or absolute URL pointing to the directory tree to fetch',\n }),\n targetPath: z =>\n z\n .string({\n description:\n 'Target path within the working directory to download the contents to. Defaults to the working directory root.',\n })\n .optional(),\n values: z =>\n z\n .record(z.any(), {\n description: 'Values to pass on to the templating engine',\n })\n .optional(),\n copyWithoutRender: z =>\n z\n .array(z.string(), {\n description:\n 'An array of glob patterns. Any files or directories which match are copied without being processed as templates.',\n })\n .optional(),\n copyWithoutTemplating: z =>\n z\n .array(z.string(), {\n description:\n 'An array of glob patterns. Contents of matched files or directories are copied without being processed, but paths are subject to rendering.',\n })\n .optional(),\n cookiecutterCompat: z =>\n z\n .boolean({\n description:\n 'Enable features to maximise compatibility with templates built for fetch:cookiecutter',\n })\n .optional(),\n templateFileExtension: z =>\n z\n .union([z.string(), z.boolean()], {\n description:\n 'If set, only files with the given extension will be templated. If set to `true`, the default extension `.njk` is used.',\n })\n .optional(),\n replace: z =>\n z\n .boolean({\n description:\n 'If set, replace files in targetPath instead of skipping existing ones.',\n })\n .optional(),\n trimBlocks: z =>\n z\n .boolean({\n description:\n 'If set, the first newline after a block is removed (block, not variable tag).',\n })\n .optional(),\n lstripBlocks: z =>\n z\n .boolean({\n description:\n 'If set, leading spaces and tabs are stripped from the start of a line to a block.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'An optional token to use for authentication when reading the resources.',\n })\n .optional(),\n },\n },\n supportsDryRun: true,\n handler: ctx =>\n createTemplateActionHandler({\n ctx,\n resolveTemplate: async () => {\n ctx.logger.info('Fetching template content from remote URL');\n\n assertScmUserCredentials({\n integrations: options.integrations,\n requireScmUserCredentials: options.requireScmUserCredentials,\n url: ctx.input.url,\n baseUrl: ctx.templateInfo?.baseUrl,\n token: ctx.input.token,\n });\n\n const workDir = await ctx.createTemporaryDirectory();\n const templateDir = resolveSafeChildPath(workDir, 'template');\n\n await fetchContents({\n baseUrl: ctx.templateInfo?.baseUrl,\n fetchUrl: ctx.input.url,\n outputPath: templateDir,\n token: ctx.input.token,\n ...options,\n });\n\n return templateDir;\n },\n ...options,\n templateCapabilities,\n }),\n });\n}\n"],"names":["collectActionTemplateCapabilities","createTemplateAction","examples","createTemplateActionHandler","assertScmUserCredentials","resolveSafeChildPath","fetchContents"],"mappings":";;;;;;;;AAyCO,SAAS,0BAA0B,OAAA,EAMvC;AACD,EAAA,MAAM,oBAAA,GAAuBA,wDAAkC,OAAO,CAAA;AAEtE,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,gBAAA;AAAA,IACJ,WAAA,EACE,0MAAA;AAAA,cACFC,0BAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,GAAA,EAAK,CAAA,CAAA,KACH,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,QAAQ,CAAA,CAAA,KACN,CAAA,CACG,MAAA,CAAO,CAAA,CAAE,KAAI,EAAG;AAAA,UACf,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,mBAAmB,CAAA,CAAA,KACjB,CAAA,CACG,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UACjB,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,uBAAuB,CAAA,CAAA,KACrB,CAAA,CACG,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UACjB,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,kBAAA,EAAoB,CAAA,CAAA,KAClB,CAAA,CACG,OAAA,CAA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AAcC,qCAAA,CAAqB,OAAA,EAAS,UAAU,CAAA;AAE5D,QAAA,MAAMC,kCAAA,CAAc;AAAA,UAClB,OAAA,EAAS,IAAI,YAAA,EAAc,OAAA;AAAA,UAC3B,QAAA,EAAU,IAAI,KAAA,CAAM,GAAA;AAAA,UACpB,UAAA,EAAY,WAAA;AAAA,UACZ,KAAA,EAAO,IAAI,KAAA,CAAM,KAAA;AAAA,UACjB,GAAG;AAAA,SACJ,CAAA;AAED,QAAA,OAAO,WAAA;AAAA,MACT,CAAA;AAAA,MACA,GAAG,OAAA;AAAA,MACH;AAAA,KACD;AAAA,GACJ,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/template.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Downloads a skeleton directory that lives alongside the template file and fill it out with values.',\n example: yaml.stringify({\n steps: [\n {\n action: 'fetch:template',\n id: 'fetch-template',\n name: 'Fetch template',\n input: {\n url: './skeleton',\n targetPath: './target',\n values: {\n name: 'test-project',\n count: 1234,\n itemList: ['first', 'second', 'third'],\n showDummyFile: false,\n },\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EACE,oGAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,gBAAA;AAAA,UACR,EAAA,EAAI,gBAAA;AAAA,UACJ,IAAA,EAAM,gBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,GAAA,EAAK,YAAA;AAAA,YACL,UAAA,EAAY,UAAA;AAAA,YACZ,MAAA,EAAQ;AAAA,cACN,IAAA,EAAM,cAAA;AAAA,cACN,KAAA,EAAO,IAAA;AAAA,cACP,QAAA,EAAU,CAAC,OAAA,EAAS,QAAA,EAAU,OAAO,CAAA;AAAA,cACrC,aAAA,EAAe;AAAA;AACjB;AACF;AACF;AACF,KACD;AAAA;AAEL
|
|
1
|
+
{"version":3,"file":"template.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/template.examples.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Downloads a skeleton directory that lives alongside the template file and fill it out with values.',\n example: yaml.stringify({\n steps: [\n {\n action: 'fetch:template',\n id: 'fetch-template',\n name: 'Fetch template',\n input: {\n url: './skeleton',\n targetPath: './target',\n values: {\n name: 'test-project',\n count: 1234,\n itemList: ['first', 'second', 'third'],\n showDummyFile: false,\n },\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EACE,oGAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,gBAAA;AAAA,UACR,EAAA,EAAI,gBAAA;AAAA,UACJ,IAAA,EAAM,gBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,GAAA,EAAK,YAAA;AAAA,YACL,UAAA,EAAY,UAAA;AAAA,YACZ,MAAA,EAAQ;AAAA,cACN,IAAA,EAAM,cAAA;AAAA,cACN,KAAA,EAAO,IAAA;AAAA,cACP,QAAA,EAAU,CAAC,OAAA,EAAS,QAAA,EAAU,OAAO,CAAA;AAAA,cACrC,aAAA,EAAe;AAAA;AACjB;AACF;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateActionHandler.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/templateActionHandler.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\nimport {\n isChildPath,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n ActionContext,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport fs from 'fs-extra';\nimport globby from 'globby';\nimport { isBinaryFile } from 'isbinaryfile';\nimport { createTemplateRenderer, TemplateCapabilities } from 'nunjitsu';\nimport { createDefaultFilters } from '../../../../lib/templating/filters/createDefaultFilters';\nimport {\n collectTemplateCapabilities,\n convertFiltersToRecord,\n} from '../../../../util/templating';\nimport { extname } from 'node:path';\n\nexport type TemplateActionInput = {\n targetPath?: string;\n values: any;\n templateFileExtension?: string | boolean;\n copyWithoutTemplating?: string[];\n cookiecutterCompat?: boolean;\n replace?: boolean;\n trimBlocks?: boolean;\n lstripBlocks?: boolean;\n};\n\nexport function collectActionTemplateCapabilities(options: {\n integrations: ScmIntegrations;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n}) {\n return collectTemplateCapabilities({\n filters: {\n ...convertFiltersToRecord(\n createDefaultFilters({ integrations: options.integrations }),\n ),\n ...options.additionalTemplateFilters,\n },\n globals: options.additionalTemplateGlobals,\n });\n}\n\nexport async function createTemplateActionHandler<\n I extends TemplateActionInput,\n>(options: {\n ctx: ActionContext<I, any, any>;\n resolveTemplate: () => Promise<string>;\n integrations: ScmIntegrations;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n templateCapabilities?: TemplateCapabilities;\n}) {\n const { resolveTemplate, ctx } = options;\n const templateCapabilities =\n options.templateCapabilities ?? collectActionTemplateCapabilities(options);\n\n const { outputDir, copyOnlyPatterns, renderFilename, extension } =\n resolveTemplateActionSettings(ctx);\n\n const templateDir = await resolveTemplate();\n\n if (isChildPath(templateDir, outputDir)) {\n throw new InputError('targetPath must not be within template path');\n }\n\n ctx.logger.info('Listing files and directories in template');\n const allEntriesInTemplate = await globby(`**/*`, {\n cwd: templateDir,\n dot: true,\n onlyFiles: false,\n markDirectories: true,\n followSymbolicLinks: false,\n });\n\n const nonTemplatedEntries = new Set(\n await globby(copyOnlyPatterns || [], {\n cwd: templateDir,\n dot: true,\n onlyFiles: false,\n markDirectories: true,\n followSymbolicLinks: false,\n }),\n );\n\n // Cookiecutter prefixes all parameters in templates with\n // `cookiecutter.`. To replicate this, we wrap our parameters\n // in an object with a `cookiecutter` property when compat\n // mode is enabled.\n const { cookiecutterCompat, values } = ctx.input;\n const context = {\n [cookiecutterCompat ? 'cookiecutter' : 'values']: values,\n };\n\n ctx.logger.info(\n `Processing ${allEntriesInTemplate.length} template files/directories with input values`,\n ctx.input.values,\n );\n\n const templateRenderer = createTemplateRenderer({\n ...templateCapabilities,\n allowRegexExecution: true,\n cookiecutterCompat: ctx.input.cookiecutterCompat,\n trimBlocks: ctx.input.trimBlocks,\n lstripBlocks: ctx.input.lstripBlocks,\n });\n const preparedContext = templateRenderer.prepareContext(context);\n\n for (const location of allEntriesInTemplate) {\n let renderContents: boolean;\n\n let localOutputPath = location;\n if (extension) {\n renderContents = extname(localOutputPath) === extension;\n if (renderContents) {\n localOutputPath = localOutputPath.slice(0, -extension.length);\n }\n // extension is mutual exclusive with copyWithoutRender/copyWithoutTemplating,\n // therefore the output path is always rendered.\n localOutputPath = templateRenderer.render(\n localOutputPath,\n preparedContext,\n );\n } else {\n renderContents = !nonTemplatedEntries.has(location);\n // The logic here is a bit tangled because it depends on two variables.\n // If renderFilename is true, which means copyWithoutTemplating is used,\n // then the path is always rendered.\n // If renderFilename is false, which means copyWithoutRender is used,\n // then matched file/directory won't be processed, same as before.\n if (renderFilename) {\n localOutputPath = templateRenderer.render(\n localOutputPath,\n preparedContext,\n );\n } else {\n localOutputPath = renderContents\n ? templateRenderer.render(localOutputPath, preparedContext)\n : localOutputPath;\n }\n }\n\n if (containsSkippedContent(localOutputPath)) {\n continue;\n }\n\n const outputPath = resolveSafeChildPath(outputDir, localOutputPath);\n if (fs.existsSync(outputPath) && !ctx.input.replace) {\n continue;\n }\n\n if (!renderContents && !extension) {\n ctx.logger.info(`Copying file/directory ${location} without processing.`);\n }\n\n if (location.endsWith('/')) {\n ctx.logger.info(`Writing directory ${location} to template output path.`);\n await fs.ensureDir(outputPath);\n } else {\n const inputFilePath = resolveSafeChildPath(templateDir, location);\n const stats = await fs.promises.lstat(inputFilePath);\n\n if (stats.isSymbolicLink() || (await isBinaryFile(inputFilePath))) {\n ctx.logger.info(\n `Copying file binary or symbolic link at ${location}, to template output path.`,\n );\n await fs.copy(inputFilePath, outputPath);\n } else {\n const statsObj = await fs.stat(inputFilePath);\n ctx.logger.info(\n `Writing file ${location} to template output path with mode ${statsObj.mode}.`,\n );\n const inputFileContents = await fs.readFile(inputFilePath, 'utf-8');\n await fs.outputFile(\n outputPath,\n renderContents\n ? templateRenderer.render(inputFileContents, preparedContext)\n : inputFileContents,\n { mode: statsObj.mode },\n );\n }\n }\n }\n ctx.logger.info(`Template result written to ${outputDir}`);\n}\n\nfunction resolveTemplateActionSettings<I extends TemplateActionInput>(\n ctx: ActionContext<I, any, any>,\n): {\n outputDir: string;\n copyOnlyPatterns?: string[];\n renderFilename: boolean;\n extension: string | false;\n} {\n const targetPath = ctx.input.targetPath ?? './';\n const outputDir = resolveSafeChildPath(ctx.workspacePath, targetPath);\n\n const copyOnlyPatterns = ctx.input.copyWithoutTemplating;\n const renderFilename = true;\n\n if (copyOnlyPatterns && !Array.isArray(copyOnlyPatterns)) {\n throw new InputError(\n 'Fetch action input copyWithoutTemplating must be an Array',\n );\n }\n if (\n ctx.input.templateFileExtension &&\n (copyOnlyPatterns || ctx.input.cookiecutterCompat)\n ) {\n throw new InputError(\n 'Fetch action input extension incompatible with copyWithoutTemplating and cookiecutterCompat',\n );\n }\n let extension: string | false = false;\n if (ctx.input.templateFileExtension) {\n extension =\n ctx.input.templateFileExtension === true\n ? '.njk'\n : ctx.input.templateFileExtension;\n if (!extension.startsWith('.')) {\n extension = `.${extension}`;\n }\n }\n return {\n outputDir,\n copyOnlyPatterns,\n renderFilename,\n extension,\n };\n}\n\nfunction containsSkippedContent(localOutputPath: string): boolean {\n // if the path is empty means that there is a file skipped in the root\n // if the path starts with a separator it means that the root directory has been skipped\n // if the path includes // means that there is a subdirectory skipped\n // All paths returned are considered with / separator because of globby returning the linux separator for all os'.\n return (\n localOutputPath === '' ||\n localOutputPath.startsWith('/') ||\n localOutputPath.includes('//')\n );\n}\n"],"names":["collectTemplateCapabilities","convertFiltersToRecord","createDefaultFilters","isChildPath","InputError","globby","createTemplateRenderer","extname","resolveSafeChildPath","fs","isBinaryFile"],"mappings":";;;;;;;;;;;;;;;;;AAgDO,SAAS,kCAAkC,OAAA,EAI/C;AACD,EAAA,OAAOA,sCAAA,CAA4B;AAAA,IACjC,OAAA,EAAS;AAAA,MACP,GAAGC,iCAAA;AAAA,QACDC,yCAAA,CAAqB,EAAE,YAAA,EAAc,OAAA,CAAQ,cAAc;AAAA,OAC7D;AAAA,MACA,GAAG,OAAA,CAAQ;AAAA,KACb;AAAA,IACA,SAAS,OAAA,CAAQ;AAAA,GAClB,CAAA;AACH;AAEA,eAAsB,4BAEpB,OAAA,EAOC;AACD,EAAA,MAAM,EAAE,eAAA,EAAiB,GAAA,EAAI,GAAI,OAAA;AACjC,EAAA,MAAM,oBAAA,GACJ,OAAA,CAAQ,oBAAA,IAAwB,iCAAA,CAAkC,OAAO,CAAA;AAE3E,EAAA,MAAM,EAAE,SAAA,EAAW,gBAAA,EAAkB,gBAAgB,SAAA,EAAU,GAC7D,8BAA8B,GAAG,CAAA;AAEnC,EAAA,MAAM,WAAA,GAAc,MAAM,eAAA,EAAgB;AAE1C,EAAA,IAAIC,4BAAA,CAAY,WAAA,EAAa,SAAS,CAAA,EAAG;AACvC,IAAA,MAAM,IAAIC,kBAAW,6CAA6C,CAAA;AAAA,EACpE;AAEA,EAAA,GAAA,CAAI,MAAA,CAAO,KAAK,2CAA2C,CAAA;AAC3D,EAAA,MAAM,oBAAA,GAAuB,MAAMC,uBAAA,CAAO,CAAA,IAAA,CAAA,EAAQ;AAAA,IAChD,GAAA,EAAK,WAAA;AAAA,IACL,GAAA,EAAK,IAAA;AAAA,IACL,SAAA,EAAW,KAAA;AAAA,IACX,eAAA,EAAiB,IAAA;AAAA,IACjB,mBAAA,EAAqB;AAAA,GACtB,CAAA;AAED,EAAA,MAAM,sBAAsB,IAAI,GAAA;AAAA,IAC9B,MAAMA,uBAAA,CAAO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AA,EAAG;AACxD,IAAA,MAAM,IAAIJ,iBAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,IACE,IAAI,KAAA,CAAM,qBAAA,KACT,gBAAA,IAAoB,GAAA,CAAI,MAAM,kBAAA,CAAA,EAC/B;AACA,IAAA,MAAM,IAAIA,iBAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,IAAI,SAAA,GAA4B,KAAA;AAChC,EAAA,IAAI,GAAA,CAAI,MAAM,qBAAA,EAAuB;AACnC,IAAA,SAAA,GACE,IAAI,KAAA,CAAM,qBAAA,KAA0B,IAAA,GAChC,MAAA,GACA,IAAI,KAAA,CAAM,qBAAA;AAChB,IAAA,IAAI,CAAC,SAAA,CAAU,UAAA,CAAW,GAAG,CAAA,EAAG;AAC9B,MAAA,SAAA,GAAY,IAAI,SAAS,CAAA,CAAA;AAAA,IAC3B;AAAA,EACF;AACA,EAAA,OAAO;AAAA,IACL,SAAA;AAAA,IACA,gBAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACF;AACF;AAEA,SAAS,uBAAuB,eAAA,EAAkC;AAKhE,EAAA,OACE,eAAA,KAAoB,MACpB,eAAA,CAAgB,UAAA,CAAW,GAAG,CAAA,IAC9B,eAAA,CAAgB,SAAS,IAAI,CAAA;AAEjC;;;"}
|
|
1
|
+
{"version":3,"file":"templateActionHandler.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/templateActionHandler.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\nimport {\n isChildPath,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n ActionContext,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport fs from 'fs-extra';\nimport globby from 'globby';\nimport { isBinaryFile } from 'isbinaryfile';\nimport { createTemplateRenderer, TemplateCapabilities } from 'nunjitsu';\nimport { createDefaultFilters } from '../../../../lib/templating/filters/createDefaultFilters';\nimport {\n collectTemplateCapabilities,\n convertFiltersToRecord,\n} from '../../../../util/templating';\nimport { extname } from 'node:path';\n\nexport type TemplateActionInput = {\n targetPath?: string;\n values: any;\n templateFileExtension?: string | boolean;\n copyWithoutTemplating?: string[];\n cookiecutterCompat?: boolean;\n replace?: boolean;\n trimBlocks?: boolean;\n lstripBlocks?: boolean;\n};\n\nexport function collectActionTemplateCapabilities(options: {\n integrations: ScmIntegrations;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n}) {\n return collectTemplateCapabilities({\n filters: {\n ...convertFiltersToRecord(\n createDefaultFilters({ integrations: options.integrations }),\n ),\n ...options.additionalTemplateFilters,\n },\n globals: options.additionalTemplateGlobals,\n });\n}\n\nexport async function createTemplateActionHandler<\n I extends TemplateActionInput,\n>(options: {\n ctx: ActionContext<I, any, any>;\n resolveTemplate: () => Promise<string>;\n integrations: ScmIntegrations;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n templateCapabilities?: TemplateCapabilities;\n}) {\n const { resolveTemplate, ctx } = options;\n const templateCapabilities =\n options.templateCapabilities ?? collectActionTemplateCapabilities(options);\n\n const { outputDir, copyOnlyPatterns, renderFilename, extension } =\n resolveTemplateActionSettings(ctx);\n\n const templateDir = await resolveTemplate();\n\n if (isChildPath(templateDir, outputDir)) {\n throw new InputError('targetPath must not be within template path');\n }\n\n ctx.logger.info('Listing files and directories in template');\n const allEntriesInTemplate = await globby(`**/*`, {\n cwd: templateDir,\n dot: true,\n onlyFiles: false,\n markDirectories: true,\n followSymbolicLinks: false,\n });\n\n const nonTemplatedEntries = new Set(\n await globby(copyOnlyPatterns || [], {\n cwd: templateDir,\n dot: true,\n onlyFiles: false,\n markDirectories: true,\n followSymbolicLinks: false,\n }),\n );\n\n // Cookiecutter prefixes all parameters in templates with\n // `cookiecutter.`. To replicate this, we wrap our parameters\n // in an object with a `cookiecutter` property when compat\n // mode is enabled.\n const { cookiecutterCompat, values } = ctx.input;\n const context = {\n [cookiecutterCompat ? 'cookiecutter' : 'values']: values,\n };\n\n ctx.logger.info(\n `Processing ${allEntriesInTemplate.length} template files/directories with input values`,\n ctx.input.values,\n );\n\n const templateRenderer = createTemplateRenderer({\n ...templateCapabilities,\n allowRegexExecution: true,\n cookiecutterCompat: ctx.input.cookiecutterCompat,\n trimBlocks: ctx.input.trimBlocks,\n lstripBlocks: ctx.input.lstripBlocks,\n });\n const preparedContext = templateRenderer.prepareContext(context);\n\n for (const location of allEntriesInTemplate) {\n let renderContents: boolean;\n\n let localOutputPath = location;\n if (extension) {\n renderContents = extname(localOutputPath) === extension;\n if (renderContents) {\n localOutputPath = localOutputPath.slice(0, -extension.length);\n }\n // extension is mutual exclusive with copyWithoutRender/copyWithoutTemplating,\n // therefore the output path is always rendered.\n localOutputPath = templateRenderer.render(\n localOutputPath,\n preparedContext,\n );\n } else {\n renderContents = !nonTemplatedEntries.has(location);\n // The logic here is a bit tangled because it depends on two variables.\n // If renderFilename is true, which means copyWithoutTemplating is used,\n // then the path is always rendered.\n // If renderFilename is false, which means copyWithoutRender is used,\n // then matched file/directory won't be processed, same as before.\n if (renderFilename) {\n localOutputPath = templateRenderer.render(\n localOutputPath,\n preparedContext,\n );\n } else {\n localOutputPath = renderContents\n ? templateRenderer.render(localOutputPath, preparedContext)\n : localOutputPath;\n }\n }\n\n if (containsSkippedContent(localOutputPath)) {\n continue;\n }\n\n const outputPath = resolveSafeChildPath(outputDir, localOutputPath);\n if (fs.existsSync(outputPath) && !ctx.input.replace) {\n continue;\n }\n\n if (!renderContents && !extension) {\n ctx.logger.info(`Copying file/directory ${location} without processing.`);\n }\n\n if (location.endsWith('/')) {\n ctx.logger.info(`Writing directory ${location} to template output path.`);\n await fs.ensureDir(outputPath);\n } else {\n const inputFilePath = resolveSafeChildPath(templateDir, location);\n const stats = await fs.promises.lstat(inputFilePath);\n\n if (stats.isSymbolicLink() || (await isBinaryFile(inputFilePath))) {\n ctx.logger.info(\n `Copying file binary or symbolic link at ${location}, to template output path.`,\n );\n await fs.copy(inputFilePath, outputPath);\n } else {\n const statsObj = await fs.stat(inputFilePath);\n ctx.logger.info(\n `Writing file ${location} to template output path with mode ${statsObj.mode}.`,\n );\n const inputFileContents = await fs.readFile(inputFilePath, 'utf-8');\n await fs.outputFile(\n outputPath,\n renderContents\n ? templateRenderer.render(inputFileContents, preparedContext)\n : inputFileContents,\n { mode: statsObj.mode },\n );\n }\n }\n }\n ctx.logger.info(`Template result written to ${outputDir}`);\n}\n\nfunction resolveTemplateActionSettings<I extends TemplateActionInput>(\n ctx: ActionContext<I, any, any>,\n): {\n outputDir: string;\n copyOnlyPatterns?: string[];\n renderFilename: boolean;\n extension: string | false;\n} {\n const targetPath = ctx.input.targetPath ?? './';\n const outputDir = resolveSafeChildPath(ctx.workspacePath, targetPath);\n\n const copyOnlyPatterns = ctx.input.copyWithoutTemplating;\n const renderFilename = true;\n\n if (copyOnlyPatterns && !Array.isArray(copyOnlyPatterns)) {\n throw new InputError(\n 'Fetch action input copyWithoutTemplating must be an Array',\n );\n }\n if (\n ctx.input.templateFileExtension &&\n (copyOnlyPatterns || ctx.input.cookiecutterCompat)\n ) {\n throw new InputError(\n 'Fetch action input extension incompatible with copyWithoutTemplating and cookiecutterCompat',\n );\n }\n let extension: string | false = false;\n if (ctx.input.templateFileExtension) {\n extension =\n ctx.input.templateFileExtension === true\n ? '.njk'\n : ctx.input.templateFileExtension;\n if (!extension.startsWith('.')) {\n extension = `.${extension}`;\n }\n }\n return {\n outputDir,\n copyOnlyPatterns,\n renderFilename,\n extension,\n };\n}\n\nfunction containsSkippedContent(localOutputPath: string): boolean {\n // if the path is empty means that there is a file skipped in the root\n // if the path starts with a separator it means that the root directory has been skipped\n // if the path includes // means that there is a subdirectory skipped\n // All paths returned are considered with / separator because of globby returning the linux separator for all os'.\n return (\n localOutputPath === '' ||\n localOutputPath.startsWith('/') ||\n localOutputPath.includes('//')\n );\n}\n"],"names":["collectTemplateCapabilities","convertFiltersToRecord","createDefaultFilters","isChildPath","InputError","globby","createTemplateRenderer","extname","resolveSafeChildPath","fs","isBinaryFile"],"mappings":";;;;;;;;;;;;;;;;;AAgDO,SAAS,kCAAkC,OAAA,EAI/C;AACD,EAAA,OAAOA,sCAAA,CAA4B;AAAA,IACjC,OAAA,EAAS;AAAA,MACP,GAAGC,iCAAA;AAAA,QACDC,yCAAA,CAAqB,EAAE,YAAA,EAAc,OAAA,CAAQ,cAAc;AAAA,OAC7D;AAAA,MACA,GAAG,OAAA,CAAQ;AAAA,KACb;AAAA,IACA,SAAS,OAAA,CAAQ;AAAA,GAClB,CAAA;AACH;AAEA,eAAsB,4BAEpB,OAAA,EAOC;AACD,EAAA,MAAM,EAAE,eAAA,EAAiB,GAAA,EAAI,GAAI,OAAA;AACjC,EAAA,MAAM,oBAAA,GACJ,OAAA,CAAQ,oBAAA,IAAwB,iCAAA,CAAkC,OAAO,CAAA;AAE3E,EAAA,MAAM,EAAE,SAAA,EAAW,gBAAA,EAAkB,gBAAgB,SAAA,EAAU,GAC7D,8BAA8B,GAAG,CAAA;AAEnC,EAAA,MAAM,WAAA,GAAc,MAAM,eAAA,EAAgB;AAE1C,EAAA,IAAIC,4BAAA,CAAY,WAAA,EAAa,SAAS,CAAA,EAAG;AACvC,IAAA,MAAM,IAAIC,kBAAW,6CAA6C,CAAA;AAAA,EACpE;AAEA,EAAA,GAAA,CAAI,MAAA,CAAO,KAAK,2CAA2C,CAAA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ateFile.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { UrlReaderService } from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n createTemplateAction,\n fetchFile,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport path from 'node:path';\nimport { examples } from './templateFile.examples';\nimport { assertScmUserCredentials } from './assertScmUserCredentials';\nimport { createTemplateFileActionHandler } from './templateFileActionHandler';\nimport { collectActionTemplateCapabilities } from './templateActionHandler';\n\n/**\n * Downloads a single file and templates variables into file.\n * Then places the result in the workspace, or optionally in a subdirectory\n * specified by the 'targetPath' input option.\n * @public\n */\nexport function createFetchTemplateFileAction(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n requireScmUserCredentials?: boolean;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n}) {\n const templateCapabilities = collectActionTemplateCapabilities(options);\n\n return createTemplateAction({\n id: 'fetch:template:file',\n description: 'Downloads single file and places it in the workspace.',\n examples,\n schema: {\n input: {\n url: z =>\n z.string({\n description:\n 'Relative path or absolute URL pointing to the single file to fetch.',\n }),\n targetPath: z =>\n z.string({\n description:\n 'Target path within the working directory to download the file as.',\n }),\n values: z =>\n z\n .record(z.any(), {\n description: 'Values to pass on to the templating engine',\n })\n .optional(),\n cookiecutterCompat: z =>\n z\n .boolean({\n description:\n 'Enable features to maximise compatibility with templates built for fetch:cookiecutter',\n })\n .optional(),\n replace: z =>\n z\n .boolean({\n description:\n 'If set, replace file in targetPath instead of overwriting existing one.',\n })\n .optional(),\n trimBlocks: z =>\n z\n .boolean({\n description:\n 'If set, the first newline after a block is removed (block, not variable tag).',\n })\n .optional(),\n lstripBlocks: z =>\n z\n .boolean({\n description:\n 'If set, leading spaces and tabs are stripped from the start of a line to a block.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'An optional token to use for authentication when reading the resources.',\n })\n .optional(),\n },\n },\n supportsDryRun: true,\n handler: ctx =>\n createTemplateFileActionHandler({\n ctx,\n resolveTemplateFile: async () => {\n ctx.logger.info('Fetching template file content from remote URL');\n\n assertScmUserCredentials({\n integrations: options.integrations,\n requireScmUserCredentials: options.requireScmUserCredentials,\n url: ctx.input.url,\n baseUrl: ctx.templateInfo?.baseUrl,\n token: ctx.input.token,\n });\n\n const workDir = await ctx.createTemporaryDirectory();\n // Write to a tmp file, render the template, then copy to workspace.\n const tmpFilePath = path.join(workDir, 'tmp');\n\n await fetchFile({\n baseUrl: ctx.templateInfo?.baseUrl,\n fetchUrl: ctx.input.url,\n outputPath: tmpFilePath,\n token: ctx.input.token,\n ...options,\n });\n return tmpFilePath;\n },\n ...options,\n templateCapabilities,\n }),\n });\n}\n"],"names":["collectActionTemplateCapabilities","createTemplateAction","examples","createTemplateFileActionHandler","assertScmUserCredentials","path","fetchFile"],"mappings":";;;;;;;;;;;;;AAoCO,SAAS,8BAA8B,OAAA,EAM3C;AACD,EAAA,MAAM,oBAAA,GAAuBA,wDAAkC,OAAO,CAAA;AAEtE,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,qBAAA;AAAA,IACJ,WAAA,EAAa,uDAAA;AAAA,cACbC,8BAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,GAAA,EAAK,CAAA,CAAA,KACH,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KAC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M,OAAA,GAAU,MAAM,GAAA,CAAI,wBAAA,EAAyB;AAEnD,QAAA,MAAM,WAAA,GAAcC,qBAAA,CAAK,IAAA,CAAK,OAAA,EAAS,KAAK,CAAA;AAE5C,QAAA,MAAMC,8BAAA,CAAU;AAAA,UACd,OAAA,EAAS,IAAI,YAAA,EAAc,OAAA;AAAA,UAC3B,QAAA,EAAU,IAAI,KAAA,CAAM,GAAA;AAAA,UACpB,UAAA,EAAY,WAAA;AAAA,UACZ,KAAA,EAAO,IAAI,KAAA,CAAM,KAAA;AAAA,UACjB,GAAG;AAAA,SACJ,CAAA;AACD,QAAA,OAAO,WAAA;AAAA,MACT,CAAA;AAAA,MACA,GAAG,OAAA;AAAA,MACH;AAAA,KACD;AAAA,GACJ,CAAA;AACH
|
|
1
|
+
{"version":3,"file":"templateFile.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/templateFile.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { UrlReaderService } from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n createTemplateAction,\n fetchFile,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport path from 'node:path';\nimport { examples } from './templateFile.examples';\nimport { assertScmUserCredentials } from './assertScmUserCredentials';\nimport { createTemplateFileActionHandler } from './templateFileActionHandler';\nimport { collectActionTemplateCapabilities } from './templateActionHandler';\n\n/**\n * Downloads a single file and templates variables into file.\n * Then places the result in the workspace, or optionally in a subdirectory\n * specified by the 'targetPath' input option.\n * @public\n */\nexport function createFetchTemplateFileAction(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n requireScmUserCredentials?: boolean;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n}) {\n const templateCapabilities = collectActionTemplateCapabilities(options);\n\n return createTemplateAction({\n id: 'fetch:template:file',\n description: 'Downloads single file and places it in the workspace.',\n examples,\n schema: {\n input: {\n url: z =>\n z.string({\n description:\n 'Relative path or absolute URL pointing to the single file to fetch.',\n }),\n targetPath: z =>\n z.string({\n description:\n 'Target path within the working directory to download the file as.',\n }),\n values: z =>\n z\n .record(z.any(), {\n description: 'Values to pass on to the templating engine',\n })\n .optional(),\n cookiecutterCompat: z =>\n z\n .boolean({\n description:\n 'Enable features to maximise compatibility with templates built for fetch:cookiecutter',\n })\n .optional(),\n replace: z =>\n z\n .boolean({\n description:\n 'If set, replace file in targetPath instead of overwriting existing one.',\n })\n .optional(),\n trimBlocks: z =>\n z\n .boolean({\n description:\n 'If set, the first newline after a block is removed (block, not variable tag).',\n })\n .optional(),\n lstripBlocks: z =>\n z\n .boolean({\n description:\n 'If set, leading spaces and tabs are stripped from the start of a line to a block.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'An optional token to use for authentication when reading the resources.',\n })\n .optional(),\n },\n },\n supportsDryRun: true,\n handler: ctx =>\n createTemplateFileActionHandler({\n ctx,\n resolveTemplateFile: async () => {\n ctx.logger.info('Fetching template file content from remote URL');\n\n assertScmUserCredentials({\n integrations: options.integrations,\n requireScmUserCredentials: options.requireScmUserCredentials,\n url: ctx.input.url,\n baseUrl: ctx.templateInfo?.baseUrl,\n token: ctx.input.token,\n });\n\n const workDir = await ctx.createTemporaryDirectory();\n // Write to a tmp file, render the template, then copy to workspace.\n const tmpFilePath = path.join(workDir, 'tmp');\n\n await fetchFile({\n baseUrl: ctx.templateInfo?.baseUrl,\n fetchUrl: ctx.input.url,\n outputPath: tmpFilePath,\n token: ctx.input.token,\n ...options,\n });\n return tmpFilePath;\n },\n ...options,\n templateCapabilities,\n }),\n });\n}\n"],"names":["collectActionTemplateCapabilities","createTemplateAction","examples","createTemplateFileActionHandler","assertScmUserCredentials","path","fetchFile"],"mappings":";;;;;;;;;;;;;AAoCO,SAAS,8BAA8B,OAAA,EAM3C;AACD,EAAA,MAAM,oBAAA,GAAuBA,wDAAkC,OAAO,CAAA;AAEtE,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,qBAAA;AAAA,IACJ,WAAA,EAAa,uDAAA;AAAA,cACbC,8BAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,GAAA,EAAK,CAAA,CAAA,KACH,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,QAAQ,CAAA,CAAA,KACN,CAAA,CACG,MAAA,CAAO,CAAA,CAAE,KAAI,EAAG;AAAA,UACf,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,kBAAA,EAAoB,CAAA,CAAA,KAClB,CAAA,CACG,OAAA,CAAQ;AAAA,UACP,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CACG,OAAA,CAAQ;AAAA,UACP,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,OAAA,CAAQ;AAAA,UACP,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,YAAA,EAAc,CAAA,CAAA,KACZ,CAAA,CACG,OAAA,CAAQ;AAAA,UACP,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,OAAA,EAAS,SACPC,yDAAA,CAAgC;AAAA,MAC9B,GAAA;AAAA,MACA,qBAAqB,YAAY;AAC/B,QAAA,GAAA,CAAI,MAAA,CAAO,KAAK,gDAAgD,CAAA;AAEhE,QAAAC,iDAAA,CAAyB;AAAA,UACvB,cAAc,OAAA,CAAQ,YAAA;AAAA,UACtB,2BAA2B,OAAA,CAAQ,yBAAA;AAAA,UACnC,GAAA,EAAK,IAAI,KAAA,CAAM,GAAA;AAAA,UACf,OAAA,EAAS,IAAI,YAAA,EAAc,OAAA;AAAA,UAC3B,KAAA,EAAO,IAAI,KAAA,CAAM;AAAA,SAClB,CAAA;AAED,QAAA,MAAM,OAAA,GAAU,MAAM,GAAA,CAAI,wBAAA,EAAyB;AAEnD,QAAA,MAAM,WAAA,GAAcC,qBAAA,CAAK,IAAA,CAAK,OAAA,EAAS,KAAK,CAAA;AAE5C,QAAA,MAAMC,8BAAA,CAAU;AAAA,UACd,OAAA,EAAS,IAAI,YAAA,EAAc,OAAA;AAAA,UAC3B,QAAA,EAAU,IAAI,KAAA,CAAM,GAAA;AAAA,UACpB,UAAA,EAAY,WAAA;AAAA,UACZ,KAAA,EAAO,IAAI,KAAA,CAAM,KAAA;AAAA,UACjB,GAAG;AAAA,SACJ,CAAA;AACD,QAAA,OAAO,WAAA;AAAA,MACT,CAAA;AAAA,MACA,GAAG,OAAA;AAAA,MACH;AAAA,KACD;AAAA,GACJ,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateFile.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/templateFile.examples.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Downloads a template file and fill it out with values.',\n example: yaml.stringify({\n steps: [\n {\n action: 'fetch:template:file',\n id: 'fetch-template-file',\n name: 'Fetch template file',\n input: {\n url: './skeleton.txt',\n targetPath: './target/skeleton.txt',\n values: {\n name: 'test-project',\n count: 1234,\n itemList: ['first', 'second', 'third'],\n },\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,wDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,qBAAA;AAAA,UACR,EAAA,EAAI,qBAAA;AAAA,UACJ,IAAA,EAAM,qBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,GAAA,EAAK,gBAAA;AAAA,YACL,UAAA,EAAY,uBAAA;AAAA,YACZ,MAAA,EAAQ;AAAA,cACN,IAAA,EAAM,cAAA;AAAA,cACN,KAAA,EAAO,IAAA;AAAA,cACP,QAAA,EAAU,CAAC,OAAA,EAAS,QAAA,EAAU,OAAO;AAAA;AACvC;AACF;AACF;AACF,KACD;AAAA;AAEL
|
|
1
|
+
{"version":3,"file":"templateFile.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/templateFile.examples.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Downloads a template file and fill it out with values.',\n example: yaml.stringify({\n steps: [\n {\n action: 'fetch:template:file',\n id: 'fetch-template-file',\n name: 'Fetch template file',\n input: {\n url: './skeleton.txt',\n targetPath: './target/skeleton.txt',\n values: {\n name: 'test-project',\n count: 1234,\n itemList: ['first', 'second', 'third'],\n },\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,wDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,qBAAA;AAAA,UACR,EAAA,EAAI,qBAAA;AAAA,UACJ,IAAA,EAAM,qBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,GAAA,EAAK,gBAAA;AAAA,YACL,UAAA,EAAY,uBAAA;AAAA,YACZ,MAAA,EAAQ;AAAA,cACN,IAAA,EAAM,cAAA;AAAA,cACN,KAAA,EAAO,IAAA;AAAA,cACP,QAAA,EAAU,CAAC,OAAA,EAAS,QAAA,EAAU,OAAO;AAAA;AACvC;AACF;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateFileActionHandler.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/templateFileActionHandler.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n ActionContext,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport fs from 'fs-extra';\nimport path from 'node:path';\nimport { createTemplateRenderer, TemplateCapabilities } from 'nunjitsu';\nimport { collectActionTemplateCapabilities } from './templateActionHandler';\n\nexport type TemplateFileActionInput = {\n targetPath: string;\n values: any;\n cookiecutterCompat?: boolean;\n replace?: boolean;\n trimBlocks?: boolean;\n lstripBlocks?: boolean;\n};\n\nexport async function createTemplateFileActionHandler<\n I extends TemplateFileActionInput = TemplateFileActionInput,\n>(options: {\n ctx: ActionContext<I, any, any>;\n resolveTemplateFile: () => Promise<string>;\n integrations: ScmIntegrations;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n templateCapabilities?: TemplateCapabilities;\n}) {\n const { resolveTemplateFile, ctx } = options;\n const templateCapabilities =\n options.templateCapabilities ?? collectActionTemplateCapabilities(options);\n\n const outputPath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.targetPath,\n );\n\n if (fs.existsSync(outputPath) && !ctx.input.replace) {\n ctx.logger.info(\n `File ${ctx.input.targetPath} already exists in workspace, not replacing.`,\n );\n return;\n }\n const filePath = await resolveTemplateFile();\n\n const { cookiecutterCompat, values } = ctx.input;\n const context = {\n [cookiecutterCompat ? 'cookiecutter' : 'values']: values,\n };\n\n ctx.logger.info(\n `Processing template file with input values`,\n ctx.input.values,\n );\n\n const templateRenderer = createTemplateRenderer({\n ...templateCapabilities,\n allowRegexExecution: true,\n cookiecutterCompat,\n trimBlocks: ctx.input.trimBlocks,\n lstripBlocks: ctx.input.lstripBlocks,\n });\n\n const contents = await fs.readFile(filePath, 'utf-8');\n const result = templateRenderer.render(contents, context);\n await fs.ensureDir(path.dirname(outputPath));\n await fs.outputFile(outputPath, result);\n\n ctx.logger.info(`Template file has been written to ${outputPath}`);\n}\n"],"names":["collectActionTemplateCapabilities","resolveSafeChildPath","fs","createTemplateRenderer","path"],"mappings":";;;;;;;;;;;;;AAoCA,eAAsB,gCAEpB,OAAA,EAOC;AACD,EAAA,MAAM,EAAE,mBAAA,EAAqB,GAAA,EAAI,GAAI,OAAA;AACrC,EAAA,MAAM,oBAAA,GACJ,OAAA,CAAQ,oBAAA,IAAwBA,uDAAA,CAAkC,OAAO,CAAA;AAE3E,EAAA,MAAM,UAAA,GAAaC,qCAAA;AAAA,IACjB,GAAA,CAAI,aAAA;AAAA,IACJ,IAAI,KAAA,CAAM;AAAA,GACZ;AAEA,EAAA,IAAIC,oBAAG,UAAA,CAAW,UAAU,KAAK,CAAC,GAAA,CAAI,MAAM,OAAA,EAAS;AACnD,IAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,MACT,CAAA,KAAA,EAAQ,GAAA,CAAI,KAAA,CAAM,UAAU,CAAA,4CAAA;AAAA,KAC9B;AACA,IAAA;AAAA,EACF;AACA,EAAA,MAAM,QAAA,GAAW,MAAM,mBAAA,EAAoB;AAE3C,EAAA,MAAM,EAAE,kBAAA,EAAoB,MAAA,EAAO,GAAI,GAAA,CAAI,KAAA;AAC3C,EAAA,MAAM,OAAA,GAAU;AAAA,IACd,CAAC,kBAAA,GAAqB,cAAA,GAAiB,QAAQ,GAAG;AAAA,GACpD;AAEA,EAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,IACT,CAAA,0CAAA,CAAA;AAAA,IACA,IAAI,KAAA,CAAM;AAAA,GACZ;AAEA,EAAA,MAAM,mBAAmBC,+BAAA,CAAuB;AAAA,IAC9C,GAAG,oBAAA;AAAA,IACH,mBAAA,EAAqB,IAAA;AAAA,IACrB,kBAAA;AAAA,IACA,UAAA,EAAY,IAAI,KAAA,CAAM,UAAA;AAAA,IACtB,YAAA,EAAc,IAAI,KAAA,CAAM;AAAA,GACzB,CAAA;AAED,EAAA,MAAM,QAAA,GAAW,MAAMD,mBAAA,CAAG,QAAA,CAAS,UAAU,OAAO,CAAA;AACpD,EAAA,MAAM,MAAA,GAAS,gBAAA,CAAiB,MAAA,CAAO,QAAA,EAAU,OAAO,CAAA;AACxD,EAAA,MAAMA,mBAAA,CAAG,SAAA,CAAUE,qBAAA,CAAK,OAAA,CAAQ,UAAU,CAAC,CAAA;AAC3C,EAAA,MAAMF,mBAAA,CAAG,UAAA,CAAW,UAAA,EAAY,MAAM,CAAA;AAEtC,EAAA,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,CAAA,kCAAA,EAAqC,UAAU,CAAA,CAAE,CAAA;AACnE
|
|
1
|
+
{"version":3,"file":"templateFileActionHandler.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/templateFileActionHandler.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n ActionContext,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport fs from 'fs-extra';\nimport path from 'node:path';\nimport { createTemplateRenderer, TemplateCapabilities } from 'nunjitsu';\nimport { collectActionTemplateCapabilities } from './templateActionHandler';\n\nexport type TemplateFileActionInput = {\n targetPath: string;\n values: any;\n cookiecutterCompat?: boolean;\n replace?: boolean;\n trimBlocks?: boolean;\n lstripBlocks?: boolean;\n};\n\nexport async function createTemplateFileActionHandler<\n I extends TemplateFileActionInput = TemplateFileActionInput,\n>(options: {\n ctx: ActionContext<I, any, any>;\n resolveTemplateFile: () => Promise<string>;\n integrations: ScmIntegrations;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n templateCapabilities?: TemplateCapabilities;\n}) {\n const { resolveTemplateFile, ctx } = options;\n const templateCapabilities =\n options.templateCapabilities ?? collectActionTemplateCapabilities(options);\n\n const outputPath = resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input.targetPath,\n );\n\n if (fs.existsSync(outputPath) && !ctx.input.replace) {\n ctx.logger.info(\n `File ${ctx.input.targetPath} already exists in workspace, not replacing.`,\n );\n return;\n }\n const filePath = await resolveTemplateFile();\n\n const { cookiecutterCompat, values } = ctx.input;\n const context = {\n [cookiecutterCompat ? 'cookiecutter' : 'values']: values,\n };\n\n ctx.logger.info(\n `Processing template file with input values`,\n ctx.input.values,\n );\n\n const templateRenderer = createTemplateRenderer({\n ...templateCapabilities,\n allowRegexExecution: true,\n cookiecutterCompat,\n trimBlocks: ctx.input.trimBlocks,\n lstripBlocks: ctx.input.lstripBlocks,\n });\n\n const contents = await fs.readFile(filePath, 'utf-8');\n const result = templateRenderer.render(contents, context);\n await fs.ensureDir(path.dirname(outputPath));\n await fs.outputFile(outputPath, result);\n\n ctx.logger.info(`Template file has been written to ${outputPath}`);\n}\n"],"names":["collectActionTemplateCapabilities","resolveSafeChildPath","fs","createTemplateRenderer","path"],"mappings":";;;;;;;;;;;;;AAoCA,eAAsB,gCAEpB,OAAA,EAOC;AACD,EAAA,MAAM,EAAE,mBAAA,EAAqB,GAAA,EAAI,GAAI,OAAA;AACrC,EAAA,MAAM,oBAAA,GACJ,OAA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AMF,mBAAA,CAAG,UAAA,CAAW,UAAA,EAAY,MAAM,CAAA;AAEtC,EAAA,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,CAAA,kCAAA,EAAqC,UAAU,CAAA,CAAE,CAAA;AACnE;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspaceTemplate.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/workspaceTemplate.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n createTemplateAction,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './template.examples';\nimport {\n collectActionTemplateCapabilities,\n createTemplateActionHandler,\n} from './templateActionHandler';\n\n/**\n * Templates variables into file and directory names and content of 'sourcePath' in the action context workspace.\n * Then places the result into a subdirectory of the workspace specified by the 'targetPath' input option.\n *\n * @public\n */\nexport function createWorkspaceTemplateAction(options: {\n integrations: ScmIntegrations;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n}) {\n const templateCapabilities = collectActionTemplateCapabilities(options);\n\n return createTemplateAction({\n id: 'workspace:template',\n description:\n 'Templates variables into file and directory names and content of `sourcePath` in the action context workspace. Then places the result into a subdirectory of the workspace specified by the `targetPath` input option.',\n examples,\n schema: {\n input: {\n sourcePath: z =>\n z\n .string()\n .describe(\n 'Path within the working directory denoting source template.',\n ),\n targetPath: z =>\n z\n .string()\n .describe(\n 'Target path within the working directory to download the contents to; must not overlap `sourcePath`.',\n ),\n values: z =>\n z\n .record(z.any())\n .optional()\n .describe('Values to pass to the templating engine.'),\n copyWithoutTemplating: z =>\n z\n .array(z.string())\n .describe(\n 'An array of glob patterns. Contents of matched files or directories are copied without being processed, but paths are subject to rendering.',\n ),\n cookiecutterCompat: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'Enable features to maximise compatibility with templates built for fetch:cookiecutter',\n ),\n templateFileExtension: z =>\n z\n .string()\n .or(z.boolean())\n .optional()\n .describe(\n 'If set, only files with the given extension will be templated. If set to `true`, the default extension `.njk` is used.',\n ),\n replace: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'If set, replace files in targetPath instead of skipping existing ones.',\n ),\n },\n },\n supportsDryRun: true,\n handler: ctx =>\n createTemplateActionHandler({\n ctx,\n resolveTemplate: async () =>\n resolveSafeChildPath(ctx.workspacePath, ctx.input.sourcePath),\n ...options,\n templateCapabilities,\n }),\n });\n}\n"],"names":["collectActionTemplateCapabilities","createTemplateAction","examples","createTemplateActionHandler","resolveSafeChildPath"],"mappings":";;;;;;;AAmCO,SAAS,8BAA8B,OAAA,EAI3C;AACD,EAAA,MAAM,oBAAA,GAAuBA,wDAAkC,OAAO,CAAA;AAEtE,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,oBAAA;AAAA,IACJ,WAAA,EACE,wNAAA;AAAA,cACFC,0BAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,MAAA,EAAO,CACP,QAAA;AAAA,UACC;AAAA,SACF;AAAA,QACJ,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,MAAA,EAAO,CACP,QAAA;AAAA,UACC;AAAA,SACF;AAAA,QACJ,MAAA,EAAQ,CAAA,CAAA,KACN,CAAA,CACG,MAAA,CAAO,CAAA,CAAE,GAAA,EAAK,CAAA,CACd,QAAA,EAAS,CACT,QAAA,CAAS,0CAA0C,CAAA;AAAA,QACxD,uBAAuB,CAAA,CAAA,KACrB,CAAA,CACG,MAAM,CAAA,CAAE,MAAA,EAAQ,CAAA,CAChB,QAAA;AAAA,UACC;AAAA,SACF;AAAA,QACJ,oBAAoB,CAAA,CAAA,KAClB,CAAA,CACG,OAAA,EAAQ,CACR,UAAS,CACT,QAAA;AAAA,UACC;AAAA,SACF;AAAA,QACJ,qBAAA,EAAuB,CAAA,CAAA,KACrB,CAAA,CACG,MAAA,EAAO,CACP,EAAA,CAAG,CAAA,CAAE,OAAA,EAAS,CAAA,CACd,QAAA,EAAS,CACT,QAAA;AAAA,UACC;AAAA,SACF;AAAA,QACJ,SAAS,CAAA,CAAA,KACP,CAAA,CACG,OAAA,EAAQ,CACR,UAAS,CACT,QAAA;AAAA,UACC;AAAA;AACF;AACN,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,OAAA,EAAS,SACPC,iDAAA,CAA4B;AAAA,MAC1B,GAAA;AAAA,MACA,iBAAiB,YACfC,qCAAA,CAAqB,IAAI,aAAA,EAAe,GAAA,CAAI,MAAM,UAAU,CAAA;AAAA,MAC9D,GAAG,OAAA;AAAA,MACH;AAAA,KACD;AAAA,GACJ,CAAA;AACH
|
|
1
|
+
{"version":3,"file":"workspaceTemplate.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/workspaceTemplate.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n createTemplateAction,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './template.examples';\nimport {\n collectActionTemplateCapabilities,\n createTemplateActionHandler,\n} from './templateActionHandler';\n\n/**\n * Templates variables into file and directory names and content of 'sourcePath' in the action context workspace.\n * Then places the result into a subdirectory of the workspace specified by the 'targetPath' input option.\n *\n * @public\n */\nexport function createWorkspaceTemplateAction(options: {\n integrations: ScmIntegrations;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n}) {\n const templateCapabilities = collectActionTemplateCapabilities(options);\n\n return createTemplateAction({\n id: 'workspace:template',\n description:\n 'Templates variables into file and directory names and content of `sourcePath` in the action context workspace. Then places the result into a subdirectory of the workspace specified by the `targetPath` input option.',\n examples,\n schema: {\n input: {\n sourcePath: z =>\n z\n .string()\n .describe(\n 'Path within the working directory denoting source template.',\n ),\n targetPath: z =>\n z\n .string()\n .describe(\n 'Target path within the working directory to download the contents to; must not overlap `sourcePath`.',\n ),\n values: z =>\n z\n .record(z.any())\n .optional()\n .describe('Values to pass to the templating engine.'),\n copyWithoutTemplating: z =>\n z\n .array(z.string())\n .describe(\n 'An array of glob patterns. Contents of matched files or directories are copied without being processed, but paths are subject to rendering.',\n ),\n cookiecutterCompat: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'Enable features to maximise compatibility with templates built for fetch:cookiecutter',\n ),\n templateFileExtension: z =>\n z\n .string()\n .or(z.boolean())\n .optional()\n .describe(\n 'If set, only files with the given extension will be templated. If set to `true`, the default extension `.njk` is used.',\n ),\n replace: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'If set, replace files in targetPath instead of skipping existing ones.',\n ),\n },\n },\n supportsDryRun: true,\n handler: ctx =>\n createTemplateActionHandler({\n ctx,\n resolveTemplate: async () =>\n resolveSafeChildPath(ctx.workspacePath, ctx.input.sourcePath),\n ...options,\n templateCapabilities,\n }),\n });\n}\n"],"names":["collectActionTemplateCapabilities","createTemplateAction","examples","createTemplateActionHandler","resolveSafeChildPath"],"mappings":";;;;;;;AAmCO,SAAS,8BAA8B,OAAA,EAI3C;AACD,EAAA,MAAM,oBAAA,GAAuBA,wDAAkC,OAAO,CAAA;AAEtE,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,oBAAA;AAAA,IACJ,WAAA,EACE,wNAAA;AAAA,cACFC,0BAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,MAAA,EAAO,CACP,QAAA;AAAA,UACC;AAAA,SACF;AAAA,QACJ,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,MAAA,EAAO,CACP,QAAA;AAAA,UACC;AAAA,SACF;AAAA,QACJ,MAAA,EAAQ,CAAA,CAAA,KACN,CAAA,CACG,MAAA,CAAO,CAAA,CAAE,GAAA,EAAK,CAAA,CACd,QAAA,EAAS,CACT,QAAA,CAAS,0CAA0C,CAAA;AAAA,QACxD,uBAAuB,CAAA,CAAA,KACrB,CAAA,CACG,MAAM,CAAA,CAAE,MAAA,EAAQ,CAAA,CAChB,QAAA;AAAA,UACC;AAAA,SACF;AAAA,QACJ,oBAAoB,CAAA,CAAA,KAClB,CAAA,CACG,OAAA,EAAQ,CACR,UAAS,CACT,QAAA;AAAA,UACC;AAAA,SACF;AAAA,QACJ,qBAAA,EAAuB,CAAA,CAAA,KACrB,CAAA,CACG,MAAA,EAAO,CACP,EAAA,CAAG,CAAA,CAAE,OAAA,EAAS,CAAA,CACd,QAAA,EAAS,CACT,QAAA;AAAA,UACC;AAAA,SACF;AAAA,QACJ,SAAS,CAAA,CAAA,KACP,CAAA,CACG,OAAA,EAAQ,CACR,UAAS,CACT,QAAA;AAAA,UACC;AAAA;AACF;AACN,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,OAAA,EAAS,SACPC,iDAAA,CAA4B;AAAA,MAC1B,GAAA;AAAA,MACA,iBAAiB,YACfC,qCAAA,CAAqB,IAAI,aAAA,EAAe,GAAA,CAAI,MAAM,UAAU,CAAA;AAAA,MAC9D,GAAG,OAAA;AAAA,MACH;AAAA,KACD;AAAA,GACJ,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspaceTemplateFile.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/workspaceTemplateFile.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n createTemplateAction,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './templateFile.examples';\nimport { createTemplateFileActionHandler } from './templateFileActionHandler';\nimport { collectActionTemplateCapabilities } from './templateActionHandler';\n\n/**\n * Templates variables into a single workspace file, placing the result into another location in the workspace.\n * @public\n */\nexport function createWorkspaceTemplateFileAction(options: {\n integrations: ScmIntegrations;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n}) {\n const templateCapabilities = collectActionTemplateCapabilities(options);\n\n return createTemplateAction({\n id: 'workspace:template:file',\n description:\n 'Templates variables into a single workspace file, placing the result into another location in the workspace.',\n examples,\n schema: {\n input: {\n sourcePath: z =>\n z.string().describe('Path in workspace to source file.'),\n targetPath: z => z.string().describe('Target path in workspace.'),\n values: z =>\n z\n .record(z.any())\n .optional()\n .describe('Values to pass to the templating engine.'),\n cookiecutterCompat: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'Enable features to maximise compatibility with templates built for fetch:cookiecutter',\n ),\n replace: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'If set, replace files in targetPath instead of skipping existing ones.',\n ),\n },\n },\n supportsDryRun: true,\n handler: ctx =>\n createTemplateFileActionHandler({\n ctx,\n resolveTemplateFile: async () =>\n resolveSafeChildPath(ctx.workspacePath, ctx.input.sourcePath),\n ...options,\n templateCapabilities,\n }),\n });\n}\n"],"names":["collectActionTemplateCapabilities","createTemplateAction","examples","createTemplateFileActionHandler","resolveSafeChildPath"],"mappings":";;;;;;;;AA+BO,SAAS,kCAAkC,OAAA,EAI/C;AACD,EAAA,MAAM,oBAAA,GAAuBA,wDAAkC,OAAO,CAAA;AAEtE,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,yBAAA;AAAA,IACJ,WAAA,EACE,8GAAA;AAAA,cACFC,8BAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,YAAY,CAAA,CAAA,KACV,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,mCAAmC,CAAA;AAAA,QACzD,YAAY,CAAA,CAAA,KAAK,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,2BAA2B,CAAA;AAAA,QAChE,MAAA,EAAQ,CAAA,CAAA,KACN,CAAA,CACG,MAAA,CAAO,CAAA,CAAE,GAAA,EAAK,CAAA,CACd,QAAA,EAAS,CACT,QAAA,CAAS,0CAA0C,CAAA;AAAA,QACxD,oBAAoB,CAAA,CAAA,KAClB,CAAA,CACG,OAAA,EAAQ,CACR,UAAS,CACT,QAAA;AAAA,UACC;AAAA,SACF;AAAA,QACJ,SAAS,CAAA,CAAA,KACP,CAAA,CACG,OAAA,EAAQ,CACR,UAAS,CACT,QAAA;AAAA,UACC;AAAA;AACF;AACN,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,OAAA,EAAS,SACPC,yDAAA,CAAgC;AAAA,MAC9B,GAAA;AAAA,MACA,qBAAqB,YACnBC,qCAAA,CAAqB,IAAI,aAAA,EAAe,GAAA,CAAI,MAAM,UAAU,CAAA;AAAA,MAC9D,GAAG,OAAA;AAAA,MACH;AAAA,KACD;AAAA,GACJ,CAAA;AACH
|
|
1
|
+
{"version":3,"file":"workspaceTemplateFile.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/fetch/workspaceTemplateFile.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n createTemplateAction,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './templateFile.examples';\nimport { createTemplateFileActionHandler } from './templateFileActionHandler';\nimport { collectActionTemplateCapabilities } from './templateActionHandler';\n\n/**\n * Templates variables into a single workspace file, placing the result into another location in the workspace.\n * @public\n */\nexport function createWorkspaceTemplateFileAction(options: {\n integrations: ScmIntegrations;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n}) {\n const templateCapabilities = collectActionTemplateCapabilities(options);\n\n return createTemplateAction({\n id: 'workspace:template:file',\n description:\n 'Templates variables into a single workspace file, placing the result into another location in the workspace.',\n examples,\n schema: {\n input: {\n sourcePath: z =>\n z.string().describe('Path in workspace to source file.'),\n targetPath: z => z.string().describe('Target path in workspace.'),\n values: z =>\n z\n .record(z.any())\n .optional()\n .describe('Values to pass to the templating engine.'),\n cookiecutterCompat: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'Enable features to maximise compatibility with templates built for fetch:cookiecutter',\n ),\n replace: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'If set, replace files in targetPath instead of skipping existing ones.',\n ),\n },\n },\n supportsDryRun: true,\n handler: ctx =>\n createTemplateFileActionHandler({\n ctx,\n resolveTemplateFile: async () =>\n resolveSafeChildPath(ctx.workspacePath, ctx.input.sourcePath),\n ...options,\n templateCapabilities,\n }),\n });\n}\n"],"names":["collectActionTemplateCapabilities","createTemplateAction","examples","createTemplateFileActionHandler","resolveSafeChildPath"],"mappings":";;;;;;;;AA+BO,SAAS,kCAAkC,OAAA,EAI/C;AACD,EAAA,MAAM,oBAAA,GAAuBA,wDAAkC,OAAO,CAAA;AAEtE,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,yBAAA;AAAA,IACJ,WAAA,EACE,8GAAA;AAAA,cACFC,8BAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,YAAY,CAAA,CAAA,KACV,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,mCAAmC,CAAA;AAAA,QACzD,YAAY,CAAA,CAAA,KAAK,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,2BAA2B,CAAA;AAAA,QAChE,MAAA,EAAQ,CAAA,CAAA,KACN,CAAA,CACG,MAAA,CAAO,CAAA,CAAE,GAAA,EAAK,CAAA,CACd,QAAA,EAAS,CACT,QAAA,CAAS,0CAA0C,CAAA;AAAA,QACxD,oBAAoB,CAAA,CAAA,KAClB,CAAA,CACG,OAAA,EAAQ,CACR,UAAS,CACT,QAAA;AAAA,UACC;AAAA,SACF;AAAA,QACJ,SAAS,CAAA,CAAA,KACP,CAAA,CACG,OAAA,EAAQ,CACR,UAAS,CACT,QAAA;AAAA,UACC;AAAA;AACF;AACN,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,OAAA,EAAS,SACPC,yDAAA,CAAgC;AAAA,MAC9B,GAAA;AAAA,MACA,qBAAqB,YACnBC,qCAAA,CAAqB,IAAI,aAAA,EAAe,GAAA,CAAI,MAAM,UAAU,CAAA;AAAA,MAC9D,GAAG,OAAA;AAAA,MACH;AAAA,KACD;AAAA,GACJ,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/filesystem/delete.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport fs from 'fs-extra';\nimport globby from 'globby';\nimport { examples } from './delete.examples';\n\n/**\n * Creates new action that enables deletion of files and directories in the workspace.\n * @public\n */\nexport const createFilesystemDeleteAction = () => {\n return createTemplateAction({\n id: 'fs:delete',\n description: 'Deletes files and directories from the workspace',\n examples,\n schema: {\n input: {\n files: z =>\n z.array(z.string(), {\n description: 'A list of files and directories that will be deleted',\n }),\n },\n },\n supportsDryRun: true,\n async handler(ctx) {\n if (!Array.isArray(ctx.input?.files)) {\n throw new InputError('files must be an Array');\n }\n\n for (const file of ctx.input.files) {\n // globby cannot handle backslash file separators\n const safeFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n file,\n ).replace(/\\\\/g, '/');\n const resolvedPaths = await globby(safeFilepath, {\n cwd: ctx.workspacePath,\n absolute: true,\n dot: true,\n });\n\n for (const filepath of resolvedPaths) {\n try {\n const safePath = resolveSafeChildPath(ctx.workspacePath, filepath);\n await fs.remove(safePath);\n ctx.logger.info(`File ${safePath} deleted successfully`);\n } catch (err) {\n ctx.logger.error(`Failed to delete file`, err);\n throw err;\n }\n }\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","InputError","resolveSafeChildPath","globby","fs"],"mappings":";;;;;;;;;;;;;;AA2BO,MAAM,+BAA+B,MAAM;AAChD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,WAAA;AAAA,IACJ,WAAA,EAAa,kDAAA;AAAA,cACbC,wBAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAO,CAAA,CAAA,KACL,CAAA,CAAE,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UAClB,WAAA,EAAa;AAAA,SACd;AAAA;AACL,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,GAAA,CAAI,KAAA,EAAO,KAAK,CAAA,EAAG;AACpC,QAAA,MAAM,IAAIC,kBAAW,wBAAwB,CAAA;AAAA,MAC/C;AAEA,MAAA,KAAA,MAAW,IAAA,IAAQ,GAAA,CAAI,KAAA,CAAM,KAAA,EAAO;AAElC,QAAA,MAAM,YAAA,GAAeC,qCAAA;AAAA,UACnB,GAAA,CAAI,aAAA;AAAA,UACJ;AAAA,SACF,CAAE,OAAA,CAAQ,KAAA,EAAO,GAAG,CAAA;AACpB,QAAA,MAAM,aAAA,GAAgB,MAAMC,uBAAA,CAAO,YAAA,EAAc;AAAA,UAC/C,KAAK,GAAA,CAAI,aAAA;AAAA,UACT,QAAA,EAAU,IAAA;AAAA,UACV,GAAA,EAAK;AAAA,SACN,CAAA;AAED,QAAA,KAAA,MAAW,YAAY,aAAA,EAAe;AACpC,UAAA,IAAI;AACF,YAAA,MAAM,QAAA,GAAWD,qCAAA,CAAqB,GAAA,CAAI,aAAA,EAAe,QAAQ,CAAA;AACjE,YAAA,MAAME,mBAAA,CAAG,OAAO,QAAQ,CAAA;AACxB,YAAA,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,CAAA,KAAA,EAAQ,QAAQ,CAAA,qBAAA,CAAuB,CAAA;AAAA,UACzD,SAAS,GAAA,EAAK;AACZ,YAAA,GAAA,CAAI,MAAA,CAAO,KAAA,CAAM,CAAA,qBAAA,CAAA,EAAyB,GAAG,CAAA;AAC7C,YAAA,MAAM,GAAA;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH
|
|
1
|
+
{"version":3,"file":"delete.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/filesystem/delete.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport fs from 'fs-extra';\nimport globby from 'globby';\nimport { examples } from './delete.examples';\n\n/**\n * Creates new action that enables deletion of files and directories in the workspace.\n * @public\n */\nexport const createFilesystemDeleteAction = () => {\n return createTemplateAction({\n id: 'fs:delete',\n description: 'Deletes files and directories from the workspace',\n examples,\n schema: {\n input: {\n files: z =>\n z.array(z.string(), {\n description: 'A list of files and directories that will be deleted',\n }),\n },\n },\n supportsDryRun: true,\n async handler(ctx) {\n if (!Array.isArray(ctx.input?.files)) {\n throw new InputError('files must be an Array');\n }\n\n for (const file of ctx.input.files) {\n // globby cannot handle backslash file separators\n const safeFilepath = resolveSafeChildPath(\n ctx.workspacePath,\n file,\n ).replace(/\\\\/g, '/');\n const resolvedPaths = await globby(safeFilepath, {\n cwd: ctx.workspacePath,\n absolute: true,\n dot: true,\n });\n\n for (const filepath of resolvedPaths) {\n try {\n const safePath = resolveSafeChildPath(ctx.workspacePath, filepath);\n await fs.remove(safePath);\n ctx.logger.info(`File ${safePath} deleted successfully`);\n } catch (err) {\n ctx.logger.error(`Failed to delete file`, err);\n throw err;\n }\n }\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","InputError","resolveSafeChildPath","globby","fs"],"mappings":";;;;;;;;;;;;;;AA2BO,MAAM,+BAA+B,MAAM;AAChD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,WAAA;AAAA,IACJ,WAAA,EAAa,kDAAA;AAAA,cACbC,wBAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAO,CAAA,CAAA,KACL,CAAA,CAAE,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UAClB,WAAA,EAAa;AAAA,SACd;AAAA;AACL,KACF;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,GAAA,CAAI,KAAA,EAAO,KAAK,CAAA,EAAG;AACpC,QAAA,MAAM,IAAIC,kBAAW,wBAAwB,CAAA;AAAA,MAC/C;AAEA,MAAA,KAAA,MAAW,IAAA,IAAQ,GAAA,CAAI,KAAA,CAAM,KAAA,EAAO;AAElC,QAAA,MAAM,YAAA,GAAeC,qCAAA;AAAA,UACnB,GAAA,CAAI,aAAA;AAAA,UACJ;AAAA,SACF,CAAE,OAA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