|
| 1 | +# Contributing to loq |
| 2 | + |
| 3 | +Thanks for your interest in contributing! |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +```bash |
| 8 | +# Clone the repo |
| 9 | +git clone https://github.com/code-with-auto/loq.git |
| 10 | +cd loq |
| 11 | + |
| 12 | +# Install dependencies |
| 13 | +bun install |
| 14 | + |
| 15 | +# Run tests |
| 16 | +bun test |
| 17 | + |
| 18 | +# Run in dev mode |
| 19 | +bun run dev |
| 20 | +``` |
| 21 | + |
| 22 | +## Development Workflow |
| 23 | + |
| 24 | +1. Fork the repo |
| 25 | +2. Create a feature branch: `git checkout -b feat/my-feature` |
| 26 | +3. Make your changes |
| 27 | +4. Run tests: `bun test` |
| 28 | +5. Run type check: `bun run typecheck` |
| 29 | +6. Commit with conventional commits |
| 30 | +7. Push and open a PR |
| 31 | + |
| 32 | +## Commit Messages |
| 33 | + |
| 34 | +Use conventional commits: |
| 35 | + |
| 36 | +``` |
| 37 | +feat: add support for Docker log format |
| 38 | +fix: handle missing timestamp in syslog |
| 39 | +docs: update README with new examples |
| 40 | +test: add coverage for edge cases |
| 41 | +refactor: simplify query executor |
| 42 | +chore: update dependencies |
| 43 | +ci: fix GitHub Actions workflow |
| 44 | +``` |
| 45 | + |
| 46 | +## Adding a New Parser |
| 47 | + |
| 48 | +See the [Custom Formats Guide](https://code-with-auto.github.io/loq/guide/custom-formats.html#contributing-built-in-parsers) for detailed instructions. |
| 49 | + |
| 50 | +Quick overview: |
| 51 | + |
| 52 | +1. Create `src/parser/formats/myformat.ts` |
| 53 | +2. Implement `LogParser` interface |
| 54 | +3. Register in `src/parser/auto-detect.ts` |
| 55 | +4. Add tests in `tests/parser/myformat.test.ts` |
| 56 | +5. Submit PR |
| 57 | + |
| 58 | +## Project Structure |
| 59 | + |
| 60 | +``` |
| 61 | +loq/ |
| 62 | +├── src/ |
| 63 | +│ ├── index.ts # CLI entry point |
| 64 | +│ ├── cli/args.ts # Argument parsing |
| 65 | +│ ├── config/loader.ts # Config file loading |
| 66 | +│ ├── parser/ |
| 67 | +│ │ ├── types.ts # Core types |
| 68 | +│ │ ├── auto-detect.ts # Format detection |
| 69 | +│ │ └── formats/ # Built-in parsers |
| 70 | +│ ├── query/ |
| 71 | +│ │ ├── lexer.ts # Tokenizer |
| 72 | +│ │ ├── parser.ts # Query parser |
| 73 | +│ │ ├── ast.ts # AST types |
| 74 | +│ │ └── executor.ts # Query execution |
| 75 | +│ ├── output/ |
| 76 | +│ │ ├── formatter.ts # Output formatting |
| 77 | +│ │ └── colors.ts # Terminal colors |
| 78 | +│ └── utils/time.ts # Time utilities |
| 79 | +├── tests/ # Test files |
| 80 | +└── docs/ # VitePress docs |
| 81 | +``` |
| 82 | + |
| 83 | +## Code Style |
| 84 | + |
| 85 | +- TypeScript with strict mode |
| 86 | +- No semicolons (Bun default) |
| 87 | +- 2 space indentation |
| 88 | +- Prefer `const` over `let` |
| 89 | +- Use descriptive variable names |
| 90 | + |
| 91 | +## Running Tests |
| 92 | + |
| 93 | +```bash |
| 94 | +# Run all tests |
| 95 | +bun test |
| 96 | + |
| 97 | +# Run specific test file |
| 98 | +bun test tests/parser/json.test.ts |
| 99 | + |
| 100 | +# Run with coverage |
| 101 | +bun test --coverage |
| 102 | + |
| 103 | +# Watch mode |
| 104 | +bun test --watch |
| 105 | +``` |
| 106 | + |
| 107 | +## Questions? |
| 108 | + |
| 109 | +Open an issue or start a discussion on GitHub. |
0 commit comments