0.20.0 • Published 10 months ago

@cables/cables v0.20.0

Weekly downloads
3
License
MIT
Repository
github
Last release
10 months ago

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"
  • -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.

0.20.0

10 months ago

0.19.0

12 months ago

0.15.0

1 year ago

0.16.0

1 year ago

0.17.0

12 months ago

0.18.0

12 months ago

0.13.1

1 year ago

0.13.2

1 year ago

0.13.3

1 year ago

0.13.0

1 year ago

0.12.0

2 years ago

0.11.0

2 years ago

0.10.4

3 years ago

0.10.1

3 years ago

0.10.2

3 years ago

0.10.3

3 years ago

0.10.0

3 years ago

0.9.0

3 years ago

0.8.3

4 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

6 years ago

0.5.3

6 years ago

0.5.0

6 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.4.0

6 years ago

0.3.2

6 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago