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

@cables/cables

v0.19.0

Published

cables command line tool

Downloads

76

Readme

cables-cli

Command line tool to export and download cables patches from the command line

             C   A   B   L   E   S   >>>  ___:_ _
       _ _:_______________ _____________ /   |\   _ _______
          |  _           /\\_           \    |\\.  _)     /\       ______         
    _____ | (/)        _/\\\(_______    /    |\\| /    __/\\\     /     /\    
   /   _/\_      _    /_\\\/_\\\\ _/   /     |\\|/     \_\\\/___ /     /\\\ 
  /   /_\\|_     |\     \\(    /\ \   /_    _:\\/__ /\_/       /_\   _/_\\/___
_/   /(     \    |_\     \__  /_\\_)    \         (_          /   \          /\
\           _\   \___     _/             \         /         /     \_       /\\\
 \_________(    _|\\\\     \_ ___________/   _    /_________/       /      /\\\/
  \\\\\\\\|_____)\\\        |\\\\\/         (/)  /\\\\\\\/                /_\\/
   \\\\\\\\\\\\\\\\\\_______:\\.\/______________/\\\\\\\\\_________________(\\ 
 _|.._     \\\\\\\)  \\\\\\\\\\| \\\\\\\\\\\\\\\\\\\/     \\\\\\\\\\\\\\\\\\\\
(_|||_)               \\\\\\\\\|  \\\\\\\\\\\\\\\\\/       \\\\\\\\\\\\\\\\\\( 
 ---|-->> 

Installation

Run npm install -g @cables/cables.
Create an API key on cables.gl/settings —> navigate to API key —> press Generate. When you first start the tool it will show a prompt for the API key. Once entered your API key will be stored in ~/.cablesrc.

Run

Export

To export and download a cables patch into a specific directory run:

cables --export [CABLES PATCH ID] -d [DESTINATION]

You can find the patch ID by opening your patch in the cables editor – the last part of the URL is the patch ID, e.g.:

https://cables.gl/edit/pQpie9
—> pQpie9 is the patch ID

Example:

cables --export pQpie9 -d "my-patch"

Please note: Running the command will overwrite everything in the my-patch-folder.

Arguments

  • -e / --export [PATCH ID]: Export patch, to use on a webserver
  • -C / --code [PATCH ID],[PATCH ID],[PATCH ID]: Export ops code for patch(es)
  • -p / --patch [PATCH ID]: Export patch, to use in cables standalone
  • -d / --destination [DESTINATION]: Folder to download the patch to, can either be absolute or relative
  • -g / --minify-glsl : Minifies shader-code in .frag and .att attachments
  • -i / --no-index : Removes the index.html file when set
  • -x / --no-extract : do not extract the downloaded zip file
  • -j / --json-filename [JSON FILENAME] : Define the filename of the patch json file
  • -c / --combine-js : combine javascript and json into a single patch.js
  • -a / --assets <auto|all|none>: export assets of patch, defaults to "auto"
  • -b / --skip-backups: do not include backup files in patch export
  • -f / --no-subdirs: put js and assets into same directory as index.html ("flat export")
  • -m / --no-minify: do not minify code
  • -M / --sourcemaps: if code is minified, add sourcemaps to the export
  • -D / --dev: export from dev server
  • --api-key: define apikey on the command line, overriding anything that might be in ~/.cablesrc

Use as a module

Install as dependency:

npm install --save @cables/cables

Export:

const cables = require('@cables/cables');
cables.export(options, onFinished, onError);

Simple Export Example:

const cables = require('@cables/cables');

cables.export({
  patchId: "pQpie9",
  destination: "patch" 
}, onFinished, onError);

function onFinished() {
  console.log("Export finished!");
}

function onError(err) {
  console.log("There was an error exporting your patch :/");
}

Advanced Export Example:

const cables = require('@cables/cables');

cables.export({
  patchId: "pQpie9",
  destination: "patch",
  noIndex: true,
  jsonFilename: "my-patch" /* patch will be stored as my-patch.json */
}, onFinished, onError);

function onFinished(filename) {
  console.log("Export finished: "+filename);
}

function onError(err) {
  console.log("There was an error exporting your patch :/");
}

Export Code (-C) Example:

If you just need the op-code of one or more patches you created, you can use the -C option and provide a comma-seperated list of patch-ids to download ops.js with all code included.

This is helpful, when you want to add multiple patches to one page. Download the patches individually (do NOT use --combine-js), load libs and cables.min.js as provided in the individual index.html and swap out ops.js with this download.

cables -C -d "public" pQpie9
var cables = require("@cables/cables");

cables.code({
  code: "one,two,thee",
  destination: "patch" 
}, onFinished, onError);

function onFinished() {
  console.log("Export finished!");
}

function onError(err) {
  console.log("There was an error exporting your patch :/");
}

Use in package.json:

{
  "scripts": {
      "patchup": "cables -c -i -d 'public' -e pQpie9",
      "code": "cables -C -d 'public' pQpie9"
  }
}

The project contains an example-package.json with patchup and deploy as predefined scripts.

Further Infos

For more infos on the cables API see cables API docs.