backdot 1.3.1 → 1.4.0

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
@@ -20,7 +20,7 @@ This creates `~/.backdot.json` with sensible defaults and walks you through setu
20
20
  "repository": "git@github.com:USERNAME/backdot-backup.git",
21
21
  "machine": "my-work-laptop",
22
22
  "gitignored": ["~/my-project"],
23
- "paths": ["~/.zshrc", "~/.oh-my-zsh/custom/*.zsh", "~/.ssh/config/config", "~/.npmrc"]
23
+ "paths": ["~/.zshrc", "~/.oh-my-zsh/custom/*.zsh", "~/.ssh/config", "~/.npmrc"]
24
24
  }
25
25
  ```
26
26
 
@@ -30,6 +30,12 @@ Run your first backup:
30
30
  backdot --backup
31
31
  ```
32
32
 
33
+ or configure the backport process to run automatically (daily at 2am)
34
+
35
+ ```bash
36
+ backdot --schedule
37
+ ```
38
+
33
39
  ## Configuration
34
40
 
35
41
  | Key | Description |
package/dist/cli.js CHANGED
@@ -12,6 +12,7 @@ import { restore } from "./restore.js";
12
12
  import { init } from "./init.js";
13
13
  import { setupLaunchd, uninstallLaunchd, isScheduled } from "./plist.js";
14
14
  import { logger } from "./log.js";
15
+ import { sendNotification } from "./notify.js";
15
16
  function getVersion() {
16
17
  const pkgPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), "../package.json");
17
18
  try {
@@ -176,6 +177,9 @@ async function main() {
176
177
  const msg = err instanceof Error ? err.message : String(err);
177
178
  logger.error(msg);
178
179
  console.error(`\n Error: ${msg}\n`);
180
+ if (!process.stdout.isTTY) {
181
+ sendNotification("Backdot", `Backup failed: ${msg}`);
182
+ }
179
183
  process.exit(1);
180
184
  }
181
185
  }
@@ -0,0 +1 @@
1
+ export declare function sendNotification(title: string, message: string): void;
package/dist/notify.js ADDED
@@ -0,0 +1,15 @@
1
+ import { execSync } from "node:child_process";
2
+ import { logger } from "./log.js";
3
+ export function sendNotification(title, message) {
4
+ if (process.platform !== "darwin")
5
+ return;
6
+ const escaped = message.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
7
+ const titleEscaped = title.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
8
+ try {
9
+ execSync(`osascript -e 'display notification "${escaped}" with title "${titleEscaped}" subtitle "Scheduled backup failed"'`, { stdio: "pipe" });
10
+ }
11
+ catch (err) {
12
+ const msg = err instanceof Error ? err.message : String(err);
13
+ logger.warn(`Failed to send notification: ${msg}`);
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backdot",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Lightweight CLI to backup dotfiles and gitignored files to a Git repo on a daily schedule",
5
5
  "type": "module",
6
6
  "license": "MIT",