Centralize and automate all the things! So I don't have to copy pasta configs in every single project.
npm -i D virmator
npx virmator --help
Below is full documentation for the cli, which is generated via the cli's
[npx] virmator [--flags] command subCommand
npx is needed when the command is run directly from the terminal (not scoped within an npm script) unless the package has been globally installed (which will work just fine but I wouldn't recommend, simply because I prefer explicit dependencies).
compile typescript files Pass any extra tsc flags to this command.
- no extra flags:
- one extra flag:
virmator compile --noEmit
Run type checking without emitting compiled files.
Either upgrade or check dependencies
Check that dependencies are all good via a default set of rules in configs/dep-cruiser.config.ts and dependency-cruiser.
Upgrade all packages using npm-check-updates and configs/ncu.config.ts.
Regenerate all npm deps and package-lock.json
- Upgrade deps:
virmator deps upgrade
- Check deps:
virmator deps check
- Check deps for a specific file:
virmator deps check ./src/my-file.ts
- Regen deps:
virmator deps regen
upgrade npm dependencies
regenerate npm dependencies
This also inserts code snippets into markdown files. This uses the markdown-code-example-inserter package to expand code link comments inside of markdown files to actual markdown code blocks. See that package's README for more details but the basics are that you need a comment that looks like the following in your markdown file for this to do anything:
<!-- example-link: path/to/file.ts -->
By default this command parses all markdown files in the repo (ignoring node_modules). Specific markdown files can be parsed by giving virmator extra parameters.
To check if files are up-to-date (rather than actually updating them), use the "check" sub-command.
- default experience (usually all you need):
- checking if files are up-to-date:
virmator docs check
- override files to check to a single file:
virmator docs only/this/one/file.md
- override files to check to a group of files:
virmator docs "only/this/dir/*.md"
Check that documentation is up-to-date.
Formats source files with Prettier.
If only specific file extensions should be formatted, add the "--file-types" argument to this command. All following arguments will be treated as file extensions to be formatted. For example, the following command will format files only if they have the extension ".md" or ".json": virmator format --file-types md json
Any other arguments encountered between the operation command (if provided) and the "--file-types" marker are treated as extra arguments to Prettier and will be passed along.
checks formatting for files:
virmator format check
checks formatting only for .md files:
virmator format check --file-types md
checks formatting only for .md and .json files:
virmator format check --file-types md json
fixes formatting for files:
virmator format virmator format
examples with extra Prettier flags:
virmator format --ignore-path .prettierignore virmator format --ignore-path .prettierignore virmator format --ignore-path .prettierignore --file-types md json
check formatting without overwriting files.
Runs a frontend. Currently uses vite.
Builds and bundles the frontend for deployment.
Builds and previews the built output.
Initialize a repo with all virmator config files.
- run init:
- run init and force all configs to be written:
virmator init force
force overwrite files even if they already exist.
Publish an npm package. Includes workspace support. Add test commands to run before publish as arguments.
- publish a package:
- publish a package and run tests beforehand:
virmator publish npm test
Spellcheck code with cspell. By default this spellchecks every file in the entire repo (except for those ignored in the config file), including .dot files. If any arguments are passed to this command, the default cspell args that this command applies are ignored, you'll have to supply them via your args.
Test all .test.ts files with Mocha and Chai. By default this command tests all ".test.ts" files in the current directory (recursively) that are not ".type.test.ts" files. To override this behavior, override the "spec" property in .mocharc.js.
This command is meant to run Node.js tests. For running web-based testing, see the test-web command.
Note that the below single file examples only work because the base Mocha config from virmator is setup to handle them. (So if you don't use that config, the examples may not work properly.)
- Test all .test.ts and .test.tsx files:
- Test a single file:
virmator test ./path/to/single/file.js
- Test multiple files:
virmator test "./**/single-file.js"
run tests with code coverage calculations. This will often result in incorrect stack traces on errors, so this is only recommended after having first gotten all tests to pass without coverage calculations.
Runs tests within browsers rather than inside of Node.js. Test files fed into this command cannot be mixed with test files run by the "virmator test" command, as the run-time environment is quite different (Node.js vs browser). However, just like the test command, this command will all ".test.ts" files in the current directory (recursively) that are not ".type.test.ts" files. To override this behavior, override the "files" property in web-test-runner.config.mjs.
By default this command runs all tests three times: in Chromium (Chrome), Firefox, and Webkit (Safari) using playwright.
- Test all .test.ts and .test.tsx files:
- Test a specific file:
virmator test-web path/to/file.test.ts
run web tests with code coverage calculations
Update all existing configuration files that virmator is able to update. (Like base config files.)