mod
mod
is a command line tool to quickly scaffold a new Deno module. It creates
app and dependency entrypoints, a .gitignore
file and has options to add a
test-driven setup and/or include a basic CI pipeline.
Try it without any installation:
Bash/Zsh
deno run \
--allow-read=my_deno_module \
--allow-run=git \
--allow-write=my_deno_module \
https://deno.land/x/mod/mod.ts \
--name my_deno_module
PowerShell
deno run `
--allow-read=my_deno_module `
--allow-run=git `
--allow-write=my_deno_module `
https://deno.land/x/mod/mod.ts `
--name my_deno_module
Table of Contents
Installation
mod
requires deno
and optionally git
. You can get the latest stable
release from deno.land/x
:
deno install --allow-read --allow-run=git --allow-write -fn mod https://deno.land/x/mod@v2.2.18/mod.ts
You can also get the unstable canary release from GitHub by installing via the
main
branchβs raw URL:
deno install --allow-read --allow-run=git --allow-write -fn mod https://raw.githubusercontent.com/GJZwiers/mod/main/mod.ts
Permissions
mod
requires the following permissions:
read
: to check if files already exists before writing.run=git
: to rungit
commands, more specificallygit init
write
: to make files as part of the module initialization.
Omitting run
permissions is possible, but it means a Git repository will not
be initialized automatically.
Usage
mod
This will create the following file structure in the current working directory:
.
βββ .gitignore
βββ deps.ts
βββ dev_deps.ts
βββ mod.ts
Note that mod
does not overwrite files unless --force
is used explicitly.
This means the program can also be used to βfill in the blanksβ in a directory
where not all of the files above are present yet.
Also note that mod
does not perform editor-specific setups such as enabling
Deno in VS Code via .vscode/settings.json
.
If git
is installed on the machine then git init
will be run as well.
To create the new module in a new directory:
mod --name my_deno_module
This will create the following file and directory structure:
.
βββ my_deno_module
| βββ .gitignore
| βββ deps.ts
| βββ dev_deps.ts
| βββ mod.ts
mod
can also create other files in addition to the basics, such as a workflow
file for GitHub Actions:
mod -n my_deno_module --ci
.
βββ my_deno_module
| βββ .github
| | βββ workflows
| | | βββ build.yaml
| βββ .gitignore
| βββ deps.ts
| βββ dev_deps.ts
| βββ mod.ts
You can also initialize with JavaScript:
mod --js
.
βββ .gitignore
βββ deps.js
βββ dev_deps.js
βββ mod.js
Options
mod
can create other files with the module, such as an import map or a Deno
configuration file. To see what options and flags are available use:
mod --help
if you have the CLI installed ordeno run https://deno.land/x/mod/mod.ts --help
Contributing
Bug reports and feature requests are very welcome! If you want to contribute a fix or feature yourself, fork this repository and make a pull request with your changes.