- Rename MediaConfig -> ProjectConfigurator throughout; drop the Parameters
tab/page; rename the Mounts tab to Projects and restructure it into three
sections: Central services, Main services, Third-party services
- Add a self-describe contract (GET /api/info returning name/tabs/mountTypes)
and a server-side discovery proxy (POST /api/discover-service) so adding a
main service only requires a URL
- Add ProjectConfigurator HA: multiple instances now sync their settings with
each other (GET /api/settings/export, POST /api/settings/sync, a periodic
background puller), last-write-wins per key by updated_at
- Add a generic, project-agnostic file-storage API on CarrierNode
(GET/POST/DELETE /api/mount/{project}/{type}[/*]) driven by the same
configured_mounts data the Projects workspace already writes, usable by any
registered project, not just the media family
- Add last_login_at tracking to the shared auth Store/User (schema, queries,
UpdateLastLogin) and surface it through the shared web-ui ManagedUser type
and UserManagement component
- Retire the "MediaCollection" name: Go module -> repos.gfranz.ch/Gabriel20xx/shared/media-backend,
binary -> mediabackend, session cookie default -> "session", media-webui
merged into webui, media-shared-assets renamed to legacy-assets and pruned
to the one file MediaDesktop still uses
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
143 lines
4.4 KiB
JavaScript
143 lines
4.4 KiB
JavaScript
#!/usr/bin/env node
|
|
import fs from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
const repoRoot = path.resolve(__dirname, '..', '..');
|
|
|
|
const registryBase = 'https://registry.npmjs.org';
|
|
const sections = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
|
|
|
|
function shouldSkipSpec(spec) {
|
|
if (!spec) return true;
|
|
const lower = spec.toLowerCase();
|
|
return (
|
|
lower.startsWith('file:') ||
|
|
lower.startsWith('workspace:') ||
|
|
lower.startsWith('link:') ||
|
|
lower.startsWith('github:') ||
|
|
lower.startsWith('git+') ||
|
|
lower.startsWith('http://') ||
|
|
lower.startsWith('https://') ||
|
|
lower.startsWith('npm:')
|
|
);
|
|
}
|
|
|
|
function isSimpleRange(spec) {
|
|
if (!spec) return false;
|
|
if (spec === '*' || spec === 'latest') return true;
|
|
if (spec.includes(' ') || spec.includes('||')) return false;
|
|
return /^[~^]?\d+(\.\d+){0,2}([-.][0-9A-Za-z-.]+)?$/.test(spec);
|
|
}
|
|
|
|
function buildNextSpec(currentSpec, latest) {
|
|
if (currentSpec === '*' || currentSpec === 'latest') {
|
|
return `^${latest}`;
|
|
}
|
|
if (currentSpec.startsWith('~')) return `~${latest}`;
|
|
if (currentSpec.startsWith('^')) return `^${latest}`;
|
|
return `^${latest}`;
|
|
}
|
|
|
|
async function fetchLatestVersion(pkgName) {
|
|
const encoded = encodeURIComponent(pkgName);
|
|
const res = await fetch(`${registryBase}/${encoded}`);
|
|
if (!res.ok) {
|
|
throw new Error(`Failed to fetch ${pkgName}: ${res.status} ${res.statusText}`);
|
|
}
|
|
const data = await res.json();
|
|
const latest = data?.['dist-tags']?.latest;
|
|
if (!latest) {
|
|
throw new Error(`Missing dist-tags.latest for ${pkgName}`);
|
|
}
|
|
return latest;
|
|
}
|
|
|
|
async function loadJson(filePath) {
|
|
const raw = await fs.readFile(filePath, 'utf8');
|
|
return JSON.parse(raw);
|
|
}
|
|
|
|
async function saveJson(filePath, data) {
|
|
const next = JSON.stringify(data, null, 2) + '\n';
|
|
await fs.writeFile(filePath, next, 'utf8');
|
|
}
|
|
|
|
async function updatePackageJson(packageJsonPath) {
|
|
const pkg = await loadJson(packageJsonPath);
|
|
let changed = false;
|
|
const changes = [];
|
|
|
|
for (const section of sections) {
|
|
const deps = pkg[section];
|
|
if (!deps) continue;
|
|
|
|
const entries = Object.entries(deps);
|
|
for (const [name, spec] of entries) {
|
|
if (shouldSkipSpec(spec) || !isSimpleRange(spec)) continue;
|
|
let latest;
|
|
try {
|
|
latest = await fetchLatestVersion(name);
|
|
} catch (err) {
|
|
console.warn(`[skip] ${name}: ${err.message}`);
|
|
continue;
|
|
}
|
|
const nextSpec = buildNextSpec(spec, latest);
|
|
if (nextSpec !== spec) {
|
|
deps[name] = nextSpec;
|
|
changed = true;
|
|
changes.push({ name, from: spec, to: nextSpec, section });
|
|
}
|
|
}
|
|
}
|
|
|
|
if (changed) {
|
|
await saveJson(packageJsonPath, pkg);
|
|
}
|
|
|
|
return { changed, changes };
|
|
}
|
|
|
|
// this repo has no root package.json / npm workspaces (unlike the monorepo this was extracted
|
|
// from), so there's no "workspaces" array to discover packages from. webui/ is the only local npm
|
|
// package whose dependency versions this repo owns and should bump directly. shared/package.json
|
|
// is intentionally excluded: it's a vendored, byte-for-byte copy synced in from the separate
|
|
// shared repo (see scripts/sync-shared.mjs) and any local edit to it would just be overwritten by
|
|
// the next sync — dependency bumps for shared/ belong upstream in that repo instead.
|
|
const LOCAL_PACKAGE_DIRS = ['webui'];
|
|
|
|
async function main() {
|
|
const packageJsonPaths = LOCAL_PACKAGE_DIRS.map(dir => path.join(repoRoot, dir, 'package.json'));
|
|
|
|
const results = [];
|
|
for (const pkgPath of packageJsonPaths) {
|
|
try {
|
|
const result = await updatePackageJson(pkgPath);
|
|
results.push({ pkgPath, ...result });
|
|
} catch (err) {
|
|
console.error(`[error] ${pkgPath}: ${err.message}`);
|
|
}
|
|
}
|
|
|
|
const updated = results.filter(r => r.changed);
|
|
const totalChanges = updated.reduce((sum, r) => sum + r.changes.length, 0);
|
|
|
|
console.log(`Updated ${updated.length} package.json file(s).`);
|
|
console.log(`Total dependency updates: ${totalChanges}`);
|
|
|
|
for (const { pkgPath, changes } of updated) {
|
|
const rel = path.relative(repoRoot, pkgPath);
|
|
console.log(`\n${rel}`);
|
|
for (const change of changes) {
|
|
console.log(` ${change.section}: ${change.name} ${change.from} -> ${change.to}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
main().catch(err => {
|
|
console.error(err);
|
|
process.exitCode = 1;
|
|
});
|