Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: type generator and move to single package.json #93

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
366 changes: 365 additions & 1 deletion package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
"types": "./dist/index.d.ts",
"scripts": {
"prepare": "husky install",
"postinstall": "if [ -e src/generator ]; then cd src/generator && npm install; fi",
"test": "npm run generate && npm run test_without_generate",
"test_without_generate": "jest src/parsing",
"generate": "cd src/generator && node main.js generic postgresql clickhouse",
"build_generator": "cd src/generator && rimraf dist && tsc -p tsconfig.build.json",
NikitaShkaruba marked this conversation as resolved.
Show resolved Hide resolved
"launch_generator": "cd src/generator && node dist/main.js generic postgresql clickhouse",
"generate": "npm run build_generator && npm run launch_generator",
"lint": "npm run prettier -- --check",
"fix": "npm run prettier -- --write",
"prettier": "prettier \"**/*.{md,yaml,yml,json}\"",
"build": "rimraf dist && tsc -p src/parsing",
"build": "rimraf dist && tsc -p tsconfig.build.json",
"prepublishOnly": "npm run build"
},
"devDependencies": {
Expand All @@ -38,6 +39,7 @@
"@jest/globals": "^29.7.0",
"husky": "^8.0.3",
"jest": "^29.5.0",
"jison": "https://github.com/JohanAhlen/jison/tarball/ad8e41475e",
"nano-staged": "^0.8.0",
"prettier": "^2.8.4",
"rimraf": "^5.0.1",
Expand Down
34 changes: 34 additions & 0 deletions src/generator/@types/jison_cli.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Please note that the code below is the modified code distributed on the terms, mentioned below.
// The copyright for the changes belongs to YANDEX LLC.
//
// Copyright 2023 YANDEX LLC
//
// Licensed under the Apache License, Version 2.0 (the "License")
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.

declare module 'jison/lib/cli.js' {
export interface JisonOptions {
file: string;
lexfile?: string;
json?: boolean;
outfile?: string;
moduleName?: string;
debug?: boolean;
'parser-type'?: string;
'module-type'?: string;
}

interface JisonCli {
main(options: JisonOptions): void;
}

const jisonCli: JisonCli;

export default jisonCli;
}
24 changes: 16 additions & 8 deletions src/generator/lib/files.js → src/generator/lib/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,23 @@

import fs from 'fs';

export const listDir = async folder => fs.promises.readdir(folder);
export async function listDir(folder: string): Promise<string[]> {
return fs.promises.readdir(folder);
}

export const fileExists = file => fs.existsSync(file);
export function fileExists(file: string): boolean {
return fs.existsSync(file);
}

export const readFile = async path => {
const buffer = await fs.promises.readFile(path);
return buffer ? buffer.toString() : "";
};
export async function readFile(path: string): Promise<string> {
const buffer = await fs.promises.readFile(path);
return buffer ? buffer.toString() : '';
}

export const writeFile = (path, contents) => fs.promises.writeFile(path, contents);
export async function writeFile(path: string, contents: string): Promise<void> {
return fs.promises.writeFile(path, contents);
}

export const deleteFile = path => fs.unlinkSync(path);
export function deleteFile(path: string): void {
fs.unlinkSync(path);
}
238 changes: 0 additions & 238 deletions src/generator/lib/generator.js

This file was deleted.

Loading
Loading