Merge branch 'master' into shmidt-i/backend-plugins-standalone-builds-fix

This commit is contained in:
Ivan Shmidt
2020-06-17 10:02:42 +02:00
committed by GitHub
28 changed files with 638 additions and 225 deletions
+7 -6
View File
@@ -6,7 +6,9 @@
"types": "src/index.ts",
"private": false,
"publishConfig": {
"access": "public"
"access": "public",
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts"
},
"homepage": "https://backstage.io",
"repository": {
@@ -19,7 +21,7 @@
],
"license": "Apache-2.0",
"scripts": {
"build": "backstage-cli build-cache -- tsc",
"build": "backstage-cli build --outputs cjs,types",
"lint": "backstage-cli lint",
"test": "backstage-cli test",
"prepack": "backstage-cli prepack",
@@ -27,6 +29,8 @@
"clean": "backstage-cli clean"
},
"dependencies": {
"@types/cors": "^2.8.6",
"@types/express": "^4.17.6",
"compression": "^1.7.4",
"cors": "^2.8.5",
"express": "^4.17.1",
@@ -38,8 +42,6 @@
"devDependencies": {
"@backstage/cli": "^0.1.1-alpha.8",
"@types/compression": "^1.7.0",
"@types/cors": "^2.8.6",
"@types/express": "^4.17.6",
"@types/http-errors": "^1.6.3",
"@types/morgan": "^1.9.0",
"@types/stoppable": "^1.1.0",
@@ -50,8 +52,7 @@
"http-errors": "^1.7.3",
"jest": "^26.0.1",
"jest-fetch-mock": "^3.0.3",
"supertest": "^4.0.2",
"typescript": "^3.9.2"
"supertest": "^4.0.2"
},
"files": [
"dist"
-14
View File
@@ -1,14 +0,0 @@
{
"include": ["src"],
"compilerOptions": {
"outDir": "dist",
"incremental": true,
"sourceMap": true,
"declaration": true,
"strict": true,
"target": "ES2019",
"module": "commonjs",
"esModuleInterop": true,
"types": ["node", "jest", "webpack-env"]
}
}
+3 -13
View File
@@ -1,7 +1,7 @@
{
"name": "example-backend",
"version": "0.1.1-alpha.8",
"main": "dist",
"main": "dist/index.cjs.js",
"types": "src/index.ts",
"private": true,
"license": "Apache-2.0",
@@ -9,7 +9,7 @@
"node": ">=12"
},
"scripts": {
"build": "tsc",
"build": "backstage-cli backend:build",
"start": "backstage-cli backend:dev",
"lint": "backstage-cli lint",
"test": "backstage-cli test",
@@ -24,7 +24,6 @@
"@backstage/plugin-identity-backend": "^0.1.1-alpha.8",
"@backstage/plugin-scaffolder-backend": "^0.1.1-alpha.8",
"@backstage/plugin-sentry-backend": "^0.1.1-alpha.8",
"esm": "^3.2.25",
"express": "^4.17.1",
"knex": "^0.21.1",
"sqlite3": "^4.2.0",
@@ -34,15 +33,6 @@
"@backstage/cli": "^0.1.1-alpha.8",
"@types/express": "^4.17.6",
"@types/express-serve-static-core": "^4.17.5",
"@types/helmet": "^0.0.47",
"jest": "^26.0.1",
"tsc-watch": "^4.2.3",
"typescript": "^3.9.2"
},
"nodemonConfig": {
"watch": [
"./dist",
"node_modules/@backstage*"
]
"@types/helmet": "^0.0.47"
}
}
-15
View File
@@ -1,15 +0,0 @@
{
"include": ["src"],
"compilerOptions": {
"outDir": "dist",
"incremental": true,
"sourceMap": true,
"declaration": true,
"strict": true,
"target": "es2019",
"module": "commonjs",
"esModuleInterop": true,
"lib": ["es2019", "dom"],
"types": ["node", "jest", "webpack-env"]
}
}
@@ -0,0 +1,23 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { buildPackage, Output } from '../../lib/packager';
export default async () => {
await buildPackage({
outputs: new Set([Output.cjs, Output.types]),
});
};
+5
View File
@@ -41,6 +41,11 @@ const main = (argv: string[]) => {
.option('--check', 'Enable type checking and linting')
.action(lazyAction(() => import('./commands/app/serve'), 'default'));
program
.command('backend:build')
.description('Build a backend plugin')
.action(lazyAction(() => import('./commands/backend/build'), 'default'));
program
.command('backend:dev')
.description('Start local development server with HMR for the backend')
+8 -7
View File
@@ -5,9 +5,14 @@
"types": "src/index.ts",
"license": "Apache-2.0",
"private": true,
"publishConfig": {
"access": "public",
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts"
},
"scripts": {
"start": "backstage-cli backend:dev",
"build": "tsc",
"build": "backstage-cli backend:build",
"lint": "backstage-cli lint",
"test": "backstage-cli test",
"prepack": "backstage-cli prepack",
@@ -42,13 +47,9 @@
"@backstage/cli": "^0.1.1-alpha.8",
"@types/body-parser": "^1.19.0",
"@types/passport-saml": "^1.1.2",
"jest-fetch-mock": "^3.0.3",
"tsc-watch": "^4.2.3"
"jest-fetch-mock": "^3.0.3"
},
"files": [
"dist"
],
"nodemonConfig": {
"watch": "./dist"
}
]
}
-15
View File
@@ -1,15 +0,0 @@
{
"include": ["src"],
"compilerOptions": {
"outDir": "dist",
"incremental": true,
"sourceMap": true,
"declaration": true,
"strict": true,
"target": "es2019",
"module": "commonjs",
"esModuleInterop": true,
"lib": ["es2019"],
"types": ["node", "jest", "webpack-env"]
}
}
+8 -8
View File
@@ -5,9 +5,14 @@
"types": "src/index.ts",
"license": "Apache-2.0",
"private": true,
"publishConfig": {
"access": "public",
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts"
},
"scripts": {
"start": "backstage-cli backend:dev",
"build": "tsc",
"build": "backstage-cli backend:build",
"lint": "backstage-cli lint",
"test": "backstage-cli test",
"prepack": "backstage-cli prepack",
@@ -18,7 +23,6 @@
"dependencies": {
"@backstage/backend-common": "^0.1.1-alpha.8",
"@backstage/catalog-model": "^0.1.1-alpha.8",
"esm": "^3.2.25",
"express": "^4.17.1",
"express-promise-router": "^3.0.3",
"fs-extra": "^9.0.0",
@@ -41,14 +45,10 @@
"@types/uuid": "^8.0.0",
"@types/yup": "^0.28.2",
"jest-fetch-mock": "^3.0.3",
"supertest": "^4.0.2",
"tsc-watch": "^4.2.3"
"supertest": "^4.0.2"
},
"files": [
"dist",
"migrations"
],
"nodemonConfig": {
"watch": "./dist"
}
]
}
-16
View File
@@ -1,16 +0,0 @@
{
"include": ["src"],
"compilerOptions": {
"outDir": "dist",
"incremental": true,
"sourceMap": true,
"declaration": true,
"strict": true,
"target": "es2019",
"module": "commonjs",
"esModuleInterop": true,
"allowJs": true,
"lib": ["es2019"],
"types": ["node", "jest", "webpack-env"]
}
}
+1
View File
@@ -30,6 +30,7 @@
"@material-ui/core": "^4.9.1",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.45",
"moment": "^2.26.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router": "^6.0.0-alpha.5",
@@ -0,0 +1,46 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React, { FC } from 'react';
import { Header, HomepageTimer, Page, pageTheme } from '@backstage/core';
import { getTimeBasedGreeting } from './utils/timeUtil';
const CatalogLayout: FC<{}> = props => {
const { children } = props;
// const profile = useProfile();
const profile = { givenName: 'friend' };
const greeting = getTimeBasedGreeting();
return (
<Page theme={pageTheme.home}>
<Header
title={
profile
? `${greeting.greeting}, ${profile.givenName}!`
: greeting.greeting
}
subtitle="Backstage Service Catalog"
tooltip={greeting.language}
pageTitleOverride="Home"
>
<HomepageTimer />
</Header>
{children}
</Page>
);
};
export default CatalogLayout;
@@ -64,7 +64,7 @@ describe('CatalogPage', () => {
),
);
expect(
await rendered.findByText('Keep track of your software'),
await rendered.findByText('Backstage Service Catalog'),
).toBeInTheDocument();
});
});
@@ -19,14 +19,11 @@ import {
Content,
ContentHeader,
DismissableBanner,
Header,
HeaderTabs,
HomepageTimer,
Page,
pageTheme,
SupportButton,
useApi,
} from '@backstage/core';
import CatalogLayout from './CatalogLayout';
import { rootRoute as scaffolderRootRoute } from '@backstage/plugin-scaffolder';
import { Button, Link, makeStyles, Typography } from '@material-ui/core';
import Edit from '@material-ui/icons/Edit';
@@ -155,10 +152,7 @@ export const CatalogPage: FC<{}> = () => {
];
return (
<Page theme={pageTheme.home}>
<Header title="Service Catalog" subtitle="Keep track of your software">
<HomepageTimer />
</Header>
<CatalogLayout>
<HeaderTabs tabs={tabs} />
<Content>
<DismissableBanner
@@ -178,7 +172,6 @@ export const CatalogPage: FC<{}> = () => {
}
id="catalog_page_welcome_banner"
/>
<ContentHeader title="Services">
<Button
component={RouterLink}
@@ -207,6 +200,6 @@ export const CatalogPage: FC<{}> = () => {
/>
</div>
</Content>
</Page>
</CatalogLayout>
);
};
@@ -0,0 +1,134 @@
{
"English": "Good afternoon",
"Abkhaz": "Уа, мшы бзиа",
"Adyghe": "Уимафэ шІу",
"Afrikaans": "Goeie middag",
"Albanian": "Mirëdita",
"Aleut": "Angaliichxizax̂",
"Aklan": "Mayad nga hapon",
"Alsatian": "Güete Nàchmittag",
"Arabic": "مساء الخير",
"Armenian": "Բարի կէսօր:",
"Assamese": "শুভ আবেলি",
"Asturian": "Bones tardes",
"Azerbaijani": "Günortanız xeyir",
"Bashkir": "хәйерле көн",
"Basque": "Arratsalde on",
"Bavarian": "Guadn åmd",
"Bengali": "শুভ বিকাল",
"Bhojpuri": "राम राम",
"Bosnian": "Dobar dan",
"Breton": "Demat",
"Bulgarian": "Добър ден",
"Cebuano": "Maayong Hapon",
"Chamorro": "Buenas tåtdes",
"Chinese": "午安",
"Cornish": "Dohajydh da",
"Corsican": "Bonghjornu",
"Croatian": "Dobar dan",
"Cuyonon": "Mayad nga apon",
"Czech": "Dobré odpoledne",
"Danish": "God eftermiddag",
"Dutch": "Goedemiddag",
"Estonian": "Tere päevast",
"Ewe": "Ŋdɔ",
"Faroese": "Góðan dagin",
"Fijian": "Bula",
"Finnish": "Hyvää päivää",
"Flemish": "Ghoeie middagh",
"French": "Bon après-midi",
"Frisian (North)": "Moin",
"Frisian (West)": "Goeie middei",
"Friulian": "Bundì",
"Galician": "Boa tarde",
"Georgian": "დილა მშვიდობისა",
"German": "Guten Tag",
"Greek": "Καλό απόγευμα",
"Greenlandic": "Inuugujaq",
"Haitian Creole": "Bon apre-midi",
"Hausa": "Barka da yamma",
"Hawaiian": "Aloha ʻauinalā",
"Hebrew": "אחר צהריים טובים",
"Hindi": "नमस्कार",
"Icelandic": "Góðan dag",
"Iloko": "Naimbag a malem",
"Indonesian": "Selamat sore",
"Iñupiaq": "Unnusatkun",
"Gaelic": "Tráthnóna maith duit",
"Italian": "Buongiorno",
"Japanese": "こんにちは",
"Javanese": "Sugeng siang",
"Jèrriais": "Bouônjour",
"Kannada": "ಶುಭ ಮಧ್ಯಾಹ್ನ",
"Kazakh": "Kayırlı kun",
"Khmer": "ទិវាសួស្ដី",
"Korean": "안녕하세요",
"Kurdish": "Rojbash",
"Kyrgyz": "Кутмандуу күнүңүз менен",
"Latvian": "Labdien",
"Limburgish": "Gojemiddig",
"Lithuanian": "Laba diena",
"Lozi": "Ki musihali",
"Lule Sámi": "Buorre biejvve",
"Luxembourgish": "Gudde Mëtteg",
"Macedonian": "Добар ден",
"Malagasy": "Manao ahoana e",
"Maltese": "Wara nofsinhar it-tajjeb",
"Mam": "Qalte",
"Manx": "Fastyr mie",
"Māori": "Kia ora",
"Middle Egyptian Hieroglyphs": "𓄤 𓅓𓈙𓂋𓅱𓇰",
"Nepali": "नमस्कार",
"Newari": "भिं न्हि",
"Northern Sámi": "Buorre beaivvi",
"Northern Sotho": "Dumêlang",
"Norwegian": "God ettermiddag",
"Occitan": "Bon vèspre",
"Odia": "ସୁଭ ଖରା ବେଳ",
"Papiamento": "Bon tardi",
"Pashto": "ورځ مو په خير",
"Polish": "Dzień dobry",
"Portuguese": "Boa tarde",
"Romanian": "Bună ziua",
"Russian": "Добрый день",
"Sakha": "Үтүө күнүнэн",
"Sardinian": "Bona sera",
"Scottish Gaelic": "Feasgar math",
"Scots": "Guid efternuin",
"Serbian": "Добар дан",
"Shona": "Masikati",
"Sicilian": "Bon jornu",
"Sinhala": "සුභ දවාලක්",
"Slovenian": "Dober dan",
"Somali": "Galab wanaagsan",
"Southern Sámi": "Buerie biejjie",
"Sumerian": "𒄭𒌓𒁀",
"Swahili": "Habari ya mchana",
"Swedish": "God eftermiddag",
"Swiss German": "Gueten Abig",
"Tagalog": "Magandang hapon po",
"Tamil": "மதிய வணக்கம்",
"Tatar": "Xäyerle kön",
"Telugu": "శుభ మద్యాహ్నం",
"Tetum": "Botarde",
"Thai": "สวัสดีครับ",
"Tibetan": "ཉིན་གུང་བདེ་ལེགས།",
"Tok Pisin": "Apinum",
"Tongan": "Mālō tau mau e hoata ni",
"Tsonga": "Indzengha",
"Tswana": "Thupama e e monate",
"Turkish": "Tünaydın",
"Ukrainian": "Доброго дня",
"Urdu": "روز بخير",
"Uzbek": "Xayrli kun",
"Venetian": "Bondì",
"Vietnamese": "Xin chào",
"Võro": "Hüvvä lõunaaigo",
"Welsh": "P'nawn da",
"Xhosa": "Uben' emva kwemini entle",
"Yapese": "Fal'e misii",
"Yiddish": "א גוט אָוונט",
"Yucatec Maya": "Ma'lob chi'inil K'iin",
"Zazaki": "Perocê şıma xeyr bo",
"Zulu": "Sawubona"
}
@@ -0,0 +1,100 @@
{
"Afrikaans": "Goeienaand",
"Aklanon": "Mayad nga gabi-i",
"Albanian": "Mirëmbrëma",
"Anglo-Saxon": "God æfen",
"Arabic": "Masaa al-khair",
"Aragonese": "Buena nuei",
"Armenian": "Pari yerego",
"Aromunian": "Bunã seara",
"Asante": "Maadwó",
"Asturian": "Bona nuechi",
"Ateso": "Akwar najokan",
"Aymara": "Winas tartis",
"Azerbaijani": "Axşamınız xeyir",
"Basque": "Arratsalde on",
"Belorussian": "Dobry viechar",
"Bemba": "Cungulopo mukwai",
"Bengali": "Shuvo shandhya",
"Bilen": "Aja kunduKwma?",
"Breton": "Noz vat",
"Bulgarian": "Dobar vecher",
"Cantonese": "Maan ngon",
"Cassubian": "Dobri wieczór",
"Catalan": "Bona tarda",
"Chamorro": "Pupuengin maolek",
"Chechen": "Sürea dika yoila",
"Comoran": "Bariza massihou",
"Cornish": "Gorthugher da",
"Croatian": "Dobra večer",
"Czech": "Dobrý večer",
"Danish": "God aften",
"Dutch": "Goedenavond",
"Edo": "Ób’ótà",
"English": "Good evening",
"Esperanto": "Bonan vesperon",
"Estonian": "Tere õhtust",
"Faroese": "Gott kvøld",
"Farsi": "Shab beh'khayr",
"Fijian": "Ni sa bogi",
"Finnish": "Hyvää iltaa",
"French": "Bonsoir",
"Galician": "Boas noites",
"Georgian": "Saghamo mshvidobisa",
"German": "Guten Abend",
"Greek": "Kalinishta",
"Guarani": "Mba’éichapa ndepyhare",
"Hebrew": "Erev tov",
"Hungarian": "Jó estét",
"Icelandic": "Gott kvöld",
"Indonesian": "Selamat malam",
"Irish Gaelic": "Tráthnóna",
"Italian": "Buona sera",
"Japanese": "こんばんは",
"Japanese (Romanji)": "Konban wa",
"Kazakh": "Kayırlı keş",
"Kurdish": "Evarbash",
"Latvian": "Labvakar",
"Lithuanian": "Labas vakaras",
"Luganda": "Osiibye otya nno",
"Luo": "Oimore",
"Luxembourgish": "Gudden Owend",
"Macedonian": "Dobra vecher",
"Malay": "Selamat malam",
"Maltese": "Il-lejla t-tajba",
"Mandarin": "Wan shang hao",
"Maori": "Kia orana i teia aiai",
"Marshallese": "Yokwe in jota",
"Mawe": "Awãe aiko",
"Middle Egyptian Hieroglyphs": "𓄤 𓅱𓃉𓇰",
"Mongolian": "Odoin mend",
"Norwegian [Bokmaal]": "God kveld",
"Odia": "ସୁଭସନ୍ଧ୍ୟା",
"Polish": "Dobry wieczór",
"Portuguese": "Boa noite",
"Quiché": "Xe qij",
"Romani [Sinte]": "Lashi rachi",
"Romanian": "Bunã seara",
"Russian": "Dobry vyecher",
"Scottish Gaelic": "Feasgar mhath",
"Scots": "Guid eenin",
"Sesotho": "Fonane",
"Serbian": "Добро вече",
"Slovak": "Dober vecher",
"Slovenian": "Dober vecher",
"Somali": "Habeen wanaagsan",
"Spanish": "Buenas tardes",
"Sumerian": "𒄭𒈪",
"Swedish": "God afton",
"Tagalog": "Magandang gabi",
"Tatar": "Xäyerle kiç",
"Telugu" : "శుభ సాయంత్రం",
"Thai": "Sawat-dii torn khum",
"Turkish": "İyi akşamlar",
"Ukrainian": "Dobry vechir",
"Uzbek": "Xayrli kech",
"Welsh": "Noswaith dda",
"Yiddish": "Ah gutn ovnt",
"Chinese": "晚安",
"Valyrian": "sȳz bantis"
}
@@ -0,0 +1,64 @@
{
"English": "Good morning",
"Afrikaans": "Goeiemôre, Môre",
"Albanian": "Mirëmëngjes",
"Arabic": "صباح الخير",
"Armenian": "Paree looys",
"Azerbaijani": "Sabahınız xeyir",
"Bengali": "shuprobhat",
"Bulgarian": "Dobro utro",
"Catalan": "Bon dia",
"Chinese": "早安",
"Croatian": "Dobro jutro",
"Czech": "Dobré ráno",
"Danish": "God morgen",
"Dutch": "Goedemorgen",
"Esperanto": "Bonan matenon",
"Estonian": "Tere hommikust",
"Finnish": "Hyvää huomenta",
"French": "Bonjour",
"German": "Guten Morgen",
"Greek": "Kaliméra",
"Kalaallisut": "Iterluarit",
"Hawaiian": "Aloha kakahiaka",
"Hebrew": "boker tov",
"Hindi": "Namaste",
"Hungarian": "Jó reggelt",
"Indonesian": "Selamat pagi",
"Irish": "Dia dhuit",
"Italian": "Buongiorno",
"Japanese": "お早う",
"Korean": "안녕하세요",
"Kazakh": "Kayırlı tan",
"Kurdish": "Beyanî baş",
"Lithuanian": "Labas rytas",
"Macedonian": "Добро утро",
"Malay": "Selamat pagi",
"Maltese": "Bonġu",
"Middle Egyptian Hieroglyphs": "𓄤 𓃀 𓂓 𓇳𓐅",
"Nepali": "subha prabhat",
"Norwegian": "God morgen",
"Odia": "ସୁପ୍ରଭାତ",
"Polish": "Dzień dobry",
"Portuguese": "Bom dia",
"Romanian": "Bună dimineaţa",
"Russian": "Доброе утро",
"Serbian": "Добро јутро",
"Spanish": "Buenos días",
"Sumerian": "𒄭𒌓",
"Swahili": "Habari ya asubuhi",
"Swedish": "God morgon",
"Tagalog": "Magandang umaga po",
"Taiwanese": "爻早",
"Tatar": "Xäyerle irtä",
"Telugu": "శుభోదయం",
"Thai": "สวัสดีครับ",
"Turkish": "Günaydın",
"Ukrainian": "Доброго ранку",
"Urdu": "صبح بخير",
"Uzbek": "Xayrli tong",
"Vietnamese": "Chào buổi sáng",
"Welsh": "Bore da",
"Latvian": "Labrīt",
"Valyrian": "Sȳz ñāqes"
}
@@ -0,0 +1,72 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import moment from 'moment';
import goodMorning from './locales/goodMorning.locales.json';
import goodAfternoon from './locales/goodAfternoon.locales.json';
import goodEvening from './locales/goodEvening.locales.json';
/**
* Validates that a date is a valid ISO string.
*
* @param date A date string
* @returns {bool} Whether the date is valid or not.
*/
export function isValidDate(date) {
return moment(date).isValid();
}
/**
* Validates that a date is a valid ISO string and a specific format.
*
* @param date A date string
* @param format A format string or an array of format strings to validate against.
* @returns {bool} Whether the date is valid or not according to the format.
*/
export function isValidDateAndFormat(date, format) {
return moment(date, format, true).isValid();
}
export function relativeTime(timestamp) {
return moment(timestamp).fromNow();
}
// Select a large random integer at startup, to prevent the greetings to change every time the user
// navigates.
const greetingRandomSeed = Math.floor(Math.random() * 1000000);
export function getTimeBasedGreeting() {
const random = array => array[greetingRandomSeed % array.length];
const currentHour = new Date(Date.now()).getHours();
if (currentHour >= 23) {
return {
language: 'Seriously',
greeting: 'Get some rest',
};
}
const timeOfDay = hour => {
if (hour < 12) return goodMorning;
if (hour < 17) return goodAfternoon;
return goodEvening;
};
const greetings = timeOfDay(currentHour);
const greetingsKey = random(Object.keys(greetings));
return {
language: greetingsKey,
greeting: greetings[greetingsKey],
};
}
@@ -0,0 +1,44 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { isValidDateAndFormat, getTimeBasedGreeting } from './timeUtil';
it('validates time format', () => {
const valid = isValidDateAndFormat(
'1970-01-01T00:00:00',
'YYYY-MM-DD[T]HH:mm:ss',
);
const invalid = isValidDateAndFormat(
'1970/01/01T00:00:00',
'YYYY-MM-DD[T]HH:mm:ss',
);
expect(valid).toBe(true);
expect(invalid).toBe(false);
});
it('has greeting and language', () => {
const greeting = getTimeBasedGreeting();
expect(greeting).toHaveProperty('greeting');
expect(greeting).toHaveProperty('language');
});
it('greets late at night', () => {
jest
.spyOn(global.Date, 'now')
.mockImplementationOnce(() => new Date('1970-01-01T23:00:00').valueOf());
const greeting = getTimeBasedGreeting();
expect(greeting.greeting).toBe('Get some rest');
});
+8 -7
View File
@@ -5,9 +5,14 @@
"types": "src/index.ts",
"license": "Apache-2.0",
"private": true,
"publishConfig": {
"access": "public",
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts"
},
"scripts": {
"start": "backstage-cli backend:dev",
"build": "tsc",
"build": "backstage-cli backend:build",
"lint": "backstage-cli lint",
"test": "backstage-cli test",
"prepack": "backstage-cli prepack",
@@ -28,13 +33,9 @@
},
"devDependencies": {
"@backstage/cli": "^0.1.1-alpha.8",
"jest-fetch-mock": "^3.0.3",
"tsc-watch": "^4.2.3"
"jest-fetch-mock": "^3.0.3"
},
"files": [
"dist"
],
"nodemonConfig": {
"watch": "./dist"
}
]
}
-15
View File
@@ -1,15 +0,0 @@
{
"include": ["src"],
"compilerOptions": {
"outDir": "dist",
"incremental": true,
"sourceMap": true,
"declaration": true,
"strict": true,
"target": "es2019",
"module": "commonjs",
"esModuleInterop": true,
"lib": ["es2019"],
"types": ["node", "jest", "webpack-env"]
}
}
+6 -1
View File
@@ -5,9 +5,14 @@
"types": "src/index.ts",
"license": "Apache-2.0",
"private": true,
"publishConfig": {
"access": "public",
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts"
},
"scripts": {
"build": "tsc",
"start": "backstage-cli backend:dev",
"build": "backstage-cli backend:build",
"lint": "backstage-cli lint",
"test": "backstage-cli test",
"prepack": "backstage-cli prepack",
-16
View File
@@ -1,16 +0,0 @@
{
"include": ["src"],
"compilerOptions": {
"outDir": "dist",
"incremental": true,
"sourceMap": true,
"declaration": true,
"strict": true,
"target": "es2019",
"module": "commonjs",
"esModuleInterop": true,
"allowJs": true,
"lib": ["es2019"],
"types": ["node", "jest", "webpack-env"]
}
}
@@ -19,19 +19,21 @@ import {
Lifecycle,
Content,
ContentHeader,
InfoCard,
Header,
Page,
pageTheme,
} from '@backstage/core';
import { Typography, Link, Button } from '@material-ui/core';
import { Link as RouterLink } from 'react-router-dom';
import TemplateCard from '../TemplateCard';
// TODO(blam): Connect to backend
const STATIC_DATA = [
{
id: 'react-ssr-template',
type: 'web-infra',
name: 'SSR React Website',
tags: ['Experimental'],
description:
'Next.js application skeleton for creating isomorphic web applications.',
ownerId: 'something',
@@ -68,15 +70,15 @@ const ScaffolderPage: React.FC<{}> = () => {
.
</Typography>
<div style={{ display: 'flex' }}>
{STATIC_DATA.map((item, ix) => {
{STATIC_DATA.map(item => {
return (
<InfoCard
<TemplateCard
key={item.id}
title={item.name}
deepLink={{ title: 'Create', link: '#' }}
key={ix}
>
<Typography paragraph>{item.description}</Typography>
</InfoCard>
type={item.type}
description={item.description}
tags={item.tags}
/>
);
})}
</div>
@@ -0,0 +1,84 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React, { FC } from 'react';
import {
Button,
Card,
Chip,
Grid,
Typography,
makeStyles,
} from '@material-ui/core';
const useStyles = makeStyles(theme => ({
header: {
color: theme.palette.common.white,
padding: theme.spacing(2, 2, 6),
backgroundImage:
'linear-gradient(-137deg, rgb(25, 230, 140) 0%, rgb(29, 127, 110) 100%)',
},
content: {
padding: theme.spacing(2),
},
description: {
height: 175,
overflow: 'hidden',
textOverflow: 'ellipsis',
},
footer: {
display: 'flex',
flexDirection: 'row-reverse',
},
}));
type TemplateCardProps = {
description: string;
tags: string[];
title: string;
type: string;
};
const TemplateCard: FC<TemplateCardProps> = ({
description,
tags,
title,
type,
}) => {
const classes = useStyles();
return (
<Grid item xs={12} sm={6} md={3}>
<Card>
<div className={classes.header}>
<Typography variant="subtitle2">{type}</Typography>
<Typography variant="h6">{title}</Typography>
</div>
<div className={classes.content}>
{tags?.map(tag => (
<Chip label={tag} />
))}
<Typography variant="body2" paragraph className={classes.description}>
{description}
</Typography>
<div className={classes.footer}>
<Button color="primary">Choose</Button>
</div>
</div>
</Card>
</Grid>
);
};
export default TemplateCard;
+8 -7
View File
@@ -5,9 +5,14 @@
"types": "src/index.ts",
"license": "Apache-2.0",
"private": true,
"publishConfig": {
"access": "public",
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts"
},
"scripts": {
"start": "backstage-cli backend:dev",
"build": "tsc",
"build": "backstage-cli backend:build",
"lint": "backstage-cli lint",
"test": "backstage-cli test",
"prepack": "backstage-cli prepack",
@@ -29,13 +34,9 @@
},
"devDependencies": {
"@backstage/cli": "^0.1.1-alpha.8",
"jest-fetch-mock": "^3.0.3",
"tsc-watch": "^4.2.3"
"jest-fetch-mock": "^3.0.3"
},
"files": [
"dist"
],
"nodemonConfig": {
"watch": "./dist"
}
]
}
-15
View File
@@ -1,15 +0,0 @@
{
"include": ["src"],
"compilerOptions": {
"outDir": "dist",
"incremental": true,
"sourceMap": true,
"declaration": true,
"strict": true,
"target": "es2019",
"module": "commonjs",
"esModuleInterop": true,
"lib": ["es2019"],
"types": ["node", "jest", "webpack-env"]
}
}
+3 -51
View File
@@ -6848,15 +6848,6 @@ cross-spawn@7.0.1:
shebang-command "^2.0.0"
which "^2.0.1"
cross-spawn@^5.1.0:
version "5.1.0"
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
integrity sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=
dependencies:
lru-cache "^4.0.1"
shebang-command "^1.2.0"
which "^1.2.9"
cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2:
version "7.0.3"
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
@@ -12555,14 +12546,6 @@ lowlight@~1.11.0:
fault "^1.0.2"
highlight.js "~9.13.0"
lru-cache@^4.0.1:
version "4.1.5"
resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==
dependencies:
pseudomap "^1.0.2"
yallist "^2.1.2"
lru-cache@^5.1.1:
version "5.1.1"
resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
@@ -13137,7 +13120,7 @@ moment@2.24.0:
resolved "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
moment@^2.25.3:
moment@^2.25.3, moment@^2.26.0:
version "2.26.0"
resolved "https://registry.npmjs.org/moment/-/moment-2.26.0.tgz#5e1f82c6bafca6e83e808b30c8705eed0dcbd39a"
integrity sha512-oIixUO+OamkUkwjhAVE18rAMfRJNsNe/Stid/gwHSOfHrOtw9EhAY2AHvdKZ/k/MggcYELFCJz/Sn2pL8b8JMw==
@@ -13330,11 +13313,6 @@ nocache@2.1.0:
resolved "https://registry.npmjs.org/nocache/-/nocache-2.1.0.tgz#120c9ffec43b5729b1d5de88cd71aa75a0ba491f"
integrity sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q==
node-cleanup@^2.1.2:
version "2.1.2"
resolved "https://registry.npmjs.org/node-cleanup/-/node-cleanup-2.1.2.tgz#7ac19abd297e09a7f72a71545d951b517e4dde2c"
integrity sha1-esGavSl+Caf3KnFUXZUbUX5N3iw=
node-dir@^0.1.10:
version "0.1.17"
resolved "https://registry.npmjs.org/node-dir/-/node-dir-0.1.17.tgz#5f5665d93351335caabef8f1c554516cf5f1e4e5"
@@ -15176,18 +15154,13 @@ prr@~1.0.1:
resolved "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476"
integrity sha1-0/wRS6BplaRexok/SEzrHXj19HY=
ps-tree@1.2.0, ps-tree@^1.2.0:
ps-tree@1.2.0:
version "1.2.0"
resolved "https://registry.npmjs.org/ps-tree/-/ps-tree-1.2.0.tgz#5e7425b89508736cdd4f2224d028f7bb3f722ebd"
integrity sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA==
dependencies:
event-stream "=3.3.4"
pseudomap@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM=
psl@^1.1.28:
version "1.8.0"
resolved "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24"
@@ -17430,11 +17403,6 @@ string-argv@0.3.1:
resolved "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da"
integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==
string-argv@^0.1.1:
version "0.1.2"
resolved "https://registry.npmjs.org/string-argv/-/string-argv-0.1.2.tgz#c5b7bc03fb2b11983ba3a72333dd0559e77e4738"
integrity sha512-mBqPGEOMNJKXRo7z0keX0wlAhbBAjilUdPW13nN0PecVryZxdHIeM7TqbsSUA7VYuS00HGC6mojP7DlQzfa9ZA==
string-hash@^1.1.1:
version "1.1.3"
resolved "https://registry.npmjs.org/string-hash/-/string-hash-1.1.3.tgz#e8aafc0ac1855b4666929ed7dd1275df5d6c811b"
@@ -18333,17 +18301,6 @@ ts-pnp@^1.1.2:
resolved "https://registry.npmjs.org/ts-pnp/-/ts-pnp-1.1.6.tgz#389a24396d425a0d3162e96d2b4638900fdc289a"
integrity sha512-CrG5GqAAzMT7144Cl+UIFP7mz/iIhiy+xQ6GGcnjTezhALT02uPMRw7tgDSESgB5MsfKt55+GPWw4ir1kVtMIQ==
tsc-watch@^4.2.3:
version "4.2.8"
resolved "https://registry.npmjs.org/tsc-watch/-/tsc-watch-4.2.8.tgz#cb8639bf507738dfa64590504f539a2f525d3a7b"
integrity sha512-EtWdmVZYFxTxSHqtmpowtvC/son28Hgl3qxYnD6sy+uGQXsWYDQxwmL8EneWca2kzAIYNZq3CGrUdK1jjbL4Vw==
dependencies:
cross-spawn "^5.1.0"
node-cleanup "^2.1.2"
ps-tree "^1.2.0"
string-argv "^0.1.1"
strip-ansi "^4.0.0"
tsconfig-paths@^3.9.0:
version "3.9.0"
resolved "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz#098547a6c4448807e8fcb8eae081064ee9a3c90b"
@@ -18462,7 +18419,7 @@ typedarray@^0.0.6:
resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
typescript@^3.9.2, typescript@^3.9.3:
typescript@^3.9.3:
version "3.9.5"
resolved "https://registry.npmjs.org/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36"
integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==
@@ -19510,11 +19467,6 @@ y18n@^4.0.0:
resolved "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==
yallist@^2.1.2:
version "2.1.2"
resolved "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=
yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3:
version "3.1.1"
resolved "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"