Defaults to module, but exports to CommonJS and ESM.
With documentation, update and release mechanisms and gitlab/github workflows to match;
Defines a 'way' to write jsDocs to optimize the output
Optimized for github in terms of badges. CI is equivalent between Gitlab and Github.
Auto setup on first npm install
Will accept a .token file containing token valid for private npm dependencies, npm and docker registries
create a new project using this one as a template.
clone it git clone <project> and navigate to the root folder cd <project>
If your project has private dependencies or publishes to private npm registries, create an .npmrc containing:
@<scope1>:registry=https://<ADDRESS>.com/api/v4/packages/npm/
@<scope2>:registry=https://<ADDRESS>.<DOMAIN>.com/api/v4/packages/npm/
//<ADDRESS>.<DOMAIN>.com/:_authToken=${TOKEN}
//<ADDRESS>.<DOMAIN>.com/api/v4/groups/<GROUP_ID>/packages/npm/:_authToken=${TOKEN}
//<ADDRESS>.<DOMAIN>.com/api/v4/projects/<PROJECT_ID>/packages/npm/:_authToken=${TOKEN}
Changing:
- to `gitlab` or `github` (or other);
- to your domain if any (if you are using plain gitlab or github use empty and take care to remove the extra
.); - <GROUP_ID> to your project's group id (if any). otherwise remove this line
- <PROJECT_ID> to your project's id
and adding a .token file containing your access token to the private registries na repositories.
run npm run initial-setup
Run npm install (or npm run do-install if you have private dependencies and a .token file) to install the dependencies:
If this is the first time you are running this command it will also:
- update this repository's dependencies to their latest version;
- creates a
.tokenfile which you can leave empty unless you have private dependencies or publish to private registries - delete this 'first run script' file and npm call from the
package.json; - try to commit the updated
package.jsonand deleted files (having ssh access helps here);
Preconfigured Jest based testing:
- Configured to goup all modules in their testing, and test them as a whole.
- When adding a new submodule, add it to
jest.config.js
Make sure your .gitmodules file contains your modules in the required build order so the build script can conclude.
This repository automates releases in the following manner:
- run
npm run release -- <major|minor|patch|version> <message>:- if arguments are missing you will be prompted for them;
- it will run
npm run prepare-releasenpm script; - it will commit all changes;
- it will push the new tag;
If publishing to a private repo's npm registry, make sure you add to your package.json:
{
"publishConfig": {
"<SCOPE>:registry": " https://<REGISTRY>/api/v4/projects/<PROJECT_ID>/packages/npm/"
}
}Where:
<SCOPE>- Is the scope of your package;<REGISTRY>- your registry host;<PROJECT_ID>- you project ID number (easy to grab via UI in gitlab or by running$("meta[name=octolytics-dimension-repository_id]").getAttribute('content')in the repository page in github) ;
Unless the -no-ci flag is passed in the commit message to the npm run release command, publishing will be handled
automatically by github/gitlab (triggered by the tag).
When the -no-ci flag is passed then you can:
- run
npm run publish. This command assumes :- you have previously run the
npm run release; - you have you publishing properly configured in
npmrcandpackage.json; - The token for any special access required is stored in the
.tokenfile;
- you have previously run the
Since CI for multi module projects can be anything. No CI is included.
For the default CI reference ts-workspace
- Setup for a linux based environment (Sorry windows users. use WSL... or just change already);
- Setup for node 20, but will work at least with 16;
- Requires docker to build documentation (drawings and PlantUML)
The repository proposes a way to generate documentation that while still not ideal, produces verys consitest results.
In the code you see an example on how to properly document each code object, but the overall structure is:
- each package is a
@module; - Classes and Interfaces are categorized into
@categoryand@subcategory; - All other objects are categorized by
@namespaceand@memberOf; - Enums and const are declared as
@constand both must describe their properties as@property(when constants are objects); - Interfaces must declare their methods
@method;
There are 3 steps the generating the documentation (automated in CI):
npm run drawings- generates png files from each drawing in theworkdocs/drawingsfolder and moves them to theworkdocs/resourcesfolder (requires Docker);npm run uml- generates png files from each PlantUML diagram in theworkdocs/umlfolder and moves them to theworkdocs/resourcesfolder (requires Docker);npm run docs- this has several stages, defined under thegulp docs(gulpfile.js):- compiles the Readme file via md compile:
- enables keeping separate files for sections that are then joined into a single file;
- Allows keeping specific files in the jsdocs tutorial folder so they show up on their own menu;
- compiles the documentation from the source code using jsdocs:
- uses the better docs template with the category and component plugins
- uses the mermaid jsdoc plugin to embue uml diagrams in the docs
- includes a nav link to the test coverage results;
- copies the jsdoc and mds to
/docs; - copies the
./workdocs/{drawings, uml, assets, resources}to./docs;
- compiles the Readme file via md compile:
The produced docs folder contains the resulting documentation;
When adding a new submodule, do not forget to add it the jsdocs list
The following npm scripts are available for development:
inital-setup- will run only on the first install to trigger the dep update. will self delete;preinstall- initializes the git modules;do-install- sets aTOKENenvironment variable to the contents of.tokenand runs npm install (useful when you have private dependencies);postinstall- checkout master on all modules, pulls and install dependencies;flash-forward- updates all dependencies. Take care, This may not be desirable is some cases;reset- updates all dependencies. Take care, This may not be desirable is some cases;reset-build- resets and then builds;link-token- creates symlinks in all modules to the.token;set-dev- checout out master on all modules and symlinks the relative dependencies according to the modules;test- runs unit tests;test:unit- runs it tests;test:all- runs all tests;coverage- runs all test, calculates coverage and generates badges for readme;build-all- builds the code (via gulpgulpfile.js) in development mode (generateslibanddistfolder);build-all:prod- builds the code (via gulpgulpfile.js) in production mode (generateslibanddistfolder);npm-link- symlinks relative dependencies;npm-unlink- reverses the dependency symlink process;set-to-latest- checkout all modules to master;git-checkout- checkout all modules to master;git-pull- pull all modules;git-all- runs git command in all modules;run-all- runs command in all modules;prepare-release- defines the commands to run prior to a new tag (defaults to linting, building production code, running tests and documentation generation);release- triggers a new tag being pushed to master (via./bin/tag_release.sh);clean-publish- cleans the package.json for publishing;drawings- compiles all DrawIO*.drawiofiles in theworkdocs/drawingsfolder to png and moves them to theworkdocs/resourcesfolder;uml- compiles all PlantUML*.pumlfiles in theworkdocs/umlfolder to png and moves them to theworkdocs/resourcesfolder;docs- compiles all the coverage, drawings, uml, jsdocs and md docs into a readable web page under./docs;
ts-multi-module-workspace
│
│ .gitignore <-- Defines files ignored to git
│ .npmignore <-- Defines files ignored by npm
│ .nmprc <-- Defines the Npm registry for this package
│ .eslintrc.cjs <-- linting for the project
│ .prettier.config.cjs <-- Code style for the project
│ .gitlab-ci.yml <-- Gillab CI/CD file
│ gulpfile.js <-- Gulp build scripts. used for building na other features (eg docs)
│ jest.config.ts <-- Tests Configuration file
│ mdCompile.json <-- md Documentation generation configuration file
│ jsdocs.json <-- jsdoc Documentation generation configuration file
│ Dockerfile <-- minimal example of a node service Dockerfile
│ LICENCE.md <-- Licence disclamer
│ package.json
│ package-lock.json
│ README.md <-- Readme File dynamically compiled from 'workdocs' via the 'docs' npm script
│ tsconfig.json <-- Typescript config file. Is overriden in 'gulpfile.js'
│
└───bin
│ │ tag_release.sh <-- Script to help with releases
│
└───docs
│ │ ... <-- Dinamically generated folder, containing the compiled documentation for this repository. generated via the 'docs' npm script
│
└───src
│ │ ... <-- Source code for this repository
│
└───tests
│ │───unit <-- Unit tests
│ └───integration <-- Integration tests
│
└───workdocs <-- Folder with all pre-compiled documentation
│ │───assets <-- Documentation asset folder
│ │───badges <-- Auto generated coverage badges folder
│ │───coverage <-- Auto generated coverage results
│ │───drawings <-- DrawIO folder. Drawings (*.drawio) here will be processed to generate documentation (requires docker)
│ │───uml <-- PlantUML folder. Diagrams (*.puml) here will be processed to generate documentation (requires docker)
│ │───tutorials <-- Tutorial folder
│ │ ... <-- Categorized *.md files that are merged to generate the final readme (via md compile)
│ │ Readme.md <-- Entry point to the README.md
│
└───dist
│ │ ... <-- Dinamically generated folder containing the bundles for distribution
│
└───lib
| ... <-- Dinamically generated folder containing the compiled code
If you have bug reports, questions or suggestions please create a new issue.
I am grateful for any contributions made to this project. Please read this to get started.
The first and easiest way you can support it is by Contributing. Even just finding a typo in the documentation is important.
Financial support is always welcome and helps keep the both me and the project alive and healthy.
So if you can, if this project in any way. either by learning something or simply by helping you save precious time, please consider donating.
This project is released under the MIT License.
