Skip to content

Commit

Permalink
feat: basic doctor infos
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed May 11, 2022
1 parent 4b7ebe5 commit e97f6e3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
9 changes: 9 additions & 0 deletions extensions/vscode-vue-language-features/package.json
Expand Up @@ -421,6 +421,11 @@
"title": "Restart Vue server",
"category": "Volar"
},
{
"command": "volar.action.doctor",
"title": "Show doctor panel (WIP)",
"category": "Volar"
},
{
"command": "volar.action.verifyAllScripts",
"title": "Verify All Scripts",
Expand Down Expand Up @@ -509,6 +514,10 @@
"command": "volar.action.restartServer",
"when": "volar.activated"
},
{
"command": "volar.action.doctor",
"when": "volar.activated"
},
{
"command": "volar.action.verifyAllScripts",
"when": "volar.activated"
Expand Down
2 changes: 2 additions & 0 deletions extensions/vscode-vue-language-features/src/common.ts
Expand Up @@ -16,6 +16,7 @@ import * as tsVersion from './features/tsVersion';
import * as verifyAll from './features/verifyAll';
import * as virtualFiles from './features/virtualFiles';
import * as tsconfig from './features/tsconfig';
import * as doctor from './features/doctor';

let apiClient: lsp.CommonLanguageClient;
let docClient: lsp.CommonLanguageClient | undefined;
Expand Down Expand Up @@ -132,6 +133,7 @@ async function doActivate(context: vscode.ExtensionContext, createLc: CreateLang
autoInsertion.activate(context, htmlClient, apiClient);
tsVersion.activate(context, [apiClient, docClient].filter(shared.notEmpty));
tsconfig.activate(context, docClient ?? apiClient);
doctor.activate(context);

async function registerUseSecondServerChange() {
vscode.workspace.onDidChangeConfiguration(async () => {
Expand Down
50 changes: 50 additions & 0 deletions extensions/vscode-vue-language-features/src/features/doctor.ts
@@ -0,0 +1,50 @@
import { getCurrentTsPaths } from './tsVersion';
import * as vscode from 'vscode';
import * as shared from '@volar/shared';
import { takeOverModeEnabled } from '../common';

export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.commands.registerCommand('volar.action.doctor', async () => {

// TODO: tsconfig infos
// TODO: warnings

const tsPaths = getCurrentTsPaths(context);
const tsVersion = shared.getTypeScriptVersion(tsPaths.serverPath);
const content = `
## Infos
vscode.version: ${vscode.version}
vscode.typescript.version: ${tsVersion}
vscode.typescript-extension.actived: ${!!vscode.extensions.getExtension('vscode.typescript-language-features')}
vue-language-features.version: ${context.extension.packageJSON.version}
typescript-vue-plugin.version: ${vscode.extensions.getExtension('Vue.vscode-typescript-vue-plugin')?.packageJSON.version}
vetur.actived: ${!!vscode.extensions.getExtension('octref.vetur')}
workspace.vue-tsc.version: ${getWorkspacePackageJson('vue-tsc')?.version}
workspace.typescript.version: ${getWorkspacePackageJson('typescript')?.version}
workspace.vue.version: ${getWorkspacePackageJson('vue')?.version}
workspace.@vue/runtime-dom.version: ${getWorkspacePackageJson('@vue/runtime-dom')?.version}
takeover-mode.enabled: ${takeOverModeEnabled()}
### Configuration
\`\`\`json
${JSON.stringify({
volar: vscode.workspace.getConfiguration('').get('volar'),
typescript: vscode.workspace.getConfiguration('').get('typescript'),
javascript: vscode.workspace.getConfiguration('').get('javascript'),
}, null, 2)}
\`\`\`
`;

const document = await vscode.workspace.openTextDocument({ content: content.trim(), language: 'markdown' });

await vscode.window.showTextDocument(document);
}));
}

function getWorkspacePackageJson(pkg: string): { version: string; } | undefined {
try {
return require(require.resolve(pkg + '/package.json', { paths: [vscode.workspace.rootPath!] }));
} catch { }
}

1 comment on commit e97f6e3

@yaegassy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For projects using pnpm as package manager, it seems that the version of @vue/runtime-dom is not being obtained.

However, this is probably a check item for vue2, and I have a feeling that users who use vue2 will not willingly use pnpm, so I don't think there is a problem at present.

vscode-volar-action-doctor

Please sign in to comment.