Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctor panel features #1532

Merged
merged 1 commit into from Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions extensions/vscode-vue-language-features/package.json
Expand Up @@ -800,6 +800,7 @@
"release": "npm run release:node && npm run release:browser"
},
"devDependencies": {
"@types/semver": "^7.3.9",
"@types/vscode": "1.67.0",
"@volar/preview": "0.38.2",
"@volar/shared": "0.38.2",
Expand All @@ -810,6 +811,7 @@
"esbuild-plugin-copy": "latest",
"path-browserify": "^1.0.1",
"punycode": "^2.1.1",
"semver": "^7.3.7",
"vsce": "latest",
"vscode-languageclient": "^8.0.1",
"vscode-nls": "^5.0.1"
Expand Down
40 changes: 38 additions & 2 deletions extensions/vscode-vue-language-features/src/features/doctor.ts
Expand Up @@ -3,6 +3,7 @@ import * as vscode from 'vscode';
import * as shared from '@volar/shared';
import { takeOverModeEnabled } from '../common';
import * as fs from '../utils/fs';
import * as semver from 'semver'

export async function register(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.commands.registerCommand('volar.action.doctor', async () => {
Expand All @@ -24,6 +25,40 @@ export async function register(context: vscode.ExtensionContext) {
path: tsConfigPath,
content: await fs.readFile(tsConfigPath),
})));

const vueVersion = getWorkspacePackageJson('vue')?.version;
const runtimeDomVersion = getWorkspacePackageJson('@vue/runtime-dom')?.version;

let parsedTsConfig: undefined | Record<string, any>
try {
parsedTsConfig = tsConfigs[0] ? JSON.parse(tsConfigs[0].content) : undefined
} catch (error) {
console.error(error)
parsedTsConfig = undefined
}
const vueTarget = parsedTsConfig?.vueCompilerOptions?.target

if (vueVersion) {
if (semver.lte(vueVersion, '2.6.14')) {
if (!runtimeDomVersion) {
vscode.window.showWarningMessage(
'Found Vue with version <2.7 but no "@vue/runtime-dom". Consider adding "@vue/runtime-dom" to your dev dependencies.'
);
}
if (vueTarget !== 2) {
vscode.window.showWarningMessage(
'Found Vue with version <2.7 but incorrect "target" option in your "tsconfig.json". Consider adding "target": 2.'
);
}
}

if (semver.gt(vueVersion, '2.6.14') && semver.lt(vueVersion, '3.0.0') && vueTarget !== 2.7) {
vscode.window.showWarningMessage(
'Found Vue with version <2.7 but incorrect "target" option in your "tsconfig.json". Consider adding "target": 2.7'
);
}
}

const tsPaths = getCurrentTsPaths(context);
const tsVersion = shared.getTypeScriptVersion(tsPaths.serverPath);
const content = `
Expand All @@ -37,8 +72,9 @@ export async function register(context: vscode.ExtensionContext) {
- vetur.actived: ${!!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}
- workspace.vue.version: ${vueVersion}
- workspace.@vue/runtime-dom.version: ${runtimeDomVersion}
- workspace.tsconfig.vueCompilerOptions.target: ${vueTarget}
- takeover-mode.enabled: ${takeOverModeEnabled()}

## tsconfigs
Expand Down