From 52d8b759d3e8ba93e1de577f7424d9653fae402e Mon Sep 17 00:00:00 2001 From: Alex Szczuczko Date: Fri, 6 Dec 2019 07:34:06 -0700 Subject: [PATCH] KEYCLOAK-11293 Update theme build for keycloak-preview `npm install` is changed to run at build time, removing the need for commiting the js modules, which are getting a bit silly in size with the introduction of account2. Appropriate changes to prod-arguments.json are included that should enable the product build to function properly. The community and developer builds will continue to work without the proxying PNC provides. This also changes the themes pom to work with more than one `package.json` file. The only other one at the moment is for the new account console / account2. The documentation file has been updated. Since we're building directly out of the source directories, it is possible in a local dev environment for unintended files (e.g. old compiled .js files), placed within src/main/resources/, to be included in the themes jar. This shouldn't be a problem for actual builds though, which use a fresh clone. Other small changes include refactoring the npm setup stuff to a global definition, and the introduction of some properties to avoid duplicating path definitions everywhere. This commit does not include the churn that would result from deleting the existing commited modules. --- .travis.yml | 1 + pom.xml | 2 +- prod-arguments.json | 12 +- themes/UPDATING-NODE-MODULES.md | 11 +- themes/pom.xml | 284 +++++++----------- .../account/resources/.gitignore | 3 +- .../account/resources/app/ContentPages.tsx | 4 +- .../keycloak/common/resources}/package.json | 0 8 files changed, 132 insertions(+), 185 deletions(-) rename themes/src/main/{ => resources/theme/keycloak/common/resources}/package.json (100%) diff --git a/.travis.yml b/.travis.yml index d2344f5f1cf..f135d9ca241 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: java cache: directories: - $HOME/.m2 + - $HOME/.npm before_cache: - rm -rf $HOME/.m2/repository/org/keycloak diff --git a/pom.xml b/pom.xml index f6e6010bb3a..1c69afccf4e 100755 --- a/pom.xml +++ b/pom.xml @@ -148,7 +148,7 @@ 2.3.7 1.2.1.Final 1.6.5 - 1.5 + 1.8.0 0.28.0 diff --git a/prod-arguments.json b/prod-arguments.json index 57207d39de8..4df5df377b0 100644 --- a/prod-arguments.json +++ b/prod-arguments.json @@ -2,7 +2,8 @@ "mvn": { "profiles": ["product", "!community", "jboss-release", "distribution-downloads"], "properties": { - "skipTests": "true" + "skipTests": "true", + "npmRegistryURL": "$NPM_REGISTRY_INSTANCE_URL" } }, "pme": { @@ -24,5 +25,12 @@ "dependencyOverride.org.jboss.logging:jboss-logging@org.keycloak:keycloak-as7-subsystem": "", "dependencyOverride.org.jboss.logging:jboss-logging@org.keycloak:keycloak-saml-as7-subsystem": "" } - } + }, + "prereqs": [ + "npm config set fetch-retry-mintimeout 60000", + "npm config set fetch-retry-maxtimeout 120000", + "npm config set fetch-retries 10", + "npm config set strict-ssl=false", + "npm config set cafile /tmp/indy-proxy-ca.crt" + ] } diff --git a/themes/UPDATING-NODE-MODULES.md b/themes/UPDATING-NODE-MODULES.md index 77b2b8912e8..3f880ca4ceb 100644 --- a/themes/UPDATING-NODE-MODULES.md +++ b/themes/UPDATING-NODE-MODULES.md @@ -5,15 +5,18 @@ Edit `src/main/package.json` to update the dependency versions. Then run the fol cd themes mvn clean install -Pnpm-update -The above will download the full NPM dependencies to `src/main/node_modules`. The main purpose of this directory is that we have the full source code available for dependencies in the future. This will be removed in the future as the internal build systems will take care of this. - -Next it will copy the dependencies to `src/main/resources/theme/keycloak/common/resources/node_modules`. Here it will use a filter while copying to remove files that we should not include in the distribution (for example documentation and tests for dependencies). +The above will download the full NPM dependencies to `src/main/resources/theme/keycloak/common/resources/node_modules`. The main purpose of this directory is that we have the full source code available for dependencies in the future. This will be removed in the future as the internal build systems will take care of this. Before committing changes review changes in `src/main/resources/theme/keycloak/common/resources/node_modules` making sure that it hasn't added new unused dependencies (transitive dependencies) and added any files that are not needed in the distribution (this is importat as the full node_modules downloaded are 176M while the filtered dependencies are 42M). ## Updating dependencies for the new account console -TBD +The node dependencies will be downloaded at build time, based on the content of `package-lock.json`. To update `package-lock.json`: + cd src/main/resources/theme/keycloak-preview/account/resources/ + npm install + git add package-lock.json + cd - +You should verify the new set of packages don't break anything before commiting the new `package-lock.json`. Do not commit the `node_modules` directory for the new account console. diff --git a/themes/pom.xml b/themes/pom.xml index 3c798f9e908..2a95668b040 100755 --- a/themes/pom.xml +++ b/themes/pom.xml @@ -11,6 +11,108 @@ keycloak-themes Keycloak Themes + jar + + + src/main/resources/theme/keycloak/common/resources + src/main/resources/theme/keycloak-preview/account/resources + ci --no-optional --ignore-scripts + + + + + + com.github.eirslett + frontend-maven-plugin + + + + setup-node + + install-node-and-npm + + initialize + + + + compile-account2 + + npm + + generate-resources + + ${dir.account2} + run build --scripts-prepend-node-path + + + + + npm-install-account2 + initialize + + npm + + + ${dir.account2} + ${args.npm.install} + + + + + v12.13.0 + 6.9.0 + ${project.basedir} + + + + + + + src/main/resources + + **/node_modules/**/node_modules/** + **/minimist/** + **/mkdirp/** + **/package.json + **/package-lock.json + **/bower.json + **/component.json + **/composer.json + **/npm-shrinkwrap.json + **/select2.jquery.json + **/*.markdown + **/*.swf + **/*.sh + **/.bin/** + **/bin/** + **/build/** + **/docs/** + **/demo/** + **/devtools/** + **/example/** + **/examples/** + **/grunt/** + **/less/** + **/sass/** + **/scss/** + **/jquery/src/** + **/angular-treeview/src/** + **/test/** + **/tests/** + **/_config.yml + **/api.md + **/AUTHORS.txt + **/CHANGELOG.md + **/CONTRIBUTING.md + **/HELP-US-OUT.txt + **/README.md + **/Gruntfile.js + **/Gemfile* + **/.* + + + + @@ -22,9 +124,6 @@ - - src/main/resources - src/main/resources-community @@ -40,93 +139,10 @@ - - src/main/resources - src/main/resources-product - - - maven-jar-plugin - - - **/keycloak-preview/** - - - - - - - - - account2 - - - - com.github.eirslett - frontend-maven-plugin - - - install node and npm - - install-node-and-npm - - generate-resources - - v8.9.4 - - - - npm install - - npm - - generate-resources - - install - - - - compile typescript - - npm - - compile - - run build - - - - npm remove dev dependencies production=true - - npm - - process-classes - - install --production=true --no-package-lock - - - - - src/main/resources/theme/keycloak-preview/account/resources - - - - maven-clean-plugin - - - - src/main/resources/theme/keycloak-preview/account/resources/node_modules - - - src/main/resources/theme/keycloak-preview/account/resources/node - - - - - @@ -134,19 +150,11 @@ npm-update - + com.github.eirslett frontend-maven-plugin - 1.8.0 - - install-node-and-npm - generate-resources - - install-node-and-npm - - npm-install generate-resources @@ -154,15 +162,11 @@ npm + ${dir.common} install -P -E --no-optional --ignore-scripts --no-bin-links --no-shrinkwrap --no-package-lock - - v12.13.0 - 6.9.0 - src/main/resources - @@ -177,10 +181,7 @@ - src/main/resources/node_modules - - - src/main/resources/theme/keycloak/common/resources/node_modules + ${dir.common}/node_modules @@ -194,90 +195,25 @@ - src/main/node_modules/angular-translate/node_modules/ + ${dir.common}/node_modules/angular-translate/node_modules/ - src/main/node_modules/patternfly/node_modules/ + ${dir.common}/node_modules/patternfly/node_modules/ - src/main/node_modules/rcue/node_modules/ + ${dir.common}/node_modules/rcue/node_modules/ - src/main/node_modules/minimist + ${dir.common}/node_modules/minimist - src/main/node_modules/mkdirp + ${dir.common}/node_modules/mkdirp - - - maven-resources-plugin - 3.0.2 - - - copy-resources - generate-resources - - copy-resources - - - - src/main/resources/theme/keycloak/common/resources/node_modules - - - src/main/node_modules - - **/*.json - **/*.json - **/*.markdown - **/*.swf - **/*.sh - **/.bin/** - **/bin/** - **/build/** - **/docs/** - **/demo/** - **/devtools/** - **/example/** - **/examples/** - **/grunt/** - **/less/** - **/node_modules/** - **/sass/** - **/scss/** - **/src/** - **/test/** - **/tests/** - **/_config.yml - **/api.md - **/AUTHORS.txt - **/CHANGELOG.md - **/CONTRIBUTING.md - **/HELP-US-OUT.txt - **/README.md - **/Gruntfile.js - **/Gemfile* - **/index.js - **/.* - - - - src/main/node_modules - - angular-ui-select2/src/select2.js - filesaver/src/Filesaver.js - filesaver/src/changename.js - - - - - - - diff --git a/themes/src/main/resources/theme/keycloak-preview/account/resources/.gitignore b/themes/src/main/resources/theme/keycloak-preview/account/resources/.gitignore index ab55afc3d4a..054eb7141ac 100644 --- a/themes/src/main/resources/theme/keycloak-preview/account/resources/.gitignore +++ b/themes/src/main/resources/theme/keycloak-preview/account/resources/.gitignore @@ -8,9 +8,8 @@ keycloak.json # ignore log files *.log -# ignore libraries (for now?) +# Do not commit, installed at compile time node_modules -node # Don't ignore these !keycloak.js diff --git a/themes/src/main/resources/theme/keycloak-preview/account/resources/app/ContentPages.tsx b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/ContentPages.tsx index b31bd92e8ba..8c22abfde11 100644 --- a/themes/src/main/resources/theme/keycloak-preview/account/resources/app/ContentPages.tsx +++ b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/ContentPages.tsx @@ -78,7 +78,7 @@ function createNavItems(activePage: PageDef, contentParam: ContentItem[], groupN if (typeof content === 'undefined') return (); const links: React.ReactElement[] = contentParam.map((item: ContentItem) => { - const navLinkId: string = `nav-link-${item.id}`; + const navLinkId = `nav-link-${item.id}`; if (isExpansion(item)) { return ); -} \ No newline at end of file +} diff --git a/themes/src/main/package.json b/themes/src/main/resources/theme/keycloak/common/resources/package.json similarity index 100% rename from themes/src/main/package.json rename to themes/src/main/resources/theme/keycloak/common/resources/package.json