From e8c60104df09c2cc93387632d32822a701ba8211 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Tue, 22 Sep 2020 13:30:13 +0200 Subject: [PATCH 01/21] feat(scaffolder): cra add gha integration, fix imports --- packages/cli/package.json | 2 +- .../WorkflowRunLogs/WorkflowRunLogs.tsx | 2 +- plugins/scaffolder-backend/package.json | 1 + .../create-react-app/template.yaml | 7 + .../stages/templater/{cra.ts => cra/index.ts} | 33 +++-- .../cra/templates/.github/workflows/main.yml | 41 ++++++ .../JobStatusModal/JobStatusModal.tsx | 5 +- yarn.lock | 121 +++++++++++++++++- 8 files changed, 196 insertions(+), 16 deletions(-) rename plugins/scaffolder-backend/src/scaffolder/stages/templater/{cra.ts => cra/index.ts} (73%) create mode 100644 plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/templates/.github/workflows/main.yml diff --git a/packages/cli/package.json b/packages/cli/package.json index e1f51be5b7..7f84217ec5 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -38,7 +38,7 @@ "@rollup/plugin-json": "^4.0.2", "@rollup/plugin-node-resolve": "^8.1.0", "@rollup/plugin-yaml": "^2.1.1", - "@spotify/eslint-config": "^7.0.1", + "@spotify/eslint-config": "^8.1.0", "@sucrase/webpack-loader": "^2.0.0", "@svgr/plugin-jsx": "5.4.x", "@svgr/plugin-svgo": "5.4.x", diff --git a/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx b/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx index 390f35d516..d03c2d6be8 100644 --- a/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx +++ b/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx @@ -30,13 +30,13 @@ import { import React, { Suspense } from 'react'; import { useDownloadWorkflowRunLogs } from './useDownloadWorkflowRunLogs'; -import LinePart from 'react-lazylog/build/LinePart'; import { useProjectName } from '../useProjectName'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import DescriptionIcon from '@material-ui/icons/Description'; import { Entity } from '@backstage/catalog-model'; const LazyLog = React.lazy(() => import('react-lazylog/build/LazyLog')); +const LinePart = React.lazy(() => import('react-lazylog/build/LinePart')); const useStyles = makeStyles(() => ({ button: { diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index 0eaa33e1f8..a53dc96aee 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -23,6 +23,7 @@ "@backstage/backend-common": "^0.1.1-alpha.22", "@backstage/catalog-model": "^0.1.1-alpha.22", "@backstage/config": "^0.1.1-alpha.22", + "@backstage/plugin-github-actions": "^0.1.1-alpha.22", "@gitbeaker/core": "^23.5.0", "@gitbeaker/node": "^23.5.0", "@octokit/rest": "^18.0.0", 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 2c8b3b3d6d..c5b500c701 100644 --- a/plugins/scaffolder-backend/sample-templates/create-react-app/template.yaml +++ b/plugins/scaffolder-backend/sample-templates/create-react-app/template.yaml @@ -18,6 +18,7 @@ spec: required: - component_id - use_typescript + - description properties: component_id: title: Name @@ -32,3 +33,9 @@ spec: 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 + diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra.ts b/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts similarity index 73% rename from plugins/scaffolder-backend/src/scaffolder/stages/templater/cra.ts rename to plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts index da33149c24..e771ada8c3 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts @@ -14,17 +14,19 @@ * limitations under the License. */ import fs from 'fs-extra'; -import { runDockerContainer } from './helpers'; -import { TemplaterBase, TemplaterRunOptions } from '.'; +import { runDockerContainer } from '../helpers'; +import { TemplaterBase, TemplaterRunOptions } from '..'; import path from 'path'; -import { TemplaterRunResult } from './types'; +import { TemplaterRunResult } from '../types'; import * as yaml from 'yaml'; +import { GITHUB_ACTIONS_ANNOTATION } from '@backstage/plugin-github-actions'; export class CreateReactAppTemplater implements TemplaterBase { public async run(options: TemplaterRunOptions): Promise { const { component_id: componentName, use_typescript: withTypescript, + use_github_actions: withGithubActions, description, owner, } = options.values; @@ -48,6 +50,23 @@ export class CreateReactAppTemplater implements TemplaterBase { }, }); + const extraAnnotations: Record = {}; + const finalDir = path.resolve( + resultDir, + options.values.component_id as string, + ); + + if (withGithubActions) { + await fs.promises.mkdir(`${finalDir}/.github`); + await fs.promises.mkdir(`${finalDir}/.github/workflows`); + await fs.promises.copyFile( + `${__dirname}/templates/.github/workflows/main.yml`, + `${finalDir}/.github/workflows/main.yml`, + ); + + extraAnnotations[GITHUB_ACTIONS_ANNOTATION] = options.values.storePath; + } + // Need to also make a component-info.yaml to store the data about the service. const componentInfo = { apiVersion: 'backstage.io/v1alpha1', @@ -55,6 +74,9 @@ export class CreateReactAppTemplater implements TemplaterBase { metadata: { name: componentName, description, + annotations: { + ...extraAnnotations, + }, }, spec: { type: 'website', @@ -63,11 +85,6 @@ export class CreateReactAppTemplater implements TemplaterBase { }, }; - const finalDir = path.resolve( - resultDir, - options.values.component_id as string, - ); - await fs.promises.writeFile( `${finalDir}/component-info.yaml`, yaml.stringify(componentInfo), diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/templates/.github/workflows/main.yml b/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/templates/.github/workflows/main.yml new file mode 100644 index 0000000000..65cae9abbb --- /dev/null +++ b/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/templates/.github/workflows/main.yml @@ -0,0 +1,41 @@ +name: CRA Build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x] + + steps: + - name: checkout code + uses: actions/checkout@v1 + - name: get yarn cache + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: use node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: yarn install, build, and test + working-directory: . + run: | + yarn install + yarn build + yarn test + env: + CI: true diff --git a/plugins/scaffolder/src/components/JobStatusModal/JobStatusModal.tsx b/plugins/scaffolder/src/components/JobStatusModal/JobStatusModal.tsx index 87b70a9553..0b6c451ff8 100644 --- a/plugins/scaffolder/src/components/JobStatusModal/JobStatusModal.tsx +++ b/plugins/scaffolder/src/components/JobStatusModal/JobStatusModal.tsx @@ -43,10 +43,11 @@ export const JobStatusModal = ({ entity, }: Props) => { const job = useJobPolling(jobId); + const jobStatus = job?.status ?? ''; useEffect(() => { - if (job?.status === 'COMPLETED') onComplete(job); - }, [job, onComplete]); + if (jobStatus === 'COMPLETED') onComplete(job); + }, [jobStatus, onComplete]); // eslint-disable-line react-hooks/exhaustive-deps return ( diff --git a/yarn.lock b/yarn.lock index 0cdce51f95..e89d95bd9b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3525,6 +3525,11 @@ resolved "https://registry.npmjs.org/@spotify/eslint-config-base/-/eslint-config-base-7.0.0.tgz#36804ae09ec938f1aa5f9464ea993f3f151cfaa8" integrity sha512-XRTrTRyRRYBxPYINKNHw4B8QWlA3p4I+id/Po2sMdejtXH3LZgDgIjdschUZSdQ6J6dVYDdaVykdizRM9I+G6Q== +"@spotify/eslint-config-base@^8.0.0": + version "8.0.0" + resolved "https://registry.npmjs.org/@spotify/eslint-config-base/-/eslint-config-base-8.0.0.tgz#c3d10d8a05ad9129d579952cb80063e4c4fa216e" + integrity sha512-07Fo+KoTMl4AaZJPD6deFnYmG634wzgeqfFcWdFlIrOLAasvWSH8Lp6ZE9cJBKuffOAy8kuEE1SwFo34+5X8bQ== + "@spotify/eslint-config-oss@^1.0.1": version "1.0.2" resolved "https://registry.npmjs.org/@spotify/eslint-config-oss/-/eslint-config-oss-1.0.2.tgz#b0e56e549c78dcdd79063ce48521f10c3420f701" @@ -3537,12 +3542,22 @@ resolved "https://registry.npmjs.org/@spotify/eslint-config-react/-/eslint-config-react-7.0.1.tgz#2e70de9d7911ea9aeaa55a83a332220a28f6c431" integrity sha512-HNDHvm19EaBXiDgsg52mjMgKWZTeA0hO2Q75ACNwb8UtjIKkANqyyuzyDGo8jiGMbWIm6wJjShlRtT95emNlqQ== +"@spotify/eslint-config-react@^8.0.2": + version "8.0.2" + resolved "https://registry.npmjs.org/@spotify/eslint-config-react/-/eslint-config-react-8.0.2.tgz#91af3c58b22d49a96795336ed66927e722cda430" + integrity sha512-V0gzO/jWmjhODLINAfeunHj+OBdj/cQeVDw+92ZUlkonAg6BZLjX6Vy8jeIUFjfgmVOtI9eKbcApxaurj1jN6g== + "@spotify/eslint-config-typescript@^7.0.0": version "7.0.0" resolved "https://registry.npmjs.org/@spotify/eslint-config-typescript/-/eslint-config-typescript-7.0.0.tgz#fc5227e3344f74b41ac3a530df24a95ac13254e4" integrity sha512-28I/SAf68NKbWZ5IY0WYMa0D18PxWdC9DP9gRbOTlZufmsS8jEgqf3zBUWmP6XOf1nihpKWcqvbFUG5H7/JYXA== -"@spotify/eslint-config@^7.0.0", "@spotify/eslint-config@^7.0.1": +"@spotify/eslint-config-typescript@^8.0.1": + version "8.0.1" + resolved "https://registry.npmjs.org/@spotify/eslint-config-typescript/-/eslint-config-typescript-8.0.1.tgz#2d3ee56a8a3f945454109086639cde47251d1e62" + integrity sha512-ALkA4WA2ZikX7grkptZ36J1N/iap0IJeViy6/ZcxSkm6yEy2BYslmS2MdoJ5PV/DfZ3Z/21d/+XYFqVEpcbrXg== + +"@spotify/eslint-config@^7.0.0": version "7.0.1" resolved "https://registry.npmjs.org/@spotify/eslint-config/-/eslint-config-7.0.1.tgz#07a21cfd7fce89cfc2c6dd5ea5d747e741201b66" integrity sha512-8GI/TZGUhS4pr7oipT2MjrZFRgXcKzk9YImEusUdD2f5vlCniRFIBQNrvTMkyjfdQqvIVqJPLcdVPXeAgprsMw== @@ -3559,6 +3574,29 @@ eslint-plugin-react "^7.12.4" eslint-plugin-react-hooks "^4.0.0" +"@spotify/eslint-config@^8.1.0": + version "8.1.0" + resolved "https://registry.npmjs.org/@spotify/eslint-config/-/eslint-config-8.1.0.tgz#00801a892a8f51df3f1074f7bc695052df4c9cd6" + integrity sha512-A3THg4Y2eK+hijUO+kt2ZL278XciFo/s/pwZ93c4/cYwFXYf1mcB2tmnmhP/6kK4QxF7rYmO8nYJMwPZ1sOkyQ== + dependencies: + "@spotify/eslint-config-base" "^8.0.0" + "@spotify/eslint-config-react" "^8.0.2" + "@spotify/eslint-config-typescript" "^8.0.1" + "@spotify/eslint-plugin" "^8.1.0" + "@spotify/web-scripts-utils" "^8.0.0" + "@typescript-eslint/eslint-plugin" "^3.4.0" + "@typescript-eslint/parser" "^3.4.0" + eslint-config-prettier "^6.0.0" + eslint-plugin-jest "^23.17.1" + eslint-plugin-jsx-a11y "^6.2.1" + eslint-plugin-react "^7.12.4" + eslint-plugin-react-hooks "^4.0.0" + +"@spotify/eslint-plugin@^8.1.0": + version "8.1.0" + resolved "https://registry.npmjs.org/@spotify/eslint-plugin/-/eslint-plugin-8.1.0.tgz#a9c5f971537c647d20d6f8c608018aec8d1b882a" + integrity sha512-/VBOF0vMRhVQFqdsNQ5NKhZeD8IWimqKZzsp2yrjLKDajXOfCsA8VpCtm/j4T6/8j/mqb7Rz9ePT+thHfGtBxg== + "@spotify/prettier-config@^7.0.0": version "7.0.0" resolved "https://registry.npmjs.org/@spotify/prettier-config/-/prettier-config-7.0.0.tgz#47750979d1282197295108b6958360660a955c16" @@ -3577,6 +3615,14 @@ glob "^7.1.4" read-pkg-up "^7.0.1" +"@spotify/web-scripts-utils@^8.0.0": + version "8.0.0" + resolved "https://registry.npmjs.org/@spotify/web-scripts-utils/-/web-scripts-utils-8.0.0.tgz#83e49a0050e0ca553769cea4052fe438bc0378a7" + integrity sha512-5ADUaRRW+ZJHYhfSiaJVVq+9hVfAin+WYaJzEd/3oTvd6P1BrVsAdyxBdmXtacTHu+vjlVoye/kxdpUhlIq9Iw== + dependencies: + glob "^7.1.4" + read-pkg-up "^7.0.1" + "@storybook/addon-actions@^6.0.21": version "6.0.21" resolved "https://registry.npmjs.org/@storybook/addon-actions/-/addon-actions-6.0.21.tgz#0de1d109d4b1eb99f644bbe84e74c25cfd2b1b6b" @@ -5457,6 +5503,18 @@ regexpp "^3.0.0" tsutils "^3.17.1" +"@typescript-eslint/eslint-plugin@^3.4.0": + version "3.10.1" + resolved "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.10.1.tgz#7e061338a1383f59edc204c605899f93dc2e2c8f" + integrity sha512-PQg0emRtzZFWq6PxBcdxRH3QIQiyFO3WCVpRL3fgj5oQS3CDs3AeAKfv4DxNhzn8ITdNJGJ4D3Qw8eAJf3lXeQ== + dependencies: + "@typescript-eslint/experimental-utils" "3.10.1" + debug "^4.1.1" + functional-red-black-tree "^1.0.1" + regexpp "^3.0.0" + semver "^7.3.2" + tsutils "^3.17.1" + "@typescript-eslint/experimental-utils@2.24.0", "@typescript-eslint/experimental-utils@^2.5.0": version "2.24.0" resolved "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.24.0.tgz#a5cb2ed89fedf8b59638dc83484eb0c8c35e1143" @@ -5466,6 +5524,17 @@ "@typescript-eslint/typescript-estree" "2.24.0" eslint-scope "^5.0.0" +"@typescript-eslint/experimental-utils@3.10.1": + version "3.10.1" + resolved "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.10.1.tgz#e179ffc81a80ebcae2ea04e0332f8b251345a686" + integrity sha512-DewqIgscDzmAfd5nOGe4zm6Bl7PKtMG2Ad0KG8CUZAHlXfAKTF9Ol5PXhiMh39yRL2ChRH1cuuUGOcVyyrhQIw== + dependencies: + "@types/json-schema" "^7.0.3" + "@typescript-eslint/types" "3.10.1" + "@typescript-eslint/typescript-estree" "3.10.1" + eslint-scope "^5.0.0" + eslint-utils "^2.0.0" + "@typescript-eslint/parser@^2.14.0": version "2.24.0" resolved "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.24.0.tgz#2cf0eae6e6dd44d162486ad949c126b887f11eb8" @@ -5476,6 +5545,22 @@ "@typescript-eslint/typescript-estree" "2.24.0" eslint-visitor-keys "^1.1.0" +"@typescript-eslint/parser@^3.4.0": + version "3.10.1" + resolved "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.10.1.tgz#1883858e83e8b442627e1ac6f408925211155467" + integrity sha512-Ug1RcWcrJP02hmtaXVS3axPPTTPnZjupqhgj+NnZ6BCkwSImWk/283347+x9wN+lqOdK9Eo3vsyiyDHgsmiEJw== + dependencies: + "@types/eslint-visitor-keys" "^1.0.0" + "@typescript-eslint/experimental-utils" "3.10.1" + "@typescript-eslint/types" "3.10.1" + "@typescript-eslint/typescript-estree" "3.10.1" + eslint-visitor-keys "^1.1.0" + +"@typescript-eslint/types@3.10.1": + version "3.10.1" + resolved "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.10.1.tgz#1d7463fa7c32d8a23ab508a803ca2fe26e758727" + integrity sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ== + "@typescript-eslint/typescript-estree@2.24.0": version "2.24.0" resolved "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.24.0.tgz#38bbc8bb479790d2f324797ffbcdb346d897c62a" @@ -5489,6 +5574,27 @@ semver "^6.3.0" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@3.10.1": + version "3.10.1" + resolved "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz#fd0061cc38add4fad45136d654408569f365b853" + integrity sha512-QbcXOuq6WYvnB3XPsZpIwztBoquEYLXh2MtwVU+kO8jgYCiv4G5xrSP/1wg4tkvrEE+esZVquIPX/dxPlePk1w== + dependencies: + "@typescript-eslint/types" "3.10.1" + "@typescript-eslint/visitor-keys" "3.10.1" + debug "^4.1.1" + glob "^7.1.6" + is-glob "^4.0.1" + lodash "^4.17.15" + semver "^7.3.2" + tsutils "^3.17.1" + +"@typescript-eslint/visitor-keys@3.10.1": + version "3.10.1" + resolved "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz#cd4274773e3eb63b2e870ac602274487ecd1e931" + integrity sha512-9JgC82AaQeglebjZMgYR5wgmfUdUc+EitGUUMW8u2nDckaeimzW+VsoLV6FoimPv2id3VQzfjwBxEMVz08ameQ== + dependencies: + eslint-visitor-keys "^1.1.0" + "@webassemblyjs/ast@1.9.0": version "1.9.0" resolved "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964" @@ -10069,6 +10175,13 @@ eslint-plugin-import@^2.20.2, eslint-plugin-import@^2.22.0: resolve "^1.17.0" tsconfig-paths "^3.9.0" +eslint-plugin-jest@^23.17.1: + version "23.20.0" + resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.20.0.tgz#e1d69c75f639e99d836642453c4e75ed22da4099" + integrity sha512-+6BGQt85OREevBDWCvhqj1yYA4+BFK4XnRZSGJionuEYmcglMZYLNNBBemwzbqUAckURaHdJSBcjHPyrtypZOw== + dependencies: + "@typescript-eslint/experimental-utils" "^2.5.0" + eslint-plugin-jest@^23.6.0: version "23.8.2" resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.8.2.tgz#6f28b41c67ef635f803ebd9e168f6b73858eb8d4" @@ -10114,9 +10227,9 @@ eslint-plugin-notice@^0.9.10: metric-lcs "^0.1.2" eslint-plugin-react-hooks@^4.0.0: - version "4.0.4" - resolved "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.0.4.tgz#aed33b4254a41b045818cacb047b81e6df27fa58" - integrity sha512-equAdEIsUETLFNCmmCkiCGq6rkSK5MoJhXFPFYeUebcjKgBmWWcgVOqZyQC8Bv1BwVCnTq9tBxgJFgAJTWoJtA== + version "4.1.1" + resolved "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.1.1.tgz#b37e1ff622b7800cd673901de32db1103d48411d" + integrity sha512-vFJNwsf4MLYS0lHYfz9LqxQ+GccYsGGeKPHDxgkIaKbAhNuTLnST+q44pt81MzJZyFU5K4XLF6WiCGv3Yb6tCg== eslint-plugin-react@^7.12.4: version "7.19.0" From 248f615148c7a48efc2320f330621684c55d0d27 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Tue, 22 Sep 2020 13:50:54 +0200 Subject: [PATCH 02/21] fix(scaffolder): sturdier fix for the catalog posting after success --- .../JobStatusModal/JobStatusModal.tsx | 2 +- .../components/TemplatePage/TemplatePage.tsx | 41 ++++++++++--------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/plugins/scaffolder/src/components/JobStatusModal/JobStatusModal.tsx b/plugins/scaffolder/src/components/JobStatusModal/JobStatusModal.tsx index 0b6c451ff8..e7d13e609f 100644 --- a/plugins/scaffolder/src/components/JobStatusModal/JobStatusModal.tsx +++ b/plugins/scaffolder/src/components/JobStatusModal/JobStatusModal.tsx @@ -46,7 +46,7 @@ export const JobStatusModal = ({ const jobStatus = job?.status ?? ''; useEffect(() => { - if (jobStatus === 'COMPLETED') onComplete(job); + if (jobStatus === 'COMPLETED') onComplete(job!); }, [jobStatus, onComplete]); // eslint-disable-line react-hooks/exhaustive-deps return ( diff --git a/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx b/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx index e68c795bd6..4ead44ab99 100644 --- a/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx +++ b/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx @@ -27,7 +27,7 @@ import { import { catalogApiRef } from '@backstage/plugin-catalog'; import { LinearProgress } from '@material-ui/core'; import { IChangeEvent } from '@rjsf/core'; -import React, { useState } from 'react'; +import React, { useState, useCallback } from 'react'; import { useParams } from 'react-router-dom'; import useStaleWhileRevalidate from 'swr'; import { scaffolderApiRef } from '../../api'; @@ -108,27 +108,30 @@ export const TemplatePage = () => { null, ); - const handleCreateComplete = async (job: Job) => { - const componentYaml = job.metadata.remoteUrl?.replace( - /\.git$/, - '/blob/master/component-info.yaml', - ); - - if (!componentYaml) { - errorApi.post( - new Error( - `Failed to find component-info.yaml file in ${job.metadata.remoteUrl}.`, - ), + const handleCreateComplete = useCallback( + async (job: Job) => { + const componentYaml = job.metadata.remoteUrl?.replace( + /\.git$/, + '/blob/master/component-info.yaml', ); - return; - } - const { - entities: [createdEntity], - } = await catalogApi.addLocation('github', componentYaml); + if (!componentYaml) { + errorApi.post( + new Error( + `Failed to find component-info.yaml file in ${job.metadata.remoteUrl}.`, + ), + ); + return; + } - setEntity((createdEntity as any) as TemplateEntityV1alpha1); - }; + const { + entities: [createdEntity], + } = await catalogApi.addLocation('github', componentYaml); + + setEntity((createdEntity as any) as TemplateEntityV1alpha1); + }, + [catalogApi, setEntity, errorApi], + ); if (!loading && !template) { errorApi.post(new Error('Template was not found.')); From 37da165e7088fa54e1587e3f15b1f96a37d6de87 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Tue, 29 Sep 2020 12:39:14 +0200 Subject: [PATCH 03/21] feat: universal file for github-actions --- packages/cli/src/lib/builder/config.ts | 17 ++++++++++++++++- plugins/github-actions/package.json | 3 ++- .../src/components/Cards/Cards.tsx | 2 +- .../github-actions/src/components/Router.tsx | 2 +- .../src/components/useProjectName.ts | 3 +-- plugins/github-actions/src/index.ts | 1 - plugins/github-actions/universal.js | 18 ++++++++++++++++++ .../scaffolder/stages/templater/cra/index.ts | 3 ++- 8 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 plugins/github-actions/universal.js diff --git a/packages/cli/src/lib/builder/config.ts b/packages/cli/src/lib/builder/config.ts index afcedaae59..44ccc85824 100644 --- a/packages/cli/src/lib/builder/config.ts +++ b/packages/cli/src/lib/builder/config.ts @@ -77,6 +77,21 @@ export const makeConfigs = async ( mainFields.unshift('browser'); } + const commonjsInclude: Array = [/node_modules/]; + + // Purpose of this file is + // to be bridge between + // frontend- and backend- + // plugins' code + const UNIVERSAL_FILE = 'universal.js'; + const universalPath = paths.resolveTarget(UNIVERSAL_FILE); + const universalFileExists = fs.existsSync(universalPath); + + if (universalFileExists) { + mainFields.push(UNIVERSAL_FILE); + commonjsInclude.push(UNIVERSAL_FILE); + } + configs.push({ input: 'src/index.ts', output, @@ -88,7 +103,7 @@ export const makeConfigs = async ( }), resolve({ mainFields }), commonjs({ - include: /node_modules/, + include: commonjsInclude, exclude: [/\/[^/]+\.(?:stories|test)\.[^/]+$/], }), postcss(), diff --git a/plugins/github-actions/package.json b/plugins/github-actions/package.json index 9d1538ce99..0000e07d23 100644 --- a/plugins/github-actions/package.json +++ b/plugins/github-actions/package.json @@ -50,6 +50,7 @@ "jest-fetch-mock": "^3.0.3" }, "files": [ - "dist" + "dist", + "universal.js" ] } diff --git a/plugins/github-actions/src/components/Cards/Cards.tsx b/plugins/github-actions/src/components/Cards/Cards.tsx index 28783efdea..f963be7569 100644 --- a/plugins/github-actions/src/components/Cards/Cards.tsx +++ b/plugins/github-actions/src/components/Cards/Cards.tsx @@ -32,7 +32,7 @@ import { useApi, } from '@backstage/core'; import ExternalLinkIcon from '@material-ui/icons/Launch'; -import { GITHUB_ACTIONS_ANNOTATION } from '../useProjectName'; +import { GITHUB_ACTIONS_ANNOTATION } from '../../../universal'; const useStyles = makeStyles({ externalLinkIcon: { diff --git a/plugins/github-actions/src/components/Router.tsx b/plugins/github-actions/src/components/Router.tsx index 7d340fb8b8..8314981ed6 100644 --- a/plugins/github-actions/src/components/Router.tsx +++ b/plugins/github-actions/src/components/Router.tsx @@ -19,7 +19,7 @@ import { Routes, Route } from 'react-router'; import { rootRouteRef, buildRouteRef } from '../plugin'; import { WorkflowRunDetails } from './WorkflowRunDetails'; import { WorkflowRunsTable } from './WorkflowRunsTable'; -import { GITHUB_ACTIONS_ANNOTATION } from './useProjectName'; +import { GITHUB_ACTIONS_ANNOTATION } from '../../universal'; import { WarningPanel } from '@backstage/core'; export const isPluginApplicableToEntity = (entity: Entity) => diff --git a/plugins/github-actions/src/components/useProjectName.ts b/plugins/github-actions/src/components/useProjectName.ts index ec7158bd27..226cc6c775 100644 --- a/plugins/github-actions/src/components/useProjectName.ts +++ b/plugins/github-actions/src/components/useProjectName.ts @@ -16,8 +16,7 @@ import { useAsync } from 'react-use'; import { Entity } from '@backstage/catalog-model'; - -export const GITHUB_ACTIONS_ANNOTATION = 'github.com/project-slug'; +import { GITHUB_ACTIONS_ANNOTATION } from '../../universal'; export const useProjectName = (entity: Entity) => { const { value, loading, error } = useAsync(async () => { diff --git a/plugins/github-actions/src/index.ts b/plugins/github-actions/src/index.ts index 24fe6fc90d..5c89c7f920 100644 --- a/plugins/github-actions/src/index.ts +++ b/plugins/github-actions/src/index.ts @@ -18,4 +18,3 @@ export { plugin } from './plugin'; export * from './api'; export { Router, isPluginApplicableToEntity } from './components/Router'; export * from './components/Cards'; -export { GITHUB_ACTIONS_ANNOTATION } from './components/useProjectName'; diff --git a/plugins/github-actions/universal.js b/plugins/github-actions/universal.js new file mode 100644 index 0000000000..a414b71749 --- /dev/null +++ b/plugins/github-actions/universal.js @@ -0,0 +1,18 @@ +/* + * 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. + */ + +// This file is shared between frontend and backend plugins +module.exports.GITHUB_ACTIONS_ANNOTATION = 'github.com/project-slug'; diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts b/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts index e771ada8c3..61a7064dc0 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts @@ -19,7 +19,8 @@ import { TemplaterBase, TemplaterRunOptions } from '..'; import path from 'path'; import { TemplaterRunResult } from '../types'; import * as yaml from 'yaml'; -import { GITHUB_ACTIONS_ANNOTATION } from '@backstage/plugin-github-actions'; +// eslint-disable-next-line monorepo/no-internal-import +import { GITHUB_ACTIONS_ANNOTATION } from '@backstage/plugin-github-actions/universal'; export class CreateReactAppTemplater implements TemplaterBase { public async run(options: TemplaterRunOptions): Promise { From e3bb82deab77f656c935e234d0fa2c2e148a76fa Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Wed, 7 Oct 2020 16:29:32 +0200 Subject: [PATCH 04/21] refactor: universal folder, package.json --- packages/cli/src/lib/builder/config.ts | 10 +++++----- plugins/github-actions/package.json | 2 +- .../{universal.js => universal/index.js} | 6 +++++- plugins/github-actions/universal/package.json | 5 +++++ 4 files changed, 16 insertions(+), 7 deletions(-) rename plugins/github-actions/{universal.js => universal/index.js} (87%) create mode 100644 plugins/github-actions/universal/package.json diff --git a/packages/cli/src/lib/builder/config.ts b/packages/cli/src/lib/builder/config.ts index 44ccc85824..b899fc98d3 100644 --- a/packages/cli/src/lib/builder/config.ts +++ b/packages/cli/src/lib/builder/config.ts @@ -16,7 +16,7 @@ import chalk from 'chalk'; import fs from 'fs-extra'; -import { relative as relativePath } from 'path'; +import { relative as relativePath, join as joinPath } from 'path'; import peerDepsExternal from 'rollup-plugin-peer-deps-external'; import commonjs from '@rollup/plugin-commonjs'; import resolve from '@rollup/plugin-node-resolve'; @@ -83,13 +83,13 @@ export const makeConfigs = async ( // to be bridge between // frontend- and backend- // plugins' code - const UNIVERSAL_FILE = 'universal.js'; - const universalPath = paths.resolveTarget(UNIVERSAL_FILE); + const UNIVERSAL_FOLDER = 'universal'; + const universalPath = paths.resolveTarget(UNIVERSAL_FOLDER); const universalFileExists = fs.existsSync(universalPath); if (universalFileExists) { - mainFields.push(UNIVERSAL_FILE); - commonjsInclude.push(UNIVERSAL_FILE); + mainFields.push(UNIVERSAL_FOLDER); + commonjsInclude.push(joinPath(UNIVERSAL_FOLDER, '*.js')); } configs.push({ diff --git a/plugins/github-actions/package.json b/plugins/github-actions/package.json index 0000e07d23..c4a6d8cc01 100644 --- a/plugins/github-actions/package.json +++ b/plugins/github-actions/package.json @@ -51,6 +51,6 @@ }, "files": [ "dist", - "universal.js" + "universal" ] } diff --git a/plugins/github-actions/universal.js b/plugins/github-actions/universal/index.js similarity index 87% rename from plugins/github-actions/universal.js rename to plugins/github-actions/universal/index.js index a414b71749..b101b61efc 100644 --- a/plugins/github-actions/universal.js +++ b/plugins/github-actions/universal/index.js @@ -1,3 +1,4 @@ +// @ts-check /* * Copyright 2020 Spotify AB * @@ -14,5 +15,8 @@ * limitations under the License. */ -// This file is shared between frontend and backend plugins +/** + * Annotation to define on the entity to enable the plugin + * @type {string} + */ module.exports.GITHUB_ACTIONS_ANNOTATION = 'github.com/project-slug'; diff --git a/plugins/github-actions/universal/package.json b/plugins/github-actions/universal/package.json new file mode 100644 index 0000000000..df593c690d --- /dev/null +++ b/plugins/github-actions/universal/package.json @@ -0,0 +1,5 @@ +{ + "main": "index.js", + "module": "index.js", + "description": "Provides code that can be shared between frontend- and backend-oriented packages" +} From 7b9abc0a10fa07cb482d1bbec3d085483c5e4dcb Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Wed, 7 Oct 2020 17:01:44 +0200 Subject: [PATCH 05/21] fix: import --- .../src/components/Cards/RecentWorkflowRunsCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx b/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx index e5bba7fad9..aa1fecba7d 100644 --- a/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx +++ b/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx @@ -15,7 +15,7 @@ */ import { Entity } from '@backstage/catalog-model'; import { errorApiRef, useApi } from '@backstage/core-api'; -import { GITHUB_ACTIONS_ANNOTATION } from '../useProjectName'; +import { GITHUB_ACTIONS_ANNOTATION } from '../../../universal'; import { useWorkflowRuns } from '../useWorkflowRuns'; import React, { useEffect } from 'react'; import { EmptyState, Table } from '@backstage/core'; From 9c3a03d20d45142bed11c126b744b971793400e9 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Wed, 7 Oct 2020 17:13:32 +0200 Subject: [PATCH 06/21] fix: eslint --- .../scaffolder/src/components/JobStatusModal/JobStatusModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scaffolder/src/components/JobStatusModal/JobStatusModal.tsx b/plugins/scaffolder/src/components/JobStatusModal/JobStatusModal.tsx index 6561e5153d..33fdb73b2e 100644 --- a/plugins/scaffolder/src/components/JobStatusModal/JobStatusModal.tsx +++ b/plugins/scaffolder/src/components/JobStatusModal/JobStatusModal.tsx @@ -53,7 +53,7 @@ export const JobStatusModal = ({ onComplete(job!); } else if (jobStatus === 'FAILED') setDialogTitle('Failed to create component'); - }, [jobStatus, onComplete, setDialogTitle]); + }, [jobStatus, onComplete, setDialogTitle]); // eslint-disable-line react-hooks/exhaustive-deps return ( From b314109c83bb4e6e0e33442c8ba564c57eb5f61e Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 28 Oct 2020 09:10:48 +0100 Subject: [PATCH 07/21] chore(lint): update to use the latest monorepo plugin --- packages/cli/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index c336684ba5..c855d86e04 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -58,7 +58,7 @@ "eslint": "^7.1.0", "eslint-formatter-friendly": "^7.0.0", "eslint-plugin-import": "^2.20.2", - "eslint-plugin-monorepo": "^0.2.1", + "eslint-plugin-monorepo": "^0.3.0", "fork-ts-checker-webpack-plugin": "^4.0.5", "fs-extra": "^9.0.0", "handlebars": "^4.7.3", diff --git a/yarn.lock b/yarn.lock index 9d7c53fb8c..3210ca0a83 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10784,10 +10784,10 @@ eslint-plugin-jsx-a11y@^6.2.1: has "^1.0.3" jsx-ast-utils "^2.2.1" -eslint-plugin-monorepo@^0.2.1: - version "0.2.1" - resolved "https://registry.npmjs.org/eslint-plugin-monorepo/-/eslint-plugin-monorepo-0.2.1.tgz#96cfc4af241077675f40d7017377897fb8ea537b" - integrity sha512-82JaAjuajVAsDT+pMvdt275H6F55H3MEofaMZbJurGqfXpPDT4eayTgYyyjfd1XR8VD1S+ORbuHCULnSqNyD9g== +eslint-plugin-monorepo@^0.3.0: + version "0.3.0" + resolved "https://registry.npmjs.org/eslint-plugin-monorepo/-/eslint-plugin-monorepo-0.3.0.tgz#8bfab30713fbc543cb7bffae651ab37bf601a3b3" + integrity sha512-pg1Q37BSDDFh7XdKIsCAi+6/XtE/Kyltu6KokFRFsDe1vOa/R6+O9OVLmav012bBDPrChw8QzBDE7pvADg9+Jg== dependencies: eslint-module-utils "^2.1.1" get-monorepo-packages "^1.1.0" From 002e0eb1ef7a0ef4190e15bbc7d0976f6326833a Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 28 Oct 2020 09:36:18 +0100 Subject: [PATCH 08/21] chore(lint): bump again as there was a problem --- packages/cli/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index c855d86e04..f6b4ff20fc 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -58,7 +58,7 @@ "eslint": "^7.1.0", "eslint-formatter-friendly": "^7.0.0", "eslint-plugin-import": "^2.20.2", - "eslint-plugin-monorepo": "^0.3.0", + "eslint-plugin-monorepo": "^0.3.1", "fork-ts-checker-webpack-plugin": "^4.0.5", "fs-extra": "^9.0.0", "handlebars": "^4.7.3", diff --git a/yarn.lock b/yarn.lock index 3210ca0a83..18b0d93a2d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10784,10 +10784,10 @@ eslint-plugin-jsx-a11y@^6.2.1: has "^1.0.3" jsx-ast-utils "^2.2.1" -eslint-plugin-monorepo@^0.3.0: - version "0.3.0" - resolved "https://registry.npmjs.org/eslint-plugin-monorepo/-/eslint-plugin-monorepo-0.3.0.tgz#8bfab30713fbc543cb7bffae651ab37bf601a3b3" - integrity sha512-pg1Q37BSDDFh7XdKIsCAi+6/XtE/Kyltu6KokFRFsDe1vOa/R6+O9OVLmav012bBDPrChw8QzBDE7pvADg9+Jg== +eslint-plugin-monorepo@^0.3.1: + version "0.3.1" + resolved "https://registry.npmjs.org/eslint-plugin-monorepo/-/eslint-plugin-monorepo-0.3.1.tgz#698a74b3ef2a3481faaefab6219184429a57e01e" + integrity sha512-Oz91zASwmNapr5IHP9MYh4mEmkb5ZQJ1XxXU6KFY5eLxD1+V+J4B+yYDiILkaQCf5Itz4LKgnCoiB59lD/X29A== dependencies: eslint-module-utils "^2.1.1" get-monorepo-packages "^1.1.0" From 41ed522afbb4bab16dd5c5a768d950b195f1d525 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Wed, 28 Oct 2020 10:00:04 +0100 Subject: [PATCH 09/21] chore: bump eslint-plugin-monorepo --- packages/cli/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 8a330d861b..8aceb440d0 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -65,7 +65,7 @@ "eslint-plugin-import": "^2.20.2", "eslint-plugin-jest": "^24.1.0", "eslint-plugin-jsx-a11y": "^6.2.1", - "eslint-plugin-monorepo": "^0.2.1", + "eslint-plugin-monorepo": "^0.3.1", "eslint-plugin-react": "^7.12.4", "eslint-plugin-react-hooks": "^4.0.0", "fork-ts-checker-webpack-plugin": "^4.0.5", diff --git a/yarn.lock b/yarn.lock index ef52ed9918..9bc6cf9efa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10912,10 +10912,10 @@ eslint-plugin-jsx-a11y@^6.2.1: has "^1.0.3" jsx-ast-utils "^2.2.1" -eslint-plugin-monorepo@^0.2.1: - version "0.2.1" - resolved "https://registry.npmjs.org/eslint-plugin-monorepo/-/eslint-plugin-monorepo-0.2.1.tgz#96cfc4af241077675f40d7017377897fb8ea537b" - integrity sha512-82JaAjuajVAsDT+pMvdt275H6F55H3MEofaMZbJurGqfXpPDT4eayTgYyyjfd1XR8VD1S+ORbuHCULnSqNyD9g== +eslint-plugin-monorepo@^0.3.1: + version "0.3.1" + resolved "https://registry.npmjs.org/eslint-plugin-monorepo/-/eslint-plugin-monorepo-0.3.1.tgz#698a74b3ef2a3481faaefab6219184429a57e01e" + integrity sha512-Oz91zASwmNapr5IHP9MYh4mEmkb5ZQJ1XxXU6KFY5eLxD1+V+J4B+yYDiILkaQCf5Itz4LKgnCoiB59lD/X29A== dependencies: eslint-module-utils "^2.1.1" get-monorepo-packages "^1.1.0" From 2ceb961f4ee5d40625881ca621e03a8a47b9b7aa Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Wed, 28 Oct 2020 10:08:01 +0100 Subject: [PATCH 10/21] chore: merge upstream --- packages/cli/package.json | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index de447b27b5..8aceb440d0 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -38,11 +38,7 @@ "@rollup/plugin-json": "^4.0.2", "@rollup/plugin-node-resolve": "^9.0.0", "@rollup/plugin-yaml": "^2.1.1", -<<<<<<< HEAD - "@spotify/eslint-config-base": "^9.0.0", -======= "@spotify/eslint-config-base": "^8.0.0", ->>>>>>> 88203b2fdd686da88b4d9f5ebe3564be90bcdd37 "@spotify/eslint-config-react": "^8.0.0", "@spotify/eslint-config-typescript": "^8.0.0", "@sucrase/webpack-loader": "^2.0.0", @@ -67,15 +63,11 @@ "eslint-config-prettier": "^6.0.0", "eslint-formatter-friendly": "^7.0.0", "eslint-plugin-import": "^2.20.2", -<<<<<<< HEAD "eslint-plugin-jest": "^24.1.0", "eslint-plugin-jsx-a11y": "^6.2.1", "eslint-plugin-monorepo": "^0.3.1", "eslint-plugin-react": "^7.12.4", "eslint-plugin-react-hooks": "^4.0.0", -======= - "eslint-plugin-monorepo": "^0.3.1", ->>>>>>> 88203b2fdd686da88b4d9f5ebe3564be90bcdd37 "fork-ts-checker-webpack-plugin": "^4.0.5", "fs-extra": "^9.0.0", "handlebars": "^4.7.3", From a569f36ce8cd04b21d8164f7dd797df5263d3191 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Wed, 28 Oct 2020 10:47:38 +0100 Subject: [PATCH 11/21] refactor: remove eslint-disable monorepo/internal-import --- packages/app/src/index.tsx | 3 +-- .../github-actions/{universal/index.js => universal.js} | 0 plugins/github-actions/universal/package.json | 5 ----- .../src/scaffolder/stages/templater/cra/index.ts | 6 ++++-- yarn.lock | 7 ------- 5 files changed, 5 insertions(+), 16 deletions(-) rename plugins/github-actions/{universal/index.js => universal.js} (100%) delete mode 100644 plugins/github-actions/universal/package.json diff --git a/packages/app/src/index.tsx b/packages/app/src/index.tsx index a38159a258..ed1637d2c2 100644 --- a/packages/app/src/index.tsx +++ b/packages/app/src/index.tsx @@ -14,8 +14,7 @@ * limitations under the License. */ -// eslint-disable-next-line monorepo/no-internal-import -import '@backstage/cli/asset-types'; +import '@backstage/cli/asset-types/asset-types'; import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; diff --git a/plugins/github-actions/universal/index.js b/plugins/github-actions/universal.js similarity index 100% rename from plugins/github-actions/universal/index.js rename to plugins/github-actions/universal.js diff --git a/plugins/github-actions/universal/package.json b/plugins/github-actions/universal/package.json deleted file mode 100644 index df593c690d..0000000000 --- a/plugins/github-actions/universal/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "main": "index.js", - "module": "index.js", - "description": "Provides code that can be shared between frontend- and backend-oriented packages" -} diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts b/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts index 61a7064dc0..7d27688c0b 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts @@ -19,8 +19,8 @@ import { TemplaterBase, TemplaterRunOptions } from '..'; import path from 'path'; import { TemplaterRunResult } from '../types'; import * as yaml from 'yaml'; -// eslint-disable-next-line monorepo/no-internal-import import { GITHUB_ACTIONS_ANNOTATION } from '@backstage/plugin-github-actions/universal'; +import { resolvePackagePath } from '@backstage/backend-common'; export class CreateReactAppTemplater implements TemplaterBase { public async run(options: TemplaterRunOptions): Promise { @@ -61,7 +61,9 @@ export class CreateReactAppTemplater implements TemplaterBase { await fs.promises.mkdir(`${finalDir}/.github`); await fs.promises.mkdir(`${finalDir}/.github/workflows`); await fs.promises.copyFile( - `${__dirname}/templates/.github/workflows/main.yml`, + `${resolvePackagePath( + '@backstage/plugin-scaffolder-backend', + )}/templates/.github/workflows/main.yml`, `${finalDir}/.github/workflows/main.yml`, ); diff --git a/yarn.lock b/yarn.lock index c31e12127d..9bc6cf9efa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3801,17 +3801,10 @@ dependencies: "@sinonjs/commons" "^1.7.0" -<<<<<<< HEAD -"@spotify/eslint-config-base@^8.1.0": - version "9.0.0" - resolved "https://registry.npmjs.org/@spotify/eslint-config-base/-/eslint-config-base-9.0.0.tgz#e122b2e6d1a11750170badc5be6774ded95953d2" - integrity sha512-LNGY6bBM0IlosvMIx9Ic5gqatpa5LPvrJhN4RnrUnP9oaXNLgPTKDE89p3eC5Tnh78ADdX4HD+rbHDSyP2tBgg== -======= "@spotify/eslint-config-base@^8.0.0": version "8.0.0" resolved "https://registry.npmjs.org/@spotify/eslint-config-base/-/eslint-config-base-8.0.0.tgz#c3d10d8a05ad9129d579952cb80063e4c4fa216e" integrity sha512-07Fo+KoTMl4AaZJPD6deFnYmG634wzgeqfFcWdFlIrOLAasvWSH8Lp6ZE9cJBKuffOAy8kuEE1SwFo34+5X8bQ== ->>>>>>> 88203b2fdd686da88b4d9f5ebe3564be90bcdd37 "@spotify/eslint-config-oss@^1.0.1": version "1.0.2" From fcee31f99a9bec113da137205e63de427a3e4100 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Wed, 28 Oct 2020 11:18:57 +0100 Subject: [PATCH 12/21] fix: universal folder -> universal file --- packages/cli/src/lib/builder/config.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/lib/builder/config.ts b/packages/cli/src/lib/builder/config.ts index c305d248be..60b8ad20ba 100644 --- a/packages/cli/src/lib/builder/config.ts +++ b/packages/cli/src/lib/builder/config.ts @@ -16,7 +16,7 @@ import chalk from 'chalk'; import fs from 'fs-extra'; -import { relative as relativePath, join as joinPath } from 'path'; +import { relative as relativePath } from 'path'; import peerDepsExternal from 'rollup-plugin-peer-deps-external'; import commonjs from '@rollup/plugin-commonjs'; import resolve from '@rollup/plugin-node-resolve'; @@ -85,13 +85,13 @@ export const makeConfigs = async ( // to be bridge between // frontend- and backend- // plugins' code - const UNIVERSAL_FOLDER = 'universal'; - const universalPath = paths.resolveTarget(UNIVERSAL_FOLDER); + const UNIVERSAL_FILE = 'universal.js'; + const universalPath = paths.resolveTarget(UNIVERSAL_FILE); const universalFileExists = fs.existsSync(universalPath); if (universalFileExists) { - mainFields.push(UNIVERSAL_FOLDER); - commonjsInclude.push(joinPath(UNIVERSAL_FOLDER, '*.js')); + mainFields.push(UNIVERSAL_FILE); + commonjsInclude.push(UNIVERSAL_FILE); } configs.push({ From 67da53ab33839fd748a8d108134633913e3512e2 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Tue, 3 Nov 2020 14:58:20 +0100 Subject: [PATCH 13/21] feat: add universal file to plugin template --- packages/cli/templates/default-plugin/package.json.hbs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cli/templates/default-plugin/package.json.hbs b/packages/cli/templates/default-plugin/package.json.hbs index 41f942fb79..8afd3654df 100644 --- a/packages/cli/templates/default-plugin/package.json.hbs +++ b/packages/cli/templates/default-plugin/package.json.hbs @@ -46,6 +46,7 @@ "cross-fetch": "^3.0.6" }, "files": [ - "dist" + "dist", + "universal" ] } From c58fa2cb139b478c1808a5ac56420f0349d1ec89 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Tue, 10 Nov 2020 15:10:41 +0100 Subject: [PATCH 14/21] fix: disable files field sync --- packages/cli/src/lib/diff/handlers.ts | 7 ++++++- packages/cli/templates/default-plugin/package.json.hbs | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/lib/diff/handlers.ts b/packages/cli/src/lib/diff/handlers.ts index 40e3d4c587..588ce2f45f 100644 --- a/packages/cli/src/lib/diff/handlers.ts +++ b/packages/cli/src/lib/diff/handlers.ts @@ -61,7 +61,12 @@ class PackageJsonHandler { await this.syncField('main:src'); } await this.syncField('types'); - await this.syncField('files'); + + // shmidt-i: Skipping `files` for now, + // need more info how to handle + // and what to allow + + // await this.syncField('files'); await this.syncScripts(); await this.syncPublishConfig(); await this.syncDependencies('dependencies'); diff --git a/packages/cli/templates/default-plugin/package.json.hbs b/packages/cli/templates/default-plugin/package.json.hbs index 6cfdc6530b..a3f924408a 100644 --- a/packages/cli/templates/default-plugin/package.json.hbs +++ b/packages/cli/templates/default-plugin/package.json.hbs @@ -46,7 +46,6 @@ "cross-fetch": "^3.0.6" }, "files": [ - "dist", - "universal" + "dist" ] } From f5339205e991a5b2e0c66074f9f41cef8ddcd555 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 15 Dec 2020 10:30:36 +0100 Subject: [PATCH 15/21] chore: bump to latest eslint monorepo plugin --- packages/cli/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 7477eef5d7..1e3bfeac1e 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -65,7 +65,7 @@ "eslint-plugin-import": "^2.20.2", "eslint-plugin-jest": "^24.1.0", "eslint-plugin-jsx-a11y": "^6.2.1", - "eslint-plugin-monorepo": "^0.3.1", + "eslint-plugin-monorepo": "^0.3.2", "eslint-plugin-react": "^7.12.4", "eslint-plugin-react-hooks": "^4.0.0", "fork-ts-checker-webpack-plugin": "^4.0.5", diff --git a/yarn.lock b/yarn.lock index f8e0e00ae5..5ee42e7dd9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11023,10 +11023,10 @@ eslint-plugin-jsx-a11y@^6.2.1: has "^1.0.3" jsx-ast-utils "^2.2.1" -eslint-plugin-monorepo@^0.3.1: - version "0.3.1" - resolved "https://registry.npmjs.org/eslint-plugin-monorepo/-/eslint-plugin-monorepo-0.3.1.tgz#698a74b3ef2a3481faaefab6219184429a57e01e" - integrity sha512-Oz91zASwmNapr5IHP9MYh4mEmkb5ZQJ1XxXU6KFY5eLxD1+V+J4B+yYDiILkaQCf5Itz4LKgnCoiB59lD/X29A== +eslint-plugin-monorepo@^0.3.2: + version "0.3.2" + resolved "https://registry.npmjs.org/eslint-plugin-monorepo/-/eslint-plugin-monorepo-0.3.2.tgz#bc546cbe84b21ae6a7622f261bf9fe73b1524367" + integrity sha512-CypTAqHjTR05XxzqDj7x88oVu2GiqqQA/datD9kIwciHzpj0oE4YbTdyEFFKADgd7dbd21KliSlUpOvo626FBw== dependencies: eslint-module-utils "^2.1.1" get-monorepo-packages "^1.1.0" From bdd10ca66f39d319a334ae6d8e39b0f36c8ea9ce Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 15 Dec 2020 19:48:11 +0100 Subject: [PATCH 16/21] chore: replace GITHUB_ACTIONS_ANNOTATION with const for now as we need a release of the github-actions-plugin first --- plugins/github-actions/src/components/Cards/Cards.tsx | 5 ++++- .../src/components/Cards/RecentWorkflowRunsCard.tsx | 5 ++++- plugins/github-actions/src/components/Router.tsx | 5 ++++- .../src/scaffolder/stages/templater/cra/index.ts | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/github-actions/src/components/Cards/Cards.tsx b/plugins/github-actions/src/components/Cards/Cards.tsx index 64de351d4e..0d797dcc41 100644 --- a/plugins/github-actions/src/components/Cards/Cards.tsx +++ b/plugins/github-actions/src/components/Cards/Cards.tsx @@ -32,7 +32,10 @@ import { useApi, } from '@backstage/core'; import ExternalLinkIcon from '@material-ui/icons/Launch'; -import { GITHUB_ACTIONS_ANNOTATION } from '../../../universal'; + +// TODO(blam): Replace with the universal import from github-actions after a release +// As it will break the E2E without it +const GITHUB_ACTIONS_ANNOTATION = 'github.com/project-slug'; const useStyles = makeStyles({ externalLinkIcon: { diff --git a/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx b/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx index 184e784249..094464f3a2 100644 --- a/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx +++ b/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx @@ -15,7 +15,6 @@ */ import { Entity } from '@backstage/catalog-model'; import { errorApiRef, useApi } from '@backstage/core-api'; -import { GITHUB_ACTIONS_ANNOTATION } from '../../../universal'; import { useWorkflowRuns } from '../useWorkflowRuns'; import React, { useEffect } from 'react'; import { EmptyState, InfoCard, Table } from '@backstage/core'; @@ -23,6 +22,10 @@ import { WorkflowRunStatus } from '../WorkflowRunStatus'; import { Button, Link } from '@material-ui/core'; import { generatePath, Link as RouterLink } from 'react-router-dom'; +// TODO(blam): Replace with the universal import from github-actions after a release +// As it will break the E2E without it +const GITHUB_ACTIONS_ANNOTATION = 'github.com/project-slug'; + const firstLine = (message: string): string => message.split('\n')[0]; export type Props = { diff --git a/plugins/github-actions/src/components/Router.tsx b/plugins/github-actions/src/components/Router.tsx index 720f751be6..964b8dc112 100644 --- a/plugins/github-actions/src/components/Router.tsx +++ b/plugins/github-actions/src/components/Router.tsx @@ -19,9 +19,12 @@ import { Routes, Route } from 'react-router'; import { rootRouteRef, buildRouteRef } from '../plugin'; import { WorkflowRunDetails } from './WorkflowRunDetails'; import { WorkflowRunsTable } from './WorkflowRunsTable'; -import { GITHUB_ACTIONS_ANNOTATION } from '../../universal'; import { MissingAnnotationEmptyState } from '@backstage/core'; +// TODO(blam): Replace with the universal import from github-actions after a release +// As it will break the E2E without it +const GITHUB_ACTIONS_ANNOTATION = 'github.com/project-slug'; + export const isPluginApplicableToEntity = (entity: Entity) => Boolean(entity.metadata.annotations?.[GITHUB_ACTIONS_ANNOTATION]); diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts b/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts index ce7e76fb47..b30e86d903 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/templater/cra/index.ts @@ -19,9 +19,12 @@ import { TemplaterBase, TemplaterRunOptions } from '..'; import path from 'path'; import { TemplaterRunResult } from '../types'; import * as yaml from 'yaml'; -import { GITHUB_ACTIONS_ANNOTATION } from '@backstage/plugin-github-actions/universal'; import { resolvePackagePath } from '@backstage/backend-common'; +// TODO(blam): Replace with the universal import from github-actions after a release +// As it will break the E2E without it +const GITHUB_ACTIONS_ANNOTATION = 'github.com/project-slug'; + export class CreateReactAppTemplater implements TemplaterBase { public async run(options: TemplaterRunOptions): Promise { const { From a04b28ac4b38ddf4e385cf366eecaf7dcb9a00cb Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 15 Dec 2020 21:04:15 +0100 Subject: [PATCH 17/21] feat: do better file detection to check that the universal file is added to the diff too --- packages/cli/src/lib/diff/handlers.ts | 23 ++++++++++++++++++++++- plugins/github-actions/package.json | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/lib/diff/handlers.ts b/packages/cli/src/lib/diff/handlers.ts index befda6b5e1..840b58af65 100644 --- a/packages/cli/src/lib/diff/handlers.ts +++ b/packages/cli/src/lib/diff/handlers.ts @@ -61,13 +61,34 @@ class PackageJsonHandler { await this.syncField('main:src'); } await this.syncField('types'); - + await this.syncFiles(); await this.syncScripts(); await this.syncPublishConfig(); await this.syncDependencies('dependencies'); await this.syncDependencies('devDependencies'); } + private async syncFiles() { + const hasUniversalFile = this.targetPkg.files.includes('universal.js'); + const hasConfigTypeScriptFile = + typeof this.targetPkg.configSchema === 'string'; + + if (hasUniversalFile || hasConfigTypeScriptFile) { + const files = [...this.pkg.files]; + if (hasUniversalFile) { + files.push('universal.js'); + } + + if (hasConfigTypeScriptFile) { + files.push(this.targetPkg.configSchema); + } + + await this.syncField('files', { files }); + } else { + await this.syncField('files'); + } + } + // Make sure a field inside package.json is in sync. This mutates the targetObj and writes package.json on change. private async syncField( fieldName: string, diff --git a/plugins/github-actions/package.json b/plugins/github-actions/package.json index 5bab38b404..33481328b6 100644 --- a/plugins/github-actions/package.json +++ b/plugins/github-actions/package.json @@ -64,6 +64,6 @@ }, "files": [ "dist", - "universal" + "universal.js" ] } From c754b6aa47b88f1ee44489b17149bc10452d32ee Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 16 Dec 2020 10:36:57 +0100 Subject: [PATCH 18/21] chore: revert some of the universal file stuff for now --- packages/cli/src/lib/builder/config.ts | 17 +---------- packages/cli/src/lib/diff/handlers.ts | 30 ++++++------------- plugins/github-actions/package.json | 3 +- .../src/components/Cards/Cards.tsx | 5 +--- .../Cards/RecentWorkflowRunsCard.tsx | 5 +--- .../github-actions/src/components/Router.tsx | 5 +--- .../src/components/useProjectName.ts | 3 +- plugins/github-actions/src/index.ts | 1 + plugins/github-actions/universal.js | 22 -------------- plugins/scaffolder-backend/package.json | 3 +- 10 files changed, 18 insertions(+), 76 deletions(-) delete mode 100644 plugins/github-actions/universal.js diff --git a/packages/cli/src/lib/builder/config.ts b/packages/cli/src/lib/builder/config.ts index 60b8ad20ba..2e7847fdb1 100644 --- a/packages/cli/src/lib/builder/config.ts +++ b/packages/cli/src/lib/builder/config.ts @@ -79,21 +79,6 @@ export const makeConfigs = async ( mainFields.unshift('browser'); } - const commonjsInclude: Array = [/node_modules/]; - - // Purpose of this file is - // to be bridge between - // frontend- and backend- - // plugins' code - const UNIVERSAL_FILE = 'universal.js'; - const universalPath = paths.resolveTarget(UNIVERSAL_FILE); - const universalFileExists = fs.existsSync(universalPath); - - if (universalFileExists) { - mainFields.push(UNIVERSAL_FILE); - commonjsInclude.push(UNIVERSAL_FILE); - } - configs.push({ input: 'src/index.ts', output, @@ -105,7 +90,7 @@ export const makeConfigs = async ( }), resolve({ mainFields }), commonjs({ - include: commonjsInclude, + include: /node_modules/, exclude: [/\/[^/]+\.(?:stories|test)\.[^/]+$/], }), postcss(), diff --git a/packages/cli/src/lib/diff/handlers.ts b/packages/cli/src/lib/diff/handlers.ts index 840b58af65..a210986b2a 100644 --- a/packages/cli/src/lib/diff/handlers.ts +++ b/packages/cli/src/lib/diff/handlers.ts @@ -68,27 +68,6 @@ class PackageJsonHandler { await this.syncDependencies('devDependencies'); } - private async syncFiles() { - const hasUniversalFile = this.targetPkg.files.includes('universal.js'); - const hasConfigTypeScriptFile = - typeof this.targetPkg.configSchema === 'string'; - - if (hasUniversalFile || hasConfigTypeScriptFile) { - const files = [...this.pkg.files]; - if (hasUniversalFile) { - files.push('universal.js'); - } - - if (hasConfigTypeScriptFile) { - files.push(this.targetPkg.configSchema); - } - - await this.syncField('files', { files }); - } else { - await this.syncField('files'); - } - } - // Make sure a field inside package.json is in sync. This mutates the targetObj and writes package.json on change. private async syncField( fieldName: string, @@ -126,6 +105,15 @@ class PackageJsonHandler { } } + private async syncFiles() { + if (typeof this.targetPkg.configSchema === 'string') { + const files = [...this.pkg.files, this.targetPkg.configSchema]; + await this.syncField('files', { files }); + } else { + await this.syncField('files'); + } + } + private async syncScripts() { const pkgScripts = this.pkg.scripts; const targetScripts = (this.targetPkg.scripts = diff --git a/plugins/github-actions/package.json b/plugins/github-actions/package.json index 33481328b6..6c01a592d8 100644 --- a/plugins/github-actions/package.json +++ b/plugins/github-actions/package.json @@ -63,7 +63,6 @@ "msw": "^0.21.2" }, "files": [ - "dist", - "universal.js" + "dist" ] } diff --git a/plugins/github-actions/src/components/Cards/Cards.tsx b/plugins/github-actions/src/components/Cards/Cards.tsx index 0d797dcc41..1f1e2997df 100644 --- a/plugins/github-actions/src/components/Cards/Cards.tsx +++ b/plugins/github-actions/src/components/Cards/Cards.tsx @@ -32,10 +32,7 @@ import { useApi, } from '@backstage/core'; import ExternalLinkIcon from '@material-ui/icons/Launch'; - -// TODO(blam): Replace with the universal import from github-actions after a release -// As it will break the E2E without it -const GITHUB_ACTIONS_ANNOTATION = 'github.com/project-slug'; +import { GITHUB_ACTIONS_ANNOTATION } from '../useProjectName'; const useStyles = makeStyles({ externalLinkIcon: { diff --git a/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx b/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx index 094464f3a2..70348ece0a 100644 --- a/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx +++ b/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx @@ -15,6 +15,7 @@ */ import { Entity } from '@backstage/catalog-model'; import { errorApiRef, useApi } from '@backstage/core-api'; +import { GITHUB_ACTIONS_ANNOTATION } from '../useProjectName'; import { useWorkflowRuns } from '../useWorkflowRuns'; import React, { useEffect } from 'react'; import { EmptyState, InfoCard, Table } from '@backstage/core'; @@ -22,10 +23,6 @@ import { WorkflowRunStatus } from '../WorkflowRunStatus'; import { Button, Link } from '@material-ui/core'; import { generatePath, Link as RouterLink } from 'react-router-dom'; -// TODO(blam): Replace with the universal import from github-actions after a release -// As it will break the E2E without it -const GITHUB_ACTIONS_ANNOTATION = 'github.com/project-slug'; - const firstLine = (message: string): string => message.split('\n')[0]; export type Props = { diff --git a/plugins/github-actions/src/components/Router.tsx b/plugins/github-actions/src/components/Router.tsx index 964b8dc112..e7430d40ed 100644 --- a/plugins/github-actions/src/components/Router.tsx +++ b/plugins/github-actions/src/components/Router.tsx @@ -19,12 +19,9 @@ import { Routes, Route } from 'react-router'; import { rootRouteRef, buildRouteRef } from '../plugin'; import { WorkflowRunDetails } from './WorkflowRunDetails'; import { WorkflowRunsTable } from './WorkflowRunsTable'; +import { GITHUB_ACTIONS_ANNOTATION } from './useProjectName'; import { MissingAnnotationEmptyState } from '@backstage/core'; -// TODO(blam): Replace with the universal import from github-actions after a release -// As it will break the E2E without it -const GITHUB_ACTIONS_ANNOTATION = 'github.com/project-slug'; - export const isPluginApplicableToEntity = (entity: Entity) => Boolean(entity.metadata.annotations?.[GITHUB_ACTIONS_ANNOTATION]); diff --git a/plugins/github-actions/src/components/useProjectName.ts b/plugins/github-actions/src/components/useProjectName.ts index 226cc6c775..ec7158bd27 100644 --- a/plugins/github-actions/src/components/useProjectName.ts +++ b/plugins/github-actions/src/components/useProjectName.ts @@ -16,7 +16,8 @@ import { useAsync } from 'react-use'; import { Entity } from '@backstage/catalog-model'; -import { GITHUB_ACTIONS_ANNOTATION } from '../../universal'; + +export const GITHUB_ACTIONS_ANNOTATION = 'github.com/project-slug'; export const useProjectName = (entity: Entity) => { const { value, loading, error } = useAsync(async () => { diff --git a/plugins/github-actions/src/index.ts b/plugins/github-actions/src/index.ts index 5c89c7f920..24fe6fc90d 100644 --- a/plugins/github-actions/src/index.ts +++ b/plugins/github-actions/src/index.ts @@ -18,3 +18,4 @@ export { plugin } from './plugin'; export * from './api'; export { Router, isPluginApplicableToEntity } from './components/Router'; export * from './components/Cards'; +export { GITHUB_ACTIONS_ANNOTATION } from './components/useProjectName'; diff --git a/plugins/github-actions/universal.js b/plugins/github-actions/universal.js deleted file mode 100644 index b101b61efc..0000000000 --- a/plugins/github-actions/universal.js +++ /dev/null @@ -1,22 +0,0 @@ -// @ts-check -/* - * 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. - */ - -/** - * Annotation to define on the entity to enable the plugin - * @type {string} - */ -module.exports.GITHUB_ACTIONS_ANNOTATION = 'github.com/project-slug'; diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index b1c9c099b4..50bddaaf41 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -29,7 +29,6 @@ "clean": "backstage-cli clean" }, "dependencies": { - "@backstage/plugin-github-actions": "^0.2.4", "@backstage/backend-common": "^0.4.0", "@backstage/catalog-model": "^0.5.0", "@backstage/config": "^0.1.2", @@ -46,7 +45,7 @@ "express": "^4.17.1", "express-promise-router": "^3.0.3", "fs-extra": "^9.0.0", - "git-url-parse": "^11.4.0", + "git-url-parse": "^11.4.3", "globby": "^11.0.0", "helmet": "^4.0.0", "jsonschema": "^1.2.6", From e07eb800c70cba522137f3dfb0dae3859997f73d Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 16 Dec 2020 17:28:53 +0100 Subject: [PATCH 19/21] chore: remove deep link --- packages/app/src/index.tsx | 2 +- yarn.lock | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/app/src/index.tsx b/packages/app/src/index.tsx index ed1637d2c2..71fd40dd7e 100644 --- a/packages/app/src/index.tsx +++ b/packages/app/src/index.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import '@backstage/cli/asset-types/asset-types'; +import '@backstage/cli/asset-types'; import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; diff --git a/yarn.lock b/yarn.lock index 272f85a7a9..65bb891a59 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13259,6 +13259,13 @@ git-url-parse@^11.4.0: dependencies: git-up "^4.0.0" +git-url-parse@^11.4.3: + version "11.4.3" + resolved "https://registry.npmjs.org/git-url-parse/-/git-url-parse-11.4.3.tgz#1610284edf1f14964180f5b3399ec68b692cfd87" + integrity sha512-LZTTk0nqJnKN48YRtOpR8H5SEfp1oM2tls90NuZmBxN95PnCvmuXGzqQ4QmVirBgKx2KPYfPGteX3/raWjKenQ== + dependencies: + git-up "^4.0.0" + gitconfiglocal@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz#41d045f3851a5ea88f03f24ca1c6178114464b9b" From 19554f6d68f8a71a74897ecd1ee14f5371fdfb97 Mon Sep 17 00:00:00 2001 From: Ben Lambert Date: Mon, 21 Dec 2020 11:11:07 +0100 Subject: [PATCH 20/21] Create good-hairs-sniff.md --- .changeset/good-hairs-sniff.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changeset/good-hairs-sniff.md diff --git a/.changeset/good-hairs-sniff.md b/.changeset/good-hairs-sniff.md new file mode 100644 index 0000000000..e23df05600 --- /dev/null +++ b/.changeset/good-hairs-sniff.md @@ -0,0 +1,8 @@ +--- +"@backstage/cli": patch +"@backstage/plugin-github-actions": patch +"@backstage/plugin-scaffolder-backend": patch +"@backstage/plugin-scaffolder": patch +--- + +Added Github Actions for Create React App, and allow better imports of files inside a module when they're exposed using `files` in `package.json` From 8f01e55c5f60db89886ef7f8bd09a3a2ff698c71 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 21 Dec 2020 11:20:13 +0100 Subject: [PATCH 21/21] chore: fixing changeset prettyness --- .changeset/good-hairs-sniff.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.changeset/good-hairs-sniff.md b/.changeset/good-hairs-sniff.md index e23df05600..540da80d60 100644 --- a/.changeset/good-hairs-sniff.md +++ b/.changeset/good-hairs-sniff.md @@ -1,8 +1,8 @@ --- -"@backstage/cli": patch -"@backstage/plugin-github-actions": patch -"@backstage/plugin-scaffolder-backend": patch -"@backstage/plugin-scaffolder": patch +'@backstage/cli': patch +'@backstage/plugin-github-actions': patch +'@backstage/plugin-scaffolder-backend': patch +'@backstage/plugin-scaffolder': patch --- Added Github Actions for Create React App, and allow better imports of files inside a module when they're exposed using `files` in `package.json`