fix(FN-952): activate projects after CLI registration
- Set project status to 'active' after registration in runInit (kb init) - Set project status to 'active' after registration in runProjectAdd (kb project add) - Set project status to 'active' after interactive registration in resolveProjectDirectory - Add updateProject mock to init.test.ts, project.test.ts, and project-resolver.test.ts
This commit is contained in:
@@ -12,6 +12,7 @@ const mockCentralInit = vi.fn();
|
||||
const mockCentralClose = vi.fn();
|
||||
const mockGetProjectByPath = vi.fn();
|
||||
const mockRegisterProject = vi.fn();
|
||||
const mockUpdateProject = vi.fn().mockResolvedValue({});
|
||||
|
||||
vi.mock("@fusion/core", () => ({
|
||||
CentralCore: vi.fn().mockImplementation(() => ({
|
||||
@@ -19,6 +20,7 @@ vi.mock("@fusion/core", () => ({
|
||||
close: mockCentralClose,
|
||||
getProjectByPath: mockGetProjectByPath,
|
||||
registerProject: mockRegisterProject,
|
||||
updateProject: mockUpdateProject,
|
||||
})),
|
||||
resolveGlobalDir: vi.fn(),
|
||||
}));
|
||||
|
||||
@@ -109,6 +109,9 @@ export async function runInit(options: InitOptions = {}): Promise<void> {
|
||||
isolationMode: "in-process",
|
||||
});
|
||||
|
||||
// Activate the project (registration sets it to 'initializing')
|
||||
await central.updateProject(project.id, { status: "active" });
|
||||
|
||||
console.log(` ✓ Registered in central database`);
|
||||
console.log(`\n✓ Project "${project.name}" initialized successfully!`);
|
||||
console.log(`\n Next steps:`);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
|
||||
const mockListProjects = vi.fn();
|
||||
const mockRegisterProject = vi.fn();
|
||||
const mockUpdateProject = vi.fn().mockResolvedValue({});
|
||||
const mockUnregisterProject = vi.fn();
|
||||
const mockGetProject = vi.fn();
|
||||
const mockGetProjectByPath = vi.fn();
|
||||
@@ -28,6 +29,7 @@ vi.mock("@fusion/core", () => ({
|
||||
close: mockClose.mockResolvedValue(undefined),
|
||||
listProjects: mockListProjects,
|
||||
registerProject: mockRegisterProject,
|
||||
updateProject: mockUpdateProject,
|
||||
unregisterProject: mockUnregisterProject,
|
||||
getProject: mockGetProject,
|
||||
getProjectByPath: mockGetProjectByPath,
|
||||
|
||||
@@ -361,6 +361,9 @@ export async function runProjectAdd(
|
||||
isolationMode,
|
||||
});
|
||||
|
||||
// Activate the project (registration sets it to 'initializing')
|
||||
await central.updateProject(project.id, { status: "active" });
|
||||
|
||||
console.log();
|
||||
console.log(` ✓ Registered project '${projectName}'`);
|
||||
console.log(` Location: ${formatDisplayPath(project.path)}`);
|
||||
|
||||
@@ -18,6 +18,7 @@ vi.mock("@fusion/core", async () => {
|
||||
getProject = vi.fn().mockResolvedValue(undefined);
|
||||
getProjectByPath = vi.fn().mockResolvedValue(undefined);
|
||||
registerProject = vi.fn();
|
||||
updateProject = vi.fn().mockResolvedValue({});
|
||||
unregisterProject = vi.fn().mockResolvedValue(undefined);
|
||||
getProjectHealth = vi.fn().mockResolvedValue(undefined);
|
||||
isInitialized = vi.fn().mockReturnValue(true);
|
||||
|
||||
@@ -263,6 +263,9 @@ export async function resolveProject(options: ResolveOptions = {}): Promise<Reso
|
||||
isolationMode: "in-process",
|
||||
});
|
||||
|
||||
// Activate the project (registration sets it to 'initializing')
|
||||
await central.updateProject(newProject.id, { status: "active" });
|
||||
|
||||
console.log(`\n ✓ Registered project "${newProject.name}"`);
|
||||
return createResolvedProject(newProject);
|
||||
} catch (err: any) {
|
||||
@@ -606,6 +609,9 @@ export async function registerProjectInteractive(
|
||||
isolationMode: options.isolation ?? "in-process",
|
||||
});
|
||||
|
||||
// Activate the project (registration sets it to 'initializing')
|
||||
await central.updateProject(project.id, { status: "active" });
|
||||
|
||||
return createResolvedProject(project);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user