Skip to content

Commit a33cf89

Browse files
authored
Feat/routing refactor (#8)
* feat: MVP 1. (#7) * feat: MVP 1. * code review fixes * code review fixes pt.2 * regenerated schemas * code reviews pt. 2. * repo add fix * CORS and gitignore fix * code review fixes pt.1. * user settings refactor * cr fixes * token list fix * page layout optimalizations * progress * progress * progress * repository layer fixes * progress * code review fixes * code review fixes * added createElevatedContext * FS updates, system identity context * fs update * cr fixes * visual hierarchy update * persist log entries, bulk removes * progress on entity refactors * service details to data grid * review fixes, bulk remove fixes * navigation fixes * allow to clear logs * code review fixes * code review fixes * service creation and GH pull improvements * Form refactors * missing sync fixes * install fix * Service status history updates * log fix * process updates * detached process kill * export button * form handling improvements * updates * selection fix * service details page refactor * services refactor * prerequisites refactor * progress on prerequisites, cr fixes * component consolidation and cleanup * service form fixes * prerequisites and build fixes * progress on env.variables * prerequisite check in-memory * MCP server improvements * required files setup * github repo in memory search fix * fs update and fixes * theme support * furystack upgrade * eslint integration * prettier fix * test fix * gitignore fix * filled changelogs * removed e2e tests from main build pipeline * progress on fs upgrades * routes refactor * added stackCraftNavigate * type safe routing * config test fix * creation and smoke fix * shades upgrades, dog fooding progress * fixed dog fooding test * routing refactors * e2e fix * feat: UI / UX refactor * cr fixes * breadcrumbs to header * progress * display branch fix * SqLite to Postgres * different db port * cleaned up legacy websocket announcements, branch name sync * "commits behind" implementation * security hardening * security for file overrides * cr fixes * husky + lint staged fixes * versioning, changelogs * ts upgrade * win32 fixes * prettier fix
1 parent 99b4167 commit a33cf89

File tree

114 files changed

+6700
-1924
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+6700
-1924
lines changed

.cursor/rules/CODE_STYLE.mdc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ yarn lint
3838

3939
### Automated Formatting
4040

41-
Code is automatically formatted on commit via Husky:
41+
Code is automatically formatted on commit via Husky and lint-staged:
4242

4343
```json
4444
{
45-
"lint-staged": {
46-
"*.{ts,tsx}": ["eslint --fix", "prettier --write", "git add"]
47-
}
45+
"lint-staged": {
46+
"*.{ts,tsx}": ["eslint --cache --fix", "prettier --write"]
47+
}
4848
}
4949
```
5050

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DATABASE_URL=postgres://stackcraft:stackcraft@localhost:5433/stackcraft

.github/workflows/ui-tests.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ jobs:
1010
matrix:
1111
node-version: [22.x, 24.x]
1212

13+
services:
14+
postgres:
15+
image: postgres:17-alpine
16+
env:
17+
POSTGRES_USER: stackcraft
18+
POSTGRES_PASSWORD: stackcraft
19+
POSTGRES_DB: stackcraft
20+
ports:
21+
- 5433:5432
22+
options: >-
23+
--health-cmd pg_isready
24+
--health-interval 10s
25+
--health-timeout 5s
26+
--health-retries 5
27+
28+
env:
29+
DATABASE_URL: postgres://stackcraft:stackcraft@localhost:5433/stackcraft
30+
1331
steps:
1432
- uses: actions/checkout@v4
1533
- name: Use Node.js ${{ matrix.node-version }}

.husky/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!-- version-type: minor -->
2+
# common
3+
4+
## ✨ Features
5+
6+
### Domain Model Layer
7+
8+
Added a full domain model layer for stack and service management, replacing the previous minimal `User`-only model surface:
9+
10+
- `StackDefinition` / `StackConfig` — stack metadata, main directory, and environment variable configuration
11+
- `ServiceDefinition` / `ServiceConfig` — service commands, working directory, file definitions, and prerequisite associations
12+
- `ServiceStatus` — typed status per pipeline stage (`CloneStatus`, `InstallStatus`, `BuildStatus`, `RunStatus`)
13+
- `ServiceGitStatus` — branch name, commits behind remote, and auto-fetch flag
14+
- `ServiceStateHistory` / `ServiceStateEvent` — audit trail of state transitions with trigger source tracking
15+
- `ServiceLogEntry` — structured log entries per service process
16+
- `GitHubRepository` — linked Git repository with URL and branch configuration
17+
- `Prerequisite` / `PrerequisiteCheckResult` — typed prerequisites (Node.js, Yarn, .NET, NuGet, env var, custom script) with check status
18+
- `ApiToken` / `PublicApiToken` — bearer token management for REST and MCP authentication
19+
- `EnvironmentVariableValue` — environment variables with `isSecret` flag for encryption support
20+
- `StackView` / `ServiceView` — entity views for filtered data projection
21+
22+
### Typed REST API Definitions
23+
24+
Replaced the single monolithic `StackCraftApi` with individual typed API interfaces, each with its own generated JSON schema:
25+
26+
- `IdentityApi` — authentication, current user, login/logout, password reset
27+
- `InstallApi` — first-run service status and installation trigger
28+
- `StacksApi` — stack CRUD, import/export, and setup orchestration
29+
- `ServicesApi` — service CRUD, lifecycle actions (start/stop/restart/install/build/pull/setup/update), logs, history, branches, checkout, and file application
30+
- `GitHubRepositoriesApi` — repository CRUD with URL validation
31+
- `PrerequisitesApi` — prerequisite CRUD with on-demand check execution
32+
- `TokensApi` — API token creation, listing, and deletion
33+
- `SystemApi` — environment variable availability checks
34+
35+
### Service Path Utilities
36+
37+
- Added `getRepoNameFromUrl()` to extract repository names from Git URLs
38+
- Added `getServiceCwd()` to resolve a service's working directory from stack config, service definition, and repository URL
39+
40+
## ♻️ Refactoring
41+
42+
- Removed `StackCraftApi` and `BoilerplateApi` single-API types in favor of per-domain API modules
43+
- Removed test-only endpoints (`TestQueryEndpoint`, `TestUrlParamsEndpoint`, `TestPostBodyEndpoint`)
44+
- Schema generation now emits one JSON file per API module instead of a single `stack-craft-api.json`
45+
46+
## 🧪 Tests
47+
48+
- Added unit tests for `getRepoNameFromUrl()` and `getServiceCwd()` path utilities
49+
50+
## ⬆️ Dependencies
51+
52+
- Added `@furystack/core` for shared entity types (`WithOptionalId`)
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<!-- version-type: minor -->
2+
# frontend
3+
4+
## ✨ Features
5+
6+
### Nested Routing System
7+
8+
Implemented a full nested routing system with typed navigation helpers (`StackCraftNestedRouteLink`, `stackCraftNavigate`) and URL-driven breadcrumb navigation. All routes are scoped under stacks for contextual navigation.
9+
10+
### Dashboard
11+
12+
Stack overview page displaying all stacks with entity-sync–powered live updates. Selecting a stack shows its services, status, and quick actions.
13+
14+
### Service Management
15+
16+
- **Services list** with pipeline status indicators (clone → install → build → run) and bulk actions
17+
- **Service detail page** with pipeline stepper, log viewer, branch selector, environment overrides, prerequisite status, and lifecycle controls (start/stop/restart/install/build/pull/setup/update)
18+
- **Service logs** with ANSI color rendering, per-process filtering, and log clearing
19+
- **Create service wizard** with two-step flow: define service then optional automated setup
20+
21+
### Stack Management
22+
23+
- **Create/edit stack** with name, display name, main directory, and markdown description
24+
- **Stack import/export** for portability between environments with environment variable remapping
25+
- **Stack setup** progress page showing clone/install/build readiness per service
26+
27+
### Repository Management
28+
29+
- **Repository list/create/edit** pages for managing linked GitHub repositories with URL validation
30+
31+
### Prerequisites Management
32+
33+
- **Prerequisites list** with check status display and typed creation form supporting Node.js, Yarn, .NET SDK, NuGet feeds, environment variables, and custom scripts
34+
35+
### User Settings
36+
37+
- Theme selection with persistent storage
38+
- Password change form
39+
- API token management (create, list, delete)
40+
41+
### Installer Wizard
42+
43+
Full-screen first-run wizard with prerequisite checks, admin user creation, and success confirmation — shown automatically when the backend reports an uninstalled state.
44+
45+
### Layout and Navigation
46+
47+
- **Sidebar** with collapsible per-stack navigation sections (services, repositories, prerequisites, import/export)
48+
- **Header** with breadcrumbs, theme toggle, and logout
49+
- **Entity sync** via WebSocket (`/api/ws`) for real-time collection updates across all views
50+
51+
### UI Components
52+
53+
- `ServicePipelineStepper` / `MiniPipelineDots` — visualize clone/install/build/run stages with color-coded status
54+
- `BranchSelector` — Git branch switching with remote branch listing
55+
- `EnvironmentVariablesManager` — stack-level env var editing with secret masking and availability checks
56+
- `ServiceEnvOverrides` — per-service environment variable override editing
57+
- `LogViewer` / `LogLine` — streaming log display with ANSI escape sequence rendering
58+
- `PrerequisiteTable` / `PrerequisiteList` — prerequisite display with check status chips
59+
- `ServiceTable` / `RepositoryTable` — data tables with status indicators and actions
60+
- `StatusChips` — colored status badges for pipeline stages and prerequisite types
61+
62+
### Utilities
63+
64+
- `parseAnsi()` — parses ANSI escape sequences into styled segments for terminal log rendering
65+
- `getServicePipelineStages()` / `getServicePrimaryAction()` — derive pipeline visualization data and contextual actions from service state
66+
- `applyClientFindOptions()` — client-side `FindOptions` filtering, ordering, and pagination
67+
68+
### Per-API REST Clients
69+
70+
Replaced monolithic `StackCraftApiClient` with individual typed clients: `IdentityApiClient`, `StacksApiClient`, `ServicesApiClient`, `GitHubReposApiClient`, `PrerequisitesApiClient`, `TokensApiClient`, `SystemApiClient`, `InstallApiClient`.
71+
72+
## ♻️ Refactoring
73+
74+
- Restructured app shell into `Header` + `Sidebar` + `Body` layout with auth/install gating
75+
- Replaced `StackCraftApiClient` and `BoilerplateApiClient` with per-domain API clients
76+
- Session service now uses `IdentityApiClient` with full `User` type and `[Symbol.dispose]` cleanup
77+
78+
## 🧪 Tests
79+
80+
- Added unit tests for ANSI escape sequence parser (`parse-ansi.spec.ts`)
81+
- Added unit tests for service pipeline stage derivation and action mapping (`service-pipeline.spec.ts`)
82+
83+
## 📦 Build
84+
85+
- Migrated to Vite 8 with synchronous `defineConfig`
86+
87+
## ⬆️ Dependencies
88+
89+
- Added `@furystack/cache`, `@furystack/entity-sync`, `@furystack/entity-sync-client` for live data sync
90+
- Bumped Vite to v8, Vitest to v4
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<!-- version-type: minor -->
2+
# service
3+
4+
## ✨ Features
5+
6+
### Process Manager
7+
8+
Added `ProcessManager` to orchestrate service lifecycle (clone, install, build, run, pull, setup, update) with child process management, `ServiceStateHistory` audit trail, and batched log forwarding to `LogStorageService`. Automatically reconciles stale states on startup.
9+
10+
### Git Integration
11+
12+
- `GitService` — wrapper for git operations: clone, fetch, pull, list branches, current branch, commits behind remote, and checkout
13+
- `GitWatcher` — periodic remote fetch (default 5 min) per service with auto-fetch toggle; updates `ServiceGitStatus` and service status when remotes change
14+
- `GitHeadWatcher` — monitors `.git/HEAD` for branch switches and updates branch/behind counts in `ServiceGitStatus`
15+
16+
### MCP Server
17+
18+
Exposed a Model Context Protocol server (Streamable HTTP on port 9091) with bearer token authentication and tools for:
19+
20+
- `stack-tools` — list, get, create, update, delete, export, import, and setup stacks
21+
- `service-tools` — list, create, edit, delete services; start/stop/restart/install/build/pull/setup/update lifecycle; get logs and state history
22+
- `prerequisite-tools` — list, check, create, update, and delete prerequisites
23+
- `repository-tools` — list, get, create, update, delete, and validate repositories
24+
- `env-variable-tools` — set/remove stack env variables and service env overrides
25+
- `service-file-tools` — manage shared and local encrypted service files (list/read/add/update/remove/apply)
26+
- `system-tools` — check environment variable availability
27+
28+
### Security
29+
30+
- `CryptoService` with AES-256-GCM encryption for sensitive environment variables and service files, keyed from `STACK_CRAFT_ENCRYPTION_KEY` or auto-generated `~/.stack-craft/encryption.key`
31+
- `SecretDetector` with heuristic scanning for secrets in commands and file content
32+
- Bearer API token authentication (`BearerTokenAuth`) with SHA-256 hashed storage; plaintext returned only at creation time
33+
- Sensitive data masking on REST responses for environment variables and service files
34+
- Startup migration (`encryptExistingSecrets`) to encrypt pre-existing plaintext secrets in the database
35+
36+
### Prerequisite Evaluation
37+
38+
Prerequisite check system supporting Node.js version, Yarn version, .NET SDK version, NuGet feed availability, environment variable presence, and custom script execution. Evaluates all prerequisites in the background after startup.
39+
40+
### Stack Import/Export
41+
42+
- `exportStackAction` — serializes a stack with its services, repositories, and prerequisites to JSON
43+
- `importStackAction` — imports a stack from JSON with environment variable remapping, deduplication, and conflict resolution
44+
45+
### WebSocket Entity Sync
46+
47+
Real-time entity synchronization via WebSocket at `/api/ws` using `SyncSubscribeAction` / `SyncUnsubscribeAction` for live frontend updates.
48+
49+
### Additional REST Endpoints
50+
51+
- Password reset flow via `/api/identity/password-reset`
52+
- `LogStorageService` for per-service log persistence, query, and pruning
53+
- Repository URL validation via `git ls-remote`
54+
- Environment variable availability check at `/api/system/check-env-availability`
55+
- Service file application to disk via `/api/services/:id/apply-files`
56+
57+
## ♻️ Refactoring
58+
59+
### PostgreSQL Migration
60+
61+
Migrated from `@furystack/filesystem-store` (file-backed JSON) to PostgreSQL via `@furystack/sequelize-store` with Sequelize models and JSONB columns for flexible fields. In-memory stores retained for transient data (`ServiceGitStatus`, `PrerequisiteCheckResult`, sessions, log entries).
62+
63+
### REST API Reorganization
64+
65+
Restructured the REST API into domain-specific modules: identity, install, stacks, services, github-repositories, prerequisites, tokens, and system — each with dedicated setup, actions, and authorization.
66+
67+
### Seed Removal
68+
69+
Replaced the `seed.ts` script with an installer flow triggered from the frontend on first run.
70+
71+
## 🧪 Tests
72+
73+
- `ProcessManager` — lifecycle orchestration, state transitions, log batching, stale state reconciliation
74+
- `GitService` — clone, fetch, pull, branches, current branch, commits behind, checkout
75+
- `CryptoService` — encrypt/decrypt round-trip, key generation, tamper detection
76+
- `env-encryption-helpers` — encrypt/mask/decrypt for stack and service payloads, `UNCHANGED_SENTINEL` handling
77+
- `secret-detector` — heuristic pattern matching for secrets in commands and file content
78+
- `apply-service-files` — merge and write service file definitions to disk
79+
- `check-prerequisite-action` — all prerequisite types and edge cases
80+
- `service-branches-action` / `service-checkout-action` — branch listing and checkout flows
81+
- `service-lifecycle-action` — lifecycle action dispatching
82+
- `import-export-actions` — stack export/import with remapping and deduplication
83+
- `setup-tokens-rest-api` — token CRUD with hashed storage
84+
- `bearer-token-auth` — token resolution and user loading
85+
- `service-installer` — installation flow
86+
- `config` / `get-cors-options` / `get-port` — configuration resolution
87+
88+
## ⬆️ Dependencies
89+
90+
- Added `sequelize`, `pg`, `pg-hstore`, `@furystack/sequelize-store` for PostgreSQL support
91+
- Removed `@furystack/filesystem-store`
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!-- version-type: minor -->
2+
# stack-craft
3+
4+
## ✨ Features
5+
6+
- Added PostgreSQL via `docker-compose.yml` for local development (port 5433, `postgres:17-alpine`)
7+
- Added `.env.example` with `DATABASE_URL` configuration for quick setup
8+
- Added separate E2E test suites: installer flow (`test:e2e:install`), smoke tests (`smoke.spec.ts`), and dogfooding tests (`dogfooding.spec.ts`) covering real repository clone/install/build/run
9+
10+
## ♻️ Refactoring
11+
12+
- Renamed `test:unit` script to `test` for simplicity
13+
- Split E2E tests into focused scenarios (installer, smoke, dogfooding) replacing the single `page.spec.ts`
14+
15+
## 👷 CI
16+
17+
- Added PostgreSQL service container to the `ui-tests` workflow with health checks
18+
- Separated installer E2E (`test:e2e:install`) from app E2E in the CI pipeline
19+
- Moved heavy Playwright tests from `build-test` to `ui-tests` workflow to keep the default build fast
20+
21+
## 📚 Documentation
22+
23+
- Updated README with PostgreSQL setup instructions, Docker run example with `DATABASE_URL`, and revised testing commands
24+
25+
## 📦 Build
26+
27+
- Upgraded to Yarn 4.13.0
28+
- Upgraded ESLint to v10 with `@furystack/eslint-plugin` (replacing `eslint-plugin-playwright`)
29+
- Upgraded Vite to v8, Vitest to v4, `@playwright/test` to v1.58
30+
31+
## ⬆️ Dependencies
32+
33+
- Added `jsdom` for Vitest browser environment
34+
- Bumped `typescript-eslint`, `lint-staged`, `rimraf`, `@types/node`

.yarn/versions/6a9239ac.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
releases:
2+
common: minor
3+
frontend: minor
4+
service: minor
5+
stack-craft: minor

0 commit comments

Comments
 (0)