22 Commits

Author SHA1 Message Date
44fdf49555 chore(release): v0.0.1-alpha.3 2025-07-16 08:39:28 -05:00
afe795edd5 feat(scripts): 2 new scripts for the build process 2025-07-16 08:37:25 -05:00
a0856d171a refactor(releases): simplified the functions 2025-07-16 08:36:49 -05:00
5ed4a6c081 refactor(build): changes to show more details when we run the build stuff 2025-07-16 08:34:50 -05:00
7a4840ef95 refactor(package.json): changes to the scripts 2025-07-16 08:33:32 -05:00
c3473ca60e refactor(release-it): changes to the build process and changelog 2025-07-16 08:33:00 -05:00
646735565f refactor(createzip): change the name from release to createZip 2025-07-16 08:24:13 -05:00
a354004201 chore(release): v0.0.1-alpha.2 2025-07-16 07:08:01 -05:00
942be59715 refactor(build): changes to add in releasing from build 2025-07-16 07:07:08 -05:00
70e376c939 fix(build): removed the * at the end of source so no more errors 2025-07-16 06:56:13 -05:00
62a1ad83ab build(wrapper): added the wrapper to our build script 2025-07-16 06:55:52 -05:00
47c5a47ffa test(scripts): added in a go script to test my other scripts 2025-07-16 06:49:24 -05:00
9bd6e1fc04 feat(scripts): added in iis contorls 2025-07-16 06:48:43 -05:00
73600055fc fix(release script): correction to the script so it now puts the package to correct location 2025-07-15 10:39:20 -05:00
80907a89a9 refactor(backend): changes to how the api incorrect routes are handled 2025-07-14 21:58:01 -05:00
2472374157 refactor(zips): changes on how the compiler dose the zip to keep it cleaner 2025-07-14 21:57:04 -05:00
b72a10db94 refactor(build): changed the wording to understand the error when the .env missing 2025-07-14 21:56:16 -05:00
d097988dfd feat(lstwrapper): added a c# wrapper so we can run on windows server and get ssl
this will also allow us to still use docker
2025-07-14 21:55:25 -05:00
cb9e8e1107 fix(docker compose): corrected the data path wording and added a build option in 2025-07-14 21:54:18 -05:00
7bb7df788e fix(docker): corrections to the docker script
as we run it in the root we dont want to have it go up 2 levels only be at the same level
2025-07-12 21:50:58 -05:00
f26cf6404e ci(docker): changes to remove cache so we are always creating a new build 2025-07-12 21:42:25 -05:00
7f867b02d6 refactor(backend): changes to have a catch all and not return a 404 always 2025-07-12 21:41:47 -05:00
22 changed files with 513 additions and 262 deletions

5
.gitignore vendored
View File

@@ -4,6 +4,9 @@ frontend/.tanstack/
frontend/.output/
frontend/.nitro/
releases/
LstWrapper/bin
LstWrapper/publish
LstWrapper/obj
# ---> Go
# If you prefer the allow list template instead of the deny list, see community template:
@@ -184,3 +187,5 @@ test-results/
backend/go.sum
BUILD_NUMBER
scripts/resetDanger.js
LstWrapper/Program_vite_as_Static.txt
scripts/stopPool.go

View File

@@ -9,19 +9,53 @@
"publish": false
},
"hooks": {
"before:init": "node ./scripts/read-build-number.js",
"after:release": "node ./scripts/create-gitea-release.js ${version}"
},
"github": false,
"plugins": {
"@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",
"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}",
"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"]

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,26 @@
# Changelog
All notable changes to LST will be documented in this file.
## [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)
### Bug Fixes

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

85
LstWrapper/Program.cs Normal file
View File

@@ -0,0 +1,85 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System.Net.Http;
var builder = WebApplication.CreateBuilder(args);
// to build the binary dotnet publish -c Release -o ./publish
// Go backend
builder.Services.AddHttpClient("GoBackend", client =>
{
client.BaseAddress = new Uri("http://localhost:8080");
client.Timeout = TimeSpan.FromSeconds(30);
});
// Node frontend
builder.Services.AddHttpClient("NodeFrontend", client =>
{
client.BaseAddress = new Uri("http://localhost:3000");
client.Timeout = TimeSpan.FromSeconds(30);
});
var app = builder.Build();
app.UseStaticFiles();
app.Use((Func<HttpContext, Func<Task>, Task>)(async (context, next) =>
{
var clientFactory = context.RequestServices.GetRequiredService<IHttpClientFactory>();
var isApiRequest =
context.Request.Path.StartsWithSegments("/api") ||
context.Request.Path.StartsWithSegments("/graphql") ||
context.Request.Path.StartsWithSegments("/auth") ||
!context.Request.Method.Equals("GET", StringComparison.OrdinalIgnoreCase);
var client = clientFactory.CreateClient(isApiRequest ? "GoBackend" : "NodeFrontend");
try
{
var requestUri = context.Request.Path + context.Request.QueryString;
var request = new HttpRequestMessage(
new HttpMethod(context.Request.Method),
requestUri);
foreach (var header in context.Request.Headers)
{
if (!request.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray()))
{
request.Content ??= new StreamContent(context.Request.Body);
request.Content.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray());
}
}
if (context.Request.ContentLength > 0 || context.Request.Headers.ContainsKey("Transfer-Encoding"))
{
request.Content = new StreamContent(context.Request.Body);
}
var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, context.RequestAborted);
context.Response.StatusCode = (int)response.StatusCode;
foreach (var header in response.Headers)
{
context.Response.Headers[header.Key] = header.Value.ToArray();
}
foreach (var header in response.Content.Headers)
{
context.Response.Headers[header.Key] = header.Value.ToArray();
}
context.Response.Headers.Remove("transfer-encoding");
await response.Content.CopyToAsync(context.Response.Body);
}
catch (HttpRequestException ex)
{
context.Response.StatusCode = isApiRequest ? 503 : 502;
await context.Response.WriteAsync($"{(isApiRequest ? "Go API" : "Frontend")} unavailable: {ex.Message}");
}
}));
app.Run();

View File

@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5015",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7208;http://localhost:5015",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

15
LstWrapper/web.config Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet"
arguments=".\LstWrapper.dll"
stdoutLogEnabled="true"
stdoutLogFile=".\logs\stdout"
hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>

View File

@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<p>The new begining to lst</p>
</body>
</html>

View File

@@ -11,10 +11,19 @@ func main() {
fmt.Println("Welcome to lst backend where all the fun happens.")
r := gin.Default()
r.GET("/", errorLoc)
r.GET("/api/ping", func(c *gin.Context) {
c.JSON(200, gin.H{"message": "pong"})
})
r.Any("/api", errorApiLoc)
r.Any("/", errorLoc)
r.Run(":8080")
}
func errorLoc(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "welcome to lst system you might have just encountered an incorrect area of the app"})
c.JSON(http.StatusBadRequest, gin.H{"message": "welcome to lst system you might have just encountered an incorrect area of the app"})
}
func errorApiLoc(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"message": "looks like you have encountered an api route that dose not exist"})
}

View File

@@ -1,21 +1,27 @@
---
services:
lst_backend:
# build: . # Tell Docker Compose to build the image using the Dockerfile in the current directory
image: git.tuffraid.net/cowch/logistics_support_tool:backend-latest
container_name: lst_backend # A friendly name for your running container
volumes:
- /path/to/frontend/backend:/data
ports:
- "8080:8080"
restart: unless-stopped
lst_backend:
# build: . # Tell Docker Compose to build the image using the Dockerfile in the current directory
build:
context: .
dockerfile: ./backend/Dockerfile
image: git.tuffraid.net/cowch/logistics_support_tool:backend-latest
container_name: lst_backend # A friendly name for your running container
volumes:
- /path/to/backend/data:/data
ports:
- "8080:8080"
restart: unless-stopped
lst_frontend:
# build: . # Tell Docker Compose to build the image using the Dockerfile in the current directory
image: git.tuffraid.net/cowch/logistics_support_tool:frontend-latest
container_name: lst_frontend # A friendly name for your running container
volumes:
- /path/to/frontend/data:/data
ports:
- "3120:3000"
restart: unless-stopped
lst_frontend:
# build: . # Tell Docker Compose to build the image using the Dockerfile in the current directory
build:
context: .
dockerfile: ./frontend/Dockerfile
image: git.tuffraid.net/cowch/logistics_support_tool:frontend-latest
container_name: lst_frontend # A friendly name for your running container
volumes:
- /path/to/frontend/data:/data
ports:
- "3120:3000"
restart: unless-stopped

4
package-lock.json generated
View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "logistics_support_tool",
"version": "0.0.1-alpha.1",
"version": "0.0.1-alpha.3",
"description": "This is the new logisitcs support tool",
"private": true,
"main": "index.js",
@@ -11,8 +11,7 @@
"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": "powershell -File ./scripts/dockerBuild.ps1",
"release:createZip": "powershell -File ./scripts/release.ps1",
"release:gitea": "node ./scripts/create-gitea-release.js",
"createZip": "powershell -File ./scripts/createZip.ps1",
"release": "release-it --verbose --non-interactive --preRelease=alpha",
"commit": "cz"
},

View File

@@ -21,7 +21,7 @@ if (Test-Path $envFile) {
}
if (-not $env:BUILD_NAME) {
Write-Warning "BUILD_NAME environment variable is not set. Cannot create BUILD_NUMBER file"
Write-Warning "BUILD_NAME environment variable is not set. Please make sure you have entered the correct info the env"
exit 1
}
@@ -111,10 +111,44 @@ function Update-BuildNumber {
Write-Host "Fronend build finished successfully."
Pop-Location
Update-BuildNumber
Write-Host "Building wrapper"
Push-Location $rootDir/LstWrapper
dotnet publish -c Release -o ./publish
Pop-Location
try {
Update-BuildNumber
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
if ($LASTEXITCODE -ne 0) {
throw "Failed to create Gitea release"
}
}
} catch {
Write-Warning "Release process failed: $_"
exit 1
}
break

View File

@@ -1,252 +1,124 @@
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 path from "path";
import { fileURLToPath } from "url";
import fetch from "node-fetch";
import dotenv from "dotenv";
dotenv.config({ path: "./.env" });
// Resolve the directory of the current script
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Absolute path to BUILD_NUMBER
const buildNumberPath = path.resolve(__dirname, "../BUILD_NUMBER");
// Load build number from BUILD_NUMBER file
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 version = process.argv[2];
if (!version) {
console.error("Version not passed to create-gitea-release.js");
process.exit(1);
}
const fullVersion = `${version}.${buildNumber}`;
const { GITEA_URL, GITEA_USERNAME, GITEA_REPO, GITEA_TOKEN } = process.env;
if (!GITEA_URL || !GITEA_USERNAME || !GITEA_REPO || !GITEA_TOKEN) {
console.error("Missing required environment variables");
process.exit(1);
}
// Step 1: Generate or update CHANGELOG.md
// 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 () => {
const getChangelogContent = async () => {
try {
const changelogPath = path.resolve(__dirname, "../CHANGELOG.md");
console.log(`Attempting to read changelog from: ${changelogPath}`); // Debugging line
const changelogContent = await fs.readFile(changelogPath, "utf8");
console.log(
"Changelog content read successfully (first 200 chars):",
changelogContent.substring(0, 200)
); // Debugging line
const content = await fs.readFile(changelogPath, "utf8");
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 = [];
let inLatestRelease = false;
let foundFirstHeading = false;
// 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
if (inLatestRelease) {
latestReleaseNotes.push(trimmedLine); // Use trimmedLine here
}
if (sections.length < 2) {
console.warn("Couldn't find version section in changelog");
return "No changelog content available.";
}
// 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.";
}
// The first section is the latest version
const latestSection = sections[1];
return latestSection.trim();
} catch (err) {
console.error("Error reading or parsing CHANGELOG.md:", err);
throw err;
console.error("Error reading changelog:", err);
return "No changelog content available.";
}
};
const releaseNotes = await getLatestChangelog();
// Step 3: Create or update Gitea release
const createOrUpdateRelease = async () => {
const createOrUpdateRelease = async (releaseNotes) => {
const tagName = `v${version}`;
const apiBase = `https://${GITEA_URL}/api/v1/repos/${GITEA_USERNAME}/${GITEA_REPO}`;
const existing = await fetch(`${apiBase}/releases/tags/${tagName}`, {
headers: { Authorization: `token ${GITEA_TOKEN}` },
});
try {
const existing = await fetch(`${apiBase}/releases/tags/${tagName}`, {
headers: { Authorization: `token ${GITEA_TOKEN}` },
});
let release;
if (existing.ok) {
// Update existing release
const existingRelease = await existing.json();
console.log(`Updating existing release ${tagName}`);
if (existing.ok) {
const existingRelease = await existing.json();
console.log(`Release ${tagName} already exists. Updating it.`);
const response = await fetch(
`${apiBase}/releases/${existingRelease.id}`,
{
method: "PATCH",
headers: {
Authorization: `token ${GITEA_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: tagName,
body: releaseNotes,
draft: false,
prerelease: false, // Change to true if you want prereleases
}),
}
);
const updateResponse = await fetch(
`${apiBase}/releases/${existingRelease.id}`,
{
method: "PATCH",
if (!response.ok)
throw new Error(`Failed to update release: ${response.status}`);
const release = await response.json();
console.log("Release updated:", release.html_url);
return release;
} else if (existing.status === 404) {
// Create new release
console.log(`Creating new release ${tagName}`);
const response = await fetch(`${apiBase}/releases`, {
method: "POST",
headers: {
Authorization: `token ${GITEA_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: tagName,
tag_name: tagName,
name: `Release ${version}`,
body: releaseNotes,
draft: false,
prerelease: true,
prerelease: false, // Change to true if you want prereleases
}),
}
);
});
if (!updateResponse.ok) {
const errorText = await updateResponse.text();
throw new Error(
`Failed to update release: ${updateResponse.status} - ${errorText}`
);
if (!response.ok)
throw new Error(`Failed to create release: ${response.status}`);
const release = await response.json();
console.log("Release created:", release.html_url);
return release;
} else {
throw new Error(`Failed to check release: ${existing.status}`);
}
release = await updateResponse.json();
console.log("Release updated:", release.html_url || release.url);
} else if (existing.status === 404) {
const createResponse = await fetch(`${apiBase}/releases`, {
method: "POST",
headers: {
Authorization: `token ${GITEA_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
tag_name: tagName,
name: `Release ${fullVersion}`,
body: releaseNotes,
draft: false,
prerelease: true,
}),
});
if (!createResponse.ok) {
const errorText = await createResponse.text();
throw new Error(
`Failed to create release: ${createResponse.status} - ${errorText}`
);
}
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}`
);
} catch (error) {
console.error("Error in createOrUpdateRelease:", error);
throw error;
}
return release;
};
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 () => {
try {
const release = await createOrUpdateRelease();
// await uploadAsset(release); // fix this later and just update the readme.
} catch (err) {
console.error(err);
const releaseNotes = await getChangelogContent();
await createOrUpdateRelease(releaseNotes);
} catch (error) {
console.error("Release failed:", error);
process.exit(1);
}
})();

View File

@@ -66,17 +66,38 @@ if ($existingZips.Count -gt $keepReleases) {
Write-Host "`nPackaging release: $($zipName)"
$filesToInclude = @(
"backend\lst_backend.exe",
"frontend\.nitro",
"frontend\.tanstack",
"frontend\.output",
"frontend\public",
"package.json",
"CHANGELOG.md",
"README.md"
# Create a temporary staging directory
$tempStageDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP "lst_staging") -Force
# Copy files to organized structure
$filesToCopy = @(
@{ Source = "backend\lst_backend.exe"; Destination = "backend\lst_backend.exe" },
@{ Source = "LstWrapper\publish"; Destination = "lstwrapper\" },
@{ Source = "frontend\.nitro"; Destination = "frontend\.nitro" },
@{ Source = "frontend\.tanstack"; Destination = "frontend\.tanstack" },
@{ Source = "frontend\.output"; Destination = "frontend\.output" },
@{ Source = "frontend\public"; Destination = "frontend\public" },
@{ Source = "package.json"; Destination = "package.json" },
@{ Source = "CHANGELOG.md"; Destination = "CHANGELOG.md" },
@{ Source = "README.md"; Destination = "README.md" }
)
Compress-Archive -Path $filesToInclude -DestinationPath $zipPath
foreach ($file in $filesToCopy) {
$destPath = Join-Path $tempStageDir $file.Destination
New-Item -ItemType Directory -Path (Split-Path $destPath -Parent) -Force | Out-Null
Copy-Item -Path $file.Source -Destination $destPath -Recurse -Force
}
Write-Host "`nRelease package created at: $($zipPath)"
# Create the zip from the staged directory
Compress-Archive -Path "$tempStageDir\*" -DestinationPath $zipPath
# Clean up temporary directory
Remove-Item $tempStageDir -Recurse -Force
Write-Host "`nRelease package created at: $($zipPath)"
Write-Host "Organized structure:"
Write-Host "- backend/"
Write-Host "- frontend/"
Write-Host "- lstwrapper/"
Write-Host "- CHANGELOG.md"
Write-Host "- README.md"

View File

@@ -1,6 +1,6 @@
Write-Host "Building the docker images for front and backend"
docker build -t logistics_support_tool:frontend-latest -f ../frontend/Dockerfile ../frontend
docker build -t logistics_support_tool:backend-latest -f ../backend/Dockerfile ../backend
docker build -t logistics_support_tool:frontend-latest -f ./frontend/Dockerfile --no-cache ./frontend
docker build -t logistics_support_tool:backend-latest -f ./backend/Dockerfile --no-cache ./backend
Write-Host "Tagging the builds with latest this is for testing test basically."
docker tag logistics_support_tool:frontend-latest git.tuffraid.net/cowch/logistics_support_tool:frontend-latest

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));

46
scripts/iisControls.ps1 Normal file
View File

@@ -0,0 +1,46 @@
param (
[string]$ServerName,
[string]$AppPoolName,
[string]$StopOrStart
)
write-host $StopOrStart
if ($StopOrStart -eq "stop") {
Invoke-Command -ComputerName $ServerName -Credential $cred -ScriptBlock {
param($AppPoolName)
Import-Module WebAdministration
Write-Host "Stopping AppPool '$AppPoolName' on $($env:COMPUTERNAME)"
try {
Stop-WebAppPool -Name $AppPoolName -ErrorAction Stop
Start-Sleep -Seconds 2
$state = (Get-WebAppPoolState -Name $AppPoolName).Value
Write-Host "Result: $state"
} catch {
Write-Error $_.Exception.Message
exit 1
}
} -ArgumentList $AppPoolName
}
if ($StopOrStart -eq "start"){
Invoke-Command -ComputerName $ServerName -Credential $cred -ScriptBlock {
param($AppPoolName)
Import-Module WebAdministration
Write-Host "Starting AppPool '$AppPoolName' on $($env:COMPUTERNAME)"
try {
Start-WebAppPool -Name $AppPoolName
Start-Sleep -Seconds 2
$state = (Get-WebAppPoolState -Name $AppPoolName).Value
Write-Host "Result: $state"
} catch {
Write-Error $_.Exception.Message
exit 1
}
} -ArgumentList $AppPoolName
}

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();