Skip to content

Commit

Permalink
feat: add telemetry to typescript-plugin-vue and typecheck (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
znck committed Jan 16, 2021
1 parent c975971 commit 701261b
Show file tree
Hide file tree
Showing 37 changed files with 1,290 additions and 1,009 deletions.
42 changes: 26 additions & 16 deletions extensions/vscode-vue-language-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
"icon": "logo.png",
"main": "dist/index.js",
"activationEvents": [
"onLanguage:vue"
"onLanguage:vue",
"onLanguage:typescript",
"onLanguage:typescriptreact",
"onLanguage:javascript",
"onLanguage:javascriptreact",
"onCommand:vuedx.openVirtualFile"
],
"files": [
"dist"
Expand Down Expand Up @@ -52,54 +57,59 @@
],
"commands": [
{
"command": "vue.openVirtualFile",
"command": "vuedx.openVirtualFile",
"title": "Vue: Show virtual file"
}
],
"configuration": {
"title": "VueDX",
"properties": {
"vue.suggest.enabled": {
"vuedx.suggest.enabled": {
"type": "boolean",
"default": true,
"description": "Enabled/disable autocomplete suggestions.",
"scope": "resource"
},
"vue.format.enable": {
"vuedx.format.enable": {
"type": "boolean",
"default": true,
"description": "Enable/disable default TypeScript/JavaScript formatter.",
"scope": "window"
},
"vue.implementationsCodeLens.enabled": {
"vuedx.implementationsCodeLens.enabled": {
"type": "boolean",
"default": true,
"description": "Enable/disable implementations CodeLens. This CodeLens shows the implementers of an interface.",
"scope": "window"
},
"vue.suggest.completeJSDocs": {
"vuedx.suggest.completeJSDocs": {
"type": "boolean",
"default": true,
"description": "Enable/disable suggestion to complete JSDoc comments.",
"scope": "resource"
},
"vue.referencesCodeLens.enabled": {
"vuedx.referencesCodeLens.enabled": {
"type": "boolean",
"default": true,
"description": "Enable/disable references CodeLens in TypeScript/JavaScript files.",
"scope": "window"
},
"vue.autoClosingTags": {
"vuedx.autoClosingTags": {
"type": "boolean",
"default": true,
"description": "Enable/disable automatic closing of JSX tags. Requires using TypeScript 3.0 or newer in the workspace."
},
"vuedx.telemetry": {
"type": "boolean",
"default": true,
"description": "Enable/disable telemetry."
}
}
},
"menus": {
"commandPalette": [
{
"command": "vue.openVirtualFile",
"command": "vuedx.openVirtualFile",
"when": "editorLangId == vue"
},
{
Expand Down Expand Up @@ -127,14 +137,14 @@
"jsonValidation": [
{
"fileMatch": "vueconfig.json",
"url": "https://unpkg.com/@vuedx/projectconfig@0.4.0/schema.json"
"url": "https://unpkg.com/@vuedx/projectconfig@0.5.0/schema.json"
}
],
"typescriptServerPlugins": [
{
"name": "@vuedx/typescript-standalone",
"enableForWorkspaceTypeScriptVersions": true,
"configNamespace": "vue",
"configNamespace": "vuedx",
"languages": [
"vue"
]
Expand All @@ -149,19 +159,19 @@
},
"homepage": "https://github.com/znck/vue-developer-experience/blob/master/extensions/vscode#readme",
"dependencies": {
"@vuedx/analyze": "workspace:*",
"@vuedx/typescript-standalone": "workspace:*",
"fast-glob": "^3.2.4",
"json5": "^2.1.3"
"@vuedx/typescript-standalone": "workspace:*"
},
"devDependencies": {
"@types/vscode": "^1.50.0",
"@vercel/ncc": "^0.24.1",
"@vuedx/vue-virtual-textdocument": "workspace:*",
"@vuedx/analyze": "workspace:*",
"@vuedx/typescript-plugin-vue": "workspace:*",
"@vuedx/vue-virtual-textdocument": "workspace:*",
"inversify": "^5.0.1",
"reflect-metadata": "^0.1.13",
"typescript": "^4.0.3",
"fast-glob": "^3.2.4",
"json5": "^2.1.3",
"vsce": "1.81.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class OpenVirtualFileCommand extends Installable {
super.install()

return vscode.commands.registerTextEditorCommand(
'vue.openVirtualFile',
'vuedx.openVirtualFile',
this.onExecute.bind(this) as any,
)
}
Expand Down
37 changes: 35 additions & 2 deletions extensions/vscode-vue-language-features/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,45 @@ export async function activate(
container.get(VirtualFileSwitcher).install(),
new vscode.Disposable(() => container.unbindAll()),
)

const ts = vscode.extensions.getExtension(
'vscode.typescript-language-features',
)

if (ts != null) {
if (!ts.isActive) await ts.activate()
if (!ts.isActive) {
await ts.activate()
}

const api = ts.exports.getAPI(0)
if (api != null) {
context.subscriptions.push(
vscode.workspace.onDidChangeConfiguration((event) => {
if (event.affectsConfiguration('vuedx')) {
syncConfig(api, getConfig())
}
}),
)
}
}
}

function syncConfig(api: any, config: any): void {
api.configurePlugin('@vuedx/typescript-standalone', config)
}

function getConfig(): any {
const config = vscode.workspace.getConfiguration('vuedx')

return {
telemetry: config.get('telemetry') ?? true,
features: {
diagnostics: config.get('features.diagnostics') ?? true,
organizeImports: config.get('features.organizeImports') ?? true,
quickInfo: config.get('features.quickInfo') ?? true,
rename: config.get('features.rename') ?? true,
refactor: config.get('features.refactor') ?? true,
goto: config.get('features.goto') ?? true,
tagCompletions: config.get('features.tagCompletions') ?? ['html', 'svg'],
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Installable } from '../utils/installable'
import { DocumentService } from './documents'

/**
* Triggers completions when ":" is typed.
* Triggers completions when ":" or "/" is typed.
*/
@injectable()
export class TemplateLanguageProxy
Expand Down Expand Up @@ -86,8 +86,6 @@ export class TemplateLanguageProxy
): document is RenderFunctionTextDocument {
const result = document != null && this.languages.has(document.languageId)

console.log(`Is ${document?.languageId ?? 'null'} supported?`, result)

return result
}

Expand Down
4 changes: 4 additions & 0 deletions extensions/vscode-vue-language-features/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src"]
}
3 changes: 1 addition & 2 deletions extensions/vscode-vue-language-features/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src"]
"extends": "./tsconfig.build.json"
}
2 changes: 1 addition & 1 deletion packages/analyze/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
"commander": "^6.1.0",
"fast-glob": "^3.2.4",
"hash-sum": "^2.0.0",
"@vuedx/shared": "workspace:*",
"micromatch": "^4.0.2"
},
"devDependencies": {
"@types/babel__traverse": "^7.0.15",
"@types/node": "^14.14.14",
"@vuedx/shared": "workspace:*",
"typescript": "^4.0.3"
}
}
4 changes: 1 addition & 3 deletions packages/analyze/src/project/detector/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ export function getPackageJSON(
try {
return requireFileFromPackage(require, packageName, 'package.json', rootDir)
} catch (error) {
console.error(error)

return { name: packageName, version: 'latest' }
return { name: packageName, version: '3.0.0' }
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-tsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"@babel/parser": "7.12.3",
"@babel/types": "7.12.1",
"@vue/compiler-core": "^3.0.1",
"@vuedx/shared": "workspace:*",
"@vuedx/template-ast-types": "workspace:*"
},
"devDependencies": {
"@vuedx/shared": "workspace:*",
"typescript": "^4.0.3"
}
}
13 changes: 11 additions & 2 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"private": true,
"name": "@vuedx/shared",
"version": "0.5.0",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts"
"types": "dist/index.d.ts",
"dependencies": {
"@amplitude/node": "^1.2.0",
"clean-stack": "^3.0.1",
"node-machine-id": "^1.1.12",
"uuid": "^8.3.2"
},
"devDependencies": {
"@types/uuid": "^8.3.0"
}
}
1 change: 1 addition & 0 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './component'
export * from './number'
export * from './path'
export * from './string'
export * from './telemetry'

0 comments on commit 701261b

Please sign in to comment.