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

@sinclair/drift

v0.9.1

Published

Run Chrome from the Terminal

Downloads

77

Readme

npm version GitHub CI

Install

$ npm install -g @sinclair/drift 

Usage

$ drift url http://localhost:5000

Overview

Drift is a command line tool that integrates the Chrome Developer Console into the terminal. It is built upon the Chrome DevTools Protocol and implements an interactive repl for running code in remote Chrome instances. Drift enables browser functionality to be developed and tested entirely from within a terminal window.

Drift works similar to Node but runs code in constrained browser environments. It can be used for browser automation, running browser code in CI environments or used as a general purpose scripting tool.

License MIT

Contents

Commands

The Drift CLI accepts a series of commands which are run in sequence against a sandboxed Chrome instance. When all commands have completed, Drift will enter an interactive repl similar to the Chrome DevTools Console.

The following is the Drift command line interface

Format:

  $ drift [...command]

Examples:

  $ drift url https://domain.com
  $ drift run script.ts
  $ drift url https://domain.com run script.ts
  $ drift url https://domain.com wait 1000 save image.png
  $ drift window devtools url https://domain.com

Commands:

  url         url         Load page
  run         path        Add script to page
  css         path        Add style to page
  save        path        Save page as image or pdf
  args        [...args]   Adds args to Drift.args
  watch       [...path]   Watch and reload
  user        path        User directory
  mousedown   x y         Send mousedown event
  position    x y         Desktop window position
  size        w h         Desktop window size
  wait        ms          Wait timeout
  reload                  Reload page
  close                   Close drift

Flags:

  window                  Open window
  devtools                Open devtools
  incognto                Open incognito
  verbose                 Log Chrome messages
  reset                   Reset user directory
  fail                    Close drift on exceptions
  help                    Show this help message

Examples

The following are some examples

# starts with interactive repl

$ drift
# opens github.com

$ drift url http://github.com
# runs index.ts

$ drift run index.ts
# opens a window, runs index.ts, waits 5 seconds then closes

$ drift window run index.ts wait 5000 close
# opens github.com, waits 4 seconds then takes a screenshot

$ drift url https://github.com wait 4000 save screenshot.png

Testing

When testing browser code in CI environments, call close(...) to terminate the process with a non zero exit code on error. CI environments will interpret this is a failed process.

test().then(() => close(0)).catch(() => close(1))

Which can be run on CI environments with the following.

$ drift run test.ts

Contribute

Drift is open to community contribution. Please ensure you submit an open issue before submitting a pull request. The Drift project preferences open community discussion prior to accepting new features.