@vention/vention-cli 0.11.1 → 0.12.0
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 +276 -57
- package/cli.esm.js +9 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,84 +1,263 @@
|
|
|
1
|
-
# Vention CLI
|
|
1
|
+
# Vention CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> A command-line tool that enables local development of MachineLogic Python applications with bidirectional sync between your IDE and MachineBuilder.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- Supports MachineLogic Python apps only. Code-free MachineLogic programs are not supported.
|
|
7
|
-
- You must have the MachineLogic tab open for your design in MachineBuilder. Opening that tab makes the design active for the CLI.
|
|
8
|
-
- Learn about MachineLogic Python app structure (main.py, project.json, HMI, etc.): https://docs.vention.io/docs/machinelogic-python-programming-guide
|
|
5
|
+
---
|
|
9
6
|
|
|
10
|
-
##
|
|
7
|
+
## Table of Contents
|
|
8
|
+
- [✨ Features](#-features)
|
|
9
|
+
- [🧠 Concepts & Overview](#-concepts--overview)
|
|
10
|
+
- [⚙️ Installation & Setup](#-installation--setup)
|
|
11
|
+
- [🚀 Quickstart Tutorial](#-quickstart-tutorial)
|
|
12
|
+
- [🛠 How-to Guides](#-how-to-guides)
|
|
13
|
+
- [📖 API Reference](#-api-reference)
|
|
14
|
+
- [🔍 Troubleshooting & FAQ](#-troubleshooting--faq)
|
|
11
15
|
|
|
16
|
+
|
|
17
|
+
## ✨ Features
|
|
18
|
+
- **Local IDE development**: Edit MachineLogic Python apps in your preferred IDE with full tooling support
|
|
19
|
+
- **Bidirectional sync**: Pull apps from MachineBuilder and push changes back seamlessly
|
|
20
|
+
- **Active design detection**: Automatically finds and connects to designs with MachineLogic tab open
|
|
21
|
+
- **Smart file handling**: Automatically ignores build artifacts, virtual environments, and common development files
|
|
22
|
+
- **Session management**: Persistent authentication with secure token storage
|
|
23
|
+
- **Multiple apps support**: Link and switch between different apps within the same design
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 🧠 Concepts & Overview
|
|
28
|
+
|
|
29
|
+
### Active Design
|
|
30
|
+
The Vention CLI connects to **active designs** — designs where you have the MachineLogic tab open in MachineBuilder. This active session enables the CLI to discover available designs and apps for sync operations.
|
|
31
|
+
|
|
32
|
+
### Link State
|
|
33
|
+
When you pull or link an app, the CLI creates a `.machine-code-app-directory-info.json` file in your project root. This file maintains the connection between your local directory and a specific design/app combination, enabling seamless push/pull operations without re-selection.
|
|
34
|
+
|
|
35
|
+
### File Synchronization
|
|
36
|
+
- **Pull**: Downloads the app's source files from MachineBuilder and writes them to your local directory
|
|
37
|
+
- **Push**: Serializes local files and uploads them to the active design in MachineBuilder
|
|
38
|
+
- **Ignored patterns**: `venv`, `node_modules`, `dist`, `build`, `__pycache__`, `*.egg-info`, `.machine-code-app-directory-info.json`
|
|
39
|
+
|
|
40
|
+
### Authentication Flow
|
|
41
|
+
OAuth-based authentication opens a browser window for secure login. Session tokens are stored in `~/.vention-cli-config.json` for subsequent CLI operations.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## ⚙️ Installation & Setup
|
|
46
|
+
|
|
47
|
+
**Requirements:**
|
|
48
|
+
- Node.js 16 or higher
|
|
49
|
+
- npm or yarn
|
|
50
|
+
- Active MachineBuilder session with MachineLogic tab open
|
|
51
|
+
|
|
52
|
+
**Install globally via npm:**
|
|
12
53
|
```bash
|
|
13
|
-
# Install from npm
|
|
14
54
|
npm install -g @vention/vention-cli
|
|
15
55
|
```
|
|
16
56
|
|
|
17
|
-
|
|
57
|
+
**Verify installation:**
|
|
58
|
+
```bash
|
|
59
|
+
vention --version
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Command aliases:**
|
|
63
|
+
Use either `vention` or `vn` as the command prefix.
|
|
64
|
+
|
|
65
|
+
**Learn more about MachineLogic Python app structure:**
|
|
66
|
+
https://docs.vention.io/docs/machinelogic-python-programming-guide
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 🚀 Quickstart Tutorial
|
|
18
71
|
|
|
19
|
-
|
|
72
|
+
This tutorial shows the complete workflow from authentication to syncing your first app.
|
|
20
73
|
|
|
21
|
-
1
|
|
22
|
-
|
|
74
|
+
**Step 1: Open your design**
|
|
75
|
+
Open your design in MachineBuilder and select the **MachineLogic tab**. This activates the design for CLI access.
|
|
76
|
+
|
|
77
|
+
**Step 2: Authenticate**
|
|
23
78
|
```bash
|
|
24
79
|
vention login
|
|
25
80
|
```
|
|
26
|
-
|
|
81
|
+
This opens a browser window for secure OAuth login.
|
|
82
|
+
|
|
83
|
+
**Step 3: Pull your app locally**
|
|
27
84
|
```bash
|
|
28
85
|
vention pull
|
|
29
86
|
```
|
|
30
|
-
|
|
31
|
-
|
|
87
|
+
The CLI will:
|
|
88
|
+
- Show available active designs
|
|
89
|
+
- Let you select a design
|
|
90
|
+
- Display MachineLogic Python apps in that design
|
|
91
|
+
- Let you select an app to pull
|
|
92
|
+
- Create a folder named after the app with all source files
|
|
93
|
+
|
|
94
|
+
**Step 4: Edit locally**
|
|
95
|
+
Open the created folder in your IDE and edit files like `main.py` or `project.json`.
|
|
96
|
+
|
|
97
|
+
**Step 5: Push changes back**
|
|
32
98
|
```bash
|
|
33
99
|
vention push
|
|
34
100
|
```
|
|
35
|
-
|
|
101
|
+
Your changes are now uploaded to MachineBuilder.
|
|
102
|
+
|
|
103
|
+
**Step 6: Run in MachineBuilder**
|
|
104
|
+
Use the MachineLogic panel in MachineBuilder to run and test your updated app.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 🛠 How-to Guides
|
|
109
|
+
|
|
110
|
+
### Link an existing directory without pulling files
|
|
111
|
+
|
|
112
|
+
If you already have the app files locally and just want to establish the link:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
cd my-existing-app
|
|
116
|
+
vention link
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
This writes `.machine-code-app-directory-info.json` without overwriting your files.
|
|
120
|
+
|
|
121
|
+
### Update an already-linked app
|
|
122
|
+
|
|
123
|
+
If your directory is already linked, simply run pull again to update files in place:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
vention pull
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The CLI detects the existing link and updates the project without creating a new folder.
|
|
130
|
+
|
|
131
|
+
### Switch between different apps
|
|
132
|
+
|
|
133
|
+
To link your current directory to a different app:
|
|
134
|
+
|
|
135
|
+
1. Delete the `.machine-code-app-directory-info.json` file
|
|
136
|
+
2. Run `vention link` or `vention pull` and select the new app
|
|
137
|
+
|
|
138
|
+
### View help for any command
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
vention --help
|
|
142
|
+
vention pull --help
|
|
143
|
+
vention push --help
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Work with multiple environments
|
|
36
147
|
|
|
37
|
-
|
|
148
|
+
The CLI stores the environment (e.g., `prod`, `staging`) in the link metadata file. To switch environments, re-link to the desired environment.
|
|
38
149
|
|
|
39
|
-
|
|
40
|
-
- App selection: When pulling/linking, choose one of the design’s MachineLogic Python apps.
|
|
41
|
-
- Local state: The CLI writes `.machine-code-app-directory-info.json` at the project root to remember the selected design/app and environment.
|
|
42
|
-
- File sync:
|
|
43
|
-
- Pull: Downloads the app’s source files and writes them to disk.
|
|
44
|
-
- Push: Serializes local files and uploads them to your active design.
|
|
45
|
-
- Ignored items when pushing: `venv`, `node_modules`, `dist`, `build`, `__pycache__`, `*.egg-info`, `.machine-code-app-directory-info.json`.
|
|
150
|
+
---
|
|
46
151
|
|
|
47
|
-
##
|
|
152
|
+
## 📖 API Reference
|
|
153
|
+
|
|
154
|
+
### Global Options
|
|
48
155
|
|
|
49
156
|
```bash
|
|
50
|
-
vention --help #
|
|
51
|
-
vention --version #
|
|
157
|
+
vention --help # Display help information
|
|
158
|
+
vention --version # Display CLI version
|
|
52
159
|
```
|
|
53
160
|
|
|
54
|
-
|
|
161
|
+
### `vention login`
|
|
162
|
+
|
|
163
|
+
**Description:** Authenticate with your Vention account using OAuth.
|
|
164
|
+
|
|
165
|
+
**Usage:**
|
|
55
166
|
```bash
|
|
56
167
|
vention login
|
|
57
|
-
# will open a browser window where you will be able to login to your Vention account
|
|
58
168
|
```
|
|
59
169
|
|
|
60
|
-
|
|
170
|
+
**Behavior:**
|
|
171
|
+
- Opens a browser window for secure OAuth authentication
|
|
172
|
+
- Stores session tokens in `~/.vention-cli-config.json`
|
|
173
|
+
- Tokens persist across terminal sessions
|
|
174
|
+
|
|
175
|
+
**Exit codes:**
|
|
176
|
+
- `0`: Authentication successful
|
|
177
|
+
- `1`: Authentication failed or cancelled
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
### `vention pull`
|
|
182
|
+
|
|
183
|
+
**Description:** Fetch a MachineLogic Python app from your active design into the current directory.
|
|
184
|
+
|
|
185
|
+
**Usage:**
|
|
61
186
|
```bash
|
|
62
187
|
vention pull
|
|
63
|
-
# If the current folder isn’t linked yet, select a design (with MachineLogic open) and then an app.
|
|
64
|
-
# If linked, the CLI updates the existing project in place.
|
|
65
188
|
```
|
|
66
189
|
|
|
67
|
-
|
|
190
|
+
**Behavior:**
|
|
191
|
+
- If the directory is not linked: prompts for design and app selection, creates a new folder
|
|
192
|
+
- If the directory is already linked: updates files in place using stored link metadata
|
|
193
|
+
- Downloads all source files except ignored patterns
|
|
194
|
+
- Writes/updates `.machine-code-app-directory-info.json`
|
|
195
|
+
- Updates `lastPulledAt` timestamp
|
|
196
|
+
|
|
197
|
+
**Prerequisites:**
|
|
198
|
+
- User must be logged in (`vention login`)
|
|
199
|
+
- Target design must have MachineLogic tab open in MachineBuilder
|
|
200
|
+
- Target app must be a MachineLogic Python app (code-free apps not supported)
|
|
201
|
+
|
|
202
|
+
**Exit codes:**
|
|
203
|
+
- `0`: Pull successful
|
|
204
|
+
- `1`: Not logged in, no active design found, or pull failed
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
### `vention push`
|
|
209
|
+
|
|
210
|
+
**Description:** Upload local changes from the linked directory to your active design.
|
|
211
|
+
|
|
212
|
+
**Usage:**
|
|
68
213
|
```bash
|
|
69
|
-
vention
|
|
70
|
-
# Writes .machine-code-app-directory-info.json so future push/pull operations know what to target.
|
|
214
|
+
vention push
|
|
71
215
|
```
|
|
72
216
|
|
|
73
|
-
|
|
217
|
+
**Behavior:**
|
|
218
|
+
- Reads `.machine-code-app-directory-info.json` to identify target design/app
|
|
219
|
+
- Serializes all local files except ignored patterns
|
|
220
|
+
- Uploads to MachineBuilder
|
|
221
|
+
- Updates `lastPushedAt` timestamp
|
|
222
|
+
|
|
223
|
+
**Prerequisites:**
|
|
224
|
+
- Directory must be linked (contains `.machine-code-app-directory-info.json`)
|
|
225
|
+
- User must be logged in
|
|
226
|
+
- The same design must be active in MachineBuilder (MachineLogic tab open)
|
|
227
|
+
|
|
228
|
+
**Exit codes:**
|
|
229
|
+
- `0`: Push successful
|
|
230
|
+
- `1`: Not linked, not logged in, design not active, or push failed
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
### `vention link`
|
|
235
|
+
|
|
236
|
+
**Description:** Link the current directory to a design + app without pulling files.
|
|
237
|
+
|
|
238
|
+
**Usage:**
|
|
74
239
|
```bash
|
|
75
|
-
vention
|
|
76
|
-
# Requires the same design to be open in MachineBuilder (MachineLogic tab selected).
|
|
240
|
+
vention link
|
|
77
241
|
```
|
|
78
242
|
|
|
79
|
-
|
|
243
|
+
**Behavior:**
|
|
244
|
+
- Prompts for design and app selection
|
|
245
|
+
- Writes `.machine-code-app-directory-info.json` with link metadata
|
|
246
|
+
- Does not download or modify existing files
|
|
247
|
+
|
|
248
|
+
**Use case:** Useful when you already have the app files and just want to establish the connection for push operations.
|
|
80
249
|
|
|
81
|
-
|
|
250
|
+
**Exit codes:**
|
|
251
|
+
- `0`: Link successful
|
|
252
|
+
- `1`: Not logged in, no active design found, or link failed
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
### Link Metadata File
|
|
257
|
+
|
|
258
|
+
**Location:** `.machine-code-app-directory-info.json` (project root)
|
|
259
|
+
|
|
260
|
+
**Schema:**
|
|
82
261
|
```json
|
|
83
262
|
{
|
|
84
263
|
"appName": "My App",
|
|
@@ -91,27 +270,67 @@ The CLI stores link info in `.machine-code-app-directory-info.json` at the proje
|
|
|
91
270
|
}
|
|
92
271
|
```
|
|
93
272
|
|
|
94
|
-
|
|
273
|
+
**Fields:**
|
|
274
|
+
- `appName` (string): Human-readable app name
|
|
275
|
+
- `designId` (number): Unique design identifier
|
|
276
|
+
- `applicationId` (string): Unique application identifier
|
|
277
|
+
- `uuid` (string, optional): App UUID if available
|
|
278
|
+
- `environment` (string): Target environment (e.g., `prod`, `staging`)
|
|
279
|
+
- `lastPulledAt` (ISO 8601 timestamp): Last successful pull time
|
|
280
|
+
- `lastPushedAt` (ISO 8601 timestamp): Last successful push time
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## 🔍 Troubleshooting & FAQ
|
|
285
|
+
|
|
286
|
+
### Common Errors
|
|
287
|
+
|
|
288
|
+
**"Not logged in. Please run 'vention login' first."**
|
|
289
|
+
- **Cause:** Authentication tokens not found or expired
|
|
290
|
+
- **Solution:** Run `vention login` to re-authenticate
|
|
291
|
+
|
|
292
|
+
**"No active design found …" or "Please open the design and navigate to MachineLogic …"**
|
|
293
|
+
- **Cause:** No designs have the MachineLogic tab open in MachineBuilder
|
|
294
|
+
- **Solution:** Open your target design in MachineBuilder and click the MachineLogic tab to activate it
|
|
295
|
+
|
|
296
|
+
**"This directory is not linked …" (during push)**
|
|
297
|
+
- **Cause:** The directory doesn't have `.machine-code-app-directory-info.json`
|
|
298
|
+
- **Solution:** Run `vention link` or `vention pull` to establish the link
|
|
299
|
+
|
|
300
|
+
**Push fails with authentication errors**
|
|
301
|
+
- **Cause:** Session tokens expired
|
|
302
|
+
- **Solution:** Run `vention login` to refresh authentication
|
|
303
|
+
|
|
304
|
+
**"Directory already exists" (during pull)**
|
|
305
|
+
- **Cause:** A folder with the app name already exists
|
|
306
|
+
- **Solution:** Either:
|
|
307
|
+
- `cd` into the existing directory and run `vention pull` (updates in place)
|
|
308
|
+
- Rename or delete the conflicting folder
|
|
309
|
+
- Run `vention link` instead to link without creating a new folder
|
|
310
|
+
|
|
311
|
+
### FAQ
|
|
312
|
+
|
|
313
|
+
**Q: Can I use this with code-free MachineLogic programs?**
|
|
314
|
+
A: No, only MachineLogic Python apps are supported.
|
|
315
|
+
|
|
316
|
+
**Q: Do I need to keep MachineBuilder open while editing locally?**
|
|
317
|
+
A: No, you only need MachineBuilder open (with MachineLogic tab active) when running `pull` or `push` commands.
|
|
95
318
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
- The CLI ignores common build artifacts and environments when pushing (see list above).
|
|
99
|
-
- Session storage: Login data is saved to `~/.vention-cli-config.json`.
|
|
319
|
+
**Q: Where are my authentication tokens stored?**
|
|
320
|
+
A: In `~/.vention-cli-config.json` in your home directory.
|
|
100
321
|
|
|
101
|
-
|
|
322
|
+
**Q: Can I work on multiple apps simultaneously?**
|
|
323
|
+
A: Yes, each app folder maintains its own link metadata. You can have multiple linked directories.
|
|
102
324
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
- Use `vention pull` to get the app locally, edit in your IDE, then `vention push` to update the running app in your active design.
|
|
106
|
-
- Use the MachineLogic UI to run and test.
|
|
325
|
+
**Q: What files are ignored during push?**
|
|
326
|
+
A: `venv`, `node_modules`, `dist`, `build`, `__pycache__`, `*.egg-info`, and `.machine-code-app-directory-info.json`.
|
|
107
327
|
|
|
108
|
-
|
|
328
|
+
**Q: Can I add custom ignore patterns?**
|
|
329
|
+
A: Not currently. The ignore list is built into the CLI.
|
|
109
330
|
|
|
110
|
-
|
|
331
|
+
**Q: What happens if I edit the same app in both MachineBuilder and locally?**
|
|
332
|
+
A: The last push/pull wins. There's no conflict resolution or merging. We recommend using version control (Git) for your local copy.
|
|
111
333
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
- “This directory is not linked …” during push → Run `vention link` or pull the app first.
|
|
115
|
-
- Push fails with auth errors → Re-run `vention login` (tokens may have expired).
|
|
116
|
-
- Directory already exists when pulling → Either run pull inside the existing project directory or rename/delete the conflicting folder.
|
|
334
|
+
**Q: Does this work with MachineMotion apps?**
|
|
335
|
+
A: The CLI specifically targets MachineLogic Python apps. For MachineMotion development, see the MachineMotion SDK documentation.
|
|
117
336
|
|
package/cli.esm.js
CHANGED
|
@@ -386,7 +386,7 @@ const createFileSystemFromJson = async (fileSystemNode, targetDirectory) => {
|
|
|
386
386
|
const decodedContent = Buffer.from(contentOrNode, "base64");
|
|
387
387
|
const fileHandle = await fs.promises.open(fullPath, "w");
|
|
388
388
|
try {
|
|
389
|
-
await fileHandle.writeFile(decodedContent);
|
|
389
|
+
await fileHandle.writeFile(new Uint8Array(decodedContent));
|
|
390
390
|
await fileHandle.sync();
|
|
391
391
|
}
|
|
392
392
|
finally {
|
|
@@ -400,12 +400,14 @@ const createFileSystemFromJson = async (fileSystemNode, targetDirectory) => {
|
|
|
400
400
|
}
|
|
401
401
|
};
|
|
402
402
|
await writeFiles(fileSystemNode, targetDirectory);
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
403
|
+
if (process.platform !== "win32") {
|
|
404
|
+
const dirHandle = await fs.promises.open(targetDirectory, "r");
|
|
405
|
+
try {
|
|
406
|
+
await dirHandle.sync();
|
|
407
|
+
}
|
|
408
|
+
finally {
|
|
409
|
+
await dirHandle.close();
|
|
410
|
+
}
|
|
409
411
|
}
|
|
410
412
|
};
|
|
411
413
|
const ensureDirectoryExists = async (directory) => {
|