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

@remy/gina

v0.1.0

Published

A Glitch CLI deploy tool

Downloads

3

Readme

Gina: A Glitch CLI

This is (an experimental) command line tool to upload a project to Glitch (based on an undocumented API) and return a URL to the live server.

gina example

Installation & usage

Via npm to install the gina command line tool:

npm install --gobal @remy/gina

Now from inside a node project:

gina

This will take a few minutes depending on the size and complexity of the project. By default the user will be anonymous. To assign to your own Glitch account, find your

Connecting to your Glitch account

You'll need your Glitch token. There's a few ways to get this, but it's not super easy. I recommend using Chrome and opening the developer tools.

Head to glitch.com and sign in. From the developer tools' console panel, run the following code:

JSON.parse(localStorage.cachedUser).persistentToken

This should print a string that looks like a series of letters and numbers separated by dashes.

You can use the token on the command line like this:

GLITCH_TOKEN=xxxxx-xxxx-xxxx-xxxxx gina

Or you can add it to your terminal profile by adding the following line to your .bashrc (or .profile or whichever file you use):

GLITCH_TOKEN=xxxxx-xxxx-xxxx-xxxxx

Then run the source command on that file (.bashrc or which file you edited), like this:

source /Users/remy/.bashrc

Now you can run gina without the token defined (as above).

Internals

  1. Anon user (or token from existing account) POST https://api.glitch.com/users/anon => JSON { persistentToken }
  2. Create a project: POST https://api.glitch.com/projects?authorization=${ persistentToken } => JSON { id, name }
  3. Create secure socket: wss://api.glitch.com/hushed-frog/ot?token=${ persistentToken }
  4. Delete original files in project
  5. Glob all local files (ignoring based on .gitignore) and upload
  6. Listen to the glitch log and wait for dep install and listening

WebSocket API

init

{"command":"broadcast","message":{"user":{"avatarUrl":null,"awaitingInvite":false,"id":553215,"name":null,"login":null,"color":"#80f289","utcOffset":0,"branchName":"Live","readOnly":false,"thanksReceived":false,"tabId":"49017","projectPermission":{"userId":0000,"projectId":"55d4fb6f-gggg-4a70-a214-292ba452bbb2","accessLevel":30},"invited":false,"left":false,"stopAsking":false}}}

Documents down:

[{"response_type":"document","id":"15107826537bca4ee0-e18c-gggg-99fa-fa696c5c7e86","path":"server.js","content":"...","version":1,"broadcast":{}}]

Delete file

{"command":"document","id":"15107826534933af4b-c5f0-4b06-gggg-a7aacb923b97","path":""}

Delete all the files:

const path = '';
files.filter(_ => _.path !== '.glitch-assets').map(({ id }) => {
  wss.send(JSON.stringify({
    command: "document",
    id,
    path // empty string deletes
  }))
})

Create file

const path = "my-file.js";
const id = uuid.v4();
const document = { command: "document", id, path }
wss.send(JSON.stringify(document));

// then send contents via a transform
const submit = { id, "command":"submit","transform":{"position":0,"insert": contents ,"num_delete":0,"version":2} };
wss.send(JSON.stringify(submit));

The name

I've decided to follow the UK weather system naming approach, in that they use names of women and men cycling their way through the alphabet. In my case, I'm taking the first letter from the project of interest, i.e. Glitch.

I'm kind on the bench about whether it works. I like that it's short and catchy, but I also have a niggle that it might be a bit weird. Ping me an issue if you think it needs changing (either offline via email or an open issue).

TODO

  • [ ] Asset files
  • [ ] Detect package name and re-use
  • [ ] Better error handling

Licence

  • MIT / https://rem.mit-license.org