Compare commits
4 Commits
dd88f258ed
...
df85a30dff
| Author | SHA1 | Date | |
|---|---|---|---|
| df85a30dff | |||
| d5e9176d53 | |||
| 45b1f7c0a6 | |||
| eaac8143e9 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@ server/dist
|
||||
dist
|
||||
apiDocsLSTV2
|
||||
testFiles
|
||||
builds
|
||||
|
||||
|
||||
# ---> Node
|
||||
|
||||
21
package-lock.json
generated
21
package-lock.json
generated
@@ -13,6 +13,7 @@
|
||||
"@hono/zod-openapi": "^0.18.4",
|
||||
"@scalar/hono-api-reference": "^0.5.175",
|
||||
"@types/jsonwebtoken": "^9.0.8",
|
||||
"adm-zip": "^0.5.16",
|
||||
"axios": "^1.7.9",
|
||||
"bcrypt": "^5.1.1",
|
||||
"compression": "^1.8.0",
|
||||
@@ -34,6 +35,7 @@
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/adm-zip": "^0.5.7",
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/mssql": "^9.1.7",
|
||||
@@ -2504,6 +2506,16 @@
|
||||
"integrity": "sha512-7qSgZbincDDDFyRweCIEvZULFAw5iz/DeunhvuxpL31nfntX3P4Yd4HkHBRg9H8CdqY1e5WFN1PZIz/REL9MVQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/adm-zip": {
|
||||
"version": "0.5.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/adm-zip/-/adm-zip-0.5.7.tgz",
|
||||
"integrity": "sha512-DNEs/QvmyRLurdQPChqq0Md4zGvPwHerAJYWk9l2jCbD1VPpnzRJorOdiq4zsw09NFbYnhfsoEhWtxIzXpn2yw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/bcrypt": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/bcrypt/-/bcrypt-5.0.2.tgz",
|
||||
@@ -3122,6 +3134,15 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/adm-zip": {
|
||||
"version": "0.5.16",
|
||||
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.16.tgz",
|
||||
"integrity": "sha512-TGw5yVi4saajsSEgz25grObGHEUaDrniwvA2qwSC060KfqGPdglhvPMA2lPIoxs3PQIItj2iag35fONcQqgUaQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/agent-base": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
||||
|
||||
137
package.json
137
package.json
@@ -1,67 +1,74 @@
|
||||
{
|
||||
"name": "fullstack-app",
|
||||
"version": "2.4.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "concurrently -n \"server,frontend\" -c \"#007755,#2f6da3\" \"npm run dev:server\" \"cd frontend && npm run dev\"",
|
||||
"dev:server": "dotenvx run -f .env -- tsx watch server/index.ts",
|
||||
"dev:frontend": "cd frontend && npm run dev",
|
||||
"dev:dbgen": " drizzle-kit generate --config=drizzle-dev.config.ts",
|
||||
"dev:dbmigrate": " drizzle-kit migrate --config=drizzle-dev.config.ts",
|
||||
"build": "npm run build:server && npm run build:frontend",
|
||||
"build:server": "rimraf dist && tsc --build && xcopy server\\scripts dist\\server\\scripts /E /I /Y",
|
||||
"build:frontend": "cd frontend && npm run build",
|
||||
"start": "set NODE_ENV=production && npm run start:server",
|
||||
"start:server": "dotenvx run -f .env -- node dist/server/index.js",
|
||||
"db:generate": "npx drizzle-kit generate",
|
||||
"db:migrate": "npx drizzle-kit push",
|
||||
"deploy": "standard-version --conventional-commits",
|
||||
"commit": "cz",
|
||||
"prodinstall": "npm i --omit=dev && npm run db:migrate"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dotenvx/dotenvx": "^1.38.3",
|
||||
"@hono/node-server": "^1.13.8",
|
||||
"@hono/zod-openapi": "^0.18.4",
|
||||
"@scalar/hono-api-reference": "^0.5.175",
|
||||
"@types/jsonwebtoken": "^9.0.8",
|
||||
"axios": "^1.7.9",
|
||||
"bcrypt": "^5.1.1",
|
||||
"compression": "^1.8.0",
|
||||
"cookie": "^1.0.2",
|
||||
"date-fns": "^4.1.0",
|
||||
"dotenv": "^16.4.7",
|
||||
"drizzle-kit": "^0.30.4",
|
||||
"drizzle-orm": "^0.39.3",
|
||||
"drizzle-zod": "^0.7.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"mssql": "^11.0.1",
|
||||
"nodemailer": "^6.10.0",
|
||||
"nodemailer-express-handlebars": "^7.0.0",
|
||||
"pg": "^8.13.3",
|
||||
"pino": "^9.6.0",
|
||||
"pino-abstract-transport": "^2.0.0",
|
||||
"pino-pretty": "^13.0.0",
|
||||
"postgres": "^3.4.5",
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/mssql": "^9.1.7",
|
||||
"@types/node": "^22.13.5",
|
||||
"@types/pg": "^8.11.11",
|
||||
"concurrently": "^8.2.0",
|
||||
"cz-conventional-changelog": "^3.3.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"rimraf": "^6.0.1",
|
||||
"standard-version": "^9.5.0",
|
||||
"tsx": "^4.7.1",
|
||||
"typescript": "~5.7.3"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-conventional-changelog"
|
||||
}
|
||||
"name": "lstv2",
|
||||
"version": "2.4.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "concurrently -n \"server,frontend\" -c \"#007755,#2f6da3\" \"npm run dev:server\" \"cd frontend && npm run dev\"",
|
||||
"dev:server": "dotenvx run -f .env -- tsx watch server/index.ts",
|
||||
"dev:frontend": "cd frontend && npm run dev",
|
||||
"dev:dbgen": " drizzle-kit generate --config=drizzle-dev.config.ts",
|
||||
"dev:dbmigrate": " drizzle-kit migrate --config=drizzle-dev.config.ts",
|
||||
"build": "npm run build:server && npm run build:frontend",
|
||||
"build:server": "rimraf build && tsc --build && xcopy server\\scripts dist\\server\\scripts /E /I /Y",
|
||||
"build:frontend": "cd frontend && npm run build",
|
||||
"start": "set NODE_ENV=production && npm run start:server",
|
||||
"start:server": "dotenvx run -f .env -- node dist/server/index.js",
|
||||
"db:generate": "npx drizzle-kit generate",
|
||||
"db:migrate": "npx drizzle-kit push",
|
||||
"deploy": "standard-version --conventional-commits",
|
||||
"commit": "cz",
|
||||
"prodinstall": "npm i --omit=dev && npm run db:migrate"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dotenvx/dotenvx": "^1.38.3",
|
||||
"@hono/node-server": "^1.13.8",
|
||||
"@hono/zod-openapi": "^0.18.4",
|
||||
"@scalar/hono-api-reference": "^0.5.175",
|
||||
"@types/jsonwebtoken": "^9.0.8",
|
||||
"adm-zip": "^0.5.16",
|
||||
"axios": "^1.7.9",
|
||||
"bcrypt": "^5.1.1",
|
||||
"compression": "^1.8.0",
|
||||
"cookie": "^1.0.2",
|
||||
"date-fns": "^4.1.0",
|
||||
"dotenv": "^16.4.7",
|
||||
"drizzle-kit": "^0.30.4",
|
||||
"drizzle-orm": "^0.39.3",
|
||||
"drizzle-zod": "^0.7.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"mssql": "^11.0.1",
|
||||
"nodemailer": "^6.10.0",
|
||||
"nodemailer-express-handlebars": "^7.0.0",
|
||||
"pg": "^8.13.3",
|
||||
"pino": "^9.6.0",
|
||||
"pino-abstract-transport": "^2.0.0",
|
||||
"pino-pretty": "^13.0.0",
|
||||
"postgres": "^3.4.5",
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/adm-zip": "^0.5.7",
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/mssql": "^9.1.7",
|
||||
"@types/node": "^22.13.5",
|
||||
"@types/pg": "^8.11.11",
|
||||
"concurrently": "^8.2.0",
|
||||
"cz-conventional-changelog": "^3.3.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"rimraf": "^6.0.1",
|
||||
"standard-version": "^9.5.0",
|
||||
"tsx": "^4.7.1",
|
||||
"typescript": "~5.7.3"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-conventional-changelog"
|
||||
}
|
||||
}
|
||||
},
|
||||
"admConfig": {
|
||||
"build": 2,
|
||||
"dest": "C:\\Users\\matthes01\\Documents\\lstv2\\builds",
|
||||
"src": "C:\\Users\\matthes01\\Documents\\lstv2"
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ param (
|
||||
[string]$dir,
|
||||
[string]$app
|
||||
)
|
||||
# dir is the location of the root folder.
|
||||
|
||||
# Store the original directory
|
||||
$originalDir = Get-Location
|
||||
@@ -23,38 +24,12 @@ if (-not (Test-Path $dir)) {
|
||||
# Navigate to the directory
|
||||
Set-Location -Path $dir
|
||||
|
||||
Write-Host "Cleaning the app."
|
||||
# Run npm run build
|
||||
Write-Host "Running 'npm run build' in directory: $dir"
|
||||
npm run build
|
||||
|
||||
# Function to delete all `dist` and `.turbo` folders recursively
|
||||
function Delete-Folders {
|
||||
param (
|
||||
[string]$folderName
|
||||
)
|
||||
Write-Host "Build completed successfully."
|
||||
|
||||
# Define the directories to search (packages and apps)
|
||||
$searchDirectories = @("/", "frontend")
|
||||
|
||||
foreach ($searchDir in $searchDirectories) {
|
||||
$fullSearchPath = Join-Path -Path $dir -ChildPath $searchDir
|
||||
|
||||
# Check if the directory exists
|
||||
if (Test-Path $fullSearchPath) {
|
||||
# Find all folders matching the name
|
||||
$folders = Get-ChildItem -Path $fullSearchPath -Recurse -Directory -Filter $folderName -ErrorAction SilentlyContinue
|
||||
|
||||
if ($folders) {
|
||||
#Write-Host "Deleting all '$folderName' folders in $fullSearchPath and its subdirectories..."
|
||||
foreach ($folder in $folders) {
|
||||
#Write-Host "Deleting: $($folder.FullName)"
|
||||
Remove-Item -Path $folder.FullName -Recurse -Force
|
||||
}
|
||||
} else {
|
||||
# Write-Host "No '$folderName' folders found in $fullSearchPath and its subdirectories."
|
||||
}
|
||||
} else {
|
||||
# Write-Host "Directory '$fullSearchPath' does not exist."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Delete-Folders -folderName "dist"
|
||||
# Restore the original directory
|
||||
Set-Location -Path $originalDir
|
||||
exit 0
|
||||
155
server/scripts/zipUpBuild.ts
Normal file
155
server/scripts/zipUpBuild.ts
Normal file
@@ -0,0 +1,155 @@
|
||||
import AdmZip from "adm-zip";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import {execSync} from "child_process";
|
||||
import {createLog} from "../services/logger/logger.js";
|
||||
|
||||
// create the ignore list
|
||||
const ignoreList = [
|
||||
"node_modules",
|
||||
"apiDocsLSTV2",
|
||||
"testFiles",
|
||||
".env",
|
||||
".gitignore",
|
||||
".versionrc.json",
|
||||
"drizzle-dev.config.ts",
|
||||
"nssm.exe",
|
||||
// front end ignore
|
||||
"/frontend/node_modules",
|
||||
"fonrtend/.env",
|
||||
"frontend/public",
|
||||
"frontend/src",
|
||||
"frontend/.gitignore",
|
||||
"frontend/eslint.config.js",
|
||||
"frontend/index.html",
|
||||
"frontend/package.json",
|
||||
"frontend/package-lock.json",
|
||||
"frontend/README.md",
|
||||
"frontend/tsconfig.json",
|
||||
"frontend/tsconfig.app.json",
|
||||
"frontend/tsconfig.node.json",
|
||||
"frontend/vite.config.ts",
|
||||
];
|
||||
|
||||
const getAdmInfo = async (appLock: string) => {
|
||||
try {
|
||||
const packagePath = path.join(appLock, "package.json");
|
||||
const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf-8"));
|
||||
//const version = packageJson.version;
|
||||
return packageJson;
|
||||
} catch (error) {
|
||||
createLog("error", "lst", "zipUpBuild", `Error in getting the version: ${error}`);
|
||||
return error;
|
||||
}
|
||||
};
|
||||
|
||||
const shouldIgnore = (itemPath: any) => {
|
||||
const normalizedItemPath = itemPath.replace(/\\/g, "/");
|
||||
|
||||
return ignoreList.some((ignorePattern) => {
|
||||
const normalizedIgnorePatther = ignorePattern.replace(/\\/g, "/");
|
||||
return normalizedItemPath.includes(normalizedIgnorePatther);
|
||||
});
|
||||
};
|
||||
|
||||
const addToZip = (zip: any, currentPath: any, rootPath: any) => {
|
||||
const items = fs.readdirSync(currentPath);
|
||||
|
||||
items.forEach((item) => {
|
||||
const itemPath = path.join(currentPath, item);
|
||||
const relativePath = path.relative(rootPath, itemPath);
|
||||
|
||||
// Skip if the item is in the ignore list
|
||||
if (shouldIgnore(relativePath)) {
|
||||
createLog("info", "lst", "zipUpBuild", `Ignoring: ${relativePath}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const stat = fs.statSync(itemPath);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
// If it's a directory, recursively add its contents
|
||||
addToZip(zip, itemPath, rootPath);
|
||||
} else {
|
||||
// If it's a file, add it to the zip with the preserved folder structure
|
||||
zip.addLocalFile(itemPath, path.dirname(relativePath));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const updateBuildNumber = (appLock: string) => {
|
||||
const packagePath = path.join(appLock, "package.json"); // Adjust path if necessary
|
||||
|
||||
try {
|
||||
// Read package.json
|
||||
const pkgData = fs.readFileSync(packagePath, "utf8");
|
||||
const pkgJson = JSON.parse(pkgData);
|
||||
|
||||
// Ensure admConfig exists
|
||||
if (pkgJson.admConfig && typeof pkgJson.admConfig.build === "number") {
|
||||
// Increment the build number
|
||||
pkgJson.admConfig.build += 1;
|
||||
|
||||
// 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}`);
|
||||
// Auto-commit changes
|
||||
execSync("git add package.json");
|
||||
execSync(`git commit -m "chore: bump build number to ${pkgJson.admConfig.build}"`);
|
||||
} else {
|
||||
createLog("error", "lst", "zipUpBuild", "admConfig.build is missing or not a number");
|
||||
}
|
||||
} catch (error) {
|
||||
createLog("error", "lst", "zipUpBuild", `Error updating build number: ${error}`);
|
||||
}
|
||||
};
|
||||
|
||||
export const createZip = async (appLock: string) => {
|
||||
const app = await getAdmInfo(appLock);
|
||||
const zip = new AdmZip();
|
||||
|
||||
//dest path for this app... hard coded for meow will be in db later
|
||||
const destPath = app.admConfig.dest;
|
||||
|
||||
addToZip(zip, app.admConfig.src, app.admConfig.src);
|
||||
|
||||
// Write the zip file to disk
|
||||
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}`);
|
||||
updateBuildNumber(appLock);
|
||||
|
||||
// only keep the last 5 builds for the type we have.
|
||||
try {
|
||||
const appFiles = fs
|
||||
.readdirSync(destPath)
|
||||
.filter((file) => file.startsWith(app.name)) // Ensure only backend files are matched
|
||||
.map((file) => ({
|
||||
name: file,
|
||||
time: fs.statSync(path.join(destPath, file)).mtime.getTime(),
|
||||
}))
|
||||
.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)}`);
|
||||
|
||||
if (appFiles.length > 5) {
|
||||
appFiles.slice(0, -5).forEach((file) => {
|
||||
const filePath = path.join(destPath, file.name);
|
||||
try {
|
||||
fs.unlinkSync(filePath);
|
||||
createLog("info", "lst", "zipUpBuild", `Deleted: ${file.name}`);
|
||||
} catch (error: any) {
|
||||
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}`);
|
||||
}
|
||||
};
|
||||
|
||||
createZip("C:\\Users\\matthes01\\Documents\\lstv2");
|
||||
@@ -15,7 +15,7 @@ export const initializeProdPool = async () => {
|
||||
|
||||
if (!serverUp) {
|
||||
createLog("error", "lst", "server", `The sql ${dbServer[0].value} is not reachable`);
|
||||
return;
|
||||
return {success: false, message: `The sql ${dbServer[0].value} is not reachable`};
|
||||
}
|
||||
if (!installed) {
|
||||
createLog("info", "lst", "sqlProd", "The server was not installed will reconnect in 5 seconds");
|
||||
|
||||
Reference in New Issue
Block a user