Skip to content

My deno dev template with sample scripts, tests, tasks (including git hooks) and workflows.

License

Notifications You must be signed in to change notification settings

kawarimidoll/deno-dev-template

Repository files navigation

deno-dev-template

GitHub tag (latest SemVer) ci deno.land LICENSE

My deno dev template with sample scripts, tests, tasks (including git hooks) and workflows.

You can customize as you like.

Setup

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.

Scripts

There are small scripts generated by deno init and sample API server:

  • main.ts
  • main_bench.ts
  • main_test.ts
  • server.ts

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 in deno.jsonc and add configurations.
  • 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).

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/[email protected]/scripts/setup-hooks.ts

Tasks

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
  • 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.

Workflows

Workflows of GitHub Actions are defined:

  • ci
    • Run deno task ci on pull request.
  • udd
    • Run deno task deps on workflow_dispatch.
    • It is useful to run it periodically by scheduling.

Author

kawarimidoll

License

MIT

About

My deno dev template with sample scripts, tests, tasks (including git hooks) and workflows.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project