Typescript module seed
- Developping:
- Latest typescript version
- Multiple tsconfig files
- Testing: mocha/chai for testing
- ts-node for on-the-fly test compilation
- code coverage with istanbul
- Publishing proper .npmignore so published module only has the necessary sources
- Continuous integration with travis CI
- dist : distribution folder (build folder)
- gen: contains generated files
- coverage: code coverage report
- src: your source folder
- test: Test folder
- testcase contains testing file
- bootstrap.ts bootstrap file for tests
- mocha.opts mocha options file
- git clone the repository
- remove .git and add your own repository
- npm install
TODO
npm run build
Generated file can be found in ./dist directory.
It uses mocha for testing. Files that ends with .spec.ts
are test file (See mocha option file ./test/mocha.opts).
Use the following shortcuts to run tests:
npm run test
- Tests only
npm run cover
- Run tests with coveragenpm run show-coverage
- Show code coverage report (Located in ./gen/coverage)
If you want to set up code coverage measurements in a project, there are usually 4 things that you’ll need:
- a test runner: mocha
- a code coverage tool istanbul/nyc, to generate code coverage reports. With a code reporter for coveralls: mocha-lcov-reporter
- a code coverage insight service Coveralls, to provide you a nice visualization of your code coverage data
- a reporting tool node-coveralls, codecov.io, to send your reports to some service
For more information about code coverage see this article.
Reminder: This approach uses two branches to track the history of the project. While the master branch contains tags and/or commits that record the project's official release history, a shared integration branch (usually called "develop") gives your team a place to ferret out bugs and incompatible changes. More info here
You must have git flow
extension installed. See here.
-
First update package version Use `npm version [patch|minor|major]. It will:
- Bumps the version in package.json (the patch part)
- Creates a commit with specified message
- Tags that commit with the new version
-
Push to remote
git push --tags
Version should follow semver format. As a reminder, here the summary of how it works: Given a version number MAJOR.MINOR.PATCH, increment the:
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards-compatible manner, and
- PATCH version when you make backwards-compatible bug fixes.
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
Or using standard-version
All commands in package.json
-
npm run build - run tsc
-
npm run build:watch - run tsc in watch-mode
-
npm run clean - delete build directory
-
npm run lint - runs tslint
-
npm test - run mocha on all *.ts files in test/
-
npm run node - run ts-node to get a REPL or run a script, e.g. a spike: npm run node src/spikes/consolespike.ts
-
npm run test:watch - re-run mocha on all *.ts files in test/ everytime a file changes
MIT © Stéphane Léonard