init
deno-init
is a simple command line tool to initialize new Deno projects from
templates or through prompts.
Please note this module’s API is not stable yet and there may be breaking changes on
0.x
version increments.
Table of Contents
Installation
First install deno
and make sure it is available on a terminal. git
is also recommended though not required.
Next, run the deno install
command below to install the executable:
deno.land
deno install --allow-read --allow-run --allow-write --unstable -n deno-init https://deno.land/x/init@0.15.0/mod.ts
nest.land
deno install --allow-read --allow-run --allow-write --unstable -n deno-init https://x.nest.land/init@0.15.0/mod.ts
github
deno install --allow-read --allow-run --allow-write --unstable -n deno-init https://raw.githubusercontent.com/GJZwiers/deno-init/main/mod.ts
If you already have a previous installation and would like to upgrade, run the command with the new version number and include the -f
flag.
Permissions
The program needs the following permissions to run:
read
: to load files that are used to initialize projects from templatesrun
: to rungit init
if the git option is truewrite
: to make files in order to initialize new projectsunstable
: to allow the use of unstable APIs. These mostly come from the module’s external dependencies.
Basic Usage
deno-init
This will prompt you for the following:
- Use TypeScript? (default
y
) - Set entrypoint: (default
mod.ts
) - Set dependency entrypoint: (default
deps.ts
) - Set dev dependency entrypoint: (default
dev_deps.ts
) - Add import map? (default
n
)
Choosing all defaults will create the following structure in the current directory:
.
│ .gitignore
│ deps.ts
| dev_deps.ts
│ mod.ts
If you choose to init with an import map an import_map.json
file is added to the above. If git
is installed on the machine then git init
is run as well.
Note that deno-init
will not overwrite files or directories unless the --force
option is used explicitly. This means the program can ‘fill in the blanks’ in a project where not all of the files above are present yet.
Options
--help
will print all available options to the terminal.
--yes
or -y
will initialize the project with all the defaults, skipping the
prompts:
deno-init --yes
--name
or -n
will initialize the project in a new directory in the current working directory:
deno-init --name awesome_deno_project
--import-map
or -m
will add an (empty) import_map.json
file to the project:
deno-init --import-map
--cache
or -c
will run deno cache
on any dependencies in for example deps.ts
after all of the project’s files have been made:
deno-init --cache
--force
or -f
will allow the progam to overwrite existing files. This can be helpful
to re-initialize but use with caution.
deno-init --force
--no-git
disables running git init
as part of the project initialization.
deno-init --no-git
Subcommands
Use --help
with any of the subcommands to get more detailed information.
The deno-init
subcommands will create a new project from a chosen template,
which can be specified with --template
or -t
. If --template
is omitted
you will be prompted to choose one from a list of available choices.
api
Use to initialize a Deno RESTful API from a template.
deno-init api --template opine
Available templates: opine
, restful_oak
.
cli
Use to initialize a Deno Command Line Interface (CLI) from a template.
deno-init cli --template cliffy
Available templates: cliffy
.
server
Use to initialize a Deno HTTP server from a template.
deno-init server --template oak
Available templates: deno_http
, drash
, oak
.
tdd
Use to initialize a Deno Test-Driven Development project from a template.
deno-init tdd --template rhum
Available templates: deno
, rhum
.
Contributing
TBD