You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AlaSQL is an open source SQL database for JavaScript with a focus on query speed and data source flexibility for both relational data and schemaless data. It works in web browsers, Node.js, and mobile apps.
6
6
7
-
## Technology Stack
8
-
9
-
-**Language**: JavaScript (ES5/ES6)
10
-
-**Build System**: Shell script (`build.sh`) that concatenates source files from `src/` into `dist/`
11
-
-**Package Manager**: Yarn (preferred) or npm
12
-
-**Testing**: Mocha test framework
13
-
-**Code Formatting**: Prettier with specific settings (tabs, single quotes, no bracket spacing)
14
-
-**Parser**: Jison for SQL parsing (generates `src/alasqlparser.js`)
15
-
-**Minification**: esbuild for minifying distribution files
-`dist/` - Built distribution files (generated, not committed)
21
-
-`test/` - Test files following `test###.js` naming pattern where ### is typically the issue number
11
+
-`test/` - Test files following `test###.js` naming pattern where ### is typically the issue number or test###-B if the testfilenumber is already taken.
22
12
-`types/` - TypeScript type definitions
23
13
-`docs/` - Documentation
24
14
-`examples/` - Example usage code
25
15
26
-
## Development Workflow
27
-
28
-
### Building
29
-
30
-
```bash
31
-
# Full build (includes formatting)
32
-
yarn build
33
-
34
-
# Build only (no formatting)
35
-
yarn build-only
36
-
37
-
# Or use the shell script directly
38
-
sh build.sh
39
-
```
40
-
41
-
The build process:
42
-
1. Concatenates all source files from `src/` in a specific order
43
-
2. Removes comments and performs text replacements
44
-
3. Creates browser (`alasql.js`, `alasql.min.js`) and Node.js (`alasql.fs.js`) versions
45
-
4. Injects version numbers from package.json
46
16
47
-
### Testing
48
17
49
-
```bash
50
-
# Run all tests (includes build)
51
-
yarn test
52
-
53
-
# Run tests only (without build)
54
-
yarn test-only
55
-
56
-
# Run browser tests
57
-
yarn test-browser
58
-
```
59
-
60
-
### Code Formatting
61
-
62
-
```bash
63
-
# Format changed files since develop branch
64
-
yarn format
65
18
66
-
# Format all files
67
-
yarn format-all
68
-
69
-
# Check formatting
70
-
yarn test-format
71
-
```
72
-
73
-
**Important**: Always run `yarn format` before committing. The pre-push hook checks formatting.
74
-
75
-
## Code Style Guidelines
76
-
77
-
### Formatting Rules
78
-
- Use **tabs** for indentation (not spaces)
79
-
- Use **single quotes** for strings
80
-
- No spaces inside brackets: `{foo: 'bar'}` not `{ foo: 'bar' }`
81
-
- Print width: 100 characters
82
-
- Arrow functions: avoid parens when possible (`x => x` not `(x) => x`)
83
-
- Trailing commas: ES5 style
84
-
85
-
### File Organization
86
-
- Source files in `src/` are numbered to control concatenation order
87
-
- Each file typically handles a specific SQL statement or feature
88
-
- The concatenation order in `build.sh` determines the final build output
89
-
90
-
### Comments
91
-
- Avoid multiline comments starting with `/*/*` (they are removed during build)
92
-
- Avoid comments with `console.log()` in them (removed during build)
93
-
- Use `//` for single-line comments when they contain meaningful information
94
-
95
-
## Testing Guidelines
96
19
97
20
### Creating Tests
98
-
1. Copy `test/test000.js` as a template
99
21
2. Name new test files as `test/test###.js` where `###` is the GitHub issue number if applicable
22
+
1. Copy the structure in `test/test000.js` as a template
100
23
3. Tests should be self-contained and clear about what they're testing
101
24
4. Use the Mocha test framework with standard assertions
102
25
103
-
### Test Structure
104
-
- Tests are run with `--bail` flag (stops on first failure)
105
-
- Tests use dot reporter in CI for concise output
106
-
- Browser tests can be run separately with `yarn test-browser`
107
-
108
26
## SQL Parser Modifications
109
27
110
-
If modifying the SQL parser:
28
+
If a problem demands modifying the lexical parser then seek to do chances as small as possible to `src/alasqlparser.jison`. Afterwards run `yarn jison && yarn test` to confirm the result.
111
29
112
-
```bash
113
-
# Regenerate parser from Jison grammar
114
-
yarn jison
115
-
```
116
-
117
-
This generates `src/alasqlparser.js` from `src/alasqlparser.jison`. The generated file is committed to the repository.
118
-
119
-
## Branch Strategy
120
-
121
-
-**develop** - Main development branch (work from this branch)
122
-
-**master** - Production/release branch
123
-
- Always base your work on the `develop` branch
124
-
125
-
## Common Commands
30
+
## Commands
126
31
127
32
```bash
128
33
# Install dependencies
@@ -137,42 +42,29 @@ yarn format
137
42
# Build project
138
43
yarn build
139
44
140
-
# Install globally for testing CLI
141
-
yarn install-g
142
-
```
143
-
144
-
## Important Notes
145
45
146
-
###Files to Avoid Modifying
46
+
## Files to Avoid Modifying
147
47
- `dist/` - Generated files, will be overwritten on build
148
48
- `src/alasqlparser.js` - Generated from Jison grammar (modify the `.jison` file instead)
149
49
- `.min.js` files - Generated during build
150
50
151
51
### Node.js Version
152
-
- Requires Node.js >= 15
153
-
154
-
### Code Generation
155
-
- The build process heavily uses `rexreplace` for text transformations
156
-
- Version strings `PACKAGE_VERSION` and `BUILD_VERSION` are injected during build
157
-
- Browser and Node.js builds have different code paths (marked with `not-for-browser` and `only-for-browser`)
52
+
- Requires Node.js >= 20 for building
158
53
159
54
## When Implementing Features
160
55
161
56
1. **Understand the issue thoroughly** - Read related test cases and existing code
162
57
2. **Write a test first** - Create `test/test###.js`for the issue
163
58
3. **Verify test fails** - Run `yarn test` to confirm the test catches the issue
164
59
4. **Implement the fix** - Modify appropriate file(s) in`src/`
165
-
5.**Verify test passes** - Run `yarn test` again
166
-
6.**Format code** - Run `yarn format` before committing
167
-
7.**Build succeeds** - Ensure `yarn build` completes without errors
60
+
5. **Format code** - Run `yarn format` before committing
61
+
6. **Verify test passes** - Run `yarn test` again
62
+
63
+
now commit the code.
168
64
169
65
## When Reviewing Code
170
66
171
-
- Check that formatting matches Prettier config (tabs, single quotes, etc.)
172
-
- Verify tests exist for new functionality
173
-
- Ensure the build script includes any new source files in the correct order
174
-
- Confirm browser and Node.js compatibility if applicable
175
-
- Check that documentation is updated if API changes
67
+
- Verify tests exist for any new functionality and any regression the code changes could have affected.
0 commit comments