Skip to content

Latest commit

 

History

History
160 lines (112 loc) · 4.91 KB

DEVELOPER.md

File metadata and controls

160 lines (112 loc) · 4.91 KB

Developer Instructions

Prerequisites

The pm2 package needs to be available for tests. You can install the same by executing

npm install -g pm2

⚙️ Configure

This microservice needs library assets and configuration file. Please see README for this information.

🛠️ Developer Commands

yarn install    # Install dependencies for the microservice
yarn syntax     # Analyze code for errors and style issues
yarn format     #format .ts[x] and .js[x] files with prettier
yarn graph      # Generate dependency graphs in the code
yarn build      # Compile ES6 to ES5 and copy JS files to build/ directory
yarn test:unit  # Run unit tests
yarn test:int   # Run integration tests
yarn test:e2e   # Run end-to-end tests
yarn test:http  # Run tests for HTTP file service provided by cloudcmd
yarn test:all   # Run all tests except http tests
yarn start -h   # List of all the CLI commands
yarn start      # Start the application
yarn start:pm2  # Start the application with process manager 2
yarn stop:pm2   # Stop the application managed by process manager 2
yarn clean      # Deletes "build", "coverage", "dist" and other temp files

NOTE: The integration, end-to-end and http tests require a valid configuration. This configuration is already set in libms.test.yaml file.

Service Endpoint

The URL endpoint for this microservice is located at: localhost:PORT/lib

The API page shows sample queries and responses.

Manual testing

As of now, some features require manual testing or attention.

CloudCMD (a npm package dependency)

Due to how CloudCMD works, it is required to manually run yarn test:http with LOCAL_PATH both as an absolute path and local path. For example, the manual tests need to be done with the following LOCAL_PATH values.

OS Absolute Path Relative Path
Windows C:\DTaaS\files ....\files
Linux /Users/<Username>/DTaaS/files ../../files

PM2

the pm2 might not close spawned processes correctly, therefore please use the following command to kill a process. pm2 del <id>.

NOTE: to see the processes spawned by pm2 use pm2 list

📦 🚢 Packages

Docker images

The docker version of lib microservice is packaged with the DTaaS application release. Please see publishing page for more information publishing docker images.

Default NPM Registry

The default registry for npm packages is npmjs.

npm install -g @into-cps-association/libms

The steps for publishing the package to npmjs are listed in npm packages page.

The libms is also published on this registry, usually per release of the DTaaS application. The package on npmjs is more stable than the package on github npm registry.

Github NPM Package Registry

The Github actions workflow of lib microservice publishes the libms into packages.

A new libmspackage is published to github packages for each version of libms microservice.

Verdaccio - Local NPM Package Registry

Use the instructions in publish npm package for help with publishing libms npm package in local computer.

Application of the advice given on that page for libms will require running the following commands.

Use in Docker Environment

Adjust Configuration (Optional)

The microservices require configuration and the docker version of the microservices uses the configuration file available in config/libms.dev.yaml.

For more see configuration documentation. The config/libms.dev.yaml file is used for configuration of the container.

A new directory named files is created in servers/lib directory and files are saved and served from the files directory.

Use

The commands to start and stop the appliation are:

NOTE: the docker compose file is located in the servers/lib directory.

docker compose -f compose.lib.dev.yml up -d

This command brings up the lib docker container and makes the website available at http://localhost:4001. The config/libms.dev.yaml file is used as the microservice configuration. If the configuration values are changed, please restart the container.

docker compose -f compose.lib.dev.yml down
docker compose -f compose.lib.dev.yml up -d

Publish

yarn install
yarn build #the dist/ directory is needed for publishing step
yarn publish --no-git-tag-version #increments version and publishes to registry
yarn publish #increments version, publishes to registry and adds a git tag

Unpublish

npm unpublish  --registry http://localhost:4873/ @into-cps-association/[email protected]