-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jesse Zhang
committed
Feb 16, 2018
0 parents
commit e2fbdc3
Showing
46 changed files
with
3,969 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{js,ts,html}] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[*.{json,yml,g4}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.DS_Store | ||
*~ | ||
*.log | ||
.npmrc | ||
coverage/ | ||
dist/ | ||
node_modules/ | ||
package-lock.json | ||
.antlr/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: node_js | ||
node_js: | ||
- "node" | ||
install: | ||
- npm install | ||
script: | ||
- npm run build | ||
- npm run test | ||
after_success: | ||
- npm run coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"editor.insertSpaces": false, | ||
"editor.detectIndentation": false, | ||
"editor.renderIndentGuides": false, | ||
"editor.renderWhitespace": "boundary", | ||
"files.exclude": { | ||
"**/.git": true, | ||
"**/.svn": true, | ||
"**/.hg": true, | ||
"**/.DS_Store": true, | ||
"**/coverage": true, | ||
"**/dist": true, | ||
"**/node_modules": true | ||
}, | ||
"files.watcherExclude": { | ||
"**/.git/**": true, | ||
"**/coverage/**": true, | ||
"**/dist/**": true, | ||
"**/node_modules/**": true | ||
}, | ||
"search.exclude": { | ||
"**/coverage": true, | ||
"**/dist": true, | ||
"**/node_modules": true | ||
}, | ||
"tslint.exclude": [ | ||
"**/scripts/**/*.js" | ||
], | ||
"vsicons.presets.angular": false, | ||
"TodoParser": { | ||
"include": [ | ||
"ts", | ||
"js", | ||
"html", | ||
"scss" | ||
], | ||
"folderExclude": [ | ||
"node_modules", | ||
".vscode" | ||
], | ||
"only": [ | ||
"src" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# @lchemy/api-filter-parser | ||
TODO | ||
|
||
[![NPM Version](https://img.shields.io/npm/v/@lchemy/api-filter-parser.svg)](https://www.npmjs.com/package/@lchemy/api-filter-parser) | ||
[![Build Status](https://img.shields.io/travis/lchemy/api-filter-parser/master.svg)](https://travis-ci.org/lchemy/api-filter-parser) | ||
[![Coverage Status](https://img.shields.io/coveralls/lchemy/api-filter-parser/master.svg)](https://coveralls.io/r/lchemy/api-filter-parser?branch=master) | ||
[![GitHub Issues](https://img.shields.io/github/issues/lchemy/api-filter-parser.svg)](https://github.com/lchemy/api-filter-parser) | ||
|
||
## Wat? | ||
- Wat? | ||
|
||
## Usage | ||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require("./scripts/gulp"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
transform: { | ||
"^.+\\.ts$": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
}, | ||
testRegex: "^.+\.spec\.ts$", | ||
moduleFileExtensions: ["ts", "js"], | ||
setupTestFrameworkScriptFile: "<rootDir>/src/tests/bootstrap.ts", | ||
collectCoverage: true, | ||
mapCoverage: true, | ||
collectCoverageFrom: [ | ||
"src/**/*.ts", | ||
"!src/**/index.ts", | ||
"!src/codegen/**/*.ts", | ||
"!src/**/*.d.ts", | ||
"!src/**/*.spec.ts", | ||
"!src/**/tests/**/*.ts" | ||
], | ||
coverageDirectory: "<rootDir>/coverage", | ||
coverageReporters: ["lcov", "text", "text-summary"], | ||
modulePathIgnorePatterns: [ | ||
"<rootDir>/dist" | ||
], | ||
verbose: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "@lchemy/api-filter-parser", | ||
"description": "", | ||
"version": "1.0.0-beta.0", | ||
"contributors": [ | ||
"Jesse Zhang" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/lchemy/api-filter-parser.git" | ||
}, | ||
"private": true, | ||
"license": "ISC", | ||
"scripts": { | ||
"build": "gulp build", | ||
"clean": "gulp clean", | ||
"codegen": "gulp build:codegen", | ||
"coveralls": "cat ./coverage/lcov.info | coveralls", | ||
"develop": "gulp develop", | ||
"test": "gulp test", | ||
"tslint": "gulp tslint", | ||
"prepublishOnly": "echo 'Cannot publish the development files. Publish the built files instead.' && exit 1" | ||
}, | ||
"dependencies": { | ||
"@lchemy/antlr4ts": "^0.4.1-alpha.1", | ||
"@lchemy/orm": "^1.0.0-beta.0" | ||
}, | ||
"devDependencies": { | ||
"@lchemy/antlr4ts-cli": "^0.4.0-alpha.6", | ||
"@types/jest": "^22.1.2", | ||
"@types/knex": "^0.14.7", | ||
"coveralls": "^3.0.0", | ||
"del": "^3.0.0", | ||
"fs-extra": "^5.0.0", | ||
"glob-promise": "^3.3.0", | ||
"gulp": "^4.0.0", | ||
"gulp-plumber": "^1.2.0", | ||
"gulp-tslint": "^8.1.3", | ||
"gulp-typescript": "^4.0.1", | ||
"jest": "^22.3.0", | ||
"jest-cli": "^22.3.0", | ||
"knex": "^0.14.3", | ||
"merge2": "^1.2.1", | ||
"shelljs": "^0.8.1", | ||
"ts-jest": "^22.0.4", | ||
"tslint": "^5.9.1", | ||
"typescript": "^2.7.2", | ||
"vinyl-map": "^1.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const gulp = require("gulp"), | ||
ts = require("gulp-typescript"), | ||
map = require("vinyl-map"), | ||
merge = require("merge2"), | ||
shell = require("shelljs"), | ||
path = require("path"); | ||
|
||
gulp.task("build:package", () => { | ||
return gulp.src("package.json").pipe(map((pkgJson) => { | ||
const pkg = JSON.parse(pkgJson); | ||
|
||
delete pkg.private; | ||
delete pkg.scripts; | ||
delete pkg.devDependencies; | ||
pkg.main = "index.js"; | ||
|
||
const dependencies = pkg.dependencies; | ||
pkg.dependencies = Object.keys(dependencies).reduce((memo, key) => { | ||
if (dependencies[key].startsWith("file:")) { | ||
const file = dependencies[key].substr(5); | ||
memo[key] = `file:${ path.join("..", file) }`; | ||
} else { | ||
memo[key] = dependencies[key]; | ||
} | ||
return memo; | ||
}, {}); | ||
|
||
return JSON.stringify(pkg, undefined, 2) + "\n"; | ||
})).pipe(gulp.dest("dist")); | ||
}); | ||
|
||
gulp.task("build:codegen", () => { | ||
shell.mkdir("-p", "./src/codegen"); | ||
const out = shell.exec("antlr4ts -o ../codegen -visitor ApiFilter.g4", { | ||
cwd: path.join(__dirname, "../../src/grammar") | ||
}); | ||
if (out.code !== 0) { | ||
console.error(out.stderr); | ||
throw new Error(`antlr4ts exited with exit code ${ out.code }`); | ||
} | ||
|
||
// need to replace all the imports with @lchemy/antlr4ts | ||
return gulp.src("./src/codegen/*.ts").pipe(map((code) => { | ||
return code.toString("utf8").replace(/(^import .+? from ')antlr4ts(.*?');/gm, "$1@lchemy/antlr4ts$2"); | ||
})).pipe(gulp.dest("./src/codegen")); | ||
}); | ||
|
||
gulp.task("build:ts", () => { | ||
const tsProject = ts.createProject("tsconfig.build.json"); | ||
|
||
const tsResult = gulp.src([ | ||
"./src/**/*.ts", | ||
"!./src/**/tests/**/*.ts", | ||
"!./src/**/*.spec.ts" | ||
]) | ||
.pipe(tsProject()); | ||
|
||
return merge([ | ||
tsResult.dts, | ||
tsResult.js | ||
]).pipe(gulp.dest("dist")); | ||
}); | ||
|
||
gulp.task("build", gulp.series( | ||
"clean:dist", | ||
"build:package", | ||
"build:codegen", | ||
"build:ts" | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const gulp = require("gulp"), | ||
del = require("del"); | ||
|
||
gulp.task("clean:dist", () => { | ||
return del("dist"); | ||
}); | ||
|
||
gulp.task("clean:test", () => { | ||
return del("coverage"); | ||
}); | ||
|
||
gulp.task("clean:codegen", () => { | ||
return del("src/codegen"); | ||
}); | ||
|
||
gulp.task("clean", gulp.parallel([ | ||
"clean:dist", | ||
"clean:test", | ||
"clean:codegen" | ||
])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const gulp = require("gulp"), | ||
ts = require("gulp-typescript"), | ||
merge = require("merge2"), | ||
plumber = require("gulp-plumber"), | ||
jestCli = require("jest-cli"), | ||
jestConfig = require("../../jest.config"); | ||
|
||
gulp.task("develop:build:package", () => { | ||
gulp.watch([ | ||
"./package.json" | ||
], gulp.series("build:package")); | ||
}); | ||
|
||
gulp.task("develop:build:codegen", () => { | ||
gulp.watch([ | ||
"./scripts/codegen/templates/**/*.ejs" | ||
], gulp.series("build:codegen")); | ||
}); | ||
|
||
gulp.task("develop:build:ts", () => { | ||
const tsProject = ts.createProject("tsconfig.build.json", { | ||
isolatedModules: true | ||
}); | ||
|
||
const build = () => { | ||
const tsResult = gulp.src([ | ||
"./src/**/*.ts", | ||
"!./src/**/tests/**/*.ts", | ||
"!./src/**/*.spec.ts" | ||
]) | ||
.pipe(plumber()) | ||
.pipe(tsProject()); | ||
|
||
return merge([ | ||
tsResult.dts, | ||
tsResult.js | ||
]).pipe(gulp.dest("dist")); | ||
}; | ||
build.displayName = "develop:build:ts:execution"; | ||
|
||
gulp.watch([ | ||
"./src/**/*.ts", | ||
"!./src/**/tests/**/*.ts", | ||
"!./src/**/*.spec.ts" | ||
], build); | ||
}); | ||
|
||
gulp.task("develop:test:jest", () => { | ||
return jestCli.runCLI({ | ||
config: jestConfig, | ||
watchAll: true | ||
}, ["."]); | ||
}); | ||
|
||
gulp.task("develop", gulp.series( | ||
"build", | ||
gulp.parallel( | ||
"develop:build:codegen", | ||
"develop:build:ts", | ||
"develop:build:package" | ||
// "develop:test:jest" | ||
) | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require("./clean"); | ||
|
||
require("./build"); | ||
require("./test"); | ||
require("./tslint"); | ||
|
||
require("./develop"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const gulp = require("gulp"), | ||
jestCli = require("jest-cli"), | ||
jestConfig = require("../../jest.config"); | ||
|
||
gulp.task("test:jest", () => { | ||
return jestCli.runCLI({ | ||
config: jestConfig | ||
}, ["."]).then(({ results }) => { | ||
if (!results.success) { | ||
return Promise.reject(new Error(`Failed running ${ results.numFailedTests } test(s)`)); | ||
} | ||
}); | ||
}); | ||
|
||
gulp.task("test", gulp.series([ | ||
"clean:test", | ||
"build:codegen", | ||
"test:jest" | ||
])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const gulp = require("gulp"), | ||
tslint = require("tslint"), | ||
gulpTslint = require("gulp-tslint"); | ||
|
||
gulp.task("tslint", () => { | ||
const program = tslint.Linter.createProgram("./tsconfig.json"); | ||
return gulp.src([ | ||
"src/**/*.ts", | ||
"!src/**/codegen/**/*.ts" | ||
]) | ||
.pipe(gulpTslint({ | ||
program, | ||
formatter: "verbose" | ||
})) | ||
.pipe(gulpTslint.report()) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
T__0=1 | ||
T__1=2 | ||
T__2=3 | ||
OP_NULL_CHECK=4 | ||
OP_COMPARISON=5 | ||
OP_LIKE=6 | ||
OP_BETWEEN=7 | ||
OP_IN=8 | ||
OP_EXISTS=9 | ||
AND=10 | ||
OR=11 | ||
HAVE_COUNT=12 | ||
RAW=13 | ||
FIELD=14 | ||
STRING=15 | ||
NUMBER=16 | ||
SPACE=17 | ||
'('=1 | ||
','=2 | ||
')'=3 | ||
'and'=10 | ||
'or'=11 | ||
'have count'=12 |
Oops, something went wrong.