Skip to content

Repository: digital-development

This repository contains frontend applications for Kalmar Energi.

It uses NX to handle the monorepo setup.

Read more in the getting started documentation

Or the NX blog

Use the NX Playbook

Or follow the NX youtube channel

To install development dependencies run:

Terminal window
npm install

Enable “short/named imports” in VS code

Section titled “Enable “short/named imports” in VS code”

Add this to user settings.json:

Terminal window
"typescript.preferences.importModuleSpecifier": "shortest",
"javascript.preferences.importModuleSpecifier": "shortest",

To start a development server for any given angular application run:

Terminal window
npx nx serve [app-name]

Ex:

Terminal window
npx nx serve outage

or

Terminal window
npx nx run outage:serve:development

To start a development server for multiple applications at once, run:

Terminal window
npx nx run-many --target=serve --projects=[app-name],[app-name]

Ex:

Terminal window
npx nx run-many --target=serve --projects=device,outage

Its recommended to install the official nx plugin “NX Console”. This plugin provides generators and commands to make it easier to work with NX.

The Angular Language Service plugin helps with code completion while writing angular code.

ESLint provides feedback for when ESLint rules are not followed.

To run build command against a given app run:

Terminal window
npx nx run outage:build:production

To run lint command against a given app run:

Terminal window
npx nx run outage:lint

or

Terminal window
npx nx run outage:lint --fix

Use the --dry-run flag to see what will be generated without actually running the command.

To generate a new library run

Terminal window
npx nx g @nx/angular:library shared-ui --tags=shared-ui
npx nx g @nx/angular:library features --tags=features
npx nx g @nx/angular:library operators --tags=operators
npx nx g @nx/angular:library models --tags=models

Generate component inside shared-ui

Terminal window
npx nx g @nx/angular:component header --project=shared-ui --export
npx nx g @nx/angular:component footer --project=shared-ui --export --standalone
npx nx g @nx/angular:component alert --project=shared-ui --export --standalone
npx nx g @nx/angular:component table --project=shared-ui --export --standalone --inline-style --inline-template
npx nx g @nx/angular:component dialog --project=shared-ui --export --standalone --inline-style --inline-template

To generate a standalone component inside the features library

Terminal window
npx nx g @nx/angular:component not-found --project=features --standalone --export

This component can later be imported like:

Terminal window
import { NotFoundComponent } from "@portal/features";

or

Terminal window
loadComponent: () =>
import("@portal/features").then((m) => m.NotFoundComponent),

Generate a new feature

Terminal window
npx nx g @nx/angular:module not-found --project=features
npx nx g @nx/angular:component not-found --project=features --module=not-found --export
npx nx g @nx/angular:component not-found --project=features --standalone

View interactive project graph

Terminal window
npx nx graph

see what’s been affected by changes

Terminal window
npx nx affected:graph --base=master --head=HEAD

run tests for current changes

Terminal window
npx nx affected:test

run e2e tests for current changes

Terminal window
npx nx affected:e2e

To run i18n command against a given app run:

Terminal window
npx nx run outage:extract-i18n --format=xlf2 --output-path apps/outage/src/locale

or

Terminal window
npm run outage:extract-locale

To enable post build command the nx command needs to bee triggered through npm run. So to make sure localization index.html is copied to the dist folder, in CI/CD run the following:

Terminal window
npm run outage:build:production
Terminal window
npx nx clear-cache

To upgrade all dependencies to latest minor version run:

Terminal window
npx npm-check-updates --upgrade --target "minor"

To update all angular related dependencies to latest available minor/patch version run:

Terminal window
npx npm-check-updates --upgrade --target "minor" --filter "/@angular.*/"

To update all typescript/eslint related dependencies to latest available minor/patch version run:

Terminal window
npx npm-check-updates --upgrade --target "minor" --filter "@typescript-eslint/*"

Sort all dependencies by running:

Terminal window
npx sort-package-json

The following dependencies are installed from static files in the vendor folder:

xlsx

SheetJS are currently (or permanently) uploading new versions via their own CDN. See https://git.sheetjs.com/sheetjs/sheetjs/issues/2667

Because of this, the package can not be installed via npm anymore. To not depend on SheetJS CDN being online during npm installs, the static file is saved as a vendor module.

Install through vendoring

A regular check in the changelog is prefferable to determine if any new version should be downloaded to upgrade the package.