From 6708dde532ef5b5cd42d155f1fb848db7a23173a Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Thu, 25 Jun 2026 12:23:57 +0200 Subject: [PATCH] feat(services): add status service and refactor CLI --- src/cli/commands/status.ts | 12 ++---------- src/core/services/statusService.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 src/core/services/statusService.ts diff --git a/src/cli/commands/status.ts b/src/cli/commands/status.ts index 9ddd1bd..4d9edec 100644 --- a/src/cli/commands/status.ts +++ b/src/cli/commands/status.ts @@ -1,14 +1,6 @@ -import { existsSync } from 'fs'; -import { generateStatus } from '../../core/status.js'; -import { readEntity } from '../../core/files.js'; -import { getStatusPath } from '../../core/paths.js'; +import { getStatus, updateStatus } from '../../core/services/statusService.js'; export function status(cwd: string, options: { update?: boolean } = {}): void { - const statusPath = getStatusPath(cwd); - if (options.update || !existsSync(statusPath)) { - generateStatus(cwd); - } - - const { body } = readEntity(statusPath); + const body = options.update ? updateStatus(cwd) : getStatus(cwd); console.log(body); } diff --git a/src/core/services/statusService.ts b/src/core/services/statusService.ts new file mode 100644 index 0000000..5d0d4e8 --- /dev/null +++ b/src/core/services/statusService.ts @@ -0,0 +1,18 @@ +import { existsSync } from 'fs'; +import { generateStatus } from '../status.js'; +import { readEntity } from '../files.js'; +import { getStatusPath } from '../paths.js'; + +export function getStatus(cwd: string): string { + const statusPath = getStatusPath(cwd); + if (!existsSync(statusPath)) { + generateStatus(cwd); + } + const { body } = readEntity(statusPath); + return body; +} + +export function updateStatus(cwd: string): string { + generateStatus(cwd); + return getStatus(cwd); +}