NixΒ² CLI
this cli will allow nixΒ² developers to easily create, modify, and maintain their services
[ Installation πΎ | Usage π€ | NPM π¦ | Github πΈ ]
All you need is to install is node
$ npm i -g @nix2/nix-cli
The basic command is nix-cli
which if you are using the zsh plugin you are given an alias of dev
.
The rest of the documentation uses dev
but should be the same for nix-cli
.
When running the command with no arguments, it will default to dev info
.
This CLI is built with commander.js, which generates help screens based off the structure of the application.
To get help on any commands, just run dev help
.
$ dev help
Usage: nix-cli [options] [command]
Options:
-v output cli version
-h, --help display help for command
Commands:
auth authenticate to a user account
info display service context info
init [options] [dirname] initialize a service
make make things related to your service
authors manage your authors
cache manage your cache
help [command] display help for command
Authenticate the CLI user.
NOTE This is currently WIP so it is a mock authentication.
Initialize a service.
The init command needs to be provided a service type. If there is no service provided as the agument, it will prompt the user to select all the valid service types from a list.
Here are the two ways you can initialize.
$ dev init
? Select the type
> typescript
graphql
$ dev init graphql
After selecting the service type, it will prompt you on filling in details for the service. Each service has different initialize data but there are four options that all are asked for, no matter the service type.
Name | Description | Default |
---|---|---|
identifier |
Service Identifier | Taken from the directory name |
label |
Service Label (for humans) | Taken from the service ID |
description |
Service Description | "A NixΒ² Service" |
userLeadDev |
Makes the user the leadDev |
true |
The info command will give you basic info on your current Service Context.
$ dev info
Nix2 CLI version 1.0.1
local data from service.yaml
|
| Blog (blog)
| The blog service
| v1.0.0 - 1 dev
|
The make
command allows a developer to make certain services that are supported by a service. The access to files that can be created with make
depends on your plugin configuration. Each service has different files that can be created with make
but there are still some files that are avaliable with all plugins.
Name | File | Description |
---|---|---|
readme |
README.md |
Creates a README file. |
gitignore |
.gitignore |
Creates a .gitignore |
The database command or db
, allows a developer to create, modify, deploy, maintain, and retire a service's database.
Nix2 uses FaunaDB for databases.
Authenticates yourself with FaunaDB.
Lists all the Nix2 databases.
Creates a service database.
Links a service with a database.
Functionality for controlling service schemas.
Lists basic info for the service's schemas.
A shortcut for this command is dev schemas
$ dev schemas list
Displaying 1 schema
ββββββββ¬ββββββββ¬ββββββββββββββ
β ID β Label β Description β
ββββββββΌββββββββΌββββββββββββββ€
β user β User β A Serv User β
ββββββββ΄ββββββββ΄ββββββββββββββ
Add schemas by their ID.
$ dev schemas add user
β About to write to service.yaml
identifier: 'user'
label: 'User'
pluralName: 'users'
fields:
? Proceed with adding schema? Yes
β Schema user added
Remove schemas by their id.
$ dev schemas remove user
β About to write to service.yaml
identifier: 'user'
label: 'User'
pluralName: 'users'
fields:
? Proceed with removing user? Yes
β Schema user removed
You can also use the -y
flag to skip the confirmation screen.
Functionality for controlling service authors.
Lists basic info for the service's authors.
A shortcut for this command is dev authors
$ dev authors list
Displaying 2 authors
ββββββββββββββββββββββββ¬βββββββββββ¬ββββββββββ
β Email β Name β Flags β
ββββββββββββββββββββββββΌβββββββββββΌββββββββββ€
β maxk@nix2.io β Max Koon β leadDev β
ββββββββββββββββββββββββΌβββββββββββΌββββββββββ€
β support@nix2.io β Support β support β
ββββββββββββββββββββββββ΄βββββββββββ΄ββββββββββ
Add authors by their email.
$ dev authors add m@x.com
β About to write to service.yaml
{
email: 'm@x.com',
name: 'Max',
publicEmail: null,
url: null,
alert: 'none',
flags: [ 'dev' ]
}
? Proceed with adding author? Yes
β Author m@x.com added
To add data to author you can use different parameters which can be listed with help flag.
This will return:
$ dev authors add --help
Usage: nix-cli authors add [options] <email>
Options:
-n, --authorName [name] name of the author
-E, --publicEmail [publicEmail] email to use for the public
-u, --url [url] author url
-a, --alert [alert] alert options
-p, --public set the public flag
-d, --dev developer flag
-D, --ldev lead dev flag
-s, --support support flag
-y, --yes skip the confirmation screen
-h, --help display help for command
NOTE Each author's data is cached for the most recent usage so you don't need to retype all these parameters each time you add an author. To clear cache please read this
Remove authors by their email.
$ dev authors remove m@x.com
β About to write to service.yaml
{
email: 'm@x.com',
name: 'Max',
publicEmail: null,
url: null,
alert: 'none',
flags: [ 'dev' ]
}
? Proceed with removing author? Yes
β Author m@x.com removed
You can also use the -y
flag to skip the confirmation screen.
Plugins were added in version 1.1.0, and enhances the scalability of the CLI, and allow for core functions to be separate from the services.
You can manage plugins with the plugin
command.
$ dev plugins list
----------
graphql
typescript
----------
$ dev plugins add typescript
β Installed typescript
$ dev plugins remove typescript
β Removed typescript
$ dev plugins update *
β Updated typescript
β Updated graphql
The Nix Plugin Registry is the container of all plugin information. Information including names, descriptions, and versions.
The NPR runs on the npr repository. It functions completely with github actions.
There are multiple environments for deployed services such as development and production.
With the env
command you can manage your selected environment
List all the available environments
$ dev env list
------------
- prod
- dev (selected)
------------
$ dev env prod
β switched to env: 'prod'
Service versioning follows Semantic Versioning
To get the current version you can run
$ dev version
The 'example-service' is on version 2.0.1
You can bump the version manually by doing:
$ dev version 2.0.2
Updated version to 2.0.2
You can also bump with patch
, minor
, or major
.
$ dev version minor
Updated version to 2.1.0
Updates the CLI with yarn.
$ dev update
β Updated the CLI
To clear all the cache use:
$ dev cache clear