Skip to content

Commit f5c9c90

Browse files
committed
refactoring: use webpack + HMR unit tests + one build bundle per language
1 parent 2a4618d commit f5c9c90

15 files changed

Lines changed: 4232 additions & 4170 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ lib/
66
.coveralls.yml
77
bower_components/
88
umd/
9+
output/

.nycrc

Lines changed: 0 additions & 33 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"name": "Attach unit tests",
7+
"request": "attach",
8+
"port": 9240,
9+
"resolveSourceMapLocations": [
10+
"${workspaceFolder}/**",
11+
"!**/node_modules/**"
12+
],
13+
"skipFiles": [
14+
"<node_internals>/*.js",
15+
"**/loader.js", // webpack hmr reloader
16+
"node_modules/core-js/**",
17+
"output/**"
18+
]
19+
}
20+
]
21+
}

.vscode/settings.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"mochaExplorer.hmrBundle": "output/dev/tests.js",
3+
// When using HMR, it is recommanded to configure a different debug port here.
4+
// otherwise, you wont be able to use mocha tests in multiple instances of vscode.
5+
"mochaExplorer.debuggerPort": 9240,
6+
"mochaExplorer.require": "source-map-support/register",
7+
"files.exclude": {
8+
"**/.git": true,
9+
"**/.svn": true,
10+
"**/.hg": true,
11+
"**/CVS": true,
12+
"**/.DS_Store": true,
13+
"node_modules": true,
14+
"output": true,
15+
"package-lock.json": true
16+
}
17+
}

index.d.ts

Lines changed: 1 addition & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1 @@
1-
// Type definitions for node-sql-parser 1.0
2-
// Project: https://github.com/taozhi8833998/node-sql-parser#readme
3-
// Definitions by: taozhi8833998 <https://github.com/taozhi8833998>
4-
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5-
// TypeScript Version: 2.4
6-
7-
export interface With {
8-
name: string;
9-
stmt: any[];
10-
columns?: any[];
11-
}
12-
export type WhilteListCheckMode = 'table' | 'column';
13-
export interface Option {
14-
database?: string,
15-
type?: string,
16-
}
17-
export interface TableColumnAst {
18-
tableList: string[];
19-
columnList: string[];
20-
ast: AST[] | AST;
21-
}
22-
export interface From {
23-
db: string | null;
24-
table: string;
25-
as: string | null;
26-
}
27-
export interface Dual {
28-
type: 'dual';
29-
}
30-
export interface Limit {
31-
type: string;
32-
value: number;
33-
}
34-
export interface OrderBy {
35-
type: 'ASC' | 'DESC';
36-
expr: any;
37-
}
38-
export interface ColumnRef {
39-
type: 'column_ref';
40-
table: string | null;
41-
column: string;
42-
}
43-
export interface SetList {
44-
column: string;
45-
value: any;
46-
table: string | null;
47-
}
48-
export interface InsertReplaceValue {
49-
type: 'expr_list';
50-
value: any[];
51-
}
52-
export interface Star {
53-
type: 'star';
54-
value: '*';
55-
}
56-
export interface AggrFunc {
57-
type: 'aggr_func';
58-
name: string;
59-
args: ColumnRef | AggrFunc | Star | null;
60-
}
61-
export interface Column {
62-
expr: ColumnRef | AggrFunc;
63-
as: string;
64-
}
65-
export interface Select {
66-
with: With | null;
67-
type: 'select';
68-
options: any[] | null;
69-
distinct: 'DISTINCT' | null;
70-
columns: any[] | Column[] | '*';
71-
from: Array<From | Dual> | null;
72-
where: any;
73-
groupby: ColumnRef[] | null;
74-
having: any[] | null;
75-
orderby: OrderBy[] | null;
76-
limit: Limit[] | null;
77-
}
78-
export interface Insert_Replace {
79-
type: 'replace' | 'insert';
80-
db: string | null;
81-
table: any;
82-
columns: string[] | null;
83-
values: InsertReplaceValue[];
84-
}
85-
export interface Update {
86-
type: 'update';
87-
db: string | null;
88-
table: Array<From | Dual> | null;
89-
set: SetList[];
90-
where: any;
91-
}
92-
export interface Delete {
93-
type: 'delete';
94-
table: any;
95-
from: Array<From | Dual>;
96-
where: any;
97-
}
98-
99-
export interface Alter {
100-
type: 'alter',
101-
table: From,
102-
expr: any
103-
}
104-
105-
export interface Use {
106-
type: 'use';
107-
db: string;
108-
}
109-
110-
export type AST = Use | Select | Insert_Replace | Update | Delete | Alter;
111-
112-
export class Parser {
113-
constructor();
114-
115-
parse(sql: string, opt?: Option): TableColumnAst;
116-
117-
astify(sql: string, opt?: Option): AST[] | AST;
118-
119-
sqlify(ast: AST[] | AST, opt?: Option): string;
120-
121-
whiteListCheck(sql: string, whiteList: string[], opt?: Option): Error | undefined;
122-
123-
tableList(sql: string, opt?: Option): string[];
124-
125-
columnList(sql: string, opt?: Option): string[];
126-
}
1+
export * from './types';

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
const Parser = require('./lib/parser').default
2-
const util = require('./lib/util')
1+
import Parser from './src/parser';
2+
import * as util from './src/util';
33

4-
module.exports = {
4+
export {
55
Parser,
66
util,
7-
}
7+
};
88

99
if (global && global.window) {
1010
global.window.NodeSQLParser = {
1111
Parser,
1212
util,
13-
}
13+
};
1414
}

0 commit comments

Comments
 (0)