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/
|
!cmd/
|
||||||
!go/**
|
!cmd/**
|
||||||
|
!internal/
|
||||||
|
!internal/**
|
||||||
|
!webterm/
|
||||||
|
!webterm/**
|
||||||
|
!go.mod
|
||||||
|
!go.sum
|
||||||
!Dockerfile
|
!Dockerfile
|
||||||
!.dockerignore
|
!.dockerignore
|
||||||
!VERSION
|
!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.
|
1. **Before changes**: Run `make check` to establish baseline.
|
||||||
2. **After changes**: Run `make check` and `make race`.
|
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.
|
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.
|
- Put `golangci-lint` and `gosec` wiring behind Make targets when introduced.
|
||||||
|
|
||||||
## Conventions to implement
|
## 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.
|
- Avoid bespoke CI steps when a Make target can encode the same behavior.
|
||||||
|
|||||||
+1
-2
@@ -10,14 +10,13 @@
|
|||||||
webterm.log
|
webterm.log
|
||||||
|
|
||||||
# Coverage/build artifacts
|
# Coverage/build artifacts
|
||||||
go/coverage.out
|
|
||||||
coverage.out
|
coverage.out
|
||||||
dist/
|
dist/
|
||||||
build/
|
build/
|
||||||
target/
|
target/
|
||||||
|
|
||||||
# Go
|
# Go
|
||||||
go/bin/
|
bin/
|
||||||
|
|
||||||
# Frontend
|
# Frontend
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|||||||
+6
-4
@@ -4,11 +4,13 @@
|
|||||||
FROM golang:1.26-alpine AS builder
|
FROM golang:1.26-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY go/go.mod go/go.sum ./go/
|
COPY go.mod go.sum ./
|
||||||
RUN cd go && go mod download
|
RUN go mod download
|
||||||
COPY go ./go
|
COPY cmd ./cmd
|
||||||
|
COPY internal ./internal
|
||||||
|
COPY webterm ./webterm
|
||||||
COPY VERSION ./VERSION
|
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
|
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
|
.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
|
GO_DIR = .
|
||||||
STATIC_JS_DIR = go/webterm/static/js
|
STATIC_JS_DIR = webterm/static/js
|
||||||
TERMINAL_TS = $(STATIC_JS_DIR)/terminal.ts
|
TERMINAL_TS = $(STATIC_JS_DIR)/terminal.ts
|
||||||
TERMINAL_JS = $(STATIC_JS_DIR)/terminal.js
|
TERMINAL_JS = $(STATIC_JS_DIR)/terminal.js
|
||||||
GHOSTTY_WASM = $(STATIC_JS_DIR)/ghostty-vt.wasm
|
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
|
```bash
|
||||||
git clone https://github.com/rcarmo/webterm.git
|
git clone https://github.com/rcarmo/webterm.git
|
||||||
cd webterm/go
|
cd webterm
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
go build -o ./bin/webterm ./cmd/webterm
|
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
|
## Quick start
|
||||||
|
|
||||||
Run a default shell session:
|
Run a default shell session:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd go
|
|
||||||
go run ./cmd/webterm
|
go run ./cmd/webterm
|
||||||
```
|
```
|
||||||
|
|
||||||
Run a specific command:
|
Run a specific command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd go
|
|
||||||
go run ./cmd/webterm -- htop
|
go run ./cmd/webterm -- htop
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -64,14 +62,12 @@ Then open <http://localhost:8080>.
|
|||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd go
|
go run ./cmd/webterm -- --landing-manifest ./landing.yaml
|
||||||
go run ./cmd/webterm -- --landing-manifest ../landing.yaml
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker watch
|
### Docker watch
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd go
|
|
||||||
go run ./cmd/webterm -- --docker-watch
|
go run ./cmd/webterm -- --docker-watch
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -83,8 +79,7 @@ Containers with these labels become tiles:
|
|||||||
### Compose manifest
|
### Compose manifest
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd go
|
go run ./cmd/webterm -- --compose-manifest ./docker-compose.yaml
|
||||||
go run ./cmd/webterm -- --compose-manifest ../docker-compose.yaml
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Environment variables
|
## Environment variables
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Browser (terminal.js + ghostty-vt.wasm)
|
|||||||
│
|
│
|
||||||
│ WS / HTTP / SSE
|
│ WS / HTTP / SSE
|
||||||
▼
|
▼
|
||||||
go/webterm/server.go (LocalServer)
|
webterm/server.go (LocalServer)
|
||||||
│
|
│
|
||||||
├── session_manager.go (route/app/session registry)
|
├── session_manager.go (route/app/session registry)
|
||||||
├── terminal_session.go (PTY-backed local sessions)
|
├── terminal_session.go (PTY-backed local sessions)
|
||||||
@@ -21,9 +21,9 @@ go/webterm/server.go (LocalServer)
|
|||||||
|
|
||||||
## Packages
|
## Packages
|
||||||
|
|
||||||
- `go/cmd/webterm`: CLI entrypoint
|
- `cmd/webterm`: CLI entrypoint
|
||||||
- `go/webterm`: server/runtime/domain logic
|
- `webterm`: server/runtime/domain logic
|
||||||
- `go/internal/terminalstate`: Go terminal emulator wrapper (`go-te`) used for screenshots
|
- `internal/terminalstate`: Go terminal emulator wrapper (`go-te`) used for screenshots
|
||||||
|
|
||||||
## Runtime data flow
|
## Runtime data flow
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ go/webterm/server.go (LocalServer)
|
|||||||
|
|
||||||
## Static assets
|
## Static assets
|
||||||
|
|
||||||
Assets live in `go/webterm/static`:
|
Assets live in `webterm/static`:
|
||||||
|
|
||||||
- `js/terminal.ts` source
|
- `js/terminal.ts` source
|
||||||
- `js/terminal.js` bundled client
|
- `js/terminal.js` bundled client
|
||||||
@@ -47,7 +47,7 @@ Assets live in `go/webterm/static`:
|
|||||||
The server resolves static files from:
|
The server resolves static files from:
|
||||||
|
|
||||||
1. `WEBTERM_STATIC_PATH` (if set)
|
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
|
3. embedded assets bundled into the Go binary
|
||||||
|
|
||||||
## Docker integration
|
## Docker integration
|
||||||
|
|||||||
+4
-4
@@ -9,10 +9,10 @@
|
|||||||
"typescript": "^5.7.0"
|
"typescript": "^5.7.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"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": "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 go/webterm/static/js/terminal.ts --outfile=go/webterm/static/js/terminal.js --minify --target=browser",
|
"build:fast": "bun build webterm/static/js/terminal.ts --outfile=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",
|
"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",
|
"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,
|
"isolatedModules": true,
|
||||||
"lib": ["ES2022", "DOM", "DOM.Iterable"]
|
"lib": ["ES2022", "DOM", "DOM.Iterable"]
|
||||||
},
|
},
|
||||||
"include": ["go/webterm/static/js/**/*.ts"],
|
"include": ["webterm/static/js/**/*.ts"],
|
||||||
"exclude": ["node_modules"]
|
"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