@hmcts/ccd-case-ui-toolkit

Case UI Toolkit

Stats

stars šŸŒŸissues āš ļøupdated šŸ› created šŸ£size šŸ‹ļøā€ā™€ļø
343Jun 22, 2021Mar 15, 2018Minified + gzip package size for @hmcts/ccd-case-ui-toolkit in KB

Readme

ccd-case-ui-toolkit

License: MIT Build Status codecov Codacy Badge Known Vulnerabilities HitCount Issue Stats

Quick Start (for local development and testing)

# Install all dependencies
yarn install

# Create symbolic link
yarn link

# Build library in watch mode
yarn build:watch

In your project folder that should consume the library:

# Go to consumer repository folder
cd case-management-web

# Link you library to the project
yarn link "@hmcts/ccd-case-ui-toolkit"

yarn start

Note: The linking might be broken so if your encounter problems please follow this process:

# Install all dependencies
yarn install

# Build library in watch mode
yarn build:watch

In you project folder that should consume the library:

# Go to consumer repository folder
cd case-management-web

# Remove existing toolkit dist
rm -rf node_modules/\@hmcts/ccd-case-ui-toolkit/dist

# Link you library to the project
cp <location of ccd-case-ui-toolkit>/dist node_modules/\@hmcts/ccd-case-ui-toolkit

yarn start

You can also have a quick look at an example usage of the UI Toolkit demo project (after both folders had yarn install ran on them) by:

# Build the toolkit and fire up the demo application to view it
yarn demo

Broken down into individual steps, this does the following:

# build UI Toolkit
yarn build:esm

# copy UI Toolkit dist folder to demo/node_modules/@hmcts/ccd-case-ui-toolkit/dist
yarn build:demo

# start demo app and stub server in same process
yarn start
# Go to http://localhost:8080

File Structure

case-ui-toolkit
|
ā”œā”€ demo                         - Self documenting application consuming components from src/shared/components
| ā”œā”€ src                        - Application sources folder
| | ā”œā”€ app                      - Components and modules implementing application
| | ā”œā”€ public                   - Fonts and images for application
| | ā”œā”€ style                    - Styles for application
| | ā”œā”€ index.html               - Index page of application
| | ā”œā”€ main.ts                  - Application initialisation logic
| | ā””ā”€ tsconfig.app.js          - Src folder typescript options to compile with
| ā”œā”€ stubs                      - Back end stubs the application starts off
| ā”œā”€ angular.js                 - Angular options to configure the application
| ā”œā”€ gulpfile.js                - Gulp tasks to copy the built ui toolkit library to demo application
| ā”œā”€ heroku-publish.js          - Script that deploys demo application latest master to Heroku
| ā”œā”€ package.json               - yarn dependencies, scripts and package configuration for demo application
| ā”œā”€ README.md                  - README for the demo app
| ā”œā”€ server.js                  - Demo application startup script.
| ā”œā”€ tsconfig.js                - Typescript base options that different config files derive from
| ā””ā”€ yarn.lock                  - File storing locked down dependencies for consistent installs
|
ā”œā”€ src                          - Library sources home folder
| ā”œā”€ scripts                    - Contains CI/Release related scripts
| ā”œā”€ components                 - Basic building blocks components with tests for CCD
| ā”œā”€ shared                     - Folder containing exportable components and directives that are shared with library consumers
| | ā”œā”€ components               - Components that are meant to be shared with library consumers (e.g. ExUI)
| | | ā”œā”€<component>             - Example component
| | | | ā”œā”€ domain               - Component specific domain structures
| | | | ā”œā”€ services             - Component specific services
| | | | ā””ā”€ <component files>    - Template, Component, Module and index files
| | ā”œā”€ directives               - Directives that are meant to be shared with library consumers (e.g. ExUI)
| | | ā”œā”€<directive>             - Example directive
| | | | ā”œā”€ domain               - Directive specific domain structures
| | | | ā”œā”€ services             - Directive specific services
| | | | ā””ā”€ <directive files>    - Template, Component, Module and index files
| | ā”œā”€ domain                   - Domain structures that are used by shared components and directives
| | ā”œā”€ fixture                  - Test domain builders and fixtures for shared components and directives
| | ā”œā”€ pipes                    - Pipes for shared components and directives
| | ā”œā”€ services                 - Common services for shared components and directives
| | ā””ā”€ test                     - Other test helpers
| ā””ā”€ index.ts                   - Library entry point that is used by builders
|
ā”œā”€ .editorconfig                - Common IDE configuration
ā”œā”€ .gitignore                   - List of files that are ignored while publishing to git repo
ā”œā”€ .npmignore                   - List of files that are ignored while publishing to npmjs
ā”œā”€ .travis.yml                  - Travis CI configuration
ā”œā”€ LICENSE.md                   - License details
ā”œā”€ README.md                    - README for the library
ā”œā”€ gulpfile.js                  - Gulp helper scripts
ā”œā”€ karma-test-entry.ts          - Entry script for Karma tests
ā”œā”€ karma.conf.ts                - Karma configuration for our unit tests
ā”œā”€ package.json                 - yarn dependencies, scripts and package configuration
ā”œā”€ tsconfig-aot.json            - TypeScript configuration for AOT build
ā”œā”€ tsconfig.json                - TypeScript configuration for UMD and Test builds
ā”œā”€ tslint.json                  - TypeScript linting configuration
ā”œā”€ webpack-test.config.ts       - Webpack configuration for building test version of the library
ā”œā”€ webpack-umd.config.ts        - Webpack configuration for building UMD bundle
ā””ā”€ yarn.lock                    - yarn lock file that locks dependency versions

Getting Started

Build the library

  • yarn build for building the library once (both ESM and AOT versions).
  • yarn build:watch for building the library (both ESM and AOT versions) and watch for file changes.

You may also build UMD bundle and ESM files separately:

  • yarn build:esm - for building AOT/JIT compatible versions of files.
  • yarn build:esm:watch - the same as previous command but in watch-mode.
  • yarn build:umd - for building UMD bundle only.
  • yarn build:umd:watch - the same as previous command but in watch-mode.

Build the library (for CCD devs working on ccd-case-management-web)

For CCD developers it should be noted the library should be built with just the yarn build:esm which is much faster. That will build the JIT version that is currently used by case management web.

Other commands

Test the library

  • yarn test for running all your *.spec.ts tests once. Generated code coverage report may be found in coverage folder.
  • yarn test:watch for running all you *.spec.ts and watch for file changes.

Library development workflow

In order to debug your library in browser you need to have Angular project that will consume your library, build the application and display it. For your convenience all of that should happen automatically in background so once you change library source code you should instantly see the changes in browser.

There are several ways to go here:

  • Use your real library-consumer project and link your library to it via yarn link command (see below).
  • Use Angular-CLI to generate library-consumer project for you and then use yarn link to link your library to it.

Using consumer applications

You may take advantage of watch-modes for library build in order to see changes to your library's source code immediately in your browser.

To do so you need to:

  1. Open two console instances.
  2. Launch library build in watch mode in first console instance by running yarn build:watch (assuming that you're in case-ui-toolkit root folder).
  3. Launch your consumer project build (JIT version) in watch-mode by running yarn start in second console instance (for instance assuming that you're in case-management-web folder).

As a result once you change library source code it will be automatically re-compiled and in turn your JIT consuming project (e.g. case-management-web) will be automatically re-built and you will be able to see that changes in your browser instantly.

Library Release

Travis build system automatically publish NPM packages including GitHub releases whenever there is a version change in package.json

Prerelease version from PR branch should follow the format as x.y.z-RDM-xxx-prerelease

LICENSE

This project is licensed under the MIT License - see the LICENSE file for details.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.