Skip to content

Commit

Permalink
Weaver webpack upgrade (#436) (#440)
Browse files Browse the repository at this point in the history
* Error 500 issue resolved for Discovery View click

* Code re-implemented and clean up as per PR review suggestion

* weaver webpack upgrade

mirador update pending

* correct karma conf

* update package.json

* add badges to readme

* passing tests excluding controller tests

* disable lighthouse in workflow

* bundle mirador

* fix broken tests

* remove extra newlines

* remove commented out badges for now

* Relocate files and ensure usable permissions.

* fix mirador bundle build

Co-authored-by: Rincy Mathew <[email protected]>
Co-authored-by: Kevin Day <[email protected]>
Co-authored-by: Kevin Day <[email protected]>

Co-authored-by: Rincy Mathew <[email protected]>
Co-authored-by: Kevin Day <[email protected]>
Co-authored-by: Kevin Day <[email protected]>
  • Loading branch information
4 people authored Aug 5, 2022
1 parent 5805780 commit 43e01a9
Show file tree
Hide file tree
Showing 77 changed files with 1,376 additions and 834 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
src/main/webapp/app/node_modules
61 changes: 47 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,90 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: "Checkout Repository"
uses: actions/checkout@v3
with:
path: repo

- name: "Checkout Weaver-UI-Core"
uses: actions/checkout@v3
with:
repository: TAMULib/Weaver-UI-Core
path: weaver-ui
ref: 2.x-staging

- name: "Run Weaver-UI-Core Docker Compose Registry Image"
run: docker-compose -f $GITHUB_WORKSPACE/weaver-ui/docker-compose.yml up -d registry

- name: "Publish Weaver-UI-Core (@wvr/core)"
run: |
cd $GITHUB_WORKSPACE/weaver-ui
npm run publish:local
- name: "Install Chrome Drivers"
run: sudo apt-get install xvfb

- name: "Node Cache"
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-cache-node-${{ hashFiles('**/package.json', '**/package-lock.json') }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json', '**/package-lock.json') }}

- name: "Node Modules Cache"
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-cache-node_modules-${{ hashFiles('**/package.json', '**/package-lock.json') }}
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package.json', '**/package-lock.json') }}

- name: "Maven Cache"
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-cache-maven-${{ hashFiles('**/pom.xml') }}
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

- name: "Setup Node"
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16

- name: "Setup Java"
uses: actions/setup-java@v1
with:
java-version: 11

- name: "Maven and Node Tests"
- name: "Maven Tests"
env:
NPM_CONFIG_REGISTRY: http://localhost:4873
run: |
npm i
cd $GITHUB_WORKSPACE/repo
mvn clean test jacoco:report coveralls:report -DdryRun=true -DtestClient
- name: "Combine Coverage"
run: jq 'reduce inputs as $i (.; .source_files += $i.source_files)' target/coveralls.json src/main/webapp/coverage/coveralls.json > coveralls.json
run: |
cd $GITHUB_WORKSPACE/repo
cat coverage/lcov.info | node node_modules/coveralls/bin/coveralls.js -s > coverage/coveralls.json
jq 'reduce inputs as $i (.; .source_files += $i.source_files)' target/coveralls.json coverage/coveralls.json > coveralls.json
- name: "Coverage Report"
uses: MikeEdgar/github-action@raw_coverage_file
with:
github-token: ${{ secrets.github_token }}
path-to-file: './coveralls.json'
path-to-file: repo/coveralls.json
coverage-format: raw

# - name: "Lighthouse Report"
# env:
# LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
# run: |
# cd $GITHUB_WORKSPACE/repo
# xvfb-run --auto-servernum npm run test:audit

- name: "Deploy GH-Pages"
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
uses: JamesIves/[email protected]
with:
github_token: ${{ secrets.github_token }}
branch: gh-pages
folder: target/generated-docs
folder: repo/target/gh-pages
clean: true
single_commit: true
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ logs/
.DS_Store
package-lock.json

src/main/webapp/app/resources/js/*
.env

.wvr/tmp/
dist/
coverage/
114 changes: 114 additions & 0 deletions .wvr/build-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
const config = {
path: './dist',

// webpack dev server public path
publicPath: '/sage',

terserOptions: {
ecma: 5,
format: {},
parse: {},
compress: {
unused: false,
},
mangle: false,
module: false
},

copy: [
{
from: './node_modules/@wvr/core/app/resources/images',
to: './node_modules/@wvr/core/app/resources/images'
},
{
from: './node_modules/@wvr/core/app/views',
to: './node_modules/@wvr/core/app/views'
},
{
from: './build/appConfig.js.template',
to: './appConfig.js',
transform(content) {
return content
.toString()
.replace('${AUTH_STRATEGY}', 'weaverAuth')
.replace('${AUTH_SERVICE_URL}', 'https://labs.library.tamu.edu/authfix')
.replace('${STOMP_DEBUG}', 'false')
.replace('${AVALON_URL}', 'avalon-pre.library.tamu.edu:443');
},
},
],
entry: {
mirador: [
'./src/main/webapp/build-js/TAMUMirador.src.js'
],
app: [
'./node_modules/jquery/dist/jquery.js',
'./node_modules/bootstrap/dist/js/bootstrap.js',
'./node_modules/sockjs-client/dist/sockjs.js',
'./node_modules/stompjs/lib/stomp.js',
'./node_modules/angular/angular.js',
'./node_modules/angular-route/angular-route.js',
'./node_modules/angular-loader/angular-loader.js',
'./node_modules/angular-sanitize/angular-sanitize.js',
'./node_modules/angular-messages/angular-messages.js',
'./node_modules/ng-file-upload/dist/ng-file-upload-shim.js',
'./node_modules/ng-file-upload/dist/ng-file-upload.js',
'./node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js',
'./node_modules/ng-table/bundles/ng-table.js',
'./node_modules/openseadragon/build/openseadragon/openseadragon.js',
'./node_modules/ng-openseadragon/build/angular-openseadragon.js',
'./node_modules/@wvr/core/app/config/coreConfig.js',
'./node_modules/@wvr/core/app/components/version/version.js',
'./node_modules/@wvr/core/app/components/version/version-directive.js',
'./node_modules/@wvr/core/app/components/version/interpolate-filter.js',
'./src/main/webapp/app/config/apiMapping.js',
'./node_modules/@wvr/core/app/core.js',
'./node_modules/@wvr/core/app/setup.js',
'./node_modules/@wvr/core/app/config/coreRuntime.js',
'./node_modules/@wvr/core/app/config/coreAngularConfig.js',
'./node_modules/@wvr/core/app/config/logging.js',
'./node_modules/@wvr/core/app/constants/apiResponseActions.js',
'./node_modules/@wvr/core/app/constants/httpMethodVerbs.js',
'./node_modules/@wvr/core/app/directives/headerDirective.js',
'./node_modules/@wvr/core/app/directives/footerDirective.js',
'./node_modules/@wvr/core/app/directives/userDirective.js',
'./node_modules/@wvr/core/app/directives/modalDirective.js',
'./node_modules/@wvr/core/app/directives/alertDirective.js',
'./node_modules/@wvr/core/app/directives/accordionDirective.js',
'./node_modules/@wvr/core/app/directives/tabsDirective.js',
'./node_modules/@wvr/core/app/directives/tooltipDirective.js',
'./node_modules/@wvr/core/app/directives/validationMessageDirective.js',
'./node_modules/@wvr/core/app/directives/validatedInputDirective.js',
'./node_modules/@wvr/core/app/directives/validatedSelectDirective.js',
'./node_modules/@wvr/core/app/directives/validatedTextAreaDirective.js',
'./node_modules/@wvr/core/app/services/accessControlService.js',
'./node_modules/@wvr/core/app/services/wsService.js',
'./node_modules/@wvr/core/app/services/wsApi.js',
'./node_modules/@wvr/core/app/services/restApi.js',
'./node_modules/@wvr/core/app/services/fileService.js',
'./node_modules/@wvr/core/app/services/authService.js',
'./node_modules/@wvr/core/app/services/storageService.js',
'./node_modules/@wvr/core/app/services/utilityService.js',
'./node_modules/@wvr/core/app/services/alertService.js',
'./node_modules/@wvr/core/app/services/validationStore.js',
'./node_modules/@wvr/core/app/services/userService.js',
'./node_modules/@wvr/core/app/services/modalService.js',
'./node_modules/@wvr/core/app/services/modelCache.js',
'./node_modules/@wvr/core/app/services/modelUpdateService.js',
'./node_modules/@wvr/core/app/repo/abstractRepo.js',
'./node_modules/@wvr/core/app/model/abstractModel.js',
'./node_modules/@wvr/core/app/model/assumedControl.js',
'./node_modules/@wvr/core/app/model/user.js',
'./node_modules/@wvr/core/app/controllers/abstractController.js',
'./node_modules/@wvr/core/app/controllers/coreAdminController.js',
'./node_modules/@wvr/core/app/controllers/authenticationController.js',
'./node_modules/@wvr/core/app/controllers/loginController.js',
'./node_modules/@wvr/core/app/controllers/registrationController.js',
'./node_modules/@wvr/core/app/controllers/userController.js',
'./node_modules/@wvr/core/app/controllers/errorPageController.js',
'./src/main/webapp/app/**/*(*.js)'
],
}
}

module.exports.config = config;
30 changes: 24 additions & 6 deletions DEPLOYING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
The DEPLOYING documentation is currently a work in progress.

### Development with Weaver

* Clone [Weaver-UI-Core]([email protected]:TAMULib/Weaver-UI-Core.git)
* Start docker compose within Weaver-UI-Core directory.

```sh
docker-compose up
```

* Copy the `example.env` file and call it `.env`. These are build args and container environment variables used in docker-compose.yml.
* Change variables as needed.
* Run `docker-compose` commands.

```sh
docker-compose build --no-cache
docker-compose up
```

### AUTHORIZATION

By default, SAGE is configured to support email based registration and authorization with password ('emailRegistration'). There is generally no need to change this.
Expand All @@ -10,7 +28,7 @@ SAGE can also be configured to use Weaver Authentication ('weaverAuth'), an exte

The SAGE UI's appConfig object has an 'authStrategies' property that accepts a list of strings representing the active auth strategies:

https://github.com/TAMULib/SAGE/blob/master/src/main/webapp/app/config/appConfig.js#L8
https://github.com/TAMULib/SAGE/blob/master/build/appConfig.js.template#L8

The SAGE UI displays different login prompts and exhibits certain behaviors based on the authStrategies property:

Expand All @@ -22,7 +40,7 @@ When emailRegistration is active, the 'appLoginController', an extension of Weav

If you are using an auth service other than SAGE's built in service, you will need to provide its url using the 'authService' property, also part of the appConfig object:

https://github.com/TAMULib/SAGE/blob/master/src/main/webapp/app/config/appConfig.js#L10
https://github.com/TAMULib/SAGE/blob/master/build/appConfig.js.template#L10

It's most common to choose one authentication strategy, but it is technically possible to support two or more strategies simultaneously by listing each entry separated by commas.

Expand All @@ -31,19 +49,19 @@ It's most common to choose one authentication strategy, but it is technically po

The SAGE service can also be run with a development only profile that provides mock auth credentials.

This is activated by choosing 'mock-token-provider' as the active profile in application.properties:
This is activated by choosing 'mock-token-provider' as the active profile in application.yml:

https://github.com/TAMULib/SAGE/blob/master/src/main/resources/application.properties
https://github.com/TAMULib/SAGE/blob/master/src/main/resources/application.yml

And pointing the SAGE UI to the mock auth API by setting the appConfig object's 'authService' property to:

window.location.protocol + '//' + window.location.host + window.location.base + '/mock/auth'

https://github.com/TAMULib/SAGE/blob/master/src/main/webapp/app/config/appConfig.js
https://github.com/TAMULib/SAGE/blob/master/build/appConfig.js.template

The authorization level of the mock user is determined by the 'mockRole' property, also on the appConfig object:

https://github.com/TAMULib/SAGE/blob/master/src/main/webapp/app/config/appConfig.js
https://github.com/TAMULib/SAGE/blob/master/build/appConfig.js.template


### CUSTOMIZING AUTH STRATEGIES
Expand Down
Loading

0 comments on commit 43e01a9

Please sign in to comment.