newsline-cli 1.0.1 → 1.0.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.md CHANGED
@@ -98,7 +98,13 @@ Claude Code plugin: run `/plugin marketplace update itdar`, then `/reload-plugin
98
98
  ## Uninstall
99
99
 
100
100
  ```sh
101
- newsline uninstall # restores your previous status line
101
+ newsline uninstall # restores your previous status line
102
+ newsline uninstall --purge # also removes the CLI binary + the PATH line install.sh added
102
103
  ```
103
104
 
104
105
  Needs `bash` + `python3` (macOS / Linux; Windows via WSL).
106
+
107
+ ## Contributing
108
+
109
+ Bug reports and PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) for local setup,
110
+ testing, and the release process.
package/install.sh CHANGED
@@ -34,6 +34,32 @@ ln -sf "$SHARE/newsline" "$BIN/newsline"
34
34
 
35
35
  echo "✔ installed: $BIN/newsline"
36
36
 
37
+ # Garbage-collect stale PATH lines from earlier installs whose prefix no longer
38
+ # exists (e.g. throwaway test prefixes), so rc files don't pile up dead newsline
39
+ # entries that shadow the current install. Only drops blocks whose dir is gone.
40
+ prune_stale_newsline_path() { # $1 = rc file
41
+ [ -f "$1" ] || return 0
42
+ awk '
43
+ /^# added by newsline installer$/ {
44
+ marker=$0
45
+ if ((getline pl) > 0) {
46
+ keep=1
47
+ if (match(pl, /\/[^ "]*\/bin/)) {
48
+ d=substr(pl, RSTART, RLENGTH)
49
+ if (system("[ -d \"" d "\" ]") != 0) keep=0
50
+ }
51
+ if (keep) { print marker; print pl }
52
+ next
53
+ }
54
+ print marker; next
55
+ }
56
+ { print }
57
+ ' "$1" > "$1.nltmp" 2>/dev/null && mv "$1.nltmp" "$1"
58
+ }
59
+ for rc in "$HOME/.zshrc" "$HOME/.bashrc" "$HOME/.profile" "$HOME/.config/fish/config.fish"; do
60
+ prune_stale_newsline_path "$rc"
61
+ done
62
+
37
63
  # Register $BIN on PATH for future shells (idempotent), by shell rc file.
38
64
  case ":$PATH:" in
39
65
  *":$BIN:"*)
package/newsline CHANGED
@@ -342,6 +342,8 @@ PY
342
342
  }
343
343
 
344
344
  cmd_uninstall() {
345
+ local purge=0 a
346
+ for a in "$@"; do case "$a" in --purge|-p) purge=1 ;; esac; done
345
347
  local base base_obj
346
348
  base=$(cfg_get base_statusline)
347
349
  base_obj=$(cfg_get_obj base_statusline_obj)
@@ -378,6 +380,48 @@ PY
378
380
  local cache="${NEWSLINE_CACHE:-$HOME/.cache/newsline}"
379
381
  rm -f "$CONFIG" "$cache/line" "$cache/feeds.resolved.json" "$cache/feeds.resolved.ok" "$cache/notice" 2>/dev/null
380
382
  echo "✔ newsline uninstalled."
383
+
384
+ [ "$purge" = "1" ] || return 0
385
+ # --purge: also remove the CLI binary + the PATH line install.sh added. Only for
386
+ # the install.sh layout ($PREFIX/share/newsline + $PREFIX/bin/newsline); a
387
+ # package-managed install (brew/npm) is left to its own package manager.
388
+ case "$HERE" in
389
+ */share/newsline)
390
+ local prefix bin rc
391
+ prefix="$(cd "$HERE/../.." 2>/dev/null && pwd)"; bin="$prefix/bin"
392
+ if [ -e "$bin/newsline" ]; then
393
+ rm -f "$bin/newsline"
394
+ rm -rf "$HERE" # $PREFIX/share/newsline (this script's dir)
395
+ for rc in "$HOME/.zshrc" "$HOME/.bashrc" "$HOME/.profile" "$HOME/.config/fish/config.fish"; do
396
+ [ -f "$rc" ] || continue
397
+ awk -v bin="$bin" '
398
+ function strip(p){ sub(/^\/private/, "", p); return p } # macOS /var == /private/var
399
+ /^# added by newsline installer$/ {
400
+ marker=$0
401
+ if ((getline pl) > 0) {
402
+ drop=0
403
+ if (match(pl, /\/[^ "]*\/bin/)) {
404
+ d=substr(pl, RSTART, RLENGTH)
405
+ if (strip(d) == strip(bin)) drop=1 # our block -> drop marker + path line
406
+ }
407
+ if (drop) next
408
+ print marker; print pl; next
409
+ }
410
+ print marker; next
411
+ }
412
+ { print }
413
+ ' "$rc" > "$rc.nltmp" 2>/dev/null && mv "$rc.nltmp" "$rc"
414
+ done
415
+ echo "✔ purged CLI: removed $bin/newsline and its PATH entry (open a new shell to refresh PATH)."
416
+ else
417
+ echo "ℹ nothing to purge (no $bin/newsline)."
418
+ fi
419
+ ;;
420
+ *)
421
+ echo "ℹ this CLI wasn't installed via install.sh (looks package-managed);"
422
+ echo " remove it with: brew uninstall newsline or npm uninstall -g newsline-cli"
423
+ ;;
424
+ esac
381
425
  }
382
426
 
383
427
  usage() {
@@ -390,7 +434,8 @@ newsline — local news status-line utility
390
434
  white → cyan → yellow → green → blue →
391
435
  magenta → red → back to default
392
436
  newsline colorlist list the available colors with a preview
393
- newsline uninstall remove & restore previous status line
437
+ newsline uninstall [--purge] remove & restore previous status line
438
+ (--purge also deletes the CLI + PATH line)
394
439
  EOF
395
440
  if [ "${1:-}" = "--all" ]; then
396
441
  cat <<'EOF'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newsline-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Locale-aware one-line news in your Claude Code status line — local, composes with your existing status line.",
5
5
  "bin": {
6
6
  "newsline": "newsline"
package/refresh.sh CHANGED
@@ -23,7 +23,7 @@ case "$API" in off|OFF|none|local) API="" ;; esac
23
23
  COUNT="${NEWSLINE_COUNT:-15}" # how many headlines to cache for rotation
24
24
  # Client version, sent to /feed as ?v= for the server-side update nudge.
25
25
  # Bump together with package.json when tagging a release.
26
- export NEWSLINE_VERSION="${NEWSLINE_VERSION:-1.0.1}"
26
+ export NEWSLINE_VERSION="${NEWSLINE_VERSION:-1.0.2}"
27
27
  LOCK="$CACHE_DIR/refresh.lock"
28
28
  mkdir -p "$CACHE_DIR" 2>/dev/null
29
29