feat(services): add status service and refactor CLI
This commit is contained in:
parent
e69e81135a
commit
6708dde532
@ -1,14 +1,6 @@
|
|||||||
import { existsSync } from 'fs';
|
import { getStatus, updateStatus } from '../../core/services/statusService.js';
|
||||||
import { generateStatus } from '../../core/status.js';
|
|
||||||
import { readEntity } from '../../core/files.js';
|
|
||||||
import { getStatusPath } from '../../core/paths.js';
|
|
||||||
|
|
||||||
export function status(cwd: string, options: { update?: boolean } = {}): void {
|
export function status(cwd: string, options: { update?: boolean } = {}): void {
|
||||||
const statusPath = getStatusPath(cwd);
|
const body = options.update ? updateStatus(cwd) : getStatus(cwd);
|
||||||
if (options.update || !existsSync(statusPath)) {
|
|
||||||
generateStatus(cwd);
|
|
||||||
}
|
|
||||||
|
|
||||||
const { body } = readEntity(statusPath);
|
|
||||||
console.log(body);
|
console.log(body);
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/core/services/statusService.ts
Normal file
18
src/core/services/statusService.ts
Normal 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);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user