@tailor-platform/dev-cli
v0.4.2
Published
Tailor Platform CLI for frontend devs
Downloads
6,342
Maintainers
Keywords
Readme
@tailor-platform/dev-cli
With Tailor Platform dev CLI, you can:
- install required dependencies for building your own Tailor Platform apps
- start local devlopment stack, apply your manifest on it
Table of Contents
Installation
npm install -D @tailor-platform/dev-cli@preview
Once after your installation, tailordev
command will be available.
$ npx tailordev --help
Usage: tailordev [options] [command]
CLI for Tailor Platform application devs
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
reset [options] reset local environment
start [options] start local development environment
apply [options] apply manifest onto local environment
import [options] <paths...> import seed manifest (this needs minitailor running by `start` command)
install:deps [options] install required dependencies (tailorctl, cuelang)
uninstall:deps uninstall dependencies
help [command] display help for command
Usage
tailordev
CLI expects the following directory structure for example:
yourapp
├── pacakge.json
├── .tailordevenv.json
└── manifest
└── config
└── template
├── gateway.cue
├── pipelines.cue
├── stateflow.cue
└── tailordb.cue
1. Configuration
In this case you will need to have .tailordevenv.json
with the following content:
{
// The project name
"name": "stock-api",
// The directory path where contains the files specified by the following `target` array
"manifest": "manifest/config/template",
// File names to run cuelang on and apply
"target": ["gateway.cue", "pipelines.cue", "tailordb.cue", "stateflow.cue"]
}
This is the initial point to start out.
2. Install dependencies
Run npx tailordev install:deps
will install required binaries on your local. Those will be placed under ~/.local/share/tailordev
.
It is recommended to run this command as postinstall
in your package.json. You can remove those downloaded files by npx tailordev uninstall:deps
.
3. Spin up local environment
Run npx tailordev start
to start your local development envrionment. This needs docker-compose currently under the hood, so make sure it is installed and up on your machine.
start
command generates .tailordev
directory which has files generated by tailordev CLI. Those files will be generated every time in starting so can be ignored from your VCS.
You can also use --only-file
option to generate compose.yml in .tailordev
directory. This options is useful if you would like to run docker-compose manually.
4. Apply your manifest
Run npx tailordev apply
to apply your application manifest onto your local dev environment next.
This also runs Cuelang evaluation (same as cue eval
), and the evaluated files will be generated in .tailordev/generated
with the same directory structure as the one you specified in manifest
field in .tailordevrc.json
.
apply
command supports --env <value>
option to switch your manifest in evaluation. This internally works as attributes in Cuelang, so you will be able to switch values in manifest files with @if(<value>)
.
If you would just like to evaluate and generate manifest under .tailordev/generated
, you can use --only-eval
option that skips applying manifests onto local development environment.
Use as npm scripts
As tailordev CLI is built with Node.js, it will be good fit to have it in your package.json scripts as well as other tools like Next.js.
{
"name": "yourapp",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"start:backend": "tailordev start",
"apply": "tailordev apply",
"reset": "tailordev reset",
"postinstall": "tailordev install:deps"
}
}