Skip to content

Commit 0113232

Browse files
authored
Upgrade dependencies (joe-re#114)
* upgrade tar * fix error by upgrading yargs
1 parent 7587a1f commit 0113232

File tree

10 files changed

+43
-319
lines changed

10 files changed

+43
-319
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@
103103
"wait-on": "^5.0.1"
104104
},
105105
"dependencies": {
106-
"electron-rebuild": "^1.11.0",
107106
"sqlite3": "^5.0.2"
107+
},
108+
"resolutions": {
109+
"tar": ">4.4.18"
108110
}
109111
}

packages/client/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ export function activate(context: ExtensionContext) {
115115
});
116116

117117
// Using the location of the javacript file built by `npm run prepublish`
118-
const serverModule = context.asAbsolutePath(path.join('packages', 'server', 'dist', 'cli.js'))
119-
const execArgs = ['up', '--method', 'node-ipc']
118+
const serverModule = context.asAbsolutePath(path.join('packages', 'server', 'dist', 'vscodeExtensionServer.js'))
119+
const execArgs = ['false'] // [1: debug]
120120
const debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };
121121
let connectionNames = []
122122
let connectedConnectionName = ''

packages/client/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"onNotebook:jupyter-notebook"
2020
],
2121
"dependencies": {
22-
"electron-rebuild": "^1.11.0",
2322
"vscode": "^1.1.37",
2423
"vscode-languageclient": "^7.0.0",
2524
"vscode-test": "^1.3.0"

packages/server/bin/cli.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
import yargs from 'yargs'
2-
import { createServer } from '../src/createServer'
2+
import { hideBin } from 'yargs/helpers'
3+
import { ConnectionMethod, createServer } from '../src/createServer'
34

4-
const cli = yargs
5+
const cli = yargs(hideBin(process.argv))
56
.usage('SQL Language Server Command Line Interface')
6-
.command('up', 'run sql-language-server', {
7-
method: {
7+
.command('up', 'run sql-language-server', (v) => {
8+
return v.option('method', {
89
alias: 'm',
910
type: 'string',
1011
default: 'node-ipc',
1112
choices: ['stdio', 'node-ipc'],
1213
describe: 'What use to communicate with sql language server'
13-
},
14-
'debug': {
14+
}).option('debug', {
1515
alias: 'd',
1616
type: 'boolean',
1717
default: false,
1818
describe: 'Enable debug logging'
19-
}
20-
}, () => {
21-
createServer()
19+
})
20+
}, (v) => {
21+
createServer({ method: v.method as ConnectionMethod, debug: v.debug })
2222
process.stdin.resume()
2323
})
2424
.example('$0 up --method stdio', ': start up sql-language-server - communicate via stdio')
2525
.help()
26-
.argv
2726

28-
if (cli._.length === 0) {
29-
yargs.showHelp()
27+
cli.parse()
28+
29+
if ((cli.argv as any)._.length === 0) {
30+
cli.showHelp()
3031
}
3132

3233
process.stdin.on('close', () => {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { createServer } from '../src/createServer'
2+
createServer({ method: 'node-ipc', debug: process.argv[2] === 'true' })

packages/server/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
"license": "MIT",
2323
"scripts": {
2424
"compile:cli": "esbuild bin/cli.ts --bundle --platform=node --external:pg-native --outfile=dist/cli.js",
25+
"compile:vscode": "esbuild bin/vscodeExtensionServer.ts --bundle --platform=node --external:pg-native --outfile=dist/vscodeExtensionServer.js",
2526
"compile:index": "tsc -p .",
2627
"clean": "rm -rf dist",
2728
"watch:cli": "yarn compile:cli --watch",
2829
"watch:index": "tsc -w",
2930
"test": "jest",
30-
"prepare-vsc-extension": "yarn clean && yarn compile:cli",
31+
"prepare-vsc-extension": "yarn clean && yarn compile:vscode",
3132
"prepublish": "yarn clean && yarn compile:index"
3233
},
3334
"files": [
@@ -39,6 +40,7 @@
3940
"@google-cloud/bigquery": "^5.9.0",
4041
"@joe-re/sql-parser": "^1.2.0",
4142
"@types/pg": "^7.4.10",
43+
"@types/yargs": "^17.0.8",
4244
"cardinal": "^2.1.1",
4345
"jest": "^26.0.1",
4446
"log4js": "^6.2.1",

packages/server/src/ambient.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
declare module 'yargs'

packages/server/src/createServer.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import cache from './cache'
1212
import { complete } from './complete'
1313
import createDiagnostics from './createDiagnostics'
1414
import createConnection from './createConnection'
15-
import yargs from 'yargs'
1615
import SettingStore from './SettingStore'
1716
import { Schema } from './database_libs/AbstractClient'
1817
import getDatabaseClient from './database_libs/getDatabaseClient'
@@ -26,14 +25,11 @@ import path from 'path'
2625
import process from 'process'
2726

2827
export type ConnectionMethod = 'node-ipc' | 'stdio'
29-
type Args = {
30-
method?: ConnectionMethod
31-
}
3228

3329
const TRIGGER_CHARATER = '.'
3430

35-
export function createServerWithConnection(connection: Connection) {
36-
initializeLogging()
31+
export function createServerWithConnection(connection: Connection, debug = false) {
32+
initializeLogging(debug)
3733
const logger = log4js.getLogger()
3834
const documents = new TextDocuments(TextDocument)
3935
documents.listen(connection);
@@ -325,7 +321,7 @@ export function createServerWithConnection(connection: Connection) {
325321
return connection
326322
}
327323

328-
export function createServer() {
329-
const connection: Connection = createConnection((yargs.argv as Args).method || 'node-ipc')
330-
return createServerWithConnection(connection)
324+
export function createServer(params: { method?: ConnectionMethod, debug?: boolean } = {}) {
325+
const connection: Connection = createConnection(params.method ?? 'node-ipc')
326+
return createServerWithConnection(connection, params.debug)
331327
}

packages/server/src/initializeLogging.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import log4js from 'log4js';
22
import * as path from 'path'
33
import * as os from 'os'
4-
import yargs from 'yargs'
54

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

10-
export default function initializeLogging() {
9+
export default function initializeLogging(debug = false) {
1110
log4js.configure({
1211
appenders: {
1312
server: {
@@ -17,7 +16,8 @@ export default function initializeLogging() {
1716
ackups: MAX_LOG_BACKUPS
1817
}
1918
},
20-
categories: { default: { appenders: ['server'], level: yargs.argv.debug ? 'debug' : 'debug' } }
19+
// TODO: Should accept level
20+
categories: { default: { appenders: ['server'], level: debug ? 'debug' : 'debug' } }
2121
})
2222

2323
const logger = log4js.getLogger()

0 commit comments

Comments
 (0)