hello-lights 0.3.3 → 0.3.5

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.
@@ -81,6 +81,8 @@ jobs:
81
81
 
82
82
  - run: npm ci
83
83
 
84
+ - run: npm run peg
85
+
84
86
  - run: npm install -g npm@latest
85
87
 
86
88
  - name: Determine version bump type
package/README.md CHANGED
@@ -10,13 +10,37 @@ Works with a [Cleware USB traffic light](http://www.cleware.info/data/usbtischam
10
10
 
11
11
  ## Install
12
12
 
13
+ ### As a CLI (global)
14
+
15
+ ```sh
16
+ $ npm install -g hello-lights
17
+ ```
18
+
19
+ ### As a library
20
+
13
21
  ```sh
14
22
  $ npm install hello-lights --save
15
23
  ```
16
24
 
17
25
  ## Usage
18
26
 
19
- Issue commands to control a connected traffic light:
27
+ ### CLI
28
+
29
+ Install globally and run `hello-lights` from the command line:
30
+
31
+ ```sh
32
+ $ hello-lights exec bounce 300 # execute a command
33
+ $ hello-lights exec-file ./cmds.clj # execute commands from a file
34
+ $ hello-lights repl # start an interactive REPL
35
+ $ hello-lights serve # start the HTTP server on port 9000
36
+ $ hello-lights serve --port 3000 # start the HTTP server on a custom port
37
+ ```
38
+
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.
40
+
41
+ ### Library
42
+
43
+ Use `hello-lights` as a library in your Node.js project:
20
44
 
21
45
  ```js
22
46
  const {Commander} = require('hello-lights');
@@ -75,6 +99,51 @@ $ npm run cli -- serve --port 3000 # start the HTTP server on a custom port
75
99
 
76
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.
77
101
 
102
+ ## Running as a Linux Service
103
+
104
+ You can set up `hello-lights serve` to run automatically as a systemd user service on Linux.
105
+
106
+ Create the service file at `~/.config/systemd/user/hello-lights.service`:
107
+
108
+ ```ini
109
+ [Unit]
110
+ Description=Hello Lights Server
111
+ After=network.target
112
+
113
+ [Service]
114
+ Type=simple
115
+ Environment=PATH=/path/to/node/bin:/usr/bin:/bin
116
+ ExecStart=/path/to/node/bin/hello-lights serve
117
+ Restart=on-failure
118
+ RestartSec=5
119
+
120
+ [Install]
121
+ WantedBy=default.target
122
+ ```
123
+
124
+ Replace `/path/to/node/bin` with the directory containing your `node` and `hello-lights` binaries (e.g. `~/.nvm/versions/node/v24.13.1/bin`). The `Environment=PATH=...` line is needed because systemd doesn't load your shell profile, so tools installed via nvm won't be found otherwise.
125
+
126
+ Then enable and start the service:
127
+
128
+ ```sh
129
+ $ systemctl --user daemon-reload
130
+ $ systemctl --user enable hello-lights # start automatically on login
131
+ $ systemctl --user start hello-lights # start now
132
+ ```
133
+
134
+ To start the service on boot (without needing to log in), enable lingering for your user:
135
+
136
+ ```sh
137
+ $ sudo loginctl enable-linger $USER
138
+ ```
139
+
140
+ Check status and logs:
141
+
142
+ ```sh
143
+ $ systemctl --user status hello-lights
144
+ $ journalctl --user -u hello-lights -f # follow logs
145
+ ```
146
+
78
147
  ## CI
79
148
 
80
149
  The CI workflow runs on every push and pull request to `master`. It has three jobs: