Skip to content

Commit d4c6309

Browse files
committed
Cli and server versions of queryleaf
1 parent d5a1d65 commit d4c6309

File tree

89 files changed

+14225
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+14225
-89
lines changed

.eslintrc.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
ecmaVersion: 2020,
6+
sourceType: 'module',
7+
project: ['./tsconfig.json', './packages/*/tsconfig.json'],
8+
},
9+
plugins: ['@typescript-eslint'],
10+
extends: [
11+
'eslint:recommended',
12+
'plugin:@typescript-eslint/recommended',
13+
],
14+
env: {
15+
node: true,
16+
jest: true,
17+
},
18+
rules: {
19+
'@typescript-eslint/no-explicit-any': 'warn',
20+
'@typescript-eslint/explicit-function-return-type': 'off',
21+
'@typescript-eslint/no-unused-vars': ['error', {
22+
argsIgnorePattern: '^_',
23+
varsIgnorePattern: '^_'
24+
}],
25+
},
26+
ignorePatterns: ['dist', 'node_modules', '*.js', '*.d.ts']
27+
};

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [16.x, 18.x]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'yarn'
25+
26+
- name: Install dependencies
27+
run: yarn install --frozen-lockfile
28+
29+
- name: Build
30+
run: yarn build
31+
32+
- name: Lint
33+
run: yarn lint
34+
35+
- name: Format check
36+
run: yarn format:check
37+
38+
- name: Typecheck
39+
run: yarn typecheck
40+
41+
- name: Test
42+
run: yarn test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
/dist
33
/build
44
/site
5+
packages/*/dist
56

67
# Dependencies
78
/node_modules
9+
packages/*/node_modules
810

911
# IDE and OS files
1012
.idea/

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 100,
6+
"tabWidth": 2
7+
}

README-monorepo.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# QueryLeaf Monorepo Guidelines
2+
3+
This repository uses a monorepo structure with Yarn workspaces to manage multiple packages.
4+
5+
## Repository Structure
6+
7+
- `packages/lib`: Core library for SQL to MongoDB translation
8+
- `packages/cli`: Command-line interface
9+
- `packages/server`: REST API server
10+
11+
## Development Workflow
12+
13+
### Installation
14+
15+
```bash
16+
yarn install
17+
```
18+
19+
### Building
20+
21+
```bash
22+
# Build all packages
23+
yarn build
24+
25+
# Build individual packages
26+
yarn build:lib
27+
yarn build:cli
28+
yarn build:server
29+
```
30+
31+
### Testing
32+
33+
```bash
34+
# Run all tests
35+
yarn test
36+
37+
# Run tests for individual packages
38+
yarn test:lib
39+
yarn test:cli
40+
yarn test:server
41+
42+
# Run specific test types for the lib package
43+
yarn test:lib:unit
44+
yarn test:lib:integration
45+
```
46+
47+
### Code Quality
48+
49+
```bash
50+
# Run TypeScript type checking
51+
yarn typecheck
52+
53+
# Run linting
54+
yarn lint
55+
yarn lint:fix
56+
57+
# Run code formatting
58+
yarn format
59+
yarn format:check
60+
61+
# Run all validations (types, linting, tests, formatting)
62+
yarn validate
63+
```
64+
65+
## Adding new features
66+
67+
1. Determine which package(s) need to be modified
68+
2. Make changes in the appropriate package(s)
69+
3. Add tests in the package's `tests` directory
70+
4. Run `yarn validate` to ensure everything passes
71+
5. Submit a pull request
72+
73+
## Dependency Management
74+
75+
- Shared dev dependencies (TypeScript, ESLint, etc.) are in the root `package.json`
76+
- Package-specific dependencies are in each package's `package.json`
77+
- Use `yarn add <package> -W` to add a dependency to the root
78+
- Use `yarn workspace @queryleaf/[package] add <dependency>` to add a dependency to a specific package
79+
80+
## Release Process
81+
82+
Each package is versioned independently but released together.
83+
84+
1. Update versions in each package's `package.json`
85+
2. Build all packages: `yarn build`
86+
3. Publish packages:
87+
```
88+
cd packages/lib && npm publish
89+
cd ../cli && npm publish
90+
cd ../server && npm publish
91+
```
92+
93+
## Best Practices
94+
95+
1. Keep packages focused on a single responsibility
96+
2. Share code through dependencies, not copy-paste
97+
3. Ensure all code is properly tested
98+
4. Maintain consistent coding style across packages using ESLint and Prettier
99+
5. Document all public APIs

bin/queryleaf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('../dist/cli.js');

bin/queryleaf-server

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('../dist/server.js');

docs/getting-started/installation.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,70 @@ Before installing QueryLeaf, make sure you have:
1313

1414
## Installing QueryLeaf
1515

16-
You can install QueryLeaf using npm or yarn:
16+
QueryLeaf is divided into three separate packages to minimize dependencies:
17+
18+
### Core Library
19+
20+
Install the core library as a dependency in your project:
21+
22+
=== "npm"
23+
```bash
24+
npm install @queryleaf/lib
25+
```
26+
27+
=== "yarn"
28+
```bash
29+
yarn add @queryleaf/lib
30+
```
31+
32+
### Command Line Interface
33+
34+
To use the command-line interface, install the CLI package:
1735

1836
=== "npm"
1937
```bash
20-
npm install queryleaf
38+
# As a project dependency
39+
npm install @queryleaf/cli
40+
41+
# Or globally
42+
npm install -g @queryleaf/cli
2143
```
2244

2345
=== "yarn"
2446
```bash
25-
yarn add queryleaf
47+
# As a project dependency
48+
yarn add @queryleaf/cli
49+
50+
# Or globally
51+
yarn global add @queryleaf/cli
2652
```
2753

54+
After installation, you'll have access to the `queryleaf` command.
55+
56+
### Web Server
57+
58+
To use the web server for a MongoDB SQL proxy, install the server package:
59+
60+
=== "npm"
61+
```bash
62+
# As a project dependency
63+
npm install @queryleaf/server
64+
65+
# Or globally
66+
npm install -g @queryleaf/server
67+
```
68+
69+
=== "yarn"
70+
```bash
71+
# As a project dependency
72+
yarn add @queryleaf/server
73+
74+
# Or globally
75+
yarn global add @queryleaf/server
76+
```
77+
78+
After installation, you'll have access to the `queryleaf-server` command.
79+
2880
## TypeScript Support
2981

3082
QueryLeaf is written in TypeScript and includes type definitions out of the box. You don't need to install any additional packages for TypeScript support.
@@ -114,4 +166,6 @@ Now that you have installed QueryLeaf, you can proceed to:
114166

115167
- [Quick Start Guide](quickstart.md): Learn the basics of using QueryLeaf
116168
- [Core Concepts](../usage/core-concepts.md): Understand the architecture and principles
169+
- [CLI Documentation](../usage/cli.md): Learn how to use the command-line interface
170+
- [Server Documentation](../usage/server.md): Learn how to run and use the web server
117171
- [Examples](../usage/examples.md): See practical examples of using QueryLeaf

0 commit comments

Comments
 (0)