hello-lights 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,9 +34,11 @@ $ hello-lights exec-file ./cmds.clj # execute commands from a file
34
34
  $ hello-lights repl # start an interactive REPL
35
35
  $ hello-lights serve # start the HTTP server on port 9000
36
36
  $ hello-lights serve --port 3000 # start the HTTP server on a custom port
37
+ $ hello-lights --selector http exec bounce 300 # execute via a remote server
38
+ $ hello-lights --selector http --host http://myserver:3000 repl # REPL via a remote server
37
39
  ```
38
40
 
39
- Use `--help` for the full list of options, including `--serial-num` to target a specific device and `--selector multi` to control multiple traffic lights at once.
41
+ Use `--help` for the full list of options, including `--serial-num` to target a specific device, `--selector multi` to control multiple traffic lights at once, and `--selector http` to send commands to a remote hello-lights server.
40
42
 
41
43
  ### Library
42
44
 
@@ -95,9 +97,11 @@ $ npm run cli -- exec-file ./cmds.clj # execute commands from a file
95
97
  $ npm run cli -- repl # start an interactive REPL
96
98
  $ npm run cli -- serve # start the HTTP server on port 9000
97
99
  $ npm run cli -- serve --port 3000 # start the HTTP server on a custom port
100
+ $ npm run cli -- --selector http exec bounce 300 # execute via a remote server
101
+ $ npm run cli -- --selector http --host http://myserver:3000 repl # REPL via a remote server
98
102
  ```
99
103
 
100
- Use `--help` for the full list of options, including `--serial-num` to target a specific device and `--selector multi` to control multiple traffic lights at once.
104
+ Use `--help` for the full list of options, including `--serial-num` to target a specific device, `--selector multi` to control multiple traffic lights at once, and `--selector http` to send commands to a remote hello-lights server.
101
105
 
102
106
  ## HTTP Server REST API
103
107
 
@@ -1,6 +1,6 @@
1
1
  const chalk = require('chalk');
2
2
  const path = require('path');
3
- const {Commander} = require('..');
3
+ const {Commander, RestCommander} = require('..');
4
4
  const {MetaFormatter, CodeFormatter} = require('..').commands;
5
5
 
6
6
  /////////////////////////////////////////////////////////////////
@@ -87,6 +87,9 @@ function resolveDeviceManager(options) {
87
87
  /////////////////////////////////////////////////////////////////
88
88
 
89
89
  function resolveCommander(options) {
90
+ if (options.selector === 'http') {
91
+ return new RestCommander({host: options.host, logger});
92
+ }
90
93
  return Commander[options.selector]({
91
94
  logger,
92
95
  formatter: new ChalkMetaFormatter(),
@@ -116,8 +119,13 @@ function define(yargs) {
116
119
  .option('selector', {
117
120
  alias: 's',
118
121
  describe: 'selector type to use',
119
- choices: ['single', 'multi'],
120
- default: 'single' });
122
+ choices: ['single', 'multi', 'http'],
123
+ default: 'single' })
124
+ .option('host', {
125
+ alias: 'H',
126
+ describe: 'server URL for --selector http',
127
+ default: 'http://localhost:9000',
128
+ type: 'string' });
121
129
  }
122
130
 
123
131
  /////////////////////////////////////////////////////////////////
@@ -84,7 +84,7 @@ class CommanderRepl {
84
84
  }
85
85
 
86
86
  supportsNewDevice() {
87
- return !!this.manager.newDevice;
87
+ return !!this.manager && !!this.manager.newDevice;
88
88
  }
89
89
  newDevice() {
90
90
  this.manager.newDevice();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hello-lights",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "Commands to control a traffic light",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -16,7 +16,7 @@
16
16
  "build:doc": "jsdoc src -c jsdoc.json",
17
17
  "build:web": "npm run peg && npm run browserify && npm run build:doc",
18
18
  "doc": "npm run build:doc && open-cli web/doc/index.html",
19
- "lint": "coffeelint -f coffeelint.json test && eslint src web dev",
19
+ "lint": "coffeelint -f coffeelint.json test && eslint src web",
20
20
  "peg": "pegjs -o src/commands/peg-parser.js src/commands/grammar.pegjs && pegjs -o src/commands/doc-peg-parser.js src/commands/doc-grammar.pegjs && pegjs -o src/commands/formatter-peg-parser.js src/commands/formatter-grammar.pegjs",
21
21
  "mocha-solo": "mocha --require coffeescript/register",
22
22
  "mocha-grep": "mocha --require coffeescript/register \"test/**/*.coffee\" --grep",
@@ -31,23 +31,22 @@
31
31
  "web": "open-cli web/index.html",
32
32
  "cpy-lib": "cpy \"**/*.*\" \"!*.pegjs\" ../lib/ --cwd=src --parents",
33
33
  "prepublishOnly": "npm run cpy-lib",
34
- "dev:install": "cd dev && npm install",
35
34
  "precli": "npm run cpy-lib",
36
35
  "cli": "node cli.js"
37
36
  },
38
37
  "devDependencies": {
39
- "browserify": "^16.5.2",
38
+ "browserify": "^17.0.1",
40
39
  "chai": "^4.3.4",
41
40
  "chai-as-promised": "^7.1.1",
42
41
  "chai-string": "^1.5.0",
43
42
  "coffeelint": "^2.1.0",
44
43
  "coffeescript": "^2.5.1",
45
- "cpy-cli": "^3.1.1",
44
+ "cpy-cli": "^7.0.0",
46
45
  "docdash": "^1.2.0",
47
46
  "eslint": "^6.8.0",
48
47
  "jsdoc": "^3.6.6",
49
- "mocha": "^7.2.0",
50
- "nyc": "^15.1.0",
48
+ "mocha": "^11.7.5",
49
+ "nyc": "^17.1.0",
51
50
  "open-cli": "^6.0.1",
52
51
  "pegjs": "^0.10.0",
53
52
  "sinon": "^9.2.4"