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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
lint:
name: Lint & Format
name: Lint
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
run: bun run build

test:
name: Unit Test
name: Test
runs-on: ubuntu-latest

steps:
Expand Down
27 changes: 3 additions & 24 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dev": "tsc --watch",
"start": "bun src/server.ts",
"typecheck": "tsc --noEmit",
"test": "prettier --check . && xo && ava",
"test": "bun test",
"lint": "biome check --write .",
"lint:check": "biome check .",
"format": "biome format --write .",
Expand Down Expand Up @@ -42,31 +42,10 @@
"devDependencies": {
"@sindresorhus/tsconfig": "^3.0.1",
"@types/react": "^19.1.11",
"@vdemedes/prettier-config": "^2.0.1",
"ava": "^5.2.0",
"bun-types": "^1.3.1",
"chalk": "^5.6.2",
"chokidar": "^3.5.3",
"eslint-config-xo-react": "^0.27.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"ink-testing-library": "^3.0.0",
"prettier": "^2.8.7",
"typescript": "^5.9.3",
"xo": "^0.53.1"
},
"ava": {
"extensions": {
"ts": "module",
"tsx": "module"
}
},
"xo": {
"extends": "xo-react",
"prettier": true,
"rules": {
"react/prop-types": "off"
}
},
"prettier": "@vdemedes/prettier-config"
"typescript": "^5.9.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { WorkspaceType } from "../../../types/workspace";
import { LowdbAdapter } from "../../storage/lowdb-adapter";
import { ChangeOrchestrator } from "../change-orchestrator";
import { EnvironmentOrchestrator } from "../environment-orchestrator";
import { WorkspaceOrchestrator } from "../workspace-orchestrator";
import { WorkspaceType } from "../../types/workspace";
import { LowdbAdapter } from "../storage/lowdb-adapter";
import { ChangeOrchestrator } from "./change-orchestrator";
import { EnvironmentOrchestrator } from "./environment-orchestrator";
import { WorkspaceOrchestrator } from "./workspace-orchestrator";

describe("ChangeOrchestrator", () => {
let tempDir: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { ProcessType } from "../../../types/process";
import { WorkspaceType } from "../../../types/workspace";
import { LowdbAdapter } from "../../storage/lowdb-adapter";
import { EnvironmentOrchestrator } from "../environment-orchestrator";
import { ProcessOrchestrator } from "../process-orchestrator";
import { WorkspaceOrchestrator } from "../workspace-orchestrator";
import { ProcessType } from "../../types/process";
import { WorkspaceType } from "../../types/workspace";
import { LowdbAdapter } from "../storage/lowdb-adapter";
import { EnvironmentOrchestrator } from "./environment-orchestrator";
import { ProcessOrchestrator } from "./process-orchestrator";
import { WorkspaceOrchestrator } from "./workspace-orchestrator";

describe("EnvironmentOrchestrator", () => {
let tempDir: string;
Expand All @@ -20,6 +20,8 @@ describe("EnvironmentOrchestrator", () => {
tempDir = await mkdtemp(join(tmpdir(), "env-test-"));
const dbPath = join(tempDir, "test-db.json");
adapter = new LowdbAdapter(dbPath);
// Ensure clean state for each test
await adapter.clear();
orchestrator = new EnvironmentOrchestrator(adapter);
workspaceOrchestrator = new WorkspaceOrchestrator(adapter);
processOrchestrator = new ProcessOrchestrator(adapter);
Expand Down Expand Up @@ -61,20 +63,24 @@ describe("EnvironmentOrchestrator", () => {
});

describe("list", () => {
test("returns empty array when no environments", async () => {
test("returns default environment when no custom environments created", async () => {
const environments = await orchestrator.list();
expect(environments).toHaveLength(0);
// createEmptyDatabase() includes a default environment
expect(environments).toHaveLength(1);
expect(environments[0]?.id).toBe("default");
});

test("returns all environments", async () => {
test("returns all environments including default", async () => {
const env1 = await orchestrator.create();
const env2 = await orchestrator.create();

const environments = await orchestrator.list();

expect(environments).toHaveLength(2);
// 2 created + 1 default
expect(environments).toHaveLength(3);
expect(environments.map((e) => e.id)).toContain(env1.id);
expect(environments.map((e) => e.id)).toContain(env2.id);
expect(environments.map((e) => e.id)).toContain("default");
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Agent } from "../../../types/process";
import { AgentType, ProcessStatus, ProcessType } from "../../../types/process";
import { WorkspaceType } from "../../../types/workspace";
import { LowdbAdapter } from "../../storage/lowdb-adapter";
import { EnvironmentOrchestrator } from "../environment-orchestrator";
import { ProcessOrchestrator } from "../process-orchestrator";
import { WorkspaceOrchestrator } from "../workspace-orchestrator";
import type { Agent } from "../../types/process";
import { AgentType, ProcessStatus, ProcessType } from "../../types/process";
import { WorkspaceType } from "../../types/workspace";
import { LowdbAdapter } from "../storage/lowdb-adapter";
import { EnvironmentOrchestrator } from "./environment-orchestrator";
import { ProcessOrchestrator } from "./process-orchestrator";
import { WorkspaceOrchestrator } from "./workspace-orchestrator";

describe("ProcessOrchestrator", () => {
let tempDir: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { LocalWorkspace } from "../../../types/workspace";
import { WorkspaceType } from "../../../types/workspace";
import { LowdbAdapter } from "../../storage/lowdb-adapter";
import { ChangeOrchestrator } from "../change-orchestrator";
import { EnvironmentOrchestrator } from "../environment-orchestrator";
import { WorkspaceOrchestrator } from "../workspace-orchestrator";
import type { LocalWorkspace } from "../../types/workspace";
import { WorkspaceType } from "../../types/workspace";
import { LowdbAdapter } from "../storage/lowdb-adapter";
import { ChangeOrchestrator } from "./change-orchestrator";
import { EnvironmentOrchestrator } from "./environment-orchestrator";
import { WorkspaceOrchestrator } from "./workspace-orchestrator";

describe("WorkspaceOrchestrator", () => {
let tempDir: string;
Expand All @@ -20,6 +20,8 @@ describe("WorkspaceOrchestrator", () => {
tempDir = await mkdtemp(join(tmpdir(), "workspace-test-"));
const dbPath = join(tempDir, "test-db.json");
adapter = new LowdbAdapter(dbPath);
// Ensure clean state for each test
await adapter.clear();
orchestrator = new WorkspaceOrchestrator(adapter);
environmentOrchestrator = new EnvironmentOrchestrator(adapter);
changeOrchestrator = new ChangeOrchestrator(adapter);
Expand All @@ -42,9 +44,11 @@ describe("WorkspaceOrchestrator", () => {
expect((workspace as LocalWorkspace).path).toBe("/tmp/test");
});

test("creates cloud workspace without path", async () => {
test("creates cloud workspace with branch", async () => {
const env = await environmentOrchestrator.create();
const workspace = await orchestrator.create(env.id, WorkspaceType.CLOUD);
const workspace = await orchestrator.create(env.id, WorkspaceType.CLOUD, {
branch: "main",
});

expect(workspace.id).toBeDefined();
expect(workspace.type).toBe(WorkspaceType.CLOUD);
Expand All @@ -60,7 +64,12 @@ describe("WorkspaceOrchestrator", () => {
});

const retrieved = await orchestrator.get(workspace.id);
expect(retrieved).toEqual(workspace);
// Compare relevant fields (lastUsedAt is set by use() call in create())
expect(retrieved.id).toBe(workspace.id);
expect(retrieved.type).toBe(workspace.type);
expect(retrieved.environmentId).toBe(workspace.environmentId);
expect((retrieved as LocalWorkspace).path).toBe("/tmp/test");
expect(retrieved.lastUsedAt).toBeInstanceOf(Date);
});

test("throws error for non-existent workspace", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { existsSync } from "node:fs";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Change, Environment, Process } from "../../../types/index";
import { ProcessStatus, ProcessType } from "../../../types/process";
import { LowdbAdapter } from "../lowdb-adapter";
import type { Change, Environment, Process } from "../../types/index";
import { ProcessStatus, ProcessType } from "../../types/process";
import { LowdbAdapter } from "./lowdb-adapter";

describe("LowdbAdapter", () => {
let tempDir: string;
Expand All @@ -17,6 +17,8 @@ describe("LowdbAdapter", () => {
tempDir = await mkdtemp(join(tmpdir(), "lowdb-test-"));
dbPath = join(tempDir, "test-db.json");
adapter = new LowdbAdapter(dbPath);
// Ensure clean state for each test
await adapter.clear();
});

afterEach(async () => {
Expand All @@ -27,9 +29,11 @@ describe("LowdbAdapter", () => {
});

describe("initialization", () => {
test("initializes with empty collections", async () => {
test("initializes with default environment", async () => {
const data = await adapter.read();
expect(Object.keys(data.environments)).toHaveLength(0);
// createEmptyDatabase() includes a default environment
expect(Object.keys(data.environments)).toHaveLength(1);
expect(data.environments["default"]).toBeDefined();
expect(Object.keys(data.workspaces)).toHaveLength(0);
expect(Object.keys(data.processes)).toHaveLength(0);
expect(Object.keys(data.changes)).toHaveLength(0);
Expand Down Expand Up @@ -75,14 +79,16 @@ describe("LowdbAdapter", () => {
expect(await adapter.has("environments", "env-2")).toBe(false);
});

test("clear all data", async () => {
test("clear resets to default database", async () => {
const environment: Environment = { id: "env-1" };
await adapter.set("environments", "env-1", environment);

await adapter.clear();
const data = await adapter.read();

expect(Object.keys(data.environments)).toHaveLength(0);
// clear() resets to createEmptyDatabase() which has default env
expect(Object.keys(data.environments)).toHaveLength(1);
expect(data.environments["default"]).toBeDefined();
});
});

Expand All @@ -95,9 +101,11 @@ describe("LowdbAdapter", () => {
await adapter.set("environments", "env-2", env2);

const collection = await adapter.getCollection("environments");
expect(Object.keys(collection)).toHaveLength(2);
// 2 added + 1 default environment
expect(Object.keys(collection)).toHaveLength(3);
expect(collection["env-1"]).toEqual(env1);
expect(collection["env-2"]).toEqual(env2);
expect(collection["default"]).toBeDefined();
});

test("updateCollection replaces entire collection", async () => {
Expand Down Expand Up @@ -183,7 +191,8 @@ describe("LowdbAdapter", () => {
await Promise.all(writes);
const collection = await adapter.getCollection("environments");

expect(Object.keys(collection)).toHaveLength(10);
// 10 added + 1 default environment
expect(Object.keys(collection)).toHaveLength(11);
});
});
});
17 changes: 0 additions & 17 deletions apps/cli/test.js

This file was deleted.

5 changes: 2 additions & 3 deletions apps/desktop/electron-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ import pkg from "./package.json";

const currentYear = new Date().getFullYear();
const author = pkg.author?.name ?? pkg.author;
const authorInKebabCase = author.replace(/\s+/g, "-");
const appId = `com.${authorInKebabCase}.${pkg.name}`.toLowerCase();
const productName = pkg.productName;

const config: Configuration = {
appId,
appId: "com.superset.desktop",
productName,
copyright: `Copyright © ${currentYear} — ${author}`,
electronVersion: pkg.devDependencies.electron.replace(/^\^/, ""),
Expand Down Expand Up @@ -81,6 +79,7 @@ const config: Configuration = {
category: "Utility",
synopsis: pkg.description,
target: ["AppImage", "deb"],
artifactName: `superset-\${version}-\${arch}.\${ext}`,
},

// Windows
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"release": "electron-builder --publish always",
"clean:dev": "rimraf ./node_modules/.dev",
"typecheck": "tsc --noEmit",
"test": "bun test",
"lint": "biome check --no-errors-on-unmatched",
"lint:fix": "biome check --write --no-errors-on-unmatched --assist-enabled=true",
"format": "biome format --write --no-errors-on-unmatched",
Expand Down
Loading
Loading