My deno dev template with sample scripts, tests, tasks (including git hooks) and workflows.
You can customize as you like.
Create repository by this template, or just copy deno.jsonc
in this repository
to your project.
Run deno task setup-hooks
at first or when you add git hooks definitions.
There are small scripts generated by deno init
and sample API server:
- main.ts
- main_bench.ts
- main_test.ts
- server.ts
- This server is running on Deno Deploy.
Some utility scripts is in scripts
directory:
- lint-staged.ts
- Run lint-staged with configurations
in
deno.jsonc
. - Read, env, run and write permissions are required.
- To use this, add
lint-staged
key indeno.jsonc
and add configurations.
- Run lint-staged with configurations
in
- setup-hooks.ts
- Setup git hooks defined in
deno.jsonc
using deno_hooks. - Read and run permissions are required (in addition, this script give a write permission to deno_hooks).
- To use this, add tasks in
deno.jsonc
with a key with the same name as git hooks (e.g. pre-commit, commit-msg). - You can also specify the directory where the hooks are defined using the key
hooks_dir
(default is .hooks).
- Setup git hooks defined in
deno.jsonc
should look like this to use above scripts:
// deno.jsonc
{
"lint-staged": {
"*": "deno lint && deno fmt"
},
"hooks_dir": ".my_hooks",
"tasks": {
"setup-hooks": "deno run --allow-read --allow-run https://pax.deno.dev/kawarimidoll/deno-dev-template/scripts/setup-hooks.ts",
"pre-commit": "deno run --allow-read --allow-env --allow-run --allow-write https://pax.deno.dev/kawarimidoll/deno-dev-template/scripts/lint-staged.ts",
"pre-push": "deno test"
}
}
💡 You can specify versions of scripts:
https://pax.deno.dev/kawarimidoll/deno-dev-template@2.0.1/scripts/setup-hooks.ts
Available Tasks:
- run
- Define common permissions.
- Using this task allows omitting permission declarations in other task definitions.
- dev
- Run main script with '--watch' flag.
- main
- Run main script once.
- start
- Start server script.
- test
- Run tests.
- Don't return error if no test files are found.
- cov
- Run tests and show coverage.
- lint
- Run lint (excluding coverage directory).
- fmt
- Run formatting (excluding coverage directory).
- ci
- Execute lint, formatting, and tests.
- deps
- Update dependencies using deno-udd.
- setup-hooks
- Set up the following git hooks.
- commit-msg
- Validate commit messages with commitlint.
- pre-commit
- Execute processes defined in lint-staged.
- pre-push
- Execute
deno task ci
.
- Execute
Workflows of GitHub Actions are defined:
- ci
- Run
deno task ci
on pull request.
- Run
- udd
- Run
deno task deps
on workflow_dispatch. - It is useful to run it periodically by scheduling.
- Run
MIT