This repo is intended to allow spooling up Angular projects in a monorepo rapidly, with a minimum of configuration.
- Angular 18 (with Node 20)
- Parallel server/client execution
- Bare-bones api proxy to the back-end *
- SASS boilerplate included
- Frontend environment detection/switching *
- Auto-unsub from subscriptions and component variables
- Heroku deployment
- Google Analytics
- Cookie API
- Service worker to persist app and manage versions *
- Hot module replacement for faster dev iteration
- Typescript with node for back-end
- Client & Server unit testing via jasmine
- Benchmark memory usage and response times (throttled for mobile) in tests
- Internationalization (i18n) with Transloco
- IndexedDB for offline storage *
- e2e testing with TestCafe + snapshots
- Feature flags *
- CI/CD (github actions, sonar)
- Hotjar script for user behavior analysis
(* indicates a feature that’s visible in the sample app)
- public api with GraphQL *
- DB-agnostic query layer
- Elf state management *
- Immutable.js to minimize mutation
- Websockets to reconcile disparities between server and local data *
- Ionic & Electron integration
- Auth-agnostic (or maybe just Firebase) user management (emails and password resetting and deliverability) *
Install node 20.16.0
Recommended to install NVM to manage node versions.
Install NPM 10.8.1 (should be bundled with node).
Install Angular CLI to allow executing commands: npm i -g @angular/cli
From the root, run npm ci
Create your .env
file from the .env.example
and never commit sensitive information like API keys or passwords or usernames or email addresses
Develop against branches from dev
feature branch using prefix feature/
. main
is for production releases, staging
is to test prod.
In the project directory, you can run:
Runs the front- and back-end concurrently. See above.
This is the preferred method of running a local
Runs only the front-end of the app (on port 4200) in development mode.
Open http://localhost:4200 to view it in the browser.
The page will reload if you make edits.
Runs only the back-end of the app (on port 4201) in development mode.
Open http://localhost:4201/api to view it in the browser.
This will display the API responses.
- from root, run
npm test
for full test suite, below (best to ensure green 100% coverage before any PRs todev
)
- from root, run
npm run test-translation
to uncover any gaps in translation files, relative to schema (will not detect completely missing schema keys; refer to browser errors for that)
- from root, run
npm run test-server
andnpm run test-client
to execute each unit test suite independently
- from root, run
npm run test-e2e
Runs e2e tests and takes new "tested" screenshots.
Run the Testcafe command with more parameters, since with this one we're taking screenshots and prepping to compare them.
-
from root, run
npm run accept <directory>
Accept all screenshot diffs and overwrite accepted comparisons. Optional argument is a directory to traverse, for targeting specific test cases. -
from
tests/e2e
, runnode test_runner accepted
Runs e2e tests and takes the base screenshots if they don't exist. (will overwrite existing screenshots) -
from
tests/e2e
, runnpx testcafe-blink-diff tests/e2e/screenshots --compare accepted:tested --open --threshold 0.005
The CLI command to compare accepted:tested screenshots for differences. If a test case's screenshots have not been created, this will fail when looking for the "accepted.png" The report will be in generated/index.html.
Install Docker from website (not homebrew).
from tests
, create docker instance with docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest
Navigate to SonarQube Server instance
- Log in to your SonarQube server as an administrator.
- Go to the Security page (usually located in the top-right corner of the page).
- Click on My Account.
- Scroll down to the Security section.
- Click on Generate Tokens.
- Enter a name for the token (e.g., "My Token").
- Click Generate.
- add token to .env file
Download SonarScanner and run from project root: npm run sonar
- mac (requires homebrew):
brew tap heroku/brew && brew install heroku
- linux:
sudo snap install --classic heroku
heroku git:remote -a <APP_NAME>-dev
git remote rename heroku dev
heroku git:remote -a <APP_NAME>-staging
git remote rename heroku staging
heroku git:remote -a <APP_NAME>
git remote rename heroku production
git push dev dev:main
from staging branch:
git push staging staging:main
from main branch:
git push production main:main