@backstage/plugin-scaffolder-backend 2.2.0-next.1 → 2.2.1-next.0

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/ScaffolderPlugin.cjs.js.map +1 -1
  3. package/dist/lib/templating/SecureTemplater.cjs.js.map +1 -1
  4. package/dist/lib/templating/filters/createDefaultFilters.cjs.js.map +1 -1
  5. package/dist/lib/templating/filters/parseEntityRef/examples.cjs.js.map +1 -1
  6. package/dist/lib/templating/filters/parseEntityRef/filter.cjs.js.map +1 -1
  7. package/dist/lib/templating/filters/parseRepoUrl/examples.cjs.js.map +1 -1
  8. package/dist/lib/templating/filters/parseRepoUrl/filter.cjs.js.map +1 -1
  9. package/dist/lib/templating/filters/pick/examples.cjs.js.map +1 -1
  10. package/dist/lib/templating/filters/pick/filter.cjs.js.map +1 -1
  11. package/dist/lib/templating/filters/projectSlug/examples.cjs.js.map +1 -1
  12. package/dist/lib/templating/filters/projectSlug/filter.cjs.js.map +1 -1
  13. package/dist/lib/templating/helpers.cjs.js.map +1 -1
  14. package/dist/scaffolder/actions/TemplateActionRegistry.cjs.js.map +1 -1
  15. package/dist/scaffolder/actions/builtin/catalog/fetch.cjs.js.map +1 -1
  16. package/dist/scaffolder/actions/builtin/catalog/fetch.examples.cjs.js.map +1 -1
  17. package/dist/scaffolder/actions/builtin/catalog/register.cjs.js.map +1 -1
  18. package/dist/scaffolder/actions/builtin/catalog/register.examples.cjs.js.map +1 -1
  19. package/dist/scaffolder/actions/builtin/catalog/write.cjs.js.map +1 -1
  20. package/dist/scaffolder/actions/builtin/catalog/write.examples.cjs.js.map +1 -1
  21. package/dist/scaffolder/actions/builtin/debug/log.cjs.js.map +1 -1
  22. package/dist/scaffolder/actions/builtin/debug/log.examples.cjs.js.map +1 -1
  23. package/dist/scaffolder/actions/builtin/debug/wait.cjs.js.map +1 -1
  24. package/dist/scaffolder/actions/builtin/debug/wait.examples.cjs.js.map +1 -1
  25. package/dist/scaffolder/actions/builtin/fetch/plain.cjs.js.map +1 -1
  26. package/dist/scaffolder/actions/builtin/fetch/plain.examples.cjs.js.map +1 -1
  27. package/dist/scaffolder/actions/builtin/fetch/plainFile.cjs.js.map +1 -1
  28. package/dist/scaffolder/actions/builtin/fetch/plainFile.examples.cjs.js.map +1 -1
  29. package/dist/scaffolder/actions/builtin/fetch/template.cjs.js.map +1 -1
  30. package/dist/scaffolder/actions/builtin/fetch/template.examples.cjs.js.map +1 -1
  31. package/dist/scaffolder/actions/builtin/fetch/templateActionHandler.cjs.js.map +1 -1
  32. package/dist/scaffolder/actions/builtin/fetch/templateFile.cjs.js.map +1 -1
  33. package/dist/scaffolder/actions/builtin/fetch/templateFile.examples.cjs.js.map +1 -1
  34. package/dist/scaffolder/actions/builtin/fetch/templateFileActionHandler.cjs.js.map +1 -1
  35. package/dist/scaffolder/actions/builtin/filesystem/delete.cjs.js.map +1 -1
  36. package/dist/scaffolder/actions/builtin/filesystem/delete.examples.cjs.js.map +1 -1
  37. package/dist/scaffolder/actions/builtin/filesystem/read.cjs.js.map +1 -1
  38. package/dist/scaffolder/actions/builtin/filesystem/read.examples.cjs.js.map +1 -1
  39. package/dist/scaffolder/actions/builtin/filesystem/rename.cjs.js.map +1 -1
  40. package/dist/scaffolder/actions/builtin/filesystem/rename.examples.cjs.js.map +1 -1
  41. package/dist/scaffolder/dryrun/DecoratedActionsRegistry.cjs.js.map +1 -1
  42. package/dist/scaffolder/dryrun/createDryRunner.cjs.js.map +1 -1
  43. package/dist/scaffolder/tasks/DatabaseTaskStore.cjs.js.map +1 -1
  44. package/dist/scaffolder/tasks/DatabaseWorkspaceProvider.cjs.js.map +1 -1
  45. package/dist/scaffolder/tasks/NunjucksWorkflowRunner.cjs.js.map +1 -1
  46. package/dist/scaffolder/tasks/StorageTaskBroker.cjs.js.map +1 -1
  47. package/dist/scaffolder/tasks/TaskWorker.cjs.js.map +1 -1
  48. package/dist/scaffolder/tasks/WorkspaceService.cjs.js.map +1 -1
  49. package/dist/scaffolder/tasks/dbUtil.cjs.js.map +1 -1
  50. package/dist/scaffolder/tasks/helper.cjs.js.map +1 -1
  51. package/dist/scaffolder/tasks/logger.cjs.js +5 -6
  52. package/dist/scaffolder/tasks/logger.cjs.js.map +1 -1
  53. package/dist/scaffolder/tasks/taskRecoveryHelper.cjs.js.map +1 -1
  54. package/dist/schema/openapi/generated/router.cjs.js.map +1 -1
  55. package/dist/service/alpha.cjs.js.map +1 -1
  56. package/dist/service/helpers.cjs.js.map +1 -1
  57. package/dist/service/permissions.cjs.js.map +1 -1
  58. package/dist/service/router.cjs.js +8 -1
  59. package/dist/service/router.cjs.js.map +1 -1
  60. package/dist/service/rules.cjs.js.map +1 -1
  61. package/dist/util/checkPermissions.cjs.js.map +1 -1
  62. package/dist/util/loggerToWinstonLogger.cjs.js.map +1 -1
  63. package/dist/util/metrics.cjs.js.map +1 -1
  64. package/dist/util/templating.cjs.js.map +1 -1
  65. package/package.json +27 -27
package/CHANGELOG.md CHANGED
@@ -1,5 +1,65 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 2.2.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/integration@1.18.0-next.0
9
+ - @backstage/plugin-scaffolder-backend-module-gitlab@0.9.5-next.0
10
+ - @backstage/plugin-auth-node@0.6.7-next.0
11
+ - @backstage/backend-defaults@0.12.1-next.0
12
+ - @backstage/plugin-bitbucket-cloud-common@0.3.2-next.0
13
+ - @backstage/plugin-scaffolder-backend-module-azure@0.2.13-next.0
14
+ - @backstage/plugin-scaffolder-backend-module-bitbucket@0.3.14-next.0
15
+ - @backstage/plugin-scaffolder-backend-module-bitbucket-cloud@0.2.13-next.0
16
+ - @backstage/plugin-scaffolder-backend-module-bitbucket-server@0.2.13-next.0
17
+ - @backstage/plugin-scaffolder-backend-module-gerrit@0.2.13-next.0
18
+ - @backstage/plugin-scaffolder-backend-module-gitea@0.2.13-next.0
19
+ - @backstage/plugin-scaffolder-backend-module-github@0.8.3-next.0
20
+ - @backstage/plugin-scaffolder-common@1.7.1-next.0
21
+ - @backstage/plugin-scaffolder-node@0.11.1-next.0
22
+ - @backstage/backend-plugin-api@1.4.3-next.0
23
+ - @backstage/plugin-permission-node@0.10.4-next.0
24
+ - @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.2.12-next.0
25
+ - @backstage/backend-openapi-utils@0.6.1-next.0
26
+ - @backstage/plugin-catalog-node@1.18.1-next.0
27
+ - @backstage/plugin-events-node@0.4.15-next.0
28
+
29
+ ## 2.2.0
30
+
31
+ ### Minor Changes
32
+
33
+ - c08cbc4: Move Scaffolder API to OpenAPI
34
+ - 2032660: Fixed fs:readdir action example
35
+ - 11dc90f: Implement max length for scaffolder auditor audit logging with default of 256
36
+ - 812485c: Add step info to scaffolder action context to access the step id and name.
37
+
38
+ ### Patch Changes
39
+
40
+ - caee2eb: Fixed WinstonLogger throwing when redactions were null or undefined
41
+ - 4ae87f5: add `getResources` method to `permissionIntegrationRouter` for frontend task permission checks
42
+ - b817c1d: Stop logging of `SPLAT` twice in logs
43
+ - Updated dependencies
44
+ - @backstage/backend-openapi-utils@0.6.0
45
+ - @backstage/backend-defaults@0.12.0
46
+ - @backstage/plugin-scaffolder-common@1.7.0
47
+ - @backstage/plugin-scaffolder-node@0.11.0
48
+ - @backstage/plugin-scaffolder-backend-module-gitlab@0.9.4
49
+ - @backstage/plugin-catalog-node@1.18.0
50
+ - @backstage/plugin-scaffolder-backend-module-github@0.8.2
51
+ - @backstage/plugin-auth-node@0.6.6
52
+ - @backstage/plugin-permission-node@0.10.3
53
+ - @backstage/backend-plugin-api@1.4.2
54
+ - @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.2.11
55
+ - @backstage/plugin-events-node@0.4.14
56
+ - @backstage/plugin-scaffolder-backend-module-azure@0.2.12
57
+ - @backstage/plugin-scaffolder-backend-module-bitbucket@0.3.13
58
+ - @backstage/plugin-scaffolder-backend-module-bitbucket-cloud@0.2.12
59
+ - @backstage/plugin-scaffolder-backend-module-bitbucket-server@0.2.12
60
+ - @backstage/plugin-scaffolder-backend-module-gerrit@0.2.12
61
+ - @backstage/plugin-scaffolder-backend-module-gitea@0.2.12
62
+
3
63
  ## 2.2.0-next.1
4
64
 
5
65
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"ScaffolderPlugin.cjs.js","sources":["../src/ScaffolderPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\nimport { eventsServiceRef } from '@backstage/plugin-events-node';\nimport { TaskBroker, TemplateAction } from '@backstage/plugin-scaffolder-node';\nimport {\n AutocompleteHandler,\n CreatedTemplateFilter,\n CreatedTemplateGlobal,\n createTemplateFilter,\n createTemplateGlobalFunction,\n createTemplateGlobalValue,\n scaffolderActionsExtensionPoint,\n scaffolderAutocompleteExtensionPoint,\n scaffolderTaskBrokerExtensionPoint,\n scaffolderTemplatingExtensionPoint,\n scaffolderWorkspaceProviderExtensionPoint,\n WorkspaceProvider,\n} from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createCatalogRegisterAction,\n createCatalogWriteAction,\n createDebugLogAction,\n createFetchCatalogEntityAction,\n createFetchPlainAction,\n createFetchPlainFileAction,\n createFetchTemplateAction,\n createFetchTemplateFileAction,\n createFilesystemDeleteAction,\n createFilesystemReadDirAction,\n createFilesystemRenameAction,\n createWaitAction,\n} from './scaffolder';\nimport { createRouter } from './service/router';\nimport { loggerToWinstonLogger } from './util/loggerToWinstonLogger';\nimport {\n convertFiltersToRecord,\n convertGlobalsToRecord,\n} from './util/templating';\n\n/**\n * Scaffolder plugin\n *\n * @public\n */\nexport const scaffolderPlugin = createBackendPlugin({\n pluginId: 'scaffolder',\n register(env) {\n const addedActions = new Array<TemplateAction<any, any>>();\n env.registerExtensionPoint(scaffolderActionsExtensionPoint, {\n addActions(...newActions: TemplateAction<any>[]) {\n addedActions.push(...newActions);\n },\n });\n\n let taskBroker: TaskBroker | undefined;\n env.registerExtensionPoint(scaffolderTaskBrokerExtensionPoint, {\n setTaskBroker(newTaskBroker) {\n if (taskBroker) {\n throw new Error('Task broker may only be set once');\n }\n taskBroker = newTaskBroker;\n },\n });\n\n const additionalTemplateFilters: CreatedTemplateFilter<any, any>[] = [];\n const additionalTemplateGlobals: CreatedTemplateGlobal[] = [];\n\n env.registerExtensionPoint(scaffolderTemplatingExtensionPoint, {\n addTemplateFilters(newFilters) {\n additionalTemplateFilters.push(\n ...(Array.isArray(newFilters)\n ? newFilters\n : Object.entries(newFilters).map(([id, filter]) =>\n createTemplateFilter({\n id,\n filter,\n }),\n )),\n );\n },\n addTemplateGlobals(newGlobals) {\n additionalTemplateGlobals.push(\n ...(Array.isArray(newGlobals)\n ? newGlobals\n : Object.entries(newGlobals).map(([id, global]) =>\n typeof global === 'function'\n ? createTemplateGlobalFunction({ id, fn: global })\n : createTemplateGlobalValue({ id, value: global }),\n )),\n );\n },\n });\n\n const autocompleteHandlers: Record<string, AutocompleteHandler> = {};\n env.registerExtensionPoint(scaffolderAutocompleteExtensionPoint, {\n addAutocompleteProvider(provider) {\n autocompleteHandlers[provider.id] = provider.handler;\n },\n });\n\n const additionalWorkspaceProviders: Record<string, WorkspaceProvider> = {};\n env.registerExtensionPoint(scaffolderWorkspaceProviderExtensionPoint, {\n addProviders(provider) {\n Object.assign(additionalWorkspaceProviders, provider);\n },\n });\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n lifecycle: coreServices.rootLifecycle,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n auth: coreServices.auth,\n httpRouter: coreServices.httpRouter,\n httpAuth: coreServices.httpAuth,\n auditor: coreServices.auditor,\n catalog: catalogServiceRef,\n events: eventsServiceRef,\n },\n async init({\n logger,\n config,\n lifecycle,\n reader,\n database,\n auth,\n httpRouter,\n httpAuth,\n catalog,\n permissions,\n events,\n auditor,\n }) {\n const log = loggerToWinstonLogger(logger);\n const integrations = ScmIntegrations.fromConfig(config);\n\n const templateExtensions = {\n additionalTemplateFilters: convertFiltersToRecord(\n additionalTemplateFilters,\n ),\n additionalTemplateGlobals: convertGlobalsToRecord(\n additionalTemplateGlobals,\n ),\n };\n const actions = [\n // actions provided from other modules\n ...addedActions,\n\n // built-in actions for the scaffolder\n createFetchPlainAction({\n reader,\n integrations,\n }),\n createFetchPlainFileAction({\n reader,\n integrations,\n }),\n createFetchTemplateAction({\n integrations,\n reader,\n ...templateExtensions,\n }),\n createFetchTemplateFileAction({\n integrations,\n reader,\n ...templateExtensions,\n }),\n createDebugLogAction(),\n createWaitAction(),\n // todo(blam): maybe these should be a -catalog module?\n createCatalogRegisterAction({ catalog, integrations }),\n createFetchCatalogEntityAction({ catalog }),\n createCatalogWriteAction(),\n createFilesystemDeleteAction(),\n createFilesystemRenameAction(),\n createFilesystemReadDirAction(),\n ];\n\n const actionIds = actions.map(action => action.id).join(', ');\n\n log.info(\n `Starting scaffolder with the following actions enabled ${actionIds}`,\n );\n\n const router = await createRouter({\n logger,\n config,\n database,\n catalog,\n lifecycle,\n actions,\n taskBroker,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n auth,\n httpAuth,\n permissions,\n autocompleteHandlers,\n additionalWorkspaceProviders,\n events,\n auditor,\n });\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createBackendPlugin","scaffolderActionsExtensionPoint","scaffolderTaskBrokerExtensionPoint","scaffolderTemplatingExtensionPoint","createTemplateFilter","createTemplateGlobalFunction","createTemplateGlobalValue","scaffolderAutocompleteExtensionPoint","scaffolderWorkspaceProviderExtensionPoint","coreServices","catalogServiceRef","eventsServiceRef","log","loggerToWinstonLogger","ScmIntegrations","convertFiltersToRecord","convertGlobalsToRecord","createFetchPlainAction","createFetchPlainFileAction","createFetchTemplateAction","createFetchTemplateFileAction","createDebugLogAction","createWaitAction","createCatalogRegisterAction","createFetchCatalogEntityAction","createCatalogWriteAction","createFilesystemDeleteAction","createFilesystemRenameAction","createFilesystemReadDirAction","router","createRouter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEO,MAAM,mBAAmBA,oCAAoB,CAAA;AAAA,EAClD,QAAU,EAAA,YAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAM,MAAA,YAAA,GAAe,IAAI,KAAgC,EAAA;AACzD,IAAA,GAAA,CAAI,uBAAuBC,qCAAiC,EAAA;AAAA,MAC1D,cAAc,UAAmC,EAAA;AAC/C,QAAa,YAAA,CAAA,IAAA,CAAK,GAAG,UAAU,CAAA;AAAA;AACjC,KACD,CAAA;AAED,IAAI,IAAA,UAAA;AACJ,IAAA,GAAA,CAAI,uBAAuBC,wCAAoC,EAAA;AAAA,MAC7D,cAAc,aAAe,EAAA;AAC3B,QAAA,IAAI,UAAY,EAAA;AACd,UAAM,MAAA,IAAI,MAAM,kCAAkC,CAAA;AAAA;AAEpD,QAAa,UAAA,GAAA,aAAA;AAAA;AACf,KACD,CAAA;AAED,IAAA,MAAM,4BAA+D,EAAC;AACtE,IAAA,MAAM,4BAAqD,EAAC;AAE5D,IAAA,GAAA,CAAI,uBAAuBC,wCAAoC,EAAA;AAAA,MAC7D,mBAAmB,UAAY,EAAA;AAC7B,QAA0B,yBAAA,CAAA,IAAA;AAAA,UACxB,GAAI,MAAM,OAAQ,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,EAAA;AAAA,UACrBC,qBAAiB,EAAA;AAAA;AAAA,UAEjBC,oCAA4B,CAAA,EAAE,OAAS,EAAA,YAAA,EAAc,CAAA;AAAA,UACrDC,oCAAA,CAA+B,EAAE,OAAA,EAAS,CAAA;AAAA,UAC1CC,8BAAyB,EAAA;AAAA,UACzBC,oCAA6B,EAAA;AAAA,UAC7BC,mCAA6B,EAAA;AAAA,UAC7BC,kCAA8B;AAAA,SAChC;AAEA,QAAM,MAAA,SAAA,GAAY,QAAQ,GAAI,CAAA,CAAA,MAAA,KAAU,OAAO,EAAE,CAAA,CAAE,KAAK,IAAI,CAAA;AAE5D,QAAIhB,KAAA,CAAA,IAAA;AAAA,UACF,0DAA0D,SAAS,CAAA;AAAA,SACrE;AAEA,QAAM,MAAAiB,QAAA,GAAS,MAAMC,mBAAa,CAAA;AAAA,UAChC,MAAA;AAAA,UACA,MAAA;AAAA,UACA,QAAA;AAAA,UACA,OAAA;AAAA,UACA,SAAA;AAAA,UACA,OAAA;AAAA,UACA,UAAA;AAAA,UACA,yBAAA;AAAA,UACA,yBAAA;AAAA,UACA,IAAA;AAAA,UACA,QAAA;AAAA,UACA,WAAA;AAAA,UACA,oBAAA;AAAA,UACA,4BAAA;AAAA,UACA,MAAA;AAAA,UACA;AAAA,SACD,CAAA;AACD,QAAA,UAAA,CAAW,IAAID,QAAM,CAAA;AAAA;AACvB,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
1
+ {"version":3,"file":"ScaffolderPlugin.cjs.js","sources":["../src/ScaffolderPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\nimport { eventsServiceRef } from '@backstage/plugin-events-node';\nimport { TaskBroker, TemplateAction } from '@backstage/plugin-scaffolder-node';\nimport {\n AutocompleteHandler,\n CreatedTemplateFilter,\n CreatedTemplateGlobal,\n createTemplateFilter,\n createTemplateGlobalFunction,\n createTemplateGlobalValue,\n scaffolderActionsExtensionPoint,\n scaffolderAutocompleteExtensionPoint,\n scaffolderTaskBrokerExtensionPoint,\n scaffolderTemplatingExtensionPoint,\n scaffolderWorkspaceProviderExtensionPoint,\n WorkspaceProvider,\n} from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createCatalogRegisterAction,\n createCatalogWriteAction,\n createDebugLogAction,\n createFetchCatalogEntityAction,\n createFetchPlainAction,\n createFetchPlainFileAction,\n createFetchTemplateAction,\n createFetchTemplateFileAction,\n createFilesystemDeleteAction,\n createFilesystemReadDirAction,\n createFilesystemRenameAction,\n createWaitAction,\n} from './scaffolder';\nimport { createRouter } from './service/router';\nimport { loggerToWinstonLogger } from './util/loggerToWinstonLogger';\nimport {\n convertFiltersToRecord,\n convertGlobalsToRecord,\n} from './util/templating';\n\n/**\n * Scaffolder plugin\n *\n * @public\n */\nexport const scaffolderPlugin = createBackendPlugin({\n pluginId: 'scaffolder',\n register(env) {\n const addedActions = new Array<TemplateAction<any, any>>();\n env.registerExtensionPoint(scaffolderActionsExtensionPoint, {\n addActions(...newActions: TemplateAction<any>[]) {\n addedActions.push(...newActions);\n },\n });\n\n let taskBroker: TaskBroker | undefined;\n env.registerExtensionPoint(scaffolderTaskBrokerExtensionPoint, {\n setTaskBroker(newTaskBroker) {\n if (taskBroker) {\n throw new Error('Task broker may only be set once');\n }\n taskBroker = newTaskBroker;\n },\n });\n\n const additionalTemplateFilters: CreatedTemplateFilter<any, any>[] = [];\n const additionalTemplateGlobals: CreatedTemplateGlobal[] = [];\n\n env.registerExtensionPoint(scaffolderTemplatingExtensionPoint, {\n addTemplateFilters(newFilters) {\n additionalTemplateFilters.push(\n ...(Array.isArray(newFilters)\n ? newFilters\n : Object.entries(newFilters).map(([id, filter]) =>\n createTemplateFilter({\n id,\n filter,\n }),\n )),\n );\n },\n addTemplateGlobals(newGlobals) {\n additionalTemplateGlobals.push(\n ...(Array.isArray(newGlobals)\n ? newGlobals\n : Object.entries(newGlobals).map(([id, global]) =>\n typeof global === 'function'\n ? createTemplateGlobalFunction({ id, fn: global })\n : createTemplateGlobalValue({ id, value: global }),\n )),\n );\n },\n });\n\n const autocompleteHandlers: Record<string, AutocompleteHandler> = {};\n env.registerExtensionPoint(scaffolderAutocompleteExtensionPoint, {\n addAutocompleteProvider(provider) {\n autocompleteHandlers[provider.id] = provider.handler;\n },\n });\n\n const additionalWorkspaceProviders: Record<string, WorkspaceProvider> = {};\n env.registerExtensionPoint(scaffolderWorkspaceProviderExtensionPoint, {\n addProviders(provider) {\n Object.assign(additionalWorkspaceProviders, provider);\n },\n });\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n lifecycle: coreServices.rootLifecycle,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n auth: coreServices.auth,\n httpRouter: coreServices.httpRouter,\n httpAuth: coreServices.httpAuth,\n auditor: coreServices.auditor,\n catalog: catalogServiceRef,\n events: eventsServiceRef,\n },\n async init({\n logger,\n config,\n lifecycle,\n reader,\n database,\n auth,\n httpRouter,\n httpAuth,\n catalog,\n permissions,\n events,\n auditor,\n }) {\n const log = loggerToWinstonLogger(logger);\n const integrations = ScmIntegrations.fromConfig(config);\n\n const templateExtensions = {\n additionalTemplateFilters: convertFiltersToRecord(\n additionalTemplateFilters,\n ),\n additionalTemplateGlobals: convertGlobalsToRecord(\n additionalTemplateGlobals,\n ),\n };\n const actions = [\n // actions provided from other modules\n ...addedActions,\n\n // built-in actions for the scaffolder\n createFetchPlainAction({\n reader,\n integrations,\n }),\n createFetchPlainFileAction({\n reader,\n integrations,\n }),\n createFetchTemplateAction({\n integrations,\n reader,\n ...templateExtensions,\n }),\n createFetchTemplateFileAction({\n integrations,\n reader,\n ...templateExtensions,\n }),\n createDebugLogAction(),\n createWaitAction(),\n // todo(blam): maybe these should be a -catalog module?\n createCatalogRegisterAction({ catalog, integrations }),\n createFetchCatalogEntityAction({ catalog }),\n createCatalogWriteAction(),\n createFilesystemDeleteAction(),\n createFilesystemRenameAction(),\n createFilesystemReadDirAction(),\n ];\n\n const actionIds = actions.map(action => action.id).join(', ');\n\n log.info(\n `Starting scaffolder with the following actions enabled ${actionIds}`,\n );\n\n const router = await createRouter({\n logger,\n config,\n database,\n catalog,\n lifecycle,\n actions,\n taskBroker,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n auth,\n httpAuth,\n permissions,\n autocompleteHandlers,\n additionalWorkspaceProviders,\n events,\n auditor,\n });\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createBackendPlugin","scaffolderActionsExtensionPoint","scaffolderTaskBrokerExtensionPoint","scaffolderTemplatingExtensionPoint","createTemplateFilter","createTemplateGlobalFunction","createTemplateGlobalValue","scaffolderAutocompleteExtensionPoint","scaffolderWorkspaceProviderExtensionPoint","coreServices","catalogServiceRef","eventsServiceRef","log","loggerToWinstonLogger","ScmIntegrations","convertFiltersToRecord","convertGlobalsToRecord","createFetchPlainAction","createFetchPlainFileAction","createFetchTemplateAction","createFetchTemplateFileAction","createDebugLogAction","createWaitAction","createCatalogRegisterAction","createFetchCatalogEntityAction","createCatalogWriteAction","createFilesystemDeleteAction","createFilesystemRenameAction","createFilesystemReadDirAction","router","createRouter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEO,MAAM,mBAAmBA,oCAAA,CAAoB;AAAA,EAClD,QAAA,EAAU,YAAA;AAAA,EACV,SAAS,GAAA,EAAK;AACZ,IAAA,MA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AAA,UACA,QAAA;AAAA,UACA,OAAA;AAAA,UACA,SAAA;AAAA,UACA,OAAA;AAAA,UACA,UAAA;AAAA,UACA,yBAAA;AAAA,UACA,yBAAA;AAAA,UACA,IAAA;AAAA,UACA,QAAA;AAAA,UACA,WAAA;AAAA,UACA,oBAAA;AAAA,UACA,4BAAA;AAAA,UACA,MAAA;AAAA,UACA;AAAA,SACD,CAAA;AACD,QAAA,UAAA,CAAW,IAAID,QAAM,CAAA;AAAA,MACvB;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SecureTemplater.cjs.js","sources":["../../../src/lib/templating/SecureTemplater.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 { Isolate } from 'isolated-vm';\nimport { resolvePackagePath } from '@backstage/backend-plugin-api';\nimport {\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport fs from 'fs-extra';\nimport { JsonValue } from '@backstage/types';\nimport { getMajorNodeVersion, isNoNodeSnapshotOptionProvided } from './helpers';\n\n// language=JavaScript\nconst mkScript = (nunjucksSource: string) => `\nconst { render, renderCompat } = (() => {\n const module = {};\n const process = { env: {} };\n const require = (pkg) => { if (pkg === 'events') { return function (){}; }};\n\n ${nunjucksSource}\n\n const env = module.exports.configure({\n autoescape: false,\n ...JSON.parse(nunjucksConfigs),\n tags: {\n variableStart: '\\${{',\n variableEnd: '}}',\n },\n });\n\n const compatEnv = module.exports.configure({\n autoescape: false,\n ...JSON.parse(nunjucksConfigs),\n tags: {\n variableStart: '{{',\n variableEnd: '}}',\n },\n });\n compatEnv.addFilter('jsonify', compatEnv.getFilter('dump'));\n\n const handleFunctionResult = (value) => {\n return value === '' ? undefined : JSON.parse(value);\n };\n for (const name of JSON.parse(availableTemplateFilters)) {\n env.addFilter(name, (...args) => handleFunctionResult(callFilter(name, args)));\n }\n for (const [name, value] of Object.entries(JSON.parse(availableTemplateGlobals))) {\n env.addGlobal(name, value);\n }\n for (const name of JSON.parse(availableTemplateCallbacks)) {\n env.addGlobal(name, (...args) => handleFunctionResult(callGlobal(name, args)));\n }\n\n let uninstallCompat = undefined;\n\n function render(str, values) {\n try {\n if (uninstallCompat) {\n uninstallCompat();\n uninstallCompat = undefined;\n }\n return env.renderString(str, JSON.parse(values));\n } catch (error) {\n // Make sure errors don't leak anything\n throw new Error(String(error.message));\n }\n }\n\n function renderCompat(str, values) {\n try {\n if (!uninstallCompat) {\n uninstallCompat = module.exports.installJinjaCompat();\n }\n return compatEnv.renderString(str, JSON.parse(values));\n } catch (error) {\n // Make sure errors don't leak anything\n throw new Error(String(error.message));\n }\n }\n\n return { render, renderCompat };\n})();\n`;\n\ninterface SecureTemplaterOptions {\n /* Enables jinja compatibility and the \"jsonify\" filter */\n cookiecutterCompat?: boolean;\n /* Extra user-provided nunjucks filters */\n templateFilters?: Record<string, TemplateFilter>;\n /* Extra user-provided nunjucks globals */\n templateGlobals?: Record<string, TemplateGlobal>;\n nunjucksConfigs?: { trimBlocks?: boolean; lstripBlocks?: boolean };\n}\n\nexport type SecureTemplateRenderer = (\n template: string,\n values: unknown,\n) => string;\n\nexport class SecureTemplater {\n static async loadRenderer(options: SecureTemplaterOptions = {}) {\n const {\n cookiecutterCompat,\n templateFilters = {},\n templateGlobals = {},\n nunjucksConfigs = {},\n } = options;\n\n const nodeVersion = getMajorNodeVersion();\n if (nodeVersion >= 20 && !isNoNodeSnapshotOptionProvided()) {\n throw new Error(\n `When using Node.js version 20 or newer, the scaffolder backend plugin requires that it be started with the --no-node-snapshot option. \n Please make sure that you have NODE_OPTIONS=--no-node-snapshot in your environment.`,\n );\n }\n\n const isolate = new Isolate({ memoryLimit: 128 });\n const context = await isolate.createContext();\n const contextGlobal = context.global;\n\n const nunjucksSource = await fs.readFile(\n resolvePackagePath(\n '@backstage/plugin-scaffolder-backend',\n 'assets/nunjucks.js.txt',\n ),\n 'utf-8',\n );\n\n const nunjucksScript = await isolate.compileScript(\n mkScript(nunjucksSource),\n );\n\n await contextGlobal.set('nunjucksConfigs', JSON.stringify(nunjucksConfigs));\n\n const availableFilters = Object.keys(templateFilters);\n\n await contextGlobal.set(\n 'availableTemplateFilters',\n JSON.stringify(availableFilters),\n );\n\n const globalCallbacks = [];\n const globalValues: Record<string, unknown> = {};\n for (const [name, value] of Object.entries(templateGlobals)) {\n if (typeof value === 'function') {\n globalCallbacks.push(name);\n } else {\n globalValues[name] = value;\n }\n }\n\n await contextGlobal.set(\n 'availableTemplateGlobals',\n JSON.stringify(globalValues),\n );\n await contextGlobal.set(\n 'availableTemplateCallbacks',\n JSON.stringify(globalCallbacks),\n );\n\n await contextGlobal.set(\n 'callFilter',\n (filterName: string, args: JsonValue[]) => {\n if (!Object.hasOwn(templateFilters, filterName)) {\n return '';\n }\n const [input, ...rest] = args;\n const rz = templateFilters[filterName](input, ...rest);\n return rz === undefined ? '' : JSON.stringify(rz);\n },\n );\n\n await contextGlobal.set(\n 'callGlobal',\n (globalName: string, args: JsonValue[]) => {\n if (!Object.hasOwn(templateGlobals, globalName)) {\n return '';\n }\n const global = templateGlobals[globalName];\n if (typeof global !== 'function') {\n return '';\n }\n const rz = global(...args);\n return rz === undefined ? '' : JSON.stringify(rz);\n },\n );\n\n await nunjucksScript.run(context);\n\n const render: SecureTemplateRenderer = (template, values) => {\n if (!context) {\n throw new Error('SecureTemplater has not been initialized');\n }\n\n contextGlobal.setSync('templateStr', String(template));\n contextGlobal.setSync('templateValues', JSON.stringify(values));\n\n if (cookiecutterCompat) {\n return context.evalSync(`renderCompat(templateStr, templateValues)`);\n }\n\n return context.evalSync(`render(templateStr, templateValues)`);\n };\n return render;\n }\n}\n"],"names":["getMajorNodeVersion","isNoNodeSnapshotOptionProvided","Isolate","fs","resolvePackagePath"],"mappings":";;;;;;;;;;;AA2BA,MAAM,QAAA,GAAW,CAAC,cAA2B,KAAA;AAAA;AAAA;AAAA;AAAA;;AAAA,EAAA,EAMzC,cAAc;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA,CAAA;AAgFX,MAAM,eAAgB,CAAA;AAAA,EAC3B,aAAa,YAAA,CAAa,OAAkC,GAAA,EAAI,EAAA;AAC9D,IAAM,MAAA;AAAA,MACJ,kBAAA;AAAA,MACA,kBAAkB,EAAC;AAAA,MACnB,kBAAkB,EAAC;AAAA,MACnB,kBAAkB;AAAC,KACjB,GAAA,OAAA;AAEJ,IAAA,MAAM,cAAcA,2BAAoB,EAAA;AACxC,IAAA,IAAI,WAAe,IAAA,EAAA,IAAM,CAACC,sCAAA,EAAkC,EAAA;AAC1D,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA;AAAA,2FAAA;AAAA,OAEF;AAAA;AAGF,IAAA,MAAM,UAAU,IAAIC,kBAAA,CAAQ,EAAE,WAAA,EAAa,KAAK,CAAA;AAChD,IAAM,MAAA,OAAA,GAAU,MAAM,OAAA,CAAQ,aAAc,EAAA;AAC5C,IAAA,MAAM,gBAAgB,OAAQ,CAAA,MAAA;AAE9B,IAAM,MAAA,cAAA,GAAiB,MAAMC,mBAA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CAAA,CAAA,CAAA;AAAA,KAC/D;AACA,IAAO,OAAA,MAAA;AAAA;AAEX;;;;"}
1
+ {"version":3,"file":"SecureTemplater.cjs.js","sources":["../../../src/lib/templating/SecureTemplater.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 { Isolate } from 'isolated-vm';\nimport { resolvePackagePath } from '@backstage/backend-plugin-api';\nimport {\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport fs from 'fs-extra';\nimport { JsonValue } from '@backstage/types';\nimport { getMajorNodeVersion, isNoNodeSnapshotOptionProvided } from './helpers';\n\n// language=JavaScript\nconst mkScript = (nunjucksSource: string) => `\nconst { render, renderCompat } = (() => {\n const module = {};\n const process = { env: {} };\n const require = (pkg) => { if (pkg === 'events') { return function (){}; }};\n\n ${nunjucksSource}\n\n const env = module.exports.configure({\n autoescape: false,\n ...JSON.parse(nunjucksConfigs),\n tags: {\n variableStart: '\\${{',\n variableEnd: '}}',\n },\n });\n\n const compatEnv = module.exports.configure({\n autoescape: false,\n ...JSON.parse(nunjucksConfigs),\n tags: {\n variableStart: '{{',\n variableEnd: '}}',\n },\n });\n compatEnv.addFilter('jsonify', compatEnv.getFilter('dump'));\n\n const handleFunctionResult = (value) => {\n return value === '' ? undefined : JSON.parse(value);\n };\n for (const name of JSON.parse(availableTemplateFilters)) {\n env.addFilter(name, (...args) => handleFunctionResult(callFilter(name, args)));\n }\n for (const [name, value] of Object.entries(JSON.parse(availableTemplateGlobals))) {\n env.addGlobal(name, value);\n }\n for (const name of JSON.parse(availableTemplateCallbacks)) {\n env.addGlobal(name, (...args) => handleFunctionResult(callGlobal(name, args)));\n }\n\n let uninstallCompat = undefined;\n\n function render(str, values) {\n try {\n if (uninstallCompat) {\n uninstallCompat();\n uninstallCompat = undefined;\n }\n return env.renderString(str, JSON.parse(values));\n } catch (error) {\n // Make sure errors don't leak anything\n throw new Error(String(error.message));\n }\n }\n\n function renderCompat(str, values) {\n try {\n if (!uninstallCompat) {\n uninstallCompat = module.exports.installJinjaCompat();\n }\n return compatEnv.renderString(str, JSON.parse(values));\n } catch (error) {\n // Make sure errors don't leak anything\n throw new Error(String(error.message));\n }\n }\n\n return { render, renderCompat };\n})();\n`;\n\ninterface SecureTemplaterOptions {\n /* Enables jinja compatibility and the \"jsonify\" filter */\n cookiecutterCompat?: boolean;\n /* Extra user-provided nunjucks filters */\n templateFilters?: Record<string, TemplateFilter>;\n /* Extra user-provided nunjucks globals */\n templateGlobals?: Record<string, TemplateGlobal>;\n nunjucksConfigs?: { trimBlocks?: boolean; lstripBlocks?: boolean };\n}\n\nexport type SecureTemplateRenderer = (\n template: string,\n values: unknown,\n) => string;\n\nexport class SecureTemplater {\n static async loadRenderer(options: SecureTemplaterOptions = {}) {\n const {\n cookiecutterCompat,\n templateFilters = {},\n templateGlobals = {},\n nunjucksConfigs = {},\n } = options;\n\n const nodeVersion = getMajorNodeVersion();\n if (nodeVersion >= 20 && !isNoNodeSnapshotOptionProvided()) {\n throw new Error(\n `When using Node.js version 20 or newer, the scaffolder backend plugin requires that it be started with the --no-node-snapshot option. \n Please make sure that you have NODE_OPTIONS=--no-node-snapshot in your environment.`,\n );\n }\n\n const isolate = new Isolate({ memoryLimit: 128 });\n const context = await isolate.createContext();\n const contextGlobal = context.global;\n\n const nunjucksSource = await fs.readFile(\n resolvePackagePath(\n '@backstage/plugin-scaffolder-backend',\n 'assets/nunjucks.js.txt',\n ),\n 'utf-8',\n );\n\n const nunjucksScript = await isolate.compileScript(\n mkScript(nunjucksSource),\n );\n\n await contextGlobal.set('nunjucksConfigs', JSON.stringify(nunjucksConfigs));\n\n const availableFilters = Object.keys(templateFilters);\n\n await contextGlobal.set(\n 'availableTemplateFilters',\n JSON.stringify(availableFilters),\n );\n\n const globalCallbacks = [];\n const globalValues: Record<string, unknown> = {};\n for (const [name, value] of Object.entries(templateGlobals)) {\n if (typeof value === 'function') {\n globalCallbacks.push(name);\n } else {\n globalValues[name] = value;\n }\n }\n\n await contextGlobal.set(\n 'availableTemplateGlobals',\n JSON.stringify(globalValues),\n );\n await contextGlobal.set(\n 'availableTemplateCallbacks',\n JSON.stringify(globalCallbacks),\n );\n\n await contextGlobal.set(\n 'callFilter',\n (filterName: string, args: JsonValue[]) => {\n if (!Object.hasOwn(templateFilters, filterName)) {\n return '';\n }\n const [input, ...rest] = args;\n const rz = templateFilters[filterName](input, ...rest);\n return rz === undefined ? '' : JSON.stringify(rz);\n },\n );\n\n await contextGlobal.set(\n 'callGlobal',\n (globalName: string, args: JsonValue[]) => {\n if (!Object.hasOwn(templateGlobals, globalName)) {\n return '';\n }\n const global = templateGlobals[globalName];\n if (typeof global !== 'function') {\n return '';\n }\n const rz = global(...args);\n return rz === undefined ? '' : JSON.stringify(rz);\n },\n );\n\n await nunjucksScript.run(context);\n\n const render: SecureTemplateRenderer = (template, values) => {\n if (!context) {\n throw new Error('SecureTemplater has not been initialized');\n }\n\n contextGlobal.setSync('templateStr', String(template));\n contextGlobal.setSync('templateValues', JSON.stringify(values));\n\n if (cookiecutterCompat) {\n return context.evalSync(`renderCompat(templateStr, templateValues)`);\n }\n\n return context.evalSync(`render(templateStr, templateValues)`);\n };\n return render;\n }\n}\n"],"names":["getMajorNodeVersion","isNoNodeSnapshotOptionProvided","Isolate","fs","resolvePackagePath"],"mappings":";;;;;;;;;;;AA2BA,MAAM,QAAA,GAAW,CAAC,cAAA,KAA2B;AAAA;AAAA;AAAA;AAAA;;AAAA,EAAA,EAMzC,cAAc;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AClB,YAAA;AAAA,MACA,CAAC,YAAoB,IAAA,KAAsB;AACzC,QAAA,IAAI,CAAC,MAAA,CAAO,MAAA,CAAO,eAAA,EAAiB,UAAU,CAAA,EAAG;AAC/C,UAAA,OAAO,EAAA;AAAA,QACT;AACA,QAAA,MAAM,MAAA,GAAS,gBAAgB,UAAU,CAAA;AACzC,QAAA,IAAI,OAAO,WAAW,UAAA,EAAY;AAChC,UAAA,OAAO,EAAA;AAAA,QACT;AACA,QAAA,MAAM,EAAA,GAAK,MAAA,CAAO,GAAG,IAAI,CAAA;AACzB,QAAA,OAAO,EAAA,KAAO,MAAA,GAAY,EAAA,GAAK,IAAA,CAAK,UAAU,EAAE,CAAA;AAAA,MAClD;AAAA,KACF;AAEA,IAAA,MAAM,cAAA,CAAe,IAAI,OAAO,CAAA;AAEhC,IAAA,MAAM,MAAA,GAAiC,CAAC,QAAA,EAAU,MAAA,KAAW;AAC3D,MAAA,IAAI,CAAC,OAAA,EAAS;AACZ,QAAA,MAAM,IAAI,MAAM,0CAA0C,CAAA;AAAA,MAC5D;AAEA,MAAA,aAAA,CAAc,OAAA,CAAQ,aAAA,EAAe,MAAA,CAAO,QAAQ,CAAC,CAAA;AACrD,MAAA,aAAA,CAAc,OAAA,CAAQ,gBAAA,EAAkB,IAAA,CAAK,SAAA,CAAU,MAAM,CAAC,CAAA;AAE9D,MAAA,IAAI,kBAAA,EAAoB;AACtB,QAAA,OAAO,OAAA,CAAQ,SAAS,CAAA,yCAAA,CAA2C,CAAA;AAAA,MACrE;AAEA,MAAA,OAAO,OAAA,CAAQ,SAAS,CAAA,mCAAA,CAAqC,CAAA;AAAA,IAC/D,CAAA;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createDefaultFilters.cjs.js","sources":["../../../../src/lib/templating/filters/createDefaultFilters.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 { ScmIntegrations } from '@backstage/integration';\nimport { createParseRepoUrl } from './parseRepoUrl';\nimport { parseEntityRef } from './parseEntityRef';\nimport { pick } from './pick';\nimport { createProjectSlug } from './projectSlug';\n\nexport const createDefaultFilters = (options: {\n integrations: ScmIntegrations;\n}) => [\n createParseRepoUrl(options.integrations),\n parseEntityRef,\n pick,\n createProjectSlug(options.integrations),\n];\n"],"names":["createParseRepoUrl","parseEntityRef","pick","createProjectSlug"],"mappings":";;;;;;;AAqBa,MAAA,oBAAA,GAAuB,CAAC,OAE/B,KAAA;AAAA,EACJA,yBAAA,CAAmB,QAAQ,YAAY,CAAA;AAAA,EACvCC,uBAAA;AAAA,EACAC,aAAA;AAAA,EACAC,0BAAA,CAAkB,QAAQ,YAAY;AACxC;;;;"}
1
+ {"version":3,"file":"createDefaultFilters.cjs.js","sources":["../../../../src/lib/templating/filters/createDefaultFilters.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 { ScmIntegrations } from '@backstage/integration';\nimport { createParseRepoUrl } from './parseRepoUrl';\nimport { parseEntityRef } from './parseEntityRef';\nimport { pick } from './pick';\nimport { createProjectSlug } from './projectSlug';\n\nexport const createDefaultFilters = (options: {\n integrations: ScmIntegrations;\n}) => [\n createParseRepoUrl(options.integrations),\n parseEntityRef,\n pick,\n createProjectSlug(options.integrations),\n];\n"],"names":["createParseRepoUrl","parseEntityRef","pick","createProjectSlug"],"mappings":";;;;;;;AAqBO,MAAM,oBAAA,GAAuB,CAAC,OAAA,KAE/B;AAAA,EACJA,yBAAA,CAAmB,QAAQ,YAAY,CAAA;AAAA,EACvCC,uBAAA;AAAA,EACAC,aAAA;AAAA,EACAC,0BAAA,CAAkB,QAAQ,YAAY;AACxC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"examples.cjs.js","sources":["../../../../../src/lib/templating/filters/parseEntityRef/examples.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 { TemplateFilterExample } from '@backstage/plugin-scaffolder-node/alpha';\n\nexport const examples: TemplateFilterExample[] = [\n {\n description: 'Without context',\n example: `\\\n- id: log\n name: Parse Entity Reference\n action: debug:log\n input:\n message: \\${{ parameters.owner | parseEntityRef }}\n`,\n notes: `\\\n- **Input**: \\`group:techdocs\\`\n- **Output**: \\`{\"kind\": \"group\", \"namespace\": \"default\", \"name\": \"techdocs\"}\\`\n`,\n },\n {\n description: 'With context',\n example: `\\\n- id: log\n name: Parse Entity Reference\n action: debug:log\n input:\n message: \\${{ parameters.owner | parseEntityRef({ defaultKind:\"group\", defaultNamespace:\"another-namespace\" }) }}\n`,\n notes: `\\\n- **Input**: \\`techdocs\\`\n- **Arguments:**: \\`[{ \"defaultKind\": \"group\", \"defaultNamespace\": \"another-namespace\" }]\\`\n- **Output**: \\`{\"kind\": \"group\", \"namespace\": \"another-namespace\", \"name\": \"techdocs\"}\\`\n`,\n },\n];\n"],"names":[],"mappings":";;AAiBO,MAAM,QAAoC,GAAA;AAAA,EAC/C;AAAA,IACE,WAAa,EAAA,iBAAA;AAAA,IACb,OAAS,EAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA,IAOT,KAAO,EAAA,CAAA;AAAA;AAAA;AAAA,GAIT;AAAA,EACA;AAAA,IACE,WAAa,EAAA,cAAA;AAAA,IACb,OAAS,EAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA,IAOT,KAAO,EAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAMX;;;;"}
1
+ {"version":3,"file":"examples.cjs.js","sources":["../../../../../src/lib/templating/filters/parseEntityRef/examples.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 { TemplateFilterExample } from '@backstage/plugin-scaffolder-node/alpha';\n\nexport const examples: TemplateFilterExample[] = [\n {\n description: 'Without context',\n example: `\\\n- id: log\n name: Parse Entity Reference\n action: debug:log\n input:\n message: \\${{ parameters.owner | parseEntityRef }}\n`,\n notes: `\\\n- **Input**: \\`group:techdocs\\`\n- **Output**: \\`{\"kind\": \"group\", \"namespace\": \"default\", \"name\": \"techdocs\"}\\`\n`,\n },\n {\n description: 'With context',\n example: `\\\n- id: log\n name: Parse Entity Reference\n action: debug:log\n input:\n message: \\${{ parameters.owner | parseEntityRef({ defaultKind:\"group\", defaultNamespace:\"another-namespace\" }) }}\n`,\n notes: `\\\n- **Input**: \\`techdocs\\`\n- **Arguments:**: \\`[{ \"defaultKind\": \"group\", \"defaultNamespace\": \"another-namespace\" }]\\`\n- **Output**: \\`{\"kind\": \"group\", \"namespace\": \"another-namespace\", \"name\": \"techdocs\"}\\`\n`,\n },\n];\n"],"names":[],"mappings":";;AAiBO,MAAM,QAAA,GAAoC;AAAA,EAC/C;AAAA,IACE,WAAA,EAAa,iBAAA;AAAA,IACb,OAAA,EAAS,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA,IAOT,KAAA,EAAO,CAAA;AAAA;AAAA;AAAA,GAIT;AAAA,EACA;AAAA,IACE,WAAA,EAAa,cAAA;AAAA,IACb,OAAA,EAAS,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA,IAOT,KAAA,EAAO,CAAA;AAAA;AAAA;AAAA;AAAA;AAMX;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"filter.cjs.js","sources":["../../../../../src/lib/templating/filters/parseEntityRef/filter.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 { parseEntityRef as filter } from '@backstage/catalog-model';\nimport { createTemplateFilter } from '@backstage/plugin-scaffolder-node/alpha';\nimport { examples } from './examples';\n\nexport const parseEntityRef = createTemplateFilter({\n id: 'parseEntityRef',\n description:\n 'Extracts the parts of an entity reference, such as the kind, namespace, and name.',\n schema: z =>\n z\n .function()\n .args(\n z.union([\n z.string().describe('compact entity reference'),\n z\n .object({\n kind: z.string().optional(),\n namespace: z.string().optional(),\n name: z.string(),\n })\n .describe('`CompoundEntityRef`'),\n ]),\n z\n .object({\n defaultKind: z\n .string()\n .describe('The default kind, if none is given in the reference'),\n defaultNamespace: z\n .string()\n .describe(\n 'The default namespace, if none is given in the reference',\n ),\n })\n .partial()\n .optional(),\n )\n .returns(\n z\n .object({\n kind: z.string(),\n namespace: z.string(),\n name: z.string(),\n })\n .describe('`CompoundEntityRef`'),\n ),\n examples,\n filter,\n});\n"],"names":["createTemplateFilter","examples","filter"],"mappings":";;;;;;AAmBO,MAAM,iBAAiBA,0BAAqB,CAAA;AAAA,EACjD,EAAI,EAAA,gBAAA;AAAA,EACJ,WACE,EAAA,mFAAA;AAAA,EACF,MAAQ,EAAA,CAAA,CAAA,KACN,CACG,CAAA,QAAA,EACA,CAAA,IAAA;AAAA,IACC,EAAE,KAAM,CAAA;AAAA,MACN,CAAE,CAAA,MAAA,EAAS,CAAA,QAAA,CAAS,0BAA0B,CAAA;AAAA,MAC9C,EACG,MAAO,CAAA;AAAA,QACN,IAAM,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS,EAAA;AAAA,QAC1B,SAAW,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS,EAAA;AAAA,QAC/B,IAAA,EAAM,EAAE,MAAO;AAAA,OAChB,CACA,CAAA,QAAA,CAAS,qBAAqB;AAAA,KAClC,CAAA;AAAA,IACD,EACG,MAAO,CAAA;AAAA,MACN,WAAa,EAAA,CAAA,CACV,MAAO,EAAA,CACP,SAAS,qDAAqD,CAAA;AAAA,MACjE,gBAAA,EAAkB,CACf,CAAA,MAAA,EACA,CAAA,QAAA;AAAA,QACC;AAAA;AACF,KACH,CAAA,CACA,OAAQ,EAAA,CACR,QAAS;AAAA,GAEb,CAAA,OAAA;AAAA,IACC,EACG,MAAO,CAAA;AAAA,MACN,IAAA,EAAM,EAAE,MAAO,EAAA;AAAA,MACf,SAAA,EAAW,EAAE,MAAO,EAAA;AAAA,MACpB,IAAA,EAAM,EAAE,MAAO;AAAA,KAChB,CACA,CAAA,QAAA,CAAS,qBAAqB;AAAA,GACnC;AAAA,YACJC,iBAAA;AAAA,UACAC;AACF,CAAC;;;;"}
1
+ {"version":3,"file":"filter.cjs.js","sources":["../../../../../src/lib/templating/filters/parseEntityRef/filter.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 { parseEntityRef as filter } from '@backstage/catalog-model';\nimport { createTemplateFilter } from '@backstage/plugin-scaffolder-node/alpha';\nimport { examples } from './examples';\n\nexport const parseEntityRef = createTemplateFilter({\n id: 'parseEntityRef',\n description:\n 'Extracts the parts of an entity reference, such as the kind, namespace, and name.',\n schema: z =>\n z\n .function()\n .args(\n z.union([\n z.string().describe('compact entity reference'),\n z\n .object({\n kind: z.string().optional(),\n namespace: z.string().optional(),\n name: z.string(),\n })\n .describe('`CompoundEntityRef`'),\n ]),\n z\n .object({\n defaultKind: z\n .string()\n .describe('The default kind, if none is given in the reference'),\n defaultNamespace: z\n .string()\n .describe(\n 'The default namespace, if none is given in the reference',\n ),\n })\n .partial()\n .optional(),\n )\n .returns(\n z\n .object({\n kind: z.string(),\n namespace: z.string(),\n name: z.string(),\n })\n .describe('`CompoundEntityRef`'),\n ),\n examples,\n filter,\n});\n"],"names":["createTemplateFilter","examples","filter"],"mappings":";;;;;;AAmBO,MAAM,iBAAiBA,0BAAA,CAAqB;AAAA,EACjD,EAAA,EAAI,gBAAA;AAAA,EACJ,WAAA,EACE,mFAAA;AAAA,EACF,MAAA,EAAQ,CAAA,CAAA,KACN,CAAA,CACG,QAAA,EAAS,CACT,IAAA;AAAA,IACC,EAAE,KAAA,CAAM;AAAA,MACN,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,CAAS,0BAA0B,CAAA;AAAA,MAC9C,EACG,MAAA,CAAO;AAAA,QACN,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,QAC1B,SAAA,EAAW,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,QAC/B,IAAA,EAAM,EAAE,MAAA;AAAO,OAChB,CAAA,CACA,QAAA,CAAS,qBAAqB;AAAA,KAClC,CAAA;AAAA,IACD,EACG,MAAA,CAAO;AAAA,MACN,WAAA,EAAa,CAAA,CACV,MAAA,EAAO,CACP,SAAS,qDAAqD,CAAA;AAAA,MACjE,gBAAA,EAAkB,CAAA,CACf,MAAA,EAAO,CACP,QAAA;AAAA,QACC;AAAA;AACF,KACH,CAAA,CACA,OAAA,EAAQ,CACR,QAAA;AAAS,GACd,CACC,OAAA;AAAA,IACC,EACG,MAAA,CAAO;AAAA,MACN,IAAA,EAAM,EAAE,MAAA,EAAO;AAAA,MACf,SAAA,EAAW,EAAE,MAAA,EAAO;AAAA,MACpB,IAAA,EAAM,EAAE,MAAA;AAAO,KAChB,CAAA,CACA,QAAA,CAAS,qBAAqB;AAAA,GACnC;AAAA,YACJC,iBAAA;AAAA,UACAC;AACF,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"examples.cjs.js","sources":["../../../../../src/lib/templating/filters/parseRepoUrl/examples.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 */\n\nimport { TemplateFilterExample } from '@backstage/plugin-scaffolder-node/alpha';\n\nexport const examples: TemplateFilterExample[] = [\n {\n example: `\\\n- id: log\n name: Parse Repo URL\n action: debug:log\n input:\n message: \\${{ parameters.repoUrl | parseRepoUrl }}`,\n notes: ` - **Input**: \\`github.com?repo=backstage&owner=backstage\\`\n - **Output**: \\`{\"host\":\"github.com\",\"owner\":\"backstage\",\"repo\":\"backstage\"}\\`\n`,\n },\n];\n"],"names":[],"mappings":";;AAkBO,MAAM,QAAoC,GAAA;AAAA,EAC/C;AAAA,IACE,OAAS,EAAA,CAAA;AAAA;AAAA;AAAA;AAAA,sDAAA,CAAA;AAAA,IAMT,KAAO,EAAA,CAAA;AAAA;AAAA;AAAA;AAIX;;;;"}
1
+ {"version":3,"file":"examples.cjs.js","sources":["../../../../../src/lib/templating/filters/parseRepoUrl/examples.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 */\n\nimport { TemplateFilterExample } from '@backstage/plugin-scaffolder-node/alpha';\n\nexport const examples: TemplateFilterExample[] = [\n {\n example: `\\\n- id: log\n name: Parse Repo URL\n action: debug:log\n input:\n message: \\${{ parameters.repoUrl | parseRepoUrl }}`,\n notes: ` - **Input**: \\`github.com?repo=backstage&owner=backstage\\`\n - **Output**: \\`{\"host\":\"github.com\",\"owner\":\"backstage\",\"repo\":\"backstage\"}\\`\n`,\n },\n];\n"],"names":[],"mappings":";;AAkBO,MAAM,QAAA,GAAoC;AAAA,EAC/C;AAAA,IACE,OAAA,EAAS,CAAA;AAAA;AAAA;AAAA;AAAA,sDAAA,CAAA;AAAA,IAMT,KAAA,EAAO,CAAA;AAAA;AAAA;AAAA;AAIX;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"filter.cjs.js","sources":["../../../../../src/lib/templating/filters/parseRepoUrl/filter.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 { ScmIntegrations } from '@backstage/integration';\nimport { parseRepoUrl } from '@backstage/plugin-scaffolder-node';\nimport { createTemplateFilter } from '@backstage/plugin-scaffolder-node/alpha';\nimport { examples } from './examples';\n\nexport const createParseRepoUrl = (integrations: ScmIntegrations) =>\n createTemplateFilter({\n id: 'parseRepoUrl',\n description:\n 'Parses a repository URL into its constituent parts: owner, repository name, etc.',\n schema: z =>\n z\n .function()\n .args(\n z.string().describe('repo URL as collected from repository picker'),\n )\n .returns(\n z\n .object({\n repo: z.string(),\n host: z.string(),\n })\n .merge(\n z\n .object({\n owner: z.string(),\n organization: z.string(),\n workspace: z.string(),\n project: z.string(),\n })\n .partial(),\n )\n .describe('`RepoSpec`'),\n ),\n examples,\n filter: url => parseRepoUrl(url, integrations),\n });\n"],"names":["createTemplateFilter","examples","parseRepoUrl"],"mappings":";;;;;;AAoBa,MAAA,kBAAA,GAAqB,CAAC,YAAA,KACjCA,0BAAqB,CAAA;AAAA,EACnB,EAAI,EAAA,cAAA;AAAA,EACJ,WACE,EAAA,kFAAA;AAAA,EACF,MAAQ,EAAA,CAAA,CAAA,KACN,CACG,CAAA,QAAA,EACA,CAAA,IAAA;AAAA,IACC,CAAE,CAAA,MAAA,EAAS,CAAA,QAAA,CAAS,8CAA8C;AAAA,GAEnE,CAAA,OAAA;AAAA,IACC,EACG,MAAO,CAAA;AAAA,MACN,IAAA,EAAM,EAAE,MAAO,EAAA;AAAA,MACf,IAAA,EAAM,EAAE,MAAO;AAAA,KAChB,CACA,CAAA,KAAA;AAAA,MACC,EACG,MAAO,CAAA;AAAA,QACN,KAAA,EAAO,EAAE,MAAO,EAAA;AAAA,QAChB,YAAA,EAAc,EAAE,MAAO,EAAA;AAAA,QACvB,SAAA,EAAW,EAAE,MAAO,EAAA;AAAA,QACpB,OAAA,EAAS,EAAE,MAAO;AAAA,OACnB,EACA,OAAQ;AAAA,KACb,CACC,SAAS,YAAY;AAAA,GAC1B;AAAA,YACJC,iBAAA;AAAA,EACA,MAAQ,EAAA,CAAA,GAAA,KAAOC,iCAAa,CAAA,GAAA,EAAK,YAAY;AAC/C,CAAC;;;;"}
1
+ {"version":3,"file":"filter.cjs.js","sources":["../../../../../src/lib/templating/filters/parseRepoUrl/filter.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 { ScmIntegrations } from '@backstage/integration';\nimport { parseRepoUrl } from '@backstage/plugin-scaffolder-node';\nimport { createTemplateFilter } from '@backstage/plugin-scaffolder-node/alpha';\nimport { examples } from './examples';\n\nexport const createParseRepoUrl = (integrations: ScmIntegrations) =>\n createTemplateFilter({\n id: 'parseRepoUrl',\n description:\n 'Parses a repository URL into its constituent parts: owner, repository name, etc.',\n schema: z =>\n z\n .function()\n .args(\n z.string().describe('repo URL as collected from repository picker'),\n )\n .returns(\n z\n .object({\n repo: z.string(),\n host: z.string(),\n })\n .merge(\n z\n .object({\n owner: z.string(),\n organization: z.string(),\n workspace: z.string(),\n project: z.string(),\n })\n .partial(),\n )\n .describe('`RepoSpec`'),\n ),\n examples,\n filter: url => parseRepoUrl(url, integrations),\n });\n"],"names":["createTemplateFilter","examples","parseRepoUrl"],"mappings":";;;;;;AAoBO,MAAM,kBAAA,GAAqB,CAAC,YAAA,KACjCA,0BAAA,CAAqB;AAAA,EACnB,EAAA,EAAI,cAAA;AAAA,EACJ,WAAA,EACE,kFAAA;AAAA,EACF,MAAA,EAAQ,CAAA,CAAA,KACN,CAAA,CACG,QAAA,EAAS,CACT,IAAA;AAAA,IACC,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,CAAS,8CAA8C;AAAA,GACpE,CACC,OAAA;AAAA,IACC,EACG,MAAA,CAAO;AAAA,MACN,IAAA,EAAM,EAAE,MAAA,EAAO;AAAA,MACf,IAAA,EAAM,EAAE,MAAA;AAAO,KAChB,CAAA,CACA,KAAA;AAAA,MACC,EACG,MAAA,CAAO;AAAA,QACN,KAAA,EAAO,EAAE,MAAA,EAAO;AAAA,QAChB,YAAA,EAAc,EAAE,MAAA,EAAO;AAAA,QACvB,SAAA,EAAW,EAAE,MAAA,EAAO;AAAA,QACpB,OAAA,EAAS,EAAE,MAAA;AAAO,OACnB,EACA,OAAA;AAAQ,KACb,CACC,SAAS,YAAY;AAAA,GAC1B;AAAA,YACJC,iBAAA;AAAA,EACA,MAAA,EAAQ,CAAA,GAAA,KAAOC,iCAAA,CAAa,GAAA,EAAK,YAAY;AAC/C,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"examples.cjs.js","sources":["../../../../../src/lib/templating/filters/pick/examples.ts"],"sourcesContent":["import { TemplateFilterExample } from '@backstage/plugin-scaffolder-node/alpha';\n\n/*\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 */\nexport const examples: TemplateFilterExample[] = [\n {\n example: `\\\n- id: log\n name: Pick\n action: debug:log\n input:\n message: \\${{ parameters.owner | parseEntityRef | pick('name') }}`,\n notes: `\\\n- **Input**: \\`{ kind: 'Group', namespace: 'default', name: 'techdocs'\\` }\n- **Output**: \\`techdocs\\`\n`,\n },\n];\n"],"names":[],"mappings":";;AAiBO,MAAM,QAAoC,GAAA;AAAA,EAC/C;AAAA,IACE,OAAS,EAAA,CAAA;AAAA;AAAA;AAAA;AAAA,qEAAA,CAAA;AAAA,IAMT,KAAO,EAAA,CAAA;AAAA;AAAA;AAAA;AAKX;;;;"}
1
+ {"version":3,"file":"examples.cjs.js","sources":["../../../../../src/lib/templating/filters/pick/examples.ts"],"sourcesContent":["import { TemplateFilterExample } from '@backstage/plugin-scaffolder-node/alpha';\n\n/*\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 */\nexport const examples: TemplateFilterExample[] = [\n {\n example: `\\\n- id: log\n name: Pick\n action: debug:log\n input:\n message: \\${{ parameters.owner | parseEntityRef | pick('name') }}`,\n notes: `\\\n- **Input**: \\`{ kind: 'Group', namespace: 'default', name: 'techdocs'\\` }\n- **Output**: \\`techdocs\\`\n`,\n },\n];\n"],"names":[],"mappings":";;AAiBO,MAAM,QAAA,GAAoC;AAAA,EAC/C;AAAA,IACE,OAAA,EAAS,CAAA;AAAA;AAAA;AAAA;AAAA,qEAAA,CAAA;AAAA,IAMT,KAAA,EAAO,CAAA;AAAA;AAAA;AAAA;AAKX;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"filter.cjs.js","sources":["../../../../../src/lib/templating/filters/pick/filter.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 { createTemplateFilter } from '@backstage/plugin-scaffolder-node/alpha';\nimport { get as filter } from 'lodash';\nimport { examples } from './examples';\n\nexport const pick = createTemplateFilter({\n id: 'pick',\n description:\n 'Selects a specific property (e.g. kind, namespace, name) from an object.',\n schema: z =>\n z\n .function()\n .args(z.any(), z.string().describe('Property'))\n .returns(z.any().describe('Selected property')),\n examples,\n filter,\n});\n"],"names":["createTemplateFilter","examples","filter"],"mappings":";;;;;;AAmBO,MAAM,OAAOA,0BAAqB,CAAA;AAAA,EACvC,EAAI,EAAA,MAAA;AAAA,EACJ,WACE,EAAA,0EAAA;AAAA,EACF,MAAA,EAAQ,OACN,CACG,CAAA,QAAA,GACA,IAAK,CAAA,CAAA,CAAE,GAAI,EAAA,EAAG,CAAE,CAAA,MAAA,GAAS,QAAS,CAAA,UAAU,CAAC,CAC7C,CAAA,OAAA,CAAQ,EAAE,GAAI,EAAA,CAAE,QAAS,CAAA,mBAAmB,CAAC,CAAA;AAAA,YAClDC,iBAAA;AAAA,UACAC;AACF,CAAC;;;;"}
1
+ {"version":3,"file":"filter.cjs.js","sources":["../../../../../src/lib/templating/filters/pick/filter.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 { createTemplateFilter } from '@backstage/plugin-scaffolder-node/alpha';\nimport { get as filter } from 'lodash';\nimport { examples } from './examples';\n\nexport const pick = createTemplateFilter({\n id: 'pick',\n description:\n 'Selects a specific property (e.g. kind, namespace, name) from an object.',\n schema: z =>\n z\n .function()\n .args(z.any(), z.string().describe('Property'))\n .returns(z.any().describe('Selected property')),\n examples,\n filter,\n});\n"],"names":["createTemplateFilter","examples","filter"],"mappings":";;;;;;AAmBO,MAAM,OAAOA,0BAAA,CAAqB;AAAA,EACvC,EAAA,EAAI,MAAA;AAAA,EACJ,WAAA,EACE,0EAAA;AAAA,EACF,MAAA,EAAQ,OACN,CAAA,CACG,QAAA,GACA,IAAA,CAAK,CAAA,CAAE,GAAA,EAAI,EAAG,CAAA,CAAE,MAAA,GAAS,QAAA,CAAS,UAAU,CAAC,CAAA,CAC7C,OAAA,CAAQ,EAAE,GAAA,EAAI,CAAE,QAAA,CAAS,mBAAmB,CAAC,CAAA;AAAA,YAClDC,iBAAA;AAAA,UACAC;AACF,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"examples.cjs.js","sources":["../../../../../src/lib/templating/filters/projectSlug/examples.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 { TemplateFilterExample } from '@backstage/plugin-scaffolder-node/alpha';\n\nexport const examples: TemplateFilterExample[] = [\n {\n example: `\\\n- id: log\n name: Project Slug\n action: debug:log\n input:\n message: \\${{ parameters.repoUrl | projectSlug }}\n`,\n notes: `\\\n- **Input**: \\`github.com?repo=backstage&owner=backstage\\`\n- **Output**: backstage/backstage\n`,\n },\n];\n"],"names":[],"mappings":";;AAiBO,MAAM,QAAoC,GAAA;AAAA,EAC/C;AAAA,IACE,OAAS,EAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA,IAOT,KAAO,EAAA,CAAA;AAAA;AAAA;AAAA;AAKX;;;;"}
1
+ {"version":3,"file":"examples.cjs.js","sources":["../../../../../src/lib/templating/filters/projectSlug/examples.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 { TemplateFilterExample } from '@backstage/plugin-scaffolder-node/alpha';\n\nexport const examples: TemplateFilterExample[] = [\n {\n example: `\\\n- id: log\n name: Project Slug\n action: debug:log\n input:\n message: \\${{ parameters.repoUrl | projectSlug }}\n`,\n notes: `\\\n- **Input**: \\`github.com?repo=backstage&owner=backstage\\`\n- **Output**: backstage/backstage\n`,\n },\n];\n"],"names":[],"mappings":";;AAiBO,MAAM,QAAA,GAAoC;AAAA,EAC/C;AAAA,IACE,OAAA,EAAS,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA,IAOT,KAAA,EAAO,CAAA;AAAA;AAAA;AAAA;AAKX;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"filter.cjs.js","sources":["../../../../../src/lib/templating/filters/projectSlug/filter.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 { ScmIntegrations } from '@backstage/integration';\nimport { parseRepoUrl } from '@backstage/plugin-scaffolder-node';\nimport { createTemplateFilter } from '@backstage/plugin-scaffolder-node/alpha';\nimport { examples } from './examples';\n\nexport const createProjectSlug = (integrations: ScmIntegrations) =>\n createTemplateFilter({\n id: 'projectSlug',\n description: 'Generates a project slug from a repository URL.',\n schema: z =>\n z\n .function()\n .args(\n z.string().describe('repo URL as collected from repository picker'),\n )\n .returns(z.string()),\n examples,\n filter: repoUrl => {\n const { owner, repo } = parseRepoUrl(repoUrl, integrations);\n return `${owner}/${repo}`;\n },\n });\n"],"names":["createTemplateFilter","examples","parseRepoUrl"],"mappings":";;;;;;AAoBa,MAAA,iBAAA,GAAoB,CAAC,YAAA,KAChCA,0BAAqB,CAAA;AAAA,EACnB,EAAI,EAAA,aAAA;AAAA,EACJ,WAAa,EAAA,iDAAA;AAAA,EACb,MAAQ,EAAA,CAAA,CAAA,KACN,CACG,CAAA,QAAA,EACA,CAAA,IAAA;AAAA,IACC,CAAE,CAAA,MAAA,EAAS,CAAA,QAAA,CAAS,8CAA8C;AAAA,GAEnE,CAAA,OAAA,CAAQ,CAAE,CAAA,MAAA,EAAQ,CAAA;AAAA,YACvBC,iBAAA;AAAA,EACA,QAAQ,CAAW,OAAA,KAAA;AACjB,IAAA,MAAM,EAAE,KAAO,EAAA,IAAA,EAAS,GAAAC,iCAAA,CAAa,SAAS,YAAY,CAAA;AAC1D,IAAO,OAAA,CAAA,EAAG,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA;AAE3B,CAAC;;;;"}
1
+ {"version":3,"file":"filter.cjs.js","sources":["../../../../../src/lib/templating/filters/projectSlug/filter.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 { ScmIntegrations } from '@backstage/integration';\nimport { parseRepoUrl } from '@backstage/plugin-scaffolder-node';\nimport { createTemplateFilter } from '@backstage/plugin-scaffolder-node/alpha';\nimport { examples } from './examples';\n\nexport const createProjectSlug = (integrations: ScmIntegrations) =>\n createTemplateFilter({\n id: 'projectSlug',\n description: 'Generates a project slug from a repository URL.',\n schema: z =>\n z\n .function()\n .args(\n z.string().describe('repo URL as collected from repository picker'),\n )\n .returns(z.string()),\n examples,\n filter: repoUrl => {\n const { owner, repo } = parseRepoUrl(repoUrl, integrations);\n return `${owner}/${repo}`;\n },\n });\n"],"names":["createTemplateFilter","examples","parseRepoUrl"],"mappings":";;;;;;AAoBO,MAAM,iBAAA,GAAoB,CAAC,YAAA,KAChCA,0BAAA,CAAqB;AAAA,EACnB,EAAA,EAAI,aAAA;AAAA,EACJ,WAAA,EAAa,iDAAA;AAAA,EACb,MAAA,EAAQ,CAAA,CAAA,KACN,CAAA,CACG,QAAA,EAAS,CACT,IAAA;AAAA,IACC,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,CAAS,8CAA8C;AAAA,GACpE,CACC,OAAA,CAAQ,CAAA,CAAE,MAAA,EAAQ,CAAA;AAAA,YACvBC,iBAAA;AAAA,EACA,QAAQ,CAAA,OAAA,KAAW;AACjB,IAAA,MAAM,EAAE,KAAA,EAAO,IAAA,EAAK,GAAIC,iCAAA,CAAa,SAAS,YAAY,CAAA;AAC1D,IAAA,OAAO,CAAA,EAAG,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,EACzB;AACF,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.cjs.js","sources":["../../../src/lib/templating/helpers.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\nexport function isNoNodeSnapshotOptionProvided(): boolean {\n return (\n process.env.NODE_OPTIONS?.includes('--no-node-snapshot') ||\n process.execArgv.includes('--no-node-snapshot')\n );\n}\n\n/**\n * Gets the major version of the currently running Node.js process.\n *\n * @remarks\n * This function extracts the major version from `process.versions.node` (a string representing the Node.js version),\n * which includes the major, minor, and patch versions. It splits this string by the `.` character to get an array\n * of these versions, and then parses the first element of this array (the major version) to a number.\n *\n * @returns {number} The major version of the currently running Node.js process.\n */\nexport function getMajorNodeVersion(): number {\n const version = process.versions.node;\n return parseInt(version.split('.')[0], 10);\n}\n"],"names":[],"mappings":";;AAgBO,SAAS,8BAA0C,GAAA;AACxD,EACE,OAAA,OAAA,CAAQ,IAAI,YAAc,EAAA,QAAA,CAAS,oBAAoB,CACvD,IAAA,OAAA,CAAQ,QAAS,CAAA,QAAA,CAAS,oBAAoB,CAAA;AAElD;AAYO,SAAS,mBAA8B,GAAA;AAC5C,EAAM,MAAA,OAAA,GAAU,QAAQ,QAAS,CAAA,IAAA;AACjC,EAAA,OAAO,SAAS,OAAQ,CAAA,KAAA,CAAM,GAAG,CAAE,CAAA,CAAC,GAAG,EAAE,CAAA;AAC3C;;;;;"}
1
+ {"version":3,"file":"helpers.cjs.js","sources":["../../../src/lib/templating/helpers.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\nexport function isNoNodeSnapshotOptionProvided(): boolean {\n return (\n process.env.NODE_OPTIONS?.includes('--no-node-snapshot') ||\n process.execArgv.includes('--no-node-snapshot')\n );\n}\n\n/**\n * Gets the major version of the currently running Node.js process.\n *\n * @remarks\n * This function extracts the major version from `process.versions.node` (a string representing the Node.js version),\n * which includes the major, minor, and patch versions. It splits this string by the `.` character to get an array\n * of these versions, and then parses the first element of this array (the major version) to a number.\n *\n * @returns {number} The major version of the currently running Node.js process.\n */\nexport function getMajorNodeVersion(): number {\n const version = process.versions.node;\n return parseInt(version.split('.')[0], 10);\n}\n"],"names":[],"mappings":";;AAgBO,SAAS,8BAAA,GAA0C;AACxD,EAAA,OACE,OAAA,CAAQ,IAAI,YAAA,EAAc,QAAA,CAAS,oBAAoB,CAAA,IACvD,OAAA,CAAQ,QAAA,CAAS,QAAA,CAAS,oBAAoB,CAAA;AAElD;AAYO,SAAS,mBAAA,GAA8B;AAC5C,EAAA,MAAM,OAAA,GAAU,QAAQ,QAAA,CAAS,IAAA;AACjC,EAAA,OAAO,SAAS,OAAA,CAAQ,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,GAAG,EAAE,CAAA;AAC3C;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateActionRegistry.cjs.js","sources":["../../../src/scaffolder/actions/TemplateActionRegistry.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 { ConflictError, NotFoundError } from '@backstage/errors';\nimport { TemplateAction } from '@backstage/plugin-scaffolder-node';\n/**\n * Registry of all registered template actions.\n * @public\n * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version.\n */\nexport class TemplateActionRegistry {\n private readonly actions = new Map<string, TemplateAction>();\n\n register(action: TemplateAction<any, any, any>) {\n if (this.actions.has(action.id)) {\n throw new ConflictError(\n `Template action with ID '${action.id}' has already been registered`,\n );\n }\n\n this.actions.set(action.id, action);\n }\n\n get(actionId: string): TemplateAction<any, any, any> {\n const action = this.actions.get(actionId);\n if (!action) {\n throw new NotFoundError(\n `Template action with ID '${actionId}' is not registered. See https://backstage.io/docs/features/software-templates/builtin-actions/ on how to add a new action module.`,\n );\n }\n return action;\n }\n\n list(): TemplateAction<any, any, any>[] {\n return [...this.actions.values()];\n }\n}\n"],"names":["ConflictError","NotFoundError"],"mappings":";;;;AAuBO,MAAM,sBAAuB,CAAA;AAAA,EACjB,OAAA,uBAAc,GAA4B,EAAA;AAAA,EAE3D,SAAS,MAAuC,EAAA;AAC9C,IAAA,IAAI,IAAK,CAAA,OAAA,CAAQ,GAAI,CAAA,MAAA,CAAO,EAAE,CAAG,EAAA;AAC/B,MAAA,MAAM,IAAIA,oBAAA;AAAA,QACR,CAAA,yBAAA,EAA4B,OAAO,EAAE,CAAA,6BAAA;AAAA,OACvC;AAAA;AAGF,IAAA,IAAA,CAAK,OAAQ,CAAA,GAAA,CAAI,MAAO,CAAA,EAAA,EAAI,MAAM,CAAA;AAAA;AACpC,EAEA,IAAI,QAAiD,EAAA;AACnD,IAAA,MAAM,MAAS,GAAA,IAAA,CAAK,OAAQ,CAAA,GAAA,CAAI,QAAQ,CAAA;AACxC,IAAA,IAAI,CAAC,MAAQ,EAAA;AACX,MAAA,MAAM,IAAIC,oBAAA;AAAA,QACR,4BAA4B,QAAQ,CAAA,kIAAA;AAAA,OACtC;AAAA;AAEF,IAAO,OAAA,MAAA;AAAA;AACT,EAEA,IAAwC,GAAA;AACtC,IAAA,OAAO,CAAC,GAAG,IAAK,CAAA,OAAA,CAAQ,QAAQ,CAAA;AAAA;AAEpC;;;;"}
1
+ {"version":3,"file":"TemplateActionRegistry.cjs.js","sources":["../../../src/scaffolder/actions/TemplateActionRegistry.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 { ConflictError, NotFoundError } from '@backstage/errors';\nimport { TemplateAction } from '@backstage/plugin-scaffolder-node';\n/**\n * Registry of all registered template actions.\n * @public\n * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version.\n */\nexport class TemplateActionRegistry {\n private readonly actions = new Map<string, TemplateAction>();\n\n register(action: TemplateAction<any, any, any>) {\n if (this.actions.has(action.id)) {\n throw new ConflictError(\n `Template action with ID '${action.id}' has already been registered`,\n );\n }\n\n this.actions.set(action.id, action);\n }\n\n get(actionId: string): TemplateAction<any, any, any> {\n const action = this.actions.get(actionId);\n if (!action) {\n throw new NotFoundError(\n `Template action with ID '${actionId}' is not registered. See https://backstage.io/docs/features/software-templates/builtin-actions/ on how to add a new action module.`,\n );\n }\n return action;\n }\n\n list(): TemplateAction<any, any, any>[] {\n return [...this.actions.values()];\n }\n}\n"],"names":["ConflictError","NotFoundError"],"mappings":";;;;AAuBO,MAAM,sBAAA,CAAuB;AAAA,EACjB,OAAA,uBAAc,GAAA,EAA4B;AAAA,EAE3D,SAAS,MAAA,EAAuC;AAC9C,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA,EAAG;AAC/B,MAAA,MAAM,IAAIA,oBAAA;AAAA,QACR,CAAA,yBAAA,EAA4B,OAAO,EAAE,CAAA,6BAAA;AAAA,OACvC;AAAA,IACF;AAEA,IAAA,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAO,EAAA,EAAI,MAAM,CAAA;AAAA,EACpC;AAAA,EAEA,IAAI,QAAA,EAAiD;AACnD,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,QAAQ,CAAA;AACxC,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAM,IAAIC,oBAAA;AAAA,QACR,4BAA4B,QAAQ,CAAA,kIAAA;AAAA,OACtC;AAAA,IACF;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEA,IAAA,GAAwC;AACtC,IAAA,OAAO,CAAC,GAAG,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AAAA,EAClC;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/catalog/fetch.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 { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';\nimport { examples } from './fetch.examples';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\n\nconst id = 'catalog:fetch';\n\n/**\n * Returns entity or entities from the catalog by entity reference(s).\n *\n * @public\n */\nexport function createFetchCatalogEntityAction(options: {\n catalog: CatalogService;\n}) {\n const { catalog } = options;\n\n return createTemplateAction({\n id,\n description:\n 'Returns entity or entities from the catalog by entity reference(s)',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n entityRef: z =>\n z\n .string({\n description: 'Entity reference of the entity to get',\n })\n .optional(),\n entityRefs: z =>\n z\n .array(z.string(), {\n description: 'Entity references of the entities to get',\n })\n .optional(),\n optional: z =>\n z\n .boolean({\n description:\n 'Allow the entity or entities to optionally exist. Default: false',\n })\n .optional(),\n defaultKind: z =>\n z.string({ description: 'The default kind' }).optional(),\n defaultNamespace: z =>\n z.string({ description: 'The default namespace' }).optional(),\n },\n output: {\n entity: z =>\n z\n .any({\n description:\n 'Object containing same values used in the Entity schema. Only when used with `entityRef` parameter.',\n })\n .optional(),\n entities: z =>\n z\n .array(\n z.any({\n description:\n 'Array containing objects with same values used in the Entity schema. Only when used with `entityRefs` parameter.',\n }),\n )\n .optional(),\n },\n },\n async handler(ctx) {\n const { entityRef, entityRefs, optional, defaultKind, defaultNamespace } =\n ctx.input;\n\n if (!entityRef && !entityRefs) {\n if (optional) {\n return;\n }\n throw new Error('Missing entity reference or references');\n }\n\n if (entityRef) {\n const entity = await catalog.getEntityByRef(\n stringifyEntityRef(\n parseEntityRef(entityRef, { defaultKind, defaultNamespace }),\n ),\n {\n credentials: await ctx.getInitiatorCredentials(),\n },\n );\n\n if (!entity && !optional) {\n throw new Error(`Entity ${entityRef} not found`);\n }\n ctx.output('entity', entity ?? null);\n }\n\n if (entityRefs) {\n const entities = await catalog.getEntitiesByRefs(\n {\n entityRefs: entityRefs.map(ref =>\n stringifyEntityRef(\n parseEntityRef(ref, { defaultKind, defaultNamespace }),\n ),\n ),\n },\n { credentials: await ctx.getInitiatorCredentials() },\n );\n\n const finalEntities = entities.items.map((e, i) => {\n if (!e && !optional) {\n throw new Error(`Entity ${entityRefs[i]} not found`);\n }\n return e ?? null;\n });\n\n ctx.output('entities', finalEntities);\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","stringifyEntityRef","parseEntityRef"],"mappings":";;;;;;AAqBA,MAAM,EAAK,GAAA,eAAA;AAOJ,SAAS,+BAA+B,OAE5C,EAAA;AACD,EAAM,MAAA,EAAE,SAAY,GAAA,OAAA;AAEpB,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAA;AAAA,IACA,WACE,EAAA,oEAAA;AAAA,cACFC,uBAAA;AAAA,IACA,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,SAAA,EAAW,CACT,CAAA,KAAA,CAAA,CACG,MAAO,CAAA;AAAA,UACN,WAAa,EAAA;AAAA,SACd,EACA,QAAS,EAAA;AAAA,QACd,YAAY,CACV,CAAA,KAAA,CAAA,CACG,KAAM,CAAA,CAAA,CAAE,QAAU,EAAA;AAAA,UACjB,WAAa,EAAA;AAAA,SACd,EACA,QAAS,EAAA;AAAA,QACd,QAAA,EAAU,CACR,CAAA,KAAA,CAAA,CACG,OAAQ,CAAA;AAAA,UACP,WACE,EAAA;AAAA,SACH,EACA,QAAS,EAAA;AAAA,QACd,WAAA,EAAa,OACX,CAAE,CAAA,MAAA,CAAO,EAAE,WAAa,EAAA,kBAAA,EAAoB,CAAA,CAAE,QAAS,EAAA;AAAA,QACzD,gBAAA,EAAkB,OAChB,CAAE,CAAA,MAAA,CAAO,EAAE,WAAa,EAAA,uBAAA,EAAyB,CAAA,CAAE,QAAS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BAAA;AAAA,gBACEC,2BAAe,CAAA,GAAA,EAAK,EAAE,WAAA,EAAa,kBAAkB;AAAA;AACvD;AACF,WACF;AAAA,UACA,EAAE,WAAA,EAAa,MAAM,GAAA,CAAI,yBAA0B;AAAA,SACrD;AAEA,QAAA,MAAM,gBAAgB,QAAS,CAAA,KAAA,CAAM,GAAI,CAAA,CAAC,GAAG,CAAM,KAAA;AACjD,UAAI,IAAA,CAAC,CAAK,IAAA,CAAC,QAAU,EAAA;AACnB,YAAA,MAAM,IAAI,KAAM,CAAA,CAAA,OAAA,EAAU,UAAW,CAAA,CAAC,CAAC,CAAY,UAAA,CAAA,CAAA;AAAA;AAErD,UAAA,OAAO,CAAK,IAAA,IAAA;AAAA,SACb,CAAA;AAED,QAAI,GAAA,CAAA,MAAA,CAAO,YAAY,aAAa,CAAA;AAAA;AACtC;AACF,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"fetch.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/catalog/fetch.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 { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';\nimport { examples } from './fetch.examples';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\n\nconst id = 'catalog:fetch';\n\n/**\n * Returns entity or entities from the catalog by entity reference(s).\n *\n * @public\n */\nexport function createFetchCatalogEntityAction(options: {\n catalog: CatalogService;\n}) {\n const { catalog } = options;\n\n return createTemplateAction({\n id,\n description:\n 'Returns entity or entities from the catalog by entity reference(s)',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n entityRef: z =>\n z\n .string({\n description: 'Entity reference of the entity to get',\n })\n .optional(),\n entityRefs: z =>\n z\n .array(z.string(), {\n description: 'Entity references of the entities to get',\n })\n .optional(),\n optional: z =>\n z\n .boolean({\n description:\n 'Allow the entity or entities to optionally exist. Default: false',\n })\n .optional(),\n defaultKind: z =>\n z.string({ description: 'The default kind' }).optional(),\n defaultNamespace: z =>\n z.string({ description: 'The default namespace' }).optional(),\n },\n output: {\n entity: z =>\n z\n .any({\n description:\n 'Object containing same values used in the Entity schema. Only when used with `entityRef` parameter.',\n })\n .optional(),\n entities: z =>\n z\n .array(\n z.any({\n description:\n 'Array containing objects with same values used in the Entity schema. Only when used with `entityRefs` parameter.',\n }),\n )\n .optional(),\n },\n },\n async handler(ctx) {\n const { entityRef, entityRefs, optional, defaultKind, defaultNamespace } =\n ctx.input;\n\n if (!entityRef && !entityRefs) {\n if (optional) {\n return;\n }\n throw new Error('Missing entity reference or references');\n }\n\n if (entityRef) {\n const entity = await catalog.getEntityByRef(\n stringifyEntityRef(\n parseEntityRef(entityRef, { defaultKind, defaultNamespace }),\n ),\n {\n credentials: await ctx.getInitiatorCredentials(),\n },\n );\n\n if (!entity && !optional) {\n throw new Error(`Entity ${entityRef} not found`);\n }\n ctx.output('entity', entity ?? null);\n }\n\n if (entityRefs) {\n const entities = await catalog.getEntitiesByRefs(\n {\n entityRefs: entityRefs.map(ref =>\n stringifyEntityRef(\n parseEntityRef(ref, { defaultKind, defaultNamespace }),\n ),\n ),\n },\n { credentials: await ctx.getInitiatorCredentials() },\n );\n\n const finalEntities = entities.items.map((e, i) => {\n if (!e && !optional) {\n throw new Error(`Entity ${entityRefs[i]} not found`);\n }\n return e ?? null;\n });\n\n ctx.output('entities', finalEntities);\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","stringifyEntityRef","parseEntityRef"],"mappings":";;;;;;AAqBA,MAAM,EAAA,GAAK,eAAA;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,UAAA,CAAY,CAAA;AAAA,UACrD;AACA,UAAA,OAAO,CAAA,IAAK,IAAA;AAAA,QACd,CAAC,CAAA;AAED,QAAA,GAAA,CAAI,MAAA,CAAO,YAAY,aAAa,CAAA;AAAA,MACtC;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/catalog/fetch.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: 'Fetch entity by reference',\n example: yaml.stringify({\n steps: [\n {\n action: 'catalog:fetch',\n id: 'fetch',\n name: 'Fetch catalog entity',\n input: {\n entityRef: 'component:default/name',\n },\n },\n ],\n }),\n },\n {\n description: 'Fetch multiple entities by reference',\n example: yaml.stringify({\n steps: [\n {\n action: 'catalog:fetch',\n id: 'fetchMultiple',\n name: 'Fetch catalog entities',\n input: {\n entityRefs: ['component:default/name'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,2BAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,eAAA;AAAA,UACR,EAAI,EAAA,OAAA;AAAA,UACJ,IAAM,EAAA,sBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,SAAW,EAAA;AAAA;AACb;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,sCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,eAAA;AAAA,UACR,EAAI,EAAA,eAAA;AAAA,UACJ,IAAM,EAAA,wBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,UAAA,EAAY,CAAC,wBAAwB;AAAA;AACvC;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"fetch.examples.cjs.js","sources":["../../../../../src/scaffolder/actions/builtin/catalog/fetch.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: 'Fetch entity by reference',\n example: yaml.stringify({\n steps: [\n {\n action: 'catalog:fetch',\n id: 'fetch',\n name: 'Fetch catalog entity',\n input: {\n entityRef: 'component:default/name',\n },\n },\n ],\n }),\n },\n {\n description: 'Fetch multiple entities by reference',\n example: yaml.stringify({\n steps: [\n {\n action: 'catalog:fetch',\n id: 'fetchMultiple',\n name: 'Fetch catalog entities',\n input: {\n entityRefs: ['component:default/name'],\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,eAAA;AAAA,UACR,EAAA,EAAI,OAAA;AAAA,UACJ,IAAA,EAAM,sBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,SAAA,EAAW;AAAA;AACb;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,sCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,eAAA;AAAA,UACR,EAAA,EAAI,eAAA;AAAA,UACJ,IAAA,EAAM,wBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,UAAA,EAAY,CAAC,wBAAwB;AAAA;AACvC;AACF;AACF,KACD;AAAA;AAEL;;;;"}
@@ -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,EAAK,GAAA,kBAAA;AAMJ,SAAS,4BAA4B,OAGzC,EAAA;AACD,EAAM,MAAA,EAAE,OAAS,EAAA,YAAA,EAAiB,GAAA,OAAA;AAElC,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAA;AAAA,IACA,WACE,EAAA,+FAAA;AAAA,cACFC,0BAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAA,EAAO,CACL,CAAA,KAAA,CAAA,CAAE,KAAM,CAAA;AAAA,QACN,EAAE,MAAO,CAAA;AAAA,UACP,cAAA,EAAgB,EAAE,MAAO,CAAA;AAAA,YACvB,WACE,EAAA;AAAA,WACH,CAAA;AAAA,UACD,QAAA,EAAU,EACP,OAAQ,CAAA;AAAA,YACP,WACE,EAAA;AAAA,WACH,EACA,QAAS;AAAA,SACb,CAAA;AAAA,QACD,EAAE,MAAO,CAAA;AAAA,UACP,eAAA,EAAiB,EAAE,MAAO,CAAA;AAAA,YACxB,WACE,EAAA;AAAA,WACH,CAAA;AAAA,UACD,eAAA,EAAiB,EACd,MAAO,CAAA;AAAA,YACN,WACE,EAAA;AAAA,WACH,EACA,QAAS,EAAA;AAAA,UACZ,QAAA,EAAU,EACP,OAAQ,CAAA;AAAA,YACP,WACE,EAAA;AAAA,WACH,EACA,QAAS;AAAA,SACb;AAAA,OACF;AAAA,KACL;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AAC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AA;AAC1B,UAAM,MAAA,EAAE,UAAa,GAAA,MAAA;AACrB,UAAI,IAAA,MAAA;AAEJ,UAAA,MAAA,GAAS,QAAS,CAAA,IAAA;AAAA,YAChB,CAAA,CAAA,KACE,CAAC,CAAE,CAAA,QAAA,CAAS,KAAK,UAAW,CAAA,YAAY,CACxC,IAAA,CAAA,CAAE,IAAS,KAAA;AAAA,WACf;AACA,UAAA,IAAI,CAAC,MAAQ,EAAA;AACX,YAAA,MAAA,GAAS,QAAS,CAAA,IAAA;AAAA,cAChB,OAAK,CAAC,CAAA,CAAE,QAAS,CAAA,IAAA,CAAK,WAAW,YAAY;AAAA,aAC/C;AAAA;AAEF,UAAA,IAAI,CAAC,MAAQ,EAAA;AACX,YAAA,MAAA,GAAS,SAAS,CAAC,CAAA;AAAA;AAGrB,UAAA,GAAA,CAAI,MAAO,CAAA,WAAA,EAAaC,+BAAmB,CAAA,MAAM,CAAC,CAAA;AAAA;AACpD,eACO,CAAG,EAAA;AACV,QAAI,IAAA,CAAC,MAAM,QAAU,EAAA;AACnB,UAAM,MAAA,CAAA;AAAA;AACR;AAGF,MAAI,GAAA,CAAA,MAAA,CAAO,kBAAkB,cAAc,CAAA;AAAA;AAC7C,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,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,WACH,CAAA;AAAA,UACD,eAAA,EAAiB,EACd,MAAA,CAAO;AAAA,YACN,WA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,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 +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,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,2BAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,kBAAA;AAAA,UACR,EAAI,EAAA,uBAAA;AAAA,UACJ,IAAM,EAAA,2BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,cACE,EAAA;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,EAAK,GAAA,eAAA;AAOJ,SAAS,wBAA2B,GAAA;AACzC,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAA;AAAA,IACA,WAAa,EAAA,gDAAA;AAAA,IACb,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,QAAA,EAAU,OACR,CAAE,CAAA,MAAA,GAAS,QAAS,EAAA,CAAE,SAAS,+BAA+B,CAAA;AAAA;AAAA,QAEhE,QAAQ,CACN,CAAA,KAAA,CAAA,CACG,OAAO,CAAE,CAAA,GAAA,EAAK,CACd,CAAA,QAAA;AAAA,UACC;AAAA;AACF;AACN,KACF;AAAA,cACAC,uBAAA;AAAA,IACA,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,MAAM,EAAE,QAAA,EAAU,MAAO,EAAA,GAAI,GAAI,CAAA,KAAA;AACjC,MAAM,MAAA,SAAA,GAAY,IAAI,YAAc,EAAA,SAAA;AACpC,MAAA,MAAM,OAAO,QAAY,IAAA,mBAAA;AACzB,MAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,CAAW,QAAA,EAAA,IAAI,CAAE,CAAA,CAAA;AAEjC,MAAA,MAAMC,mBAAG,CAAA,UAAA;AAAA,QACPC,qCAAA,CAAqB,GAAI,CAAA,aAAA,EAAe,IAAI,CAAA;AAAA,QAC5CC,gBAAK,SAAU,CAAA;AAAA,UACb,GAAG,MAAA;AAAA,UACH,QAAU,EAAA;AAAA,YACR,GAAG,MAAO,CAAA,QAAA;AAAA,YACV,GAAI,SACA,GAAA;AAAA,cACE,WAAa,EAAA;AAAA,gBACX,GAAG,OAAO,QAAS,CAAA,WAAA;AAAA,gBACnB,8BAAgC,EAAA;AAAA;AAClC,aAEF,GAAA,KAAA;AAAA;AACN,SACD;AAAA,OACH;AAAA;AACF,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,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,2BAAA;AAAA,IACb,OAAA,EAASA,gBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,eAAA;AAAA,UACR,EAAI,EAAA,0BAAA;AAAA,UACJ,IAAM,EAAA,qBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,MAAQ,EAAA;AAAA,cACN,UAAY,EAAA,uBAAA;AAAA,cACZ,IAAM,EAAA,WAAA;AAAA,cACN,QAAU,EAAA;AAAA,gBACR,IAAM,EAAA,MAAA;AAAA,gBACN,aAAa;AAAC,eAChB;AAAA,cACA,IAAM,EAAA;AAAA,gBACJ,IAAM,EAAA,SAAA;AAAA,gBACN,SAAW,EAAA,YAAA;AAAA,gBACX,KAAO,EAAA;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 { readdir, stat } from 'fs-extra';\nimport { join, relative } from 'path';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { examples } from './log.examples';\nimport fs from '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 const content = fs.readFileSync(f, 'utf-8');\n return ` - ${relativePath}:\\n\\n ${content}`;\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","fs","readdir","join","stat"],"mappings":";;;;;;;;;;;;AAsBA,MAAM,EAAK,GAAA,WAAA;AAYJ,SAAS,oBAAuB,GAAA;AACrC,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAA;AAAA,IACA,WACE,EAAA,wEAAA;AAAA,cACFC,qBAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,OAAA,EAAS,OACP,CAAE,CAAA,MAAA,CAAO,EAAE,WAAa,EAAA,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A,SACf;AAAA;AACF;AACF,GACD,CAAA;AACH;AAEA,eAAsB,iBAAiB,GAAgC,EAAA;AACrE,EAAM,MAAA,OAAA,GAAU,MAAMC,YAAA,CAAQ,GAAG,CAAA;AACjC,EAAM,MAAA,KAAA,GAAQ,MAAM,OAAQ,CAAA,GAAA;AAAA,IAC1B,OAAA,CAAQ,GAAI,CAAA,OAAM,MAAU,KAAA;AAC1B,MAAM,MAAA,GAAA,GAAMC,SAAK,CAAA,GAAA,EAAK,MAAM,CAAA;AAC5B,MAAQ,OAAA,CAAA,MAAMC,SAAK,CAAA,GAAG,CAAG,EAAA,WAAA,KAAgB,gBAAiB,CAAA,GAAG,CAAI,GAAA,CAAC,GAAG,CAAA;AAAA,KACtE;AAAA,GACH;AACA,EAAO,OAAA,KAAA,CAAM,MAAO,CAAA,CAAC,CAAG,EAAA,CAAA,KAAM,EAAE,MAAO,CAAA,CAAC,CAAG,EAAA,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 { readdir, stat } from 'fs-extra';\nimport { join, relative } from 'path';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { examples } from './log.examples';\nimport fs from '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 const content = fs.readFileSync(f, 'utf-8');\n return ` - ${relativePath}:\\n\\n ${content}`;\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","fs","readdir","join","stat"],"mappings":";;;;;;;;;;;;AAsBA,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,CAA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,EAAA,MAAM,OAAA,GAAU,MAAMC,YAAA,CAAQ,GAAG,CAAA;AACjC,EAAA,MAAM,KAAA,GAAQ,MAAM,OAAA,CAAQ,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,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,uBAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,WAAA;AAAA,UACR,EAAI,EAAA,kBAAA;AAAA,UACJ,IAAM,EAAA,mCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,8BAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,WAAA;AAAA,UACR,EAAI,EAAA,2BAAA;AAAA,UACJ,IAAM,EAAA,8BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,aAAe,EAAA;AAAA;AACjB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,iDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,WAAA;AAAA,UACR,EAAI,EAAA,2BAAA;AAAA,UACJ,IAAM,EAAA,iDAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,aAAe,EAAA;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;;;;"}