Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
# pre-commit: ensure all Go files are gofmt-formatted.
set -e

unformatted=$(gofmt -l $(find . -name '*.go' -not -path './frontend/*') 2>/dev/null)
if [ -n "$unformatted" ]; then
echo "The following Go files are not gofmt-formatted:"
echo "$unformatted"
echo ""
echo "Run: gofmt -w ."
exit 1
fi
21 changes: 21 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
# pre-push: mirror CI checks locally before pushing.
set -e

echo "==> go vet ./..."
go vet ./...

echo "==> go test ./..."
go test ./...

if command -v golangci-lint > /dev/null 2>&1; then
echo "==> golangci-lint run ./..."
golangci-lint run ./...
else
echo "golangci-lint not found, skipping (install from https://golangci-lint.run)"
fi

echo "==> frontend lint + build"
( cd frontend && npm run lint && npm run build )

echo "All pre-push checks passed."
17 changes: 16 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,21 @@ jobs:
- name: Test
run: go test -race ./...

lint:
name: Go lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.62.2

frontend:
name: Frontend (build + typecheck)
name: Frontend (lint + build + typecheck)
runs-on: ubuntu-22.04
defaults:
run:
Expand All @@ -42,5 +55,7 @@ jobs:
cache-dependency-path: frontend/package-lock.json
- name: Install
run: npm ci
- name: Lint
run: npm run lint
- name: Build (runs tsc)
run: npm run build
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
build/bin
node_modules
frontend/dist
# Keep the dir tracked (via .gitkeep) so `//go:embed all:frontend/dist`
# compiles on a clean checkout; ignore the built assets themselves.
frontend/dist/*
!frontend/dist/.gitkeep

# OS / editor cruft
.DS_Store
Expand Down
23 changes: 23 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://golangci-lint.run/usage/configuration/
run:
timeout: 5m

linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gofmt
- misspell

issues:
exclude-rules:
# Deferred Close() failures are not actionable here.
- linters: [errcheck]
source: "defer .*\\.Close\\(\\)"
# The nested scaffold under frontend/hypr is a separate module artifact.
exclude-dirs:
- frontend
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Cross-platform release workflow that builds macOS/Windows/Linux binaries on `v*` tags.
- Contributor documentation: `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, `SECURITY.md`,
issue/PR templates, and this changelog.
- `golangci-lint` config (`.golangci.yml`) and a dedicated `lint` job in CI.
- ESLint config for the frontend (`frontend/.eslintrc.cjs`); `npm run lint` added to the
frontend CI job and the pre-push hook.
- Git hooks (`.githooks/pre-commit`, `.githooks/pre-push`) that enforce formatting and
mirror CI checks locally; enable with `make hooks`.
- `Makefile` with `hooks`, `setup`, `lint`, `test`, and `build` targets.

### Changed
- cURL import now populates the header rows and request body of the active tab.
- The response view now follows the active request tab.
- The "add header" action moved next to the Request Headers title.

### Fixed
- `//go:embed all:frontend/dist` caused a compile failure on clean checkouts because
`frontend/dist/` was gitignored; fixed by committing a `.gitkeep` and updating
`.gitignore` to track it.
- Exported request headers now include their values; the `Header.value` field was
renamed to `Header.Value` so the JSON marshaller picks it up correctly.
- Request headers were serialized to an empty object and not sent; they are now sent correctly.
- Corrected the application window title (`Hpyr` → `Hypr`).

Expand Down
33 changes: 31 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,41 @@ Before pushing, run the same checks CI runs:
go vet ./...
go test ./...

# Frontend (typecheck + build)
cd frontend && npm ci && npm run build
# Go linting
golangci-lint run ./...

# Frontend (lint + typecheck + build)
cd frontend && npm ci && npm run lint && npm run build
```

CI ([`.github/workflows/ci.yml`](.github/workflows/ci.yml)) runs these on every push and pull request.

### Local git hooks

Enable the repo's git hooks to catch issues before they hit CI:

```bash
make hooks # or: git config core.hooksPath .githooks
```

- `pre-commit` — fails if any Go file is not `gofmt`-formatted.
- `pre-push` — mirrors CI (`go vet`, `go test`, `golangci-lint` if installed, frontend lint + build).

`make setup` runs `make hooks` and installs frontend dependencies in one go.

### Git hooks

The repo ships pre-commit and pre-push hooks in `.githooks/`. Enable them once per clone:

```bash
make hooks
# or manually:
git config core.hooksPath .githooks
```

The **pre-commit** hook rejects any unformatted Go files (`gofmt -w .` to fix).
The **pre-push** hook mirrors the full CI suite locally (go vet, go test, golangci-lint if available, and the frontend lint + build).

## Releasing

Hypr follows [Semantic Versioning](https://semver.org) (`MAJOR.MINOR.PATCH`):
Expand Down
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.PHONY: hooks setup lint test build

hooks:
git config core.hooksPath .githooks
chmod +x .githooks/*

setup: hooks
cd frontend && npm install

lint:
go vet ./...
golangci-lint run ./...
cd frontend && npm run lint

test:
go test ./...

build:
wails build
5 changes: 2 additions & 3 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (a *App) RunCurl(curl string) RequestResult {

type Header struct {
Key string
value string
Value string
}

// Greet returns a greeting for the given name
Expand Down Expand Up @@ -132,7 +132,6 @@ func (a *App) MakeRequest(
}
}

texts := string(b.Bytes())
result.Body = texts
result.Body = b.String()
return result
}
5 changes: 4 additions & 1 deletion export.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ func (a *App) Export(req Request, reqHeaders [][]Header, reqBodies []string, r R
}

defer f.Close()
f.Write(js)
if _, err := f.Write(js); err != nil {
log.Println(err)
return err
}

return nil
}
24 changes: 24 additions & 0 deletions frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
root: true,
env: {browser: true, es2020: true},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: [
'dist',
'wailsjs',
'node_modules',
'.eslintrc.cjs',
'vite.config.ts',
'hypr/', // stale nested Wails scaffold, not part of the app
],
parser: '@typescript-eslint/parser',
rules: {
// The Wails bindings and event payloads are loosely typed; `any` is pragmatic here.
'@typescript-eslint/no-explicit-any': 'off',
// The React root element is known to exist.
'@typescript-eslint/no-non-null-assertion': 'off',
},
}
Empty file added frontend/dist/.gitkeep
Empty file.
Loading
Loading