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

node-ray-cli

v1.1.0

Published

Debug cli scripts with ray to fix problems faster

Downloads

3

Readme

node-ray-cli


Overview

This npm package provides a ray script that lets you control Spatie's Ray app from the command line. It allows you to easily debug your CLI scripts.

Installation

Install the package normally with npm:

npm install node-ray-cli

...install it globally to be able to access it from any script/directory:

npm install -g node-ray-cli

...or run it without installing using npx:

npx node-ray-cli --help

Usage

ray <command name> <args, ...>

If no command name is specified, send is assumed.

image

When calling commands that send modifiable payloads, the payload uuid is sent to stdout if the --show-uuid option flag is provided. For example, you may modify the color of a payload after it has been sent by using the color command:

ray 'hello world' --show-uuid # writes "ae625128-ed3a-2b92-1a3f-2e0ebf7a2ad1" to stdout
ray color ae625128-ed3a-2b92-1a3f-2e0ebf7a2ad1 green

...or remove the payload from Ray entirely:

ray 'hello world' --show-uuid # writes "ae625128-ed3a-2b92-1a3f-2e0ebf7a2ad1" to stdout
ray remove ae625128-ed3a-2b92-1a3f-2e0ebf7a2ad1

Some other usage examples:

ray 'hello world' --blue
ray pause
ray html '<em>hello world</em>'
ray file message.txt

Disabling node-ray-cli

The ray command can be disabled by setting the NODE_RAY_DISABLED environment variable to "1":

export NODE_RAY_DISABLED="1"

Available option flags

There are several option flags that can be used with any command:

| Flag | Description | | --- | --- | | --hide | Display the payload as collapsed by default | | --if=value | Don't send the payload if value is "false", 0, or "no" | | --large | Display large text | | --show-uuid | Write the payload uuid to stdout | | --small | Display small text | | --blue | Display the payload as blue | | --gray | Display the payload as gray | | --green | Display the payload as green | | --orange | Display the payload as orange | | --purple | Display the payload as purple | | --red | Display the payload as red |

Command reference

| Command | Description | | --- | --- | | clear | Clear the current screen | | clear-all | Clear the current and all previous screens | | color <uuid> <color> | Change the color of a payload that has already been sent | | confetti | Display confetti in Ray! | | file <filename> | Show the contents of filename | | hide-app | Hide the Ray app | | html <content> | Display rendered html | | image <location> | Display an image from a URL or file | | json <content> | Display formatted JSON | | notify <message> | Display a desktop notification | | pause | Pause code execution | | remove <uuid> | Remove a payload | | send <payload> | Send a payload to Ray | | show-app | Show the Ray app | | size <uuid> <size> | Change the text size of a payload that has already been sent (sizes are 'large' or 'small') | | text <data> | Display a text string with whitespace preserved | | xml <data> | Display formatted XML |

Example Bash Script

#!/bin/bash

RAYUUID=$(ray "arg count: $#" --show-uuid)
ray color $RAYUUID blue

if [ $# -eq 0 ]; then
    echo "no filename provided"
    exit 1
fi

FILENAME="$1"

ray "$FILENAME"
ray file "$FILENAME" --purple --small --hide
ray show-app

if [ ! -e "$FILENAME" ]; then
    ray send "file missing: $FILENAME" --red
    exit 1
fi

ray pause

cat "$FILENAME" | wc -l

Development Setup

npm install
npm run build:dev
node dist/index.js --help

Testing

node-ray-cli uses Jest for unit tests. To run the test suite:

npm run test


Code Coverage


Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.