From 759c9a24fe3863dd1c9d7658ce115d484c303d31 Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Wed, 10 Aug 2022 11:23:31 +0200 Subject: [PATCH] Add a common demo config for package demos Centralize the server config in one place, so it can easily be changed in one file for all package demos. This just adds it for the app-shell, for starters. --- demo.common.config.js | 7 +++++ packages/app-shell/assets/index.html | 27 ------------------- packages/app-shell/assets/index.html.ejs | 33 ++++++++++++++++++++++++ packages/app-shell/rollup.config.js | 32 ++++++++++++++++++++--- 4 files changed, 68 insertions(+), 31 deletions(-) create mode 100644 demo.common.config.js delete mode 100644 packages/app-shell/assets/index.html create mode 100644 packages/app-shell/assets/index.html.ejs diff --git a/demo.common.config.js b/demo.common.config.js new file mode 100644 index 00000000..39ae08bd --- /dev/null +++ b/demo.common.config.js @@ -0,0 +1,7 @@ +export default { + basePath: '/dist/', + entryPointURL: 'http://127.0.0.1:8000', + keyCloakBaseURL: 'https://auth-dev.tugraz.at/auth', + keyCloakRealm: 'tugraz-vpu', + keyCloakClientId: 'auth-dev-mw-frontend-local', +} diff --git a/packages/app-shell/assets/index.html b/packages/app-shell/assets/index.html deleted file mode 100644 index f88f99ea..00000000 --- a/packages/app-shell/assets/index.html +++ /dev/null @@ -1,27 +0,0 @@ -<!doctype html> -<html> -<head> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - - <style> - :root { - font-family: sans-serif; - font-weight: 300; - font-size: 11pt; - } - - body { - margin: 0; - } - </style> - - <script type="module" src="/dbp-app-shell.js"></script> -</head> - -<body> - -<dbp-app-shell auth requested-login-status entry-point-url="http://127.0.0.1:8000" keycloak-config='{"url": "https://auth-dev.tugraz.at/auth", "realm": "tugraz-vpu", "clientId": "auth-dev-mw-frontend-local", "silentCheckSsoRedirectUri": "/silent-check-sso.html"}' src="/example.topic.metadata.json"></dbp-app-shell> - -</body> -</html> \ No newline at end of file diff --git a/packages/app-shell/assets/index.html.ejs b/packages/app-shell/assets/index.html.ejs new file mode 100644 index 00000000..7eb678f4 --- /dev/null +++ b/packages/app-shell/assets/index.html.ejs @@ -0,0 +1,33 @@ +<!doctype html> +<html> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + + <style> + :root { + font-family: sans-serif; + font-weight: 300; + font-size: 11pt; + } + + body { + margin: 0; + } + </style> + + <script type="module" src="<%= getUrl(name + '.js') %>"></script> +</head> + +<body> + +<dbp-app-shell + auth + requested-login-status + entry-point-url="<%= entryPointURL %>" + keycloak-config='{"url": "<%= keyCloakBaseURL %>", "realm": "<%= keyCloakRealm %>", "clientId": "<%= keyCloakClientId %>", "silentCheckSsoRedirectUri": "<%= getUrl('silent-check-sso.html') %>"}' + src="<%= getUrl('example.topic.metadata.json') %>"> +</dbp-app-shell> + +</body> +</html> diff --git a/packages/app-shell/rollup.config.js b/packages/app-shell/rollup.config.js index 9eedee2b..92f10ff6 100644 --- a/packages/app-shell/rollup.config.js +++ b/packages/app-shell/rollup.config.js @@ -1,20 +1,28 @@ import glob from 'glob'; +import url from 'url'; import resolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import copy from 'rollup-plugin-copy'; import serve from 'rollup-plugin-serve'; import del from 'rollup-plugin-delete'; import json from '@rollup/plugin-json'; +import emitEJS from 'rollup-plugin-emit-ejs'; import {getPackagePath, getDistPath} from '../../rollup.utils.js'; +import config from '../../demo.common.config.js'; const build = typeof process.env.BUILD !== 'undefined' ? process.env.BUILD : 'local'; console.log('build: ' + build); +const pkg = require('./package.json'); +const basePath = '/dist/'; +const appName = 'dbp-app-shell'; + export default (async () => { + let privatePath = await getDistPath(pkg.name); return { input: build != 'test' - ? ['src/dbp-app-shell.js', 'src/dbp-activity-example.js'] + ? ['src/' + appName + '.js', 'src/dbp-activity-example.js'] : glob.sync('test/**/*.js'), output: { dir: 'dist', @@ -27,13 +35,29 @@ export default (async () => { del({ targets: 'dist/*', }), + emitEJS({ + src: 'assets', + include: ['**/*.ejs', '**/.*.ejs'], + data: { + getUrl: (p) => { + return url.resolve(basePath, p); + }, + getPrivateUrl: (p) => { + return url.resolve(`${basePath}${privatePath}/`, p); + }, + name: appName, + entryPointURL: config.entryPointURL, + keyCloakBaseURL: config.keyCloakBaseURL, + keyCloakRealm: config.keyCloakRealm, + keyCloakClientId: config.keyCloakClientId, + }, + }), resolve(), commonjs(), json(), copy({ targets: [ {src: 'assets/silent-check-sso.html', dest: 'dist'}, - {src: 'assets/index.html', dest: 'dist'}, {src: 'assets/*.json', dest: 'dist'}, { src: await getPackagePath('@dbp-toolkit/common', 'assets/icons/*.svg'), @@ -43,8 +67,8 @@ export default (async () => { }), process.env.ROLLUP_WATCH === 'true' ? serve({ - contentBase: 'dist', - historyApiFallback: '/index.html', + contentBase: '.', + historyApiFallback: basePath + 'index.html', host: '127.0.0.1', port: 8002, }) -- GitLab