chore: revert some of the universal file stuff for now
This commit is contained in:
@@ -79,21 +79,6 @@ export const makeConfigs = async (
|
||||
mainFields.unshift('browser');
|
||||
}
|
||||
|
||||
const commonjsInclude: Array<RegExp | string> = [/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(),
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -63,7 +63,6 @@
|
||||
"msw": "^0.21.2"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"universal.js"
|
||||
"dist"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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<Theme>({
|
||||
externalLinkIcon: {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user