@zenovate/opman 0.1.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 +222 -0
- package/npm/cli.js +52 -0
- package/npm/vendor/darwin-arm64/.gitkeep +0 -0
- package/npm/vendor/darwin-arm64/opman +0 -0
- package/npm/vendor/darwin-x64/.gitkeep +0 -0
- package/npm/vendor/darwin-x64/opman +0 -0
- package/npm/vendor/win32-x64/.gitkeep +0 -0
- package/npm/vendor/win32-x64/opman.exe +0 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# @zenovate/opman
|
|
2
|
+
|
|
3
|
+
CLI for OP devices: compile Python to PikaPython bytecode (`.py.o`), upload over **serial** or **BLE**, with command mode and Python REPL.
|
|
4
|
+
|
|
5
|
+
- **Platforms**: macOS (arm64 / x64), Windows x64
|
|
6
|
+
- **npm**: [@zenovate/opman](https://www.npmjs.com/package/@zenovate/opman)
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g @zenovate/opman
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Project-local:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -D @zenovate/opman
|
|
18
|
+
npx opman --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Commands
|
|
22
|
+
|
|
23
|
+
| Task | Command |
|
|
24
|
+
|------|---------|
|
|
25
|
+
| Version | `opman --version` |
|
|
26
|
+
| Compile `.py` | `opman compile hello.py` / `opman compile *.py -o build/` |
|
|
27
|
+
| Upload file | `opman upload hello.py.o /py -p COM3 -b 9600` |
|
|
28
|
+
| Compile + upload + run | `opman deploy hello.py -p COM3 -b 9600` |
|
|
29
|
+
| Upload + run `.py.o` / `.o` | `opman deploy hello.py.o -p COM3 -b 9600` |
|
|
30
|
+
| Command mode / params | `opman shell -p COM3 -b 9600` |
|
|
31
|
+
| Python REPL | `opman python -p COM3 -b 9600` |
|
|
32
|
+
| BLE scan | `opman ble-scan [--name OP] [--all-devices]` |
|
|
33
|
+
| Raw monitor | `opman monitor -p COM3` |
|
|
34
|
+
| Shell completion | `opman completion bash` / `zsh` / `fish` / `powershell` |
|
|
35
|
+
|
|
36
|
+
> `opman python` enters Python REPL automatically — you do not need to switch device modes manually.
|
|
37
|
+
|
|
38
|
+
## deploy — compile, upload, and run
|
|
39
|
+
|
|
40
|
+
`deploy` accepts source or precompiled bytecode, uploads to the device (default directory `/py`), then runs `{"PythonFileRun":"<filename>"}`. Use `upload` if you only want to transfer without running.
|
|
41
|
+
|
|
42
|
+
**Input types**
|
|
43
|
+
|
|
44
|
+
| Input | Behavior |
|
|
45
|
+
|-------|----------|
|
|
46
|
+
| `.py` | Compile to `.py.o` locally, then upload and run |
|
|
47
|
+
| `.py.o` | Skip compile; upload and run |
|
|
48
|
+
| `.o` (any path ending in `.o`) | Same as `.py.o` — treated as bytecode |
|
|
49
|
+
|
|
50
|
+
**Flow:** compile (if `.py`) → connect → upload → `PythonFileRun` → (optional) raw monitor until **ESC**.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Serial: compile, upload, run (remote dir defaults to /py)
|
|
54
|
+
opman deploy examples/hello.py -p COM3 -b 9600
|
|
55
|
+
|
|
56
|
+
# Upload precompiled bytecode (skip compile)
|
|
57
|
+
opman deploy examples/hello.py.o -p COM3 -b 9600
|
|
58
|
+
opman deploy build/hello.o -p COM3 -b 9600
|
|
59
|
+
|
|
60
|
+
# Custom local compile output, remote name, timeout
|
|
61
|
+
opman deploy examples/hello.py -p COM3 -o build/hello.py.o \
|
|
62
|
+
--remote-name demo.py.o --run-timeout 60
|
|
63
|
+
|
|
64
|
+
# Custom remote directory
|
|
65
|
+
opman deploy examples/hello.py --remote-dir /py -p COM3 -b 9600
|
|
66
|
+
|
|
67
|
+
# Upload tuning
|
|
68
|
+
opman deploy examples/hello.py.o -p COM3 --packet-size 200 --skip-command-mode
|
|
69
|
+
|
|
70
|
+
# BLE by address or name (partial match)
|
|
71
|
+
opman deploy examples/hello.py --ble ZENO --monitor
|
|
72
|
+
|
|
73
|
+
# Monitor with hex + timestamp (press ESC to stop)
|
|
74
|
+
opman deploy examples/hello.py -p COM3 --monitor --hex --timestamp
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
| Flag | Default | Description |
|
|
78
|
+
|------|---------|-------------|
|
|
79
|
+
| `--remote-dir` | `/py` | Device directory to upload to |
|
|
80
|
+
| `-o` / `--output` | same dir as input | Local `.py.o` path when compiling `.py` |
|
|
81
|
+
| `--remote-name` | derived from input | Filename on device (used for `PythonFileRun`) |
|
|
82
|
+
| `--monitor` | off | After run succeeds, print raw device output until **ESC** |
|
|
83
|
+
| `--run-timeout` | `30` | Seconds to wait for `PythonFileRun` response |
|
|
84
|
+
| `--hex` | off | Hex display during `--monitor` |
|
|
85
|
+
| `--timestamp` | off | Timestamp prefix during `--monitor` |
|
|
86
|
+
| `-p` / `--ble` | — | Serial port, or BLE address / name (one required) |
|
|
87
|
+
| `-b` / `-c` | `115200` | Serial baud or full config, e.g. `9600,N,8,1` |
|
|
88
|
+
| `--packet-size` | `100` | Upload chunk size (bytes) |
|
|
89
|
+
| `--skip-command-mode` | off | Skip command mode before upload |
|
|
90
|
+
|
|
91
|
+
## upload
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
opman upload hello.py.o /py -p COM3 -b 9600
|
|
95
|
+
opman upload hello.py.o /py -p COM3 --remote-name custom.py.o
|
|
96
|
+
opman upload hello.py.o /py -p COM3 --packet-size 200 --skip-command-mode
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## monitor
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
opman monitor -p COM3
|
|
103
|
+
opman monitor -p COM3 --hex --timestamp -o capture.log
|
|
104
|
+
opman monitor -p COM3 --no-drain # serial only: keep pre-connect buffer
|
|
105
|
+
opman monitor --ble ZENO --hex -o ble.log
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
| Flag | Default | Description |
|
|
109
|
+
|------|---------|-------------|
|
|
110
|
+
| `--hex` | off | Hex display |
|
|
111
|
+
| `--timestamp` | off | Timestamp prefix per chunk |
|
|
112
|
+
| `--no-drain` | off | Do not drain serial buffer after connect (**serial only**) |
|
|
113
|
+
| `-o` / `--output` | — | Also write to file |
|
|
114
|
+
|
|
115
|
+
Press **ESC** (or Ctrl+C) to stop.
|
|
116
|
+
|
|
117
|
+
## python
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
opman python -p COM3 -b 9600
|
|
121
|
+
opman python -p COM3 --timeout 60
|
|
122
|
+
opman python -p COM3 --skip-python-mode # device already in REPL
|
|
123
|
+
opman python -p COM3 --no-legacy-fallback # do not fall back on old firmware path
|
|
124
|
+
opman python --ble ZENO
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Device: `exit()` to leave REPL. Local: `quit` disconnects only.
|
|
128
|
+
|
|
129
|
+
## Examples
|
|
130
|
+
|
|
131
|
+
**Compile**
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
opman compile examples/hello.py
|
|
135
|
+
opman compile examples/*.py
|
|
136
|
+
opman compile examples/*.py -o build/
|
|
137
|
+
opman compile examples/hello.py -o /tmp/custom.py.o
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Serial (Windows)**
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
opman deploy examples/hello.py -p COM3 -b 9600
|
|
144
|
+
opman deploy examples/hello.py.o -p COM3 -b 9600
|
|
145
|
+
opman deploy examples/hello.py -p COM3 -b 9600 --monitor
|
|
146
|
+
opman shell -p COM3 -b 9600
|
|
147
|
+
opman shell -p COM3 --skip-command-mode
|
|
148
|
+
opman python -p COM3 -b 9600
|
|
149
|
+
opman monitor -p COM3
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Serial config string (`-c`, same as `9600,N,8,1`)**
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
opman shell -p COM5 -c "9600,N,8,1"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**BLE**
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
opman ble-scan
|
|
162
|
+
opman ble-scan --name OP
|
|
163
|
+
opman ble-scan --all-devices
|
|
164
|
+
opman deploy examples/hello.py --ble AA:BB:CC:DD:EE:FF
|
|
165
|
+
opman deploy examples/hello.py.o --ble ZENO
|
|
166
|
+
opman deploy examples/hello.py --ble ZENO --monitor --hex
|
|
167
|
+
opman python --ble ZENO
|
|
168
|
+
opman monitor --ble ZENO --hex --timestamp
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Full parameter reference (Chinese): [docs/操作说明.md](docs/操作说明.md)
|
|
172
|
+
|
|
173
|
+
## Shell completion
|
|
174
|
+
|
|
175
|
+
Provided by the Go binary (`npm` global install or `bin/opman`). Tab-complete subcommands, flags, and local file paths.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
opman completion --help
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Current session**
|
|
182
|
+
|
|
183
|
+
| Shell | Command |
|
|
184
|
+
|-------|---------|
|
|
185
|
+
| Bash | `source <(opman completion bash)` |
|
|
186
|
+
| Zsh | `source <(opman completion zsh)` |
|
|
187
|
+
| Fish | `opman completion fish \| source` |
|
|
188
|
+
| PowerShell | `opman completion powershell \| Out-String \| Invoke-Expression` |
|
|
189
|
+
|
|
190
|
+
**Persist across sessions**
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Bash (Linux)
|
|
194
|
+
opman completion bash > /etc/bash_completion.d/opman
|
|
195
|
+
|
|
196
|
+
# Bash (macOS, Homebrew)
|
|
197
|
+
opman completion bash > $(brew --prefix)/etc/bash_completion.d/opman
|
|
198
|
+
|
|
199
|
+
# Zsh (macOS, Homebrew)
|
|
200
|
+
opman completion zsh > $(brew --prefix)/share/zsh/site-functions/_opman
|
|
201
|
+
|
|
202
|
+
# Fish
|
|
203
|
+
opman completion fish > ~/.config/fish/completions/opman.fish
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
PowerShell: add the “current session” command to your profile (`$PROFILE`).
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
# Smaller completion script (no flag descriptions)
|
|
210
|
+
opman completion bash --no-descriptions > /tmp/opman-completion.bash
|
|
211
|
+
source /tmp/opman-completion.bash
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Serial ports and BLE devices are **not** auto-suggested; connection flags `-p` / `--ble` are prioritized until one is set.
|
|
215
|
+
|
|
216
|
+
## Help
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
opman --help
|
|
220
|
+
opman <command> --help
|
|
221
|
+
opman deploy --help
|
|
222
|
+
```
|
package/npm/cli.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require('child_process');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
function platformKey() {
|
|
9
|
+
const { platform, arch } = process;
|
|
10
|
+
|
|
11
|
+
if (platform === 'darwin') {
|
|
12
|
+
if (arch === 'arm64' || arch === 'x64') {
|
|
13
|
+
return `darwin-${arch}`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (platform === 'win32') {
|
|
18
|
+
if (arch === 'x64') {
|
|
19
|
+
return 'win32-x64';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
console.error(
|
|
24
|
+
`[@zenovate/opman] Unsupported platform: ${platform}-${arch}. ` +
|
|
25
|
+
'Only macOS (arm64/x64) and Windows x64 are supported.',
|
|
26
|
+
);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const key = platformKey();
|
|
31
|
+
const binName = process.platform === 'win32' ? 'opman.exe' : 'opman';
|
|
32
|
+
const binPath = path.join(__dirname, 'vendor', key, binName);
|
|
33
|
+
|
|
34
|
+
if (!fs.existsSync(binPath)) {
|
|
35
|
+
console.error(`[@zenovate/opman] Binary not found: ${binPath}`);
|
|
36
|
+
console.error(
|
|
37
|
+
'Reinstall the package, or run scripts/build_npm.sh before publishing.',
|
|
38
|
+
);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const result = spawnSync(binPath, process.argv.slice(2), {
|
|
43
|
+
stdio: 'inherit',
|
|
44
|
+
windowsHide: false,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (result.error) {
|
|
48
|
+
console.error(`[@zenovate/opman] Failed to start: ${result.error.message}`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zenovate/opman",
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"description": "CLI for OP devices: compile Python to PikaPython bytecode, serial/BLE upload, OP>1 shell and OP>2 REPL",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/zenovate-team/opman.git"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"opman": "npm/cli.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"npm/cli.js",
|
|
14
|
+
"npm/vendor"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=16"
|
|
18
|
+
},
|
|
19
|
+
"os": [
|
|
20
|
+
"darwin",
|
|
21
|
+
"win32"
|
|
22
|
+
],
|
|
23
|
+
"cpu": [
|
|
24
|
+
"arm64",
|
|
25
|
+
"x64"
|
|
26
|
+
]
|
|
27
|
+
}
|