Crates.io | kickstart |
lib.rs | kickstart |
version | 0.4.0 |
source | src |
created_at | 2018-02-15 20:54:12.188633 |
updated_at | 2023-08-02 20:06:30.966594 |
description | A simple way to get started with a project by scaffolding from a template powered by the Tera engine |
homepage | |
repository | |
max_upload_size | |
id | 51327 |
size | 456,948 |
A CLI tool to easily get a new project up and running by using pre-made templates. This is a slightly more powerful version of an equivalent tool in Python, cookiecutter. It is an alternative to NodeJS projects such as Yeoman or Slush.
kickstart
is available only through crates.io:
$ cargo install kickstart
Or as a pre-built binary on the Releases page.
Run kickstart --help
for a full listing of the available commands and their flags/options.
{{ repo_name }}/{{author}}.md
is a valid pathcamelCase
to CamelCase
The main drawback compared to cookiecutter is the lack of hook scripts support, which can be mitigated a bit by the conditional cleanup.
Lastly, since Windows does not allow |
in file paths, you may use a tera built-in filter
by using the $$
separator instead.
Note that, in file templates, you should keep using |
for filtering, as the $$
syntax is only for files and directories. Keep in mind the characters ()
are not allowed on Windows so do not use filter parameters if you want to be cross-platform.
# From the root of this repo
$ kickstart examples/super-basic
$ kickstart examples/complex -o Hello
# Anywhere
$ kickstart https://github.com/Keats/kickstart -s examples/super-basic
$ kickstart https://github.com/Keats/kickstart-sample -o sample
Creating a template is fairly simple: create files and then just add a template.toml
in the root folder. Here is a description of all the fields available in it:
# Required, name of the template
name = "Django"
# Optional, longer form description
description = "A fully-featured Django template"
# Required, the version of the kickstart schema, currently only `1` is used
kickstart_version = 1
# Optional, the URL of the template
url = "https://google.com"
# Optional, a list of authors for this template
authors = [
]
# Optional, a list of keywords for this template
keywords = [
]
# Optional, those files will NOT be copied over when generating the template
# Use it to remove template-specific like its CI or its README/docs
ignore = [
"README.md",
"CONTRIBUTING.md",
".travis.yml",
"docs",
]
# If this is set, kickstart will use this directory as a base for the template instead of
# the root directory. This is useful when your template has its own documentation/CI/etc and you don't want
# to ignore it.
directory = "some-directory"
# Optional, a list of patterns. All files matching one of the patterns will
# be copied over without going through Tera.
# Use it for files that contain syntax similar to Tera for example
copy_without_render = [
"*.html",
]
# Optional, a list of cleanup actions to do.
# All paths listed will be deleted if the `name` has the value `value` after
# the questions have been answered and the project generated.
cleanup = [
{ name = "spa", value = true, paths = ["{{ project_name }}/templates/"]},
{ name = "auth_method", value = "none", paths = ["{{ project_name }}/docs/auth.md"]},
]
# A list of variables, the schema is explained in detail below
[[variables]]
name = "project_name"
default = "my-project"
prompt = "What is the name of this project?"
validation = "^([a-zA-Z][a-zA-Z0-9_-]+)$"
[[variables]]
name = "database"
default = "postgres"
prompt = "Which database do you want to use?"
choices = ["postgres", "mysql", "sqlite"]
[[variables]]
name = "pg_version"
default = "10.4"
prompt = "Which version of Postgres?"
choices = [
"10.4",
"10.3",
"10.2",
"10.1",
"9.6",
"9.5",
"9.4",
"9.3",
]
only_if = { name = "database", value = "postgres" }
[[variables]]
name = "auth_method"
default = "jwt"
prompt = "How are users going to be authenticated?"
choices = ["jwt", "sessions", "none"]
[[variables]]
name = "sentry"
default = true
prompt = "Do you want to add Sentry integration?"
[[variables]]
name = "spa"
default = false
prompt = "Is the frontend a SPA?"
[[variables]]
name = "js_framework"
default = "React"
prompt = "Which JS framework do you want to setup?"
choices = [
"React",
"Angular",
"Vue",
"None",
]
only_if = { name = "spa", value = true }
[[variables]]
name = "typescript"
default = true
prompt = "Do you want to use TypeScript?"
only_if = { name = "spa", value = true }
A variable has the following required fields:
name
: the name of the variable in Tera contextdefault
: the default value for that question, kickstart
uses that to deduce the type of that value (only string, bool and integer are currently supported)prompt
: the text to display to the userAnd three more optional fields:
choices
: a list of potential values, kickstart
will make the user pick oneonly_if
: this question will only be asked if the variable name
has the value value
validation
: a Regex pattern to check when getting a string valueCase conversion filters are provided (via heck):
upper_camel_case
: UpperCamelCasecamel_case
: lowerCamelCasesnake_case
: snake_casekebab_case
: kebab-caseshouty_snake_case
: SHOUTY_SNAKE_CASEtitle_case
: Title Caseshouty_kebab_case
: SHOUTY-KEBAB-CASEYou can use these like any other filter, e.g. {{variable_name | camel_case}}
.
$$
for filters in filenames/directoriesdirectory
field to change the template directory away from the current one--no-input
flag to the main command to generate a template from defaultsvalidate
commandvalidation
field to validate a string against a regexgit
command rather than git2 crate to avoid some build issuescleanup
field to template definition for post-generation cleanupvalidate
command to diagnose errors in a template.toml
file