The project is hosted on GitHub:
The project uses two branches:
master, with the latest stable version (default)develop, with the current development version
To clone the master branch, use:
mkdir ${HOME}/Work/npm-modules && cd ${HOME}/Work/npm-modules
git clone \
https://github.com/xpack/logger-ts.git logger-ts.gitFor development, to clone the develop branch, use:
git clone --branch develop \
https://github.com/xpack/logger-ts.git logger-ts.gitThe prerequisites are:
- node >= 16.0.0
- npm
To ensure compatibility with older node, revert to an older one:
nvm use --lts 16
codenpm installcd logger-ts.git
npm linkAnd in the projects referring it:
npm link @xpack/loggerThe TypeScript compiler can automatically recompile modified files. For
this, start it in watch mode.
npm run compile-watchThe current version is TypeScript 4:
The compiler is configured to produce es2020 & commonjs files,
which means ECMAScript6 with legacy CommonJS modules, that can be imported
by any other project either via require() or import.
For more details on how to configure tsconfig.json, please see:
As style, the project uses ts-standard, the TypeScript variant of
Standard Style,
automatically checked at each commit via CI.
// eslint-disable-next-line @typescript-eslint/no-xxx-yyyThe known rules are documented in the typescript-eslint project.
Generally, to fit two editor windows side by side in a screen, all files should limit the line length to 80.
/* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */Known and accepted exceptions:
- none
To manually fix compliance with the style guide (where possible):
% npm run fix
> @xpack/logger@6.0.0 fix
> ts-standard --fix src && standard --fix test
...The documentation metadata uses the TypeDoc tags, without explicit types, since they are provided by TypeScript.
The tests use the node-tap framework
(A Test-Anything-Protocol library for Node.js, written by Isaac Schlueter).
Tests can be written in TypeScript, assuming ts-node is also installed
(https://node-tap.org/docs/using-with/#using-tap-with-typescript)
As for any npm package, the standard way to run the project tests is via
npm run test:
cd logger-ts.git
npm install
npm run testA typical test result looks like:
% npm run test-100-c8
> @xpack/logger@6.0.0 pretest-100-c8 /Users/ilg/My Files/WKS Projects/xpack.github/npm-modules/logger-ts.git
> npm run lint
> @xpack/logger@6.0.0 lint /Users/ilg/My Files/WKS Projects/xpack.github/npm-modules/logger-ts.git
> ts-standard src && standard esm
> @xpack/logger@6.0.0 test-100-c8 /Users/ilg/My Files/WKS Projects/xpack.github/npm-modules/logger-ts.git
> npm run test-tap-coverage-100-c8 -s
(node:11770) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11771) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11773) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11774) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11775) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11772) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11776) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11777) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
tests/tap/010-mock-console.ts ......................... 7/7
tests/tap/020-logger-single.ts ...... [ 'trace: trace\n' ]
tests/tap/020-logger-single.ts .................... 185/185
tests/tap/030-logger-multi.ts ..................... 184/184
tests/tap/040-is-level.ts ........................... 81/81
tests/tap/050-buffer.ts ........................... 108/108
tests/tap/060-logger-empty.ts ....................... 25/25
tests/tap/070-logger-default.ts ....................... 2/2
tests/tap/080-undefined.ts .......................... 38/38
total ............................................. 630/630
630 passing (5s)
ok
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
src | 100 | 100 | 100 | 100 |
index.ts | 100 | 100 | 100 | 100 |
src/lib | 100 | 100 | 100 | 100 |
logger.ts | 100 | 100 | 100 | 100 |
------------|---------|----------|---------|---------|-------------------To run a specific test with more verbose output, use npm run tap:
% npm run tap tests/tap/010-mock-console.ts
> @xpack/logger@6.0.0 tap /Users/ilg/My Files/WKS Projects/xpack.github/npm-modules/logger-ts.git
> tap --reporter=spec "tests/tap/010-mock-console.ts"
(node:33235) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
tests/tap/010-mock-console.ts
mock console
✓ stdout is empty
✓ stderr is empty
✓ stdout has one entry
✓ stdout is output
✓ stderr is empty
✓ stderr has one entry
✓ stderr is error
7 passing (1s)Coverage tests are a good indication on how much of the source files is exercised by the tests. Ideally all source files should be covered 100%, for all 4 criteria (statements, branches, functions, lines).
Thus, passing coverage tests was enforced for all tests, as seen before.
Exclusions are marked with /* istanbul ignore next */ for
istanbul
and /* c8 ignore start */ /* c8 ignore stop */ for
c8.
- none
The continuous integration tests are performed via GitHub Actions on Ubuntu, Windows and macOS, using node 16, 18.
To trace module resolution:
"compile": "tsc --traceResolution -p ./",There are no fixed releases.
In the xpack/logger-ts Git repo:
- switch to the
developbranch - if needed, merge the
masterbranch
No need to add a tag here, it'll be added when the release is created.
Notice: this package is also used by the VS Code extension and must be kept as a legacy CommonJS dependency.
npm outdatednpm updateor edit andnpm install- repeat and possibly manually edit
package.jsonuntil everything is up to date - commit the changes
Keep:
@types/nodelocked to the oldest supported node (^16.18.14) release available for TypeScript.
As required by npm modules, this one also uses semver.
Determine the next version (like 6.0.0),
and eventually update the
package.json file; the format is 6.0.0-pre.
Check GitHub issues and pull requests:
Update the README-MAINTAINER.md file to reflect the changes
related to the new version.
- check the latest commits
npm run git-log - open the
CHANGELOG.mdfile - check if all previous fixed issues are in
- add a line * v6.0.0 released
- commit with a message like prepare v6.0.0
- terminate all running tasks (Terminal → Terminate Task...)
- select the
developbranch - commit everything
npm run fix- in the develop branch, commit all changes
npm run testnpm run typedocand open thedocs/index.htmlin a browsernpm run pack; check the list of packaged files, possibly update.npmignorenpm version patch(bug fixes),npm version minor(compatible API additions),npm version major(incompatible API changes)- push all changes to GitHub;
- the
postversionnpm script should also update tags viagit push origin --tags; this should trigger CI - wait for CI tests to complete
- check https://github.com/xpack/logger-ts/actions/
npm publish --tag next(use--access publicwhen publishing for the first time)
Check if the version is present at @xpack/logger Versions.
Test it with:
npm install -global @xpack/logger@nextIn this Git repo:
- select the
masterbranch - merge
develop - push all branches
In https://github.com/xpack/xpm-liquid-ts/milestones:
- close the current milestone.
The documentation site is built with TypeDoc and published in the project GitHub Pages.
The Web site deployment is performed automatically when pushing to the master branch, by a dedicated workflow in GitHub Actions.
When the release is considered stable, promote it as latest:
npm dist-tag ls @xpack/loggernpm dist-tag add @xpack/logger@6.0.0 latestnpm dist-tag ls @xpack/logger