npm package: @jcrafts/ldscli
Description: A CLI for LDS adapter authors!
Latest version: 0.0.1

# LDS Luvio.raml Wizard

The LDS wizard is an SDFX command that automatically creates a functional `luvio.raml` from an existing `api.raml`.

For more information on RAML and how Luvio uses it, please refer to the Luvio documentation (https://luvio-docs.herokuapp.com/guide/quick-start#raml-overview).

Invoke the CLI with the following command:

`$ ldscli lds:generate ./api.raml`

The wizard asks a series of questions to determine certain output features of `luvio.raml` and generates a `luvio.raml` file to the same directory as the input `api.raml` file.

## Arguments

`<apiRamlPath>` - a positional argument to denote the location of the input api.raml file

* `--defaults` - uses default values for luvio.raml type annotations. This argument sets a `luvio.ttl` to 15 seconds and omits `luvio.opaque` and `luvio.key` properties.

* `--force` - forces overwrite of an existing `luvio.raml` file without asking for confirmation
---
## Usage examples

### Basic case

This command processes the `api.raml` file and creates a `luvio.raml` file in the same directory.

`$ ldscli lds:generate ./api.raml`

The CLI returns a series of prompts similar to the following:

```
-----------------------
Define Type Annotations
-----------------------

TodoList
==========
? How often does this data change? (Use arrow keys)
  Every second 
  Every 5 seconds 
❯ Every 15 seconds 
  Every minute 
  Every 5 minutes 
  Every 15 minutes
  
 ? Should this type be stored as a blob? (luvio will not normalize its properties) (Y/n) 
 
 ? Select the luvio.key properties
 (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯◯ items
```

### Overwrite without asking

To overwrite a `luvio.raml` file that already exists without prompting whether the user wants to overwrite it or not, run the following command:

`$ ldscli lds:generate ./api.raml --force`

### Overwrite prompt

If a `luvio.raml` file already exists alongside the input `api.raml`, you can overwrite the file by running this command:

`$ ldscli lds:generate ./api.raml`

The following prompt appears:

`./luvio.raml already exists. Do you wish to overwrite? (Y/n): `

An input of Y (or y) confirms overwrite, any other input will cancel and exit the wizard.

### Use default values

To use default values and skip prompts for luvio type annotations, run the following command:

`$ ldscli lds:generate ./api.raml --defaults`

---
## Future enhancements

* Partial processing of an `api.raml` file (i.e., user-chosen resources to process)
* Ability to save and resume progress



<!-- [![Version](https://img.shields.io/npm/v/ldscli.svg)](https://npmjs.org/package/ldscli)
[![CircleCI](https://circleci.com/gh/ciaran.hannigan/ldscli/tree/master.svg?style=shield)](https://circleci.com/gh/ciaran.hannigan/ldscli/tree/master)
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/ciaran.hannigan/ldscli?branch=master&svg=true)](https://ci.appveyor.com/project/heroku/ldscli/branch/master)
[![Greenkeeper](https://badges.greenkeeper.io/ciaran.hannigan/ldscli.svg)](https://greenkeeper.io/)
[![Known Vulnerabilities](https://snyk.io/test/github/ciaran.hannigan/ldscli/badge.svg)](https://snyk.io/test/github/ciaran.hannigan/ldscli)
[![Downloads/week](https://img.shields.io/npm/dw/ldscli.svg)](https://npmjs.org/package/ldscli)
[![License](https://img.shields.io/npm/l/ldscli.svg)](https://github.com/ciaran.hannigan/ldscli/blob/master/package.json) -->

<!-- toc -->
* [LDS Luvio.raml Wizard](#lds-luvioraml-wizard)
<!-- tocstop -->
<!-- install -->
<!-- usage -->
```sh-session
$ npm install -g @jcrafts/ldscli
$ sfdx COMMAND
running command...
$ sfdx (--version)
@jcrafts/ldscli/0.0.1 darwin-x64 node-v14.20.0
$ sfdx --help [COMMAND]
USAGE
  $ sfdx COMMAND
...
```
<!-- usagestop -->
<!-- commands -->
* [`sfdx lds:generate [-d] [-f] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-ldsgenerate--d--f---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)

## `sfdx lds:generate [-d] [-f] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

generates luvio.raml from supplied api.raml

```
USAGE
  $ sfdx lds:generate [-d] [-f] [--json] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

ARGUMENTS
  APIRAMLPATH  Location of api.raml used for generating luvio.raml

FLAGS
  -d, --defaults                                                                    Use defaults for type annotations
                                                                                    (TTL=1000)
  -f, --force                                                                       Force overwrite of luvio.raml
  --json                                                                            format output as json
  --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)  [default: warn] logging level for
                                                                                    this command invocation

DESCRIPTION
  generates luvio.raml from supplied api.raml

EXAMPLES
  $ ldscli lds:generate [apiRamlPath]
```

_See code: [src/commands/lds/generate.ts](https://github.com/salesforce-experience-platform-emu/ldscli/blob/v0.0.1/src/commands/lds/generate.ts)_
<!-- commandsstop -->
<!-- debugging-your-plugin -->
<!-- # Debugging your plugin
We recommend using the Visual Studio Code (VS Code) IDE for your plugin development. Included in the `.vscode` directory of this plugin is a `launch.json` config file, which allows you to attach a debugger to the node process when running your commands.

To debug the `lds:org` command: 
1. Start the inspector
  
If you linked your plugin to the sfdx cli, call your command with the `dev-suspend` switch: 
```sh-session
$ sfdx lds:org -u myOrg@example.com --dev-suspend
```
  
Alternatively, to call your command using the `bin/run` script, set the `NODE_OPTIONS` environment variable to `--inspect-brk` when starting the debugger:
```sh-session
$ NODE_OPTIONS=--inspect-brk bin/run lds:org -u myOrg@example.com
```

2. Set some breakpoints in your command code
3. Click on the Debug icon in the Activity Bar on the side of VS Code to open up the Debug view.
4. In the upper left hand corner of VS Code, verify that the "Attach to Remote" launch configuration has been chosen.
5. Hit the green play button to the left of the "Attach to Remote" launch configuration window. The debugger should now be suspended on the first line of the program. 
6. Hit the green play button at the top middle of VS Code (this play button will be to the right of the play button that you clicked in step #5).
<br><img src=".images/vscodeScreenshot.png" width="480" height="278"><br>
Congrats, you are debugging! -->