@deviceinsight/ng-ui-api-client
v10.60.0
Published
This project wraps the backend APIs used by [NG-UI](https://gitlab.device-insight.com/ng-ui/ng-ui) and custom projects.
Keywords
Readme
General
This project wraps the backend APIs used by NG-UI and custom projects.
It is published as @deviceinsight/ng-ui-api-client. The package is ESM-first
(dist/index.js) with a CommonJS build (dist/index.cjs) and type declarations
(dist/types/index.d.ts). axios is a peer dependency and has to be provided by the
consuming project.
Every module under src covers one backend resource (e.g. asset.ts, event.ts,
user.ts, role.ts, licenses.ts) and is re-exported from src/index.ts.
src/axios.ts holds the shared axios instance; it exports getAxios, setAxios and
setAxiosConfig, which the consuming application uses to inject its configured
axios client.
Development
Node is pinned via .nvmrc (see also the engines field in package.json).
npm installAvailable scripts:
| Script | Description |
| ------------------- | ---------------------------------------------------------------------- |
| npm run build | Cleans dist, bundles with Vite and emits types via tsconfig.types.json |
| npm run watch | tsc --watch |
| npm run clean | Removes dist |
| npm run typecheck | tsc --noEmit |
| npm run lint | Lints src with oxlint and checks formatting (npm run lint:fix to autofix) |
| npm run prettier | Formats the TypeScript sources |
| npm run scan | Vulnerability scan via audit-ci using scan-config.json5 |
There are no unit tests in this project.
Commits are checked by a husky pre-commit hook that runs lint-staged
(prettier on the staged TypeScript files).
CHANGELOG.md is maintained per version under the version of package.json without -SNAPSHOT.
Renovate dependency updates append their entry automatically via the postUpgradeTasks hook in renovate.json, which calls ./update-changelog.sh <depName> <currentVersion> <newVersion>; patch updates are skipped.
All other changes have to be added to CHANGELOG.md by hand in the same merge request.
Linking for local development
We recommend using the yalc tool for linking @deviceinsight/ng-ui-api-client.
It's because yalc generates exactly the same package as it would be published to the npm registry,
especially it removes files that should be ignored and their existence cause problems when we use npm link.
Here's how to do the linking:
npm run build
npx yalc publish
# in the project where you want to link this library to:
npx yalc link "@deviceinsight/ng-ui-api-client"CI
.gitlab-ci.yml installs the dependencies and then runs lint and typecheck on every branch except main.
The audit job (npm run scan) only runs on develop, feature/* and renovate/* branches, so hotfixes and tags are not blocked by it.
The publish job runs for develop and for tags: -SNAPSHOT versions are published to the internal Nexus registry under the next tag, releases go to the public npm registry.
A release older than the currently published latest is published under a hotfix-<major>.<minor> tag so that latest is not moved backwards.
publish_alpha is a manual job that always publishes to the internal registry under next.
Releasing the library using git flow
Prerequisites
git flow
The git flow tools need to be installed. This depends on your operating system.
They can be also installed from the git repo: https://github.com/petervanderdoes/gitflow-avh
After git flow is installed, the repo needs to be initialized.
Make sure that the main branch is locally available.
If not, execute git checkout main.
Run git flow init and answer every question with the default (press Enter/Return).
The script verifies that the branches are named main and develop.
Releasing the develop branch
Run the release script from the repository root:
./release.shBefore running it, make sure the workarea is clean and all commits on develop are pushed; otherwise the script aborts.
It releases the current version from package.json (without -SNAPSHOT) and afterwards starts the next minor snapshot version.
Building a hotfix for a specific version of this library
When building a hotfix in ng-ui-scale, first check which version of this library is used on the main branch of ng-ui-scale, e.g. with git show origin/main:package.json | grep ng-ui-api-client.
Then build the hotfix on top of exactly that version, so that no unrelated changes from newer releases end up in the ng-ui-scale hotfix.
Do not use release.sh or git flow hotfix for this: git flow hotfix finish merges into main, which already contains the newer release.
Example: ng-ui-scale uses 10.56.0 while 10.57.0 is already released (the version on main of this library):
- Create the branch
hotfix/10.56.1from the tag 10.56.0 and install the dependencies of that version:git fetch --tags git checkout -b hotfix/10.56.1 10.56.0 npm ci - Set the version in
package.jsonandpackage-lock.jsonto 10.56.1:
If thenpm version 10.56.1 --no-git-tag-versionauditjob in.gitlab-ci.ymlstill runs on every branch exceptmain, copy itsrulesfromdevelop, so that the vulnerability audit does not block the hotfix pipeline. - Implement or cherry-pick the changes needed for the hotfix, either directly on the hotfix branch or in a feature branch that is merged into it.
- Run
npm run build,npm run lintandnpm run typecheckto verify there are no errors. - Commit the changes.
- Tag the hotfix commit and push the tag:
Thegit tag -a 10.56.1 -m "Hotfix 10.56.1" git push origin 10.56.1publishCI job builds the tag and publishes it to npm. Because 10.56.1 is older than thelatestversion, it is published under the dist-taghotfix-10.56andlateststays at 10.57.0. - Merge the hotfix branch into
developand pushdevelop:git checkout develop git pull git merge --no-ff hotfix/10.56.1 git pushpackage.jsonandpackage-lock.jsonwill conflict; keep the-SNAPSHOTversion ofdevelopand runnpm installbefore committing the merge. Do not merge the hotfix branch intomain. - Delete the local hotfix branch:
git branch -d hotfix/10.56.1. - Update
ng-ui-scaleon its hotfix branch to 10.56.1.
