@beyondwork/wb-cli 0.1.18 → 0.1.20
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 +5 -0
- package/README.md +15 -18
- package/out/extension.js +43 -7
- package/out/types.js +27 -0
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -13,11 +13,11 @@ The workblocks in those workspaces can then be stored as files on your local mac
|
|
|
13
13
|
|
|
14
14
|
The extension has 3 features:
|
|
15
15
|
|
|
16
|
-
- Get a
|
|
17
|
-
- Set a
|
|
18
|
-
- Live sync
|
|
16
|
+
- Get a workblock from an existing workspace to local filesystem
|
|
17
|
+
- Set a workblock on a workspace from local files
|
|
18
|
+
- Live sync workblocks between open workspaces and local filesystem
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Workblocks are expected to be placed in a directory that contains nothing but workblocks. When starting from scratch simply create a new directory somewhere.
|
|
21
21
|
|
|
22
22
|
### Getting started
|
|
23
23
|
|
|
@@ -29,18 +29,17 @@ Then, click on the connection in the BEYOND WORK sidebar. This will prompt for a
|
|
|
29
29
|
The connection should now have a blue checkmark. Under it, workspaces with an open editor will be shown. Each of them can be bound to a directory by clicking on them
|
|
30
30
|
and choosing `Choose a directory`.
|
|
31
31
|
|
|
32
|
+
### Getting a workblock
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
Click a workspace in the menu and choose \`Get workblock from workspace\`. This takes the workblock that's in the workspace provided and downloads it to the directory associated with the workspace.
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
### Setting a workblock
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
Click a workspace in the menu and choose \`Store workblock to workspace\`. This takes the workblock files in the associated directory and combines them into a workblock definition and sets it in the workspace provided.
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
Note that this does not actually store the workblock outside the workspace. In order to do that open the workblock editor in the workspace and click store.
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
### Syncing work blocks
|
|
42
|
+
### Syncing workblocks
|
|
44
43
|
|
|
45
44
|
Click a workspace in the menu and choose \`Enable sync\`.
|
|
46
45
|
|
|
@@ -50,7 +49,7 @@ Notice that workblocks are validated before they are set on a workspace. If a wo
|
|
|
50
49
|
|
|
51
50
|
### Directory structure
|
|
52
51
|
|
|
53
|
-
The
|
|
52
|
+
The workblock directory structure is like this:
|
|
54
53
|
|
|
55
54
|
<pre>
|
|
56
55
|
Base dir/
|
|
@@ -62,7 +61,6 @@ Base dir/
|
|
|
62
61
|
manifest.yaml
|
|
63
62
|
</pre>
|
|
64
63
|
|
|
65
|
-
|
|
66
64
|
## CLI Tool
|
|
67
65
|
|
|
68
66
|
In addition to the VS Code extension, this package provides a command-line interface (CLI) for working with Beyond Work workblocks.
|
|
@@ -80,6 +78,7 @@ pnpm add -g beyondwork
|
|
|
80
78
|
### CLI Usage
|
|
81
79
|
|
|
82
80
|
#### Assemble a workblock from a directory
|
|
81
|
+
|
|
83
82
|
```bash
|
|
84
83
|
beyondwork assemble /path/to/workblock/dir [--output output.json]
|
|
85
84
|
```
|
|
@@ -101,13 +100,11 @@ Base dir/
|
|
|
101
100
|
You can also use the library programmatically:
|
|
102
101
|
|
|
103
102
|
```typescript
|
|
104
|
-
import { assembleWorkblock, storeWorkblockFiles } from
|
|
103
|
+
import { assembleWorkblock, storeWorkblockFiles } from "beyondwork/lib/utils";
|
|
105
104
|
|
|
106
105
|
// Assemble a workblock from files
|
|
107
|
-
const workblock = await assembleWorkblock(
|
|
106
|
+
const workblock = await assembleWorkblock("/path/to/workblock");
|
|
108
107
|
|
|
109
108
|
// Store a workblock as files
|
|
110
|
-
await storeWorkblockFiles(
|
|
109
|
+
await storeWorkblockFiles("/output/path", workblockObject);
|
|
111
110
|
```
|
|
112
|
-
|
|
113
|
-
|
package/out/extension.js
CHANGED
|
@@ -101,7 +101,8 @@ async function connectToHost(host, context, treeDataProvider) {
|
|
|
101
101
|
}
|
|
102
102
|
Promise.all(message.map(async (stream) => {
|
|
103
103
|
return await newClient.getWorkblock(stream.id);
|
|
104
|
-
}))
|
|
104
|
+
}))
|
|
105
|
+
.then((workblocks) => {
|
|
105
106
|
workblocks.map((wb, idx) => {
|
|
106
107
|
onWorkblockChange(message[idx].id, wb, treeDataProvider, host);
|
|
107
108
|
if (wb) {
|
|
@@ -109,6 +110,10 @@ async function connectToHost(host, context, treeDataProvider) {
|
|
|
109
110
|
}
|
|
110
111
|
});
|
|
111
112
|
console.log("got workblocks", workblocks);
|
|
113
|
+
})
|
|
114
|
+
.catch((e) => {
|
|
115
|
+
const msg = e?.message ?? String(e);
|
|
116
|
+
outputChannel.appendLine(`[connect] Failed to prefetch workblocks: ${msg}`);
|
|
112
117
|
});
|
|
113
118
|
});
|
|
114
119
|
newClient.addEventHandler(async (message) => {
|
|
@@ -363,19 +368,50 @@ function activate(context) {
|
|
|
363
368
|
}
|
|
364
369
|
});
|
|
365
370
|
const getWB = vscode.commands.registerCommand("beyondwork.beyondwork.get", async (item) => {
|
|
366
|
-
outputChannel.
|
|
371
|
+
outputChannel.show(true);
|
|
372
|
+
outputChannel.appendLine(`Getting workblock streamId=${item.stream.id} host=${item.connection.host}`);
|
|
367
373
|
if (!item.dir) {
|
|
368
374
|
vscode.window.showErrorMessage("Please bind a directory to the stream first");
|
|
369
375
|
return;
|
|
370
376
|
}
|
|
377
|
+
const dir = item.dir;
|
|
371
378
|
const client = clientsByHost[item.connection.host];
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
if (!wb) {
|
|
375
|
-
vscode.window.showErrorMessage("No workblock in workspace");
|
|
379
|
+
if (!client) {
|
|
380
|
+
vscode.window.showErrorMessage(`Not connected to ${item.connection.host}. Connect first, then retry.`);
|
|
376
381
|
return;
|
|
377
382
|
}
|
|
378
|
-
|
|
383
|
+
try {
|
|
384
|
+
await vscode.window.withProgress({
|
|
385
|
+
location: vscode.ProgressLocation.Notification,
|
|
386
|
+
title: `Beyond Work: Getting workblock (${item.stream.title})`,
|
|
387
|
+
cancellable: true,
|
|
388
|
+
}, async (_progress, token) => {
|
|
389
|
+
let cancellationSub;
|
|
390
|
+
const cancellation = new Promise((_, reject) => {
|
|
391
|
+
cancellationSub = token.onCancellationRequested(() => reject(new Error("Cancelled")));
|
|
392
|
+
});
|
|
393
|
+
try {
|
|
394
|
+
const wb = await Promise.race([
|
|
395
|
+
client.getWorkblock(item.stream.id),
|
|
396
|
+
cancellation,
|
|
397
|
+
]);
|
|
398
|
+
outputChannel.appendLine(`Got workblock streamId=${item.stream.id}: ${wb ? wb.id : "none"}`);
|
|
399
|
+
if (!wb) {
|
|
400
|
+
vscode.window.showErrorMessage("No workblock in workspace");
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
await (0, lib_1.storeWorkblockFiles)(dir, wb, client);
|
|
404
|
+
}
|
|
405
|
+
finally {
|
|
406
|
+
cancellationSub?.dispose();
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
catch (e) {
|
|
411
|
+
const msg = e?.message ?? String(e);
|
|
412
|
+
outputChannel.appendLine(`Failed to get workblock streamId=${item.stream.id}: ${msg}`);
|
|
413
|
+
vscode.window.showErrorMessage(`Failed to get workblock: ${msg}`);
|
|
414
|
+
}
|
|
379
415
|
});
|
|
380
416
|
const setWB = vscode.commands.registerCommand("beyondwork.beyondwork.set", async (item) => {
|
|
381
417
|
outputChannel.appendLine(`Setting workblock ${item.stream}`);
|
package/out/types.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActionType = exports.EventType = void 0;
|
|
4
|
+
var EventType;
|
|
5
|
+
(function (EventType) {
|
|
6
|
+
EventType["ValidateWorkblock"] = "validate_workblock";
|
|
7
|
+
EventType["StoreWorkblock"] = "store_work_block";
|
|
8
|
+
EventType["PublishWorkblock"] = "publish_workblock";
|
|
9
|
+
EventType["SetWorkblock"] = "set_work_block";
|
|
10
|
+
EventType["BatchGetEvents"] = "batch_get_events";
|
|
11
|
+
EventType["GetEvents"] = "get_events";
|
|
12
|
+
EventType["GetWorkblock"] = "get_workblock";
|
|
13
|
+
EventType["ListWorkblockDefinitions"] = "list_workblock_definitions";
|
|
14
|
+
EventType["Events"] = "events";
|
|
15
|
+
EventType["SendMessage"] = "send_message";
|
|
16
|
+
EventType["Typing"] = "typing";
|
|
17
|
+
EventType["WbRunTest"] = "wb_run_test";
|
|
18
|
+
EventType["CreateStream"] = "create_stream";
|
|
19
|
+
EventType["CloseStream"] = "close_stream";
|
|
20
|
+
EventType["GetEditStream"] = "get_edit_stream";
|
|
21
|
+
})(EventType || (exports.EventType = EventType = {}));
|
|
22
|
+
var ActionType;
|
|
23
|
+
(function (ActionType) {
|
|
24
|
+
ActionType["Code"] = "code";
|
|
25
|
+
ActionType["Python"] = "python";
|
|
26
|
+
})(ActionType || (exports.ActionType = ActionType = {}));
|
|
27
|
+
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publisher": "beyondwork",
|
|
4
4
|
"displayName": "Beyond Work",
|
|
5
5
|
"description": "Tool for interacting with Beyond Work workblocks from VS Code and CLI.",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.20",
|
|
7
7
|
"icon": "media/icon.png",
|
|
8
8
|
"engines": {
|
|
9
9
|
"vscode": "^1.94.0",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"out/lib/**/*",
|
|
20
20
|
"out/cli.js",
|
|
21
21
|
"out/extension.js",
|
|
22
|
+
"out/types.js",
|
|
22
23
|
"media/icon.png",
|
|
23
24
|
"CHANGELOG.md",
|
|
24
25
|
"README.md",
|
|
@@ -140,6 +141,7 @@
|
|
|
140
141
|
"watch:esbuild": "node esbuild.js --watch",
|
|
141
142
|
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
|
|
142
143
|
"package": "pnpm run check-types && node esbuild.js --production && pnpm run build-webview",
|
|
144
|
+
"vsix": "bazel build //src/vscode/beyondwork:package",
|
|
143
145
|
"build-webview": "esbuild ./src/webview/main.ts --bundle --outfile=extension/out/webview/main.js --format=iife --platform=browser",
|
|
144
146
|
"build-lib": "tsc -p tsconfig.json"
|
|
145
147
|
}
|