Ignore local storage; admin users NIP-05, media, events, footer updates
- Add /storage/ and /backend/storage/ to .gitignore - Track meetup time helper, logo asset, and assorted frontend/backend fixes
This commit is contained in:
@@ -3,16 +3,45 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import sharp from 'sharp';
|
||||
|
||||
/** Walk up from cwd until we find backend + frontend package.json (monorepo root). */
|
||||
function findMonorepoRoot(start: string): string {
|
||||
let dir = path.resolve(start);
|
||||
for (let i = 0; i < 8; i++) {
|
||||
if (
|
||||
fs.existsSync(path.join(dir, 'backend', 'package.json')) &&
|
||||
fs.existsSync(path.join(dir, 'frontend', 'package.json'))
|
||||
) {
|
||||
return dir;
|
||||
}
|
||||
const parent = path.dirname(dir);
|
||||
if (parent === dir) break;
|
||||
dir = parent;
|
||||
}
|
||||
return path.resolve(start, '..');
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve relative MEDIA_STORAGE_PATH against monorepo root — matches
|
||||
* `backend/src/api/media.ts` (REPO_ROOT + relative path).
|
||||
*/
|
||||
function resolveMediaStoragePathFromEnv(envPath: string): string {
|
||||
if (path.isAbsolute(envPath)) {
|
||||
return envPath;
|
||||
}
|
||||
return path.resolve(findMonorepoRoot(process.cwd()), envPath);
|
||||
}
|
||||
|
||||
/** Resolve at request time so systemd / production env is visible (avoid build-time inlining). */
|
||||
function getMediaStorageRoot(): string {
|
||||
const envPath = process.env['MEDIA_STORAGE_PATH'];
|
||||
if (envPath) {
|
||||
return path.resolve(envPath);
|
||||
return resolveMediaStoragePathFromEnv(envPath);
|
||||
}
|
||||
const cwd = process.cwd();
|
||||
const root = findMonorepoRoot(process.cwd());
|
||||
// Prefer repo-root `storage/media` first — matches backend default in `backend/src/api/media.ts`.
|
||||
const candidates = [
|
||||
path.resolve(cwd, '../backend/storage/media'),
|
||||
path.resolve(cwd, '../storage/media'),
|
||||
path.join(root, 'storage', 'media'),
|
||||
path.join(root, 'backend', 'storage', 'media'),
|
||||
];
|
||||
for (const dir of candidates) {
|
||||
if (fs.existsSync(dir)) {
|
||||
|
||||
Reference in New Issue
Block a user