fix(commitinfo): update project metadata and make commit info generation compatible with current tooling

This commit is contained in:
2026-05-01 18:16:09 +00:00
parent 536588f61f
commit 631b346b0a
12 changed files with 4976 additions and 3709 deletions
+22 -9
View File
@@ -4,36 +4,49 @@ export class CommitInfo {
// Instance
public projectDir: string;
public plannedCommitVersionTypeArg: 'patch' | 'minor' | 'major';
public projectinfoNpmRef: plugins.projectinfo.ProjectinfoNpm;
public smartVersionRef: plugins.smartversion.SmartVersion;
public projectinfoNpmRef: plugins.projectinfo.ProjectinfoNpm | undefined;
public smartVersionRef: plugins.smartversion.SmartVersion | undefined;
private projectinfoNpmPromise: Promise<plugins.projectinfo.ProjectinfoNpm>;
constructor(projectDirArg: string, plannedCommitVersionTypeArg: 'patch' | 'minor' | 'major') {
this.projectDir = projectDirArg;
this.plannedCommitVersionTypeArg = plannedCommitVersionTypeArg;
this.projectinfoNpmRef = new plugins.projectinfo.ProjectinfoNpm(projectDirArg);
this.smartVersionRef = new plugins.smartversion.SmartVersion(this.projectinfoNpmRef.version);
this.projectinfoNpmPromise = plugins.projectinfo.ProjectinfoNpm.create(projectDirArg);
}
private async getProjectinfoNpmRef(): Promise<plugins.projectinfo.ProjectinfoNpm> {
if (!this.projectinfoNpmRef) {
this.projectinfoNpmRef = await this.projectinfoNpmPromise;
}
return this.projectinfoNpmRef;
}
public async getNextPlannedVersion() {
const projectinfoNpmRef = await this.getProjectinfoNpmRef();
this.smartVersionRef = new plugins.smartversion.SmartVersion(projectinfoNpmRef.version);
return this.smartVersionRef.getNewVersion(this.plannedCommitVersionTypeArg);
}
public async writeIntoPotentialDirs(potentialDirs: string[] = ['ts', 'ts_web']) {
const projectinfoNpmRef = await this.getProjectinfoNpmRef();
const expectedDefinitiveVersion = await this.getNextPlannedVersion();
for (const dir of potentialDirs) {
const dirExists = plugins.smartfile.fs.isDirectory(plugins.path.join(this.projectDir, dir));
const dirPath = plugins.path.join(this.projectDir, dir);
const dirExists = plugins.fs.existsSync(dirPath) && plugins.fs.statSync(dirPath).isDirectory();
if (dirExists) {
const writePath = plugins.path.join(this.projectDir, dir, '00_commitinfo_data.ts');
await plugins.smartfile.memory.toFs(
await plugins.fs.promises.writeFile(
writePath,
`/**
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '${this.projectinfoNpmRef.name}',
name: '${projectinfoNpmRef.name}',
version: '${expectedDefinitiveVersion.versionString}',
description: '${this.projectinfoNpmRef.packageJson.description}'
description: '${projectinfoNpmRef.packageJson.description}'
}
`,
writePath
'utf8'
);
}
}