sainture
10/21/2019 - 6:36 AM

Angular Library - Nexus - build and upload on Nexus

Setup Nexus (by DevOps)
1. Login in Nexus and create a npm (hosted) repository (to upload our package)
2. Create npm proxy repository for http://registry.npmjs.org (to download public packages from npmjs)
3. Create npm group repository to group "hosted" and "proxy" repository. 
  This group repository is used in our .npmrc file to download all packages.

Build library
1. Create build for the angular libary (in dist folder)
  ng build
2. Create tgz file (to be uploaded on Nexus)
  cd dist/<package-name>
  npm pack

Upload package (tgz file) to Nexus
1. Open hosted repository in Nexus
2. Click on Upload Component button and upload the above package (tgz file)


Use the above package in another angular application without .npmrc file
  npm login --registry <registry url>
  npm install <package-name> --registry <registry url>

Use the above package in another angular application using .npmrc file
1. add .npmrc file in project root (which contains information about private registry)
  registry=<private nexus repo group name>
  always-auth=true
2. login to Nexus and install the package 
  npm login
  npm install <package-name>
  (we don't have to specify --registry flag if we have .npmrc file available in project root)

To install the package from the local tgz file for development purposes
1. Add following in your package.json file
   "package-name": "file:dist/<package-name>.tgz"
2. npm install <package-name>