feat(scaffolder): now the scaffolder is passed a list of templaters which is decided by the template definition

This commit is contained in:
blam
2020-07-13 11:55:39 +02:00
parent 1d4d07e07d
commit d91c10f654
2 changed files with 19 additions and 3 deletions
+1
View File
@@ -29,6 +29,7 @@
"@backstage/plugin-scaffolder-backend": "^0.1.1-alpha.13",
"@backstage/plugin-sentry-backend": "^0.1.1-alpha.13",
"@backstage/plugin-techdocs-backend": "^0.1.1-alpha.13",
"@octokit/rest": "^18.0.0",
"dockerode": "^3.2.0",
"express": "^4.17.1",
"knex": "^0.21.1",
+18 -3
View File
@@ -20,19 +20,34 @@ import {
FilePreparer,
GithubPreparer,
Preparers,
GithubPublisher,
Templaters,
} from '@backstage/plugin-scaffolder-backend';
import { Octokit } from '@octokit/rest';
import type { PluginEnvironment } from '../types';
import Docker from 'dockerode';
export default async function createPlugin({ logger }: PluginEnvironment) {
const templater = new CookieCutter();
const cookiecutterTemplater = new CookieCutter();
const templaters = new Templaters();
templaters.register('cookiecutter', cookiecutterTemplater);
const filePreparer = new FilePreparer();
const githubPreparer = new GithubPreparer();
const preparers = new Preparers();
const dockerClient = new Docker();
preparers.register('file', filePreparer);
preparers.register('github', githubPreparer);
return await createRouter({ preparers, templater, logger, dockerClient });
const githubClient = new Octokit({ auth: process.env.GITHUB_ACCESS_TOKEN });
const publisher = new GithubPublisher({ client: githubClient });
const dockerClient = new Docker();
return await createRouter({
preparers,
templaters,
publisher,
logger,
dockerClient,
});
}