Skip to content

Commit

Permalink
use standard environments
Browse files Browse the repository at this point in the history
  • Loading branch information
wwelling committed Dec 6, 2021
1 parent c155532 commit 71f5b46
Show file tree
Hide file tree
Showing 30 changed files with 962 additions and 860 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
run: yarn run lint

- name: Run build
run: yarn run build:prod
run: yarn run build:ssr:ci

- name: Run specs (unit tests)
run: yarn run test:headless
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ npm-debug.log

/build/

/src/environments/environment.ts
/src/environments/environment.dev.ts
/src/environments/environment.prod.ts

/coverage

/dist/
Expand Down
50 changes: 49 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"extractCss": true,
Expand All @@ -88,6 +94,22 @@
"maximumError": "300kb"
}
]
},
"ci": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.ci.ts"
}
],
"optimization": true,
"outputHashing": "all",
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
Expand Down Expand Up @@ -139,6 +161,16 @@
}
],
"scripts": []
},
"configurations": {
"test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
]
}
}
},
"lint": {
Expand Down Expand Up @@ -183,7 +215,23 @@
"configurations": {
"production": {
"sourceMap": false,
"optimization": true
"optimization": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
"ci": {
"sourceMap": false,
"optimization": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.ci.ts"
}
]
}
}
},
Expand Down
6 changes: 0 additions & 6 deletions config/appConfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{
"ui": {
"ssl": false,
"host": "localhost",
"port": 4000,
"nameSpace": "/"
},
"rest": {
"ssl": true,
"host": "api7.dspace.org",
Expand Down
2 changes: 2 additions & 0 deletions cypress/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
screenshots/
videos/
5 changes: 0 additions & 5 deletions mock-nodemon.json

This file was deleted.

6 changes: 0 additions & 6 deletions nodemon.json

This file was deleted.

38 changes: 10 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,36 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
"config:dev": "ts-node --project ./tsconfig.ts-node.json scripts/set-env.ts --dev",
"config:prod": "ts-node --project ./tsconfig.ts-node.json scripts/set-env.ts --prod",
"config:test": "ts-node --project ./tsconfig.ts-node.json scripts/set-mock-env.ts",
"config:test:watch": "nodemon --config mock-nodemon.json",
"config:dev:watch": "nodemon",
"config:check:rest": "yarn run config:prod && ts-node --project ./tsconfig.ts-node.json scripts/test-rest.ts",
"config:dev:check:rest": "yarn run config:dev && ts-node --project ./tsconfig.ts-node.json scripts/test-rest.ts",
"prestart:dev": "yarn run config:dev",
"prebuild": "yarn run config:dev",
"pretest": "yarn run config:test",
"pretest:watch": "yarn run config:test",
"pretest:headless": "yarn run config:test",
"prebuild:prod": "yarn run config:prod",
"pree2e": "yarn run config:prod",
"test:rest": "ts-node --project ./tsconfig.ts-node.json scripts/test-rest.ts",
"start": "yarn run start:prod",
"serve": "ts-node --project ./tsconfig.ts-node.json scripts/serve.ts",
"start:dev": "npm-run-all --parallel config:dev:watch serve",
"start:dev": "yarn run serve",
"start:prod": "yarn run build:prod && yarn run serve:ssr",
"start:mirador:prod": "yarn run build:mirador && yarn run start:prod",
"analyze": "webpack-bundle-analyzer dist/browser/stats.json",
"build": "ng build",
"build:stats": "ng build --stats-json",
"build:prod": "yarn run build:ssr",
"build:ssr": "ng build --configuration production && ng run dspace-angular:server:production",
"test:watch": "npm-run-all --parallel config:test:watch test",
"test": "ng test --sourceMap=true --watch=true",
"test:headless": "ng test --watch=false --sourceMap=true --browsers=ChromeHeadless --code-coverage",
"build:ssr:ci": "ng build --configuration ci && ng run dspace-angular:server:ci",
"test": "ng test --sourceMap=true --watch=true --configuration test",
"test:headless": "ng test --sourceMap=true --watch=false --configuration test --browsers=ChromeHeadless --code-coverage",
"lint": "ng lint",
"lint-fix": "ng lint --fix=true",
"e2e": "ng e2e",
"serve:ssr": "node dist/server/main",
"clean:dev:config": "rimraf src/assets/appConfig.json",
"clean:coverage": "rimraf coverage",
"clean:dist": "rimraf dist",
"clean:doc": "rimraf doc",
"clean:log": "rimraf *.log*",
"clean:json": "rimraf *.records.json",
"clean:bld": "rimraf build",
"clean:node": "rimraf node_modules",
"clean:prod": "yarn run clean:coverage && yarn run clean:doc && yarn run clean:dist && yarn run clean:log && yarn run clean:json && yarn run clean:bld",
"clean": "yarn run clean:prod && yarn run clean:env && yarn run clean:node",
"clean:env": "rimraf src/environments/environment.ts",
"sync-i18n": "yarn run config:dev && ts-node --project ./tsconfig.ts-node.json scripts/sync-i18n-files.ts",
"clean:prod": "yarn run clean:dist && yarn run clean:log && yarn run clean:doc && yarn run clean:coverage && yarn run clean:json",
"clean": "yarn run clean:prod && yarn run clean:node && yarn run clean:dev:config",
"sync-i18n": "ts-node --project ./tsconfig.ts-node.json scripts/sync-i18n-files.ts",
"build:mirador": "webpack --config webpack/webpack.mirador.config.ts",
"merge-i18n": "yarn run config:dev && ts-node --project ./tsconfig.ts-node.json scripts/merge-i18n-files.ts",
"postinstall": "ngcc",
"merge-i18n": "ts-node --project ./tsconfig.ts-node.json scripts/merge-i18n-files.ts",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
},
Expand All @@ -74,7 +59,6 @@
"@angular/platform-browser-dynamic": "~11.2.14",
"@angular/platform-server": "~11.2.14",
"@angular/router": "~11.2.14",
"@angularclass/bootloader": "1.0.1",
"@kolkov/ngx-gallery": "^1.2.3",
"@ng-bootstrap/ng-bootstrap": "9.1.3",
"@ng-dynamic-forms/core": "^13.0.0",
Expand Down Expand Up @@ -178,8 +162,6 @@
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"karma-mocha-reporter": "2.2.5",
"nodemon": "^2.0.2",
"npm-run-all": "^4.1.5",
"optimize-css-assets-webpack-plugin": "^5.0.4",
"postcss-apply": "0.11.0",
"postcss-import": "^12.0.1",
Expand Down
11 changes: 8 additions & 3 deletions scripts/serve.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import * as child from 'child_process';

import { environment } from '../src/environments/environment';

import * as child from 'child_process';
// import { AppConfig } from '../src/config/app-config.interface';
// import { buildAppConfig } from '../src/config/config.server';

// const appConfig: AppConfig = buildAppConfig();

/**
* Calls `ng serve` with the following arguments configured for the UI in the environment file: host, port, nameSpace, ssl
* Calls `ng serve` with the following arguments configured for the UI in the environment: host, port, nameSpace, ssl
*/
child.spawn(
`ng serve --host ${environment.ui.host} --port ${environment.ui.port} --servePath ${environment.ui.nameSpace} --ssl ${environment.ui.ssl}`,
`ng serve --host ${environment.ui.host} --port ${environment.ui.port} --serve-path ${environment.ui.nameSpace} --ssl ${environment.ui.ssl}`,
{ stdio:'inherit', shell: true }
);
116 changes: 0 additions & 116 deletions scripts/set-env.ts

This file was deleted.

11 changes: 0 additions & 11 deletions scripts/set-mock-env.ts

This file was deleted.

8 changes: 7 additions & 1 deletion scripts/test-rest.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import * as http from 'http';
import * as https from 'https';

import { environment } from '../src/environments/environment';

// import { AppConfig } from '../src/config/app-config.interface';
// import { buildAppConfig } from '../src/config/config.server';

// const appConfig: AppConfig = buildAppConfig();

/**
* Script to test the connection with the configured REST API (in the 'rest' settings of your environment.*.ts)
*
* This script is useful to test for any Node.js connection issues with your REST API.
*
* Usage (see package.json): yarn test:rest-api
* Usage (see package.json): yarn test:rest
*/

// Get root URL of configured REST API
Expand Down
Loading

0 comments on commit 71f5b46

Please sign in to comment.