obsidian-plugin-dev-kit 0.0.0-stage → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +223 -2
- package/bin/opdk.js +34 -0
- package/dist/build/args.d.ts +10 -0
- package/dist/build/args.js +45 -0
- package/dist/build/bundle-check.d.ts +17 -0
- package/dist/build/bundle-check.js +42 -0
- package/dist/build/bundle-file.d.ts +4 -0
- package/dist/build/bundle-file.js +29 -0
- package/dist/build/commands.d.ts +5 -0
- package/dist/build/commands.js +109 -0
- package/dist/build/config.d.ts +3 -0
- package/dist/build/config.js +103 -0
- package/dist/build/css-imports.d.ts +23 -0
- package/dist/build/css-imports.js +50 -0
- package/dist/build/css-step.d.ts +10 -0
- package/dist/build/css-step.js +27 -0
- package/dist/build/css.d.ts +24 -0
- package/dist/build/css.js +47 -0
- package/dist/build/options.d.ts +55 -0
- package/dist/build/options.js +70 -0
- package/dist/build/release.d.ts +5 -0
- package/dist/build/release.js +34 -0
- package/dist/build/report.d.ts +7 -0
- package/dist/build/report.js +16 -0
- package/dist/build/vault.d.ts +26 -0
- package/dist/build/vault.js +290 -0
- package/dist/build-info.json +1 -0
- package/dist/cli/argv.d.ts +14 -0
- package/dist/cli/argv.js +18 -0
- package/dist/cli/commands.d.ts +3 -0
- package/dist/cli/commands.js +7 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +23 -0
- package/dist/cli/process-reporter.d.ts +5 -0
- package/dist/cli/process-reporter.js +15 -0
- package/dist/cli/registry.d.ts +4 -0
- package/dist/cli/registry.js +15 -0
- package/dist/cli/reporter.d.ts +53 -0
- package/dist/cli/reporter.js +100 -0
- package/dist/cli/run.d.ts +9 -0
- package/dist/cli/run.js +61 -0
- package/dist/cli/types.d.ts +27 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/version.d.ts +13 -0
- package/dist/cli/version.js +61 -0
- package/dist/config/define-config.d.ts +3 -0
- package/dist/config/define-config.js +4 -0
- package/dist/config/load-config.d.ts +6 -0
- package/dist/config/load-config.js +70 -0
- package/dist/config/manifest.d.ts +3 -0
- package/dist/config/manifest.js +72 -0
- package/dist/config/types.d.ts +146 -0
- package/dist/config/types.js +23 -0
- package/dist/demo/args.d.ts +4 -0
- package/dist/demo/args.js +13 -0
- package/dist/demo/checks.d.ts +56 -0
- package/dist/demo/checks.js +124 -0
- package/dist/demo/commands.d.ts +3 -0
- package/dist/demo/commands.js +65 -0
- package/dist/demo/config.d.ts +57 -0
- package/dist/demo/config.js +337 -0
- package/dist/demo/ffmpeg-run.d.ts +18 -0
- package/dist/demo/ffmpeg-run.js +59 -0
- package/dist/demo/ffmpeg.d.ts +63 -0
- package/dist/demo/ffmpeg.js +111 -0
- package/dist/demo/films.d.ts +46 -0
- package/dist/demo/films.js +134 -0
- package/dist/demo/phone-layout.d.ts +38 -0
- package/dist/demo/phone-layout.js +98 -0
- package/dist/demo/phone-render.d.ts +28 -0
- package/dist/demo/phone-render.js +124 -0
- package/dist/demo/published.d.ts +16 -0
- package/dist/demo/published.js +72 -0
- package/dist/demo/run.d.ts +31 -0
- package/dist/demo/run.js +397 -0
- package/dist/demo/stills.d.ts +21 -0
- package/dist/demo/stills.js +62 -0
- package/dist/e2e/artifacts.d.ts +27 -0
- package/dist/e2e/artifacts.js +90 -0
- package/dist/e2e/cleanup.d.ts +54 -0
- package/dist/e2e/cleanup.js +109 -0
- package/dist/e2e/config.d.ts +9 -0
- package/dist/e2e/config.js +42 -0
- package/dist/e2e/create-test.d.ts +37 -0
- package/dist/e2e/create-test.js +109 -0
- package/dist/e2e/demo/clip.d.ts +21 -0
- package/dist/e2e/demo/clip.js +44 -0
- package/dist/e2e/demo/create-demo.d.ts +42 -0
- package/dist/e2e/demo/create-demo.js +439 -0
- package/dist/e2e/demo/manifest.d.ts +76 -0
- package/dist/e2e/demo/manifest.js +168 -0
- package/dist/e2e/demo/names.d.ts +18 -0
- package/dist/e2e/demo/names.js +44 -0
- package/dist/e2e/demo/options.d.ts +22 -0
- package/dist/e2e/demo/options.js +59 -0
- package/dist/e2e/demo/ownership.d.ts +27 -0
- package/dist/e2e/demo/ownership.js +65 -0
- package/dist/e2e/demo/page-scripts.d.ts +82 -0
- package/dist/e2e/demo/page-scripts.js +250 -0
- package/dist/e2e/demo/png.d.ts +8 -0
- package/dist/e2e/demo/png.js +23 -0
- package/dist/e2e/demo/presets.d.ts +43 -0
- package/dist/e2e/demo/presets.js +20 -0
- package/dist/e2e/demo/privacy.d.ts +18 -0
- package/dist/e2e/demo/privacy.js +30 -0
- package/dist/e2e/demo/still-options.d.ts +22 -0
- package/dist/e2e/demo/still-options.js +68 -0
- package/dist/e2e/demo/types.d.ts +184 -0
- package/dist/e2e/demo/types.js +1 -0
- package/dist/e2e/electron-binary.d.ts +15 -0
- package/dist/e2e/electron-binary.js +30 -0
- package/dist/e2e/fixtures.d.ts +62 -0
- package/dist/e2e/fixtures.js +68 -0
- package/dist/e2e/gate.d.ts +4 -0
- package/dist/e2e/gate.js +8 -0
- package/dist/e2e/global-setup.d.ts +11 -0
- package/dist/e2e/global-setup.js +17 -0
- package/dist/e2e/helpers/commands.d.ts +14 -0
- package/dist/e2e/helpers/commands.js +56 -0
- package/dist/e2e/helpers/create-helpers.d.ts +24 -0
- package/dist/e2e/helpers/create-helpers.js +582 -0
- package/dist/e2e/helpers/device-metrics.d.ts +21 -0
- package/dist/e2e/helpers/device-metrics.js +25 -0
- package/dist/e2e/helpers/ime.d.ts +13 -0
- package/dist/e2e/helpers/ime.js +19 -0
- package/dist/e2e/helpers/layout-page-scripts.d.ts +103 -0
- package/dist/e2e/helpers/layout-page-scripts.js +224 -0
- package/dist/e2e/helpers/layout.d.ts +83 -0
- package/dist/e2e/helpers/layout.js +148 -0
- package/dist/e2e/helpers/mobile.d.ts +31 -0
- package/dist/e2e/helpers/mobile.js +26 -0
- package/dist/e2e/helpers/page-scripts.d.ts +194 -0
- package/dist/e2e/helpers/page-scripts.js +467 -0
- package/dist/e2e/helpers/settings.d.ts +8 -0
- package/dist/e2e/helpers/settings.js +16 -0
- package/dist/e2e/helpers/settle.d.ts +28 -0
- package/dist/e2e/helpers/settle.js +33 -0
- package/dist/e2e/helpers/types.d.ts +193 -0
- package/dist/e2e/helpers/types.js +1 -0
- package/dist/e2e/helpers/view-mode.d.ts +23 -0
- package/dist/e2e/helpers/view-mode.js +35 -0
- package/dist/e2e/index.d.ts +14 -0
- package/dist/e2e/index.js +4 -0
- package/dist/e2e/internals.d.ts +155 -0
- package/dist/e2e/internals.js +8 -0
- package/dist/e2e/obsidian-path.d.ts +17 -0
- package/dist/e2e/obsidian-path.js +31 -0
- package/dist/e2e/options.d.ts +123 -0
- package/dist/e2e/options.js +244 -0
- package/dist/e2e/page-scripts.d.ts +45 -0
- package/dist/e2e/page-scripts.js +53 -0
- package/dist/e2e/peers.d.ts +9 -0
- package/dist/e2e/peers.js +19 -0
- package/dist/e2e/plugins.d.ts +32 -0
- package/dist/e2e/plugins.js +119 -0
- package/dist/e2e/process-tree.d.ts +33 -0
- package/dist/e2e/process-tree.js +133 -0
- package/dist/e2e/readiness.d.ts +23 -0
- package/dist/e2e/readiness.js +63 -0
- package/dist/e2e/seed.d.ts +34 -0
- package/dist/e2e/seed.js +122 -0
- package/dist/e2e/session.d.ts +71 -0
- package/dist/e2e/session.js +266 -0
- package/dist/e2e/vault.d.ts +52 -0
- package/dist/e2e/vault.js +146 -0
- package/dist/e2e/version.d.ts +25 -0
- package/dist/e2e/version.js +40 -0
- package/dist/eslint/index.d.ts +2 -0
- package/dist/eslint/index.js +1 -0
- package/dist/eslint/obsidian-plugin.d.ts +49 -0
- package/dist/eslint/obsidian-plugin.js +115 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/kit/args.d.ts +7 -0
- package/dist/kit/args.js +21 -0
- package/dist/kit/commands.d.ts +3 -0
- package/dist/kit/commands.js +52 -0
- package/dist/kit/files.d.ts +3 -0
- package/dist/kit/files.js +24 -0
- package/dist/kit/pins.d.ts +89 -0
- package/dist/kit/pins.js +178 -0
- package/dist/kit/remote.d.ts +13 -0
- package/dist/kit/remote.js +33 -0
- package/dist/kit/runners.d.ts +11 -0
- package/dist/kit/runners.js +53 -0
- package/dist/kit/terminal-text.d.ts +6 -0
- package/dist/kit/terminal-text.js +20 -0
- package/dist/kit/upgrade.d.ts +26 -0
- package/dist/kit/upgrade.js +162 -0
- package/dist/peers/resolve.d.ts +8 -0
- package/dist/peers/resolve.js +28 -0
- package/dist/peers/versions.d.ts +30 -0
- package/dist/peers/versions.js +32 -0
- package/dist/release/api-check.d.ts +27 -0
- package/dist/release/api-check.js +119 -0
- package/dist/release/args.d.ts +40 -0
- package/dist/release/args.js +120 -0
- package/dist/release/assets.d.ts +21 -0
- package/dist/release/assets.js +35 -0
- package/dist/release/build-check.d.ts +43 -0
- package/dist/release/build-check.js +184 -0
- package/dist/release/build-script.d.ts +12 -0
- package/dist/release/build-script.js +30 -0
- package/dist/release/build-tagged.d.ts +26 -0
- package/dist/release/build-tagged.js +52 -0
- package/dist/release/bump.d.ts +24 -0
- package/dist/release/bump.js +58 -0
- package/dist/release/changelog.d.ts +25 -0
- package/dist/release/changelog.js +148 -0
- package/dist/release/check.d.ts +38 -0
- package/dist/release/check.js +150 -0
- package/dist/release/commands.d.ts +3 -0
- package/dist/release/commands.js +154 -0
- package/dist/release/committed-tree.d.ts +63 -0
- package/dist/release/committed-tree.js +118 -0
- package/dist/release/config.d.ts +3 -0
- package/dist/release/config.js +28 -0
- package/dist/release/gh-access.d.ts +14 -0
- package/dist/release/gh-access.js +45 -0
- package/dist/release/gh.d.ts +10 -0
- package/dist/release/gh.js +33 -0
- package/dist/release/git.d.ts +49 -0
- package/dist/release/git.js +111 -0
- package/dist/release/interrupt.d.ts +30 -0
- package/dist/release/interrupt.js +60 -0
- package/dist/release/json.d.ts +33 -0
- package/dist/release/json.js +81 -0
- package/dist/release/kit-check.d.ts +8 -0
- package/dist/release/kit-check.js +51 -0
- package/dist/release/manifest-rules.d.ts +23 -0
- package/dist/release/manifest-rules.js +255 -0
- package/dist/release/preflight.d.ts +10 -0
- package/dist/release/preflight.js +65 -0
- package/dist/release/problems.d.ts +24 -0
- package/dist/release/problems.js +11 -0
- package/dist/release/project-files.d.ts +14 -0
- package/dist/release/project-files.js +16 -0
- package/dist/release/publish-command.d.ts +21 -0
- package/dist/release/publish-command.js +83 -0
- package/dist/release/publish-git.d.ts +37 -0
- package/dist/release/publish-git.js +108 -0
- package/dist/release/publish-state.d.ts +29 -0
- package/dist/release/publish-state.js +70 -0
- package/dist/release/publish-verify.d.ts +41 -0
- package/dist/release/publish-verify.js +112 -0
- package/dist/release/publish-wait.d.ts +25 -0
- package/dist/release/publish-wait.js +56 -0
- package/dist/release/publish.d.ts +35 -0
- package/dist/release/publish.js +181 -0
- package/dist/release/release-assets.d.ts +39 -0
- package/dist/release/release-assets.js +68 -0
- package/dist/release/release.d.ts +37 -0
- package/dist/release/release.js +179 -0
- package/dist/release/remote.d.ts +12 -0
- package/dist/release/remote.js +15 -0
- package/dist/release/reproducible.d.ts +16 -0
- package/dist/release/reproducible.js +34 -0
- package/dist/release/run-tests.d.ts +5 -0
- package/dist/release/run-tests.js +17 -0
- package/dist/release/semver.d.ts +8 -0
- package/dist/release/semver.js +60 -0
- package/dist/release/version-rules.d.ts +28 -0
- package/dist/release/version-rules.js +63 -0
- package/dist/release/versions-json.d.ts +15 -0
- package/dist/release/versions-json.js +88 -0
- package/dist/release/workflow-run.d.ts +44 -0
- package/dist/release/workflow-run.js +71 -0
- package/dist/scanner/code-checks.d.ts +41 -0
- package/dist/scanner/code-checks.js +82 -0
- package/dist/scanner/commands.d.ts +3 -0
- package/dist/scanner/commands.js +43 -0
- package/dist/scanner/config.d.ts +7 -0
- package/dist/scanner/config.js +25 -0
- package/dist/scanner/css-check.d.ts +26 -0
- package/dist/scanner/css-check.js +63 -0
- package/dist/scanner/eslint-nesting.d.ts +16 -0
- package/dist/scanner/eslint-nesting.js +45 -0
- package/dist/scanner/findings.d.ts +23 -0
- package/dist/scanner/findings.js +21 -0
- package/dist/scanner/git-files.d.ts +16 -0
- package/dist/scanner/git-files.js +73 -0
- package/dist/scanner/lint.d.ts +47 -0
- package/dist/scanner/lint.js +163 -0
- package/dist/scanner/meta-checks.d.ts +8 -0
- package/dist/scanner/meta-checks.js +22 -0
- package/dist/scanner/outside-project.d.ts +19 -0
- package/dist/scanner/outside-project.js +20 -0
- package/dist/scanner/run.d.ts +19 -0
- package/dist/scanner/run.js +78 -0
- package/dist/scanner/scanner-config.d.ts +114 -0
- package/dist/scanner/scanner-config.js +207 -0
- package/dist/scanner/typescript-gate.d.ts +30 -0
- package/dist/scanner/typescript-gate.js +73 -0
- package/dist/vitest/build-config.d.ts +17 -0
- package/dist/vitest/build-config.js +106 -0
- package/dist/vitest/define-unit-config.d.ts +27 -0
- package/dist/vitest/define-unit-config.js +45 -0
- package/dist/vitest/dom/elements.d.ts +87 -0
- package/dist/vitest/dom/elements.js +291 -0
- package/dist/vitest/dom/index.d.ts +1 -0
- package/dist/vitest/dom/index.js +1 -0
- package/dist/vitest/dom/install.d.ts +8 -0
- package/dist/vitest/dom/install.js +261 -0
- package/dist/vitest/dom/setup.d.ts +1 -0
- package/dist/vitest/dom/setup.js +3 -0
- package/dist/vitest/index.d.ts +3 -0
- package/dist/vitest/index.js +2 -0
- package/dist/vitest/options.d.ts +92 -0
- package/dist/vitest/options.js +136 -0
- package/dist/vitest/peers.d.ts +10 -0
- package/dist/vitest/peers.js +51 -0
- package/dist/vitest/workspace-root.d.ts +7 -0
- package/dist/vitest/workspace-root.js +39 -0
- package/docs/build.md +232 -0
- package/docs/ci.md +182 -0
- package/docs/demo.md +364 -0
- package/docs/e2e.md +563 -0
- package/docs/release.md +374 -0
- package/docs/scanner.md +204 -0
- package/docs/unit.md +291 -0
- package/package.json +100 -4
- package/plugins/opdk/skills/audit/SKILL.md +81 -0
- package/plugins/opdk/skills/build/SKILL.md +79 -0
- package/plugins/opdk/skills/demo/SKILL.md +102 -0
- package/plugins/opdk/skills/e2e/SKILL.md +132 -0
- package/plugins/opdk/skills/release/SKILL.md +84 -0
- package/plugins/opdk/skills/scanner/SKILL.md +60 -0
- package/plugins/opdk/skills/unit/SKILL.md +90 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** The process and timer calls the kill logic needs, injectable so tests need no real processes. */
|
|
2
|
+
export interface ProcessIo {
|
|
3
|
+
/** `process.kill`. A negative pid signals a process group. */
|
|
4
|
+
kill(pid: number, signal: NodeJS.Signals | 0): void;
|
|
5
|
+
/** `child_process.spawnSync` without a shell; used for `taskkill` on Windows. */
|
|
6
|
+
spawnSync(command: string, args: readonly string[]): SpawnResult;
|
|
7
|
+
sleep(ms: number): Promise<void>;
|
|
8
|
+
readonly platform: NodeJS.Platform;
|
|
9
|
+
}
|
|
10
|
+
/** The part of a `spawnSync` result the kill logic reads. `error` is set when the command could not be started at all. */
|
|
11
|
+
export interface SpawnResult {
|
|
12
|
+
readonly status: number | null;
|
|
13
|
+
readonly stderr: string;
|
|
14
|
+
readonly error?: Error | undefined;
|
|
15
|
+
}
|
|
16
|
+
export interface TerminateOptions {
|
|
17
|
+
/** Polls of `pollMs` after SIGTERM and after SIGKILL. Default 60 polls of 50 ms = 3 s each. */
|
|
18
|
+
readonly polls?: number;
|
|
19
|
+
readonly pollMs?: number;
|
|
20
|
+
}
|
|
21
|
+
/** True while any process of the group is alive. EPERM counts as alive: the group is not ours to signal, or (on macOS) its processes have exited but are not reaped yet, which the next poll sees (see `signalTree`). */
|
|
22
|
+
export declare function isTreeAlive(pid: number, io: ProcessIo): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Makes sure Obsidian's whole process tree is gone, and says what it took: `gone` (nothing left to kill),
|
|
25
|
+
* `terminated` (SIGTERM was enough) or `killed` (SIGKILL, or `taskkill /T /F` on Windows). Throws when a process
|
|
26
|
+
* survives.
|
|
27
|
+
*
|
|
28
|
+
* On POSIX it looks at the group, not at the main process: Chromium helpers (renderer, GPU, network) can outlive the
|
|
29
|
+
* main process, and nothing may still be writing into the user-data folder when the caller deletes it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function terminateTree(pid: number, io: ProcessIo, options?: TerminateOptions): Promise<"gone" | "terminated" | "killed">;
|
|
32
|
+
/** The real thing: `process.kill`, `spawnSync` and `setTimeout`. */
|
|
33
|
+
export declare function createProcessIo(): ProcessIo;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
const DEFAULT_POLLS = 60;
|
|
3
|
+
const DEFAULT_POLL_MS = 50;
|
|
4
|
+
/**
|
|
5
|
+
* Group (`-pid`) on POSIX, where Playwright starts the Electron process as a group leader. Windows has no process
|
|
6
|
+
* groups, so this is the single pid: a liveness probe only. Playwright starts Electron through `cmd.exe` there
|
|
7
|
+
* (`shell: true`), which makes `pid` the shell's; `process.kill(pid)` would end `cmd.exe` and leave Obsidian running,
|
|
8
|
+
* so the tree is ended with `taskkill /T` instead (see `killWindowsTree`).
|
|
9
|
+
*/
|
|
10
|
+
function targetFor(pid, platform) {
|
|
11
|
+
return platform === "win32" ? pid : -pid;
|
|
12
|
+
}
|
|
13
|
+
function errorCode(error) {
|
|
14
|
+
return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : undefined;
|
|
15
|
+
}
|
|
16
|
+
/** True while any process of the group is alive. EPERM counts as alive: the group is not ours to signal, or (on macOS) its processes have exited but are not reaped yet, which the next poll sees (see `signalTree`). */
|
|
17
|
+
export function isTreeAlive(pid, io) {
|
|
18
|
+
try {
|
|
19
|
+
io.kill(targetFor(pid, io.platform), 0);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
const code = errorCode(error);
|
|
24
|
+
if (code === "ESRCH") {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
if (code === "EPERM") {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Sends a signal to the group. "Already gone" (ESRCH) is success; any other error is real, except EPERM, which is
|
|
35
|
+
* returned instead of thrown. On macOS a group whose members are all exited but not yet reaped zombies answers EPERM
|
|
36
|
+
* to every signal, signal 0 included, until the parent's event loop reaps them on a later turn. Deciding right here
|
|
37
|
+
* (a synchronous re-probe) would see the same EPERM, so the caller polls with `waitUntilGone`, whose sleeps let the
|
|
38
|
+
* reaping happen, and reports the returned error only if the group is still there afterwards.
|
|
39
|
+
*/
|
|
40
|
+
function signalTree(pid, signal, io) {
|
|
41
|
+
try {
|
|
42
|
+
io.kill(targetFor(pid, io.platform), signal);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
const code = errorCode(error);
|
|
46
|
+
if (code === "ESRCH") {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
if (code === "EPERM" && error instanceof Error) {
|
|
50
|
+
return error;
|
|
51
|
+
}
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
/** `taskkill` exit code for "no such process": the tree is already gone, which is what we wanted. */
|
|
57
|
+
const TASKKILL_NOT_FOUND = 128;
|
|
58
|
+
/** Ends the process and all of its descendants, as Playwright's own Windows teardown does. */
|
|
59
|
+
function killWindowsTree(pid, io) {
|
|
60
|
+
const result = io.spawnSync("taskkill", ["/PID", String(pid), "/T", "/F"]);
|
|
61
|
+
if (result.error !== undefined) {
|
|
62
|
+
throw new Error(`Could not run taskkill for Obsidian process ${String(pid)}: ${result.error.message}. Kill it by hand (taskkill /PID ${String(pid)} /T /F).`, { cause: result.error });
|
|
63
|
+
}
|
|
64
|
+
if (result.status !== 0 && result.status !== TASKKILL_NOT_FOUND) {
|
|
65
|
+
throw new Error(`taskkill /PID ${String(pid)} /T /F failed with exit code ${String(result.status)}: ${result.stderr.trim()}. Kill the process by hand.`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function waitUntilGone(pid, io, polls, pollMs) {
|
|
69
|
+
for (let i = 0; i < polls; i += 1) {
|
|
70
|
+
if (!isTreeAlive(pid, io)) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
await io.sleep(pollMs);
|
|
74
|
+
}
|
|
75
|
+
return !isTreeAlive(pid, io);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Makes sure Obsidian's whole process tree is gone, and says what it took: `gone` (nothing left to kill),
|
|
79
|
+
* `terminated` (SIGTERM was enough) or `killed` (SIGKILL, or `taskkill /T /F` on Windows). Throws when a process
|
|
80
|
+
* survives.
|
|
81
|
+
*
|
|
82
|
+
* On POSIX it looks at the group, not at the main process: Chromium helpers (renderer, GPU, network) can outlive the
|
|
83
|
+
* main process, and nothing may still be writing into the user-data folder when the caller deletes it.
|
|
84
|
+
*/
|
|
85
|
+
export async function terminateTree(pid, io, options = {}) {
|
|
86
|
+
// `-0` and `-1` would signal the caller's own group or every process the user may signal, so refuse before any signal.
|
|
87
|
+
if (!Number.isInteger(pid) || pid <= 1) {
|
|
88
|
+
throw new Error(`Refusing to end Obsidian's process tree: ${String(pid)} is not a usable process id (expected an integer above 1). ` +
|
|
89
|
+
`The Electron application did not report a pid; check the launch.`);
|
|
90
|
+
}
|
|
91
|
+
const polls = options.polls ?? DEFAULT_POLLS;
|
|
92
|
+
const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
|
|
93
|
+
if (!isTreeAlive(pid, io)) {
|
|
94
|
+
return "gone";
|
|
95
|
+
}
|
|
96
|
+
if (io.platform === "win32") {
|
|
97
|
+
killWindowsTree(pid, io);
|
|
98
|
+
if (await waitUntilGone(pid, io, polls, pollMs)) {
|
|
99
|
+
return "killed";
|
|
100
|
+
}
|
|
101
|
+
throw survivedError(pid, io);
|
|
102
|
+
}
|
|
103
|
+
let denied = signalTree(pid, "SIGTERM", io);
|
|
104
|
+
if (await waitUntilGone(pid, io, polls, pollMs)) {
|
|
105
|
+
return "terminated";
|
|
106
|
+
}
|
|
107
|
+
denied = signalTree(pid, "SIGKILL", io) ?? denied;
|
|
108
|
+
if (await waitUntilGone(pid, io, polls, pollMs)) {
|
|
109
|
+
return "killed";
|
|
110
|
+
}
|
|
111
|
+
throw survivedError(pid, io, denied);
|
|
112
|
+
}
|
|
113
|
+
function survivedError(pid, io, denied) {
|
|
114
|
+
const eperm = denied === undefined ? "" : ` The system refused the signal (${denied.message}): the group is alive but not ours to signal.`;
|
|
115
|
+
return new Error(`Obsidian process ${String(pid)} (and its helpers) survived ${io.platform === "win32" ? "taskkill" : "SIGKILL"}.${eperm} ` +
|
|
116
|
+
`Kill it by hand${io.platform === "win32" ? ` (taskkill /PID ${String(pid)} /T /F)` : ` (kill -9 -${String(pid)})`}.`, denied === undefined ? undefined : { cause: denied });
|
|
117
|
+
}
|
|
118
|
+
/** The real thing: `process.kill`, `spawnSync` and `setTimeout`. */
|
|
119
|
+
export function createProcessIo() {
|
|
120
|
+
return {
|
|
121
|
+
kill: (pid, signal) => {
|
|
122
|
+
process.kill(pid, signal);
|
|
123
|
+
},
|
|
124
|
+
spawnSync: (command, args) => {
|
|
125
|
+
const result = spawnSync(command, [...args], { encoding: "utf8", windowsHide: true });
|
|
126
|
+
return { status: result.status, stderr: result.stderr, error: result.error };
|
|
127
|
+
},
|
|
128
|
+
sleep: (ms) => new Promise((resolve) => {
|
|
129
|
+
setTimeout(resolve, ms);
|
|
130
|
+
}),
|
|
131
|
+
platform: process.platform,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Page } from "@playwright/test";
|
|
2
|
+
/** The button of the plugin trust dialog. The kit never clicks it: both its buttons have side effects (see `waitForReady`). */
|
|
3
|
+
export declare const TRUST_BUTTON_NAME = "Trust author and enable plugins";
|
|
4
|
+
export interface ReadinessFailure {
|
|
5
|
+
readonly timeoutMs: number;
|
|
6
|
+
readonly hasApp: boolean;
|
|
7
|
+
readonly layoutReady: boolean;
|
|
8
|
+
/** Plugins Obsidian has not started loading. */
|
|
9
|
+
readonly missing: readonly string[];
|
|
10
|
+
/** Plugins whose `onload()` is still running. */
|
|
11
|
+
readonly loading: readonly string[];
|
|
12
|
+
readonly trustDialogVisible: boolean;
|
|
13
|
+
/** Why a diagnostic could not be collected (for example the window closed). */
|
|
14
|
+
readonly diagnosticsError?: string;
|
|
15
|
+
}
|
|
16
|
+
/** The message of a failed readiness wait: which plugin did not load, or that the trust dialog is blocking. */
|
|
17
|
+
export declare function formatReadinessFailure(failure: ReadinessFailure): string;
|
|
18
|
+
/**
|
|
19
|
+
* Waits until the workspace is laid out and, for every plugin id, `app.plugins.plugins[id]` exists and
|
|
20
|
+
* `app.plugins.loadingPluginId` is no longer that id (its `onload()` has finished). The wait is on state, not on
|
|
21
|
+
* sleeps. On a timeout it collects what is still missing or loading and fails with a message that names it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function waitForReady(page: Page, pluginIds: readonly string[], timeoutMs: number): Promise<void>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { isReady, readinessState } from "./page-scripts.js";
|
|
2
|
+
/** The button of the plugin trust dialog. The kit never clicks it: both its buttons have side effects (see `waitForReady`). */
|
|
3
|
+
export const TRUST_BUTTON_NAME = "Trust author and enable plugins";
|
|
4
|
+
/** The message of a failed readiness wait: which plugin did not load, or that the trust dialog is blocking. */
|
|
5
|
+
export function formatReadinessFailure(failure) {
|
|
6
|
+
const head = `Obsidian was not ready after ${String(failure.timeoutMs)} ms.`;
|
|
7
|
+
if (failure.trustDialogVisible) {
|
|
8
|
+
return (`${head} The "${TRUST_BUTTON_NAME}" dialog is open: the trust flag the kit sets before the vault loads ` +
|
|
9
|
+
`did not apply, so no plugin was loaded. The kit does not click the dialog (cancelling it disables plugins ` +
|
|
10
|
+
`for good). This points at an Obsidian version that stores the flag differently; report it with the Obsidian version.`);
|
|
11
|
+
}
|
|
12
|
+
if (failure.diagnosticsError !== undefined) {
|
|
13
|
+
return `${head} Could not tell why: ${failure.diagnosticsError}`;
|
|
14
|
+
}
|
|
15
|
+
if (!failure.hasApp) {
|
|
16
|
+
return `${head} Obsidian's \`app\` object never appeared, so the vault did not open. Check the seed vault and the Obsidian install.`;
|
|
17
|
+
}
|
|
18
|
+
const parts = [];
|
|
19
|
+
if (!failure.layoutReady) {
|
|
20
|
+
parts.push("the workspace layout was not ready");
|
|
21
|
+
}
|
|
22
|
+
if (failure.loading.length > 0) {
|
|
23
|
+
parts.push(`plugin${failure.loading.length === 1 ? "" : "s"} still loading: ${failure.loading.join(", ")}`);
|
|
24
|
+
}
|
|
25
|
+
if (failure.missing.length > 0) {
|
|
26
|
+
parts.push(`plugin${failure.missing.length === 1 ? "" : "s"} not loaded: ${failure.missing.join(", ")}`);
|
|
27
|
+
}
|
|
28
|
+
const plugins = failure.loading.length + failure.missing.length > 0;
|
|
29
|
+
return `${head} ${parts.length > 0 ? `${parts.join("; ")}.` : "The state looked ready right after the timeout; raise timeouts.ready."}${plugins ? " Check the plugin loads without errors (a slow or hanging onload() shows as still loading; open the developer console in a headed run)." : ""}`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Waits until the workspace is laid out and, for every plugin id, `app.plugins.plugins[id]` exists and
|
|
33
|
+
* `app.plugins.loadingPluginId` is no longer that id (its `onload()` has finished). The wait is on state, not on
|
|
34
|
+
* sleeps. On a timeout it collects what is still missing or loading and fails with a message that names it.
|
|
35
|
+
*/
|
|
36
|
+
export async function waitForReady(page, pluginIds, timeoutMs) {
|
|
37
|
+
const ids = [...pluginIds];
|
|
38
|
+
try {
|
|
39
|
+
await page.waitForFunction(isReady, ids, { polling: 50, timeout: timeoutMs });
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
const failure = await diagnose(page, ids, timeoutMs);
|
|
43
|
+
throw new Error(formatReadinessFailure(failure), { cause: error });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function diagnose(page, ids, timeoutMs) {
|
|
47
|
+
try {
|
|
48
|
+
const state = await page.evaluate(readinessState, ids);
|
|
49
|
+
const trustDialogVisible = await page.getByRole("button", { name: TRUST_BUTTON_NAME }).isVisible();
|
|
50
|
+
return { timeoutMs, ...state, trustDialogVisible };
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return {
|
|
54
|
+
timeoutMs,
|
|
55
|
+
hasApp: false,
|
|
56
|
+
layoutReady: false,
|
|
57
|
+
missing: ids,
|
|
58
|
+
loading: [],
|
|
59
|
+
trustDialogVisible: false,
|
|
60
|
+
diagnosticsError: error instanceof Error ? error.message : String(error),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extra content for the vault of one test, written before Obsidian starts, so a spec does not have to write files and
|
|
3
|
+
* then `obsidian.reload()`. Set it with `test.use({ seed: { ... } })` in a file or a `describe`.
|
|
4
|
+
*/
|
|
5
|
+
export interface VaultSeed {
|
|
6
|
+
/**
|
|
7
|
+
* Files to add to the vault, by vault-relative path, with their text. They replace a file of the same path from
|
|
8
|
+
* the seed vault, and folders are created. A path can point into `.obsidian/` (`.obsidian/templates.json`).
|
|
9
|
+
*/
|
|
10
|
+
readonly files?: Readonly<Record<string, string>>;
|
|
11
|
+
/** Keys merged into `.obsidian/app.json` over the seed vault's and the kit's defaults (`{ "propertiesInDocument": "hidden" }`). */
|
|
12
|
+
readonly config?: Readonly<Record<string, unknown>>;
|
|
13
|
+
}
|
|
14
|
+
/** Why a vault-relative path is not usable, or `null` when it is. */
|
|
15
|
+
export declare function seedPathProblem(file: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Why a seed file must not replace what the kit writes, as a sentence naming the key to use instead; `null` when it may.
|
|
18
|
+
* `dataIds` are the plugin ids of the `data` option: only their `data.json` is the kit's. The `data.json` of any other
|
|
19
|
+
* plugin (one that lives in the seed vault, or has no `data` entry) is the spec's to write, per test.
|
|
20
|
+
*/
|
|
21
|
+
export declare function seedFileConflict(file: string, dataIds?: readonly string[]): string | null;
|
|
22
|
+
/** The id of the installed plugin whose build file (`main.js`, `manifest.json`, `styles.css` in `.obsidian/plugins/<id>/`) the file is, or `null`. */
|
|
23
|
+
export declare function seedPluginFolder(file: string, installedIds: readonly string[]): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Checks a seed the way a spec wrote it. `undefined` is no seed. Anything else wrong fails here with the key, so a
|
|
26
|
+
* typo does not produce a vault that quietly lacks the file.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveSeed(value: unknown, dataIds?: readonly string[]): VaultSeed;
|
|
29
|
+
/**
|
|
30
|
+
* Writes a resolved seed into the vault copy. Call it after the kit's own files, so the seed has the last word. A file
|
|
31
|
+
* that is a build file of an installed plugin (`installedIds`: `main.js`, `manifest.json`, `styles.css`) is refused,
|
|
32
|
+
* because it would replace the build under test.
|
|
33
|
+
*/
|
|
34
|
+
export declare function applySeed(vaultPath: string, seed: VaultSeed, installedIds?: readonly string[]): void;
|
package/dist/e2e/seed.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { createVaultHandle, mergeAppJson, readJsonObject, writeJson } from "./vault.js";
|
|
3
|
+
const KNOWN_KEYS = ["files", "config"];
|
|
4
|
+
function isRecord(value) {
|
|
5
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
/** Why a vault-relative path is not usable, or `null` when it is. */
|
|
8
|
+
export function seedPathProblem(file) {
|
|
9
|
+
if (file.trim() === "") {
|
|
10
|
+
return "is empty";
|
|
11
|
+
}
|
|
12
|
+
if (path.isAbsolute(file) || path.win32.isAbsolute(file)) {
|
|
13
|
+
return "is absolute";
|
|
14
|
+
}
|
|
15
|
+
if (file.endsWith("/") || file.endsWith("\\")) {
|
|
16
|
+
return "ends with a slash, so it names a folder";
|
|
17
|
+
}
|
|
18
|
+
if (file.split(/[\\/]/).includes("..")) {
|
|
19
|
+
return "leaves the vault with ..";
|
|
20
|
+
}
|
|
21
|
+
const normal = normalizeSeedPath(file);
|
|
22
|
+
if (normal === "") {
|
|
23
|
+
return "names the vault folder itself, not a file";
|
|
24
|
+
}
|
|
25
|
+
if (normal === ".obsidian") {
|
|
26
|
+
return "names the .obsidian folder itself, not a file";
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
/** The path as the vault sees it: forward slashes, no `./`, lowercase (macOS and Windows ignore case), `""` for the vault folder. */
|
|
31
|
+
function normalizeSeedPath(file) {
|
|
32
|
+
const normal = path.posix.normalize(file.replace(/\\/g, "/")).toLowerCase();
|
|
33
|
+
return normal === "." ? "" : normal.replace(/^\.\//, "");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Why a seed file must not replace what the kit writes, as a sentence naming the key to use instead; `null` when it may.
|
|
37
|
+
* `dataIds` are the plugin ids of the `data` option: only their `data.json` is the kit's. The `data.json` of any other
|
|
38
|
+
* plugin (one that lives in the seed vault, or has no `data` entry) is the spec's to write, per test.
|
|
39
|
+
*/
|
|
40
|
+
export function seedFileConflict(file, dataIds = []) {
|
|
41
|
+
const normal = normalizeSeedPath(file);
|
|
42
|
+
if (normal === ".obsidian/app.json") {
|
|
43
|
+
return 'would replace .obsidian/app.json, which the kit fills with its defaults (settingsPopoutWindow, alwaysUpdateLinks). Put the keys in seed.config, for example config: { propertiesInDocument: "hidden" }';
|
|
44
|
+
}
|
|
45
|
+
if (normal === ".obsidian/community-plugins.json") {
|
|
46
|
+
return "would replace .obsidian/community-plugins.json, which the kit writes from the installed plugins. List the plugins in the plugins option of createObsidianTest";
|
|
47
|
+
}
|
|
48
|
+
const dataOwner = /^\.obsidian\/plugins\/([^/]+)\/data\.json$/.exec(normal)?.[1];
|
|
49
|
+
if (dataOwner !== undefined && dataIds.some((id) => id.toLowerCase() === dataOwner)) {
|
|
50
|
+
return `would replace the data.json that the data option of createObsidianTest writes for "${dataOwner}". Change the settings there, or drop that plugin from the data option`;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
/** The id of the installed plugin whose build file (`main.js`, `manifest.json`, `styles.css` in `.obsidian/plugins/<id>/`) the file is, or `null`. */
|
|
55
|
+
export function seedPluginFolder(file, installedIds) {
|
|
56
|
+
const match = /^\.obsidian\/plugins\/([^/]+)\/(?:main\.js|manifest\.json|styles\.css)$/.exec(normalizeSeedPath(file));
|
|
57
|
+
return installedIds.find((id) => id.toLowerCase() === match?.[1]) ?? null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Checks a seed the way a spec wrote it. `undefined` is no seed. Anything else wrong fails here with the key, so a
|
|
61
|
+
* typo does not produce a vault that quietly lacks the file.
|
|
62
|
+
*/
|
|
63
|
+
export function resolveSeed(value, dataIds = []) {
|
|
64
|
+
if (value === undefined) {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
if (!isRecord(value)) {
|
|
68
|
+
throw new Error('seed: must be an object { files?, config? }, for example test.use({ seed: { files: { "Notes/a.md": "# a" } } }).');
|
|
69
|
+
}
|
|
70
|
+
for (const key of Object.keys(value)) {
|
|
71
|
+
if (!KNOWN_KEYS.includes(key)) {
|
|
72
|
+
throw new Error(`seed: unknown key "${key}". Known keys: ${KNOWN_KEYS.join(", ")}.`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const { files, config } = value;
|
|
76
|
+
if (files !== undefined) {
|
|
77
|
+
if (!isRecord(files)) {
|
|
78
|
+
throw new Error('seed: "files" must be an object from vault-relative path to text, for example { "Notes/a.md": "# a" }.');
|
|
79
|
+
}
|
|
80
|
+
for (const [file, text] of Object.entries(files)) {
|
|
81
|
+
if (typeof text !== "string") {
|
|
82
|
+
throw new Error(`seed: "files[${JSON.stringify(file)}]" must be a string (the file's text). For JSON, pass JSON.stringify(...).`);
|
|
83
|
+
}
|
|
84
|
+
const problem = seedPathProblem(file);
|
|
85
|
+
if (problem !== null) {
|
|
86
|
+
throw new Error(`seed: the path ${JSON.stringify(file)} ${problem}. Use a path relative to the vault, such as "Notes/a.md".`);
|
|
87
|
+
}
|
|
88
|
+
const conflict = seedFileConflict(file, dataIds);
|
|
89
|
+
if (conflict !== null) {
|
|
90
|
+
throw new Error(`seed: files[${JSON.stringify(file)}] ${conflict}.`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (config !== undefined && !isRecord(config)) {
|
|
95
|
+
throw new Error('seed: "config" must be an object of app.json keys, for example { propertiesInDocument: "hidden" }.');
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
...(files === undefined ? {} : { files: Object.fromEntries(Object.entries(files).map(([file, text]) => [file, String(text)])) }),
|
|
99
|
+
...(config === undefined ? {} : { config }),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Writes a resolved seed into the vault copy. Call it after the kit's own files, so the seed has the last word. A file
|
|
104
|
+
* that is a build file of an installed plugin (`installedIds`: `main.js`, `manifest.json`, `styles.css`) is refused,
|
|
105
|
+
* because it would replace the build under test.
|
|
106
|
+
*/
|
|
107
|
+
export function applySeed(vaultPath, seed, installedIds = []) {
|
|
108
|
+
for (const file of Object.keys(seed.files ?? {})) {
|
|
109
|
+
const plugin = seedPluginFolder(file, installedIds);
|
|
110
|
+
if (plugin !== null) {
|
|
111
|
+
throw new Error(`seed: files[${JSON.stringify(file)}] is a build file of the installed plugin "${plugin}" and would replace its build. Seed other files of that folder, or notes elsewhere in the vault.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const vault = createVaultHandle(vaultPath);
|
|
115
|
+
for (const [file, text] of Object.entries(seed.files ?? {})) {
|
|
116
|
+
vault.write(file, text);
|
|
117
|
+
}
|
|
118
|
+
if (seed.config !== undefined && Object.keys(seed.config).length > 0) {
|
|
119
|
+
const file = vault.resolve(".obsidian/app.json");
|
|
120
|
+
writeJson(file, { ...mergeAppJson(readJsonObject(file)), ...seed.config });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { _electron, ElectronApplication, Page } from "@playwright/test";
|
|
2
|
+
import { type TraceSettings, type VideoSettings } from "./artifacts.js";
|
|
3
|
+
import { type ElectronProbe } from "./electron-binary.js";
|
|
4
|
+
import type { ResolvedOptions } from "./options.js";
|
|
5
|
+
import { type PluginSource } from "./plugins.js";
|
|
6
|
+
import { type ProcessIo } from "./process-tree.js";
|
|
7
|
+
import { type VaultSeed } from "./seed.js";
|
|
8
|
+
import { type VaultHandle } from "./vault.js";
|
|
9
|
+
/** The trace is written under this name in the test's output folder. */
|
|
10
|
+
export declare const TRACE_FILE = "obsidian-trace.zip";
|
|
11
|
+
export type ElectronLaunchOptions = NonNullable<Parameters<typeof _electron.launch>[0]>;
|
|
12
|
+
export type ElectronLauncher = (options: ElectronLaunchOptions) => Promise<ElectronApplication>;
|
|
13
|
+
/** Everything with a side effect on the machine, injectable so the cleanup paths can be tested with fakes. */
|
|
14
|
+
export interface SessionDeps {
|
|
15
|
+
readonly launch: ElectronLauncher;
|
|
16
|
+
readonly io: ProcessIo;
|
|
17
|
+
/** Finds the plugin's `electron` package and its downloaded binary. */
|
|
18
|
+
readonly electron: ElectronProbe;
|
|
19
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
20
|
+
/** Where temp folders go. Default `os.tmpdir()`. */
|
|
21
|
+
readonly tmpRoot?: string;
|
|
22
|
+
readonly now?: () => number;
|
|
23
|
+
}
|
|
24
|
+
/** What the session needs to keep a trace and a video of the Obsidian window; see `artifacts.ts`. */
|
|
25
|
+
export interface ArtifactPlan {
|
|
26
|
+
readonly trace: TraceSettings;
|
|
27
|
+
readonly video: VideoSettings;
|
|
28
|
+
/** 0 for the first run, 1 for the first retry. */
|
|
29
|
+
readonly retry: number;
|
|
30
|
+
/** A path inside the test's output folder (`test-results`), which Playwright cleans. */
|
|
31
|
+
readonly outputPath: (name: string) => string;
|
|
32
|
+
/** Adds a file to the test report. */
|
|
33
|
+
readonly attach: (name: string, path: string, contentType: string) => void;
|
|
34
|
+
}
|
|
35
|
+
export interface SessionContext {
|
|
36
|
+
/** Goes into the temp folder names; the test title. */
|
|
37
|
+
readonly label: string;
|
|
38
|
+
/** Adds a note to the test report. */
|
|
39
|
+
readonly annotate: (type: string, description: string) => void;
|
|
40
|
+
/** Absent: no trace and no video. */
|
|
41
|
+
readonly artifacts?: ArtifactPlan;
|
|
42
|
+
/** Absent: the vault is the seed vault as it is. */
|
|
43
|
+
readonly seed?: VaultSeed;
|
|
44
|
+
}
|
|
45
|
+
/** How the test ended; decides which recordings are kept. */
|
|
46
|
+
export interface SessionOutcome {
|
|
47
|
+
readonly failed: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** A running Obsidian with its throwaway vault. `teardown` must always be called. */
|
|
50
|
+
export interface ObsidianSession {
|
|
51
|
+
readonly app: ElectronApplication;
|
|
52
|
+
readonly win: Page;
|
|
53
|
+
readonly vault: VaultHandle;
|
|
54
|
+
/** Stops the recordings, closes Obsidian and removes the folders. `outcome` defaults to a passed test. */
|
|
55
|
+
teardown(outcome?: SessionOutcome): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
/** The environment Obsidian starts with: ours minus the variables that break it or aim it at the wrong vault. */
|
|
58
|
+
export declare function buildLaunchEnv(env: Readonly<Record<string, string | undefined>>): Record<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* Checks everything that can be checked without creating anything: the Obsidian install, the build output of every
|
|
61
|
+
* plugin, the `data` ids. A problem here leaves nothing behind.
|
|
62
|
+
*/
|
|
63
|
+
export declare function prepareSession(options: ResolvedOptions, deps: Pick<SessionDeps, "env">, platform?: NodeJS.Platform): {
|
|
64
|
+
asar: string;
|
|
65
|
+
sources: PluginSource[];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Starts Obsidian on a fresh copy of the seed vault. If any step throws, everything created so far is torn down
|
|
69
|
+
* before the error reaches the caller.
|
|
70
|
+
*/
|
|
71
|
+
export declare function startSession(options: ResolvedOptions, deps: SessionDeps, context: SessionContext): Promise<ObsidianSession>;
|