@beyondwork/wb-cli 0.1.19 → 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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.1.20
4
+
5
+ - Fix "Get workblock from workspace" hanging by adding request timeouts and better progress/log/error reporting.
6
+ - Fix up documentation.
7
+
3
8
  ## v0.1.18
4
9
 
5
10
  - Added split command to the cli
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 work block from an existing workspace to local filesystem
17
- - Set a work block on a workspace from local files
18
- - Live sync work blocks between open workspaces and local filesystem
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
- Work blocks are expected to be placed in a directory that contains nothing but work blocks. When starting from scratch simply create a new directory somewhere.
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
- ### Getting a work block
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
- Click a workspace in the menu and choose \`Get workblock from workspace\`. This takes the work block that's in the workspace provided and downloads it to the directory associated with the workspace.
36
+ ### Setting a workblock
36
37
 
37
- ### Setting a work block
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
- Click a workspace in the menu and choose \`Store workblock to workspace\`. This takes the work block files in the associated directory and combines them into a work block definition and sets it in the workspace provided.
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
- Note that this does not actually store the work block outside the workspace. In order to do that open the work block editor in the workspace and click store.
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 work block directory structure is like this:
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 'beyondwork/lib/utils';
103
+ import { assembleWorkblock, storeWorkblockFiles } from "beyondwork/lib/utils";
105
104
 
106
105
  // Assemble a workblock from files
107
- const workblock = await assembleWorkblock('/path/to/workblock');
106
+ const workblock = await assembleWorkblock("/path/to/workblock");
108
107
 
109
108
  // Store a workblock as files
110
- await storeWorkblockFiles('/output/path', workblockObject);
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
- })).then((workblocks) => {
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.appendLine(`Getting workblock ${item.stream}`);
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
- const wb = await client.getWorkblock(item.stream.id);
373
- outputChannel.appendLine(`Got workblock ${wb}`);
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
- await (0, lib_1.storeWorkblockFiles)(item.dir, wb, client);
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/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.19",
6
+ "version": "0.1.20",
7
7
  "icon": "media/icon.png",
8
8
  "engines": {
9
9
  "vscode": "^1.94.0",
@@ -141,6 +141,7 @@
141
141
  "watch:esbuild": "node esbuild.js --watch",
142
142
  "watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
143
143
  "package": "pnpm run check-types && node esbuild.js --production && pnpm run build-webview",
144
+ "vsix": "bazel build //src/vscode/beyondwork:package",
144
145
  "build-webview": "esbuild ./src/webview/main.ts --bundle --outfile=extension/out/webview/main.js --format=iife --platform=browser",
145
146
  "build-lib": "tsc -p tsconfig.json"
146
147
  }