Skip to content

Commit

Permalink
simplify build (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
ostreifel authored and nathan-boyd committed Jan 22, 2018
1 parent 28715d3 commit 8be0751
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 56 deletions.
4 changes: 1 addition & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./"
}
}
94 changes: 47 additions & 47 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
2 changes: 1 addition & 1 deletion client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"module": "commonjs",
"moduleResolution": "node",
"rootDir": ".",
"outDir": "../out/client",
"outDir": "./out",
"lib": [ "es2016" ],
"sourceMap": true
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./"
}
}
2 changes: 1 addition & 1 deletion server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"module": "commonjs",
"moduleResolution": "node",
"rootDir": ".",
"outDir": "../out/server",
"outDir": "./out",
"lib": [ "es2016" ],
"sourceMap": true
}
Expand Down

0 comments on commit 8be0751

Please sign in to comment.