|
1 | 1 | import * as vscode from 'vscode'; |
2 | 2 |
|
3 | 3 | import { ServePanelProvider } from './serve-panel-provider'; |
4 | | -import { getTailscaleCommandPath } from './tailscale'; |
5 | | -import { downloadLinkForPlatform, ADMIN_CONSOLE } from './utils/url'; |
| 4 | +import { ADMIN_CONSOLE } from './utils/url'; |
6 | 5 | import { Tailscale } from './tailscale'; |
7 | | -import { fileExists } from './utils'; |
8 | | -import { EXTENSION_ID } from './constants'; |
9 | 6 | import { Logger } from './logger'; |
10 | 7 | import { errorForType } from './tailscale/error'; |
11 | 8 |
|
12 | 9 | let tailscaleInstance: Tailscale; |
13 | 10 |
|
14 | 11 | export async function activate(context: vscode.ExtensionContext) { |
15 | | - const commandPath = await getTailscaleCommandPath(); |
16 | | - |
17 | | - Logger.info(`CLI path: ${commandPath}`); |
18 | 12 | vscode.commands.executeCommand('setContext', 'tailscale.env', process.env.NODE_ENV); |
19 | 13 |
|
20 | | - if (commandPath && !(await fileExists(commandPath))) { |
21 | | - vscode.window |
22 | | - .showErrorMessage( |
23 | | - `Tailscale CLI not found at ${commandPath}. Set tailscale.path`, |
24 | | - 'Open Settings' |
25 | | - ) |
26 | | - .then(() => { |
27 | | - vscode.commands.executeCommand('workbench.action.openSettings', `@ext:${EXTENSION_ID}`); |
28 | | - }); |
29 | | - } |
30 | | - |
31 | | - if (!commandPath) { |
32 | | - vscode.window |
33 | | - .showErrorMessage( |
34 | | - 'Tailscale CLI not found. Install Tailscale or set tailscale.path', |
35 | | - 'Install Tailscale', |
36 | | - 'Open Settings' |
37 | | - ) |
38 | | - .then((selection) => { |
39 | | - if (selection === 'Install Tailscale') { |
40 | | - vscode.env.openExternal(vscode.Uri.parse(downloadLinkForPlatform(process.platform))); |
41 | | - } else if (selection === 'Open Settings') { |
42 | | - vscode.commands.executeCommand('workbench.action.openSettings', `@ext:${EXTENSION_ID}`); |
43 | | - } |
44 | | - }); |
45 | | - } |
46 | | - |
47 | 14 | tailscaleInstance = await Tailscale.withInit(vscode); |
48 | 15 |
|
49 | 16 | // walkthrough completion |
50 | 17 | tailscaleInstance.serveStatus().then((status) => { |
51 | 18 | // assume if we have any BackendState we are installed |
52 | | - vscode.commands.executeCommand('setContext', 'tailscale.walkthroughs.installed', !!commandPath); |
| 19 | + const isInstalled = status.BackendState !== ''; |
| 20 | + vscode.commands.executeCommand('setContext', 'tailscale.walkthroughs.installed', isInstalled); |
53 | 21 |
|
54 | 22 | // Funnel check |
55 | 23 | const isFunnelOn = !status?.Errors?.some((e) => e.Type === 'FUNNEL_OFF'); |
|
0 commit comments