feat(services): add status service and refactor CLI

This commit is contained in:
chahinebrini 2026-06-25 12:23:57 +02:00
parent e69e81135a
commit 6708dde532
2 changed files with 20 additions and 10 deletions

View File

@ -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);
}

View File

@ -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);
}