obsidian-plugin-dev-kit 0.0.0-stage → 0.3.2

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.
Files changed (329) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +223 -2
  3. package/bin/opdk.js +34 -0
  4. package/dist/build/args.d.ts +10 -0
  5. package/dist/build/args.js +45 -0
  6. package/dist/build/bundle-check.d.ts +17 -0
  7. package/dist/build/bundle-check.js +42 -0
  8. package/dist/build/bundle-file.d.ts +4 -0
  9. package/dist/build/bundle-file.js +29 -0
  10. package/dist/build/commands.d.ts +5 -0
  11. package/dist/build/commands.js +109 -0
  12. package/dist/build/config.d.ts +3 -0
  13. package/dist/build/config.js +103 -0
  14. package/dist/build/css-imports.d.ts +23 -0
  15. package/dist/build/css-imports.js +50 -0
  16. package/dist/build/css-step.d.ts +10 -0
  17. package/dist/build/css-step.js +27 -0
  18. package/dist/build/css.d.ts +24 -0
  19. package/dist/build/css.js +47 -0
  20. package/dist/build/options.d.ts +55 -0
  21. package/dist/build/options.js +70 -0
  22. package/dist/build/release.d.ts +5 -0
  23. package/dist/build/release.js +34 -0
  24. package/dist/build/report.d.ts +7 -0
  25. package/dist/build/report.js +16 -0
  26. package/dist/build/vault.d.ts +26 -0
  27. package/dist/build/vault.js +290 -0
  28. package/dist/build-info.json +1 -0
  29. package/dist/cli/argv.d.ts +14 -0
  30. package/dist/cli/argv.js +18 -0
  31. package/dist/cli/commands.d.ts +3 -0
  32. package/dist/cli/commands.js +7 -0
  33. package/dist/cli/main.d.ts +2 -0
  34. package/dist/cli/main.js +23 -0
  35. package/dist/cli/process-reporter.d.ts +5 -0
  36. package/dist/cli/process-reporter.js +15 -0
  37. package/dist/cli/registry.d.ts +4 -0
  38. package/dist/cli/registry.js +15 -0
  39. package/dist/cli/reporter.d.ts +53 -0
  40. package/dist/cli/reporter.js +100 -0
  41. package/dist/cli/run.d.ts +9 -0
  42. package/dist/cli/run.js +61 -0
  43. package/dist/cli/types.d.ts +27 -0
  44. package/dist/cli/types.js +1 -0
  45. package/dist/cli/version.d.ts +13 -0
  46. package/dist/cli/version.js +61 -0
  47. package/dist/config/define-config.d.ts +3 -0
  48. package/dist/config/define-config.js +4 -0
  49. package/dist/config/load-config.d.ts +6 -0
  50. package/dist/config/load-config.js +70 -0
  51. package/dist/config/manifest.d.ts +3 -0
  52. package/dist/config/manifest.js +72 -0
  53. package/dist/config/types.d.ts +146 -0
  54. package/dist/config/types.js +23 -0
  55. package/dist/demo/args.d.ts +4 -0
  56. package/dist/demo/args.js +13 -0
  57. package/dist/demo/checks.d.ts +56 -0
  58. package/dist/demo/checks.js +124 -0
  59. package/dist/demo/commands.d.ts +3 -0
  60. package/dist/demo/commands.js +65 -0
  61. package/dist/demo/config.d.ts +57 -0
  62. package/dist/demo/config.js +337 -0
  63. package/dist/demo/ffmpeg-run.d.ts +18 -0
  64. package/dist/demo/ffmpeg-run.js +59 -0
  65. package/dist/demo/ffmpeg.d.ts +63 -0
  66. package/dist/demo/ffmpeg.js +111 -0
  67. package/dist/demo/films.d.ts +46 -0
  68. package/dist/demo/films.js +134 -0
  69. package/dist/demo/phone-layout.d.ts +38 -0
  70. package/dist/demo/phone-layout.js +98 -0
  71. package/dist/demo/phone-render.d.ts +28 -0
  72. package/dist/demo/phone-render.js +124 -0
  73. package/dist/demo/published.d.ts +16 -0
  74. package/dist/demo/published.js +72 -0
  75. package/dist/demo/run.d.ts +31 -0
  76. package/dist/demo/run.js +397 -0
  77. package/dist/demo/stills.d.ts +21 -0
  78. package/dist/demo/stills.js +62 -0
  79. package/dist/e2e/artifacts.d.ts +27 -0
  80. package/dist/e2e/artifacts.js +90 -0
  81. package/dist/e2e/cleanup.d.ts +54 -0
  82. package/dist/e2e/cleanup.js +109 -0
  83. package/dist/e2e/config.d.ts +9 -0
  84. package/dist/e2e/config.js +42 -0
  85. package/dist/e2e/create-test.d.ts +37 -0
  86. package/dist/e2e/create-test.js +109 -0
  87. package/dist/e2e/demo/clip.d.ts +21 -0
  88. package/dist/e2e/demo/clip.js +44 -0
  89. package/dist/e2e/demo/create-demo.d.ts +42 -0
  90. package/dist/e2e/demo/create-demo.js +439 -0
  91. package/dist/e2e/demo/manifest.d.ts +76 -0
  92. package/dist/e2e/demo/manifest.js +168 -0
  93. package/dist/e2e/demo/names.d.ts +18 -0
  94. package/dist/e2e/demo/names.js +44 -0
  95. package/dist/e2e/demo/options.d.ts +22 -0
  96. package/dist/e2e/demo/options.js +59 -0
  97. package/dist/e2e/demo/ownership.d.ts +27 -0
  98. package/dist/e2e/demo/ownership.js +65 -0
  99. package/dist/e2e/demo/page-scripts.d.ts +82 -0
  100. package/dist/e2e/demo/page-scripts.js +250 -0
  101. package/dist/e2e/demo/png.d.ts +8 -0
  102. package/dist/e2e/demo/png.js +23 -0
  103. package/dist/e2e/demo/presets.d.ts +43 -0
  104. package/dist/e2e/demo/presets.js +20 -0
  105. package/dist/e2e/demo/privacy.d.ts +18 -0
  106. package/dist/e2e/demo/privacy.js +30 -0
  107. package/dist/e2e/demo/still-options.d.ts +22 -0
  108. package/dist/e2e/demo/still-options.js +68 -0
  109. package/dist/e2e/demo/types.d.ts +184 -0
  110. package/dist/e2e/demo/types.js +1 -0
  111. package/dist/e2e/electron-binary.d.ts +15 -0
  112. package/dist/e2e/electron-binary.js +30 -0
  113. package/dist/e2e/fixtures.d.ts +62 -0
  114. package/dist/e2e/fixtures.js +68 -0
  115. package/dist/e2e/gate.d.ts +4 -0
  116. package/dist/e2e/gate.js +8 -0
  117. package/dist/e2e/global-setup.d.ts +11 -0
  118. package/dist/e2e/global-setup.js +17 -0
  119. package/dist/e2e/helpers/commands.d.ts +14 -0
  120. package/dist/e2e/helpers/commands.js +56 -0
  121. package/dist/e2e/helpers/create-helpers.d.ts +24 -0
  122. package/dist/e2e/helpers/create-helpers.js +582 -0
  123. package/dist/e2e/helpers/device-metrics.d.ts +21 -0
  124. package/dist/e2e/helpers/device-metrics.js +25 -0
  125. package/dist/e2e/helpers/ime.d.ts +13 -0
  126. package/dist/e2e/helpers/ime.js +19 -0
  127. package/dist/e2e/helpers/layout-page-scripts.d.ts +103 -0
  128. package/dist/e2e/helpers/layout-page-scripts.js +224 -0
  129. package/dist/e2e/helpers/layout.d.ts +83 -0
  130. package/dist/e2e/helpers/layout.js +148 -0
  131. package/dist/e2e/helpers/mobile.d.ts +31 -0
  132. package/dist/e2e/helpers/mobile.js +26 -0
  133. package/dist/e2e/helpers/page-scripts.d.ts +194 -0
  134. package/dist/e2e/helpers/page-scripts.js +467 -0
  135. package/dist/e2e/helpers/settings.d.ts +8 -0
  136. package/dist/e2e/helpers/settings.js +16 -0
  137. package/dist/e2e/helpers/settle.d.ts +28 -0
  138. package/dist/e2e/helpers/settle.js +33 -0
  139. package/dist/e2e/helpers/types.d.ts +193 -0
  140. package/dist/e2e/helpers/types.js +1 -0
  141. package/dist/e2e/helpers/view-mode.d.ts +23 -0
  142. package/dist/e2e/helpers/view-mode.js +35 -0
  143. package/dist/e2e/index.d.ts +14 -0
  144. package/dist/e2e/index.js +4 -0
  145. package/dist/e2e/internals.d.ts +155 -0
  146. package/dist/e2e/internals.js +8 -0
  147. package/dist/e2e/obsidian-path.d.ts +17 -0
  148. package/dist/e2e/obsidian-path.js +31 -0
  149. package/dist/e2e/options.d.ts +123 -0
  150. package/dist/e2e/options.js +244 -0
  151. package/dist/e2e/page-scripts.d.ts +45 -0
  152. package/dist/e2e/page-scripts.js +53 -0
  153. package/dist/e2e/peers.d.ts +9 -0
  154. package/dist/e2e/peers.js +19 -0
  155. package/dist/e2e/plugins.d.ts +32 -0
  156. package/dist/e2e/plugins.js +119 -0
  157. package/dist/e2e/process-tree.d.ts +33 -0
  158. package/dist/e2e/process-tree.js +133 -0
  159. package/dist/e2e/readiness.d.ts +23 -0
  160. package/dist/e2e/readiness.js +63 -0
  161. package/dist/e2e/seed.d.ts +34 -0
  162. package/dist/e2e/seed.js +122 -0
  163. package/dist/e2e/session.d.ts +71 -0
  164. package/dist/e2e/session.js +266 -0
  165. package/dist/e2e/vault.d.ts +52 -0
  166. package/dist/e2e/vault.js +146 -0
  167. package/dist/e2e/version.d.ts +25 -0
  168. package/dist/e2e/version.js +40 -0
  169. package/dist/eslint/index.d.ts +2 -0
  170. package/dist/eslint/index.js +1 -0
  171. package/dist/eslint/obsidian-plugin.d.ts +49 -0
  172. package/dist/eslint/obsidian-plugin.js +115 -0
  173. package/dist/index.d.ts +3 -0
  174. package/dist/index.js +1 -0
  175. package/dist/kit/args.d.ts +7 -0
  176. package/dist/kit/args.js +21 -0
  177. package/dist/kit/commands.d.ts +3 -0
  178. package/dist/kit/commands.js +52 -0
  179. package/dist/kit/files.d.ts +3 -0
  180. package/dist/kit/files.js +24 -0
  181. package/dist/kit/pins.d.ts +89 -0
  182. package/dist/kit/pins.js +178 -0
  183. package/dist/kit/remote.d.ts +13 -0
  184. package/dist/kit/remote.js +33 -0
  185. package/dist/kit/runners.d.ts +11 -0
  186. package/dist/kit/runners.js +53 -0
  187. package/dist/kit/terminal-text.d.ts +6 -0
  188. package/dist/kit/terminal-text.js +20 -0
  189. package/dist/kit/upgrade.d.ts +26 -0
  190. package/dist/kit/upgrade.js +162 -0
  191. package/dist/peers/resolve.d.ts +8 -0
  192. package/dist/peers/resolve.js +28 -0
  193. package/dist/peers/versions.d.ts +30 -0
  194. package/dist/peers/versions.js +32 -0
  195. package/dist/release/api-check.d.ts +27 -0
  196. package/dist/release/api-check.js +119 -0
  197. package/dist/release/args.d.ts +40 -0
  198. package/dist/release/args.js +120 -0
  199. package/dist/release/assets.d.ts +21 -0
  200. package/dist/release/assets.js +35 -0
  201. package/dist/release/build-check.d.ts +43 -0
  202. package/dist/release/build-check.js +184 -0
  203. package/dist/release/build-script.d.ts +12 -0
  204. package/dist/release/build-script.js +30 -0
  205. package/dist/release/build-tagged.d.ts +26 -0
  206. package/dist/release/build-tagged.js +52 -0
  207. package/dist/release/bump.d.ts +24 -0
  208. package/dist/release/bump.js +58 -0
  209. package/dist/release/changelog.d.ts +25 -0
  210. package/dist/release/changelog.js +148 -0
  211. package/dist/release/check.d.ts +38 -0
  212. package/dist/release/check.js +150 -0
  213. package/dist/release/commands.d.ts +3 -0
  214. package/dist/release/commands.js +154 -0
  215. package/dist/release/committed-tree.d.ts +63 -0
  216. package/dist/release/committed-tree.js +118 -0
  217. package/dist/release/config.d.ts +3 -0
  218. package/dist/release/config.js +28 -0
  219. package/dist/release/gh-access.d.ts +14 -0
  220. package/dist/release/gh-access.js +45 -0
  221. package/dist/release/gh.d.ts +10 -0
  222. package/dist/release/gh.js +33 -0
  223. package/dist/release/git.d.ts +49 -0
  224. package/dist/release/git.js +111 -0
  225. package/dist/release/interrupt.d.ts +30 -0
  226. package/dist/release/interrupt.js +60 -0
  227. package/dist/release/json.d.ts +33 -0
  228. package/dist/release/json.js +81 -0
  229. package/dist/release/kit-check.d.ts +8 -0
  230. package/dist/release/kit-check.js +51 -0
  231. package/dist/release/manifest-rules.d.ts +23 -0
  232. package/dist/release/manifest-rules.js +255 -0
  233. package/dist/release/preflight.d.ts +10 -0
  234. package/dist/release/preflight.js +65 -0
  235. package/dist/release/problems.d.ts +24 -0
  236. package/dist/release/problems.js +11 -0
  237. package/dist/release/project-files.d.ts +14 -0
  238. package/dist/release/project-files.js +16 -0
  239. package/dist/release/publish-command.d.ts +21 -0
  240. package/dist/release/publish-command.js +83 -0
  241. package/dist/release/publish-git.d.ts +37 -0
  242. package/dist/release/publish-git.js +108 -0
  243. package/dist/release/publish-state.d.ts +29 -0
  244. package/dist/release/publish-state.js +70 -0
  245. package/dist/release/publish-verify.d.ts +41 -0
  246. package/dist/release/publish-verify.js +112 -0
  247. package/dist/release/publish-wait.d.ts +25 -0
  248. package/dist/release/publish-wait.js +56 -0
  249. package/dist/release/publish.d.ts +35 -0
  250. package/dist/release/publish.js +181 -0
  251. package/dist/release/release-assets.d.ts +39 -0
  252. package/dist/release/release-assets.js +68 -0
  253. package/dist/release/release.d.ts +37 -0
  254. package/dist/release/release.js +179 -0
  255. package/dist/release/remote.d.ts +12 -0
  256. package/dist/release/remote.js +15 -0
  257. package/dist/release/reproducible.d.ts +16 -0
  258. package/dist/release/reproducible.js +34 -0
  259. package/dist/release/run-tests.d.ts +5 -0
  260. package/dist/release/run-tests.js +17 -0
  261. package/dist/release/semver.d.ts +8 -0
  262. package/dist/release/semver.js +60 -0
  263. package/dist/release/version-rules.d.ts +28 -0
  264. package/dist/release/version-rules.js +63 -0
  265. package/dist/release/versions-json.d.ts +15 -0
  266. package/dist/release/versions-json.js +88 -0
  267. package/dist/release/workflow-run.d.ts +44 -0
  268. package/dist/release/workflow-run.js +71 -0
  269. package/dist/scanner/code-checks.d.ts +41 -0
  270. package/dist/scanner/code-checks.js +82 -0
  271. package/dist/scanner/commands.d.ts +3 -0
  272. package/dist/scanner/commands.js +43 -0
  273. package/dist/scanner/config.d.ts +7 -0
  274. package/dist/scanner/config.js +25 -0
  275. package/dist/scanner/css-check.d.ts +26 -0
  276. package/dist/scanner/css-check.js +63 -0
  277. package/dist/scanner/eslint-nesting.d.ts +16 -0
  278. package/dist/scanner/eslint-nesting.js +45 -0
  279. package/dist/scanner/findings.d.ts +23 -0
  280. package/dist/scanner/findings.js +21 -0
  281. package/dist/scanner/git-files.d.ts +16 -0
  282. package/dist/scanner/git-files.js +73 -0
  283. package/dist/scanner/lint.d.ts +47 -0
  284. package/dist/scanner/lint.js +163 -0
  285. package/dist/scanner/meta-checks.d.ts +8 -0
  286. package/dist/scanner/meta-checks.js +22 -0
  287. package/dist/scanner/outside-project.d.ts +19 -0
  288. package/dist/scanner/outside-project.js +20 -0
  289. package/dist/scanner/run.d.ts +19 -0
  290. package/dist/scanner/run.js +78 -0
  291. package/dist/scanner/scanner-config.d.ts +114 -0
  292. package/dist/scanner/scanner-config.js +207 -0
  293. package/dist/scanner/typescript-gate.d.ts +30 -0
  294. package/dist/scanner/typescript-gate.js +73 -0
  295. package/dist/vitest/build-config.d.ts +17 -0
  296. package/dist/vitest/build-config.js +106 -0
  297. package/dist/vitest/define-unit-config.d.ts +27 -0
  298. package/dist/vitest/define-unit-config.js +45 -0
  299. package/dist/vitest/dom/elements.d.ts +87 -0
  300. package/dist/vitest/dom/elements.js +291 -0
  301. package/dist/vitest/dom/index.d.ts +1 -0
  302. package/dist/vitest/dom/index.js +1 -0
  303. package/dist/vitest/dom/install.d.ts +8 -0
  304. package/dist/vitest/dom/install.js +261 -0
  305. package/dist/vitest/dom/setup.d.ts +1 -0
  306. package/dist/vitest/dom/setup.js +3 -0
  307. package/dist/vitest/index.d.ts +3 -0
  308. package/dist/vitest/index.js +2 -0
  309. package/dist/vitest/options.d.ts +92 -0
  310. package/dist/vitest/options.js +136 -0
  311. package/dist/vitest/peers.d.ts +10 -0
  312. package/dist/vitest/peers.js +51 -0
  313. package/dist/vitest/workspace-root.d.ts +7 -0
  314. package/dist/vitest/workspace-root.js +39 -0
  315. package/docs/build.md +232 -0
  316. package/docs/ci.md +182 -0
  317. package/docs/demo.md +364 -0
  318. package/docs/e2e.md +563 -0
  319. package/docs/release.md +374 -0
  320. package/docs/scanner.md +204 -0
  321. package/docs/unit.md +291 -0
  322. package/package.json +100 -4
  323. package/plugins/opdk/skills/audit/SKILL.md +81 -0
  324. package/plugins/opdk/skills/build/SKILL.md +79 -0
  325. package/plugins/opdk/skills/demo/SKILL.md +102 -0
  326. package/plugins/opdk/skills/e2e/SKILL.md +132 -0
  327. package/plugins/opdk/skills/release/SKILL.md +84 -0
  328. package/plugins/opdk/skills/scanner/SKILL.md +60 -0
  329. package/plugins/opdk/skills/unit/SKILL.md +90 -0
@@ -0,0 +1,136 @@
1
+ /** What three plugins gate on today. A floor, not a goal. */
2
+ export const DEFAULT_THRESHOLDS = { lines: 90, functions: 90, statements: 90, branches: 80 };
3
+ /** Always left out of coverage: the tests themselves, the test helpers and type declarations. */
4
+ export const BASE_COVERAGE_EXCLUDE = ["**/*.test.ts", "src/test/**", "**/*.d.ts"];
5
+ /** The `obsidian` value that selects the obsidian-test-mocks package instead of a plugin stub. */
6
+ export const OBSIDIAN_TEST_MOCKS = "obsidian-test-mocks";
7
+ const KNOWN = ["coverage", "obsidian", "dom", "include", "rootDir"];
8
+ const KNOWN_COVERAGE = ["include", "exclude", "thresholds", "allowLowerThresholds", "extraReporters"];
9
+ const THRESHOLD_KEYS = ["lines", "functions", "statements", "branches"];
10
+ const COVERAGE_EXAMPLE = 'defineUnitConfig({ coverage: { include: ["src/**/*.ts"], exclude: ["src/main.ts"] } })';
11
+ function isGlobList(value) {
12
+ return Array.isArray(value) && value.every((item) => typeof item === "string" && item !== "");
13
+ }
14
+ function isReporterList(value) {
15
+ return Array.isArray(value) && value.every((name) => name === "lcov" || name === "html");
16
+ }
17
+ function isRecord(value) {
18
+ return typeof value === "object" && value !== null && !Array.isArray(value);
19
+ }
20
+ /** Applies the defaults and rejects values of the wrong type, naming the option and what to do. */
21
+ export function resolveUnitOptions(options, cwd) {
22
+ // The options come from a plugin's JavaScript config, so the types alone prove nothing.
23
+ const raw = options;
24
+ if (!isRecord(raw)) {
25
+ throw new Error(`defineUnitConfig(): options are required. Example: ${COVERAGE_EXAMPLE}.`);
26
+ }
27
+ const unknownKeys = Object.keys(raw).filter((key) => !KNOWN.includes(key));
28
+ if (unknownKeys.length > 0) {
29
+ throw new Error(`defineUnitConfig(): unknown option(s): ${unknownKeys.join(", ")}. Allowed options: ${KNOWN.join(", ")}.`);
30
+ }
31
+ const rootDir = raw.rootDir ?? cwd;
32
+ if (typeof rootDir !== "string" || rootDir === "") {
33
+ throw new Error('defineUnitConfig(): "rootDir" must be a non-empty string, for example import.meta.dirname.');
34
+ }
35
+ const include = raw.include ?? ["src/**/*.test.ts"];
36
+ if (!isGlobList(include) || include.length === 0) {
37
+ throw new Error('defineUnitConfig(): "include" must be a non-empty array of glob strings, for example ["src/**/*.test.ts"].');
38
+ }
39
+ const obsidian = resolveObsidian(raw.obsidian);
40
+ const dom = resolveDom(raw.dom);
41
+ if ((obsidian.kind === "mocks" || (obsidian.kind === "split" && obsidian.dom.kind === "mocks")) && dom.kind === "none") {
42
+ throw new Error('defineUnitConfig(): obsidian "obsidian-test-mocks" patches the DOM and needs a DOM environment. ' +
43
+ 'List the test files that use it in "dom", for example dom: ["src/ui/**/*.test.ts"], or pass dom: "all".');
44
+ }
45
+ return { rootDir, include, obsidian, dom, coverage: resolveCoverage(raw.coverage) };
46
+ }
47
+ const OBSIDIAN_FORMS = 'a path to the plugin\'s stub such as "./src/test/stubs/obsidian.ts", "obsidian-test-mocks", or { node: "./src/test/stubs/obsidian.ts", dom: "obsidian-test-mocks" }';
48
+ function resolveObsidian(value) {
49
+ if (value === undefined)
50
+ return { kind: "none" };
51
+ if (isRecord(value))
52
+ return resolveObsidianSplit(value);
53
+ if (typeof value !== "string" || value === "") {
54
+ throw new Error(`defineUnitConfig(): "obsidian" must be ${OBSIDIAN_FORMS}.`);
55
+ }
56
+ return value === OBSIDIAN_TEST_MOCKS ? { kind: "mocks" } : { kind: "stub", path: value };
57
+ }
58
+ function resolveObsidianSplit(value) {
59
+ const unknownKeys = Object.keys(value).filter((key) => key !== "node" && key !== "dom");
60
+ if (unknownKeys.length > 0) {
61
+ throw new Error(`defineUnitConfig(): unknown "obsidian" key(s): ${unknownKeys.join(", ")}. Allowed keys: node, dom.`);
62
+ }
63
+ const { node, dom } = value;
64
+ if (typeof node !== "string" || node === "") {
65
+ throw new Error('defineUnitConfig(): "obsidian.node" must be the path to a stub for the node tests, for example "./src/test/stubs/obsidian.ts".');
66
+ }
67
+ if (node === OBSIDIAN_TEST_MOCKS) {
68
+ throw new Error('defineUnitConfig(): "obsidian.node" cannot be "obsidian-test-mocks": the package patches the DOM and only works in the DOM tests. ' +
69
+ 'Use a stub path for node, and put "obsidian-test-mocks" in "obsidian.dom".');
70
+ }
71
+ if (typeof dom !== "string" || dom === "") {
72
+ throw new Error('defineUnitConfig(): "obsidian.dom" must be "obsidian-test-mocks" or the path to a stub for the DOM tests.');
73
+ }
74
+ return { kind: "split", node, dom: dom === OBSIDIAN_TEST_MOCKS ? { kind: "mocks" } : { kind: "stub", path: dom } };
75
+ }
76
+ function resolveDom(value) {
77
+ if (value === undefined)
78
+ return { kind: "none" };
79
+ if (value === "all")
80
+ return { kind: "all" };
81
+ if (!isGlobList(value)) {
82
+ throw new Error('defineUnitConfig(): "dom" must be an array of test file globs, for example ["src/ui/**/*.test.ts"], or "all".');
83
+ }
84
+ return value.length === 0 ? { kind: "none" } : { kind: "split", globs: value };
85
+ }
86
+ function resolveCoverage(value) {
87
+ if (!isRecord(value) || !isGlobList(value.include) || value.include.length === 0) {
88
+ throw new Error(`defineUnitConfig(): "coverage.include" is required. Vitest reports only files a test imported unless it is set, ` +
89
+ `so a file no test touches would escape the gate. Example: ${COVERAGE_EXAMPLE}.`);
90
+ }
91
+ const unknownKeys = Object.keys(value).filter((key) => !KNOWN_COVERAGE.includes(key));
92
+ if (unknownKeys.length > 0) {
93
+ throw new Error(`defineUnitConfig(): unknown coverage option(s): ${unknownKeys.join(", ")}. Allowed options: ${KNOWN_COVERAGE.join(", ")}.`);
94
+ }
95
+ const exclude = value.exclude ?? [];
96
+ if (!isGlobList(exclude)) {
97
+ throw new Error('defineUnitConfig(): "coverage.exclude" must be an array of non-empty glob strings.');
98
+ }
99
+ const allowLower = value.allowLowerThresholds === undefined ? false : value.allowLowerThresholds;
100
+ if (typeof allowLower !== "boolean") {
101
+ throw new Error('defineUnitConfig(): "coverage.allowLowerThresholds" must be true or false.');
102
+ }
103
+ const extra = value.extraReporters ?? [];
104
+ if (!isReporterList(extra)) {
105
+ throw new Error('defineUnitConfig(): "coverage.extraReporters" must be an array holding "lcov", "html" or both.');
106
+ }
107
+ return {
108
+ include: value.include,
109
+ exclude: [...BASE_COVERAGE_EXCLUDE, ...exclude],
110
+ thresholds: resolveThresholds(value.thresholds, allowLower),
111
+ reporters: ["text", "json-summary", ...extra],
112
+ };
113
+ }
114
+ function resolveThresholds(value, allowLower) {
115
+ if (value === undefined)
116
+ return DEFAULT_THRESHOLDS;
117
+ if (!isRecord(value)) {
118
+ throw new Error('defineUnitConfig(): "coverage.thresholds" must be an object such as { branches: 85 }.');
119
+ }
120
+ const merged = { ...DEFAULT_THRESHOLDS };
121
+ for (const [key, number] of Object.entries(value)) {
122
+ const name = THRESHOLD_KEYS.find((candidate) => candidate === key);
123
+ if (name === undefined) {
124
+ throw new Error(`defineUnitConfig(): unknown threshold "${key}". Allowed: ${THRESHOLD_KEYS.join(", ")}.`);
125
+ }
126
+ if (typeof number !== "number" || !Number.isFinite(number) || number < 0 || number > 100) {
127
+ throw new Error(`defineUnitConfig(): threshold "${key}" must be a number from 0 to 100.`);
128
+ }
129
+ if (number < DEFAULT_THRESHOLDS[name] && !allowLower) {
130
+ throw new Error(`defineUnitConfig(): threshold "${key}: ${String(number)}" is below the default ${String(DEFAULT_THRESHOLDS[name])}. ` +
131
+ "The default is a floor. Raise the coverage, or set allowLowerThresholds: true to lower it on purpose.");
132
+ }
133
+ merged[name] = number;
134
+ }
135
+ return merged;
136
+ }
@@ -0,0 +1,10 @@
1
+ import { type PeerProblem, type VersionReader } from "../peers/versions.js";
2
+ /**
3
+ * What the unit preset needs from the plugin's `node_modules`, as a list of problems (empty when all is well):
4
+ * Vitest 5, `@vitest/coverage-v8` at the same version, and jsdom 30 or newer when `needsDom`. The plugin installs
5
+ * these itself; the kit declares no peer dependency on them, because npm checks an optional peer whenever it is
6
+ * installed and a plugin on an older Vitest could not install the kit at all.
7
+ */
8
+ export declare function findUnitPeerProblems(read: VersionReader, needsDom: boolean): PeerProblem[];
9
+ /** Throws one error with every problem and the command that fixes them; returns when the plugin's versions fit. */
10
+ export declare function assertUnitPeers(read: VersionReader, needsDom: boolean): void;
@@ -0,0 +1,51 @@
1
+ import { checkRule, formatPeerError } from "../peers/versions.js";
2
+ /** The Vitest major the preset is written and tested against. */
3
+ const VITEST = { name: "vitest", minMajor: 5, maxMajor: 5, range: "^5.0.0" };
4
+ /**
5
+ * jsdom 30 is the version the DOM project and the kit's own tests run on, and the lowest one tested. Older jsdom
6
+ * versions may work, but the kit makes no promise about them: a plugin on one gets this message instead of a
7
+ * failure inside the polyfill.
8
+ */
9
+ const JSDOM = { name: "jsdom", minMajor: 30, range: ">=30.0.0" };
10
+ const COVERAGE = "@vitest/coverage-v8";
11
+ /**
12
+ * What the unit preset needs from the plugin's `node_modules`, as a list of problems (empty when all is well):
13
+ * Vitest 5, `@vitest/coverage-v8` at the same version, and jsdom 30 or newer when `needsDom`. The plugin installs
14
+ * these itself; the kit declares no peer dependency on them, because npm checks an optional peer whenever it is
15
+ * installed and a plugin on an older Vitest could not install the kit at all.
16
+ */
17
+ export function findUnitPeerProblems(read, needsDom) {
18
+ const problems = [];
19
+ const vitest = read(VITEST.name);
20
+ const vitestProblem = checkRule(VITEST, vitest);
21
+ if (vitestProblem !== undefined)
22
+ problems.push(vitestProblem);
23
+ const coverage = read(COVERAGE);
24
+ if (vitestProblem !== undefined || vitest === undefined) {
25
+ // Vitest itself is wrong, so there is no version to match yet: the coverage package has to fit the same range.
26
+ const coverageProblem = checkRule({ ...VITEST, name: COVERAGE }, coverage);
27
+ if (coverageProblem !== undefined)
28
+ problems.push(coverageProblem);
29
+ }
30
+ else if (coverage === undefined) {
31
+ problems.push({ message: `"${COVERAGE}" is not installed; the kit needs the same version as "vitest" (${vitest}).`, install: `${COVERAGE}@${vitest}` });
32
+ }
33
+ else if (coverage !== vitest) {
34
+ problems.push({
35
+ message: `"${COVERAGE}" ${coverage} is installed next to "vitest" ${vitest}; the two must be the same version.`,
36
+ install: `${COVERAGE}@${vitest}`,
37
+ });
38
+ }
39
+ if (needsDom) {
40
+ const jsdomProblem = checkRule(JSDOM, read(JSDOM.name));
41
+ if (jsdomProblem !== undefined)
42
+ problems.push(jsdomProblem);
43
+ }
44
+ return problems;
45
+ }
46
+ /** Throws one error with every problem and the command that fixes them; returns when the plugin's versions fit. */
47
+ export function assertUnitPeers(read, needsDom) {
48
+ const problems = findUnitPeerProblems(read, needsDom);
49
+ if (problems.length > 0)
50
+ throw new Error(formatPeerError("defineUnitConfig()", problems));
51
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The folder Vite serves files from by default (`server.fs.allow` unset): the nearest parent of `start` that holds
3
+ * `pnpm-workspace.yaml`, `lerna.json` or a `package.json` with `workspaces`, else the nearest folder with a
4
+ * `package.json`, else `start`. It mirrors Vite's `searchForWorkspaceRoot` (without its Deno rule) instead of importing
5
+ * it: `vite` is only a peer of `vitest`, and the kit declares no dependency on it.
6
+ */
7
+ export declare function findWorkspaceRoot(start: string): string;
@@ -0,0 +1,39 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ /** Files whose presence marks a workspace root; the same list Vite's `searchForWorkspaceRoot` uses. */
4
+ const ROOT_FILES = ["pnpm-workspace.yaml", "lerna.json"];
5
+ function isWorkspaceManifest(dir) {
6
+ const file = path.join(dir, "package.json");
7
+ if (!fs.existsSync(file))
8
+ return false;
9
+ try {
10
+ const manifest = JSON.parse(fs.readFileSync(file, "utf8"));
11
+ return typeof manifest === "object" && manifest !== null && "workspaces" in manifest && Boolean(manifest.workspaces);
12
+ }
13
+ catch {
14
+ // A broken package.json is not a workspace marker; the plugin's own tooling reports it.
15
+ return false;
16
+ }
17
+ }
18
+ function nearestPackageRoot(start) {
19
+ for (let dir = start;; dir = path.dirname(dir)) {
20
+ if (fs.existsSync(path.join(dir, "package.json")))
21
+ return dir;
22
+ if (path.dirname(dir) === dir)
23
+ return undefined;
24
+ }
25
+ }
26
+ /**
27
+ * The folder Vite serves files from by default (`server.fs.allow` unset): the nearest parent of `start` that holds
28
+ * `pnpm-workspace.yaml`, `lerna.json` or a `package.json` with `workspaces`, else the nearest folder with a
29
+ * `package.json`, else `start`. It mirrors Vite's `searchForWorkspaceRoot` (without its Deno rule) instead of importing
30
+ * it: `vite` is only a peer of `vitest`, and the kit declares no dependency on it.
31
+ */
32
+ export function findWorkspaceRoot(start) {
33
+ for (let dir = start;; dir = path.dirname(dir)) {
34
+ if (ROOT_FILES.some((name) => fs.existsSync(path.join(dir, name))) || isWorkspaceManifest(dir))
35
+ return dir;
36
+ if (path.dirname(dir) === dir)
37
+ return nearestPackageRoot(start) ?? start;
38
+ }
39
+ }
package/docs/build.md ADDED
@@ -0,0 +1,232 @@
1
+ # Build
2
+
3
+ `opdk build` builds your plugin's CSS, bundles the plugin with esbuild for the browser platform, and then checks `main.js` for code that only exists under Node. `opdk build --vault --watch` is the same build aimed at a dev vault, rebuilding on every change.
4
+
5
+ ![Terminal: opdk build prints the CSS step, the bundle size and "free of Node-only references", then ls shows main.js and styles.css](media/build.gif)
6
+
7
+ ## Why
8
+
9
+ A plugin released as 1.0.0 failed on every phone. Its build passed `--platform=node`, so esbuild took the `node` branch of the `yaml` package's export map and bundled a build that reads `process.env`. Desktop Obsidian has `process`, so the bug only showed on mobile. Nothing in the plugin's `src/` referred to `process`; it arrived through a dependency's export conditions, which is why reading the sources cannot catch it and the built file has to be checked. A second plugin built with `--platform=node` has the same problem today.
10
+
11
+ The kit fixes the platform to `browser`, and the check fails the build if Node-only code gets in anyway. The check is skipped when `manifest.json` says `isDesktopOnly: true`.
12
+
13
+ ## What `opdk build` does
14
+
15
+ The plugin id comes from `manifest.json`, the settings from the optional `opdk.config.mjs`. In order:
16
+
17
+ 1. **CSS.** If the CSS entry (`src/styles/main.css`) exists, its `@import` lines are inlined into `styles.css`. If it does not exist and a root `styles.css` does, the step prints a `·` line and the hand-written `styles.css` stays as it is. With no `styles.css` either it prints a `!` warning, because the plugin then ships no stylesheet. A plugin that only has a hand-written `styles.css` can set `css: false` to skip the step entirely. A missing `@import` target or an import cycle stops the whole build with exit 1, and the message names the files.
18
+ 2. **Bundle.** esbuild bundles the entry (`src/main.ts`) into `main.js`: platform `browser`, format `cjs`, a footer that makes `module.exports` the plugin class, minified. A compile error is printed in esbuild's layout, followed by `build failed with N error(s)`, and the build exits 1.
19
+ 3. **Bundle check.** `main.js` is searched for Node-only code. A finding prints `cannot run on mobile`, one line per finding, and exits 1. The bundle stays on disk. Nothing is checked for a desktop-only plugin.
20
+ 4. **Done.** Exit 0 with `main.js` and `styles.css` in place.
21
+
22
+ `opdk build --vault [dir]` builds into a dev vault instead:
23
+
24
+ 1. The folder is the `--vault` value, else `$VAULT_PLUGIN`. The first line says which one was used (`from --vault` or `from VAULT_PLUGIN`).
25
+ 2. The build refuses, exits 1 and writes nothing when `dir/manifest.json` holds another plugin id (`--force` overrides this one only), when `dir` is the plugin root, when `dir` starts with `~` (nothing expands it), or when `--vault` is empty (`--vault ""`, `--vault=`). The last three are refused even with `--force`. With no `dir` and no `VAULT_PLUGIN` it stops and says to pass one.
26
+ 3. An unminified `main.js` is written into `dir`.
27
+ 4. `styles.css` is rebuilt from the CSS entry and copied into `dir` together with `manifest.json`. It is rebuilt rather than copied as is, because a stale copy is silent: a vault once shipped without the styles of two whole blocks while the TypeScript was fresh. With `css: false`, a `styles.css` in the plugin root is copied if it exists.
28
+ Only these three files are copied, the ones Obsidian loads. A hand-written `build:vault` script may also copy a screenshots folder; the kit leaves it out on purpose, because nothing in a vault's plugin folder reads screenshots. Put such files in the seed vault of a spec that needs them.
29
+ 5. There is no bundle check in this mode.
30
+
31
+ With `--watch` the build then keeps running:
32
+
33
+ - esbuild watches the sources and rebuilds `main.js`; each rebuild repeats step 4.
34
+ - The CSS entry, every file it imports and `manifest.json` are polled every 300 ms (a recursive `fs.watch` was seconds late on macOS). A change repeats step 4. Imports added or removed while it runs are tracked.
35
+ - A compile error is printed and the watch keeps going; fix the file and the next build recovers.
36
+ - The same holds for CSS. When a step fails on a broken `@import`, the files it had read stay polled, so fixing any of them triggers the next sync, and so does creating a missing `@import` target.
37
+ - If the CSS entry does not exist when the watch starts, it prints `no <entry>, CSS not watched` once and polls only `manifest.json`; esbuild still watches the sources. The line starts with `·` when a root `styles.css` exists and with `!` when there is none. The `·` line about the kept `styles.css` is printed on the first sync only, not on every one.
38
+ - `opdk.config.mjs` is read once at start. After editing it, restart the watch.
39
+ - Ctrl+C stops the watchers and exits 0.
40
+
41
+ ## Quick start
42
+
43
+ In `package.json`:
44
+
45
+ ```json
46
+ {
47
+ "scripts": {
48
+ "build": "opdk build",
49
+ "dev:vault": "opdk build --vault --watch"
50
+ },
51
+ "devDependencies": {
52
+ "obsidian-plugin-dev-kit": "github:Dimagious/obsidian-plugin-dev-kit#v0.3.2"
53
+ }
54
+ }
55
+ ```
56
+
57
+ Replace `vX.Y.Z` with the latest tag and pin it exactly.
58
+
59
+ `opdk.config.mjs` is optional. Without it you get the defaults in the table below:
60
+
61
+ ```js
62
+ import { defineConfig } from "obsidian-plugin-dev-kit";
63
+
64
+ export default defineConfig({
65
+ build: {
66
+ loader: { ".png": "dataurl" },
67
+ external: ["some-package"],
68
+ },
69
+ });
70
+ ```
71
+
72
+ For the dev loop, point the kit at the plugin folder inside your dev vault, either with `VAULT_PLUGIN` or with `--vault`:
73
+
74
+ ```bash
75
+ VAULT_PLUGIN="$HOME/vault/.obsidian/plugins/my-plugin" npm run dev:vault
76
+ opdk build --vault ~/vault/.obsidian/plugins/my-plugin
77
+ ```
78
+
79
+ `VAULT_PLUGIN` tends to stay exported in a shell. The build prints where the target came from and refuses a folder whose `manifest.json` holds another plugin id, so a stale variable cannot overwrite a different plugin. Pass `--force` to overwrite anyway. (The second command works because the shell expands `~` before `opdk` sees it; a `~` inside `VAULT_PLUGIN="~/..."` is not expanded and is refused.)
80
+
81
+ ### esbuild in your plugin
82
+
83
+ The kit pins `esbuild` 0.28.2 and `opdk build` uses it, so a plugin needs no esbuild of its own for the build. Drop the plugin's own `esbuild` devDependency once no script of yours calls esbuild directly. Until then, pin the same version the kit does; otherwise you carry two binaries at two versions.
84
+
85
+ ## Options
86
+
87
+ All keys go under `build` in `opdk.config.mjs` and are optional. An unknown key fails with a message naming it and the allowed keys; a value of the wrong type, with a message naming the key and what it must be.
88
+
89
+ | Key | Type | Default | Meaning |
90
+ |---|---|---|---|
91
+ | `entry` | string | `"src/main.ts"` | Bundle entry |
92
+ | `outfile` | string | `"main.js"` | Bundle output |
93
+ | `minify` | boolean | `true` | Minify the release bundle. Vault builds are never minified |
94
+ | `target` | string | `"es2020"` | esbuild target |
95
+ | `external` | string[] | `[]` | Added to the always-external `obsidian`, `electron`, `@codemirror/state`, `@codemirror/view` |
96
+ | `loader` | object | `{ ".css": "text" }` | esbuild loader per extension, for example `{ ".png": "dataurl" }`. Keys start with a dot. Your entries merge over the default, so an `import` of a `.css` file is a string unless you say otherwise |
97
+ | `css` | object or `false` | `{ entry: "src/styles/main.css", outfile: "styles.css" }` | CSS bundler, or `false` to skip it |
98
+ | `css.entry` | string | `"src/styles/main.css"` | CSS entry. `--watch` polls it and every file it imports |
99
+ | `css.outfile` | string | `"styles.css"` | CSS output |
100
+
101
+ Platform `browser`, format `cjs` and the footer that makes `module.exports` the plugin class are not configurable. Paths are relative to the plugin root.
102
+
103
+ Flags of `opdk build`:
104
+
105
+ | Flag | Meaning |
106
+ |---|---|
107
+ | `--vault [dir]`, `--vault=<dir>` | Build into a dev vault: unminified `main.js` in `dir`, then rebuilds `styles.css` and copies it and `manifest.json` there. `dir` defaults to `$VAULT_PLUGIN`. No bundle check. With `css: false`, a `styles.css` in the plugin root is copied if present |
108
+ | `--watch` | With `--vault`: rebuild on changes to the sources, the CSS entry and every file it imports (polled every 300 ms), and `manifest.json`. Stop with Ctrl+C. Rejected without `--vault` |
109
+ | `--force` | With `--vault`: write into a folder whose `manifest.json` holds a different plugin id. Rejected without `--vault` |
110
+
111
+ Other commands:
112
+
113
+ | Command | What it does |
114
+ |---|---|
115
+ | `opdk build-css` | Runs only the CSS step. Exit 1 when the CSS entry does not exist. With `css: false` it prints that CSS is disabled and exits 0. Takes no arguments |
116
+ | `opdk assert-bundle [file]` | Runs only the bundle check. `file` defaults to the build outfile. Exit 1 when the file is missing or has Node-only code; skipped for a desktop-only plugin |
117
+
118
+ The CSS bundler inlines `@import "x.css"` lines recursively, each path relative to the file that contains it. A missing import or an import cycle is an error that names the files. `@import` of a URL is left for the browser.
119
+
120
+ ## What the bundle check looks for
121
+
122
+ | Finding | What it means |
123
+ |---|---|
124
+ | a `process` reference | `process.env`, `process.emitWarning`, `process.platform`, `process.version`, `process.cwd` or `process.argv` is in the bundle |
125
+ | a `node:` builtin import | a `require("node:...")` call |
126
+ | `__dirname` or `__filename` | either name is in the bundle |
127
+ | `LOG_TOKENS`, `LOG_STREAM`, `emitWarning` | property names from the Node build of a dependency; these three come from the Node build of `yaml`, the one the 1.0.0 plugin above shipped. Minification renames variables but keeps property names, so the check looks for these |
128
+
129
+ ## Example output
130
+
131
+ All output below is copied from real runs; paths under the plugin folder are shortened to `/Users/me/plugin`.
132
+
133
+ A clean build (the plugin id comes from `manifest.json`):
134
+
135
+ ```text
136
+ $ opdk build
137
+ ✓ css src/styles/main.css -> styles.css (2 files, 4 lines)
138
+ · build hello-plugin: bundling src/main.ts
139
+ ✓ build hello-plugin: main.js 0.6 KiB
140
+ ✓ bundle main.js is free of Node-only references (0.6 KiB)
141
+ ```
142
+
143
+ `✓` is a step that passed, `✗` a step that failed, `·` progress and `!` a warning. Failures and esbuild's own messages go to stderr; the `✓ · !` lines go to stdout. In a terminal the lines are coloured (green, red, yellow, dim); piped into a file you get the same text without escape codes. Colour rules, in order: a non-empty `NO_COLOR` turns it off; `FORCE_COLOR` turns it on for any value except `0` and `false` (an empty value counts), even on a pipe or with `TERM=dumb`; `TERM=dumb` turns it off; `GITHUB_ACTIONS=true` turns it on, since the Actions log viewer renders it; otherwise colour needs a terminal. The format is for people: do not parse it in scripts, use the exit code.
144
+
145
+ ### A bundle the check rejects
146
+
147
+ The source reads `process.env.HOME`, which does not exist on a phone:
148
+
149
+ ![Terminal: opdk build bundles main.js, then prints "cannot run on mobile" with the offending process reference, and the exit code is 1](media/build-check-fails.gif)
150
+
151
+ ```text
152
+ $ opdk build
153
+ ✓ css src/styles/main.css -> styles.css (1 file, 2 lines)
154
+ · build hello-plugin: bundling src/main.ts
155
+ ✓ build hello-plugin: main.js 0.8 KiB
156
+ ✗ bundle main.js cannot run on mobile:
157
+ - a `process` reference: "process.env"
158
+ Check the esbuild platform: an Obsidian plugin bundles as `browser`.
159
+ $ echo "exit code: $?"
160
+ exit code: 1
161
+ ```
162
+
163
+ Read it from the top: the bundle was written, then the check found a Node-only reference and failed the build. Each `-` line names one finding, and the last line says what to check. A `process`, `node:` or `__dirname` line means your code or a dependency reaches for Node; a marker such as `LOG_TOKENS` means a dependency's Node build got bundled.
164
+
165
+ ### A compile error and a broken CSS import
166
+
167
+ An esbuild error is printed in esbuild's layout, followed by one line from the kit. Here `src/main.ts` was cut off after its first line:
168
+
169
+ ```text
170
+ $ opdk build
171
+ ✓ css src/styles/main.css -> styles.css (2 files, 4 lines)
172
+ · build hello-plugin: bundling src/main.ts
173
+ ✘ [ERROR] Expected identifier but found end of file
174
+
175
+ src/main.ts:2:0:
176
+ 2 │
177
+ ╵ ^
178
+
179
+ ✗ build hello-plugin: build failed with 1 error(s).
180
+ Fix them and rerun `opdk build`.
181
+ ```
182
+
183
+ A missing `@import` target stops the build before the bundle. The message names the importing file, the import and the path it looked for:
184
+
185
+ ```text
186
+ $ opdk build
187
+ ✗ opdk: command "build" failed: /Users/me/plugin/src/styles/main.css: @import "./nope.css" not found (looked for /Users/me/plugin/src/styles/nope.css). Fix the path or remove the import.
188
+ ```
189
+
190
+ Both exit 1.
191
+
192
+ ### The dev vault
193
+
194
+ The build prints where it writes, and refuses a folder that belongs to another plugin:
195
+
196
+ ```text
197
+ $ opdk build --vault ~/vault/.obsidian/plugins/hello-plugin
198
+ · build hello-plugin: vault target /Users/me/vault/.obsidian/plugins/hello-plugin (from --vault)
199
+ ✓ build hello-plugin: built /Users/me/vault/.obsidian/plugins/hello-plugin/main.js
200
+ ✓ css src/styles/main.css -> styles.css (2 files, 4 lines)
201
+ ✓ build hello-plugin: assets copied to /Users/me/vault/.obsidian/plugins/hello-plugin
202
+
203
+ $ VAULT_PLUGIN=~/vault/.obsidian/plugins/other-plugin opdk build --vault
204
+ · build hello-plugin: vault target /Users/me/vault/.obsidian/plugins/other-plugin (from VAULT_PLUGIN)
205
+ ✗ build hello-plugin: /Users/me/vault/.obsidian/plugins/other-plugin holds plugin other-plugin, not hello-plugin. Check VAULT_PLUGIN / --vault, or pass --force to overwrite it.
206
+ ```
207
+
208
+ The second command exits 1 and writes nothing.
209
+
210
+ A watch session, with a CSS file edited and then a source file:
211
+
212
+ ```text
213
+ $ opdk build --vault ~/vault/.obsidian/plugins/hello-plugin --watch
214
+ · build hello-plugin: vault target /Users/me/vault/.obsidian/plugins/hello-plugin (from --vault)
215
+ ✓ build hello-plugin: built /Users/me/vault/.obsidian/plugins/hello-plugin/main.js
216
+ ✓ css src/styles/main.css -> styles.css (2 files, 4 lines)
217
+ ✓ build hello-plugin: assets copied to /Users/me/vault/.obsidian/plugins/hello-plugin
218
+ · build hello-plugin: Watching for changes (Ctrl+C to stop)
219
+ ✓ css src/styles/main.css -> styles.css (2 files, 4 lines)
220
+ ✓ build hello-plugin: assets copied to /Users/me/vault/.obsidian/plugins/hello-plugin
221
+ ✓ build hello-plugin: built /Users/me/vault/.obsidian/plugins/hello-plugin/main.js
222
+ ✓ css src/styles/main.css -> styles.css (2 files, 4 lines)
223
+ ✓ build hello-plugin: assets copied to /Users/me/vault/.obsidian/plugins/hello-plugin
224
+ · build hello-plugin: watch stopped
225
+ ```
226
+
227
+ ### A mistyped option
228
+
229
+ ```text
230
+ $ opdk build # with build: { minfy: true } in opdk.config.mjs
231
+ ✗ opdk: command "build" failed: /Users/me/plugin/opdk.config.mjs: unknown key(s) in "build": minfy. Allowed keys: entry, outfile, minify, target, external, loader, css.
232
+ ```