mirror of
https://github.com/screentinker/screentinker.git
synced 2026-06-15 02:33:15 -06:00
- server/version.js: shared version helper that reads the root VERSION file once (fallback 0.0.0). Replaces the stale hardcoded 1.2.0 / 1.5.1 / 1.0.0 fallbacks in /api/version, /api/update/check, and /api/status. - config.js: DATA_DIR / DB_PATH / UPLOADS_DIR / CERTS_DIR env overrides for the db, uploads, and certs/jwt-secret locations. Unset resolves to exactly the legacy in-repo paths, so existing installs (including production) are byte-for-byte unchanged. Guarded by test/config-paths.test.js. - package.json: rename remote-display-server -> screentinker (+ lockfile name). - scripts/bump-version.sh: one-shot bump across VERSION, package.json (+lock), android (versionName and versionCode + 1), and the tizen widget version; makes one commit plus an annotated tag; prints the push command, never pushes. - .gitignore: global *.db / *.db-wal / *.db-shm / *.db.* so no database file (including .db.devbak backups, at any path) can be committed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
45 lines
2.2 KiB
JavaScript
45 lines
2.2 KiB
JavaScript
// Hard backward-compat guarantee: with DATA_DIR (and the per-path overrides)
|
|
// UNSET, config must resolve to exactly the legacy in-repo locations, so existing
|
|
// installs - including production - see zero behavior change. Also verifies the
|
|
// overrides actually relocate state (the Docker /data case).
|
|
const { test } = require('node:test');
|
|
const assert = require('node:assert');
|
|
const path = require('node:path');
|
|
|
|
const PATH_ENV = ['DATA_DIR', 'DB_PATH', 'UPLOADS_DIR', 'CERTS_DIR'];
|
|
const serverDir = path.join(__dirname, '..'); // config.js lives in server/
|
|
|
|
function loadConfig(overrides) {
|
|
PATH_ENV.forEach((k) => delete process.env[k]);
|
|
process.env.JWT_SECRET = 'test-secret'; // short-circuits the secret-file-writing IIFE (no FS side effects)
|
|
Object.assign(process.env, overrides || {});
|
|
delete require.cache[require.resolve('../config')];
|
|
return require('../config');
|
|
}
|
|
|
|
test('UNSET -> exactly the legacy in-repo paths (zero change for existing installs)', () => {
|
|
const c = loadConfig();
|
|
assert.strictEqual(c.dataDir, serverDir);
|
|
assert.strictEqual(c.dbPath, path.join(serverDir, 'db', 'remote_display.db'));
|
|
assert.strictEqual(c.uploadsDir, path.join(serverDir, 'uploads'));
|
|
assert.strictEqual(c.contentDir, path.join(serverDir, 'uploads', 'content'));
|
|
assert.strictEqual(c.screenshotsDir, path.join(serverDir, 'uploads', 'screenshots'));
|
|
assert.strictEqual(c.certsDir, path.join(serverDir, 'certs'));
|
|
});
|
|
|
|
test('DATA_DIR relocates db / uploads / certs onto the volume', () => {
|
|
const c = loadConfig({ DATA_DIR: '/data' });
|
|
assert.strictEqual(c.dbPath, path.join('/data', 'db', 'remote_display.db'));
|
|
assert.strictEqual(c.uploadsDir, path.join('/data', 'uploads'));
|
|
assert.strictEqual(c.contentDir, path.join('/data', 'uploads', 'content'));
|
|
assert.strictEqual(c.screenshotsDir, path.join('/data', 'uploads', 'screenshots'));
|
|
assert.strictEqual(c.certsDir, path.join('/data', 'certs'));
|
|
});
|
|
|
|
test('individual overrides win over DATA_DIR', () => {
|
|
const c = loadConfig({ DATA_DIR: '/data', DB_PATH: '/custom/app.db', UPLOADS_DIR: '/media' });
|
|
assert.strictEqual(c.dbPath, '/custom/app.db');
|
|
assert.strictEqual(c.uploadsDir, '/media');
|
|
assert.strictEqual(c.contentDir, path.join('/media', 'content'));
|
|
});
|