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",