npm package: @snab/cli
Description: snab cli
Author: Juan Coll
Latest version: 0.0.3

Snab cli
=================

Snab Cli for 
- backend code generation
- frontend code generation and language 
- deploy tools 

[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![CircleCI](https://circleci.com/gh/oclif/hello-world/tree/main.svg?style=shield)](https://circleci.com/gh/oclif/hello-world/tree/main)
[![GitHub license](https://img.shields.io/github/license/oclif/hello-world)](https://github.com/oclif/hello-world/blob/main/LICENSE)

<!-- toc -->
* [Usage](#usage)
* [Commands](#commands)
* [Developers](#developers)
* [or](#or)
* [Ensure that all is working. It's recommended to create a test foreach command](#ensure-that-all-is-working-its-recommended-to-create-a-test-foreach-command)
* [1. increment version](#1-increment-version)
* [2. update readme file](#2-update-readme-file)
* [3. publish package](#3-publish-package)
* [or](#or-1)
<!-- tocstop -->
* [Developers](#developers)
# Usage
<!-- usage -->
```sh-session
$ npm install -g @snab/cli
$ snab COMMAND
running command...
$ snab (--version)
@snab/cli/0.0.3 win32-x64 node-v16.20.2
$ snab --help [COMMAND]
USAGE
  $ snab COMMAND
...
```
<!-- usagestop -->
# Commands
<!-- commands -->
* [`snab demo fs NAME`](#snab-demo-fs-name)
* [`snab demo input`](#snab-demo-input)
* [`snab demo params`](#snab-demo-params)
* [`snab demo processing`](#snab-demo-processing)
* [`snab deploy`](#snab-deploy)
* [`snab help [COMMANDS]`](#snab-help-commands)
* [`snab plugins`](#snab-plugins)
* [`snab plugins:install PLUGIN...`](#snab-pluginsinstall-plugin)
* [`snab plugins:inspect PLUGIN...`](#snab-pluginsinspect-plugin)
* [`snab plugins:install PLUGIN...`](#snab-pluginsinstall-plugin-1)
* [`snab plugins:link PLUGIN`](#snab-pluginslink-plugin)
* [`snab plugins:uninstall PLUGIN...`](#snab-pluginsuninstall-plugin)
* [`snab plugins:uninstall PLUGIN...`](#snab-pluginsuninstall-plugin-1)
* [`snab plugins:uninstall PLUGIN...`](#snab-pluginsuninstall-plugin-2)
* [`snab plugins update`](#snab-plugins-update)
* [`snab service add action`](#snab-service-add-action)
* [`snab service add event`](#snab-service-add-event)
* [`snab service create`](#snab-service-create)
* [`snab web form create`](#snab-web-form-create)
* [`snab web lang check`](#snab-web-lang-check)
* [`snab web lang clean`](#snab-web-lang-clean)

## `snab demo fs NAME`

show how to use data files as templates or plain files

```
USAGE
  $ snab demo fs NAME

ARGUMENTS
  NAME  Custom Name

DESCRIPTION
  show how to use data files as templates or plain files
```

_See code: [dist/commands/demo/fs/index.ts](https://github.com/cli/cli/blob/v0.0.3/dist/commands/demo/fs/index.ts)_

## `snab demo input`

User input demo

```
USAGE
  $ snab demo input

DESCRIPTION
  User input demo
```

_See code: [dist/commands/demo/input/index.ts](https://github.com/cli/cli/blob/v0.0.3/dist/commands/demo/input/index.ts)_

## `snab demo params`

Command Arguments and Flags demo

```
USAGE
  $ snab demo params FIRSTARG [SECONDARG] -t <value> [-f]

FLAGS
  -f, --from        test flag from
  -t, --to=<value>  (required) test flag to

DESCRIPTION
  Command Arguments and Flags demo
```

_See code: [dist/commands/demo/params/index.ts](https://github.com/cli/cli/blob/v0.0.3/dist/commands/demo/params/index.ts)_

## `snab demo processing`

Spinner (waiters) messages demo

```
USAGE
  $ snab demo processing

DESCRIPTION
  Spinner (waiters) messages demo
```

_See code: [dist/commands/demo/processing/index.ts](https://github.com/cli/cli/blob/v0.0.3/dist/commands/demo/processing/index.ts)_

## `snab deploy`

deploy command

```
USAGE
  $ snab deploy

DESCRIPTION
  deploy command
```

_See code: [dist/commands/deploy/index.ts](https://github.com/cli/cli/blob/v0.0.3/dist/commands/deploy/index.ts)_

## `snab help [COMMANDS]`

Display help for snab.

```
USAGE
  $ snab help [COMMANDS] [-n]

ARGUMENTS
  COMMANDS  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for snab.
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.19/src/commands/help.ts)_

## `snab plugins`

List installed plugins.

```
USAGE
  $ snab plugins [--json] [--core]

FLAGS
  --core  Show core plugins.

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  List installed plugins.

EXAMPLES
  $ snab plugins
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.4.2/src/commands/plugins/index.ts)_

## `snab plugins:install PLUGIN...`

Installs a plugin into the CLI.

```
USAGE
  $ snab plugins:install PLUGIN...

ARGUMENTS
  PLUGIN  Plugin to install.

FLAGS
  -f, --force    Run yarn install with force flag.
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Installs a plugin into the CLI.
  Can be installed from npm or a git url.

  Installation of a user-installed plugin will override a core plugin.

  e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
  will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
  the CLI without the need to patch and update the whole CLI.


ALIASES
  $ snab plugins add

EXAMPLES
  $ snab plugins:install myplugin 

  $ snab plugins:install https://github.com/someuser/someplugin

  $ snab plugins:install someuser/someplugin
```

## `snab plugins:inspect PLUGIN...`

Displays installation properties of a plugin.

```
USAGE
  $ snab plugins:inspect PLUGIN...

ARGUMENTS
  PLUGIN  [default: .] Plugin to inspect.

FLAGS
  -h, --help     Show CLI help.
  -v, --verbose

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Displays installation properties of a plugin.

EXAMPLES
  $ snab plugins:inspect myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.4.2/src/commands/plugins/inspect.ts)_

## `snab plugins:install PLUGIN...`

Installs a plugin into the CLI.

```
USAGE
  $ snab plugins:install PLUGIN...

ARGUMENTS
  PLUGIN  Plugin to install.

FLAGS
  -f, --force    Run yarn install with force flag.
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Installs a plugin into the CLI.
  Can be installed from npm or a git url.

  Installation of a user-installed plugin will override a core plugin.

  e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
  will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
  the CLI without the need to patch and update the whole CLI.


ALIASES
  $ snab plugins add

EXAMPLES
  $ snab plugins:install myplugin 

  $ snab plugins:install https://github.com/someuser/someplugin

  $ snab plugins:install someuser/someplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.4.2/src/commands/plugins/install.ts)_

## `snab plugins:link PLUGIN`

Links a plugin into the CLI for development.

```
USAGE
  $ snab plugins:link PLUGIN

ARGUMENTS
  PATH  [default: .] path to plugin

FLAGS
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Links a plugin into the CLI for development.
  Installation of a linked plugin will override a user-installed or core plugin.

  e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
  command will override the user-installed or core plugin implementation. This is useful for development work.


EXAMPLES
  $ snab plugins:link myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.4.2/src/commands/plugins/link.ts)_

## `snab plugins:uninstall PLUGIN...`

Removes a plugin from the CLI.

```
USAGE
  $ snab plugins:uninstall PLUGIN...

ARGUMENTS
  PLUGIN  plugin to uninstall

FLAGS
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Removes a plugin from the CLI.

ALIASES
  $ snab plugins unlink
  $ snab plugins remove
```

## `snab plugins:uninstall PLUGIN...`

Removes a plugin from the CLI.

```
USAGE
  $ snab plugins:uninstall PLUGIN...

ARGUMENTS
  PLUGIN  plugin to uninstall

FLAGS
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Removes a plugin from the CLI.

ALIASES
  $ snab plugins unlink
  $ snab plugins remove
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.4.2/src/commands/plugins/uninstall.ts)_

## `snab plugins:uninstall PLUGIN...`

Removes a plugin from the CLI.

```
USAGE
  $ snab plugins:uninstall PLUGIN...

ARGUMENTS
  PLUGIN  plugin to uninstall

FLAGS
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Removes a plugin from the CLI.

ALIASES
  $ snab plugins unlink
  $ snab plugins remove
```

## `snab plugins update`

Update installed plugins.

```
USAGE
  $ snab plugins update [-h] [-v]

FLAGS
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Update installed plugins.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.4.2/src/commands/plugins/update.ts)_

## `snab service add action`

create a service action for and existing service

```
USAGE
  $ snab service add action

DESCRIPTION
  create a service action for and existing service
```

_See code: [dist/commands/service/add/action/index.ts](https://github.com/cli/cli/blob/v0.0.3/dist/commands/service/add/action/index.ts)_

## `snab service add event`

create a service event for and existing service

```
USAGE
  $ snab service add event

DESCRIPTION
  create a service event for and existing service
```

_See code: [dist/commands/service/add/event/index.ts](https://github.com/cli/cli/blob/v0.0.3/dist/commands/service/add/event/index.ts)_

## `snab service create`

create a service skeleton

```
USAGE
  $ snab service create

DESCRIPTION
  create a service skeleton
```

_See code: [dist/commands/service/create/index.ts](https://github.com/cli/cli/blob/v0.0.3/dist/commands/service/create/index.ts)_

## `snab web form create`

Create forms files

```
USAGE
  $ snab web form create

DESCRIPTION
  Create forms files
```

_See code: [dist/commands/web/form/create/index.ts](https://github.com/cli/cli/blob/v0.0.3/dist/commands/web/form/create/index.ts)_

## `snab web lang check`

check json langs files vs code used keys

```
USAGE
  $ snab web lang check

DESCRIPTION
  check json langs files vs code used keys
```

_See code: [dist/commands/web/lang/check/index.ts](https://github.com/cli/cli/blob/v0.0.3/dist/commands/web/lang/check/index.ts)_

## `snab web lang clean`

clean json langs files vs code used keys

```
USAGE
  $ snab web lang clean

DESCRIPTION
  clean json langs files vs code used keys
```

_See code: [dist/commands/web/lang/clean/index.ts](https://github.com/cli/cli/blob/v0.0.3/dist/commands/web/lang/clean/index.ts)_
<!-- commandsstop -->

# Developers
- use always pnpm as package manager ([see pnpm page](https://pnpm.io/))

## 1. Start
```shell
> pnpm dev # execute tsc watch. Build and update /dist folder on any code change  
``` 
## 2. Create your custom command
- under [src/commands] creates a folder "mycommand" 
- under [src/commands/mycommand] creates a new file index.ts 
- in file index.ts
```typescript
// in mycommand/index.ts
// ...
// BaseCommand is a Snab base Command with some utilities
export default class MyCommand extends BaseCommand<typeof MyCommand> {
    static description = 'show how to use data files as templates or plain files'
    static args = { /** my command args */ }
    static flags = { /** my command flags */ }
    static samples = [] /**  array of command use */ 

     async run(): Promise<any> {
        // 1.  in/out folders 
        // 1.1 Sepcific Files used by command
        // Use DataFolder to point to some specific data templates or files
        // All command templates or files must be allocated under "data/commands/mycommand"
        // 2 system folders must be created 
        //   - templates > files used as templates
        //   - files > unchanged files (normally files to be copied)

        const data = new DataFolder(__dirname)
        if (!data.exists()) {
            this.error('data folder not found')
            this.exit(-1)
        }

        // 1.2 output folder. In this case we point to folder where the command is executed
        // this.cwd = folder where the command is executed
        const out1 = new Folder(this.cwd).open
        // if ouput folder is a specific subfolder unders the cwd use
        const out2 = new Folder(this.cwd).folderOpen(name,{create: true})

        // 2. your code 

        throw new Error("Method not implemented.");
    }
}
```
- More command demos found under /src/commands/demo

## execute
### options 1
- for testing execution use
```shell
pnpm try mycommand
# or
./bin/run mycommand
``` 
### options 2
- install current package with npm link
```Shell
pnpm install # creates a symlink forder as global for this package
snab mycommand
```
## debug
- creates a new entry on .vscode/launch.json
```json
...
{
      "type": "node",
      "request": "launch",
      "name": "mycommand",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "program": "${workspaceFolder}/bin/dev",
      "args": [
        "mycommand",
        "[args]",        
        "[flags]",
      ],
    },
...
```
- and press F5

## publish
```Shell 
# Ensure that all is working. It's recommended to create a test foreach command
# 1. increment version 
npm version patch # or minor | major
# 2. update readme file 
npx oclif readme
# 3. publish package
npm publish  --access public --no-git-checks

# or 
pnpm npm:publish-patch # execute the 3 commands 
```
- ! Don't forget to commit your changes