diff --git a/.changeset/perfect-toes-search.md b/.changeset/perfect-toes-search.md new file mode 100644 index 0000000000..65aceb6f08 --- /dev/null +++ b/.changeset/perfect-toes-search.md @@ -0,0 +1,17 @@ +--- +'@backstage/create-app': patch +'@backstage/plugin-scaffolder-backend': patch +--- + +Migrating old `backstage.io/v1alpha1` templates to `backstage.io/v1beta2` + +Deprecating the `create-react-app` Template. We're planning on removing the `create-react-app` templater, as it's been a little tricky to support and takes 15mins to run in a container. We've currently cached a copy of the output for `create-react-app` and ship that under our sample templates folder. If you want to continue using it, we suggest copying the template out of there and putting it in your own repository as it will be removed in upcoming releases. + +We also recommend removing this entry from your `app-config.yaml` if it exists: + +```diff +- - type: url +- target: https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend/sample-templates/create-react-app/template.yaml +- rules: +- - allow: [Template] +``` diff --git a/packages/create-app/templates/default-app/app-config.yaml.hbs b/packages/create-app/templates/default-app/app-config.yaml.hbs index d37cffd680..a783d9d6b3 100644 --- a/packages/create-app/templates/default-app/app-config.yaml.hbs +++ b/packages/create-app/templates/default-app/app-config.yaml.hbs @@ -105,10 +105,6 @@ catalog: target: https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/template.yaml rules: - allow: [Template] - - type: url - target: https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend/sample-templates/create-react-app/template.yaml - rules: - - allow: [Template] - type: url target: https://github.com/spotify/cookiecutter-golang/blob/master/template.yaml rules: diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/.gitignore b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/.gitignore new file mode 100644 index 0000000000..4d29575de8 --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/.gitignore @@ -0,0 +1,23 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/README.md b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/README.md new file mode 100644 index 0000000000..305d413b8e --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/README.md @@ -0,0 +1,46 @@ +# Getting Started with Create React App + +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). + +## Available Scripts + +In the project directory, you can run: + +### `yarn start` + +Runs the app in the development mode.\ +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.\ +You will also see any lint errors in the console. + +### `yarn test` + +Launches the test runner in the interactive watch mode.\ +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. + +### `yarn build` + +Builds the app for production to the `build` folder.\ +It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.\ +Your app is ready to be deployed! + +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. + +### `yarn eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (`webpack`, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. + +## Learn More + +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). + +To learn React, check out the [React documentation](https://reactjs.org/). diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/catalog-info.yaml b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/catalog-info.yaml similarity index 51% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/catalog-info.yaml rename to plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/catalog-info.yaml index 6197888f36..4e23c5ee91 100644 --- a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/catalog-info.yaml +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/catalog-info.yaml @@ -4,8 +4,8 @@ metadata: name: {{cookiecutter.component_id | jsonify}} description: {{cookiecutter.description | jsonify}} annotations: - github.com/project-slug: {{cookiecutter.destination.git.owner + "/" + cookiecutter.destination.git.name}} - backstage.io/techdocs-ref: url:{{cookiecutter.storePath}} + github.com/project-slug: {{cookiecutter.destination.owner + "/" + cookiecutter.destination.repo}} + backstage.io/techdocs-ref: url:{{cookiecutter.destination.host + "/" + cookiecutter.destination.owner + "/" + cookiecutter.destination.repo}} spec: type: website lifecycle: experimental diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/package.json b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/package.json new file mode 100644 index 0000000000..2ce9bf6266 --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/package.json @@ -0,0 +1,43 @@ +{ + "name": "{{cookiecutter.component_id}}", + "version": "0.1.0", + "private": true, + "dependencies": { + "@testing-library/jest-dom": "^5.11.4", + "@testing-library/react": "^11.1.0", + "@testing-library/user-event": "^12.1.10", + "@types/jest": "^26.0.15", + "@types/node": "^12.0.0", + "@types/react": "^17.0.0", + "@types/react-dom": "^17.0.0", + "react": "^17.0.2", + "react-dom": "^17.0.2", + "react-scripts": "4.0.3", + "typescript": "^4.1.2", + "web-vitals": "^1.0.1" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject" + }, + "eslintConfig": { + "extends": [ + "react-app", + "react-app/jest" + ] + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } +} diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/favicon.ico b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/favicon.ico new file mode 100644 index 0000000000..a11777cc47 Binary files /dev/null and b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/favicon.ico differ diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/index.html b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/index.html new file mode 100644 index 0000000000..aa069f27cb --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + React App + + + +
+ + + diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/logo192.png b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/logo192.png new file mode 100644 index 0000000000..fc44b0a379 Binary files /dev/null and b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/logo192.png differ diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/logo512.png b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/logo512.png new file mode 100644 index 0000000000..a4e47a6545 Binary files /dev/null and b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/logo512.png differ diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/manifest.json b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/manifest.json new file mode 100644 index 0000000000..080d6c77ac --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/manifest.json @@ -0,0 +1,25 @@ +{ + "short_name": "React App", + "name": "Create React App Sample", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + }, + { + "src": "logo192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "logo512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/robots.txt b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/robots.txt new file mode 100644 index 0000000000..e9e57dc4d4 --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/public/robots.txt @@ -0,0 +1,3 @@ +# https://www.robotstxt.org/robotstxt.html +User-agent: * +Disallow: diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/App.css b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/App.css new file mode 100644 index 0000000000..74b5e05345 --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/App.css @@ -0,0 +1,38 @@ +.App { + text-align: center; +} + +.App-logo { + height: 40vmin; + pointer-events: none; +} + +@media (prefers-reduced-motion: no-preference) { + .App-logo { + animation: App-logo-spin infinite 20s linear; + } +} + +.App-header { + background-color: #282c34; + min-height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: calc(10px + 2vmin); + color: white; +} + +.App-link { + color: #61dafb; +} + +@keyframes App-logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/App.test.tsx b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/App.test.tsx new file mode 100644 index 0000000000..2a68616d98 --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/App.test.tsx @@ -0,0 +1,9 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import App from './App'; + +test('renders learn react link', () => { + render(); + const linkElement = screen.getByText(/learn react/i); + expect(linkElement).toBeInTheDocument(); +}); diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/App.tsx b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/App.tsx new file mode 100644 index 0000000000..a53698aab3 --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/App.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import logo from './logo.svg'; +import './App.css'; + +function App() { + return ( +
+
+ logo +

+ Edit src/App.tsx and save to reload. +

+ + Learn React + +
+
+ ); +} + +export default App; diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/index.css b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/index.css new file mode 100644 index 0000000000..ec2585e8c0 --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/index.css @@ -0,0 +1,13 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', + 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', + monospace; +} diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/index.tsx b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/index.tsx new file mode 100644 index 0000000000..ef2edf8ea3 --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/index.tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import './index.css'; +import App from './App'; +import reportWebVitals from './reportWebVitals'; + +ReactDOM.render( + + + , + document.getElementById('root') +); + +// If you want to start measuring performance in your app, pass a function +// to log results (for example: reportWebVitals(console.log)) +// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals +reportWebVitals(); diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/logo.svg b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/logo.svg new file mode 100644 index 0000000000..9dfc1c058c --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/react-app-env.d.ts b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/react-app-env.d.ts new file mode 100644 index 0000000000..6431bc5fc6 --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/react-app-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/reportWebVitals.ts b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/reportWebVitals.ts new file mode 100644 index 0000000000..49a2a16e0f --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/reportWebVitals.ts @@ -0,0 +1,15 @@ +import { ReportHandler } from 'web-vitals'; + +const reportWebVitals = (onPerfEntry?: ReportHandler) => { + if (onPerfEntry && onPerfEntry instanceof Function) { + import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { + getCLS(onPerfEntry); + getFID(onPerfEntry); + getFCP(onPerfEntry); + getLCP(onPerfEntry); + getTTFB(onPerfEntry); + }); + } +}; + +export default reportWebVitals; diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/setupTests.ts b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/setupTests.ts new file mode 100644 index 0000000000..8f2609b7b3 --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/src/setupTests.ts @@ -0,0 +1,5 @@ +// jest-dom adds custom jest matchers for asserting on DOM nodes. +// allows you to do things like: +// expect(element).toHaveTextContent(/react/i) +// learn more: https://github.com/testing-library/jest-dom +import '@testing-library/jest-dom'; diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/tsconfig.json b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/tsconfig.json new file mode 100644 index 0000000000..a273b0cfc0 --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/skeleton/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "allowJs": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx" + }, + "include": [ + "src" + ] +} diff --git a/plugins/scaffolder-backend/sample-templates/create-react-app/template.yaml b/plugins/scaffolder-backend/sample-templates/create-react-app/template.yaml index 82fde335c5..664b405f29 100644 --- a/plugins/scaffolder-backend/sample-templates/create-react-app/template.yaml +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/template.yaml @@ -1,67 +1,77 @@ -apiVersion: backstage.io/v1alpha1 +apiVersion: backstage.io/v1beta2 kind: Template metadata: name: create-react-app-template title: Create React App Template description: Create a new CRA website project tags: - - experimental - react - cra spec: owner: web@example.com - templater: cra type: website - path: '.' - - schema: - required: - - component_id - - use_typescript - - description - - collaborators - properties: - component_id: - title: Name - type: string - pattern: ^[a-z0-9]+(-[a-z0-9]+)*$ - description: Unique name of the component. Lowercase, URL-safe characters only. - description: - title: Description - type: string - description: Help others understand what this website is for. - use_typescript: - title: Use TypeScript - type: boolean - description: Include TypeScript - default: true - use_github_actions: - title: Use Github Actions workflows to build this component - type: boolean - description: Use Github Actions - default: true - collaborators: - title: Collaborators - description: Provide users with permissions - type: array - ui:options: - orderable: false - items: - type: object - required: - - username - - access - properties: - access: - type: string - description: The type of access for the user - default: pull - enum: - - push - - pull - - admin - - maintain - - triage - username: - type: string - description: The username or group + parameters: + - title: Provide some simple information + required: + - component_id + - owner + properties: + component_id: + title: Name + type: string + description: Unique name of the component + description: + title: Description + type: string + description: Help others understand what this website is for. + owner: + title: Owner + type: string + description: Owner of the component + ui:field: OwnerPicker + ui:options: + allowedKinds: + - Group + - title: Choose a location + required: + - repoUrl + properties: + repoUrl: + title: Repository Location + type: string + ui:field: RepoUrlPicker + ui:options: + allowedHosts: + - github.com + steps: + - id: template + name: Fetch Skeleton + Template + action: fetch:cookiecutter + input: + url: ./skeleton + copyWithoutRender: + - .github/workflows/* + values: + component_id: '{{ parameters.component_id }}' + description: '{{ parameters.description }}' + destination: '{{ parseRepoUrl parameters.repoUrl }}' + owner: '{{ parameters.owner }}' + + - id: publish + name: Publish + action: publish:github + input: + allowedHosts: ['github.com'] + description: 'This is {{ parameters.component_id }}' + repoUrl: '{{ parameters.repoUrl }}' + + - id: register + name: Register + action: catalog:register + input: + repoContentsUrl: '{{ steps.publish.output.repoContentsUrl }}' + catalogInfoPath: '/catalog-info.yaml' + + output: + remoteUrl: '{{ steps.publish.output.remoteUrl }}' + entityRef: '{{ steps.register.output.entityRef }}' diff --git a/plugins/scaffolder-backend/sample-templates/docs-template/{{cookiecutter.component_id}}/catalog-info.yaml b/plugins/scaffolder-backend/sample-templates/docs-template/skeleton/catalog-info.yaml similarity index 100% rename from plugins/scaffolder-backend/sample-templates/docs-template/{{cookiecutter.component_id}}/catalog-info.yaml rename to plugins/scaffolder-backend/sample-templates/docs-template/skeleton/catalog-info.yaml diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/docs/index.md b/plugins/scaffolder-backend/sample-templates/docs-template/skeleton/docs/index.md similarity index 96% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/docs/index.md rename to plugins/scaffolder-backend/sample-templates/docs-template/skeleton/docs/index.md index 5352ef7801..b6f7344334 100644 --- a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/docs/index.md +++ b/plugins/scaffolder-backend/sample-templates/docs-template/skeleton/docs/index.md @@ -1,4 +1,4 @@ -## {{ cookiecutter.component_id }} +## {{ cookiecutter.name }} {{ cookiecutter.description }} diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/mkdocs.yml b/plugins/scaffolder-backend/sample-templates/docs-template/skeleton/mkdocs.yml similarity index 69% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/mkdocs.yml rename to plugins/scaffolder-backend/sample-templates/docs-template/skeleton/mkdocs.yml index 64f1e9ee8e..7e1c015f28 100644 --- a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/mkdocs.yml +++ b/plugins/scaffolder-backend/sample-templates/docs-template/skeleton/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: {{cookiecutter.component_id | jsonify}} +site_name: {{cookiecutter.name | jsonify}} site_description: {{cookiecutter.description | jsonify}} nav: diff --git a/plugins/scaffolder-backend/sample-templates/docs-template/template.yaml b/plugins/scaffolder-backend/sample-templates/docs-template/template.yaml index 168daffd20..dcfa667c9f 100644 --- a/plugins/scaffolder-backend/sample-templates/docs-template/template.yaml +++ b/plugins/scaffolder-backend/sample-templates/docs-template/template.yaml @@ -1,4 +1,4 @@ -apiVersion: backstage.io/v1alpha1 +apiVersion: backstage.io/v1beta2 kind: Template metadata: name: docs-template @@ -10,21 +10,39 @@ metadata: - mkdocs spec: owner: backstage/techdocs-core - templater: cookiecutter type: documentation - path: '.' - schema: - required: - - component_id - - description - properties: - component_id: - title: Name - type: string - pattern: ^[a-z0-9A-Z_.-]{1,63}$ - description: Unique name of the component - description: - title: Description - type: string - description: Help others understand what these docs are about. + parameters: + - title: Fill in some steps + required: + - name + - description + properties: + name: + title: Name + type: string + description: Unique name of the component + ui:autofocus: true + ui:options: + rows: 5 + description: + title: Description + type: string + description: A description for the component + ui:autofocus: true + ui:options: + rows: 5 + + # This template is meant to be used on top of an existing tmeplate. + # By adding the following and fetching from an absolute URL you can + # add in the docs template + steps: + - id: fetch + name: Template Docs Skeleton + action: fetch:cookiecutter + input: + url: ./skeleton + values: + name: '{{ parameters.name }}' + description: '{{ parameters.description }}' + diff --git a/plugins/scaffolder-backend/sample-templates/local-templates.yaml b/plugins/scaffolder-backend/sample-templates/local-templates.yaml index 76c76bc97a..3b3acbae7e 100644 --- a/plugins/scaffolder-backend/sample-templates/local-templates.yaml +++ b/plugins/scaffolder-backend/sample-templates/local-templates.yaml @@ -5,9 +5,9 @@ metadata: description: A collection of locally available Backstage example templates spec: targets: - - ./create-react-app/template.yaml - ./docs-template/template.yaml - ./react-ssr-template/template.yaml + - ./create-react-app/template.yaml - ./springboot-grpc-template/template.yaml - ./v1beta2-demo/template.yaml - ./pull-request/template.yaml diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/cookiecutter.json b/plugins/scaffolder-backend/sample-templates/react-ssr-template/cookiecutter.json deleted file mode 100644 index bc6e4b5347..0000000000 --- a/plugins/scaffolder-backend/sample-templates/react-ssr-template/cookiecutter.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "_copy_without_render": [".github/workflows/*"] -} diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/hooks/post_gen_project.sh b/plugins/scaffolder-backend/sample-templates/react-ssr-template/hooks/post_gen_project.sh deleted file mode 100644 index 1e302afa5e..0000000000 --- a/plugins/scaffolder-backend/sample-templates/react-ssr-template/hooks/post_gen_project.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -echo "Could do something here?" diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.editorconfig b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/.editorconfig similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.editorconfig rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/.editorconfig diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.eslintignore b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/.eslintignore similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.eslintignore rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/.eslintignore diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.eslintrc.js b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/.eslintrc.js similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.eslintrc.js rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/.eslintrc.js diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.github/workflows/build.yml b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/.github/workflows/build.yml similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.github/workflows/build.yml rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/.github/workflows/build.yml diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.gitignore b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/.gitignore similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.gitignore rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/.gitignore diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/README.md b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/README.md similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/README.md rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/README.md diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/babel.config.js b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/babel.config.js similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/babel.config.js rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/babel.config.js diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/catalog-info.yaml b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/catalog-info.yaml new file mode 100644 index 0000000000..4e23c5ee91 --- /dev/null +++ b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/catalog-info.yaml @@ -0,0 +1,12 @@ +apiVersion: backstage.io/v1alpha1 +kind: Component +metadata: + name: {{cookiecutter.component_id | jsonify}} + description: {{cookiecutter.description | jsonify}} + annotations: + github.com/project-slug: {{cookiecutter.destination.owner + "/" + cookiecutter.destination.repo}} + backstage.io/techdocs-ref: url:{{cookiecutter.destination.host + "/" + cookiecutter.destination.owner + "/" + cookiecutter.destination.repo}} +spec: + type: website + lifecycle: experimental + owner: {{cookiecutter.owner | jsonify}} diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/docs/index.md b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/docs/index.md similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/docs/index.md rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/docs/index.md diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/jest.config.js b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/jest.config.js similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/jest.config.js rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/jest.config.js diff --git a/plugins/scaffolder-backend/sample-templates/docs-template/{{cookiecutter.component_id}}/mkdocs.yml b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/mkdocs.yml similarity index 100% rename from plugins/scaffolder-backend/sample-templates/docs-template/{{cookiecutter.component_id}}/mkdocs.yml rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/mkdocs.yml diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/next-env.d.ts b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/next-env.d.ts similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/next-env.d.ts rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/next-env.d.ts diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/next.config.js b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/next.config.js similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/next.config.js rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/next.config.js diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/package.json b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/package.json similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/package.json rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/package.json diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/prettier.config.js b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/prettier.config.js similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/prettier.config.js rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/prettier.config.js diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/public/static/fonts.css b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/public/static/fonts.css similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/public/static/fonts.css rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/public/static/fonts.css diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/src/__tests__/index.test.tsx b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/src/__tests__/index.test.tsx similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/src/__tests__/index.test.tsx rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/src/__tests__/index.test.tsx diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/src/components/Header.tsx b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/src/components/Header.tsx similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/src/components/Header.tsx rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/src/components/Header.tsx diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/src/pages/_app.tsx b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/src/pages/_app.tsx similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/src/pages/_app.tsx rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/src/pages/_app.tsx diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/src/pages/_document.tsx b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/src/pages/_document.tsx similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/src/pages/_document.tsx rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/src/pages/_document.tsx diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/src/pages/api/ping.ts b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/src/pages/api/ping.ts similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/src/pages/api/ping.ts rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/src/pages/api/ping.ts diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/src/pages/index.tsx b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/src/pages/index.tsx similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/src/pages/index.tsx rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/src/pages/index.tsx diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/tsconfig.json b/plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/tsconfig.json similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/tsconfig.json rename to plugins/scaffolder-backend/sample-templates/react-ssr-template/skeleton/tsconfig.json diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/template.yaml b/plugins/scaffolder-backend/sample-templates/react-ssr-template/template.yaml index a667e6e6b6..49802a9d62 100644 --- a/plugins/scaffolder-backend/sample-templates/react-ssr-template/template.yaml +++ b/plugins/scaffolder-backend/sample-templates/react-ssr-template/template.yaml @@ -1,4 +1,4 @@ -apiVersion: backstage.io/v1alpha1 +apiVersion: backstage.io/v1beta2 kind: Template metadata: name: react-ssr-template @@ -9,19 +9,69 @@ metadata: - react spec: owner: web@example.com - templater: cookiecutter type: website - path: '.' - schema: - required: - - component_id - - description - properties: - component_id: - title: Name - type: string - description: Unique name of the component - description: - title: Description - type: string - description: Help others understand what this website is for. + parameters: + - title: Provide some simple information + required: + - component_id + - owner + properties: + component_id: + title: Name + type: string + description: Unique name of the component + description: + title: Description + type: string + description: Help others understand what this website is for. + owner: + title: Owner + type: string + description: Owner of the component + ui:field: OwnerPicker + ui:options: + allowedKinds: + - Group + - title: Choose a location + required: + - repoUrl + properties: + repoUrl: + title: Repository Location + type: string + ui:field: RepoUrlPicker + ui:options: + allowedHosts: + - github.com + steps: + - id: template + name: Fetch Skeleton + Template + action: fetch:cookiecutter + input: + url: ./skeleton + copyWithoutRender: + - .github/workflows/* + values: + component_id: '{{ parameters.component_id }}' + description: '{{ parameters.description }}' + destination: '{{ parseRepoUrl parameters.repoUrl }}' + owner: '{{ parameters.owner }}' + + - id: publish + name: Publish + action: publish:github + input: + allowedHosts: ['github.com'] + description: 'This is {{ parameters.component_id }}' + repoUrl: '{{ parameters.repoUrl }}' + + - id: register + name: Register + action: catalog:register + input: + repoContentsUrl: '{{ steps.publish.output.repoContentsUrl }}' + catalogInfoPath: '/catalog-info.yaml' + + output: + remoteUrl: '{{ steps.publish.output.remoteUrl }}' + entityRef: '{{ steps.register.output.entityRef }}' diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.nvmrc b/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.nvmrc deleted file mode 100644 index b009dfb9d9..0000000000 --- a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -lts/* diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/cookiecutter.json b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/cookiecutter.json deleted file mode 100644 index d662b6f46b..0000000000 --- a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/cookiecutter.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "component_id": "", - "artifact_id": "{{ cookiecutter.component_id }}", - "java_package_name": "{{ cookiecutter.component_id|replace('-', '') }}", - "description": "We promise to update this description /{{cookiecutter.owner}}", - "http_port": 8080 -} diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/.editorconfig b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/.editorconfig similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/.editorconfig rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/.editorconfig diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/.github/workflows/build.yml b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/.github/workflows/build.yml similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/.github/workflows/build.yml rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/.github/workflows/build.yml diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/.gitignore b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/.gitignore similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/.gitignore rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/.gitignore diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/Dockerfile b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/Dockerfile similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/Dockerfile rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/Dockerfile diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/README.md b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/README.md similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/README.md rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/README.md diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/SERVICE.marker b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/SERVICE.marker similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/SERVICE.marker rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/SERVICE.marker diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/catalog-info.yaml b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/catalog-info.yaml similarity index 51% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/catalog-info.yaml rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/catalog-info.yaml index 02a8a7adf2..61e850255c 100644 --- a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/catalog-info.yaml +++ b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/catalog-info.yaml @@ -4,8 +4,8 @@ metadata: name: {{cookiecutter.component_id | jsonify}} description: {{cookiecutter.description | jsonify}} annotations: - github.com/project-slug: {{cookiecutter.destination.git.owner + "/" + cookiecutter.destination.git.name}} - backstage.io/techdocs-ref: url:{{cookiecutter.storePath}} + github.com/project-slug: {{cookiecutter.destination.owner + "/" + cookiecutter.destination.repo}} + backstage.io/techdocs-ref: url:{{cookiecutter.destination.host + "/" + cookiecutter.destination.owner + "/" + cookiecutter.destination.repo}} spec: type: service lifecycle: experimental diff --git a/plugins/scaffolder-backend/sample-templates/docs-template/{{cookiecutter.component_id}}/docs/index.md b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/docs/index.md similarity index 100% rename from plugins/scaffolder-backend/sample-templates/docs-template/{{cookiecutter.component_id}}/docs/index.md rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/docs/index.md diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/mkdocs.yml b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/mkdocs.yml similarity index 100% rename from plugins/scaffolder-backend/sample-templates/react-ssr-template/{{cookiecutter.component_id}}/mkdocs.yml rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/mkdocs.yml diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/pom.xml b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/pom.xml similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/pom.xml rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/pom.xml diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/src/main/java/com/example/{{cookiecutter.java_package_name}}/Application.java b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/src/main/java/com/example/{{cookiecutter.java_package_name}}/Application.java similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/src/main/java/com/example/{{cookiecutter.java_package_name}}/Application.java rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/src/main/java/com/example/{{cookiecutter.java_package_name}}/Application.java diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/src/main/java/com/example/{{cookiecutter.java_package_name}}/GreeterService.java b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/src/main/java/com/example/{{cookiecutter.java_package_name}}/GreeterService.java similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/src/main/java/com/example/{{cookiecutter.java_package_name}}/GreeterService.java rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/src/main/java/com/example/{{cookiecutter.java_package_name}}/GreeterService.java diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/src/main/resources/application.properties b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/src/main/resources/application.properties similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/src/main/resources/application.properties rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/src/main/resources/application.properties diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/src/main/resources/banner.txt b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/src/main/resources/banner.txt similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/src/main/resources/banner.txt rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/src/main/resources/banner.txt diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/src/main/resources/greeter.proto b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/src/main/resources/greeter.proto similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/src/main/resources/greeter.proto rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/src/main/resources/greeter.proto diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/src/test/java/com/example/{{cookiecutter.java_package_name}}/ApplicationTest.java b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/src/test/java/com/example/{{cookiecutter.java_package_name}}/ApplicationTest.java similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/src/test/java/com/example/{{cookiecutter.java_package_name}}/ApplicationTest.java rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/src/test/java/com/example/{{cookiecutter.java_package_name}}/ApplicationTest.java diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/{{cookiecutter.artifact_id}}.sh b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/{{cookiecutter.artifact_id}}.sh similarity index 100% rename from plugins/scaffolder-backend/sample-templates/springboot-grpc-template/{{cookiecutter.component_id}}/{{cookiecutter.artifact_id}}.sh rename to plugins/scaffolder-backend/sample-templates/springboot-grpc-template/skeleton/{{cookiecutter.artifact_id}}.sh diff --git a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/template.yaml b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/template.yaml index 8b89298a0e..c306187581 100644 --- a/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/template.yaml +++ b/plugins/scaffolder-backend/sample-templates/springboot-grpc-template/template.yaml @@ -1,4 +1,4 @@ -apiVersion: backstage.io/v1alpha1 +apiVersion: backstage.io/v1beta2 kind: Template metadata: name: springboot-template @@ -10,24 +10,79 @@ metadata: - grpc spec: owner: service@example.com - templater: cookiecutter type: service - path: '.' - schema: - required: - - component_id - - description - properties: - component_id: - title: Name - type: string - description: Unique name of the component - description: - title: Description - type: string - description: Help others understand what this service does. - http_port: - title: Port - type: integer - default: 8080 - description: The port to run the gRPC service on + + parameters: + - title: Provide some simple information + required: + - component_id + - owner + - java_package_name + properties: + component_id: + title: Name + type: string + description: Unique name of the component + java_package_name: + title: Java Package Name + type: string + description: Name for the java package. eg (io.backstage.blah) + description: + title: Description + type: string + description: Help others understand what this website is for. + owner: + title: Owner + type: string + description: Owner of the component + ui:field: OwnerPicker + ui:options: + allowedKinds: + - Group + - title: Choose a location + required: + - repoUrl + properties: + repoUrl: + title: Repository Location + type: string + ui:field: RepoUrlPicker + ui:options: + allowedHosts: + - github.com + + steps: + - id: template + name: Fetch Skeleton + Template + action: fetch:cookiecutter + input: + url: ./skeleton + copyWithoutRender: + - .github/workflows/* + values: + component_id: '{{ parameters.component_id }}' + description: '{{ parameters.description }}' + artifact_id: '{{ parameters.component_id }}' + java_package_name: '{{ parameters.java_package_name }}' + owner: '{{ parameters.owner }}' + destination: '{{ parseRepoUrl parameters.repoUrl }}' + http_port: 8080 + + - id: publish + name: Publish + action: publish:github + input: + allowedHosts: ['github.com'] + description: 'This is {{ parameters.component_id }}' + repoUrl: '{{ parameters.repoUrl }}' + + - id: register + name: Register + action: catalog:register + input: + repoContentsUrl: '{{ steps.publish.output.repoContentsUrl }}' + catalogInfoPath: '/catalog-info.yaml' + + output: + remoteUrl: '{{ steps.publish.output.remoteUrl }}' + entityRef: '{{ steps.register.output.entityRef }}'