diff --git a/packages/backend/package.json b/packages/backend/package.json index 0530f04452..01614f1ce2 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -16,6 +16,7 @@ }, "dependencies": { "@backstage/plugin-inventory-backend": "0.1.1-alpha.4", + "@backstage/plugin-scaffolder-backend": "0.1.1-alpha.4", "compression": "^1.7.4", "cors": "^2.8.5", "express": "^4.17.1", diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index fd8015c328..340a427612 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -28,6 +28,7 @@ import helmet from 'helmet'; import compression from 'compression'; import { testRouter } from './test'; import { router as inventoryRouter } from '@backstage/plugin-inventory-backend'; +import { router as scaffolderRouter } from '@backstage/plugin-scaffolder-backend'; const DEFAULT_PORT = 7000; @@ -40,6 +41,7 @@ app.use(compression()); app.use(express.json()); app.use('/test', testRouter); app.use('/inventory', inventoryRouter); +app.use('/scaffolder', scaffolderRouter); app.listen(PORT, () => { console.log(`Listening on port ${PORT}`); diff --git a/plugins/scaffolder-backend/.eslintrc.js b/plugins/scaffolder-backend/.eslintrc.js new file mode 100644 index 0000000000..f400a039e7 --- /dev/null +++ b/plugins/scaffolder-backend/.eslintrc.js @@ -0,0 +1,6 @@ +module.exports = { + rules: { + 'no-console': 0, // Permitted in console programs + 'new-cap': ['error', { capIsNew: false }], // Because Express constructs things e.g. like 'const r = express.Router()' + }, +}; diff --git a/plugins/scaffolder-backend/README.md b/plugins/scaffolder-backend/README.md new file mode 100644 index 0000000000..7ffbeae1d1 --- /dev/null +++ b/plugins/scaffolder-backend/README.md @@ -0,0 +1,6 @@ +# Title +Welcome to the scaffolder plugin! + +## Sub-section 1 + +## Sub-section 2 diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json new file mode 100644 index 0000000000..b531f78e9e --- /dev/null +++ b/plugins/scaffolder-backend/package.json @@ -0,0 +1,19 @@ +{ + "name": "@backstage/plugin-scaffolder-backend", + "version": "0.1.1-alpha.4", + "main": "dist", + "license": "Apache-2.0", + "private": true, + "scripts": { + "build": "tsc", + "lint": "backstage-cli lint", + "test": "backstage-cli test", + "clean": "backstage-cli clean" + }, + "devDependencies": { + "@backstage/cli": "^0.1.1-alpha.4" + }, + "dependencies": { + "express": "^4.17.1" + } +} diff --git a/plugins/scaffolder-backend/src/index.ts b/plugins/scaffolder-backend/src/index.ts new file mode 100644 index 0000000000..92c9090376 --- /dev/null +++ b/plugins/scaffolder-backend/src/index.ts @@ -0,0 +1,17 @@ +/* + * 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. + */ + +export { router } from './plugin'; diff --git a/plugins/scaffolder-backend/src/plugin.test.ts b/plugins/scaffolder-backend/src/plugin.test.ts new file mode 100644 index 0000000000..85c04231c0 --- /dev/null +++ b/plugins/scaffolder-backend/src/plugin.test.ts @@ -0,0 +1,38 @@ +/* + * 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. + */ +// /* +// * 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 { plugiroutn } from './plugin'; + +// describe('scaffolder', () => { +// it('should export plugin', () => { +// expect(plugin).toBeDefined(); +// }); +// }); diff --git a/plugins/scaffolder-backend/src/plugin.ts b/plugins/scaffolder-backend/src/plugin.ts new file mode 100644 index 0000000000..cccce7a229 --- /dev/null +++ b/plugins/scaffolder-backend/src/plugin.ts @@ -0,0 +1,88 @@ +/* + * 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. + */ +/* + * 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 express from 'express'; + +export const router = express.Router(); + +router.get('/v1/templates', async (_, res) => { + res + .status(200) + .send([ + { id: 'component1' }, + { id: 'component2' }, + { id: 'component3' }, + { id: 'component4' }, + ]); +}); + +router.get('/v1/template/:templateId', async (_, res) => { + res + .status(200) + .send([ + { id: 'component1' }, + { id: 'component2' }, + { id: 'component3' }, + { id: 'component4' }, + ]); +}); + +router.post('/v1/jobs', async (_, res) => { + res + .status(200) + .send([ + { id: 'component1' }, + { id: 'component2' }, + { id: 'component3' }, + { id: 'component4' }, + ]); +}); + +router.get('/v1/jobs', async (_, res) => { + res + .status(200) + .send([ + { id: 'component1' }, + { id: 'component2' }, + { id: 'component3' }, + { id: 'component4' }, + ]); +}); + +router.get('/v1/job/:jobId', async (_, res) => { + res + .status(200) + .send([ + { id: 'component1' }, + { id: 'component2' }, + { id: 'component3' }, + { id: 'component4' }, + ]); +}); diff --git a/plugins/scaffolder-backend/tsconfig.json b/plugins/scaffolder-backend/tsconfig.json new file mode 100644 index 0000000000..1b1b7e9003 --- /dev/null +++ b/plugins/scaffolder-backend/tsconfig.json @@ -0,0 +1,14 @@ +{ + "include": ["src"], + "compilerOptions": { + "baseUrl": "src", + "outDir": "dist", + "incremental": true, + "sourceMap": true, + "declaration": true, + "strict": true, + "target": "es5", + "module": "commonjs", + "esModuleInterop": true + } +} diff --git a/plugins/scaffolder/.eslintrc.js b/plugins/scaffolder/.eslintrc.js new file mode 100644 index 0000000000..f400a039e7 --- /dev/null +++ b/plugins/scaffolder/.eslintrc.js @@ -0,0 +1,6 @@ +module.exports = { + rules: { + 'no-console': 0, // Permitted in console programs + 'new-cap': ['error', { capIsNew: false }], // Because Express constructs things e.g. like 'const r = express.Router()' + }, +}; diff --git a/plugins/scaffolder/src/backend/index.ts b/plugins/scaffolder/src/backend/index.ts new file mode 100644 index 0000000000..cccce7a229 --- /dev/null +++ b/plugins/scaffolder/src/backend/index.ts @@ -0,0 +1,88 @@ +/* + * 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. + */ +/* + * 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 express from 'express'; + +export const router = express.Router(); + +router.get('/v1/templates', async (_, res) => { + res + .status(200) + .send([ + { id: 'component1' }, + { id: 'component2' }, + { id: 'component3' }, + { id: 'component4' }, + ]); +}); + +router.get('/v1/template/:templateId', async (_, res) => { + res + .status(200) + .send([ + { id: 'component1' }, + { id: 'component2' }, + { id: 'component3' }, + { id: 'component4' }, + ]); +}); + +router.post('/v1/jobs', async (_, res) => { + res + .status(200) + .send([ + { id: 'component1' }, + { id: 'component2' }, + { id: 'component3' }, + { id: 'component4' }, + ]); +}); + +router.get('/v1/jobs', async (_, res) => { + res + .status(200) + .send([ + { id: 'component1' }, + { id: 'component2' }, + { id: 'component3' }, + { id: 'component4' }, + ]); +}); + +router.get('/v1/job/:jobId', async (_, res) => { + res + .status(200) + .send([ + { id: 'component1' }, + { id: 'component2' }, + { id: 'component3' }, + { id: 'component4' }, + ]); +}); diff --git a/plugins/scaffolder/src/server.ts b/plugins/scaffolder/src/server.ts new file mode 100644 index 0000000000..ded18400b5 --- /dev/null +++ b/plugins/scaffolder/src/server.ts @@ -0,0 +1,16 @@ +/* + * 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. + */ +export { router } from './backend';