diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index 47f5a31158..c6237bc726 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -24,8 +24,9 @@ "@backstage/backend-common": "^0.1.1-alpha.12", "@backstage/catalog-model": "^0.1.1-alpha.12", "@backstage/config": "^0.1.1-alpha.12", - "@types/express": "^4.17.6", + "@octokit/rest": "^18.0.0", "@types/dockerode": "^2.5.32", + "@types/express": "^4.17.6", "compression": "^1.7.4", "cors": "^2.8.5", "dockerode": "^3.2.0", diff --git a/plugins/scaffolder-backend/src/scaffolder/index.ts b/plugins/scaffolder-backend/src/scaffolder/index.ts index a1ee172184..2c689489e4 100644 --- a/plugins/scaffolder-backend/src/scaffolder/index.ts +++ b/plugins/scaffolder-backend/src/scaffolder/index.ts @@ -14,6 +14,5 @@ * limitations under the License. */ export * from './stages/templater'; -export * from './stages/templater/cookiecutter'; export * from './stages/prepare'; export * from './jobs'; diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/store/github.ts b/plugins/scaffolder-backend/src/scaffolder/stages/store/github.ts new file mode 100644 index 0000000000..f3b69cc361 --- /dev/null +++ b/plugins/scaffolder-backend/src/scaffolder/stages/store/github.ts @@ -0,0 +1,15 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/templater/index.ts b/plugins/scaffolder-backend/src/scaffolder/stages/templater/index.ts index d0bbb0aa6c..0813d0ab86 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/templater/index.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/templater/index.ts @@ -13,45 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import type { Writable } from 'stream'; -import Docker from 'dockerode'; -import { JsonValue } from '@backstage/config'; - -export interface RequiredTemplateValues { - component_id: string; -} - -export interface TemplaterRunOptions { - directory: string; - values: RequiredTemplateValues & Record; - logStream?: Writable; - dockerClient: Docker; -} - -export type TemplaterBase = { - // runs the templating with the values and returns the directory to push the VCS - run(opts: TemplaterRunOptions): Promise; -}; - -export interface TemplaterConfig { - templater?: TemplaterBase; -} - -class Templater implements TemplaterBase { - templater?: TemplaterBase; - - constructor({ templater }: TemplaterConfig) { - this.templater = templater; - } - - public async run(opts: TemplaterRunOptions) { - return this.templater!.run(opts); - } -} - -export const createTemplater = ( - templaterConfig: TemplaterConfig, -): TemplaterBase => { - return new Templater(templaterConfig); -}; +export * from './cookiecutter'; +export * from './types'; +export * from './helpers'; diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/templater/types.ts b/plugins/scaffolder-backend/src/scaffolder/stages/templater/types.ts new file mode 100644 index 0000000000..5788b6b657 --- /dev/null +++ b/plugins/scaffolder-backend/src/scaffolder/stages/templater/types.ts @@ -0,0 +1,39 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import type { Writable } from 'stream'; +import Docker from 'dockerode'; +import { JsonValue } from '@backstage/config'; + +export type RequiredTemplateValues = { + component_id: string; +}; + +export type TemplaterRunOptions = { + directory: string; + values: RequiredTemplateValues & Record; + logStream?: Writable; + dockerClient: Docker; +}; + +export type TemplaterBase = { + // runs the templating with the values and returns the directory to push the VCS + run(opts: TemplaterRunOptions): Promise; +}; + +export type TemplaterConfig = { + templater?: TemplaterBase; +};