npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lynn-cli

v1.0.0

Published

A command line app for executing lynn requests

Downloads

50

Readme

lynn-cli

npm (scoped) npm bundle size (minified)

Lynn-cli is a command line interface that utilizes the lynn module to perform network requests. It can execute the requests and generate documentation from the request definitions.

Lynn-cli works not just with single requests, but you can create entire flows that can be tested from a single invocation. This is helpful when you have a sequence of API calls that need to be made and the data from a parent call is used in child calls.

Api details are contained in a folder structure that can be managed in a source control system. All the request and flow details are simple json documents that are easily maintained in the editor of your choice.

Install

npm install -g lynn-cli

Getting Started

Please see the Getting Started Guide

Usage

Interactive mode:

lynn-cli

Change the default working folder from ~/.lynn to a specific folder:

lynn-cli --workingFolder <path>

Set the project (aka subfolder) if your working folder contains multiple top level folders:

lynn-cli --project <project>

Add variables to the initial request environment (this can be a comma separated list of files). File paths are relative to the working folder + project and are located in the environment subfolder:

lynn-cli --environment <filename(s)>

Turn on auto saving of requests (output goes into the log subfolder of your current workingFolder + project directory):

lynn-cli --autoSave true

Execute a single request. Requests are found in the requests sub-folder and are json files that contain all the details related to executing and documenting the request.

lynn-cli --request <requestfile>

Execute a series of requests (aka flow). Flows are found in the flows sub-folder and are json files that describe which request to execute and how to execute additional reqests (perhaps with data collected from the initial request).

lynn-cli --flow <flowfile>

Interactive mode commands

Note: you can specify workingFolder, project, autoSave and environment from the command line when using interactive mode. All other parameters are ignored when using interactive mode (but are available inside the interactive mode itself).

Execute a request:

lynn-cli> request <request>

Repeat the last request again:

lynn-cli> request -l

Execute a flow (press control-c to return to the command prompt after the flow has finished):

lynn-cli> flow <flow>

Change the project:

lynn-cli> project <projectName>

Add details from an environment file (located in the lynn folder environment of the current project):

lynn-cli> environment <environmentName>

Reset the current environment and any previously executed requests:

lynn-cli> reset

View the response of the previous request. Key is optional and can contain one of the following vaules: [options, statusCode, headers, data, error, responseTime]:

lynn-cli> response [key]

Turn auto save on/off:

lynn-cli> autoSave <true/false>

Execute a jsonpath query inside the response data. See jsonpath node library for more details on allowed paths:

lynn-cli> query <jsonpath>

Display the contents of the current environment:

lynn-cli> environment

Set a variable into the current environment:

lynn-cli> set <variable> <value>

Generate markdown documentation for the API project. Note this creates a README.md in the root of the project folder, along with a /docs sub-folder.

lynn-cli> generate

List all the paths found in the response data:

lynn-cli> schema

List all the paths found in the response data in a format that can be copy/pasted into the request docs section:

lynn-cli> schema -d

Show the current config as set by the command line parameters and environment:

lynn-cli> config

Config

Any parameters that you specify on the command line are always used, but you can provide defaults for these parameters in the following ways:

Common .lynnrc file

For defaults that apply machine wide, you can create a default config file in one of the following locations:

$HOME/.lynnrc
$HOME/.lynn/config
$HOME/.config/lynn
$HOME/.config/lynn/config
/etc/lynnrc
/etc/lynn/config

Note that this is the order of importance so a file located in $HOME/.lynnrc will overwrite any default found in any of the other locations.

The config file should be a json file and has a basic structure that matches the possible command line parameters:

{
  "workingFolder": "",
  "environment": "",
  "autoSave": true,
  "project": ""
}

Note you only need to specify the parameters you want to provide defaults for in this file.

A .lynnrc file in the folder you invoke lynn-cli from

Any .lynnrc file found in the current directory will also be used and will overwrite any defaults specified in your ~/.lynnrc file. The format of the file is the same.

Also the system will look in ../ and any parent folder up to the root for any .lynnrc file, but only the first one found will be used and considered a local config file (ie: it will overwrite any config found in the machine/user wide config files above).

Environment variables

If you have environment variables for any of the parameters they will overwrite any defaults provided in the .lynnrc files above. Environment variables can be one of the following:

lynn_workingFolder lynn_environment lynn_autoSave lynn_project