@commte/mdbrowse 0.3.1 → 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.
package/README.ja.md CHANGED
@@ -59,7 +59,7 @@ mdb
59
59
 
60
60
  プレビュー用のタブが開き、小さな背景プロセスが動きだす。以後どの Markdown を保存しても、どのプロジェクトのものでも、そのタブに出る。止めるときは `mdb --stop`、再開はまた `mdb`
61
61
 
62
- ログアウトや再起動で消える。macOS なら、勝手に戻ってくるようにもできる
62
+ ログアウトや再起動で消えるので、そのままだと次に使うときにもう一度 `mdb` を叩くことになる。macOS なら、勝手に戻ってくるようにもできる
63
63
 
64
64
  ```sh
65
65
  mdb --install-agent
@@ -186,6 +186,14 @@ vim.api.nvim_create_autocmd("BufWritePost", {
186
186
  mdb sample.md
187
187
  ```
188
188
 
189
+ ## テスト
190
+
191
+ ```sh
192
+ npm test
193
+ ```
194
+
195
+ `test/cli.sh` はコマンド側を動かす。変換、相対パスの書き換え、異常系、監視、背景プロセスまで通す。必要なのは pandoc だけ。`test/browser.test.js` は `assets/head.html` からスクリプトを取り出して jsdom で動かし、更新の検知、目次の判定、バーの設定を見る。CI では macOS と Linux の両方で回していて、通らないものは公開されない
196
+
189
197
  ## 仕組み
190
198
 
191
199
  ```
package/README.md CHANGED
@@ -59,7 +59,7 @@ mdb
59
59
 
60
60
  That opens the preview tab and starts a small background process. Save any Markdown file from here on and it shows up in that tab, whichever project it lives in. `mdb --stop` ends it; `mdb` starts it again.
61
61
 
62
- The process is gone after a logout or a reboot. On macOS you can have it come back on its own:
62
+ The process is gone after a logout or a reboot, so otherwise you run `mdb` again next time. On macOS you can have it come back on its own:
63
63
 
64
64
  ```sh
65
65
  mdb --install-agent
@@ -186,6 +186,14 @@ Everything else visual lives in `~/.config/mdbrowse/head.html`: a settings block
186
186
  mdb sample.md
187
187
  ```
188
188
 
189
+ ## Tests
190
+
191
+ ```sh
192
+ npm test
193
+ ```
194
+
195
+ `test/cli.sh` drives the command itself — rendering, path rewriting, exit codes, watching, the background sync — and needs nothing but pandoc. `test/browser.test.js` pulls the script out of `assets/head.html` and runs it under jsdom, covering the reload loop, the table of contents rules and the settings bar. Both run on macOS and Linux in CI, and a release only goes out if they pass.
196
+
189
197
  ## How it works
190
198
 
191
199
  ```
package/bin/mdbrowse CHANGED
@@ -3,7 +3,7 @@
3
3
  # browser tab can stay open and just swap its contents.
4
4
  set -euo pipefail
5
5
 
6
- VERSION="0.3.1"
6
+ VERSION="0.3.2"
7
7
  PROG="$(basename "$0")"
8
8
  OUT="${MDBROWSE_OUT:-/tmp/mdbrowse.html}"
9
9
  case "$OUT" in
@@ -141,6 +141,17 @@ stop_sync() {
141
141
  if [ "$stopped" -eq 1 ]; then echo "$PROG: stopped"; else echo "$PROG: not running"; fi
142
142
  }
143
143
 
144
+ # ログイン時の自動起動があることを、初回だけ1行で知らせる。
145
+ # 毎回出すと邪魔になるので、一度出したら記録して黙る
146
+ hint_agent() {
147
+ [ "$(uname -s)" = "Darwin" ] || return 0
148
+ agent_installed && return 0
149
+ [ -f "$RUNTIME_DIR/agent-hint" ] && return 0
150
+ mkdir -p "$RUNTIME_DIR" 2>/dev/null || true
151
+ : > "$RUNTIME_DIR/agent-hint" 2>/dev/null || true
152
+ echo "$PROG: it stops at logout — 'mdb --install-agent' starts it at every login"
153
+ }
154
+
144
155
  start_sync() {
145
156
  if running_pid >/dev/null; then
146
157
  echo "$PROG: already in sync (mdb --stop to end it)"
@@ -156,6 +167,7 @@ start_sync() {
156
167
  done
157
168
  if running_pid >/dev/null; then
158
169
  echo "$PROG: in sync — save any .md and it shows up here (mdb --stop to end it)"
170
+ hint_agent
159
171
  else
160
172
  echo "$PROG: could not start the background sync (see $LOGFILE)" >&2
161
173
  return 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commte/mdbrowse",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Preview the Markdown file you are editing in a real browser, with your own CSS, from any editor that can run a shell command. No server, no port.",
5
5
  "bin": {
6
6
  "mdbrowse": "bin/mdbrowse",
@@ -15,6 +15,11 @@
15
15
  "README.ja.md",
16
16
  "LICENSE"
17
17
  ],
18
+ "scripts": {
19
+ "test": "bash test/cli.sh && vitest run",
20
+ "test:cli": "bash test/cli.sh",
21
+ "test:browser": "vitest run"
22
+ },
18
23
  "keywords": [
19
24
  "markdown",
20
25
  "preview",
@@ -43,5 +48,9 @@
43
48
  },
44
49
  "dependencies": {
45
50
  "shiki": "^4.4.3"
51
+ },
52
+ "devDependencies": {
53
+ "jsdom": "^30.0.1",
54
+ "vitest": "^5.0.0"
46
55
  }
47
56
  }