CI / test (ubuntu-latest, node 22) (push) Failing after 33m10s
CI / test (ubuntu-latest, node 24) (push) Failing after 34m41s
CI / tooling (lint, imports, typecheck) (push) Failing after 36m11s
CI / test (windows-latest, node 22) (push) Canceled after 0s
CI / test (windows-latest, node 24) (push) Canceled after 0s
45 lines
2.4 KiB
JavaScript
45 lines
2.4 KiB
JavaScript
// .gitignore keeps per-machine state out of the repository (and so out of the release packages, which ship tracked
|
|
// files only: tools/package.mjs). GitHub #258: a local npm cache (`npm_config_cache=./.npm-cache`, `npm ci --cache
|
|
// .npm-cache`) must never be committed by any contributor. The opt-in Skland credential database (docs/skland.md) is
|
|
// the other per-machine secret: `data/skland.db` and the Docker volume path `skland-data/`.
|
|
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
import { execFileSync } from 'node:child_process';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const lines = readFileSync(path.join(ROOT, '.gitignore'), 'utf8').split(/\r?\n/).map((l) => l.trim());
|
|
|
|
/** git's own verdict on a path (null when git or the repository is not available). */
|
|
function ignored(rel) {
|
|
try {
|
|
execFileSync('git', ['check-ignore', '-q', '--no-index', rel], { cwd: ROOT, stdio: 'ignore' });
|
|
return true;
|
|
} catch (e) {
|
|
return e && e.status === 1 ? false : null;
|
|
}
|
|
}
|
|
|
|
test('GitHub #258: the local npm cache (.npm-cache/) is ignored, like node_modules/ and .cache/', () => {
|
|
for (const entry of ['.npm-cache/', 'node_modules/', '.cache/']) assert.ok(lines.includes(entry), `.gitignore lists ${entry}`);
|
|
for (const rel of ['.npm-cache/_cacache/index-v5/00/aa', '.npm-cache/_logs/debug-0.log']) {
|
|
const v = ignored(rel);
|
|
if (v !== null) assert.equal(v, true, `${rel} is ignored`);
|
|
}
|
|
assert.notEqual(ignored('package.json'), true, 'a tracked file is not');
|
|
});
|
|
|
|
test('the Skland credential database (docs/skland.md): the file, its WAL side files and the Docker volume path', () => {
|
|
for (const entry of ['data/skland.db', 'data/skland.db-wal', 'data/skland.db-shm', 'skland-data/']) {
|
|
assert.ok(lines.includes(entry), `.gitignore lists ${entry}`);
|
|
}
|
|
// the store's default path, the two side files node:sqlite/WAL writes next to it, and the bind-mount form a
|
|
// deployment may use instead of docker-compose.yml's named volume (docker.test.js pins the volume itself)
|
|
for (const rel of ['data/skland.db', 'data/skland.db-wal', 'data/skland.db-shm', 'skland-data/skland.db', 'skland-data/skland.db-wal']) {
|
|
const v = ignored(rel);
|
|
if (v !== null) assert.equal(v, true, `${rel} is ignored`);
|
|
}
|
|
});
|