Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@
"wait-on": "^5.0.1"
},
"dependencies": {
"electron-rebuild": "^1.11.0",
"sqlite3": "^5.0.2"
},
"resolutions": {
"tar": ">4.4.18"
}
}
4 changes: 2 additions & 2 deletions packages/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ export function activate(context: ExtensionContext) {
});

// Using the location of the javacript file built by `npm run prepublish`
const serverModule = context.asAbsolutePath(path.join('packages', 'server', 'dist', 'cli.js'))
const execArgs = ['up', '--method', 'node-ipc']
const serverModule = context.asAbsolutePath(path.join('packages', 'server', 'dist', 'vscodeExtensionServer.js'))
const execArgs = ['false'] // [1: debug]
const debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };
let connectionNames = []
let connectedConnectionName = ''
Expand Down
1 change: 0 additions & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"onNotebook:jupyter-notebook"
],
"dependencies": {
"electron-rebuild": "^1.11.0",
"vscode": "^1.1.37",
"vscode-languageclient": "^7.0.0",
"vscode-test": "^1.3.0"
Expand Down
25 changes: 13 additions & 12 deletions packages/server/bin/cli.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
import yargs from 'yargs'
import { createServer } from '../src/createServer'
import { hideBin } from 'yargs/helpers'
import { ConnectionMethod, createServer } from '../src/createServer'

const cli = yargs
const cli = yargs(hideBin(process.argv))
.usage('SQL Language Server Command Line Interface')
.command('up', 'run sql-language-server', {
method: {
.command('up', 'run sql-language-server', (v) => {
return v.option('method', {
alias: 'm',
type: 'string',
default: 'node-ipc',
choices: ['stdio', 'node-ipc'],
describe: 'What use to communicate with sql language server'
},
'debug': {
}).option('debug', {
alias: 'd',
type: 'boolean',
default: false,
describe: 'Enable debug logging'
}
}, () => {
createServer()
})
}, (v) => {
createServer({ method: v.method as ConnectionMethod, debug: v.debug })
process.stdin.resume()
})
.example('$0 up --method stdio', ': start up sql-language-server - communicate via stdio')
.help()
.argv

if (cli._.length === 0) {
yargs.showHelp()
cli.parse()

if ((cli.argv as any)._.length === 0) {
cli.showHelp()
}

process.stdin.on('close', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/server/bin/vscodeExtensionServer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { createServer } from '../src/createServer'
createServer({ method: 'node-ipc', debug: process.argv[2] === 'true' })
4 changes: 3 additions & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
"license": "MIT",
"scripts": {
"compile:cli": "esbuild bin/cli.ts --bundle --platform=node --external:pg-native --outfile=dist/cli.js",
"compile:vscode": "esbuild bin/vscodeExtensionServer.ts --bundle --platform=node --external:pg-native --outfile=dist/vscodeExtensionServer.js",
"compile:index": "tsc -p .",
"clean": "rm -rf dist",
"watch:cli": "yarn compile:cli --watch",
"watch:index": "tsc -w",
"test": "jest",
"prepare-vsc-extension": "yarn clean && yarn compile:cli",
"prepare-vsc-extension": "yarn clean && yarn compile:vscode",
"prepublish": "yarn clean && yarn compile:index"
},
"files": [
Expand All @@ -39,6 +40,7 @@
"@google-cloud/bigquery": "^5.9.0",
"@joe-re/sql-parser": "^1.2.0",
"@types/pg": "^7.4.10",
"@types/yargs": "^17.0.8",
"cardinal": "^2.1.1",
"jest": "^26.0.1",
"log4js": "^6.2.1",
Expand Down
1 change: 0 additions & 1 deletion packages/server/src/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
declare module 'yargs'
14 changes: 5 additions & 9 deletions packages/server/src/createServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import cache from './cache'
import { complete } from './complete'
import createDiagnostics from './createDiagnostics'
import createConnection from './createConnection'
import yargs from 'yargs'
import SettingStore from './SettingStore'
import { Schema } from './database_libs/AbstractClient'
import getDatabaseClient from './database_libs/getDatabaseClient'
Expand All @@ -26,14 +25,11 @@ import path from 'path'
import process from 'process'

export type ConnectionMethod = 'node-ipc' | 'stdio'
type Args = {
method?: ConnectionMethod
}

const TRIGGER_CHARATER = '.'

export function createServerWithConnection(connection: Connection) {
initializeLogging()
export function createServerWithConnection(connection: Connection, debug = false) {
initializeLogging(debug)
const logger = log4js.getLogger()
const documents = new TextDocuments(TextDocument)
documents.listen(connection);
Expand Down Expand Up @@ -325,7 +321,7 @@ export function createServerWithConnection(connection: Connection) {
return connection
}

export function createServer() {
const connection: Connection = createConnection((yargs.argv as Args).method || 'node-ipc')
return createServerWithConnection(connection)
export function createServer(params: { method?: ConnectionMethod, debug?: boolean } = {}) {
const connection: Connection = createConnection(params.method ?? 'node-ipc')
return createServerWithConnection(connection, params.debug)
}
6 changes: 3 additions & 3 deletions packages/server/src/initializeLogging.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import log4js from 'log4js';
import * as path from 'path'
import * as os from 'os'
import yargs from 'yargs'

const MAX_LOG_SIZE = 1024 * 1024
const MAX_LOG_BACKUPS = 10
const LOG_FILE_PATH = path.join(os.tmpdir(), 'sql-language-server.log')

export default function initializeLogging() {
export default function initializeLogging(debug = false) {
log4js.configure({
appenders: {
server: {
Expand All @@ -17,7 +16,8 @@ export default function initializeLogging() {
ackups: MAX_LOG_BACKUPS
}
},
categories: { default: { appenders: ['server'], level: yargs.argv.debug ? 'debug' : 'debug' } }
// TODO: Should accept level
categories: { default: { appenders: ['server'], level: debug ? 'debug' : 'debug' } }
})

const logger = log4js.getLogger()
Expand Down
Loading