Angular
0. Introduction
Angular is a TypeScript-based open-source web application framework.
1. Reference
Version compatibility
https://angular.dev/reference/versions
Testing
https://angular.dev/guide/testing
2. Multiple versions of Node.js on Linux
See article: Node.js development
https://sites.google.com/site/pawneecity/node-js-development#h.jmr6jfkjwo6a
3. Copy index.html to dist
It's useful for having a redirection in AWS CloudFront for redirecting the user to the proper Angular application entry point if he just uses the domain name.
Eg: validationot
src/assets/index.hml
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="description" content="package.json postbuild copies it to the dist root">
<script type="text/javascript">
window.location.href ="/myapp_front/en/index.html"
</script>
</head>
<body>
</body>
</html>
package.json
Notice the dependency:
"cpx-fixed": "^1.6.0"
the copy command:
"copy:index": "cpx-fixed 'src/assets/index.html' 'dist/'"
and the package:
"package": "npm install && npm run build && npm run build:pl && npm run build:es",
{
"name": "myapp",
"version": "2.0.3",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"start:pl": "ng serve --configuration=pl",
"build:pl": "ng build --configuration=production-pl",
"start:es": "ng serve --configuration=es",
"build:es": "ng build --configuration=production-es",
"package": "npm install && npm run build && npm run build:pl && npm run build:es",
"postbuild": "npm run copy:index && node -p \"require('./package.json').version\" > dist/validaciotp_front/version",
"copy:index": "cpx-fixed 'src/assets/index.html' 'dist/'"
},
"private": true,
"dependencies": {
"@angular/animations": "~10.2.0",
"@angular/cdk": "^10.2.5",
"@angular/common": "~10.2.0",
"@angular/compiler": "~10.2.0",
"@angular/core": "~10.2.0",
"@angular/forms": "~10.2.0",
"@angular/localize": "^10.2.0",
"@angular/material": "^10.2.5",
"@angular/platform-browser": "~10.2.0",
"@angular/platform-browser-dynamic": "~10.2.0",
"@angular/router": "~10.2.0",
"export-to-csv": "^0.2.1",
"localize": "^0.4.7",
"rxjs": "~6.6.3",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.1002.0",
"@angular/cli": "~10.2.0",
"@angular/compiler-cli": "~10.2.0",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.12.47",
"cpx-fixed": "^1.6.0",
"codelyzer": "^6.0.1",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.3"
}
}
11. Update Angular version
For migrating an application from an Angular version to a newer one, follow the indications at:
https://update.angular.io/?l=3&v=7.0-14.0
21. Unit tests & End to end tests
Karma
Karma is a test runner for Angular applications. It is used to run Jasmine unit tests and E2E (end-to-end) tests.
Chrome headless
The CI/CD pipeline needs to have Chrome 59+ for Chrome headless test
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && sudo apt install ./google-chrome-stable_current_amd64.deb
Test execution (in headless mode)
ng test --no-watch --no-progress --browsers=ChromeHeadless