|
|
|
|
@@ -90,15 +90,32 @@ const updateBuildNumber = (appLock: string) => {
|
|
|
|
|
// Write the updated data back
|
|
|
|
|
fs.writeFileSync(packagePath, JSON.stringify(pkgJson, null, 2), "utf8");
|
|
|
|
|
|
|
|
|
|
createLog("info", "lst", "zipUpBuild", `Build number updated to: ${pkgJson.admConfig.build}`);
|
|
|
|
|
createLog(
|
|
|
|
|
"info",
|
|
|
|
|
"lst",
|
|
|
|
|
"zipUpBuild",
|
|
|
|
|
`Build number updated to: ${pkgJson.admConfig.build}`
|
|
|
|
|
);
|
|
|
|
|
// Auto-commit changes
|
|
|
|
|
execSync("git add package.json");
|
|
|
|
|
execSync(`git commit -m "chore: bump build number to ${pkgJson.admConfig.build}"`);
|
|
|
|
|
execSync(
|
|
|
|
|
`git commit -m "build: bump build number to ${pkgJson.admConfig.build}"`
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
createLog("error", "lst", "zipUpBuild", "admConfig.build is missing or not a number");
|
|
|
|
|
createLog(
|
|
|
|
|
"error",
|
|
|
|
|
"lst",
|
|
|
|
|
"zipUpBuild",
|
|
|
|
|
"admConfig.build is missing or not a number"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
createLog("error", "lst", "zipUpBuild", `Error updating build number: ${error}`);
|
|
|
|
|
createLog(
|
|
|
|
|
"error",
|
|
|
|
|
"lst",
|
|
|
|
|
"zipUpBuild",
|
|
|
|
|
`Error updating build number: ${error}`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -113,10 +130,18 @@ export const createZip = async (appLock: string) => {
|
|
|
|
|
addToZip(zip, srcPath, srcPath);
|
|
|
|
|
|
|
|
|
|
// Write the zip file to disk
|
|
|
|
|
const outputZipPath = path.join(destPath, `${app.name}-${app.version}-${app.admConfig.build}.zip`);
|
|
|
|
|
const outputZipPath = path.join(
|
|
|
|
|
destPath,
|
|
|
|
|
`${app.name}-${app.version}-${app.admConfig.build}.zip`
|
|
|
|
|
);
|
|
|
|
|
zip.writeZip(outputZipPath);
|
|
|
|
|
|
|
|
|
|
createLog("info", "lst", "zipUpBuild", `Zip file created at ${outputZipPath}`);
|
|
|
|
|
createLog(
|
|
|
|
|
"info",
|
|
|
|
|
"lst",
|
|
|
|
|
"zipUpBuild",
|
|
|
|
|
`Zip file created at ${outputZipPath}`
|
|
|
|
|
);
|
|
|
|
|
updateBuildNumber(appLock);
|
|
|
|
|
|
|
|
|
|
// only keep the last 5 builds for the type we have.
|
|
|
|
|
@@ -130,7 +155,12 @@ export const createZip = async (appLock: string) => {
|
|
|
|
|
}))
|
|
|
|
|
.sort((a, b) => a.time - b.time); // Sort by modification time (oldest first)
|
|
|
|
|
|
|
|
|
|
createLog("info", "lst", "zipUpBuild", `app Files (sorted by time):", ${JSON.stringify(appFiles)}`);
|
|
|
|
|
createLog(
|
|
|
|
|
"info",
|
|
|
|
|
"lst",
|
|
|
|
|
"zipUpBuild",
|
|
|
|
|
`app Files (sorted by time):", ${JSON.stringify(appFiles)}`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (appFiles.length > 5) {
|
|
|
|
|
appFiles.slice(0, -5).forEach((file) => {
|
|
|
|
|
@@ -139,14 +169,24 @@ export const createZip = async (appLock: string) => {
|
|
|
|
|
fs.unlinkSync(filePath);
|
|
|
|
|
createLog("info", "lst", "zipUpBuild", `Deleted: ${file.name}`);
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
createLog("error", "lst", "zipUpBuild", `Failed to delete ${file.name}: ${error.message}`);
|
|
|
|
|
createLog(
|
|
|
|
|
"error",
|
|
|
|
|
"lst",
|
|
|
|
|
"zipUpBuild",
|
|
|
|
|
`Failed to delete ${file.name}: ${error.message}`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
createLog("info", "lst", "zipUpBuild", "No files to delete.");
|
|
|
|
|
}
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
createLog("error", "lst", "zipUpBuild", `Error reading directory or deleting files:", ${error.message}`);
|
|
|
|
|
createLog(
|
|
|
|
|
"error",
|
|
|
|
|
"lst",
|
|
|
|
|
"zipUpBuild",
|
|
|
|
|
`Error reading directory or deleting files:", ${error.message}`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|