Local Setup
Prerequisites
Node |
12 — |
npm registry |
GitHub Packages access for |
Chrome |
Required by the Karma test runner |
npm registry authentication
@payability/pyb-ng2-api and @payability/pyb-ngx-components are published to
GitHub Packages. Create a personal access token with repo, write:packages and
read:packages, then add to ~/.npmrc:
//npm.pkg.github.com/:_authToken=YOUR_TOKEN
@payability:registry=https://npm.pkg.github.com/
|
This goes in your home |
Install
$ nvm use {node-version}
$ npm ci
npm ci is preferred over npm install — it honours package-lock.json exactly.
A postinstall hook installs the Husky git hooks.
Environment generation
src/environments/environment.ts and proxy.json are generated. Nothing runs
until you generate them.
$ export ENV_NAME=dev-1
$ npm run pre-build:proxy
ENV_NAME names the backend environment; dev-[1..10] and pnega (the default)
are the usual values. ENV_TYPE selects the domain and config profile:
|
|
|
The |
|
The |
What pre-build does
config/pre-build.js renders two templates with EJS:
|
→ |
|
→ |
It also:
-
stamps
versionfrompackage.jsonandbuildTimefromnew Date(), -
computes
gcias the first six digits of the SHA-1 ofENV_NAME, -
sets
isProductionwhenENV_NAMEisprodorstaging, -
derives
authTokenKeyasauth-<env>-supplier4(dev/localhost) orauth-supplier4-<timestamp hex>(prod).
|
Proxy mode swaps the config profile
|
|
Never edit |
Run
$ npm start
Serves on http://localhost:4200 with --proxy-config proxy.json.
Other run targets:
|
Exposes the server on the network ( |
|
Uses the checked-in |
|
Uses |
Makefile shortcuts
Makefile wraps the npm scripts and threads ENV_NAME / ENV_TYPE through.
$ make help # list targets and the current ENV_NAME / ENV_TYPE
$ make install
$ make prebuild # generate environment.ts + proxy.json
$ make start # prebuild, then serve
$ make start ENV_NAME=dev-1
$ make dev-host # serve on the network
$ make dev-direct # bake the absolute API URL in, no proxy
$ make build-prod
$ make lint / lint-fix / format
$ make test / test-ci / e2e
$ make i18n # extract translation keys
$ make clean # rm -rf dist
Defaults are ENV_NAME=pnega, ENV_TYPE=dev.
Proxy routes
config/proxy.template.json forwards:
|
|
|
|
|
|
|
|
|
|
|
|
All with secure: false and changeOrigin: true.
Memory settings
|
Every Angular CLI script in |
Local limitations
Amazon reconnect |
|
Segment |
|
Service worker |
Registered only when |
|
Active outside production, so mutations throw locally that would pass silently in prod. This is intended. |
Dev-only permissions |
|
PayShield |
The PayPal client id and plan ids are hardcoded, so a local checkout hits the real PayPal plans. |