amaran-light-cli 1.1.0 → 1.1.4
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/CHANGELOG.md +32 -0
- package/README.md +96 -75
- package/dist/__tests__/autostart.test.js.map +1 -1
- package/dist/__tests__/cli.smoke.test.js +2 -1
- package/dist/__tests__/cli.smoke.test.js.map +1 -1
- package/dist/__tests__/setupTests.d.ts +2 -0
- package/dist/__tests__/setupTests.d.ts.map +1 -0
- package/dist/__tests__/setupTests.js +21 -0
- package/dist/__tests__/setupTests.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +105 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/autoCct.d.ts.map +1 -1
- package/dist/commands/autoCct.js +23 -6
- package/dist/commands/autoCct.js.map +1 -1
- package/dist/commands/cct.d.ts.map +1 -1
- package/dist/commands/cct.js +1 -0
- package/dist/commands/cct.js.map +1 -1
- package/dist/commands/config.d.ts +4 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +221 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/discover.d.ts.map +1 -1
- package/dist/commands/discover.js +1 -0
- package/dist/commands/discover.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +2 -0
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/schedule.d.ts.map +1 -1
- package/dist/commands/schedule.js +49 -10
- package/dist/commands/schedule.js.map +1 -1
- package/dist/commands/service.d.ts.map +1 -1
- package/dist/commands/service.js +3 -4
- package/dist/commands/service.js.map +1 -1
- package/dist/commands/simulateSchedule.js +1 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +28 -1
- package/dist/commands.js.map +1 -1
- package/dist/lightControl.d.ts.map +1 -1
- package/dist/lightControl.js +32 -23
- package/dist/lightControl.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -5
- package/scripts/release.js +108 -0
- package/scripts/test.sh +6 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
## [1.1.4] - 2025-11-02
|
|
2
|
+
|
|
3
|
+
test token config
|
|
4
|
+
|
|
5
|
+
## [1.1.3] - 2025-11-02
|
|
6
|
+
|
|
7
|
+
curve config and refactors
|
|
8
|
+
|
|
9
|
+
# Changelog
|
|
10
|
+
|
|
11
|
+
All notable changes to this project will be documented in this file.
|
|
12
|
+
|
|
13
|
+
## [1.1.2] - 2024-11-01
|
|
14
|
+
|
|
15
|
+
- Enhanced CLI help output and documentation
|
|
16
|
+
|
|
17
|
+
## [1.1.0] - 2024-10-31
|
|
18
|
+
|
|
19
|
+
- Added more curves for auto-cct
|
|
20
|
+
- Improved schedule table display with all curves
|
|
21
|
+
- Better range for start/stop times for curves
|
|
22
|
+
- Added simulation of full day curve in seconds
|
|
23
|
+
- Added auto-start for the desktop app if closed
|
|
24
|
+
- Added more special times in schedule (e.g., Nautical Dawn)
|
|
25
|
+
- Various tests and refactoring
|
|
26
|
+
|
|
27
|
+
## [1.0.3] - 2024-10-30
|
|
28
|
+
|
|
29
|
+
- Initial stable release with full CLI functionality
|
|
30
|
+
- WebSocket control for Aputure Amaran lights
|
|
31
|
+
- Auto-CCT circadian lighting feature
|
|
32
|
+
- Service automation for continuous lighting adjustment
|
package/README.md
CHANGED
|
@@ -10,14 +10,19 @@ Written with AI mostly, including this documentation. Thanks to [Zac for his co
|
|
|
10
10
|
|
|
11
11
|
1. Clone this repository or download the files
|
|
12
12
|
2. Install dependencies:
|
|
13
|
+
|
|
13
14
|
```bash
|
|
14
15
|
npm install
|
|
15
16
|
```
|
|
17
|
+
|
|
16
18
|
3. Build the project:
|
|
19
|
+
|
|
17
20
|
```bash
|
|
18
21
|
npm run build
|
|
19
22
|
```
|
|
23
|
+
|
|
20
24
|
4. Optionally, install globally:
|
|
25
|
+
|
|
21
26
|
```bash
|
|
22
27
|
npm install -g .
|
|
23
28
|
```
|
|
@@ -64,9 +69,17 @@ amaran-cli discover -d
|
|
|
64
69
|
|
|
65
70
|
This command uses `lsof` to find the WebSocket port that the Amaran Desktop application is listening on, then saves it to your configuration file for future use.
|
|
66
71
|
|
|
72
|
+
## Device Identification
|
|
73
|
+
|
|
74
|
+
Devices can be identified by:
|
|
75
|
+
|
|
76
|
+
- **Device name**: Case-insensitive partial matching (e.g., "key" matches "Key Light")
|
|
77
|
+
- **Node ID**: Exact match of the device's node_id
|
|
78
|
+
|
|
67
79
|
## Usage
|
|
68
80
|
|
|
69
81
|
### List all available lights
|
|
82
|
+
|
|
70
83
|
```bash
|
|
71
84
|
amaran-cli list
|
|
72
85
|
# or
|
|
@@ -74,6 +87,7 @@ amaran-cli ls
|
|
|
74
87
|
```
|
|
75
88
|
|
|
76
89
|
### Control lights
|
|
90
|
+
|
|
77
91
|
```bash
|
|
78
92
|
# Turn light on
|
|
79
93
|
amaran-cli on "Light Name"
|
|
@@ -96,6 +110,7 @@ amaran-cli toggle
|
|
|
96
110
|
```
|
|
97
111
|
|
|
98
112
|
### Set light properties
|
|
113
|
+
|
|
99
114
|
```bash
|
|
100
115
|
# Set intensity (0-100%)
|
|
101
116
|
amaran-cli intensity 75 "Light Name"
|
|
@@ -135,6 +150,7 @@ amaran-cli color blue -i 50
|
|
|
135
150
|
**Note:** For all commands that support device names, you can omit the device name or use `all` to apply the command to all lights. Commands are throttled with 250ms delay between each device to prevent overwhelming the server.
|
|
136
151
|
|
|
137
152
|
### Auto CCT (Circadian Lighting)
|
|
153
|
+
|
|
138
154
|
```bash
|
|
139
155
|
# Set CCT for all lights based on current time and location (auto-detected via geoip)
|
|
140
156
|
amaran-cli auto-cct
|
|
@@ -156,18 +172,21 @@ amaran-cli auto-cct -d
|
|
|
156
172
|
```
|
|
157
173
|
|
|
158
174
|
The `auto-cct` command automatically adjusts color temperature based on sunrise/sunset times for your location. By default, it maps the circadian curve to:
|
|
175
|
+
|
|
159
176
|
- **Before sunrise / After sunset**: 2000K at 5% intensity (warm, dim night lighting)
|
|
160
177
|
- **Solar noon**: 6500K at 100% intensity (cool, bright daylight)
|
|
161
178
|
- **Between sunrise and sunset**: Smooth bell curve transition from 2000K/5% → 6500K/100% → 2000K/5%
|
|
162
179
|
|
|
163
180
|
This mimics natural daylight changes throughout the day for more comfortable, circadian-friendly lighting. Both color temperature and brightness follow the same curve, providing natural dimming at dawn/dusk.
|
|
164
181
|
|
|
165
|
-
|
|
182
|
+
#### Location Priority
|
|
183
|
+
|
|
166
184
|
1. Command-line `--lat` and `--lon` arguments (highest priority)
|
|
167
185
|
2. Config file defaults (set with `amaran-cli config --lat <lat> --lon <lon>`)
|
|
168
186
|
3. GeoIP lookup based on public IP address (fallback)
|
|
169
187
|
|
|
170
|
-
|
|
188
|
+
#### Bounds (optional)
|
|
189
|
+
|
|
171
190
|
You can constrain the auto-cct curve to your preferred ranges via config:
|
|
172
191
|
|
|
173
192
|
```bash
|
|
@@ -180,6 +199,7 @@ amaran-cli config --intensity-min 10 --intensity-max 80
|
|
|
180
199
|
# Show the saved configuration
|
|
181
200
|
amaran-cli config --show
|
|
182
201
|
```
|
|
202
|
+
|
|
183
203
|
If a bound is not set, the default is used. When both min and max are set, min must be <= max.
|
|
184
204
|
|
|
185
205
|
### Running Auto-CCT as a Circadian Lighting Service
|
|
@@ -218,22 +238,25 @@ amaran-cli circadian-service start
|
|
|
218
238
|
amaran-cli circadian-service uninstall
|
|
219
239
|
```
|
|
220
240
|
|
|
221
|
-
|
|
241
|
+
#### Backward Compatibility
|
|
242
|
+
|
|
222
243
|
The `service` command is still available as an alias to `circadian-service`:
|
|
244
|
+
|
|
223
245
|
```bash
|
|
224
246
|
# These commands work the same way
|
|
225
247
|
amaran-cli service install
|
|
226
248
|
amaran-cli circadian-service install
|
|
227
249
|
```
|
|
228
250
|
|
|
229
|
-
|
|
251
|
+
#### Installation Detection
|
|
252
|
+
|
|
230
253
|
- The service automatically detects if amaran-cli is installed globally (via `npm install -g`) or running from a local development build
|
|
231
254
|
- Global installations run the executable directly for better performance
|
|
232
255
|
- Local development builds use Node.js to run the built JavaScript files
|
|
233
256
|
|
|
234
257
|
The service uses macOS launchd and will automatically start on login. Logs are stored in `~/Library/Logs/amaran-circadian-service.log`.
|
|
235
258
|
|
|
236
|
-
|
|
259
|
+
#### Alternative: Using Cron
|
|
237
260
|
|
|
238
261
|
If you prefer using cron instead of launchd, the included script handles both global and local installations:
|
|
239
262
|
|
|
@@ -250,7 +273,7 @@ crontab -e
|
|
|
250
273
|
tail -f ~/.amaran-circadian-service.log
|
|
251
274
|
```
|
|
252
275
|
|
|
253
|
-
|
|
276
|
+
#### Manual launchd Setup
|
|
254
277
|
|
|
255
278
|
For advanced users who want to create the service manually:
|
|
256
279
|
|
|
@@ -271,44 +294,64 @@ $ amaran-cli schedule
|
|
|
271
294
|
Auto-CCT Schedule Preview
|
|
272
295
|
═══════════════════════════════════════════════════════════
|
|
273
296
|
|
|
274
|
-
Location:
|
|
275
|
-
Date:
|
|
297
|
+
Location: 38.XXXX°, -122.XXXX° (geoip (XXX.XXX.XXX.157))
|
|
298
|
+
Date: Sunday, November 2, 2025
|
|
276
299
|
Interval: Every 30 minutes
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
Sunset:
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
300
|
+
Curve: All available curves
|
|
301
|
+
|
|
302
|
+
NE Night End : 05:08 AM GH Golden Hour : 04:34 PM
|
|
303
|
+
DN Nautical Dawn : 05:39 AM SB Sunset Start : 05:08 PM
|
|
304
|
+
DA Dawn : 06:10 AM SS Sunset : 05:11 PM
|
|
305
|
+
SR Sunrise : 06:37 AM ND Nautical Dusk : 06:09 PM
|
|
306
|
+
SE Sunrise End : 06:40 AM DU Dusk : 05:38 PM
|
|
307
|
+
GE Golden Hour End : 07:14 AM NI Night : 06:40 PM
|
|
308
|
+
SN Solar Noon : 11:54 AM NA Nadir : 12:54 AM
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
312
|
+
Time HANN WM_SMALL WM_MEDIUM WM_LARGE CIE SUN_ALT PEREZ
|
|
313
|
+
─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
314
|
+
04:38 AM 1700K/5% 1700K/5% 1700K/5% 1700K/5% 1700K/5% 1700K/5% 1700K/5%
|
|
315
|
+
05:08 AM NE 1700K/5% 1700K/5% 1700K/5% 1700K/5% 1700K/5% 1700K/5% 1700K/5%
|
|
316
|
+
05:38 AM 1764K/6% 2493K/21% 3074K/32% 4333K/57% 1700K/5% 1700K/5% 1700K/5%
|
|
317
|
+
05:39 AM DN 1767K/6% 2509K/21% 3102K/33% 4382K/58% 1700K/5% 1700K/5% 1700K/5%
|
|
318
|
+
06:08 AM 1954K/10% 3264K/36% 4333K/57% 6103K/92% 1700K/5% 1700K/5% 1700K/5%
|
|
319
|
+
06:10 AM DA 1968K/10% 3305K/37% 4398K/58% 6163K/93% 3627K/5% 3175K/5% 3382K/5%
|
|
320
|
+
06:37 AM SR 2247K/16% 3966K/50% 5339K/77% 6500K/100% 4435K/7% 4001K/9% 4345K/6%
|
|
321
|
+
06:38 AM 2259K/16% 3991K/50% 5372K/78% 6500K/100% 4482K/7% 4033K/9% 4419K/6%
|
|
322
|
+
06:40 AM SE 2281K/17% 4032K/51% 5424K/79% 6500K/100% 4559K/8% 4086K/10% 4545K/6%
|
|
323
|
+
07:08 AM 2663K/24% 4656K/64% 6103K/92% 6500K/100% 4335K/9% 4346K/17% 4457K/13%
|
|
324
|
+
07:14 AM GE 2754K/26% 4781K/66% 6207K/94% 6500K/100% 4290K/9% 4398K/19% 4453K/15%
|
|
325
|
+
07:38 AM 3144K/34% 5240K/75% 6466K/99% 6500K/100% 4153K/9% 4602K/25% 4492K/21%
|
|
326
|
+
08:08 AM 3677K/44% 5727K/85% 6500K/100% 6500K/100% 4134K/33% 4846K/35% 4818K/26%
|
|
327
|
+
08:38 AM 4232K/55% 6103K/92% 6500K/100% 6500K/100% 4440K/66% 5075K/44% 5358K/45%
|
|
328
|
+
09:08 AM 4780K/66% 6358K/97% 6500K/100% 6500K/100% 4720K/87% 5285K/52% 5838K/79%
|
|
329
|
+
09:38 AM 5291K/76% 6485K/100% 6500K/100% 6500K/100% 4969K/97% 5472K/59% 5437K/97%
|
|
330
|
+
10:08 AM 5739K/85% 6500K/100% 6500K/100% 6500K/100% 5180K/100% 5600K/100% 5564K/100%
|
|
331
|
+
10:38 AM 6098K/92% 6500K/100% 6500K/100% 6500K/100% 5347K/100% 5684K/100% 5664K/100%
|
|
332
|
+
11:08 AM 6351K/97% 6500K/100% 6500K/100% 6500K/100% 5463K/100% 5742K/100% 5734K/100%
|
|
333
|
+
11:38 AM 6482K/100% 6500K/100% 6500K/100% 6500K/100% 5522K/100% 5771K/100% 5769K/100%
|
|
334
|
+
11:54 AM SN 6500K/100% 6500K/100% 6500K/100% 6500K/100% 5529K/100% 5775K/100% 5774K/100%
|
|
335
|
+
12:08 PM 6486K/100% 6500K/100% 6500K/100% 6500K/100% 5522K/100% 5771K/100% 5769K/100%
|
|
336
|
+
12:38 PM 6361K/97% 6500K/100% 6500K/100% 6500K/100% 5461K/100% 5741K/100% 5733K/100%
|
|
337
|
+
01:08 PM 6115K/92% 6500K/100% 6500K/100% 6500K/100% 5344K/100% 5682K/100% 5663K/100%
|
|
338
|
+
01:38 PM 5761K/85% 6500K/100% 6500K/100% 6500K/100% 5177K/100% 5598K/100% 5562K/100%
|
|
339
|
+
02:08 PM 5317K/77% 6489K/100% 6500K/100% 6500K/100% 4964K/97% 5468K/59% 5434K/97%
|
|
340
|
+
02:38 PM 4808K/67% 6368K/97% 6500K/100% 6500K/100% 4714K/87% 5281K/52% 5830K/79%
|
|
341
|
+
03:08 PM 4262K/56% 6120K/93% 6500K/100% 6500K/100% 4434K/66% 5070K/43% 5347K/45%
|
|
342
|
+
03:38 PM 3706K/45% 5750K/85% 6500K/100% 6500K/100% 4128K/32% 4841K/34% 4809K/25%
|
|
343
|
+
04:08 PM 3172K/34% 5269K/76% 6474K/100% 6500K/100% 4156K/9% 4597K/25% 4489K/21%
|
|
344
|
+
04:34 PM GH 2754K/26% 4781K/66% 6207K/94% 6500K/100% 4306K/9% 4378K/18% 4454K/14%
|
|
345
|
+
04:38 PM 2687K/25% 4690K/64% 6132K/93% 6500K/100% 4340K/9% 4340K/17% 4458K/13%
|
|
346
|
+
05:08 PM SB 2281K/17% 4032K/51% 5424K/79% 6500K/100% 4461K/7% 4019K/9% 4385K/6%
|
|
347
|
+
05:11 PM SS 2247K/16% 3966K/50% 5339K/77% 6500K/100% 4341K/7% 3933K/8% 4199K/6%
|
|
348
|
+
05:38 PM DU 1968K/10% 3305K/37% 4398K/58% 6163K/93% 1700K/5% 1700K/5% 1700K/5%
|
|
349
|
+
06:08 PM 1772K/6% 2535K/22% 3145K/34% 4457K/60% 1700K/5% 1700K/5% 1700K/5%
|
|
350
|
+
06:09 PM ND 1767K/6% 2509K/21% 3102K/33% 4382K/58% 1700K/5% 1700K/5% 1700K/5%
|
|
351
|
+
06:38 PM 1700K/5% 1743K/6% 1775K/7% 1849K/8% 1700K/5% 1700K/5% 1700K/5%
|
|
352
|
+
06:40 PM NI 1700K/5% 1700K/5% 1700K/5% 1700K/5% 1700K/5% 1700K/5% 1700K/5%
|
|
353
|
+
07:08 PM 1700K/5% 1700K/5% 1700K/5% 1700K/5% 1700K/5% 1700K/5% 1700K/5%
|
|
354
|
+
─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
312
355
|
|
|
313
356
|
# Preview with manual location
|
|
314
357
|
amaran-cli schedule --lat 40.7128 --lon -74.0060
|
|
@@ -324,6 +367,7 @@ amaran-cli schedule --lat 51.5074 --lon -0.1278 --date 2025-06-21 --interval 60
|
|
|
324
367
|
```
|
|
325
368
|
|
|
326
369
|
The schedule shows CCT and intensity values from 30 minutes before sunrise to 30 minutes after sunset, with special highlighting for:
|
|
370
|
+
|
|
327
371
|
- **Sunrise** (yellow)
|
|
328
372
|
- **Solar Noon** (green, bold)
|
|
329
373
|
- **Sunset** (magenta)
|
|
@@ -333,22 +377,26 @@ This helps you visualize and plan your automated lighting schedule before implem
|
|
|
333
377
|
Note: The schedule respects any configured bounds set via `amaran-cli config --cct-min/--cct-max` and `--intensity-min/--intensity-max`. If no bounds are set, it uses the default curve from `calculateCCT`.
|
|
334
378
|
|
|
335
379
|
### Get light status
|
|
380
|
+
|
|
336
381
|
```bash
|
|
337
382
|
amaran-cli status "Light Name"
|
|
338
383
|
```
|
|
339
384
|
|
|
340
385
|
### Global options
|
|
386
|
+
|
|
341
387
|
All commands support these options:
|
|
388
|
+
|
|
342
389
|
- `-u, --url <url>`: Override WebSocket URL
|
|
343
390
|
- `-c, --client-id <id>`: Override client ID
|
|
344
391
|
- `-d, --debug`: Enable debug mode
|
|
345
392
|
|
|
346
393
|
Example:
|
|
394
|
+
|
|
347
395
|
```bash
|
|
348
396
|
amaran-cli list -u ws://192.168.1.100:60124 -d
|
|
349
397
|
```
|
|
350
398
|
|
|
351
|
-
## Examples
|
|
399
|
+
## Usage Examples
|
|
352
400
|
|
|
353
401
|
```bash
|
|
354
402
|
# Configure for remote Amaran Desktop
|
|
@@ -387,6 +435,10 @@ amaran-cli off
|
|
|
387
435
|
|
|
388
436
|
## Development
|
|
389
437
|
|
|
438
|
+
The localhost amaran desktop websocket API looks like to be near identical or identical to the Open API Sidus has published at <https://tools.sidus.link/openapi/docs/usage> . So if `lightControl.ts` is missing any functionality you can probably use the OpenAPI spec to implement the new functionality fairly quickly. This cli would probably work with the Sidus desktop apps as well, as well as Windows verisons of the Amaran desktop app but I haven't tested it. If you want to submit PRs for it, feel free!
|
|
439
|
+
|
|
440
|
+
Extending command line tool to work with their networked Open API would probably be fairly simple to do since the local Websocket API is very similar to the Open API.
|
|
441
|
+
|
|
390
442
|
```bash
|
|
391
443
|
# Run in development mode
|
|
392
444
|
npm run dev
|
|
@@ -397,34 +449,3 @@ npm run build
|
|
|
397
449
|
# Clean build artifacts
|
|
398
450
|
npm run clean
|
|
399
451
|
```
|
|
400
|
-
|
|
401
|
-
## Device Identification
|
|
402
|
-
|
|
403
|
-
Devices can be identified by:
|
|
404
|
-
- **Device name**: Case-insensitive partial matching (e.g., "key" matches "Key Light")
|
|
405
|
-
- **Node ID**: Exact match of the device's node_id
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
## License
|
|
409
|
-
|
|
410
|
-
MIT License - see the [LICENSE](LICENSE) file for details.
|
|
411
|
-
|
|
412
|
-
## Changelog
|
|
413
|
-
|
|
414
|
-
### v1.1.0
|
|
415
|
-
- Updated GitHub Actions workflow for automatic npm publishing on release
|
|
416
|
-
- Improved build and test process in CI/CD pipeline
|
|
417
|
-
- Enhanced release automation
|
|
418
|
-
|
|
419
|
-
### v1.0.3
|
|
420
|
-
- Initial stable release with full CLI functionality
|
|
421
|
-
- WebSocket control for Aputure Amaran lights
|
|
422
|
-
- Auto-CCT circadian lighting feature
|
|
423
|
-
- Service automation for continuous lighting adjustment
|
|
424
|
-
|
|
425
|
-
## Credits
|
|
426
|
-
|
|
427
|
-
- Original WebSocket control implementation by S. Zachariah Sprackett
|
|
428
|
-
- CLI, auto-CCT, and additional features by Mahyar McDonald
|
|
429
|
-
- Built for use with Aputure Amaran lights and the Amaran Desktop application. This is not an official Amaran app and is not built by them. This was built as a quick hobby utility.
|
|
430
|
-
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autostart.test.js","sourceRoot":"","sources":["../../src/__tests__/autostart.test.ts"],"names":[],"mappings":";;AAAA,4CAAmF;
|
|
1
|
+
{"version":3,"file":"autostart.test.js","sourceRoot":"","sources":["../../src/__tests__/autostart.test.ts"],"names":[],"mappings":";;AAAA,4CAAmF;AAInF,gCAAgC;AAChC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5B,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;CAC/B,CAAC,CAAC,CAAC;AAEJ,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC;IACrC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;CAChB,CAAC,CAAC,CAAC;AAEJ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1B,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;IACrB,YAAY,EAAE,IAAI,CAAC,EAAE,EAAE;IACvB,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;IACxB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;CAC1B,CAAC,CAAC,CAAC;AAEJ,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IACxB,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IAC/B,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IAC9B,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IAC7B,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,IA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CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;YAC5D,QAAQ,CAAC,kBAAkB,CAAC,CAAC,OAAe,EAAE,QAAuE,EAAE,EAAE;gBACvH,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC/B,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;gBACzB,CAAC;qBAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,CAAC;oBACxD,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YACxC,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;YAExD,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAe,EAAC,IAAI,CAAC,CAAC;YAE3C,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_child_process_1 = require("node:child_process");
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
describe('CLI Smoke Test', () => {
|
|
9
|
-
|
|
9
|
+
const runTest = process.platform === 'darwin' ? it : it.skip;
|
|
10
|
+
runTest('should run cli help without error - macOS only', (done) => {
|
|
10
11
|
const cliPath = node_path_1.default.resolve(__dirname, '../../dist/cli.js');
|
|
11
12
|
(0, node_child_process_1.exec)(`node ${cliPath} --help`, { timeout: 10000 }, (error, stdout, _stderr) => {
|
|
12
13
|
expect(error).toBeNull();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.smoke.test.js","sourceRoot":"","sources":["../../src/__tests__/cli.smoke.test.ts"],"names":[],"mappings":";;;;;AAAA,2DAA0C;AAC1C,0DAA6B;AAE7B,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"cli.smoke.test.js","sourceRoot":"","sources":["../../src/__tests__/cli.smoke.test.ts"],"names":[],"mappings":";;;;;AAAA,2DAA0C;AAC1C,0DAA6B;AAE7B,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC;IAE7D,OAAO,CACL,gDAAgD,EAChD,CAAC,IAAI,EAAE,EAAE;QACP,MAAM,OAAO,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;QAC7D,IAAA,yBAAI,EAAC,QAAQ,OAAO,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;YAC5E,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;YACzB,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;YAC9C,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC,EACD,KAAK,CACN,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupTests.d.ts","sourceRoot":"","sources":["../../src/__tests__/setupTests.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Setup test environment before running tests
|
|
4
|
+
const node_localstorage_1 = require("node-localstorage");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
// Create a temporary directory for test local storage
|
|
8
|
+
const TEST_STORAGE_DIR = (0, node_path_1.join)(__dirname, '.test-storage');
|
|
9
|
+
try {
|
|
10
|
+
// Ensure the test storage directory exists
|
|
11
|
+
(0, node_fs_1.mkdirSync)(TEST_STORAGE_DIR, { recursive: true });
|
|
12
|
+
// Set up global localStorage for tests
|
|
13
|
+
global.localStorage = new node_localstorage_1.LocalStorage(TEST_STORAGE_DIR);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.error('Failed to set up test storage:', error);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
// Mock any other global objects if needed
|
|
20
|
+
process.env.NODE_ENV = 'test';
|
|
21
|
+
//# sourceMappingURL=setupTests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupTests.js","sourceRoot":"","sources":["../../src/__tests__/setupTests.ts"],"names":[],"mappings":";;AAAA,8CAA8C;AAC9C,yDAAiD;AACjD,yCAAiC;AACjC,qCAAoC;AAEpC,sDAAsD;AACtD,MAAM,gBAAgB,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAE1D,IAAI,CAAC;IACH,2CAA2C;IAC3C,IAAA,mBAAS,EAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjD,uCAAuC;IACvC,MAAM,CAAC,YAAY,GAAG,IAAI,gCAAY,CAAC,gBAAgB,CAAC,CAAC;AAC3D,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;IACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,0CAA0C;AAC1C,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC"}
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,eAAe,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,QAAA,MAAM,OAAO,SAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,eAAe,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,QAAA,MAAM,OAAO,SAAgB,CAAC;AA+K9B,iBAAe,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CA2H5G;AAGD,iBAAS,YAAY,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,IAClE,GAAG,MAAM,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC,CAMnC;AAGD,iBAAS,UAAU,CAAC,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgBnF;AA+KD,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -51,6 +51,94 @@ const discovery_1 = require("./discovery");
|
|
|
51
51
|
const lightControl_1 = __importDefault(require("./lightControl"));
|
|
52
52
|
const program = new commander_1.Command();
|
|
53
53
|
exports.program = program;
|
|
54
|
+
// Configure help output
|
|
55
|
+
const package_json_1 = require("../package.json");
|
|
56
|
+
program
|
|
57
|
+
.name('amaran-cli')
|
|
58
|
+
.description('Command line tool for controlling Aputure Amaran lights via WebSocket')
|
|
59
|
+
.version(package_json_1.version, '-v, --version', 'output the current version')
|
|
60
|
+
.configureHelp({
|
|
61
|
+
sortSubcommands: true,
|
|
62
|
+
sortOptions: true,
|
|
63
|
+
showGlobalOptions: true,
|
|
64
|
+
formatHelp: (cmd, helper) => {
|
|
65
|
+
const isRoot = cmd.name() === 'amaran-cli';
|
|
66
|
+
const commandPath = isRoot ? [] : [cmd.name()];
|
|
67
|
+
let current = cmd.parent;
|
|
68
|
+
// Build the full command path
|
|
69
|
+
while (current && current.name() !== 'amaran-cli') {
|
|
70
|
+
commandPath.unshift(current.name());
|
|
71
|
+
current = current.parent;
|
|
72
|
+
}
|
|
73
|
+
const commandName = commandPath.join(' ');
|
|
74
|
+
const displayName = 'amaran-cli';
|
|
75
|
+
const sections = [
|
|
76
|
+
`${chalk_1.default.blue.bold('Amaran Light Control CLI')}`,
|
|
77
|
+
'',
|
|
78
|
+
`${chalk_1.default.bold('Usage:')} ${displayName}${commandName ? ` ${commandName}` : ''} [options]${isRoot ? ' [command]' : ''}`,
|
|
79
|
+
'',
|
|
80
|
+
];
|
|
81
|
+
// Add command description if available
|
|
82
|
+
if (cmd.description()) {
|
|
83
|
+
sections.push(`${chalk_1.default.bold('Description:')} ${cmd.description()}`, '');
|
|
84
|
+
}
|
|
85
|
+
// Add command usage pattern if available
|
|
86
|
+
if (cmd.usage() && cmd.usage() !== '[options] [command]') {
|
|
87
|
+
const usage = cmd.usage().replace(/^\s*/, '');
|
|
88
|
+
sections.push(`${chalk_1.default.bold('Usage:')} ${cmd.name()} ${chalk_1.default.blue(usage)}`, '');
|
|
89
|
+
}
|
|
90
|
+
// Add options
|
|
91
|
+
const options = helper.visibleOptions(cmd);
|
|
92
|
+
if (options.length > 0) {
|
|
93
|
+
sections.push(chalk_1.default.bold('Options:'));
|
|
94
|
+
sections.push(...options.map((option) => {
|
|
95
|
+
// Split the flags and replace parameter placeholders with bright white
|
|
96
|
+
const formattedFlags = option.flags
|
|
97
|
+
.split(/\s+/)
|
|
98
|
+
.map((part) => {
|
|
99
|
+
// Match parameter placeholders like <curve> or <date>
|
|
100
|
+
const match = part.match(/^(--?[\w-]+)(?:\s+(<[^>]+>))?/);
|
|
101
|
+
if (!match)
|
|
102
|
+
return part;
|
|
103
|
+
const [_, flag, param] = match;
|
|
104
|
+
// Use blue for parameters and long options for better visibility in light mode
|
|
105
|
+
const isShortFlag = flag.startsWith('-') && !flag.startsWith('--');
|
|
106
|
+
const flagColor = isShortFlag ? chalk_1.default.cyan : chalk_1.default.blue;
|
|
107
|
+
return param ? `${flagColor(flag)} ${chalk_1.default.blue(param)}` : flagColor(flag);
|
|
108
|
+
})
|
|
109
|
+
.join(' ');
|
|
110
|
+
return ` ${formattedFlags.padEnd(40)} ${option.description}`;
|
|
111
|
+
}));
|
|
112
|
+
sections.push('');
|
|
113
|
+
}
|
|
114
|
+
// Add commands
|
|
115
|
+
const commands = helper.visibleCommands(cmd);
|
|
116
|
+
if (commands.length > 0) {
|
|
117
|
+
sections.push(chalk_1.default.bold('Commands:'));
|
|
118
|
+
// Get the max command + usage length for alignment
|
|
119
|
+
const maxCommandWidth = Math.max(...commands.map((c) => {
|
|
120
|
+
const usage = c.usage() || '';
|
|
121
|
+
return c.name().length + (usage ? usage.length + 1 : 0);
|
|
122
|
+
}), 25 // Minimum width
|
|
123
|
+
);
|
|
124
|
+
sections.push(...commands.map((cmd) => {
|
|
125
|
+
const name = cmd.name();
|
|
126
|
+
const usage = cmd.usage() || '';
|
|
127
|
+
const desc = cmd.description() || '';
|
|
128
|
+
const _commandPart = usage ? `${name} ${chalk_1.default.blue(usage)}` : name;
|
|
129
|
+
return ` ${chalk_1.default.green(name)} ${chalk_1.default.blue(usage || '').padEnd(maxCommandWidth - name.length - 1)} ${desc}`;
|
|
130
|
+
}));
|
|
131
|
+
sections.push('');
|
|
132
|
+
}
|
|
133
|
+
// Add examples for the root command
|
|
134
|
+
if (cmd.name() === 'amaran-cli') {
|
|
135
|
+
sections.push(chalk_1.default.bold('Examples:'), ' $ amaran-cli power on --all # Turn on all connected lights', ' $ amaran-cli cct 5000 --intensity 80 # Set color temperature to 5000K at 80%', ' $ amaran-cli color 255 100 50 # Set RGB color (R:255 G:100 B:50)', '');
|
|
136
|
+
}
|
|
137
|
+
sections.push(`Run ${chalk_1.default.blue('amaran-cli <command> --help')} for more information about a command.`);
|
|
138
|
+
return sections.join('\n');
|
|
139
|
+
},
|
|
140
|
+
})
|
|
141
|
+
.showHelpAfterError('(add --help for additional information)');
|
|
54
142
|
// Configuration file path
|
|
55
143
|
const configPath = path.join(process.env.HOME || '', '.amaran-cli.json');
|
|
56
144
|
// Load configuration
|
|
@@ -230,8 +318,6 @@ function findDevice(controller, deviceQuery) {
|
|
|
230
318
|
}
|
|
231
319
|
return device || null;
|
|
232
320
|
}
|
|
233
|
-
// Main CLI setup
|
|
234
|
-
program.name('amaran-cli').description('Command line tool for controlling Aputure Amaran lights').version('1.0.1');
|
|
235
321
|
// Configuration command
|
|
236
322
|
program
|
|
237
323
|
.command('config')
|
|
@@ -245,9 +331,10 @@ program
|
|
|
245
331
|
.option('--cct-max <kelvin>', 'Maximum CCT for auto-cct in Kelvin (default: 6500)')
|
|
246
332
|
.option('--intensity-min <percent>', 'Minimum intensity for auto-cct in percent (default: 5)')
|
|
247
333
|
.option('--intensity-max <percent>', 'Maximum intensity for auto-cct in percent (default: 100)')
|
|
334
|
+
.option('--default-curve <curve>', 'Default curve type (hann, wider-middle-small, wider-middle-medium, wider-middle-large, cie-daylight, sun-altitude, perez-daylight)')
|
|
248
335
|
.option('--auto-start-app <boolean>', 'Automatically start Amaran desktop app on connection failure (default: true)')
|
|
249
336
|
.option('--show', 'Show current configuration')
|
|
250
|
-
.action((options) => {
|
|
337
|
+
.action(async (options) => {
|
|
251
338
|
if (options.show) {
|
|
252
339
|
const config = loadConfig();
|
|
253
340
|
console.log(chalk_1.default.blue('Current configuration:'));
|
|
@@ -340,6 +427,19 @@ program
|
|
|
340
427
|
config.intensityMax = clamp(p, 0, 100);
|
|
341
428
|
changes.push(`Intensity maximum: ${config.intensityMax}%`);
|
|
342
429
|
}
|
|
430
|
+
// Handle default curve option
|
|
431
|
+
if (options.defaultCurve !== undefined) {
|
|
432
|
+
const { parseCurveType } = await Promise.resolve().then(() => __importStar(require('./cctUtil')));
|
|
433
|
+
try {
|
|
434
|
+
parseCurveType(options.defaultCurve);
|
|
435
|
+
config.defaultCurve = options.defaultCurve;
|
|
436
|
+
changes.push(`Default curve: ${config.defaultCurve}`);
|
|
437
|
+
}
|
|
438
|
+
catch (error) {
|
|
439
|
+
console.error(chalk_1.default.red(error.message));
|
|
440
|
+
process.exit(1);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
343
443
|
// Handle auto-start-app option
|
|
344
444
|
if (options.autoStartApp !== undefined) {
|
|
345
445
|
const value = options.autoStartApp;
|
|
@@ -376,6 +476,8 @@ program
|
|
|
376
476
|
});
|
|
377
477
|
// Register all commands
|
|
378
478
|
(0, commands_1.default)(program, { createController, findDevice, asyncCommand, saveWsUrl, loadConfig });
|
|
479
|
+
// Add custom help command that preserves the formatting
|
|
480
|
+
program.addHelpCommand('help [command]', 'Display help for a specific command');
|
|
379
481
|
// If this file is run directly, parse the arguments
|
|
380
482
|
if (require.main === module) {
|
|
381
483
|
program.parse();
|