hello-lights 0.3.16 → 0.3.17

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
@@ -63,46 +63,6 @@ Check out the available commands [here](https://jordao76.github.io/hello-lights)
63
63
 
64
64
  For the documentation look [here](https://jordao76.github.io/hello-lights/doc/index.html).
65
65
 
66
- ## Development
67
-
68
- Install dependencies:
69
-
70
- ```sh
71
- $ npm install
72
- ```
73
-
74
- ### npm scripts
75
-
76
- | Script | Description |
77
- |---|---|
78
- | `npm test` | Run all tests (generates PEG parsers first) |
79
- | `npm run lint` | Lint source and test files |
80
- | `npm run coverage` | Run tests with coverage instrumentation |
81
- | `npm run coverage:text` | Print a text coverage summary to the terminal |
82
- | `npm run coverage:open` | Generate and open an HTML coverage report |
83
- | `npm run build:doc` | Generate JSDoc documentation into `web/doc/` |
84
- | `npm run build:web` | Build all web assets (PEG parsers, browserify bundle, docs) |
85
- | `npm run doc` | Build and open the documentation in the browser |
86
- | `npm run web` | Build and open the browser demo |
87
- | `npm run mocha-grep <pattern>` | Run only tests matching a pattern |
88
- | `npm run cli` | Run the CLI locally |
89
-
90
- ### CLI
91
-
92
- Run the CLI locally with `npm run cli`:
93
-
94
- ```sh
95
- $ npm run cli -- exec bounce 300 # execute a command
96
- $ npm run cli -- exec-file ./cmds.clj # execute commands from a file
97
- $ npm run cli -- repl # start an interactive REPL
98
- $ npm run cli -- serve # start the HTTP server on port 9000
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
102
- ```
103
-
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.
105
-
106
66
  ## HTTP Server REST API
107
67
 
108
68
  The `serve` command starts an HTTP server that exposes the Commander interface as a REST API. By default it listens on port 9000.
@@ -112,7 +72,6 @@ The `serve` command starts an HTTP server that exposes the Commander interface a
112
72
  | `/run` | POST | Command string (plain text) | 202 Accepted, or 400 if malformed |
113
73
  | `/run?reset=true` | POST | Command string (plain text) | 202 Accepted (resets lights first), or 400 if malformed |
114
74
  | `/cancel` | POST | — | 200 OK |
115
- | `/definitions` | POST | Definition string (plain text) | 202 Accepted, or 400 if malformed |
116
75
  | `/commands` | GET | — | 200 + JSON array of command names |
117
76
  | `/commands/:name` | GET | — | 200 + help text (`text/x-ansi`) or 404 |
118
77
  | `/info` | GET | — | 200 + JSON array of `{ serialNum, status }` |
@@ -123,7 +82,6 @@ Examples:
123
82
  $ curl -X POST http://localhost:9000/run -d 'blink 3 green 300'
124
83
  $ curl -X POST http://localhost:9000/run?reset=true -d 'twinkle red 400'
125
84
  $ curl -X POST http://localhost:9000/cancel
126
- $ curl -X POST http://localhost:9000/definitions -d '(def foo (blink 1 green 300))'
127
85
  $ curl http://localhost:9000/commands
128
86
  $ curl http://localhost:9000/commands/turn
129
87
  $ curl http://localhost:9000/info
@@ -176,6 +134,30 @@ $ systemctl --user status hello-lights
176
134
  $ journalctl --user -u hello-lights -f # follow logs
177
135
  ```
178
136
 
137
+ ## Development
138
+
139
+ Install dependencies:
140
+
141
+ ```sh
142
+ $ npm install
143
+ ```
144
+
145
+ ### npm scripts
146
+
147
+ | Script | Description |
148
+ |---|---|
149
+ | `npm test` | Run all tests (generates PEG parsers first) |
150
+ | `npm run lint` | Lint source and test files |
151
+ | `npm run coverage` | Run tests with coverage instrumentation |
152
+ | `npm run coverage:text` | Print a text coverage summary to the terminal |
153
+ | `npm run coverage:open` | Generate and open an HTML coverage report |
154
+ | `npm run build:doc` | Generate JSDoc documentation into `web/doc/` |
155
+ | `npm run build:web` | Build all web assets (PEG parsers, browserify bundle, docs) |
156
+ | `npm run doc` | Build and open the documentation in the browser |
157
+ | `npm run web` | Build and open the browser demo |
158
+ | `npm run mocha-grep <pattern>` | Run only tests matching a pattern |
159
+ | `npm run cli` | Run the CLI locally (e.g. `npm run cli -- exec bounce 300`) |
160
+
179
161
  ## CI
180
162
 
181
163
  The CI workflow runs on every push and pull request to `master`. It has three jobs:
@@ -44,20 +44,6 @@ function createApp(commander, {logger: log = logger} = {}) {
44
44
  res.sendStatus(200);
45
45
  });
46
46
 
47
- app.post('/definitions', (req, res) => {
48
- let body = req.body || '';
49
- log.log('POST /definitions:', body);
50
- try {
51
- commander.interpreter.process(body);
52
- } catch (e) {
53
- log.error('POST /definitions: malformed:', e.message);
54
- res.status(400).send(e.message);
55
- return;
56
- }
57
- commander.runDefinitions(body);
58
- res.sendStatus(202);
59
- });
60
-
61
47
  app.get('/commands', async (req, res) => {
62
48
  res.json(await commander.fetchCommandNames());
63
49
  });
@@ -70,17 +70,6 @@ class RestCommander {
70
70
  await request(this.host, 'POST', '/cancel');
71
71
  }
72
72
 
73
- /**
74
- * Executes definition-only commands on the remote server.
75
- * @param {string} command - Command with definitions to execute.
76
- */
77
- async runDefinitions(command) {
78
- let res = await request(this.host, 'POST', '/definitions', command);
79
- if (res.statusCode === 400) {
80
- this.logger.error(res.body);
81
- }
82
- }
83
-
84
73
  /**
85
74
  * Fetches all available command names from the remote server.
86
75
  * @returns {Promise<string[]>} Array of command names.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hello-lights",
3
- "version": "0.3.16",
3
+ "version": "0.3.17",
4
4
  "description": "Commands to control a traffic light",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,14 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: "npm"
4
- directory: "/"
5
- schedule:
6
- interval: "weekly"
7
- # Only open PRs for security vulnerabilities, not version bumps
8
- open-pull-requests-limit: 5
9
- groups:
10
- # Group all security patches into a single PR when possible
11
- security-patches:
12
- applies-to: security-updates
13
- patterns:
14
- - "*"
@@ -1,118 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- pull_request:
5
- branches: [master]
6
- push:
7
- branches: [master]
8
-
9
- permissions:
10
- contents: read
11
-
12
- jobs:
13
- build:
14
- runs-on: ubuntu-latest
15
-
16
- steps:
17
- - uses: actions/checkout@v4
18
-
19
- - uses: actions/setup-node@v4
20
- with:
21
- node-version: 22
22
-
23
- - name: Install system dependencies
24
- run: sudo apt-get update && sudo apt-get install -y libusb-1.0-0-dev libudev-dev
25
-
26
- - run: npm ci
27
-
28
- - run: npm run lint
29
-
30
- - run: npm run coverage
31
-
32
- - run: npm run coverage:text
33
-
34
- - run: npm run build:web
35
-
36
- - name: Upload web artifact
37
- if: github.event_name == 'push'
38
- uses: actions/upload-pages-artifact@v3
39
- with:
40
- path: web
41
-
42
- deploy:
43
- needs: build
44
- if: github.event_name == 'push'
45
- runs-on: ubuntu-latest
46
-
47
- permissions:
48
- pages: write
49
- id-token: write
50
-
51
- environment:
52
- name: github-pages
53
- url: ${{ steps.deploy.outputs.page_url }}
54
-
55
- steps:
56
- - name: Deploy to GitHub Pages
57
- id: deploy
58
- uses: actions/deploy-pages@v4
59
-
60
- publish:
61
- needs: build
62
- if: github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip ci]')
63
- runs-on: ubuntu-latest
64
-
65
- permissions:
66
- contents: write
67
- id-token: write
68
-
69
- steps:
70
- - uses: actions/checkout@v4
71
- with:
72
- token: ${{ secrets.GITHUB_TOKEN }}
73
-
74
- - uses: actions/setup-node@v4
75
- with:
76
- node-version: 22
77
- registry-url: https://registry.npmjs.org
78
-
79
- - name: Install system dependencies
80
- run: sudo apt-get update && sudo apt-get install -y libusb-1.0-0-dev libudev-dev
81
-
82
- - run: npm ci
83
-
84
- - run: npm run peg
85
-
86
- - run: npm install -g npm@latest
87
-
88
- - name: Determine version bump type
89
- id: bump
90
- run: |
91
- COMMIT_MSG="${{ github.event.head_commit.message }}"
92
- if echo "$COMMIT_MSG" | grep -qiE '\[major\]|BREAKING CHANGE'; then
93
- echo "type=major" >> $GITHUB_OUTPUT
94
- elif echo "$COMMIT_MSG" | grep -qi '\[minor\]'; then
95
- echo "type=minor" >> $GITHUB_OUTPUT
96
- else
97
- echo "type=patch" >> $GITHUB_OUTPUT
98
- fi
99
-
100
- - name: Bump version
101
- id: version
102
- run: |
103
- git config user.name "github-actions[bot]"
104
- git config user.email "github-actions[bot]@users.noreply.github.com"
105
- npm version ${{ steps.bump.outputs.type }} -m "v%s [skip ci]"
106
- echo "new_version=$(node -p 'require("./package.json").version')" >> $GITHUB_OUTPUT
107
-
108
- - name: Push version bump
109
- run: git push --follow-tags
110
-
111
- - name: Publish to npm
112
- run: npm publish --provenance
113
-
114
- - name: Create GitHub Release
115
- uses: softprops/action-gh-release@v2
116
- with:
117
- tag_name: v${{ steps.version.outputs.new_version }}
118
- generate_release_notes: true
package/eslint.config.js DELETED
@@ -1,163 +0,0 @@
1
- 'use strict';
2
-
3
- const globals = require('globals');
4
-
5
- module.exports = [
6
- {
7
- ignores: [
8
- 'src/commands/peg-parser.js',
9
- 'src/commands/doc-peg-parser.js',
10
- 'src/commands/formatter-peg-parser.js',
11
- 'web/bundle.js',
12
- 'web/doc'
13
- ]
14
- },
15
- {
16
- languageOptions: {
17
- ecmaVersion: 2018,
18
- globals: {
19
- ...globals.node,
20
- ...globals.browser
21
- }
22
- },
23
- rules: {
24
- 'accessor-pairs': 'error',
25
- 'arrow-spacing': ['error', {'before': true, 'after': true}],
26
- 'block-spacing': ['error', 'always'],
27
- 'brace-style': ['error', '1tbs', {'allowSingleLine': true}],
28
- 'camelcase': ['error', {'properties': 'never'}],
29
- 'comma-dangle': ['error', {'arrays': 'never', 'objects': 'never', 'imports': 'never', 'exports': 'never', 'functions': 'never'}],
30
- 'comma-spacing': ['error', {'before': false, 'after': true}],
31
- 'comma-style': ['error', 'last'],
32
- 'constructor-super': 'error',
33
- 'curly': ['error', 'multi-line'],
34
- 'dot-location': ['error', 'property'],
35
- 'eol-last': 'error',
36
- 'eqeqeq': ['error', 'always', {'null': 'ignore'}],
37
- 'func-call-spacing': ['error', 'never'],
38
- 'generator-star-spacing': ['error', {'before': true, 'after': true}],
39
- 'indent': ['error', 2, {
40
- 'SwitchCase': 1,
41
- 'VariableDeclarator': 1,
42
- 'outerIIFEBody': 1,
43
- 'MemberExpression': 1,
44
- 'FunctionDeclaration': {'parameters': 1, 'body': 1},
45
- 'FunctionExpression': {'parameters': 1, 'body': 1},
46
- 'CallExpression': {'arguments': 1},
47
- 'ArrayExpression': 1,
48
- 'ObjectExpression': 1,
49
- 'ImportDeclaration': 1,
50
- 'flatTernaryExpressions': false,
51
- 'ignoreComments': false
52
- }],
53
- 'key-spacing': ['error', {'beforeColon': false, 'afterColon': true}],
54
- 'keyword-spacing': ['error', {'before': true, 'after': true}],
55
- 'new-cap': ['error', {'newIsCap': true, 'capIsNew': false}],
56
- 'no-array-constructor': 'error',
57
- 'no-caller': 'error',
58
- 'no-class-assign': 'error',
59
- 'no-compare-neg-zero': 'error',
60
- 'no-cond-assign': 'error',
61
- 'no-const-assign': 'error',
62
- 'no-constant-condition': ['error', {'checkLoops': false}],
63
- 'no-control-regex': 'error',
64
- 'no-debugger': 'error',
65
- 'no-delete-var': 'error',
66
- 'no-dupe-args': 'error',
67
- 'no-dupe-class-members': 'error',
68
- 'no-dupe-keys': 'error',
69
- 'no-duplicate-case': 'error',
70
- 'no-empty-character-class': 'error',
71
- 'no-empty-pattern': 'error',
72
- 'no-eval': 'error',
73
- 'no-ex-assign': 'error',
74
- 'no-extend-native': 'error',
75
- 'no-extra-bind': 'error',
76
- 'no-extra-boolean-cast': 'error',
77
- 'no-extra-parens': ['error', 'functions'],
78
- 'no-fallthrough': 'error',
79
- 'no-floating-decimal': 'error',
80
- 'no-func-assign': 'error',
81
- 'no-global-assign': 'error',
82
- 'no-implied-eval': 'error',
83
- 'no-inner-declarations': ['error', 'functions'],
84
- 'no-invalid-regexp': 'error',
85
- 'no-irregular-whitespace': 'error',
86
- 'no-iterator': 'error',
87
- 'no-label-var': 'error',
88
- 'no-labels': ['error', {'allowLoop': false, 'allowSwitch': false}],
89
- 'no-lone-blocks': 'error',
90
- 'no-mixed-operators': ['error', {
91
- 'groups': [
92
- ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
93
- ['&&', '||'],
94
- ['in', 'instanceof']
95
- ],
96
- 'allowSamePrecedence': true
97
- }],
98
- 'no-mixed-spaces-and-tabs': 'error',
99
- 'no-multi-spaces': 'error',
100
- 'no-multi-str': 'error',
101
- 'no-multiple-empty-lines': ['error', {'max': 1, 'maxEOF': 0}],
102
- 'no-new': 'error',
103
- 'no-new-func': 'error',
104
- 'no-new-object': 'error',
105
- 'no-new-symbol': 'error',
106
- 'no-new-wrappers': 'error',
107
- 'no-obj-calls': 'error',
108
- 'no-octal': 'error',
109
- 'no-octal-escape': 'error',
110
- 'no-proto': 'error',
111
- 'no-redeclare': 'error',
112
- 'no-regex-spaces': 'error',
113
- 'no-return-await': 'error',
114
- 'no-self-assign': 'error',
115
- 'no-self-compare': 'error',
116
- 'no-sequences': 'error',
117
- 'no-shadow-restricted-names': 'error',
118
- 'no-sparse-arrays': 'error',
119
- 'no-tabs': 'error',
120
- 'no-template-curly-in-string': 'error',
121
- 'no-this-before-super': 'error',
122
- 'no-throw-literal': 'error',
123
- 'no-trailing-spaces': 'error',
124
- 'no-undef': 'error',
125
- 'no-undef-init': 'error',
126
- 'no-unexpected-multiline': 'error',
127
- 'no-unmodified-loop-condition': 'error',
128
- 'no-unneeded-ternary': ['error', {'defaultAssignment': false}],
129
- 'no-unreachable': 'error',
130
- 'no-unsafe-finally': 'error',
131
- 'no-unsafe-negation': 'error',
132
- 'no-unused-expressions': ['error', {'allowShortCircuit': true, 'allowTernary': true, 'allowTaggedTemplates': true}],
133
- 'no-unused-vars': ['error', {'vars': 'all', 'args': 'none', 'caughtErrors': 'none', 'ignoreRestSiblings': true}],
134
- 'no-use-before-define': ['error', {'functions': false, 'classes': false, 'variables': false}],
135
- 'no-useless-call': 'error',
136
- 'no-useless-computed-key': 'error',
137
- 'no-useless-constructor': 'error',
138
- 'no-useless-escape': 'error',
139
- 'no-useless-rename': 'error',
140
- 'no-useless-return': 'error',
141
- 'no-whitespace-before-property': 'error',
142
- 'no-with': 'error',
143
- 'operator-linebreak': ['error', 'after', {'overrides': {'?': 'before', ':': 'before'}}],
144
- 'prefer-promise-reject-errors': 'error',
145
- 'quotes': ['error', 'single', {'avoidEscape': true, 'allowTemplateLiterals': true}],
146
- 'rest-spread-spacing': ['error', 'never'],
147
- 'semi': 'error',
148
- 'semi-spacing': ['error', {'before': false, 'after': true}],
149
- 'space-before-blocks': ['error', 'always'],
150
- 'space-in-parens': ['error', 'never'],
151
- 'space-unary-ops': ['error', {'words': true, 'nonwords': false}],
152
- 'symbol-description': 'error',
153
- 'template-curly-spacing': ['error', 'never'],
154
- 'template-tag-spacing': ['error', 'never'],
155
- 'unicode-bom': ['error', 'never'],
156
- 'use-isnan': 'error',
157
- 'valid-typeof': ['error', {'requireStringLiterals': true}],
158
- 'wrap-iife': ['error', 'any', {'functionPrototypeMethods': true}],
159
- 'yield-star-spacing': ['error', 'both'],
160
- 'yoda': ['error', 'never']
161
- }
162
- }
163
- ];
package/jsdoc.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "plugins": [
3
- "plugins/markdown"
4
- ],
5
- "opts": {
6
- "template": "node_modules/docdash",
7
- "readme": "./README.md",
8
- "destination": "./web/doc/",
9
- "recurse": true
10
- },
11
- "docdash": {
12
- "typedefs": true,
13
- "sectionOrder": [
14
- "Tutorials",
15
- "Namespaces",
16
- "Modules",
17
- "Interfaces",
18
- "Classes",
19
- "Mixins",
20
- "Externals"
21
- ]
22
- }
23
- }