BREAKING CHANGE(core): Migrate filesystem to smartfs (async) and add Elasticsearch service support; refactor format/commit/meta modules

This commit is contained in:
2025-11-27 21:32:34 +00:00
parent 2f3d67f9e3
commit e1d28bc10a
30 changed files with 2217 additions and 995 deletions

View File

@@ -142,10 +142,10 @@ export const run = async (argvArg: any) => {
changelog = changelog.replaceAll('\n{{nextVersionDetails}}', '');
}
await plugins.smartfile.memory.toFs(
changelog,
plugins.path.join(paths.cwd, `changelog.md`),
);
await plugins.smartfs
.file(plugins.path.join(paths.cwd, `changelog.md`))
.encoding('utf8')
.write(changelog);
ui.printStep(currentStep, totalSteps, '📄 Generating changelog.md', 'done');
// Step 3: Staging files

View File

@@ -40,8 +40,8 @@ export async function detectProjectType(): Promise<ProjectType> {
const packageJsonPath = plugins.path.join(paths.cwd, 'package.json');
const denoJsonPath = plugins.path.join(paths.cwd, 'deno.json');
const hasPackageJson = await plugins.smartfile.fs.fileExists(packageJsonPath);
const hasDenoJson = await plugins.smartfile.fs.fileExists(denoJsonPath);
const hasPackageJson = await plugins.smartfs.file(packageJsonPath).exists();
const hasDenoJson = await plugins.smartfs.file(denoJsonPath).exists();
if (hasPackageJson && hasDenoJson) {
logger.log('info', 'Detected dual project (npm + deno)');
@@ -95,10 +95,14 @@ function calculateNewVersion(currentVersion: string, versionType: VersionType):
* @param projectType The project type to determine which file to read
* @returns The current version string
*/
function readCurrentVersion(projectType: ProjectType): string {
async function readCurrentVersion(projectType: ProjectType): Promise<string> {
if (projectType === 'npm' || projectType === 'both') {
const packageJsonPath = plugins.path.join(paths.cwd, 'package.json');
const packageJson = plugins.smartfile.fs.toObjectSync(packageJsonPath) as { version?: string };
const content = (await plugins.smartfs
.file(packageJsonPath)
.encoding('utf8')
.read()) as string;
const packageJson = JSON.parse(content) as { version?: string };
if (!packageJson.version) {
throw new Error('package.json does not contain a version field');
@@ -106,7 +110,11 @@ function readCurrentVersion(projectType: ProjectType): string {
return packageJson.version;
} else {
const denoJsonPath = plugins.path.join(paths.cwd, 'deno.json');
const denoConfig = plugins.smartfile.fs.toObjectSync(denoJsonPath) as { version?: string };
const content = (await plugins.smartfs
.file(denoJsonPath)
.encoding('utf8')
.read()) as string;
const denoConfig = JSON.parse(content) as { version?: string };
if (!denoConfig.version) {
throw new Error('deno.json does not contain a version field');
@@ -121,12 +129,16 @@ function readCurrentVersion(projectType: ProjectType): string {
* @param newVersion The new version to write
*/
async function updateVersionFile(filePath: string, newVersion: string): Promise<void> {
const config = plugins.smartfile.fs.toObjectSync(filePath) as { version?: string };
const content = (await plugins.smartfs
.file(filePath)
.encoding('utf8')
.read()) as string;
const config = JSON.parse(content) as { version?: string };
config.version = newVersion;
await plugins.smartfile.memory.toFs(
JSON.stringify(config, null, 2) + '\n',
filePath
);
await plugins.smartfs
.file(filePath)
.encoding('utf8')
.write(JSON.stringify(config, null, 2) + '\n');
}
/**
@@ -162,7 +174,7 @@ export async function bumpProjectVersion(
try {
// 1. Read current version
const currentVersion = readCurrentVersion(projectType);
const currentVersion = await readCurrentVersion(projectType);
// 2. Calculate new version (reuse existing function!)
const newVersion = calculateNewVersion(currentVersion, versionType);