sls-invoke

Ability to configure json to allow for easier and quicker usage of sls invoke


Keywords
serverless, invoke, watch, json, fixtures, configure, quick
License
OPL-1.0
Install
npm install sls-invoke@0.0.2

Documentation

sls-invoke

Ability to configure json to allow for easier and quicker usage of sls invoke:

  • auto-complete suggestions
  • can be used on multi-serverless projects

Installation:

This library requires serverless be installed globally, if it has not been installed please do the following.

yarn:

yarn global add serverless
yarn add sls-invoke

npm:

npm install -g serverless
npm install --save-dev sls-invoke

Configuration Arguments:

{
  invoke: string, 
  watch: boolean,
  dry: boolean,
  fixtures: string,
  yml: string,
  stage: string,
}

Valid Arguments:

  • invoke: local | remote

    whether to invoke the function locally or remotely

  • watch: true | false

    configure if the changes to a function or fixture will trigger a re-run

  • dry: true | false

    whether the lambda should be invoked or not, useful for debugging

  • fixtures: location of directory ex) 'json', 'fixtures'

    the directory where path data exists, commonly json or fixtures, Note) do not end directory with '/'

  • yml: serverless.yml file

    this can be used to reference a specific yaml file, useful for mulit-serverless projects

  • stage: any

    invokes the function with a specific stage

Usage:

Create a configurable json file that sls-invoke can use to construct the invocation prompts. local.json

{
    "invoke": "local",
    "watch": true, 
    "fixtures": "./json",
    "yml": "./serverless.yml"
}

After the json is created, then we can reference it in scripts:

package.json

{
    "scripts": {
        "invoke:local": "sls-invoke local.json",
    }
}

Example Output:

Note: Using tab, to auto-complete suggestions is built in, typing 'my' + tab will complete to myfunk

user$ Select the function name:
user$    myfunk
user$ Select the fixture name:
user$   input.json
user$ Calling: serverless invoke local --watch --function myfunk --path ./json/input.json
user$ // severless doing its thing