March 18, 2021

tru.ID CLI: now with plugin support and a new development server plugin

Phil Leggetter
Developer Experience

For tru.ID to be successful we have to make you, the developer, successful. One of the ways we're doing this is by building and open-sourcing our developer tools. The tru.ID CLI is one such tool and today we're excited to share an update that will make getting started and building with tru.ID even easier.

The latest version of the tru.ID CLI comes with plugin support along with a new `server` plugin. This update will:

  • enable mobile developers to focus on getting started with tru.ID and integrating mobile authentication into existing mobile apps without having to setup a back-end (initially)
  • improve our Quick Start/Getting Started docs and tutorials by removing the need for back-end setup steps, so you can get to writing code or seeing an example in action ASAP
  • let you try out some examples directly from the development server

tru.ID CLI plugin support

Our CLI is built upon the fantastic Oclif Open CLI Framework by the folks at Heroku. Oclif comes with support for plugins via a "plugins" plugin, that enables you to build CLIs with a plugin architecture and also support plugins to be added and removed on the fly.

The ability to manage plugins on the fly lets us try out new functionality within our CLI without having to push a new main CLI release. It also opens up the possibility for you to build plugins that make you and other developers more productive.

To get started with our CLI run:

$ npm install -g @tru_id/cli


You can then run the following and you can now run a new `tru plugins` command.

$ tru plugins -h
list installed plugins

USAGE
$ tru plugins

OPTIONS
--core  show core plugins

EXAMPLE
$ tru plugins

COMMANDS
plugins:inspect    displays installation properties of a plugin
plugins:install    installs a plugin into the CLI
plugins:link       links a plugin into the CLI for development
plugins:uninstall  removes a plugin from the CLI
plugins:update     update installed plugins

As mentioned, the `tru plugins` command now lets us experiment with new features, and will allow others to contribute their own plugins.

The Development Server Plugin

Ordinarily, you would need to clone a git repository, configure the cloned application, install a localtunnel solution, start the server, and start the localtunnel. The localtunnel solution is required for mobile development because you'll likely want to try the application only connected to the mobile network and not a local network. All this feels like painful overhead – so we've simplified it.

With the release of the tru.ID CLI development server plugin we have removed a number of those steps by incorporating a development server and localtunnel solution within a CLI plugin. A big thanks to localtunnel.me for letting us use their awesome service.

With the tru.ID CLI installed, install the development server plugin:

$ tru plugins:install @tru_id/cli-plugin-dev-server

Create a tru.ID project:

$ tru projects:create "Amazing Mobile Auth" --project-dir path/to/project

Run the development server:

$ tru server -t --project-dir path/to/project

You'll then see your development server running with a localtunnel:

Loading standard configuration

configuration:

...

Starting localtunnel

Example app listening at http://localhost:8080

localtunnel: https://{generated-sub-domain}.loca.lt

You can then navigate to `http://localhost:8080` to see a basic page served by the dev server. You can also navigate to `https://{generated-sub-domain}.loca.lt` (`{generated-sub-domain}` will be an actual generated sub-domain) where you'll first see a prompt reminding you that `This website is served via a localtunnel`. After clicking `Click to Continue` you'll see the same site served via a public URL.

With the dev server up and running with a public URL, you can then focus on setting up one or all of our example applications:

Try it out / Provide feedback

We believe that this CLI feature and new plugin is one more step towards enabling you to be more successful on our platform, and we'd love to hear what you think. Please message us on Twitter or send us an email.