mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-28 03:53:20 +00:00
Align release metadata and audited development dependencies, and consolidate release notes with contributor acknowledgements. Cover upgrades, start-up integrity, text reflection, and interrupted saves in real Obsidian. Document the accepted provenance persistence interval: identical replayed content converges, safe merge retains the later remote content and ancestry, and overlapping edits remain available for review.
118 lines
4.0 KiB
TypeScript
118 lines
4.0 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
// Keep the public wrapper deliberately narrower than package.json. Discovery,
|
|
// installation, runner contracts, and the complete suite have different setup
|
|
// requirements and remain separate entry points.
|
|
const focusedScenarios = new Set([
|
|
"smoke",
|
|
"onboarding-invitation",
|
|
"dialog-mounts",
|
|
"joined-devices",
|
|
"joined-devices-object-storage",
|
|
"database-diagnostics",
|
|
"database-diagnostics-couchdb",
|
|
"conflict-dialog-policy",
|
|
"revision-repair",
|
|
"document-history-nav",
|
|
"document-history-restore",
|
|
"settings-ui",
|
|
"configuration-encryption",
|
|
"configuration-encryption-sync",
|
|
"review-harness",
|
|
"p2p-pane",
|
|
"replication-status",
|
|
"vault-reflection",
|
|
"third-party-chunks",
|
|
"couchdb-upload",
|
|
"couchdb-http-cache",
|
|
"chunk-fetch-retry",
|
|
"couchdb-manual-setup-workflow",
|
|
"cli-to-obsidian-sync",
|
|
"minio-upload",
|
|
"object-storage-setup-uri-workflow",
|
|
"object-storage-compatible-setup-uri-workflow",
|
|
"object-storage-qr-workflow",
|
|
"object-storage-custom-http-handler-setup-uri-workflow",
|
|
"p2p-setup-uri-workflow",
|
|
"partial-startup-file-failure",
|
|
"startup-scan",
|
|
"startup-integrity",
|
|
"stale-file-restart",
|
|
"folder-batch",
|
|
"setup-uri-workflow",
|
|
"two-vault-sync",
|
|
"security-seed-reconnect",
|
|
"hidden-file-snippet-sync",
|
|
"hidden-file-selectors",
|
|
"customisation-sync",
|
|
"customisation-catalogue-reload",
|
|
"optional-file-save-completion",
|
|
"livesync-batch",
|
|
"received-change-readiness",
|
|
"internal-metadata-doctor",
|
|
"setting-markdown-export",
|
|
"setting-markdown-roundtrip",
|
|
"upgrade-from-stable",
|
|
"upgrade-livesync-batching",
|
|
]);
|
|
|
|
function usage(): string {
|
|
return `Usage: npm run test:e2e:obsidian:focused -- <scenario> [scenario arguments]
|
|
|
|
Builds the current Self-hosted LiveSync plug-in before running one maintained
|
|
real-Obsidian scenario. Supported scenarios:
|
|
|
|
${[...focusedScenarios].map((scenario) => ` ${scenario}`).join("\n")}
|
|
|
|
This wrapper does not start CouchDB, Object Storage, or the P2P signalling
|
|
relay. Use the documented service commands or the complete
|
|
local-suite:services wrapper when required.`;
|
|
}
|
|
|
|
// npm receives each argument directly. In particular, environment values and
|
|
// scenario arguments never pass through a shell for re-interpretation.
|
|
function runNpm(args: string[]): void {
|
|
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
const result = spawnSync(npm, args, {
|
|
cwd: fileURLToPath(new URL("../../..", import.meta.url)),
|
|
stdio: "inherit",
|
|
});
|
|
if (result.error) throw result.error;
|
|
if (result.status !== 0) {
|
|
throw new Error(`npm ${args.join(" ")} failed with exit code ${result.status ?? "unknown"}.`);
|
|
}
|
|
}
|
|
|
|
function main(): void {
|
|
const [scenario, ...scenarioArguments] = process.argv.slice(2);
|
|
if (!scenario || scenario === "-h" || scenario === "--help") {
|
|
process.stdout.write(`${usage()}\n`);
|
|
return;
|
|
}
|
|
if (!focusedScenarios.has(scenario)) {
|
|
throw new Error(`Unsupported focused real-Obsidian scenario: ${scenario}\n\n${usage()}`);
|
|
}
|
|
|
|
// Individual scenario scripts intentionally remain fast, raw entry points.
|
|
// The wrapper owns the freshness guarantee which was previously easy to
|
|
// miss after changing TypeScript source.
|
|
runNpm(["run", "build"]);
|
|
|
|
// The compatibility scenario defaults to the repository CLI. Build it only
|
|
// when the caller has not selected an external CLI distribution.
|
|
if (scenario === "cli-to-obsidian-sync" && !process.env.LIVESYNC_CLI_COMMAND) {
|
|
runNpm(["run", "build", "--workspace", "self-hosted-livesync-cli"]);
|
|
}
|
|
|
|
const script = `test:e2e:obsidian:${scenario}`;
|
|
runNpm(["run", script, ...(scenarioArguments.length > 0 ? ["--", ...scenarioArguments] : [])]);
|
|
}
|
|
|
|
try {
|
|
main();
|
|
} catch (error) {
|
|
console.error(error instanceof Error ? error.message : error);
|
|
process.exitCode = 1;
|
|
}
|