From 258b21e334f1388430f9bf30634d8ef68ac89f5e Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Fri, 4 Sep 2020 12:38:23 +0200 Subject: [PATCH] remove env vars and use simple copy task to switch (#60) --- .env.dev | 2 - .env.rh-sso | 2 - Gruntfile.js | 34 +++++++++----- README.md | 12 ++++- package.json | 3 -- public/rh-sso-index.css | 10 ++++ public/rh-sso-logo.svg | 101 ++++++++++++++++++++++++++++++++++++++++ snowpack.config.js | 2 +- src/index.tsx | 4 -- yarn.lock | 10 +--- 10 files changed, 145 insertions(+), 35 deletions(-) delete mode 100644 .env.dev delete mode 100644 .env.rh-sso create mode 100644 public/rh-sso-index.css create mode 100644 public/rh-sso-logo.svg diff --git a/.env.dev b/.env.dev deleted file mode 100644 index 8c8558b43c..0000000000 --- a/.env.dev +++ /dev/null @@ -1,2 +0,0 @@ -BACKEND_URL=http://localhost:8180/auth/admin/ -SNOWPACK_PUBLIC_FAVICON=favicon.ico \ No newline at end of file diff --git a/.env.rh-sso b/.env.rh-sso deleted file mode 100644 index 6a65836aa2..0000000000 --- a/.env.rh-sso +++ /dev/null @@ -1,2 +0,0 @@ -BACKEND_URL=http://prod-url/auth/admin/realms/ -SNOWPACK_PUBLIC_FAVICON=rh-sso-favicon.ico \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index b918afe5fe..bfe01bbcfa 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,19 +1,29 @@ -module.exports = function (grunt) { +const path = require("path"); - grunt.loadNpmTasks('grunt-contrib-copy'); +module.exports = function (grunt) { + grunt.loadNpmTasks("grunt-contrib-copy"); grunt.initConfig({ // … copy: { - files: { - cwd: './node_modules/@patternfly/patternfly/assets/', - src: '**/*', - dest: 'public/assets/', - expand: true - } - } + main: { + cwd: "./node_modules/@patternfly/patternfly/assets/", + src: "**/*", + dest: "public/assets/", + expand: true, + }, + sso: { + expand: true, + cwd: "./public/", + src: "rh-sso-*", + dest: "public", + rename: function (dest, matchedSrcPath) { + return path.join(dest, matchedSrcPath.substring("rh-sso-".length)); + }, + }, + }, }); - grunt.registerTask('default', ['copy']); - -}; \ No newline at end of file + grunt.registerTask("default", ["copy:main"]); + grunt.registerTask("switch-rh-sso", ["copy:sso"]); +}; diff --git a/README.md b/README.md index de8a9c0a0b..6b38b564ff 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ For development on this project you will need a running Keycloak server listenin 1. Install dependecies and run: ```bash $> yarn - $> yarn start:dev + $> yarn start ``` ### Additionally there are some nice scripts to format and lint @@ -31,4 +31,12 @@ For development on this project you will need a running Keycloak server listenin ```bash $> yarn format $> yarn lint -``` \ No newline at end of file +``` + +To switch to a RH-SSO themed version of this console you can run: + +```bash +$> npx grunt switch-rh-sso +``` + +To switch back just do a `git checkout public` \ No newline at end of file diff --git a/package.json b/package.json index 337c7bf0d0..33842f7a3f 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,6 @@ "scripts": { "postinstall": "grunt", "start": "snowpack dev", - "start:dev": "env-cmd -f .env.dev yarn start", - "start:rh-sso": "env-cmd -f .env.rh-sso yarn start", "build": "snowpack build", "test": "jest", "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"", @@ -58,7 +56,6 @@ "babel-loader": "^8.1.0", "decompress": "^4.2.1", "decompress-targz": "^4.1.1", - "env-cmd": "^10.1.0", "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.3", "enzyme-to-json": "^3.5.0", diff --git a/public/rh-sso-index.css b/public/rh-sso-index.css new file mode 100644 index 0000000000..f0db426cc3 --- /dev/null +++ b/public/rh-sso-index.css @@ -0,0 +1,10 @@ +@import "@patternfly/patternfly/patternfly.min.css"; + +.pf-c-brand { + height: 16px; +} + +body { + --pf-global--primary-color--100: red; + --pf-global--active-color--400: darkred; +} diff --git a/public/rh-sso-logo.svg b/public/rh-sso-logo.svg new file mode 100644 index 0000000000..a908d8c006 --- /dev/null +++ b/public/rh-sso-logo.svg @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/snowpack.config.js b/snowpack.config.js index 34aacb114f..88d3ccdec7 100644 --- a/snowpack.config.js +++ b/snowpack.config.js @@ -1,7 +1,7 @@ module.exports = { extends: "@snowpack/app-scripts-react", proxy: { - "/admin": process.env.BACKEND_URL, + "/admin": "http://localhost:8180/auth/admin/", }, plugins: ["@snowpack/plugin-postcss", "@snowpack/plugin-webpack"], }; diff --git a/src/index.tsx b/src/index.tsx index 91c7ddf673..700274f5ee 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -23,7 +23,3 @@ init().then((keycloak) => { document.getElementById("app") ); }); - -(document.getElementById("favicon") as HTMLAnchorElement).href = `${ - import.meta.env.SNOWPACK_PUBLIC_FAVICON -}`; diff --git a/yarn.lock b/yarn.lock index 5a8958980b..e562b38cc0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6985,7 +6985,7 @@ commander@^2.11.0, commander@^2.19.0, commander@^2.20.0, commander@^2.8.1: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== -commander@^4.0.0, commander@^4.1.1: +commander@^4.0.1, commander@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== @@ -8272,14 +8272,6 @@ entities@^2.0.0: resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.3.tgz#5c487e5742ab93c15abb5da22759b8590ec03b7f" integrity sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ== -env-cmd@^10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/env-cmd/-/env-cmd-10.1.0.tgz#c7f5d3b550c9519f137fdac4dd8fb6866a8c8c4b" - integrity sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA== - dependencies: - commander "^4.0.0" - cross-spawn "^7.0.0" - enzyme-adapter-react-16@^1.15.3: version "1.15.3" resolved "https://registry.yarnpkg.com/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.15.3.tgz#90154055be3318d70a51df61ac89cfa22e3d5f60"