Simple word guessing game. A basic template project for using Node, TypeScript, and Jest.
Check for proper versions of NodeJS (currently v16.x) and NPM (currently v8.x):
$ node --version
$ npm --vA useful tool when moving between projects with different versions of node is nvm. A supporting .nvmrc file is a part of the project.
To download the modules needed to develop and build simply run the following from the main directory where the package.json file lives:
$ npm installThis normally only has to be done when dependencies are added or updated.
To translate the TypeScript code (*.ts) into executable JavaScript (*.js), use:
$ npm run buildWhen successful the resulting JavaScript will be in the build directory.
It is often useful to get rid of generated files during the development process. Normally, it's no big deal to partially recompile -- to only recompile the changed files -- but to be absolutely safe there is a set of npm targets that can remove intermediate files.
- tidy Deletes the
coveragedirectory (containing code coverage reports generated during testing) and thebuild/*.tsbuildinfo(cache used by TypeScript to speed up compiling) files. - clean Removes all generated files from building, but leaves the downloaded modules in place by deleting the
coverageandbuilddirectories. - distclean Resets to a fresh checkout by deleting the
coverage,build, andnode_modulesdirectories.
$ npm run cleanThis template uses Jest, CSpell, Prettier, and ESLint to handle test and code quality tasks.
To execute all *.ts tests in the tests directory, as well as run a spell checker and lint the source:
$ npm testTo just run the tests and coverage report, skipping the other useful tools (which must all pass cleanly before committing anything!), use:
$ npm run test:unitTest coverage will be calculated with each run of the test suite. If coverage falls below 95% the test run will fail.
All projects should cleanly pass linting (both eslint and prettier) before a commit.
A spell checker runs as a part of the normal testing target. When the tool flags words that are appropriate for the project but not a part of the configured dictionaries, they should be added to the src/project-dictionary.txt file.
After building the game may be executed by running:
$ npm start