@beyondwork/wb-cli 0.1.22 → 0.1.23
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/out/extension.js +31 -9
- package/out/types.js +1 -1
- package/package.json +1 -1
package/out/extension.js
CHANGED
|
@@ -47,6 +47,7 @@ const path = __importStar(require("path"));
|
|
|
47
47
|
const yaml_1 = require("yaml");
|
|
48
48
|
const markdown_it_1 = __importDefault(require("markdown-it"));
|
|
49
49
|
const lib_1 = require("./lib");
|
|
50
|
+
const connection_feedback_1 = require("./connection_feedback");
|
|
50
51
|
const clientsByHost = {};
|
|
51
52
|
let diagnosticCollection;
|
|
52
53
|
let outputChannel;
|
|
@@ -150,21 +151,24 @@ function branchOwnerId(branch) {
|
|
|
150
151
|
}
|
|
151
152
|
return undefined;
|
|
152
153
|
}
|
|
153
|
-
async function resolveBranchStream(host, workblockId, branch) {
|
|
154
|
+
async function resolveBranchStream(host, workblockId, branch, title) {
|
|
155
|
+
const key = (0, tree_data_provider_1.branchKey)(host, workblockId, branch);
|
|
156
|
+
const existingStreamId = streamsByBranchKey[key];
|
|
157
|
+
if (existingStreamId) {
|
|
158
|
+
return { id: existingStreamId };
|
|
159
|
+
}
|
|
154
160
|
const client = clientsByHost[host];
|
|
155
161
|
if (!client) {
|
|
156
162
|
throw new Error(`Not connected to ${host}`);
|
|
157
163
|
}
|
|
158
|
-
const stream = await client.
|
|
159
|
-
await client.switchStreamBranch(stream.id, branch);
|
|
160
|
-
const key = (0, tree_data_provider_1.branchKey)(host, workblockId, branch);
|
|
164
|
+
const stream = await client.createStudioWorkspace(workblockId, branch, title);
|
|
161
165
|
hostsByStream[stream.id] = host;
|
|
162
166
|
branchKeysByStream[stream.id] = key;
|
|
163
167
|
streamsByBranchKey[key] = stream.id;
|
|
164
168
|
return stream;
|
|
165
169
|
}
|
|
166
170
|
async function resolveBranchItemStream(item) {
|
|
167
|
-
return resolveBranchStream(item.connection.host, item.workblock.id, item.branch.name);
|
|
171
|
+
return resolveBranchStream(item.connection.host, item.workblock.id, item.branch.name, `${item.workblock.name} (${item.branch.name})`);
|
|
168
172
|
}
|
|
169
173
|
async function connectToHost(host, context, treeDataProvider) {
|
|
170
174
|
if (clientsByHost[host]) {
|
|
@@ -173,7 +177,11 @@ async function connectToHost(host, context, treeDataProvider) {
|
|
|
173
177
|
}
|
|
174
178
|
const token = await (0, auth_1.getApiToken)(context, host);
|
|
175
179
|
if (!token) {
|
|
176
|
-
|
|
180
|
+
const msg = `Failed to retrieve token for ${host}.`;
|
|
181
|
+
treeDataProvider.updateConnectionStatus(host, "disconnected");
|
|
182
|
+
outputChannel.appendLine(`[connection] ${msg}`);
|
|
183
|
+
vscode.window.showErrorMessage(`Beyond Work: ${msg}`);
|
|
184
|
+
throw new Error(msg);
|
|
177
185
|
}
|
|
178
186
|
const newClient = new client_1.BeyondWorkClient();
|
|
179
187
|
newClient.addCurrentUserHandler((user) => {
|
|
@@ -254,8 +262,20 @@ async function connectToHost(host, context, treeDataProvider) {
|
|
|
254
262
|
outputChannel.appendLine(`[ws] ${msg}`);
|
|
255
263
|
vscode.window.showErrorMessage(`Beyond Work: ${msg}`);
|
|
256
264
|
});
|
|
257
|
-
newClient.
|
|
258
|
-
|
|
265
|
+
newClient.addConnectionErrorHandler((err) => {
|
|
266
|
+
(0, connection_feedback_1.showConnectionError)(host, treeDataProvider, outputChannel, err);
|
|
267
|
+
});
|
|
268
|
+
try {
|
|
269
|
+
newClient.connect(host, token, context);
|
|
270
|
+
clientsByHost[host] = newClient;
|
|
271
|
+
}
|
|
272
|
+
catch (e) {
|
|
273
|
+
treeDataProvider.updateConnectionStatus(host, "disconnected");
|
|
274
|
+
const msg = e?.message ?? String(e);
|
|
275
|
+
outputChannel.appendLine(`[connection] Failed to connect to ${host}: ${msg}`);
|
|
276
|
+
vscode.window.showErrorMessage(`Beyond Work: Failed to connect to ${host}: ${msg}`);
|
|
277
|
+
throw e;
|
|
278
|
+
}
|
|
259
279
|
context.globalState.update("bw_current_connection", host);
|
|
260
280
|
return newClient;
|
|
261
281
|
}
|
|
@@ -681,7 +701,9 @@ Base dir/
|
|
|
681
701
|
let prevHost = context.globalState.get("bw_current_connection", "");
|
|
682
702
|
if (prevHost) {
|
|
683
703
|
treeDataProvider.updateConnectionStatus(prevHost, "connecting");
|
|
684
|
-
connectToHost(prevHost, context, treeDataProvider).
|
|
704
|
+
connectToHost(prevHost, context, treeDataProvider).catch((e) => {
|
|
705
|
+
outputChannel.appendLine(`[connection] ${e?.message ?? e}`);
|
|
706
|
+
});
|
|
685
707
|
}
|
|
686
708
|
const watcher = vscode.workspace.createFileSystemWatcher("**/*");
|
|
687
709
|
watcher.onDidChange(async (uri) => {
|
package/out/types.js
CHANGED
|
@@ -20,7 +20,7 @@ var EventType;
|
|
|
20
20
|
EventType["CreateStream"] = "create_stream";
|
|
21
21
|
EventType["CloseStream"] = "close_stream";
|
|
22
22
|
EventType["GetEditStream"] = "get_edit_stream";
|
|
23
|
-
EventType["
|
|
23
|
+
EventType["CreateStudioWorkspace"] = "create_studio_workspace";
|
|
24
24
|
})(EventType || (exports.EventType = EventType = {}));
|
|
25
25
|
var ActionType;
|
|
26
26
|
(function (ActionType) {
|
package/package.json
CHANGED