refactor: restructure bastion as pnpm monorepo (@lab/shared, @lab/bastion, @lab/cli)
- Split into 3 workspace packages: shared (types/constants), bastion (server), cli - CLI binary renamed from "bastion" to "lab" - Cross-package imports via @lab/shared and @lab/bastion workspace references - Extracted BastionConfig, BastionState, HardwareInfo types into @lab/shared - Added APP_NAME/APP_VERSION constants - tsconfig.base.json with project references for build ordering - Root workspace scripts: build, test, typecheck, clean Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
20
bastion/src/shared/package.json
Normal file
20
bastion/src/shared/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@lab/shared",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --build",
|
||||
"clean": "rimraf dist",
|
||||
"test": "vitest",
|
||||
"test:run": "vitest run"
|
||||
}
|
||||
}
|
||||
4
bastion/src/shared/src/constants/index.ts
Normal file
4
bastion/src/shared/src/constants/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// Application-wide constants.
|
||||
|
||||
export const APP_NAME = "lab";
|
||||
export const APP_VERSION = "0.1.0";
|
||||
9
bastion/src/shared/src/index.ts
Normal file
9
bastion/src/shared/src/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export type {
|
||||
HardwareInfo,
|
||||
InstallConfig,
|
||||
InstalledInfo,
|
||||
BastionState,
|
||||
BastionConfig,
|
||||
} from "./types/index.js";
|
||||
|
||||
export { APP_NAME, APP_VERSION } from "./constants/index.js";
|
||||
28
bastion/src/shared/src/types/config.ts
Normal file
28
bastion/src/shared/src/types/config.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// Configuration types for the bastion server.
|
||||
|
||||
export interface BastionConfig {
|
||||
fedoraVersion: string;
|
||||
arch: string;
|
||||
httpPort: number;
|
||||
timezone: string;
|
||||
locale: string;
|
||||
bastionDir: string;
|
||||
domain: string;
|
||||
dhcpMode: "proxy" | "full";
|
||||
dhcpRangeStart: string;
|
||||
dhcpRangeEnd: string;
|
||||
// Flags
|
||||
skipDnsmasq?: boolean | undefined;
|
||||
skipArtifacts?: boolean | undefined;
|
||||
// Derived at runtime
|
||||
iface: string;
|
||||
serverIp: string;
|
||||
network: string;
|
||||
gateway: string;
|
||||
sshKeys: string[];
|
||||
adminUser: string;
|
||||
fedoraMirror: string;
|
||||
tftpDir: string;
|
||||
httpDir: string;
|
||||
stateFile: string;
|
||||
}
|
||||
8
bastion/src/shared/src/types/index.ts
Normal file
8
bastion/src/shared/src/types/index.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export type {
|
||||
HardwareInfo,
|
||||
InstallConfig,
|
||||
InstalledInfo,
|
||||
BastionState,
|
||||
} from "./state.js";
|
||||
|
||||
export type { BastionConfig } from "./config.js";
|
||||
40
bastion/src/shared/src/types/state.ts
Normal file
40
bastion/src/shared/src/types/state.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
// State types for discovered machines, install queue, and installed machines.
|
||||
|
||||
export interface HardwareInfo {
|
||||
mac: string;
|
||||
product: string;
|
||||
board: string;
|
||||
serial: string;
|
||||
manufacturer: string;
|
||||
cpu_model: string;
|
||||
cpu_cores: number;
|
||||
memory_gb: number;
|
||||
arch: string;
|
||||
disks: Array<{ name: string; size_gb: number; model: string }>;
|
||||
nics: Array<{ name: string; mac: string; state: string }>;
|
||||
first_seen: string;
|
||||
last_seen: string;
|
||||
}
|
||||
|
||||
export interface InstallConfig {
|
||||
hostname: string;
|
||||
disk: string;
|
||||
role: "worker" | "infra";
|
||||
queued_at: string;
|
||||
progress?: string;
|
||||
progress_at?: string;
|
||||
progress_detail?: string;
|
||||
}
|
||||
|
||||
export interface InstalledInfo {
|
||||
hostname: string;
|
||||
role: string;
|
||||
ip: string;
|
||||
installed_at: string;
|
||||
}
|
||||
|
||||
export interface BastionState {
|
||||
discovered: Record<string, HardwareInfo>;
|
||||
install_queue: Record<string, InstallConfig>;
|
||||
installed: Record<string, InstalledInfo>;
|
||||
}
|
||||
8
bastion/src/shared/tsconfig.json
Normal file
8
bastion/src/shared/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
8
bastion/src/shared/vitest.config.ts
Normal file
8
bastion/src/shared/vitest.config.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { defineProject } from 'vitest/config';
|
||||
|
||||
export default defineProject({
|
||||
test: {
|
||||
name: 'shared',
|
||||
include: ['tests/**/*.test.ts'],
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user