Reorganize project into standard root layout
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+8
-2
@@ -1,6 +1,12 @@
|
||||
*
|
||||
!go/
|
||||
!go/**
|
||||
!cmd/
|
||||
!cmd/**
|
||||
!internal/
|
||||
!internal/**
|
||||
!webterm/
|
||||
!webterm/**
|
||||
!go.mod
|
||||
!go.sum
|
||||
!Dockerfile
|
||||
!.dockerignore
|
||||
!VERSION
|
||||
|
||||
@@ -24,5 +24,5 @@ Always use the Makefile for development tasks. Never run raw `go test`, `go vet`
|
||||
|
||||
1. **Before changes**: Run `make check` to establish baseline.
|
||||
2. **After changes**: Run `make check` and `make race`.
|
||||
3. **Frontend edits**: Run `make build` after changing `go/webterm/static/js/terminal.ts`.
|
||||
3. **Frontend edits**: Run `make build` after changing `webterm/static/js/terminal.ts`.
|
||||
4. **Major validation**: Run `make build-all` for a reproducible full run.
|
||||
|
||||
@@ -7,5 +7,5 @@ Applies when: this repo has `go.mod`.
|
||||
- Put `golangci-lint` and `gosec` wiring behind Make targets when introduced.
|
||||
|
||||
## Conventions to implement
|
||||
- `make test` should run `cd go && go test ./...`.
|
||||
- `make test` should run `go test ./...`.
|
||||
- Avoid bespoke CI steps when a Make target can encode the same behavior.
|
||||
|
||||
+1
-2
@@ -10,14 +10,13 @@
|
||||
webterm.log
|
||||
|
||||
# Coverage/build artifacts
|
||||
go/coverage.out
|
||||
coverage.out
|
||||
dist/
|
||||
build/
|
||||
target/
|
||||
|
||||
# Go
|
||||
go/bin/
|
||||
bin/
|
||||
|
||||
# Frontend
|
||||
node_modules/
|
||||
|
||||
+6
-4
@@ -4,11 +4,13 @@
|
||||
FROM golang:1.26-alpine AS builder
|
||||
|
||||
WORKDIR /src
|
||||
COPY go/go.mod go/go.sum ./go/
|
||||
RUN cd go && go mod download
|
||||
COPY go ./go
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY cmd ./cmd
|
||||
COPY internal ./internal
|
||||
COPY webterm ./webterm
|
||||
COPY VERSION ./VERSION
|
||||
RUN cd go && VERSION=$(cat /src/VERSION) && CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X github.com/rcarmo/webterm-go-port/webterm.Version=$VERSION" -o /out/webterm ./cmd/webterm
|
||||
RUN VERSION=$(cat /src/VERSION) && CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X github.com/rcarmo/webterm-go-port/webterm.Version=$VERSION" -o /out/webterm ./cmd/webterm
|
||||
|
||||
FROM alpine:3.21 AS runtime
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.PHONY: help install install-dev lint format test race coverage check fuzz build-go build build-fast bundle bundle-watch bundle-clean clean clean-all build-all typecheck bump-patch push
|
||||
|
||||
GO_DIR = go
|
||||
STATIC_JS_DIR = go/webterm/static/js
|
||||
GO_DIR = .
|
||||
STATIC_JS_DIR = webterm/static/js
|
||||
TERMINAL_TS = $(STATIC_JS_DIR)/terminal.ts
|
||||
TERMINAL_JS = $(STATIC_JS_DIR)/terminal.js
|
||||
GHOSTTY_WASM = $(STATIC_JS_DIR)/ghostty-vt.wasm
|
||||
|
||||
@@ -27,26 +27,24 @@ This repository is the Go port of the original Python implementation, which is p
|
||||
|
||||
```bash
|
||||
git clone https://github.com/rcarmo/webterm.git
|
||||
cd webterm/go
|
||||
cd webterm
|
||||
mkdir -p bin
|
||||
go build -o ./bin/webterm ./cmd/webterm
|
||||
```
|
||||
|
||||
The command above produces `go/bin/webterm`; you can also build it from repo root with `make build-go`.
|
||||
The command above produces `bin/webterm`; you can also build it from repo root with `make build-go`.
|
||||
|
||||
## Quick start
|
||||
|
||||
Run a default shell session:
|
||||
|
||||
```bash
|
||||
cd go
|
||||
go run ./cmd/webterm
|
||||
```
|
||||
|
||||
Run a specific command:
|
||||
|
||||
```bash
|
||||
cd go
|
||||
go run ./cmd/webterm -- htop
|
||||
```
|
||||
|
||||
@@ -64,14 +62,12 @@ Then open <http://localhost:8080>.
|
||||
```
|
||||
|
||||
```bash
|
||||
cd go
|
||||
go run ./cmd/webterm -- --landing-manifest ../landing.yaml
|
||||
go run ./cmd/webterm -- --landing-manifest ./landing.yaml
|
||||
```
|
||||
|
||||
### Docker watch
|
||||
|
||||
```bash
|
||||
cd go
|
||||
go run ./cmd/webterm -- --docker-watch
|
||||
```
|
||||
|
||||
@@ -83,8 +79,7 @@ Containers with these labels become tiles:
|
||||
### Compose manifest
|
||||
|
||||
```bash
|
||||
cd go
|
||||
go run ./cmd/webterm -- --compose-manifest ../docker-compose.yaml
|
||||
go run ./cmd/webterm -- --compose-manifest ./docker-compose.yaml
|
||||
```
|
||||
|
||||
## Environment variables
|
||||
|
||||
@@ -9,7 +9,7 @@ Browser (terminal.js + ghostty-vt.wasm)
|
||||
│
|
||||
│ WS / HTTP / SSE
|
||||
▼
|
||||
go/webterm/server.go (LocalServer)
|
||||
webterm/server.go (LocalServer)
|
||||
│
|
||||
├── session_manager.go (route/app/session registry)
|
||||
├── terminal_session.go (PTY-backed local sessions)
|
||||
@@ -21,9 +21,9 @@ go/webterm/server.go (LocalServer)
|
||||
|
||||
## Packages
|
||||
|
||||
- `go/cmd/webterm`: CLI entrypoint
|
||||
- `go/webterm`: server/runtime/domain logic
|
||||
- `go/internal/terminalstate`: Go terminal emulator wrapper (`go-te`) used for screenshots
|
||||
- `cmd/webterm`: CLI entrypoint
|
||||
- `webterm`: server/runtime/domain logic
|
||||
- `internal/terminalstate`: Go terminal emulator wrapper (`go-te`) used for screenshots
|
||||
|
||||
## Runtime data flow
|
||||
|
||||
@@ -37,7 +37,7 @@ go/webterm/server.go (LocalServer)
|
||||
|
||||
## Static assets
|
||||
|
||||
Assets live in `go/webterm/static`:
|
||||
Assets live in `webterm/static`:
|
||||
|
||||
- `js/terminal.ts` source
|
||||
- `js/terminal.js` bundled client
|
||||
@@ -47,7 +47,7 @@ Assets live in `go/webterm/static`:
|
||||
The server resolves static files from:
|
||||
|
||||
1. `WEBTERM_STATIC_PATH` (if set)
|
||||
2. local repository-relative fallbacks rooted at `go/webterm/static`
|
||||
2. local repository-relative fallbacks rooted at `webterm/static`
|
||||
3. embedded assets bundled into the Go binary
|
||||
|
||||
## Docker integration
|
||||
|
||||
+4
-4
@@ -9,10 +9,10 @@
|
||||
"typescript": "^5.7.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "bun run typecheck && bun build go/webterm/static/js/terminal.ts --outfile=go/webterm/static/js/terminal.js --minify --target=browser && cp node_modules/ghostty-web/ghostty-vt.wasm go/webterm/static/js/",
|
||||
"build:fast": "bun build go/webterm/static/js/terminal.ts --outfile=go/webterm/static/js/terminal.js --minify --target=browser",
|
||||
"watch": "bun build go/webterm/static/js/terminal.ts --outfile=go/webterm/static/js/terminal.js --watch --target=browser",
|
||||
"build": "bun run typecheck && bun build webterm/static/js/terminal.ts --outfile=webterm/static/js/terminal.js --minify --target=browser && cp node_modules/ghostty-web/ghostty-vt.wasm webterm/static/js/",
|
||||
"build:fast": "bun build webterm/static/js/terminal.ts --outfile=webterm/static/js/terminal.js --minify --target=browser",
|
||||
"watch": "bun build webterm/static/js/terminal.ts --outfile=webterm/static/js/terminal.js --watch --target=browser",
|
||||
"typecheck": "bun x tsc --noEmit -p tsconfig.json",
|
||||
"copy-wasm": "cp node_modules/ghostty-web/ghostty-vt.wasm go/webterm/static/js/"
|
||||
"copy-wasm": "cp node_modules/ghostty-web/ghostty-vt.wasm webterm/static/js/"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,6 +12,6 @@
|
||||
"isolatedModules": true,
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"]
|
||||
},
|
||||
"include": ["go/webterm/static/js/**/*.ts"],
|
||||
"include": ["webterm/static/js/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
Reference in New Issue
Block a user