Skip to content

Commit 9cbd192

Browse files
authored
Docs for Copilot
1 parent e602611 commit 9cbd192

File tree

1 file changed

+11
-119
lines changed

1 file changed

+11
-119
lines changed

.github/copilot-instructions.md

Lines changed: 11 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -4,125 +4,30 @@
44

55
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.
66

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
16-
177
## Project Structure
188

199
- `src/` - Source files numbered sequentially (e.g., `05copyright.js`, `10start.js`, etc.)
2010
- `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.
2212
- `types/` - TypeScript type definitions
2313
- `docs/` - Documentation
2414
- `examples/` - Example usage code
2515

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
4616

47-
### Testing
4817

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
6518

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
9619

9720
### Creating Tests
98-
1. Copy `test/test000.js` as a template
9921
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
10023
3. Tests should be self-contained and clear about what they're testing
10124
4. Use the Mocha test framework with standard assertions
10225

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-
10826
## SQL Parser Modifications
10927

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.
11129

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
12631

12732
```bash
12833
# Install dependencies
@@ -137,42 +42,29 @@ yarn format
13742
# Build project
13843
yarn build
13944

140-
# Install globally for testing CLI
141-
yarn install-g
142-
```
143-
144-
## Important Notes
14545

146-
### Files to Avoid Modifying
46+
## Files to Avoid Modifying
14747
- `dist/` - Generated files, will be overwritten on build
14848
- `src/alasqlparser.js` - Generated from Jison grammar (modify the `.jison` file instead)
14949
- `.min.js` files - Generated during build
15050

15151
### 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
15853

15954
## When Implementing Features
16055

16156
1. **Understand the issue thoroughly** - Read related test cases and existing code
16257
2. **Write a test first** - Create `test/test###.js` for the issue
16358
3. **Verify test fails** - Run `yarn test` to confirm the test catches the issue
16459
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.
16864

16965
## When Reviewing Code
17066

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.
17668

17769
## Resources
17870

0 commit comments

Comments
 (0)