Merge pull request #9519 from slougheed/fix/cookiecutter-loading
Fixed path for loading cookiecutter.json
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend-module-cookiecutter': patch
|
||||
---
|
||||
|
||||
Fixed bug where existing cookiecutter.json file is not used.
|
||||
@@ -57,23 +57,29 @@ export class CookiecutterRunner {
|
||||
workspacePath,
|
||||
values,
|
||||
logStream,
|
||||
imageName,
|
||||
templateDir,
|
||||
templateContentsDir,
|
||||
}: {
|
||||
workspacePath: string;
|
||||
values: JsonObject;
|
||||
logStream: Writable;
|
||||
imageName?: string;
|
||||
templateDir: string;
|
||||
templateContentsDir: string;
|
||||
}): Promise<void> {
|
||||
const templateDir = path.join(workspacePath, 'template');
|
||||
const intermediateDir = path.join(workspacePath, 'intermediate');
|
||||
await fs.ensureDir(intermediateDir);
|
||||
const resultDir = path.join(workspacePath, 'result');
|
||||
|
||||
// First lets grab the default cookiecutter.json file
|
||||
const cookieCutterJson = await this.fetchTemplateCookieCutter(templateDir);
|
||||
const cookieCutterJson = await this.fetchTemplateCookieCutter(
|
||||
templateContentsDir,
|
||||
);
|
||||
|
||||
const { imageName, ...valuesForCookieCutterJson } = values;
|
||||
const cookieInfo = {
|
||||
...cookieCutterJson,
|
||||
...valuesForCookieCutterJson,
|
||||
...values,
|
||||
};
|
||||
|
||||
await fs.writeJSON(path.join(templateDir, 'cookiecutter.json'), cookieInfo);
|
||||
@@ -96,7 +102,7 @@ export class CookiecutterRunner {
|
||||
});
|
||||
} else {
|
||||
await this.containerRunner.runContainer({
|
||||
imageName: (imageName as string) ?? 'spotify/backstage-cookiecutter',
|
||||
imageName: imageName ?? 'spotify/backstage-cookiecutter',
|
||||
command: 'cookiecutter',
|
||||
args: ['--no-input', '-o', '/output', '/input', '--verbose'],
|
||||
mountDirs,
|
||||
@@ -232,14 +238,16 @@ export function createFetchCookiecutterAction(options: {
|
||||
...ctx.input.values,
|
||||
_copy_without_render: ctx.input.copyWithoutRender,
|
||||
_extensions: ctx.input.extensions,
|
||||
imageName: ctx.input.imageName,
|
||||
};
|
||||
|
||||
// Will execute the template in ./template and put the result in ./result
|
||||
await cookiecutter.run({
|
||||
workspacePath: workDir,
|
||||
logStream: ctx.logStream,
|
||||
values,
|
||||
values: values,
|
||||
imageName: ctx.input.imageName,
|
||||
templateDir: templateDir,
|
||||
templateContentsDir: templateContentsDir,
|
||||
});
|
||||
|
||||
// Finally move the template result into the task workspace
|
||||
|
||||
Reference in New Issue
Block a user