19 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
21 changed files with 505 additions and 259 deletions

5
.gitignore vendored
View File

@@ -4,6 +4,9 @@ frontend/.tanstack/
frontend/.output/ frontend/.output/
frontend/.nitro/ frontend/.nitro/
releases/ releases/
LstWrapper/bin
LstWrapper/publish
LstWrapper/obj
# ---> 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:
@@ -184,3 +187,5 @@ test-results/
backend/go.sum backend/go.sum
BUILD_NUMBER BUILD_NUMBER
scripts/resetDanger.js scripts/resetDanger.js
LstWrapper/Program_vite_as_Static.txt
scripts/stopPool.go

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,26 @@
# Changelog # 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) ## [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

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

@@ -16,10 +16,14 @@ func main() {
c.JSON(200, gin.H{"message": "pong"}) c.JSON(200, gin.H{"message": "pong"})
}) })
r.Any("/api", errorApiLoc)
r.Any("/", errorLoc) r.Any("/", errorLoc)
r.Run(":8080") r.Run(":8080")
} }
func errorLoc(c *gin.Context) { 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

@@ -2,16 +2,22 @@
services: services:
lst_backend: lst_backend:
# build: . # Tell Docker Compose to build the image using the Dockerfile in the current directory # 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 image: git.tuffraid.net/cowch/logistics_support_tool:backend-latest
container_name: lst_backend # A friendly name for your running container container_name: lst_backend # A friendly name for your running container
volumes: volumes:
- /path/to/frontend/backend:/data - /path/to/backend/data:/data
ports: ports:
- "8080:8080" - "8080:8080"
restart: unless-stopped restart: unless-stopped
lst_frontend: lst_frontend:
# build: . # Tell Docker Compose to build the image using the Dockerfile in the current directory # 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 image: git.tuffraid.net/cowch/logistics_support_tool:frontend-latest
container_name: lst_frontend # A friendly name for your running container container_name: lst_frontend # A friendly name for your running container
volumes: volumes:

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "logistics_support_tool", "name": "logistics_support_tool",
"version": "0.0.3-alpha.22", "version": "0.0.1-alpha.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "logistics_support_tool", "name": "logistics_support_tool",
"version": "0.0.3-alpha.22", "version": "0.0.1-alpha.3",
"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.3",
"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

@@ -21,7 +21,7 @@ if (Test-Path $envFile) {
} }
if (-not $env:BUILD_NAME) { 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 exit 1
} }
@@ -111,10 +111,44 @@ function Update-BuildNumber {
Write-Host "Fronend build finished successfully." Write-Host "Fronend build finished successfully."
Pop-Location Pop-Location
Write-Host "Building wrapper"
Push-Location $rootDir/LstWrapper
dotnet publish -c Release -o ./publish
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
if ($LASTEXITCODE -ne 0) {
throw "Failed to create Gitea release"
}
}
} catch {
Write-Warning "Release process failed: $_"
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

@@ -66,17 +66,38 @@ if ($existingZips.Count -gt $keepReleases) {
Write-Host "`nPackaging release: $($zipName)" Write-Host "`nPackaging release: $($zipName)"
$filesToInclude = @( # Create a temporary staging directory
"backend\lst_backend.exe", $tempStageDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP "lst_staging") -Force
"frontend\.nitro",
"frontend\.tanstack", # Copy files to organized structure
"frontend\.output", $filesToCopy = @(
"frontend\public", @{ Source = "backend\lst_backend.exe"; Destination = "backend\lst_backend.exe" },
"package.json", @{ Source = "LstWrapper\publish"; Destination = "lstwrapper\" },
"CHANGELOG.md", @{ Source = "frontend\.nitro"; Destination = "frontend\.nitro" },
"README.md" @{ 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
}
# 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 "`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

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