shared-things-daemon 1.0.2 → 1.0.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.
Files changed (2) hide show
  1. package/dist/cli.js +36 -1
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -545,7 +545,42 @@ import * as fs5 from "fs";
545
545
  import * as path5 from "path";
546
546
  import { spawn } from "child_process";
547
547
  var pkg = JSON.parse(fs5.readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
548
- updateNotifier({ pkg }).notify();
548
+ var updateCheckInterval = 1e3 * 60 * 60;
549
+ var notifier = updateNotifier({ pkg, updateCheckInterval });
550
+ if (notifier.update) {
551
+ notifier.update.current = pkg.version;
552
+ if (notifier.update.current === notifier.update.latest) {
553
+ notifier.update = void 0;
554
+ }
555
+ }
556
+ var lastCheck = notifier.config?.get("lastUpdateCheck") ?? 0;
557
+ var isFirstRun = Date.now() - lastCheck < 1e3;
558
+ var intervalPassed = Date.now() - lastCheck >= updateCheckInterval;
559
+ if (!notifier.update && (isFirstRun || intervalPassed)) {
560
+ try {
561
+ const update = await notifier.fetchInfo();
562
+ notifier.config?.set("lastUpdateCheck", Date.now());
563
+ if (update && update.type !== "latest") {
564
+ notifier.update = update;
565
+ }
566
+ } catch {
567
+ }
568
+ }
569
+ if (notifier.update && notifier.update.current !== notifier.update.latest) {
570
+ notifier.config?.set("update", notifier.update);
571
+ } else {
572
+ notifier.config?.delete("update");
573
+ }
574
+ process.on("exit", () => {
575
+ if (notifier.update && notifier.update.current !== notifier.update.latest) {
576
+ console.error(
577
+ chalk.yellow(`
578
+ Update available: ${notifier.update.current} \u2192 ${notifier.update.latest}`) + chalk.dim(`
579
+ Run: npm i -g ${pkg.name}
580
+ `)
581
+ );
582
+ }
583
+ });
549
584
  var program = new Command();
550
585
  program.name("shared-things").description("Sync a Things 3 project between multiple users").version(pkg.version);
551
586
  program.command("init").description("Setup wizard").action(async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shared-things-daemon",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Sync Things 3 projects between multiple macOS users",
5
5
  "type": "module",
6
6
  "main": "./dist/cli.js",
@@ -54,4 +54,4 @@
54
54
  "tsx": "^4.7.0",
55
55
  "typescript": "^5.3.0"
56
56
  }
57
- }
57
+ }