0.0.3 • Published 8 months ago

@snab/cli v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Snab cli

Snab Cli for

  • backend code generation
  • frontend code generation and language
  • deploy tools

oclif CircleCI GitHub license

Usage

$ 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
...

Commands

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

snab demo input

User input demo

USAGE
  $ snab demo input

DESCRIPTION
  User input demo

See code: 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

snab demo processing

Spinner (waiters) messages demo

USAGE
  $ snab demo processing

DESCRIPTION
  Spinner (waiters) messages demo

See code: dist/commands/demo/processing/index.ts

snab deploy

deploy command

USAGE
  $ snab deploy

DESCRIPTION
  deploy command

See code: 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

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

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

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

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

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

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

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

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

snab service create

create a service skeleton

USAGE
  $ snab service create

DESCRIPTION
  create a service skeleton

See code: 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

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

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

Developers

1. Start

> pnpm dev # execute tsc watch. Build and update /dist folder on any code change  

2. Create your custom command

// 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
pnpm try mycommand
# or
./bin/run mycommand

options 2

  • install current package with npm link
pnpm install # creates a symlink forder as global for this package
snab mycommand

debug

  • creates a new entry on .vscode/launch.json
...
{
      "type": "node",
      "request": "launch",
      "name": "mycommand",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "program": "${workspaceFolder}/bin/dev",
      "args": [
        "mycommand",
        "[args]",        
        "[flags]",
      ],
    },
...
  • and press F5

publish

# 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