13 Commits

12 changed files with 326 additions and 229 deletions

1
.gitignore vendored
View File

@@ -7,6 +7,7 @@ releases/
LstWrapper/bin LstWrapper/bin
LstWrapper/publish LstWrapper/publish
LstWrapper/obj LstWrapper/obj
scripts/tmp
# ---> Go # ---> Go
# If you prefer the allow list template instead of the deny list, see community template: # If you prefer the allow list template instead of the deny list, see community template:

View File

@@ -9,19 +9,53 @@
"publish": false "publish": false
}, },
"hooks": { "hooks": {
"before:init": "node ./scripts/read-build-number.js",
"after:release": "node ./scripts/create-gitea-release.js ${version}" "after:release": "node ./scripts/create-gitea-release.js ${version}"
}, },
"github": false, "github": false,
"plugins": { "plugins": {
"@release-it/conventional-changelog": { "@release-it/conventional-changelog": {
"preset": "conventionalcommits", "preset": {
"name": "conventionalcommits",
"types": [
{ "type": "feat", "section": "🌟 Enhancements" },
{ "type": "fix", "section": "🐛 Bug fixes" },
{ "type": "chore", "section": "📝 Chore" },
{ "type": "docs", "section": "📚 Documentation" },
{ "type": "style", "section": "📚 Style" },
{ "type": "refactor", "section": "🛠️ Code Refactor" },
{
"type": "perf",
"section": "🚀 Performance"
},
{ "type": "test", "section": "📝 Testing Code" },
{
"type": "ci",
"section": "📈 Project changes"
},
{
"type": "build",
"hidden": false,
"section": "📈 Project Builds"
}
],
"commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}",
"compareUrlFormat": "{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}",
"issueUrlFormat": "{{host}}/{{owner}}/{{repository}}/issues/{{id}}",
"userUrlFormat": "{{host}}/{{user}}"
},
"infile": "CHANGELOG.md", "infile": "CHANGELOG.md",
"config": ".versionrc.json" "header": "# Changelog\n\nAll notable changes to LST will be documented in this file.\n",
"releaseCommitMessageFormat": "chore(release): {{currentTag}}"
} }
}, },
"gitea": { "@release-it/gitea": {
"host": "https://${GITEA_URL}", "host": "https://${GITEA_URL}",
"tokenRef": "GITEA_TOKEN" "tokenRef": "GITEA_TOKEN",
"releaseName": "v${version} (build ${BUILD_NUMBER})",
"releaseNotes": "node ./scripts/get-changelog-entry.js ${version}"
}, },
"files": ["package.json", "CHANGELOG.md"] "files": ["package.json", "CHANGELOG.md"]

View File

@@ -1,17 +0,0 @@
{
"types": [
{ "type": "feat", "section": "🌟 Enhancements" },
{ "type": "fix", "section": "🐛 Bug fixes" },
{ "type": "chore", "hidden": false, "section": "📝 Chore" },
{ "type": "docs", "section": "📚 Documentation" },
{ "type": "style", "hidden": true },
{ "type": "refactor", "section": "🛠️ Code Refactor" },
{ "type": "perf", "hidden": false, "section": "🚀 Performance" },
{ "type": "test", "section": "📝 Testing Code" },
{ "type": "ci", "hidden": false, "section": "📈 Project changes" },
{ "type": "build", "hidden": true, "section": "📈 Project Builds" }
],
"commitUrlFormat": "https://git.tuffraid.net/cowch/logistics_support_tool/commits/{{hash}}",
"compareUrlFormat": "https://git.tuffraid.net/cowch/logistics_support_tool/compare/{{previousTag}}...{{currentTag}}",
"header": "# All changes to lst are shown below.\nReleases are combined zip of backend and frontend."
}

View File

@@ -1,5 +1,37 @@
# Changelog # Changelog
All notable changes to LST will be documented in this file.
## [0.0.1-alpha.4](https://git.tuffraid.net/cowch/logistics_support_tool/compare/v0.0.1-alpha.3...v0.0.1-alpha.4) (2025-07-16)
### 📈 Project changes
* **build:** changes to ignore the tmp folder in the scripts ([26b018e](https://git.tuffraid.net/cowch/logistics_support_tool/commit/26b018ee3eb408ab3c5ddd9e886987deb3334720))
* **createzip:** changes to include the script folder ([5cb71e5](https://git.tuffraid.net/cowch/logistics_support_tool/commit/5cb71e55476f91a48d095f80be2cea3b6793f8e6))
### 📈 Project Builds
* **build:** script created to build lstv2 and copy over before zipping up also cleanup ([c0d67c2](https://git.tuffraid.net/cowch/logistics_support_tool/commit/c0d67c2a16695e40af7ec52f86fc54344f3b889c))
## [0.0.1-alpha.3](https://git.tuffraid.net/cowch/logistics_support_tool/compare/v0.0.1-alpha.2...v0.0.1-alpha.3) (2025-07-16)
### 🌟 Enhancements
* **scripts:** 2 new scripts for the build process ([afe795e](https://git.tuffraid.net/cowch/logistics_support_tool/commit/afe795edd588b823e5459a6762f787152a49a8cb))
### 🛠️ Code Refactor
* **build:** changes to show more details when we run the build stuff ([5ed4a6c](https://git.tuffraid.net/cowch/logistics_support_tool/commit/5ed4a6c081e29da6600949ed2b811551e6a947f7))
* **createzip:** change the name from release to createZip ([6467355](https://git.tuffraid.net/cowch/logistics_support_tool/commit/646735565f28153c0750e7788b349b384bd5c5de))
* **package.json:** changes to the scripts ([7a4840e](https://git.tuffraid.net/cowch/logistics_support_tool/commit/7a4840ef95c86a96e3b8a2e8af124a55af2b01b4))
* **release-it:** changes to the build process and changelog ([c3473ca](https://git.tuffraid.net/cowch/logistics_support_tool/commit/c3473ca60e7e92f68cdff4e4a35bfcff2e7ae37b))
* **releases:** simplified the functions ([a0856d1](https://git.tuffraid.net/cowch/logistics_support_tool/commit/a0856d171a404c3adf52591b3c9da4fae53322d3))
# Changelog
## [0.0.1-alpha.2](https://git.tuffraid.net/cowch/logistics_support_tool/compare/v0.0.1-alpha.1...v0.0.1-alpha.2) (2025-07-16)
## [0.0.3-alpha.22](https://git.tuffraid.net/cowch/logistics_support_tool/compare/v0.0.3-alpha.21...v0.0.3-alpha.22) (2025-07-12) ## [0.0.3-alpha.22](https://git.tuffraid.net/cowch/logistics_support_tool/compare/v0.0.3-alpha.21...v0.0.3-alpha.22) (2025-07-12)
### Bug Fixes ### Bug Fixes

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "logistics_support_tool", "name": "logistics_support_tool",
"version": "0.0.1-alpha.1", "version": "0.0.1-alpha.4",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "logistics_support_tool", "name": "logistics_support_tool",
"version": "0.0.1-alpha.1", "version": "0.0.1-alpha.4",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"dotenv": "^17.2.0", "dotenv": "^17.2.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "logistics_support_tool", "name": "logistics_support_tool",
"version": "0.0.1-alpha.1", "version": "0.0.1-alpha.4",
"description": "This is the new logisitcs support tool", "description": "This is the new logisitcs support tool",
"private": true, "private": true,
"main": "index.js", "main": "index.js",
@@ -11,8 +11,7 @@
"docker:front": "docker build -t logistics_support_tool:frontend-latest -f frontend/Dockerfile ./frontend", "docker:front": "docker build -t logistics_support_tool:frontend-latest -f frontend/Dockerfile ./frontend",
"docker:back": "docker build -t logistics_support_tool:backend-latest -f backend/Dockerfile ./backend", "docker:back": "docker build -t logistics_support_tool:backend-latest -f backend/Dockerfile ./backend",
"docker": "powershell -File ./scripts/dockerBuild.ps1", "docker": "powershell -File ./scripts/dockerBuild.ps1",
"release:createZip": "powershell -File ./scripts/release.ps1", "createZip": "powershell -File ./scripts/createZip.ps1",
"release:gitea": "node ./scripts/create-gitea-release.js",
"release": "release-it --verbose --non-interactive --preRelease=alpha", "release": "release-it --verbose --non-interactive --preRelease=alpha",
"commit": "cz" "commit": "cz"
}, },

View File

@@ -3,6 +3,12 @@ $rootDir = Join-Path $scriptDir ".."
$releaseScript = Join-Path $scriptDir "release.ps1" $releaseScript = Join-Path $scriptDir "release.ps1"
$packageJsonPath = Join-Path $rootDir "package.json" $packageJsonPath = Join-Path $rootDir "package.json"
# tmp scripts to get lstv2 into this build and zipped up with everything
. (Join-Path $PSScriptRoot "lstV2Build.ps1")
# will run the lstv2 build first so we know for sure its copied over
Build-LstV2-And-Copy
# Path to BUILD_NUMBER file, assuming root is one level up from scripts # Path to BUILD_NUMBER file, assuming root is one level up from scripts
$buildNumberFile = Join-Path $scriptDir "..\BUILD_NUMBER" $buildNumberFile = Join-Path $scriptDir "..\BUILD_NUMBER"
$envFile = Join-Path $rootDir ".env" $envFile = Join-Path $rootDir ".env"
@@ -117,10 +123,44 @@ function Update-BuildNumber {
dotnet publish -c Release -o ./publish dotnet publish -c Release -o ./publish
Pop-Location Pop-Location
try {
Update-BuildNumber Update-BuildNumber
Write-Host "Zipping up the release" Write-Host "Zipping up the release"
npm run release:createZip npm run createZip
if ($LASTEXITCODE -ne 0) {
throw "Failed to create release zip"
}
$choice = Read-Host "Are we going to create a release? y/N"
if ($choice -eq "y" -or $choice -eq "Y") {
Write-Host "Creating release..."
# This will:
# 1. Update version in package.json
# 2. Generate changelog
# 3. Create git tag
# 4. Push to remote
# 5. Create Gitea release via our script
npm run release
# deleteing the temp folder so we always cleaned up
Delete-Tmp-Folder
if ($LASTEXITCODE -ne 0) {
throw "Failed to create Gitea release"
}
}
} catch {
Write-Warning "Release process failed: $_"
# deleteing the temp folder so we always cleaned up
Delete-Tmp-Folder
exit 1
}
break break

View File

@@ -1,151 +1,64 @@
const version = process.argv[2];
if (!version) {
console.error("Version not passed to create-gitea-release.js");
process.exit(1);
}
import fs from "fs-extra"; import fs from "fs-extra";
import path from "path"; import path from "path";
import { fileURLToPath } from "url"; import { fileURLToPath } from "url";
import fetch from "node-fetch"; import fetch from "node-fetch";
import dotenv from "dotenv"; import dotenv from "dotenv";
dotenv.config({ path: "./.env" }); dotenv.config({ path: "./.env" });
// Resolve the directory of the current script
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); const __dirname = path.dirname(__filename);
// Absolute path to BUILD_NUMBER const version = process.argv[2];
const buildNumberPath = path.resolve(__dirname, "../BUILD_NUMBER"); if (!version) {
console.error("Version not passed to create-gitea-release.js");
// Load build number from BUILD_NUMBER file process.exit(1);
let buildNumber = "0";
try {
const rawBuild = fs.readFileSync(buildNumberPath, "utf8");
console.log("Raw build", rawBuild);
buildNumber = rawBuild.trim();
} catch (e) {
console.log(e);
console.warn("BUILD_NUMBER file not found, defaulting to 0");
} }
const fullVersion = `${version}.${buildNumber}`;
const { GITEA_URL, GITEA_USERNAME, GITEA_REPO, GITEA_TOKEN } = process.env; const { GITEA_URL, GITEA_USERNAME, GITEA_REPO, GITEA_TOKEN } = process.env;
if (!GITEA_URL || !GITEA_USERNAME || !GITEA_REPO || !GITEA_TOKEN) { if (!GITEA_URL || !GITEA_USERNAME || !GITEA_REPO || !GITEA_TOKEN) {
console.error("Missing required environment variables"); console.error("Missing required environment variables");
process.exit(1); process.exit(1);
} }
// Step 1: Generate or update CHANGELOG.md const getChangelogContent = async () => {
// console.log("Generating CHANGELOG.md...");
// const result = spawnSync(
// "npx",
// [
// "conventional-changelog",
// "-p",
// "conventionalcommits",
// "-i",
// "CHANGELOG.md",
// "-s",
// "-r",
// "0",
// ],
// { stdio: "inherit", shell: true }
// );
// if (result.status !== 0) {
// console.error("Failed to generate changelog");
// process.exit(1);
// }
// Corrected function to get the latest changelog entry from CHANGELOG.md
const getLatestChangelog = async () => {
try { try {
const changelogPath = path.resolve(__dirname, "../CHANGELOG.md"); const changelogPath = path.resolve(__dirname, "../CHANGELOG.md");
console.log(`Attempting to read changelog from: ${changelogPath}`); // Debugging line const content = await fs.readFile(changelogPath, "utf8");
const changelogContent = await fs.readFile(changelogPath, "utf8");
console.log(
"Changelog content read successfully (first 200 chars):",
changelogContent.substring(0, 200)
); // Debugging line
const lines = changelogContent.trim().split(/\r?\n/); // Extract the section for the current version
const versionHeading = `## [${version}]`;
const sections = content.split(/(?=^## \[)/m); // Split at version headings
let latestReleaseNotes = []; if (sections.length < 2) {
let inLatestRelease = false; console.warn("Couldn't find version section in changelog");
let foundFirstHeading = false; return "No changelog content available.";
// Regex to match a conventional changelog heading format: "## [version](url) (date)"
// The key is to correctly parse the URL part in parentheses.
const releaseHeadingRegex = /^## \[.*?\]\(.*?\)\s\(.*\)$/;
for (const line of lines) {
// Trim each line to handle potential leading/trailing spaces when matching
const trimmedLine = line.trim();
if (trimmedLine.match(releaseHeadingRegex)) {
if (!foundFirstHeading) {
// This is the first (latest) release heading we encounter
inLatestRelease = true;
foundFirstHeading = true;
// We skip the heading line itself from the notes body
continue;
} else {
// This is a subsequent release heading, meaning we've passed the latest release's content
break;
}
} }
// If we are currently inside the latest release block, add the line // The first section is the latest version
if (inLatestRelease) { const latestSection = sections[1];
latestReleaseNotes.push(trimmedLine); // Use trimmedLine here return latestSection.trim();
}
}
// Clean up the collected notes by filtering out empty lines if they are not meaningful content
// and joining them back, then trimming.
const cleanedNotes = latestReleaseNotes
.filter((line) => line !== "") // Remove truly empty lines
.join("\n")
.trim();
if (cleanedNotes) {
console.log(
"Successfully extracted latest changelog notes:\n",
cleanedNotes
);
return cleanedNotes;
} else {
console.warn(
"Could not find any content for the latest changelog entry in CHANGELOG.md. This might mean the file is empty, or the regex for headings is incorrect, or there's no content after the heading."
);
return "No changelog notes available.";
}
} catch (err) { } catch (err) {
console.error("Error reading or parsing CHANGELOG.md:", err); console.error("Error reading changelog:", err);
throw err; return "No changelog content available.";
} }
}; };
const releaseNotes = await getLatestChangelog(); const createOrUpdateRelease = async (releaseNotes) => {
// Step 3: Create or update Gitea release
const createOrUpdateRelease = async () => {
const tagName = `v${version}`; const tagName = `v${version}`;
const apiBase = `https://${GITEA_URL}/api/v1/repos/${GITEA_USERNAME}/${GITEA_REPO}`; const apiBase = `https://${GITEA_URL}/api/v1/repos/${GITEA_USERNAME}/${GITEA_REPO}`;
try {
const existing = await fetch(`${apiBase}/releases/tags/${tagName}`, { const existing = await fetch(`${apiBase}/releases/tags/${tagName}`, {
headers: { Authorization: `token ${GITEA_TOKEN}` }, headers: { Authorization: `token ${GITEA_TOKEN}` },
}); });
let release;
if (existing.ok) { if (existing.ok) {
// Update existing release
const existingRelease = await existing.json(); const existingRelease = await existing.json();
console.log(`Release ${tagName} already exists. Updating it.`); console.log(`Updating existing release ${tagName}`);
const updateResponse = await fetch( const response = await fetch(
`${apiBase}/releases/${existingRelease.id}`, `${apiBase}/releases/${existingRelease.id}`,
{ {
method: "PATCH", method: "PATCH",
@@ -157,22 +70,21 @@ const createOrUpdateRelease = async () => {
name: tagName, name: tagName,
body: releaseNotes, body: releaseNotes,
draft: false, draft: false,
prerelease: true, prerelease: false, // Change to true if you want prereleases
}), }),
} }
); );
if (!updateResponse.ok) { if (!response.ok)
const errorText = await updateResponse.text(); throw new Error(`Failed to update release: ${response.status}`);
throw new Error( const release = await response.json();
`Failed to update release: ${updateResponse.status} - ${errorText}` console.log("Release updated:", release.html_url);
); return release;
}
release = await updateResponse.json();
console.log("Release updated:", release.html_url || release.url);
} else if (existing.status === 404) { } else if (existing.status === 404) {
const createResponse = await fetch(`${apiBase}/releases`, { // Create new release
console.log(`Creating new release ${tagName}`);
const response = await fetch(`${apiBase}/releases`, {
method: "POST", method: "POST",
headers: { headers: {
Authorization: `token ${GITEA_TOKEN}`, Authorization: `token ${GITEA_TOKEN}`,
@@ -180,73 +92,33 @@ const createOrUpdateRelease = async () => {
}, },
body: JSON.stringify({ body: JSON.stringify({
tag_name: tagName, tag_name: tagName,
name: `Release ${fullVersion}`, name: `Release ${version}`,
body: releaseNotes, body: releaseNotes,
draft: false, draft: false,
prerelease: true, prerelease: false, // Change to true if you want prereleases
}), }),
}); });
if (!createResponse.ok) { if (!response.ok)
const errorText = await createResponse.text(); throw new Error(`Failed to create release: ${response.status}`);
throw new Error( const release = await response.json();
`Failed to create release: ${createResponse.status} - ${errorText}` console.log("Release created:", release.html_url);
);
}
release = await createResponse.json();
console.log("Release created:", release.html_url || release.url);
} else {
const errorText = await existing.text();
throw new Error(
`Failed to check release: ${existing.status} - ${errorText}`
);
}
return release; return release;
} else {
throw new Error(`Failed to check release: ${existing.status}`);
}
} catch (error) {
console.error("Error in createOrUpdateRelease:", error);
throw error;
}
}; };
const uploadAsset = async (release) => {
const apiUrl = `https://${GITEA_URL}/api/v1/repos/${GITEA_USERNAME}/${GITEA_REPO}/releases/assets?tag=${release.tag_name}`;
const filePath = `releases/release-${fullVersion}.zip`;
if (!(await fs.pathExists(filePath))) {
console.warn(`Zip file not found: ${filePath}. Skipping asset upload.`);
return;
}
const FormData = (await import("form-data")).default;
const form = new FormData();
form.append("name", `release-${fullVersion}.zip`);
form.append("attachment", fs.createReadStream(filePath));
const response = await fetch(apiUrl, {
method: "POST",
headers: {
Authorization: `token ${GITEA_TOKEN}`,
...form.getHeaders(),
},
body: form,
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(
`Failed to upload asset: ${response.status} - ${errorText}`
);
}
const asset = await response.json();
console.log("Asset uploaded:", asset.browser_download_url || asset.url);
};
// Run everything
(async () => { (async () => {
try { try {
const release = await createOrUpdateRelease(); const releaseNotes = await getChangelogContent();
// await uploadAsset(release); // fix this later and just update the readme. await createOrUpdateRelease(releaseNotes);
} catch (err) { } catch (error) {
console.error(err); console.error("Release failed:", error);
process.exit(1); process.exit(1);
} }
})(); })();

View File

@@ -79,7 +79,10 @@ $filesToCopy = @(
@{ Source = "frontend\public"; Destination = "frontend\public" }, @{ Source = "frontend\public"; Destination = "frontend\public" },
@{ Source = "package.json"; Destination = "package.json" }, @{ Source = "package.json"; Destination = "package.json" },
@{ Source = "CHANGELOG.md"; Destination = "CHANGELOG.md" }, @{ Source = "CHANGELOG.md"; Destination = "CHANGELOG.md" },
@{ Source = "README.md"; Destination = "README.md" } @{ Source = "README.md"; Destination = "README.md" },
# scripts to be copied over
@{ Source = "scripts\tmp"; Destination = "scripts\tmp" }
@{ Source = "scripts\iisControls.ps1"; Destination = "scripts\iisControls.ps1" }
) )
foreach ($file in $filesToCopy) { foreach ($file in $filesToCopy) {

View File

@@ -0,0 +1,42 @@
import fs from "fs-extra";
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const version = process.argv[2];
if (!version) {
console.error("Version argument is required");
process.exit(1);
}
async function getChangelogEntry() {
try {
const changelogPath = path.resolve(__dirname, "../../CHANGELOG.md");
const content = await fs.readFile(changelogPath, "utf8");
// Find the section for this version
const versionHeader = `## [${version}]`;
const sections = content.split(versionHeader);
if (sections.length < 2) {
console.warn(`No changelog entry found for version ${version}`);
return `Release ${version}`;
}
// Extract the content for this version
const versionContent = sections[1].split("\n## ")[0].trim();
// Add the version header back
return `${versionHeader}\n${versionContent}`;
} catch (error) {
console.error("Error reading changelog:", error);
return `Release ${version}`;
}
}
// Output the changelog entry (release-it will capture this stdout)
getChangelogEntry()
.then(console.log)
.catch(() => process.exit(1));

67
scripts/lstV2Build.ps1 Normal file
View File

@@ -0,0 +1,67 @@
#This is only temp until we make the entire transtion over to just this app...... long time but working on build process
$lstv2Loc = "C:\Users\matthes01\Documents\lstV2"
$lstv2BuildsDir = Join-Path $lstv2Loc "builds"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
$tmpLoc = Join-Path $scriptDir "\tmp"
function Build-LstV2-And-Copy {
if (Test-Path $tmpLoc) {
Write-Host "Temp folder for lst builds exist, moving to run the build function."
} else {
Write-Host "Tmp Folder dose not exist we will create it."
New-Item -Path $scriptDir -Name "tmp" -ItemType "Directory"
}
Write-Host "Jumping into lstV2 to build it."
Push-Location $lstv2Loc
npm run build
Write-Host "LSTV2 Finished building."
Write-Host "Copy the latest build to the tmpLoc"
# Get all build files and sort by creation time
$buildFiles = Get-ChildItem -Path $lstv2BuildsDir -File -Filter "*.zip" |
Sort-Object LastWriteTime -Descending
if ($buildFiles.Count -eq 0) {
Write-Error "No build files found in $lstv2BuildsDir"
Pop-Location
exit 1
}
# Get the most recent build
$latestBuild = $buildFiles[0]
$destinationPath = Join-Path $tmpLoc $latestBuild.Name
Write-Host "Copying latest build: $($latestBuild.Name)"
Write-Host "Created: $($latestBuild.LastWriteTime)"
Write-Host "Size: $([math]::Round($latestBuild.Length/1MB, 2)) MB"
# Copy the file
try {
Copy-Item -Path $latestBuild.FullName -Destination $destinationPath -Force
Write-Host "Successfully copied to: $destinationPath"
}
catch {
Write-Error "Failed to copy build file: $_"
Pop-Location
exit 1
}
Pop-Location
}
function Delete-Tmp-Folder
{
Write-Host "Removing the temp folder to keep it all clean"
if (Test-Path $tmpLoc) {
Remove-Item -Path $tmpLoc -Recurse
}else {
Write-Host "Tmp folder dose not exist, nothing to delete."
}
}

View File

@@ -0,0 +1,24 @@
/**
* This is for release-it to be able to post the new build number in the releases
*/
import fs from "fs-extra";
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
async function readBuildNumber() {
try {
const buildNumberPath = path.resolve(__dirname, "../BUILD_NUMBER");
const buildNumber = (await fs.readFile(buildNumberPath, "utf8")).trim();
process.env.BUILD_NUMBER = buildNumber;
console.log(`Build number: ${buildNumber}`);
} catch (error) {
console.error("Error reading BUILD_NUMBER:", error);
process.exit(1);
}
}
readBuildNumber();