diff --git a/client/package.json b/client/package.json index bd13ba3..8e22eb5 100644 --- a/client/package.json +++ b/client/package.json @@ -28,8 +28,6 @@ }, "scripts": { "build": "tsc -p ./", - "watch": "tsc -watch -p ./", - "postinstall": "node ./node_modules/vscode/bin/install && npm run copy-node-modules", - "copy-node-modules": "mkdir -p ../out/client/node_modules/ && cp -R node_modules ../out/client" + "watch": "tsc -watch -p ./" } } diff --git a/client/src/extension.ts b/client/src/extension.ts index 21f46b7..40c2213 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -7,51 +7,51 @@ import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } f export function activate(context: ExtensionContext) { - const debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] }; - - const serverModule = context.asAbsolutePath(path.join("out/server/src", "server.js")); - - const serverOptions: ServerOptions = { - run : { module: serverModule, transport: TransportKind.ipc }, - debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }, - }; - - const clientOptions: LanguageClientOptions = { - documentSelector: [{scheme: "file", language: "sql"}], - synchronize: { - configurationSection: "tsqllint", - fileEvents: workspace.createFileSystemWatcher("**/.clientrc"), - }, - }; - - const client = new LanguageClient("tsqllint", "TSQLLint", serverOptions, clientOptions); - client.registerProposedFeatures(); - - function applyTextEdits(uri: string, documentVersion: number, edits: vscode.TextEdit[]) { - const textEditor = vscode.window.activeTextEditor; - if (textEditor && textEditor.document.uri.toString() === uri) { - if (textEditor.document.version !== documentVersion) { - vscode.window.showInformationMessage( - `SqlLint fixes are outdated and can't be applied to the document.`, - ); - } - textEditor.edit((mutator) => { - for (const edit of edits) { - mutator.replace(client.protocol2CodeConverter.asRange(edit.range), edit.newText); - } - }).then((success) => { - if (!success) { - vscode.window.showErrorMessage( - "Failed to apply SqlLint fixes to the document. " + - "Please consider opening an issue with steps to reproduce.", - ); - } - }); - } - } - - context.subscriptions.push( - client.start(), - vscode.commands.registerCommand("_tsql-lint.change", applyTextEdits), - ); + let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] }; + + let serverModule = context.asAbsolutePath(path.join('./server/out/src', 'server.js')); + + let serverOptions: ServerOptions = { + run : { module: serverModule, transport: TransportKind.ipc }, + debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions } + } + + let clientOptions: LanguageClientOptions = { + documentSelector: [{scheme: 'file', language: 'sql'}], + synchronize: { + configurationSection: 'tsqllint', + fileEvents: workspace.createFileSystemWatcher('**/.clientrc') + } + } + + let client = new LanguageClient('tsqllint', 'TSQLLint', serverOptions, clientOptions); + client.registerProposedFeatures(); + + +function applyTextEdits(uri: string, documentVersion: number, edits: vscode.TextEdit[]) { + const textEditor = vscode.window.activeTextEditor; + if (textEditor && textEditor.document.uri.toString() === uri) { + if (textEditor.document.version !== documentVersion) { + vscode.window.showInformationMessage( + `SqlLint fixes are outdated and can't be applied to the document.`, + ); + } + textEditor.edit((mutator) => { + for (const edit of edits) { + mutator.replace(client.protocol2CodeConverter.asRange(edit.range), edit.newText); + } + }).then((success) => { + if (!success) { + vscode.window.showErrorMessage( + "Failed to apply SqlLint fixes to the document. " + + "Please consider opening an issue with steps to reproduce.", + ); + } + }); + } +} + context.subscriptions.push( + client.start(), + vscode.commands.registerCommand("_tsql-lint.change", applyTextEdits) + ); } diff --git a/client/tsconfig.json b/client/tsconfig.json index e093aad..516686d 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -7,7 +7,7 @@ "module": "commonjs", "moduleResolution": "node", "rootDir": ".", - "outDir": "../out/client", + "outDir": "./out", "lib": [ "es2016" ], "sourceMap": true } diff --git a/package.json b/package.json index dd6cafd..70ab14e 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "license": "MIT", "version": "0.0.3", "publisher": "tsqllint", - "main": "/out/client/src/extension", + "main": "./client/out/src/extension", "icon": "images/icon.png", "activationEvents": [ "onLanguage:sql" diff --git a/server/package.json b/server/package.json index 2690acf..fedbf9b 100644 --- a/server/package.json +++ b/server/package.json @@ -21,8 +21,6 @@ }, "scripts": { "build": "tsc -p ./", - "watch": "tsc -watch -p ./", - "postinstall": "npm run copy-node-modules", - "copy-node-modules": "mkdir -p ../out/server/node_modules/ && cp -R node_modules ../out/server" + "watch": "tsc -watch -p ./" } } diff --git a/server/tsconfig.json b/server/tsconfig.json index e4b045b..b29120d 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -7,7 +7,7 @@ "module": "commonjs", "moduleResolution": "node", "rootDir": ".", - "outDir": "../out/server", + "outDir": "./out", "lib": [ "es2016" ], "sourceMap": true }