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

bash-xops

v1.0.1

Published

A library for executing bash ops through ssh with expect prior to node.js installation on remotes

Downloads

1

Readme

bash-xops

A library for executing bash ops through ssh with expect prior to node.js installation on remotes.

rational

Since, node.js will likely not be installed on a new machine instance in some cloud, or personal cloud, it helps to have some bash commands that call upon expect to run remote scripts requiring entering user names and passwords.

The methods need to send scripts to the remote computers to run, but under the authorization of ssh. The scripts can do things like install node.js, npm, n, git, etc. Once the system is ready to be used, other services can take over more with sophisticated methods for relaying assets.

The user will likely use node.js from his own computer. So, this package wraps the bash scripts so that they can be called out of node.js tools the user might create or use.

What about Docker and others?

One might use these tools to communicate with a new instance spun up under Docker or others.

install

npm install bash-xops

tiny command line tool

npm install -g bash-xops

For example:

Here is a use of the command line that has a machine configuration passed on the command line. Here, machine.conf has the authorization and IP information for a remote host.

First, it list a remote directory. Second, it runs a silly script. Third, it sends a directory up and into the test dir, big_test_thing Fourt, it lists what's in the new remote directory.

(Note: lines ending in 'yes' are telling expect that the fingerprint will not be requested on the machine. 'yes' means we know the machine. If 'yes' is omitted, the scripts will attempt to respond to fingerprinting.)

$xops machine.conf
xops  test/host.conf
looking for a conf file in test/host.conf
CONFIG FILE:  test/host.conf
$>ldr . yes
$> spawn bash -c ssh [email protected] 'find  . -type d -maxdepth 1'
[email protected] password: 
.
./.forever

...

./big_test_thing
./node_modules
$>xbash test/moveme_move.sh yes test dog
$> spawn ./assets/ssh-wrapper.sh [email protected] test/moveme_move.sh "test dog"
SSH-WRAPPER [email protected] /the/cwd "test dog"
-rw-r--r--@ 1 moi  staff  63 Jul  2 18:17 test/moveme_move.sh
+ ssh [email protected] 'bash -s' '"test' 'dog"'
[email protected]'s password: 
Sun 02 Jul 2023 06:38:27 PM PDT
/home/moi
It's great that dog is test
+ set +x
[email protected]

$> xsenddr test/moveme ./big_test_thing yes
$> spawn scp -r ./test/moveme [email protected]:./big_test_thing
[email protected]'s password: 
test4.txt                                                                                                                                100%   64     2.0KB/s   00:00     
test3.txt                                                                                                                                100%   62     2.1KB/s   00:00    

$> ls big_test_thing/moveme yes
$> spawn bash -c ssh [email protected] 'ls -l big_test_thing/moveme'
[email protected]'s password: 
total 8
-rw-r--r-- 1 moi moi 62 Jul  2 18:10 test3.txt
-rw-r--r-- 1 moi moi 64 Jul  2 18:10 test4.txt

exported methods

  • expect_ensure_dir
  • expect_list_dir
  • expect_list_dir_dirs
  • send_up
  • expect_send_up
  • expect_send_down
  • send_dir_up
  • expect_send_dir_up
  • send_dir_down
  • expect_send_dir_down
  • perform_op
  • perform_expect_op
  • run_local_bash_script

All exported methods are async

All the methods are asynchronous. They should be called with await or other promise control.

Here is an example:

const xops = require('bash-xops')
const cmd_line_args = require('args-getter')

let [pass,user,addr,resident_file,remote_dir] = cmd_line_args()

async fun() {
	await xops.expect_send_up(pass,user,addr,resident_file,remote_dir)
}

fun()

Methods starting with expect launch expect scripts

These scripts require passwords passed in as base64 encoded. They need the user and the ip for ssh as such:

ssh user@ip ...etc

The other methods will stop and ask for a password from the user.

Please refer to the docs in the docs directory.