@backstage/plugin-scaffolder-backend-module-cookiecutter 0.3.14-next.0 → 0.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-cookiecutter
|
|
2
2
|
|
|
3
|
+
## 0.3.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-defaults@0.12.0
|
|
9
|
+
- @backstage/plugin-scaffolder-node@0.11.0
|
|
10
|
+
- @backstage/backend-plugin-api@1.4.2
|
|
11
|
+
|
|
3
12
|
## 0.3.14-next.0
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookiecutter.cjs.js","sources":["../../../src/actions/fetch/cookiecutter.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n UrlReaderService,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { JsonObject, JsonValue } from '@backstage/types';\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\nimport commandExists from 'command-exists';\nimport fs from 'fs-extra';\nimport path, { resolve as resolvePath } from 'path';\nimport { PassThrough, Writable } from 'stream';\nimport {\n createTemplateAction,\n fetchContents,\n executeShellCommand,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './cookiecutter.examples';\nimport { ContainerRunner } from './ContainerRunner';\n\nexport class CookiecutterRunner {\n private readonly containerRunner?: ContainerRunner;\n\n constructor({ containerRunner }: { containerRunner?: ContainerRunner }) {\n this.containerRunner = containerRunner;\n }\n\n private async fetchTemplateCookieCutter(\n directory: string,\n ): Promise<Record<string, JsonValue>> {\n try {\n return await fs.readJSON(path.join(directory, 'cookiecutter.json'));\n } catch (ex) {\n if (ex.code !== 'ENOENT') {\n throw ex;\n }\n\n return {};\n }\n }\n\n public async run({\n workspacePath,\n values,\n logStream,\n imageName,\n templateDir,\n templateContentsDir,\n }: {\n workspacePath: string;\n values: JsonObject;\n logStream: Writable;\n imageName?: string;\n templateDir: string;\n templateContentsDir: string;\n }): Promise<void> {\n const intermediateDir = path.join(workspacePath, 'intermediate');\n await fs.ensureDir(intermediateDir);\n const resultDir = path.join(workspacePath, 'result');\n\n // First lets grab the default cookiecutter.json file\n const cookieCutterJson = await this.fetchTemplateCookieCutter(\n templateContentsDir,\n );\n\n const cookieInfo = {\n ...cookieCutterJson,\n ...values,\n };\n\n await fs.writeJSON(path.join(templateDir, 'cookiecutter.json'), cookieInfo);\n\n // Directories to bind on container\n const mountDirs = {\n [templateDir]: '/input',\n [intermediateDir]: '/output',\n };\n\n // the command-exists package returns `true` or throws an error\n const cookieCutterInstalled = await commandExists('cookiecutter').catch(\n () => false,\n );\n if (cookieCutterInstalled) {\n await executeShellCommand({\n command: 'cookiecutter',\n args: ['--no-input', '-o', intermediateDir, templateDir, '--verbose'],\n logStream,\n });\n } else {\n if (this.containerRunner === undefined) {\n throw new Error(\n 'Invalid state: containerRunner cannot be undefined when cookiecutter is not installed',\n );\n }\n await this.containerRunner.runContainer({\n imageName: imageName ?? 'spotify/backstage-cookiecutter',\n command: 'cookiecutter',\n args: ['--no-input', '-o', '/output', '/input', '--verbose'],\n mountDirs,\n workingDir: '/input',\n // Set the home directory inside the container as something that applications can\n // write to, otherwise they will just fail trying to write to /\n envVars: { HOME: '/tmp' },\n logStream,\n });\n }\n\n // if cookiecutter was successful, intermediateDir will contain\n // exactly one directory.\n\n const [generated] = await fs.readdir(intermediateDir);\n\n if (generated === undefined) {\n throw new Error('No data generated by cookiecutter');\n }\n\n await fs.move(path.join(intermediateDir, generated), resultDir);\n }\n}\n\n/**\n * Creates a `fetch:cookiecutter` Scaffolder action.\n *\n * @remarks\n *\n * See {@link https://cookiecutter.readthedocs.io/} and {@link https://backstage.io/docs/features/software-templates/writing-custom-actions}.\n * @param options - Templating configuration.\n * @public\n */\nexport function createFetchCookiecutterAction(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n containerRunner?: ContainerRunner;\n}) {\n const { reader, containerRunner, integrations } = options;\n\n return createTemplateAction({\n id: 'fetch:cookiecutter',\n description:\n 'Downloads a template from the given URL into the workspace, and runs cookiecutter on it.',\n examples,\n schema: {\n input: {\n url: z =>\n z.string({\n description:\n 'Relative path or absolute URL pointing to the directory tree to fetch',\n }),\n targetPath: z =>\n z\n .string({\n description:\n 'Target path within the working directory to download the contents to.',\n })\n .optional(),\n values: z =>\n z\n .object(\n {},\n {\n description: 'Values to pass on to cookiecutter for templating',\n },\n )\n .passthrough(),\n copyWithoutRender: z =>\n z\n .array(z.string(), {\n description:\n 'Avoid rendering directories and files in the template',\n })\n .optional(),\n extensions: z =>\n z\n .array(z.string(), {\n description:\n \"Jinja2 extensions to add filters, tests, globals or extend the parser. Extensions must be installed in the container or on the host where Cookiecutter executes. See the contrib directory in Backstage's repo for more information\",\n })\n .optional(),\n imageName: z =>\n z\n .string({\n description:\n \"Specify a custom Docker image to run cookiecutter, to override the default: 'spotify/backstage-cookiecutter'. This can be used to execute cookiecutter with Template Extensions. Used only when a local cookiecutter is not found.\",\n })\n .optional(),\n },\n },\n async handler(ctx) {\n ctx.logger.info('Fetching and then templating using cookiecutter');\n const workDir = await ctx.createTemporaryDirectory();\n const templateDir = resolvePath(workDir, 'template');\n const templateContentsDir = resolvePath(\n templateDir,\n \"{{cookiecutter and 'contents'}}\",\n );\n const resultDir = resolvePath(workDir, 'result');\n\n if (\n ctx.input.copyWithoutRender &&\n !Array.isArray(ctx.input.copyWithoutRender)\n ) {\n throw new InputError(\n 'Fetch action input copyWithoutRender must be an Array',\n );\n }\n if (ctx.input.extensions && !Array.isArray(ctx.input.extensions)) {\n throw new InputError('Fetch action input extensions must be an Array');\n }\n\n await fetchContents({\n reader,\n integrations,\n baseUrl: ctx.templateInfo?.baseUrl,\n fetchUrl: ctx.input.url,\n outputPath: templateContentsDir,\n });\n\n const cookiecutter = new CookiecutterRunner({ containerRunner });\n const values = {\n ...ctx.input.values,\n _copy_without_render: ctx.input.copyWithoutRender,\n _extensions: ctx.input.extensions,\n };\n\n const logStream = new PassThrough();\n logStream.on('data', chunk => {\n ctx.logger.info(chunk.toString());\n });\n\n // Will execute the template in ./template and put the result in ./result\n await cookiecutter.run({\n workspacePath: workDir,\n logStream,\n values: values,\n imageName: ctx.input.imageName,\n templateDir: templateDir,\n templateContentsDir: templateContentsDir,\n });\n\n // Finally move the template result into the task workspace\n const targetPath = ctx.input.targetPath ?? './';\n const outputPath = resolveSafeChildPath(ctx.workspacePath, targetPath);\n await fs.copy(resultDir, outputPath);\n },\n });\n}\n"],"names":["fs","path","commandExists","executeShellCommand","createTemplateAction","examples","resolvePath","InputError","fetchContents","PassThrough","resolveSafeChildPath"],"mappings":";;;;;;;;;;;;;;;;;AAmCO,MAAM,kBAAmB,CAAA;AAAA,EACb,eAAA;AAAA,EAEjB,WAAA,CAAY,EAAE,eAAA,EAA0D,EAAA;AACtE,IAAA,IAAA,CAAK,eAAkB,GAAA,eAAA;AAAA;AACzB,EAEA,MAAc,0BACZ,SACoC,EAAA;AACpC,IAAI,IAAA;AACF,MAAA,OAAO,MAAMA,mBAAG,CAAA,QAAA,CAASC,sBAAK,IAAK,CAAA,SAAA,EAAW,mBAAmB,CAAC,CAAA;AAAA,aAC3D,EAAI,EAAA;AACX,MAAI,IAAA,EAAA,CAAG,SAAS,QAAU,EAAA;AACxB,QAAM,MAA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A,EAAU,IAAI,KAAM,CAAA,GAAA;AAAA,QACpB,UAAY,EAAA;AAAA,OACb,CAAA;AAED,MAAA,MAAM,YAAe,GAAA,IAAI,kBAAmB,CAAA,EAAE,iBAAiB,CAAA;AAC/D,MAAA,MAAM,MAAS,GAAA;AAAA,QACb,GAAG,IAAI,KAAM,CAAA,MAAA;AAAA,QACb,oBAAA,EAAsB,IAAI,KAAM,CAAA,iBAAA;AAAA,QAChC,WAAA,EAAa,IAAI,KAAM,CAAA;AAAA,OACzB;AAEA,MAAM,MAAA,SAAA,GAAY,IAAIC,kBAAY,EAAA;AAClC,MAAU,SAAA,CAAA,EAAA,CAAG,QAAQ,CAAS,KAAA,KAAA;AAC5B,QAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,KAAM,CAAA,QAAA,EAAU,CAAA;AAAA,OACjC,CAAA;AAGD,MAAA,MAAM,aAAa,GAAI,CAAA;AAAA,QACrB,aAAe,EAAA,OAAA;AAAA,QACf,SAAA;AAAA,QACA,MAAA;AAAA,QACA,SAAA,EAAW,IAAI,KAAM,CAAA,SAAA;AAAA,QACrB,WAAA;AAAA,QACA;AAAA,OACD,CAAA;AAGD,MAAM,MAAA,UAAA,GAAa,GAAI,CAAA,KAAA,CAAM,UAAc,IAAA,IAAA;AAC3C,MAAA,MAAM,UAAa,GAAAC,qCAAA,CAAqB,GAAI,CAAA,aAAA,EAAe,UAAU,CAAA;AACrE,MAAM,MAAAV,mBAAA,CAAG,IAAK,CAAA,SAAA,EAAW,UAAU,CAAA;AAAA;AACrC,GACD,CAAA;AACH;;;;;"}
|
|
1
|
+
{"version":3,"file":"cookiecutter.cjs.js","sources":["../../../src/actions/fetch/cookiecutter.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n UrlReaderService,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { JsonObject, JsonValue } from '@backstage/types';\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\nimport commandExists from 'command-exists';\nimport fs from 'fs-extra';\nimport path, { resolve as resolvePath } from 'path';\nimport { PassThrough, Writable } from 'stream';\nimport {\n createTemplateAction,\n fetchContents,\n executeShellCommand,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './cookiecutter.examples';\nimport { ContainerRunner } from './ContainerRunner';\n\nexport class CookiecutterRunner {\n private readonly containerRunner?: ContainerRunner;\n\n constructor({ containerRunner }: { containerRunner?: ContainerRunner }) {\n this.containerRunner = containerRunner;\n }\n\n private async fetchTemplateCookieCutter(\n directory: string,\n ): Promise<Record<string, JsonValue>> {\n try {\n return await fs.readJSON(path.join(directory, 'cookiecutter.json'));\n } catch (ex) {\n if (ex.code !== 'ENOENT') {\n throw ex;\n }\n\n return {};\n }\n }\n\n public async run({\n workspacePath,\n values,\n logStream,\n imageName,\n templateDir,\n templateContentsDir,\n }: {\n workspacePath: string;\n values: JsonObject;\n logStream: Writable;\n imageName?: string;\n templateDir: string;\n templateContentsDir: string;\n }): Promise<void> {\n const intermediateDir = path.join(workspacePath, 'intermediate');\n await fs.ensureDir(intermediateDir);\n const resultDir = path.join(workspacePath, 'result');\n\n // First lets grab the default cookiecutter.json file\n const cookieCutterJson = await this.fetchTemplateCookieCutter(\n templateContentsDir,\n );\n\n const cookieInfo = {\n ...cookieCutterJson,\n ...values,\n };\n\n await fs.writeJSON(path.join(templateDir, 'cookiecutter.json'), cookieInfo);\n\n // Directories to bind on container\n const mountDirs = {\n [templateDir]: '/input',\n [intermediateDir]: '/output',\n };\n\n // the command-exists package returns `true` or throws an error\n const cookieCutterInstalled = await commandExists('cookiecutter').catch(\n () => false,\n );\n if (cookieCutterInstalled) {\n await executeShellCommand({\n command: 'cookiecutter',\n args: ['--no-input', '-o', intermediateDir, templateDir, '--verbose'],\n logStream,\n });\n } else {\n if (this.containerRunner === undefined) {\n throw new Error(\n 'Invalid state: containerRunner cannot be undefined when cookiecutter is not installed',\n );\n }\n await this.containerRunner.runContainer({\n imageName: imageName ?? 'spotify/backstage-cookiecutter',\n command: 'cookiecutter',\n args: ['--no-input', '-o', '/output', '/input', '--verbose'],\n mountDirs,\n workingDir: '/input',\n // Set the home directory inside the container as something that applications can\n // write to, otherwise they will just fail trying to write to /\n envVars: { HOME: '/tmp' },\n logStream,\n });\n }\n\n // if cookiecutter was successful, intermediateDir will contain\n // exactly one directory.\n\n const [generated] = await fs.readdir(intermediateDir);\n\n if (generated === undefined) {\n throw new Error('No data generated by cookiecutter');\n }\n\n await fs.move(path.join(intermediateDir, generated), resultDir);\n }\n}\n\n/**\n * Creates a `fetch:cookiecutter` Scaffolder action.\n *\n * @remarks\n *\n * See {@link https://cookiecutter.readthedocs.io/} and {@link https://backstage.io/docs/features/software-templates/writing-custom-actions}.\n * @param options - Templating configuration.\n * @public\n */\nexport function createFetchCookiecutterAction(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n containerRunner?: ContainerRunner;\n}) {\n const { reader, containerRunner, integrations } = options;\n\n return createTemplateAction({\n id: 'fetch:cookiecutter',\n description:\n 'Downloads a template from the given URL into the workspace, and runs cookiecutter on it.',\n examples,\n schema: {\n input: {\n url: z =>\n z.string({\n description:\n 'Relative path or absolute URL pointing to the directory tree to fetch',\n }),\n targetPath: z =>\n z\n .string({\n description:\n 'Target path within the working directory to download the contents to.',\n })\n .optional(),\n values: z =>\n z\n .object(\n {},\n {\n description: 'Values to pass on to cookiecutter for templating',\n },\n )\n .passthrough(),\n copyWithoutRender: z =>\n z\n .array(z.string(), {\n description:\n 'Avoid rendering directories and files in the template',\n })\n .optional(),\n extensions: z =>\n z\n .array(z.string(), {\n description:\n \"Jinja2 extensions to add filters, tests, globals or extend the parser. Extensions must be installed in the container or on the host where Cookiecutter executes. See the contrib directory in Backstage's repo for more information\",\n })\n .optional(),\n imageName: z =>\n z\n .string({\n description:\n \"Specify a custom Docker image to run cookiecutter, to override the default: 'spotify/backstage-cookiecutter'. This can be used to execute cookiecutter with Template Extensions. Used only when a local cookiecutter is not found.\",\n })\n .optional(),\n },\n },\n async handler(ctx) {\n ctx.logger.info('Fetching and then templating using cookiecutter');\n const workDir = await ctx.createTemporaryDirectory();\n const templateDir = resolvePath(workDir, 'template');\n const templateContentsDir = resolvePath(\n templateDir,\n \"{{cookiecutter and 'contents'}}\",\n );\n const resultDir = resolvePath(workDir, 'result');\n\n if (\n ctx.input.copyWithoutRender &&\n !Array.isArray(ctx.input.copyWithoutRender)\n ) {\n throw new InputError(\n 'Fetch action input copyWithoutRender must be an Array',\n );\n }\n if (ctx.input.extensions && !Array.isArray(ctx.input.extensions)) {\n throw new InputError('Fetch action input extensions must be an Array');\n }\n\n await fetchContents({\n reader,\n integrations,\n baseUrl: ctx.templateInfo?.baseUrl,\n fetchUrl: ctx.input.url,\n outputPath: templateContentsDir,\n });\n\n const cookiecutter = new CookiecutterRunner({ containerRunner });\n const values = {\n ...ctx.input.values,\n _copy_without_render: ctx.input.copyWithoutRender,\n _extensions: ctx.input.extensions,\n };\n\n const logStream = new PassThrough();\n logStream.on('data', chunk => {\n ctx.logger.info(chunk.toString());\n });\n\n // Will execute the template in ./template and put the result in ./result\n await cookiecutter.run({\n workspacePath: workDir,\n logStream,\n values: values,\n imageName: ctx.input.imageName,\n templateDir: templateDir,\n templateContentsDir: templateContentsDir,\n });\n\n // Finally move the template result into the task workspace\n const targetPath = ctx.input.targetPath ?? './';\n const outputPath = resolveSafeChildPath(ctx.workspacePath, targetPath);\n await fs.copy(resultDir, outputPath);\n },\n });\n}\n"],"names":["fs","path","commandExists","executeShellCommand","createTemplateAction","examples","resolvePath","InputError","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AAM,UAAA,GAAa,GAAA,CAAI,KAAA,CAAM,UAAA,IAAc,IAAA;AAC3C,MAAA,MAAM,UAAA,GAAaC,qCAAA,CAAqB,GAAA,CAAI,aAAA,EAAe,UAAU,CAAA;AACrE,MAAA,MAAMV,mBAAA,CAAG,IAAA,CAAK,SAAA,EAAW,UAAU,CAAA;AAAA,IACrC;AAAA,GACD,CAAA;AACH;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookiecutter.examples.cjs.js","sources":["../../../src/actions/fetch/cookiecutter.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 and template using cookiecutter with minimal options.',\n example: yaml.stringify({\n steps: [\n {\n id: 'fetchTemplate',\n action: 'fetch:cookiecutter',\n name: 'Fetch and Template Using Cookiecutter',\n input: {\n url: 'https://google.com/cookie/cutter',\n values: {\n help: 'me',\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Fetch and template using cookiecutter with custom target path.',\n example: yaml.stringify({\n steps: [\n {\n id: 'fetchTemplate',\n action: 'fetch:cookiecutter',\n name: 'Fetch and Template Using Cookiecutter',\n input: {\n url: 'https://google.com/cookie/cutter',\n targetPath: 'custom-path',\n values: {\n help: 'me',\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Fetch and template using cookiecutter with copyWithoutRender.',\n example: yaml.stringify({\n steps: [\n {\n id: 'fetchTemplate',\n action: 'fetch:cookiecutter',\n name: 'Fetch and Template Using Cookiecutter',\n input: {\n url: 'https://google.com/cookie/cutter',\n values: {\n help: 'me',\n },\n copyWithoutRender: ['.github/*', '*.md'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Fetch and template using cookiecutter with custom extensions.',\n example: yaml.stringify({\n steps: [\n {\n id: 'fetchTemplate',\n action: 'fetch:cookiecutter',\n name: 'Fetch and Template Using Cookiecutter',\n input: {\n url: 'https://google.com/cookie/cutter',\n values: {\n help: 'me',\n },\n extensions: ['jinja2_time.TimeExtension'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Fetch and template using cookiecutter with a custom Docker image.',\n example: yaml.stringify({\n steps: [\n {\n id: 'fetchTemplate',\n action: 'fetch:cookiecutter',\n name: 'Fetch and Template Using Cookiecutter',\n input: {\n url: 'https://google.com/cookie/cutter',\n values: {\n help: 'me',\n },\n imageName: 'custom/cookiecutter-image',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,
|
|
1
|
+
{"version":3,"file":"cookiecutter.examples.cjs.js","sources":["../../../src/actions/fetch/cookiecutter.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 and template using cookiecutter with minimal options.',\n example: yaml.stringify({\n steps: [\n {\n id: 'fetchTemplate',\n action: 'fetch:cookiecutter',\n name: 'Fetch and Template Using Cookiecutter',\n input: {\n url: 'https://google.com/cookie/cutter',\n values: {\n help: 'me',\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Fetch and template using cookiecutter with custom target path.',\n example: yaml.stringify({\n steps: [\n {\n id: 'fetchTemplate',\n action: 'fetch:cookiecutter',\n name: 'Fetch and Template Using Cookiecutter',\n input: {\n url: 'https://google.com/cookie/cutter',\n targetPath: 'custom-path',\n values: {\n help: 'me',\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Fetch and template using cookiecutter with copyWithoutRender.',\n example: yaml.stringify({\n steps: [\n {\n id: 'fetchTemplate',\n action: 'fetch:cookiecutter',\n name: 'Fetch and Template Using Cookiecutter',\n input: {\n url: 'https://google.com/cookie/cutter',\n values: {\n help: 'me',\n },\n copyWithoutRender: ['.github/*', '*.md'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Fetch and template using cookiecutter with custom extensions.',\n example: yaml.stringify({\n steps: [\n {\n id: 'fetchTemplate',\n action: 'fetch:cookiecutter',\n name: 'Fetch and Template Using Cookiecutter',\n input: {\n url: 'https://google.com/cookie/cutter',\n values: {\n help: 'me',\n },\n extensions: ['jinja2_time.TimeExtension'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Fetch and template using cookiecutter with a custom Docker image.',\n example: yaml.stringify({\n steps: [\n {\n id: 'fetchTemplate',\n action: 'fetch:cookiecutter',\n name: 'Fetch and Template Using Cookiecutter',\n input: {\n url: 'https://google.com/cookie/cutter',\n values: {\n help: 'me',\n },\n imageName: 'custom/cookiecutter-image',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,6DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,eAAA;AAAA,UACJ,MAAA,EAAQ,oBAAA;AAAA,UACR,IAAA,EAAM,uCAAA;AAAA,UAC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ACR;AAAA,YACA,UAAA,EAAY,CAAC,2BAA2B;AAAA;AAC1C;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,mEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,eAAA;AAAA,UACJ,MAAA,EAAQ,oBAAA;AAAA,UACR,IAAA,EAAM,uCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,GAAA,EAAK,kCAAA;AAAA,YACL,MAAA,EAAQ;AAAA,cACN,IAAA,EAAM;AAAA,aACR;AAAA,YACA,SAAA,EAAW;AAAA;AACb;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
package/dist/module.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.cjs.js","sources":["../src/module.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 */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport { createFetchCookiecutterAction } from './actions';\nimport { ScmIntegrations } from '@backstage/integration';\n\n/**\n * @public\n * The Cookiecutter Module for the Scaffolder Backend\n */\nexport const cookiecutterModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'cookiecutter',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n config: coreServices.rootConfig,\n reader: coreServices.urlReader,\n },\n async init({ scaffolder, config, reader }) {\n const integrations = ScmIntegrations.fromConfig(config);\n scaffolder.addActions(\n createFetchCookiecutterAction({ reader, integrations }),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","coreServices","ScmIntegrations","createFetchCookiecutterAction"],"mappings":";;;;;;;AA2BO,MAAM,qBAAqBA,
|
|
1
|
+
{"version":3,"file":"module.cjs.js","sources":["../src/module.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 */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport { createFetchCookiecutterAction } from './actions';\nimport { ScmIntegrations } from '@backstage/integration';\n\n/**\n * @public\n * The Cookiecutter Module for the Scaffolder Backend\n */\nexport const cookiecutterModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'cookiecutter',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n config: coreServices.rootConfig,\n reader: coreServices.urlReader,\n },\n async init({ scaffolder, config, reader }) {\n const integrations = ScmIntegrations.fromConfig(config);\n scaffolder.addActions(\n createFetchCookiecutterAction({ reader, integrations }),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","coreServices","ScmIntegrations","createFetchCookiecutterAction"],"mappings":";;;;;;;AA2BO,MAAM,qBAAqBA,oCAAA,CAAoB;AAAA,EACpD,QAAA,EAAU,YAAA;AAAA,EACV,QAAA,EAAU,cAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAa,EAAG;AACzB,IAAA,YAAA,CAAa;AAAA,MACX,IAAA,EAAM;AAAA,QACJ,UAAA,EAAYC,qCAAA;AAAA,QACZ,QAAQC,6BAAA,CAAa,UAAA;AAAA,QACrB,QAAQA,6BAAA,CAAa;AAAA,OACvB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,EAAY,MAAA,EAAQ,QAAO,EAAG;AACzC,QAAA,MAAM,YAAA,GAAeC,2BAAA,CAAgB,UAAA,CAAW,MAAM,CAAA;AACtD,QAAA,UAAA,CAAW,UAAA;AAAA,UACTC,0CAAA,CAA8B,EAAE,MAAA,EAAQ,YAAA,EAAc;AAAA,SACxD;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend-module-cookiecutter",
|
|
3
|
-
"version": "0.3.14
|
|
3
|
+
"version": "0.3.14",
|
|
4
4
|
"description": "A module for the scaffolder backend that lets you template projects using cookiecutter",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"test": "backstage-cli package test"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@backstage/backend-defaults": "0.
|
|
55
|
-
"@backstage/backend-plugin-api": "1.4.2
|
|
56
|
-
"@backstage/config": "1.3.3",
|
|
57
|
-
"@backstage/errors": "1.2.7",
|
|
58
|
-
"@backstage/integration": "1.17.1",
|
|
59
|
-
"@backstage/plugin-scaffolder-node": "0.11.0
|
|
60
|
-
"@backstage/types": "1.2.1",
|
|
54
|
+
"@backstage/backend-defaults": "^0.12.0",
|
|
55
|
+
"@backstage/backend-plugin-api": "^1.4.2",
|
|
56
|
+
"@backstage/config": "^1.3.3",
|
|
57
|
+
"@backstage/errors": "^1.2.7",
|
|
58
|
+
"@backstage/integration": "^1.17.1",
|
|
59
|
+
"@backstage/plugin-scaffolder-node": "^0.11.0",
|
|
60
|
+
"@backstage/types": "^1.2.1",
|
|
61
61
|
"command-exists": "^1.2.9",
|
|
62
62
|
"fs-extra": "^11.2.0",
|
|
63
63
|
"winston": "^3.2.1",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"yn": "^4.0.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@backstage/backend-test-utils": "1.
|
|
69
|
-
"@backstage/cli": "0.
|
|
70
|
-
"@backstage/plugin-scaffolder-node-test-utils": "0.3.2
|
|
68
|
+
"@backstage/backend-test-utils": "^1.8.0",
|
|
69
|
+
"@backstage/cli": "^0.34.0",
|
|
70
|
+
"@backstage/plugin-scaffolder-node-test-utils": "^0.3.2",
|
|
71
71
|
"@types/command-exists": "^1.2.0",
|
|
72
72
|
"@types/fs-extra": "^11.0.0"
|
|
73
73
|
}
|