Skip to content

Commit

Permalink
Merge pull request #1532 from IIFelix/doctor-features
Browse files Browse the repository at this point in the history
Doctor panel features
  • Loading branch information
IIFelix committed Jul 3, 2022
2 parents 8be00c3 + 49587ad commit 1171a44
Show file tree
Hide file tree
Showing 3 changed files with 257 additions and 6 deletions.
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

0 comments on commit 1171a44

Please sign in to comment.