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

oneclick-update

v1.3.1

Published

Simple installer downloads and update server

Downloads

12

Readme

oneclick-update

Simple installer downloads and update server

What it does

Serves updates and installers following the common Squirrel + Electron pattern via Github releases.

In addition to the standard fare of these types of libraries it adds the ability to serve different release channels based on semver build metadata.

1.0.0+channelName -> /download/channelName/win32

It similarly handles prerelease channels, even prereleases on alternate channels.

2.0.0-1 -> /download/prerelease/win32

2.0.0-1+channelName -> /download/channelName/prerelease/win32

Why use this over hazel, nuts, etc...

Both nuts and hazel are excellent libraries. That being said, here are some of the reasons you might use this instead.

  • Private repos are a first class citizen, not an afterthought
  • It handles multiple builds of the same version (i.e. vendor specific builds)
  • It has separate prerelease channels, even vendor specific prerelease channels
  • It prioritizes .dmg or .pkg files for download/darwin route
  • It allows user defined platforms, for custom asset filtering
  • It's a singular standalone script
  • It has exactly 0 dependencies
  • It is actively maintained

Install

Just running as a server, use any of these options to download the script. It's standalone.

  • CLICK HERE and save the script where you please
  • curl -o oneclick.js https://raw.githubusercontent.com/doesdev/oneclick-update/master/index.js

If you're using it as a module, you know the drill.

npm i -s oneclick-update

Usage

Just running as a server, couldn't be simpler.

curl -o oneclick.js https://raw.githubusercontent.com/doesdev/oneclick-update/master/index.js
SET GITHUB_REPO=doesdev/oneclick-release-test
node oneclick.js

Using a private repo, also simple.

curl -o oneclick.js https://raw.githubusercontent.com/doesdev/oneclick-update/master/index.js
curl -o secrets.json https://raw.githubusercontent.com/doesdev/oneclick-update/master/secrets.example.json
# modify the secrets.json file with your Github oauth token, repo, port, and return URL
node oneclick.js

Environment variables

  • GITHUB_REPO - Path to Github repo (i.e. doesdev/oneclick-update)
  • GITHUB_OAUTH_TOKEN - Your Github oauth token
  • PORT - The port you want to run the server on
  • SERVER_URL - The URL of the update server (for proxying private release assets)
  • REFRESH_CACHE - Interval to check for new releases as string or ms (default 15 mins)
  • LOG_DOWNLOADS - Log downloads to console as Download for [channel/platform/filename/extension]: [asset]

Routes

Detect platform via user-agent and download latest installer
/download[/channel][/prerelease]

Download latest installer for specified platform
/download[/channel][/prerelease]/:platform

Get update JSON for specified version, if version matches latest returns no content
/update[/channel][/prerelease]/:platform/:version

Get RELEASES file with nupkg download info (Windows only)
/update[/channel][/prerelease]/win32/:version/RELEASES

API

const { requestHandler, on } = require('oneclick-update')
const config = {
  repo: 'doesdev/oneclick-release-test',
  port: 8082,
  token: 'yourGithubOauthToken',
  serverUrl: 'https://updates.example.com',
  refreshCache: '15 mins',
  logDownloads: false,
  platformFilters: { /* see Platforms below for details */ },
  hostToChannel: {
    /*
      The `hostToChannel` option allows you to treat the hostname as a channel.
      That means you can have `updates.example.com` handle the primary channel
      and `updates.otherhost.com` handle the `otherhost` channel
    */
    'updates.otherhost.com': {
      name: 'otherhost',
      serverUrl: 'https://updates.otherhost.com'
    }
  }
}

const startServer = async () => {
  const handler = await requestHandler(config)
  createServer(handler).listen(config.port, () => {
    console.log(`Update server running on port ${config.port}`)
  })
}

on('download', ({ ip, requestUrl, asset, channel, platform, version }) => {
  console.log(`User at ${ip} downloaded ${asset}`)
})

startServer()

Platforms

Natively supports Windows, OSX and Linux.

Currently arch specification is not fully implemented. That being said you can create your own platform extensions that filter assets as you desire. The intent is to support arch specification natively, but in the interim it could be implemented something like this (assuming you've named Windows x64 assets with win64 in the name).

const config = {
  platformFilters: {
    win64: (assets, action) => {
      return assets.find((a) => a.name.indexOf('win64') !== -1)
    }
  }
}

Similarly you can define any custom platform filtering that you would like. The expectation is the key is what would be specified in the platform part of the URL and the value is a function that filters the assets to the one you would like to use.

The signature of the filtering function is (assets, action, arch, extension)

  • assets: Array - list of Github release assets, the name property of each is the filename
  • action: String - name of current action (download or update)
  • arch: String - this is not currently passed, once arch is implemented it will be
  • extension: String - if extension is specified via querystring, this is it (i.e. ?filetype=dmg -> dmg)

License

MIT © Andrew Carpenter