Check out the code and go into the moment-holiday directory:
git clone https://github.com/nesto-software/moment-holiday.git
cd moment-holiday
Install the dependencies and bootstrap the monorepo:
npm run dev-install
npm run compile
The code for individual packages of this monorepo is in packages/*
.
Within any of the packages in this monorepo you'll generally use the npm
package scripts to manage the project, E.g. npm run test
or
npm run lint
. Run npm run
for a list of available commands.
Because of the monorepo structure some of the commands only work from
monorepo root using lerna run
instead of npm run
.
To run the test suite, from the root directory run:
npm test
If you want the tests to be rerun when any changes are made to the src or test files use:
npm test -- --watch
If you use vscode and you want to debug your test code, use the Debug Unit Tests
run configuration.
All the docsify
documentation can be found in the root level docs
directory. Running
the following command will stand up the docs server which will watch for
changes.
npm run docs:serve
As we use typescript, we want to provide an additional documentation for public modules - the so called API docs.
The following command is used to create the typedocs:
npm run typedoc:create
The typedoc documentation is based on your tsdoc comments. So make sure to comment public methods properly!
This package contains core entities which describe holidays. Some of the important ones are:
This package is the entry point for using the moment-holiday API.
You should import its factory method as default import.
Important entities contain:
There are two similar moment-holiday APIs.
The synchronous ('simplified') moment-holiday API does not use database modules and thus does not support client specific holiday definitions.
The synchronous API does not use Promises at all.
The asynchronous ('database') moment-holiday API uses database modules. Its methods return a promise.
This folder contains multiple packages with holiday definitions for different countries.
You should never depend on a locale package directly. The locale's public entities are exposed through the API package.
This package provides a MongoDB database plugin for moment-holiday.
It depends on the Mongoose ODM.
You can use it to store holiday definitions in a database. The library loads definitions from the mongo database.
The project is maintained by lerna. In order to make it easier for people who are not familiar with lerna, there are root level npm scripts to use.
npm run dev-install
: classic npm install for every package which installs peer dependencies as dev dependenciesnpm run ci-install
: the same as the above command but (a) removes present node_modules and (b) needs a package-lock.jsonnpm run compile
: runs tsc in every package in order to create the dist directory for nodenpm run compile:browser
: runs tsc in every package in order to create the dist.browser directory for webpacknpm run clean
: cleans all packages, i.e. removes node_modulesnpm run lint
: runs the linter for all packagesnpm run test
: runs tests in each packagenpm run publish
: publish packages which changednpm run dev
: compile all packages and invoke the client.js file in the dev packagenpm run typedoc:create
: create typedoc documentationnpm run docsify:serve
: serve the docsify documentation locallynpm run toc
: update the table of contents in this README filenpm run snyk:[monitor|protect|test]
: runs the respective snyk command - monitor and test in subpackages
We create two build directories: dist and dist.browser. This library is optimized for backend usage with node. Thus, we focus on the dist distribution of the library.
However, we want to provide basic support for the browser via the webpack bundler. Thus, we compile with the ES5 and CommonJS target for the dist.browser distribution. Webpack automatically recognizes and references the browser distribution.
Npm now uses so called 'file-specifiers'.
That is why we should put all dev-dependencies and peer-dependencies for packages in the package.json file at the root.
The packages in the packages folder then use the contents of the root node_modules folder along with their respective
node_modules folder. They get effectively merged.
Here is an issue which explains the recent changes and why lerna bootstrap
is not used anymore: lerna/lerna#1587.
It is a very fast JavaScript world we live in. ;)
Sometimes it is necessary to close and reopen vscode again in order for all imports to be resolved correctly. This issue was observed for local package imports that use symlinks.
If you want to report a bug or propose an enhancement, please fill an issue. If you want to add a locale package, please use the skeleton provided in the repository. If you want to do something else, you can place a pull request directly or contact the maintainer.
We use conventional commits and Semantic Versioning. Please structure your commit messages and package.json files accordingly.