Restructure project as Worldshaper

This commit is contained in:
Andraxion 2026-06-26 20:30:30 -04:00
parent ab891a315c
commit b4dbd4ee8e
583 changed files with 279 additions and 189269 deletions

View file

@ -11,6 +11,10 @@ const removableDirs = [
"Current",
"tmp",
".codex-logs",
".playwright-cli",
"output",
"backups",
"Release",
];
const removableFiles = [
@ -28,13 +32,6 @@ const removableFiles = [
".tmp-map-editor-vite.log",
];
const backupRetentionByPrefix = new Map([
["maps", 5],
["npcs", 5],
["tiles", 8],
["sprites", 5],
]);
function toAbsolute(relativePath) {
return path.join(projectRoot, relativePath);
}
@ -65,54 +62,6 @@ function safeRemoveFile(relativePath, removed) {
}
}
function parseBackupGroup(fileName) {
const match = /^([a-z_]+)-\d{4}-\d{2}-\d{2}T.*\.json$/i.exec(fileName);
return match ? match[1].toLowerCase() : null;
}
function pruneBackups() {
const backupsDir = toAbsolute("backups");
const removed = [];
if (!fs.existsSync(backupsDir)) {
return removed;
}
const files = fs.readdirSync(backupsDir, { withFileTypes: true })
.filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".json"))
.map((entry) => ({
name: entry.name,
path: path.join(backupsDir, entry.name),
group: parseBackupGroup(entry.name),
stat: fs.statSync(path.join(backupsDir, entry.name)),
}));
const grouped = new Map();
files.forEach((file) => {
if (!file.group) {
return;
}
if (!grouped.has(file.group)) {
grouped.set(file.group, []);
}
grouped.get(file.group).push(file);
});
grouped.forEach((groupFiles, group) => {
const keepCount = backupRetentionByPrefix.get(group) ?? 3;
const sorted = groupFiles.sort((a, b) => b.stat.mtimeMs - a.stat.mtimeMs);
sorted.slice(keepCount).forEach((file) => {
try {
fs.rmSync(file.path, { force: true });
removed.push(path.join("backups", file.name));
} catch {
// Ignore any locked backup files.
}
});
});
return removed;
}
function main() {
const removedDirs = [];
const removedFiles = [];
@ -120,12 +69,9 @@ function main() {
removableDirs.forEach((dir) => safeRemoveDir(dir, removedDirs));
removableFiles.forEach((file) => safeRemoveFile(file, removedFiles));
const removedBackups = pruneBackups();
const summary = {
removedDirs,
removedFiles,
removedBackups,
};
process.stdout.write(`${JSON.stringify(summary, null, 2)}\n`);

View file

@ -1,11 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
APP_DIR="/srv/content-editor-v2/app"
GIT_DIR="/srv/content-editor-v2/repo.git"
CONTENT_ROOT="/srv/content-editor-v2/shared/content"
APP_DIR="/srv/worldshaper/app"
GIT_DIR="/srv/worldshaper/repo.git"
CONTENT_ROOT="/srv/worldshaper/shared/content"
PORT="5180"
APP_NAME="content-editor-v2"
APP_NAME="worldshaper"
echo "[deploy] checkout"
git --work-tree="$APP_DIR" --git-dir="$GIT_DIR" checkout -f