@microtronics/studio-cli 1.2.0-alpha.2 → 1.2.0-alpha.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/README.md +136 -7
- package/dist/main.js +73 -57
- package/dist/studio-cli.d.ts +416 -1
- package/out/api.js +729 -41
- package/out/studio-cli.d.ts +416 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# @microtronics/studio-cli
|
|
2
|
+
|
|
2
3
|
> The Microtronics Studio CLI Tool
|
|
3
4
|
|
|
4
5
|
This tool assists in installing, packaging and publishing Microtronics Studio libraries and apps.
|
|
@@ -16,22 +17,21 @@ $ npm i -g @microtronics/studio-cli
|
|
|
16
17
|
```console
|
|
17
18
|
$ studio-cli --version
|
|
18
19
|
```
|
|
19
|
-
For a reference on all the available `studio-cli` commands, run `studio-cli --help`
|
|
20
20
|
|
|
21
|
+
For a reference on all the available `studio-cli` commands, run `studio-cli --help`
|
|
21
22
|
|
|
22
23
|
## Requirements
|
|
23
24
|
|
|
24
25
|
[Node.js](https://nodejs.org/en/) version `22` or higher.
|
|
25
26
|
|
|
26
|
-
|
|
27
27
|
## Standalone executables
|
|
28
28
|
|
|
29
29
|
Prebuilt single-file binaries are available for users without a [Node.js](https://nodejs.org) installation. They require no `node_modules` and no global npm install. Each binary is built with [`@yao-pkg/pkg`](https://github.com/yao-pkg/pkg) and bundles the Node 22 runtime, the `usb` native addon and the `pawncc-wasm` DLO compiler. macOS is not built for now.
|
|
30
30
|
|
|
31
|
-
| Platform
|
|
32
|
-
|
|
|
33
|
-
| Windows x64
|
|
34
|
-
| Linux x64 (glibc) | `studio-cli-linux-x64-<version>`
|
|
31
|
+
| Platform | Artifact |
|
|
32
|
+
| ----------------- | ---------------------------------- |
|
|
33
|
+
| Windows x64 | `studio-cli-win-x64-<version>.exe` |
|
|
34
|
+
| Linux x64 (glibc) | `studio-cli-linux-x64-<version>` |
|
|
35
35
|
|
|
36
36
|
The Linux binary is glibc-linked and does not run on musl-only distributions such as Alpine.
|
|
37
37
|
|
|
@@ -73,6 +73,7 @@ The npm package is unaffected: the binaries are additional artifacts, and `npm i
|
|
|
73
73
|
## Commands
|
|
74
74
|
|
|
75
75
|
### install (alias: i)
|
|
76
|
+
|
|
76
77
|
Install all dependencies in your project.
|
|
77
78
|
|
|
78
79
|
```console
|
|
@@ -85,10 +86,12 @@ project root with `npm install` - an in-sync `package-lock.json` is installed as
|
|
|
85
86
|
non-workspace projects (or not covered by any workspace pattern) are installed individually with `npm ci`.
|
|
86
87
|
|
|
87
88
|
**Options:**
|
|
89
|
+
|
|
88
90
|
- `-e, --env <environment>` - CLI target environment (defaults to STUDIO_ENV environment variable)
|
|
89
91
|
- `--token <API-token>` - API Access Token (defaults to STUDIO_TOKEN environment variable)
|
|
90
92
|
|
|
91
93
|
**Examples:**
|
|
94
|
+
|
|
92
95
|
```console
|
|
93
96
|
$ studio-cli install
|
|
94
97
|
$ studio-cli i
|
|
@@ -96,6 +99,7 @@ $ studio-cli install dependency-name
|
|
|
96
99
|
```
|
|
97
100
|
|
|
98
101
|
### build
|
|
102
|
+
|
|
99
103
|
Build the project.
|
|
100
104
|
|
|
101
105
|
```console
|
|
@@ -103,6 +107,7 @@ $ studio-cli build [options]
|
|
|
103
107
|
```
|
|
104
108
|
|
|
105
109
|
**Options:**
|
|
110
|
+
|
|
106
111
|
- `-p, --part <APM part>` - APM part that should be built
|
|
107
112
|
- Available parts: `dde`, `dlo`, `pov`, `blo`, `dfiles`
|
|
108
113
|
- `-e, --env <environment>` - CLI target environment
|
|
@@ -113,6 +118,7 @@ $ studio-cli build [options]
|
|
|
113
118
|
You can overwrite manifest options using the `--option=value` syntax.
|
|
114
119
|
|
|
115
120
|
**Examples:**
|
|
121
|
+
|
|
116
122
|
```console
|
|
117
123
|
$ studio-cli build
|
|
118
124
|
$ studio-cli build --part dlo
|
|
@@ -121,6 +127,7 @@ $ studio-cli build --dlo.mainFile="./dlo/test.dlo"
|
|
|
121
127
|
```
|
|
122
128
|
|
|
123
129
|
### publish
|
|
130
|
+
|
|
124
131
|
Publish the project to the registry.
|
|
125
132
|
|
|
126
133
|
```console
|
|
@@ -128,6 +135,7 @@ $ studio-cli publish [options]
|
|
|
128
135
|
```
|
|
129
136
|
|
|
130
137
|
**Options:**
|
|
138
|
+
|
|
131
139
|
- `-ph, --phase <release phase>` - Specify a release phase (default: `release`)
|
|
132
140
|
- Available phases: `alpha`, `beta`, `rc`, `release`, `stage`, `passive`, `withdrawn`
|
|
133
141
|
- `--allowedBackends <null|*|server.xz;server.yz>` - Specify the allowedBackends deployment for this version
|
|
@@ -140,6 +148,7 @@ $ studio-cli publish [options]
|
|
|
140
148
|
- `-i, --packagePath <path>` - Publish the provided library or app package. Use "*" for autodetection
|
|
141
149
|
|
|
142
150
|
**Examples:**
|
|
151
|
+
|
|
143
152
|
```console
|
|
144
153
|
$ studio-cli publish
|
|
145
154
|
$ studio-cli publish --phase beta
|
|
@@ -148,6 +157,7 @@ $ studio-cli publish --packagePath ./my-package.tar.gz --env wynni
|
|
|
148
157
|
```
|
|
149
158
|
|
|
150
159
|
### package (alias: pack)
|
|
160
|
+
|
|
151
161
|
Package the project.
|
|
152
162
|
|
|
153
163
|
```console
|
|
@@ -155,6 +165,7 @@ $ studio-cli package [options]
|
|
|
155
165
|
```
|
|
156
166
|
|
|
157
167
|
**Options:**
|
|
168
|
+
|
|
158
169
|
- `-ph, --phase <release phase>` - Specify a release phase (default: `release`)
|
|
159
170
|
- Available phases: `alpha`, `beta`, `rc`, `release`, `stage`, `passive`, `withdrawn`
|
|
160
171
|
- `-e, --env <environment>` - CLI target environment
|
|
@@ -162,6 +173,7 @@ $ studio-cli package [options]
|
|
|
162
173
|
- `--token <API-token>` - API Access Token
|
|
163
174
|
|
|
164
175
|
**Examples:**
|
|
176
|
+
|
|
165
177
|
```console
|
|
166
178
|
$ studio-cli package
|
|
167
179
|
$ studio-cli pack --phase alpha
|
|
@@ -169,6 +181,7 @@ $ studio-cli pack --env wynni
|
|
|
169
181
|
```
|
|
170
182
|
|
|
171
183
|
### run
|
|
184
|
+
|
|
172
185
|
Build, upload to USB device, and create development site on myDatanet. This command is designed for development and integration testing purposes.
|
|
173
186
|
|
|
174
187
|
```console
|
|
@@ -176,6 +189,7 @@ $ studio-cli run -s <serial> --server <url> [options]
|
|
|
176
189
|
```
|
|
177
190
|
|
|
178
191
|
**Options:**
|
|
192
|
+
|
|
179
193
|
- `-s, --serial <serial>` - Device serial number (16 characters hex) **[required]**
|
|
180
194
|
- `--server <url>` - myDatanet instance URL (https:// prefix optional). Defaults to `MYDATANET_HOST` environment variable
|
|
181
195
|
- `--customer <customerId>` - myDatanet customer UID or ID. Defaults to `MYDATANET_CUSTOMER` environment variable
|
|
@@ -191,6 +205,7 @@ $ studio-cli run -s <serial> --server <url> [options]
|
|
|
191
205
|
- `--siteName <name>` - Override the auto-generated development site name (max 50 characters). By default, the site name is derived from the device serial number (for DLO projects) or from the app name and current user (e.g. `MyApp_JohnDoe`)
|
|
192
206
|
|
|
193
207
|
**Exit Codes:**
|
|
208
|
+
|
|
194
209
|
- `0` - Success
|
|
195
210
|
- `1` - Build failed
|
|
196
211
|
- `2` - USB device not found
|
|
@@ -201,16 +216,19 @@ $ studio-cli run -s <serial> --server <url> [options]
|
|
|
201
216
|
|
|
202
217
|
**Output:**
|
|
203
218
|
On success, the command outputs:
|
|
219
|
+
|
|
204
220
|
- Site UID of the newly created/reused development site
|
|
205
221
|
- Site name
|
|
206
222
|
- APM ID of the development tag
|
|
207
223
|
|
|
208
224
|
With `--json`, the output is a single JSON line:
|
|
225
|
+
|
|
209
226
|
```json
|
|
210
|
-
{"siteUid":"<uid>","siteName":"<name>","apmId":"<id>"}
|
|
227
|
+
{ "siteUid": "<uid>", "siteName": "<name>", "apmId": "<id>" }
|
|
211
228
|
```
|
|
212
229
|
|
|
213
230
|
**Examples:**
|
|
231
|
+
|
|
214
232
|
```console
|
|
215
233
|
# Basic usage with environment variables
|
|
216
234
|
$ export MYDATANET_TOKEN=your_token
|
|
@@ -235,9 +253,11 @@ $ studio-cli run -s 1234567890ABCDEF --server myserver.mydatanet.net --silent --
|
|
|
235
253
|
```
|
|
236
254
|
|
|
237
255
|
### usb
|
|
256
|
+
|
|
238
257
|
USB device management commands.
|
|
239
258
|
|
|
240
259
|
#### usb list
|
|
260
|
+
|
|
241
261
|
List available USB devices.
|
|
242
262
|
|
|
243
263
|
```console
|
|
@@ -245,6 +265,7 @@ $ studio-cli usb list
|
|
|
245
265
|
```
|
|
246
266
|
|
|
247
267
|
#### usb upload
|
|
268
|
+
|
|
248
269
|
Upload an AMX binary to a USB device.
|
|
249
270
|
|
|
250
271
|
```console
|
|
@@ -252,17 +273,20 @@ $ studio-cli usb upload -s <serial> -f <path> [--debug]
|
|
|
252
273
|
```
|
|
253
274
|
|
|
254
275
|
**Options:**
|
|
276
|
+
|
|
255
277
|
- `-s, --serial <serial>` - Device serial number (16 characters hex) **[required]**
|
|
256
278
|
- `-f, --file <path>` - Path to the AMX file (relative to current directory) **[required]**
|
|
257
279
|
- `--debug` - Enable debug logging
|
|
258
280
|
|
|
259
281
|
**Example:**
|
|
282
|
+
|
|
260
283
|
```console
|
|
261
284
|
$ studio-cli usb upload -s 1234567890ABCDEF -f ./app.amx
|
|
262
285
|
$ studio-cli usb upload -s 1234567890ABCDEF -f ./app.amx --debug
|
|
263
286
|
```
|
|
264
287
|
|
|
265
288
|
#### usb sync
|
|
289
|
+
|
|
266
290
|
Sync a USB device with the myDatanet server. This triggers a full device synchronization including optional MNT and MDN communication phases.
|
|
267
291
|
|
|
268
292
|
```console
|
|
@@ -270,15 +294,120 @@ $ studio-cli usb sync -s <serial> [--debug]
|
|
|
270
294
|
```
|
|
271
295
|
|
|
272
296
|
**Options:**
|
|
297
|
+
|
|
273
298
|
- `-s, --serial <serial>` - Device serial number (16 characters hex) **[required]**
|
|
274
299
|
- `--debug` - Enable debug logging (shows sync mode, phases, and message counts)
|
|
275
300
|
|
|
276
301
|
**Example:**
|
|
302
|
+
|
|
277
303
|
```console
|
|
278
304
|
$ studio-cli usb sync -s 1234567890ABCDEF
|
|
279
305
|
$ studio-cli usb sync -s 1234567890ABCDEF --debug
|
|
280
306
|
```
|
|
281
307
|
|
|
308
|
+
### dev
|
|
309
|
+
|
|
310
|
+
Build, flash and serve a **myDatanet-compatible REST API for the attached USB device** on localhost, using the
|
|
311
|
+
project's own `dist/dde/dde.xml` as the data model. Reads are served from an in-memory mirror that a stamp poller
|
|
312
|
+
keeps in sync with the device; writes are encoded via the project DDE and pushed as UTO `DATA` frames.
|
|
313
|
+
|
|
314
|
+
```console
|
|
315
|
+
$ studio-cli dev -s <serial> [options]
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Options:**
|
|
319
|
+
|
|
320
|
+
- `-s, --serial <serial>` - Device serial number (16 characters hex) **[required]**
|
|
321
|
+
- `--port <port>` - HTTP port (default `8765`)
|
|
322
|
+
- `--host <host>` - Bind address (default `127.0.0.1`)
|
|
323
|
+
- `--allow-remote` - Permit a non-loopback `--host` without `--bearer`
|
|
324
|
+
- `--watch` - Rebuild, flash and sync on changes under `dlo/`, `dde/`, `app.ini`, `studio.json`
|
|
325
|
+
- `--no-build` / `--no-flash` - Skip the initial build / the `dist/dlo/main.amx` upload
|
|
326
|
+
- `--poll-interval <ms>` - Stamp-poll interval (default `2000`, `0` disables)
|
|
327
|
+
- `--wait <ms>` - How long a write waits for the device to confirm it (default `3000`)
|
|
328
|
+
- `--log-file [path]` - Append every log record as JSONL (default `.studio/dev/device.jsonl`)
|
|
329
|
+
- `--bearer <token>` - Require this bearer token (`--token` stays the Studio API token)
|
|
330
|
+
- `--pov [name]` - Also start `npm run dev -w pov/<name>` (default `details`) with `MYDATANET_HOST` injected
|
|
331
|
+
- `--json` - Print one JSON line `{url, serial, apmId, port}`, then JSONL events
|
|
332
|
+
|
|
333
|
+
Without `--bearer`, any incoming `Authorization` header is ignored, so a POV dev server proxying its
|
|
334
|
+
`MYDATANET_TOKEN` works unchanged. `/api/1/sites/<uid>/...` accepts **any** site uid.
|
|
335
|
+
|
|
336
|
+
A non-loopback `--host` (for example `0.0.0.0`) without `--bearer` would expose container writes, AT commands
|
|
337
|
+
and flashing to everyone who can reach the port, so it is **refused**. Pass `--bearer <token>`, or
|
|
338
|
+
`--allow-remote` to bind unauthenticated anyway - which logs a warning.
|
|
339
|
+
|
|
340
|
+
Numeric options (`--port`, `--poll-interval`, `--wait`, and `--limit`/`--duration` on the `device`
|
|
341
|
+
subcommands) must be integers in range; anything else is reported and exits with code `1`.
|
|
342
|
+
|
|
343
|
+
In a non-`--json` TTY session, stdin accepts `at <cmd>`, `sync`, `flash`, `build` and `q`.
|
|
344
|
+
|
|
345
|
+
**Endpoints:**
|
|
346
|
+
|
|
347
|
+
| Method / path | Purpose |
|
|
348
|
+
| --------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
349
|
+
| `/api/1/sites/<uid>/...` | myDatanet-compatible containers, timeseries, blueprint, `/api/1/me`, legacy `config[0-9a-c]` |
|
|
350
|
+
| `GET /dev/status` | Serial, connection, model containers, last sync, build state, poll status |
|
|
351
|
+
| `POST /dev/build` | Run the build; returns diagnostics |
|
|
352
|
+
| `POST /dev/flash` | Upload `dist/dlo/main.amx` (or `{"file": "..."}`) |
|
|
353
|
+
| `POST /dev/sync` | Full sync, or a targeted pull with `{"tags": [...]}` |
|
|
354
|
+
| `GET /dev/logs` | Ring buffer (5000 records), `?since=<seq>&limit=` |
|
|
355
|
+
| `POST /dev/at` | One AT command, `{"cmd": "at+rm2mstate"}` |
|
|
356
|
+
| `GET /dev/state` | Last rm2m state |
|
|
357
|
+
| `GET /dev/localdata`, `POST /dev/localdata/measure` | Live local-data values / trigger a measurement |
|
|
358
|
+
| `GET /dev/openapi.json` | `dist/api/main.yaml` merged with the `/dev/*` paths |
|
|
359
|
+
| `GET /events` | SSE: `log`, `state`, `sync`, `build`, `uto`, `container-changed`; `?types=log,build` filters |
|
|
360
|
+
|
|
361
|
+
Errors use the myDatanet envelope `{"err": "E_CODE message"}`. A write whose device confirmation did not arrive
|
|
362
|
+
within `--wait` is answered with the header `x-mt-mirror: stale`; `?async=1` skips the wait entirely.
|
|
363
|
+
|
|
364
|
+
**Agent workflow:**
|
|
365
|
+
|
|
366
|
+
```console
|
|
367
|
+
$ studio-cli dev -s 1234567890ABCDEF --watch --json & # server + auto build/flash on save
|
|
368
|
+
$ curl :8765/dev/openapi.json # discover this project's API
|
|
369
|
+
$ curl -X PUT :8765/api/1/sites/dev/containers/command -d '{"param1":3,"param2":4}'
|
|
370
|
+
$ curl :8765/api/1/sites/dev/containers/state # -> {"sum":7} (the DLO wrote it)
|
|
371
|
+
$ curl ':8765/dev/logs?since=0' # rm2mlog / printf output
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### device
|
|
375
|
+
|
|
376
|
+
One-shot, agent-friendly device commands: connect, act, disconnect. Every subcommand accepts
|
|
377
|
+
`--url http://127.0.0.1:8765` to run against an already-running `studio-cli dev` server instead of opening USB
|
|
378
|
+
(the USB device is single-owner - the server holds it), plus `--json`, `--silent` and `--debug`.
|
|
379
|
+
|
|
380
|
+
```console
|
|
381
|
+
$ studio-cli device <command> -s <serial> [options]
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
| Command | Purpose |
|
|
385
|
+
| -------------------------- | ---------------------------------------------------------------------- |
|
|
386
|
+
| `info` | DEVINFO/STAMPS-derived status and the model's containers |
|
|
387
|
+
| `get <container>[.field]` | Read a container, decoded via the project DDE |
|
|
388
|
+
| `set <container> <values>` | Encode a JSON object, push it, re-read the container |
|
|
389
|
+
| `timeseries <container>` | Histdata window; `--from`, `--to`, `--limit` |
|
|
390
|
+
| `logs` | Ring buffer; `--follow`, `--duration <ms>`, `--filter <regex>` |
|
|
391
|
+
| `at <cmd>` | One AT command |
|
|
392
|
+
| `state` | Last rm2m state |
|
|
393
|
+
| `flash` | `usb upload` defaulting to `dist/dlo/main.amx`; `-f, --file` overrides |
|
|
394
|
+
| `sync` | Pull the device data into the mirror (alias of `usb sync`'s intent) |
|
|
395
|
+
|
|
396
|
+
`device set` prints `{container, written, stale, record}`. `stale: true` means the device did not confirm the
|
|
397
|
+
push within `--wait` (the mirror holds the value, the device may not) - the command still exits `0`; check the
|
|
398
|
+
flag rather than the exit code.
|
|
399
|
+
|
|
400
|
+
**Exit codes:** `0` success, `1` build failed, `2` device not found, `3` USB/UTO error, `7` no
|
|
401
|
+
`dist/dde/dde.xml` (run `studio-cli build` first), `8` unknown container/field, `9` write forbidden.
|
|
402
|
+
|
|
403
|
+
**Examples:**
|
|
404
|
+
|
|
405
|
+
```console
|
|
406
|
+
$ studio-cli device get command --url http://127.0.0.1:8765 --json
|
|
407
|
+
$ studio-cli device set command '{"param1":3}' -s 1234567890ABCDEF --json
|
|
408
|
+
$ studio-cli device logs -s 1234567890ABCDEF --follow --duration 10000
|
|
409
|
+
```
|
|
410
|
+
|
|
282
411
|
## Library APM parts: version and dependencies
|
|
283
412
|
|
|
284
413
|
Studio libraries (`type: "library"`) ship npm-consumable APM parts as `dist/blo/package.json` and
|