Skip to content

Commit

Permalink
build: modular assembly (#196)
Browse files Browse the repository at this point in the history
* build: lang separate build

* build: lang separate build

* build: lang separate build

* build: lang separate build

* build: lang separate build

* build: lang separate build

* build: remove dist-types directory

* build: fix types

* build: fix build.js after rebase

* build: remove export ...Lexer and ...Parser

* build: change build
  • Loading branch information
itwillwork authored Jul 9, 2024
1 parent f6cc273 commit 1e8ff53
Show file tree
Hide file tree
Showing 206 changed files with 775 additions and 839 deletions.
24 changes: 22 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"src/autocomplete/databases/*/generated/**/*",
"src/autocomplete/databases/*/grammar/**/*"
],
"plugins": ["filenames"],
"plugins": ["filenames", "import"],
"rules": {
"array-callback-return": "off",
"consistent-return": "off",
Expand All @@ -23,6 +23,26 @@
{"blankLine": "always", "prev": "*", "next": "function"},
{"blankLine": "always", "prev": "export", "next": "*"},
{"blankLine": "always", "prev": "*", "next": "export"}
]
],
"import/no-restricted-paths": ["error", {
"zones": [
{
"target": "./src/autocomplete/databases/clickhouse/**/*",
"from": "./src/autocomplete/databases/!(clickhouse)/**/*"
},
{
"target": "./src/autocomplete/databases/mysql/**/*",
"from": "./src/autocomplete/databases/!(mysql)/**/*"
},
{
"target": "./src/autocomplete/databases/postgresql/**/*",
"from": "./src/autocomplete/databases/!(postgresql)/**/*"
},
{
"target": "./src/autocomplete/databases/yql/**/*",
"from": "./src/autocomplete/databases/!(yql)/**/*"
},
]
}]
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ node_modules

# Artifacts
dist
dist-types

.ds_store

Expand Down
8 changes: 6 additions & 2 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import {build} from 'esbuild';

const databases = ['clickhouse', 'mysql', 'postgresql', 'yql'];

build({
entryPoints: ['src/index.ts'],
external: ['antlr4ng', 'antlr4-c3'],
bundle: true,
minify: true,
keepNames: true,
format: 'esm',
outfile: 'dist/index.js',
tsconfig: './tsconfig.build.json',
entryPoints: databases.map((database) => `src/autocomplete/databases/${database}/index.ts`),
outbase: 'src/autocomplete/databases',
outdir: 'dist/databases',
splitting: true,
});
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 27 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,31 @@
"files": [
"dist/*"
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
"./clickhouse": "./dist/databases/clickhouse/index.js",
"./mysql": "./dist/databases/mysql/index.js",
"./postgresql": "./dist/databases/postgresql/index.js",
"./yql": "./dist/databases/yql/index.js"
},
"typesVersions": {
"*": {
"clickhouse": [
"./dist/types/databases/clickhouse/index.d.ts"
],
"mysql": [
"./dist/types/databases/mysql/index.d.ts"
],
"yql": [
"./dist/types/databases/yql/index.d.ts"
],
"postgresql": [
"./dist/types/databases/postgresql/index.d.ts"
],
"shared": [
"./dist/types/shared/index.d.ts"
]
}
},
"engines": {
"node": ">=16.0"
},
Expand All @@ -33,7 +56,7 @@
"generate:clickhouse": "rimraf src/autocomplete/databases/clickhouse/generated && antlr4ng -Dlanguage=TypeScript -o src/autocomplete/databases/clickhouse/generated/ -visitor -no-listener -Xexact-output-dir src/autocomplete/databases/clickhouse/grammar/ClickHouseLexer.g4 src/autocomplete/databases/clickhouse/grammar/ClickHouseParser.g4 && bash scripts/patch-generated.sh clickhouse",
"generate:yql": "rimraf src/autocomplete/databases/yql/generated && antlr4ng -Dlanguage=TypeScript -o src/autocomplete/databases/yql/generated/ -visitor -no-listener -Xexact-output-dir src/autocomplete/databases/yql/grammar/YQL.g4 && bash scripts/patch-generated.sh yql",
"test": "node --experimental-vm-modules ./node_modules/.bin/jest --verbose src",
"build": "rimraf dist && node build.js && tsc -p tsconfig.build.json",
"build": "rimraf dist && node build.js && tsc -p tsconfig.build.json --declarationDir dist/types",
"prepublishOnly": "npm run build"
},
"devDependencies": {
Expand All @@ -49,6 +72,7 @@
"antlr4ng-cli": "^2.0.0",
"esbuild": "^0.20.0",
"eslint-plugin-filenames": "^1.3.2",
"eslint-plugin-import": "^2.29.1",
"husky": "^8.0.3",
"jest": "^29.7.0",
"nano-staged": "^0.8.0",
Expand Down
236 changes: 0 additions & 236 deletions src/autocomplete/autocomplete.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import {ColumnAliasSymbol, TableSymbol} from '../../shared/symbol-table.js';
import {
AutocompleteData,
AutocompleteResultBase,
ClickHouseAutocompleteResult,
CursorPosition,
ISymbolTableVisitor,
ProcessVisitedRulesResult,
TableOrViewSuggestion,
} from '../../autocomplete-types.js';
} from '../../shared/autocomplete-types.js';
import {ClickHouseLexer} from './generated/ClickHouseLexer.js';
import {
ClickHouseParser,
Expand All @@ -27,6 +26,7 @@ import {
} from '../../shared/tables.js';
import {isStartingToWriteRule} from '../../shared/cursor';
import {shouldSuggestTemplates} from '../../shared/query.js';
import {ClickHouseAutocompleteResult} from './index';

const engines = ['Null', 'Set', 'Log', 'Memory', 'TinyLog', 'StripeLog'];

Expand Down
Loading

0 comments on commit 1e8ff53

Please sign in to comment.