Skip to content

Commit 647e27b

Browse files
committed
initial commit
0 parents  commit 647e27b

37 files changed

Lines changed: 5939 additions & 0 deletions

.github/workflows/cd.yaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
name: Build (${{ matrix.target }})
14+
runs-on: ${{ matrix.runner }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
# Linux targets — cross-compiled from ubuntu (no ARM runner needed)
20+
- runner: ubuntu-latest
21+
target: bun-linux-x64
22+
artifact: github-code-search-linux-x64
23+
- runner: ubuntu-latest
24+
target: bun-linux-x64-baseline
25+
artifact: github-code-search-linux-x64-baseline
26+
- runner: ubuntu-latest
27+
target: bun-linux-arm64
28+
artifact: github-code-search-linux-arm64
29+
# Windows — cross-compiled from ubuntu
30+
- runner: ubuntu-latest
31+
target: bun-windows-x64
32+
artifact: github-code-search-windows-x64.exe
33+
# macOS — must run on macOS for ad-hoc codesigning
34+
- runner: macos-latest
35+
target: bun-darwin-x64
36+
artifact: github-code-search-macos-x64
37+
- runner: macos-latest
38+
target: bun-darwin-arm64
39+
artifact: github-code-search-macos-arm64
40+
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v6
44+
45+
- name: Setup Bun
46+
uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2
47+
with:
48+
bun-version: latest
49+
50+
- name: Install dependencies
51+
run: bun install --frozen-lockfile
52+
53+
- name: Run tests
54+
run: bun test
55+
56+
- name: Build binary
57+
run: bun run build.ts --target=${{ matrix.target }}
58+
59+
- name: Rename artifact
60+
# build.ts outputs dist/github-code-search-<target-without-bun->
61+
# Rename to the canonical artifact name defined in the matrix.
62+
shell: bash
63+
run: |
64+
src="dist/github-code-search-$(echo '${{ matrix.target }}' | sed 's/^bun-//')"
65+
[ -f "${src}.exe" ] && src="${src}.exe"
66+
mv -v "$src" "dist/${{ matrix.artifact }}"
67+
68+
- name: Upload artifact
69+
uses: actions/upload-artifact@v7
70+
with:
71+
name: ${{ matrix.artifact }}
72+
path: dist/${{ matrix.artifact }}
73+
74+
release:
75+
name: Create GitHub release
76+
needs: build
77+
runs-on: ubuntu-latest
78+
79+
steps:
80+
- name: Download all artifacts
81+
uses: actions/download-artifact@v7
82+
with:
83+
path: dist/
84+
merge-multiple: true
85+
86+
- name: Create release
87+
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
88+
with:
89+
files: dist/*
90+
generate_release_notes: true

.github/workflows/ci.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
test:
11+
name: Unit tests
12+
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: write
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v6
19+
20+
- name: Setup Bun
21+
uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2
22+
with:
23+
bun-version: latest
24+
25+
- name: Install dependencies
26+
run: bun install --frozen-lockfile
27+
28+
- name: Run tests
29+
run: bun test
30+
31+
- name: Post LCOV coverage comment
32+
if: always() && github.event_name == 'pull_request'
33+
uses: romeovs/lcov-reporter-action@v0.3.1
34+
with:
35+
github-token: ${{ secrets.GITHUB_TOKEN }}
36+
lcov-file: coverage/lcov.info
37+
continue-on-error: true
38+
39+
quality:
40+
name: Format · Lint · Dead code
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v6
46+
47+
- name: Setup Bun
48+
uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2
49+
with:
50+
bun-version: latest
51+
52+
- name: Install dependencies
53+
run: bun install --frozen-lockfile
54+
55+
- name: Check formatting (oxfmt)
56+
run: bun run format:check
57+
58+
- name: Lint (oxlint)
59+
run: bun run lint
60+
61+
- name: Dead code detection (knip)
62+
run: bun run knip

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
.env
5+
*.local

.oxfmtrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"ignorePatterns": []
4+
}

.oxlintrc.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": null,
4+
"categories": {
5+
"correctness": "error",
6+
"suspicious": "warn"
7+
},
8+
"rules": {},
9+
"overrides": [
10+
{
11+
"files": ["**/*.test.ts"],
12+
"rules": {
13+
"no-control-regex": "off"
14+
}
15+
}
16+
],
17+
"settings": {
18+
"jsx-a11y": {
19+
"polymorphicPropName": null,
20+
"components": {},
21+
"attributes": {}
22+
},
23+
"next": {
24+
"rootDir": []
25+
},
26+
"react": {
27+
"formComponents": [],
28+
"linkComponents": [],
29+
"version": null,
30+
"componentWrapperFunctions": []
31+
},
32+
"jsdoc": {
33+
"ignorePrivate": false,
34+
"ignoreInternal": false,
35+
"ignoreReplacesDocs": true,
36+
"overrideReplacesDocs": true,
37+
"augmentsExtendsReplacesDocs": false,
38+
"implementsReplacesDocs": false,
39+
"exemptDestructuredRootsFromChecks": false,
40+
"tagNamePreference": {}
41+
},
42+
"vitest": {
43+
"typecheck": false
44+
}
45+
},
46+
"env": {
47+
"builtin": true
48+
},
49+
"globals": {},
50+
"ignorePatterns": []
51+
}

CONTRIBUTING.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Contributing to github-code-search
2+
3+
Thank you for taking the time to contribute! This document describes how to set up a development environment, run tests, and submit changes.
4+
5+
## Prerequisites
6+
7+
- [Bun](https://bun.sh) ≥ 1.0
8+
- A GitHub personal access token with `repo` scope (for integration testing)
9+
10+
## Development setup
11+
12+
```bash
13+
git clone https://github.com/fulll/github-code-search
14+
cd github-code-search
15+
bun install
16+
```
17+
18+
## Project structure
19+
20+
```
21+
github-code-search.ts # CLI entry point (Commander subcommands: query, upgrade)
22+
build.ts # Build script (compiles the standalone binary)
23+
src/
24+
types.ts # Shared TypeScript types
25+
api.ts # GitHub REST API client
26+
aggregate.ts # Result grouping and filtering logic
27+
aggregate.test.ts # Unit tests for aggregate.ts
28+
render.ts # Façade: re-exports sub-modules + TUI renderGroups/renderHelpOverlay
29+
render.test.ts # Unit tests for render.ts (rows, filter, selection, rendering)
30+
render/
31+
highlight.ts # Syntax highlighting (language detection, token rules, highlightFragment)
32+
highlight.test.ts # Unit tests for highlight.ts (per-language tokenizer coverage)
33+
filter.ts # Filter helpers (FilterStats, buildFilterStats)
34+
rows.ts # Row navigation (buildRows, rowTerminalLines, isCursorVisible)
35+
summary.ts # Stats labels (buildSummary, buildSummaryFull, buildSelectionSummary)
36+
selection.ts # Selection mutations (applySelectAll, applySelectNone)
37+
output.ts # Text (markdown) and JSON output formatters
38+
output.test.ts # Unit tests for output.ts
39+
tui.ts # Interactive keyboard-driven UI (navigation, filter mode, help overlay)
40+
upgrade.ts # Auto-upgrade logic (fetch latest release, replace binary)
41+
upgrade.test.ts # Unit tests for upgrade.ts
42+
dist/ # Compiled binary (git-ignored)
43+
```
44+
45+
## Running tests
46+
47+
```bash
48+
bun test
49+
```
50+
51+
Tests are co-located with their source files and cover the pure functions in `aggregate.ts`, `output.ts`, `render.ts`, `render/highlight.ts`, and `upgrade.ts`.
52+
53+
## Building a self-contained binary
54+
55+
Build for the current platform:
56+
57+
```bash
58+
bun run build.ts
59+
# → produces dist/github-code-search (or dist/github-code-search.exe on Windows)
60+
```
61+
62+
Cross-compile for a specific target:
63+
64+
```bash
65+
bun run build.ts --target=bun-linux-x64
66+
bun run build.ts --target=bun-linux-x64-baseline
67+
bun run build.ts --target=bun-linux-arm64
68+
bun run build.ts --target=bun-darwin-x64
69+
bun run build.ts --target=bun-darwin-arm64
70+
bun run build.ts --target=bun-windows-x64
71+
```
72+
73+
The build script automatically injects the git commit SHA, target OS, and architecture into the binary. Running `github-code-search --version` will show:
74+
75+
```
76+
1.2.3 (a1b2c3d · darwin/arm64)
77+
```
78+
79+
Compiled binaries require no runtime dependencies and can be distributed as a single file.
80+
81+
## Code style
82+
83+
- TypeScript throughout.
84+
- Pure functions wherever possible (makes unit testing straightforward).
85+
- Side-effectful code (CLI parsing, API calls, TTY interaction) is isolated in `github-code-search`, `src/api.ts`, and `src/tui.ts`.
86+
- No linter is configured yet; keep diffs small and consistent with the surrounding code.
87+
88+
## Submitting a pull request
89+
90+
1. Fork the repository and create a branch: `git checkout -b my-feature`.
91+
2. Make your changes, add or update tests.
92+
3. Ensure `bun test` passes.
93+
4. Open a pull request against `main` with a clear description of the motivation and changes.
94+
95+
## Reporting bugs
96+
97+
Please open an issue and include:
98+
99+
- The exact command you ran (with `GITHUB_TOKEN` redacted).
100+
- The output you observed vs. what you expected.
101+
- The full `github-code-search --version` output (contains commit SHA, OS, and architecture).
102+
- Your Bun version (`bun --version`) if running from source.

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# MIT License
2+
3+
Copyright (c) 2026 Fulll
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)