ledgit-cli 0.1.1 → 0.1.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 (2) hide show
  1. package/dist/index.js +307 -287
  2. package/package.json +8 -7
package/dist/index.js CHANGED
@@ -19,6 +19,46 @@ var __toESM = (mod, isNodeMode, target) => {
19
19
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
20
20
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
21
21
 
22
+ // ../../node_modules/cli-width/index.js
23
+ var require_cli_width = __commonJS((exports, module) => {
24
+ module.exports = cliWidth;
25
+ function normalizeOpts(options) {
26
+ const defaultOpts = {
27
+ defaultWidth: 0,
28
+ output: process.stdout,
29
+ tty: __require("tty")
30
+ };
31
+ if (!options) {
32
+ return defaultOpts;
33
+ }
34
+ Object.keys(defaultOpts).forEach(function(key) {
35
+ if (!options[key]) {
36
+ options[key] = defaultOpts[key];
37
+ }
38
+ });
39
+ return options;
40
+ }
41
+ function cliWidth(options) {
42
+ const opts = normalizeOpts(options);
43
+ if (opts.output.getWindowSize) {
44
+ return opts.output.getWindowSize()[0] || opts.defaultWidth;
45
+ }
46
+ if (opts.tty.getWindowSize) {
47
+ return opts.tty.getWindowSize()[1] || opts.defaultWidth;
48
+ }
49
+ if (opts.output.columns) {
50
+ return opts.output.columns;
51
+ }
52
+ if (process.env.CLI_WIDTH) {
53
+ const width = parseInt(process.env.CLI_WIDTH, 10);
54
+ if (!isNaN(width) && width !== 0) {
55
+ return width;
56
+ }
57
+ }
58
+ return opts.defaultWidth;
59
+ }
60
+ });
61
+
22
62
  // ../../node_modules/delayed-stream/lib/delayed_stream.js
23
63
  var require_delayed_stream = __commonJS((exports, module) => {
24
64
  var Stream = __require("stream").Stream;
@@ -10495,7 +10535,7 @@ var require_common = __commonJS((exports, module) => {
10495
10535
  var require_browser = __commonJS((exports, module) => {
10496
10536
  exports.formatArgs = formatArgs;
10497
10537
  exports.save = save;
10498
- exports.load = load;
10538
+ exports.load = load2;
10499
10539
  exports.useColors = useColors;
10500
10540
  exports.storage = localstorage();
10501
10541
  exports.destroy = (() => {
@@ -10627,7 +10667,7 @@ var require_browser = __commonJS((exports, module) => {
10627
10667
  } catch (error) {
10628
10668
  }
10629
10669
  }
10630
- function load() {
10670
+ function load2() {
10631
10671
  let r;
10632
10672
  try {
10633
10673
  r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
@@ -10663,7 +10703,7 @@ var require_node = __commonJS((exports, module) => {
10663
10703
  exports.log = log;
10664
10704
  exports.formatArgs = formatArgs;
10665
10705
  exports.save = save;
10666
- exports.load = load;
10706
+ exports.load = load2;
10667
10707
  exports.useColors = useColors;
10668
10708
  exports.destroy = util.deprecate(() => {
10669
10709
  }, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
@@ -10805,7 +10845,7 @@ var require_node = __commonJS((exports, module) => {
10805
10845
  delete process.env.DEBUG;
10806
10846
  }
10807
10847
  }
10808
- function load() {
10848
+ function load2() {
10809
10849
  return process.env.DEBUG;
10810
10850
  }
10811
10851
  function init(debug) {
@@ -13819,8 +13859,8 @@ var require_axios = __commonJS((exports, module) => {
13819
13859
  request.send(requestData || null);
13820
13860
  });
13821
13861
  };
13822
- var composeSignals = (signals, timeout) => {
13823
- const { length } = signals = signals ? signals.filter(Boolean) : [];
13862
+ var composeSignals = (signals2, timeout) => {
13863
+ const { length } = signals2 = signals2 ? signals2.filter(Boolean) : [];
13824
13864
  if (timeout || length) {
13825
13865
  let controller = new AbortController;
13826
13866
  let aborted;
@@ -13837,16 +13877,16 @@ var require_axios = __commonJS((exports, module) => {
13837
13877
  onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
13838
13878
  }, timeout);
13839
13879
  const unsubscribe = () => {
13840
- if (signals) {
13880
+ if (signals2) {
13841
13881
  timer && clearTimeout(timer);
13842
13882
  timer = null;
13843
- signals.forEach((signal2) => {
13883
+ signals2.forEach((signal2) => {
13844
13884
  signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
13845
13885
  });
13846
- signals = null;
13886
+ signals2 = null;
13847
13887
  }
13848
13888
  };
13849
- signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
13889
+ signals2.forEach((signal2) => signal2.addEventListener("abort", onabort));
13850
13890
  const { signal } = controller;
13851
13891
  signal.unsubscribe = () => utils$1.asap(unsubscribe);
13852
13892
  return signal;
@@ -15473,46 +15513,6 @@ var require_cli_progress = __commonJS((exports, module) => {
15473
15513
  };
15474
15514
  });
15475
15515
 
15476
- // ../../node_modules/cli-width/index.js
15477
- var require_cli_width = __commonJS((exports, module) => {
15478
- module.exports = cliWidth;
15479
- function normalizeOpts(options) {
15480
- const defaultOpts = {
15481
- defaultWidth: 0,
15482
- output: process.stdout,
15483
- tty: __require("tty")
15484
- };
15485
- if (!options) {
15486
- return defaultOpts;
15487
- }
15488
- Object.keys(defaultOpts).forEach(function(key) {
15489
- if (!options[key]) {
15490
- options[key] = defaultOpts[key];
15491
- }
15492
- });
15493
- return options;
15494
- }
15495
- function cliWidth(options) {
15496
- const opts = normalizeOpts(options);
15497
- if (opts.output.getWindowSize) {
15498
- return opts.output.getWindowSize()[0] || opts.defaultWidth;
15499
- }
15500
- if (opts.tty.getWindowSize) {
15501
- return opts.tty.getWindowSize()[1] || opts.defaultWidth;
15502
- }
15503
- if (opts.output.columns) {
15504
- return opts.output.columns;
15505
- }
15506
- if (process.env.CLI_WIDTH) {
15507
- const width = parseInt(process.env.CLI_WIDTH, 10);
15508
- if (!isNaN(width) && width !== 0) {
15509
- return width;
15510
- }
15511
- }
15512
- return opts.defaultWidth;
15513
- }
15514
- });
15515
-
15516
15516
  // node_modules/@inquirer/prompts/node_modules/@inquirer/confirm/node_modules/@inquirer/core/node_modules/wrap-ansi/node_modules/string-width/node_modules/emoji-regex/index.js
15517
15517
  var require_emoji_regex2 = __commonJS((exports, module) => {
15518
15518
  module.exports = () => {
@@ -15642,6 +15642,226 @@ var require_lib = __commonJS((exports, module) => {
15642
15642
 
15643
15643
  // src/index.ts
15644
15644
  import { Command } from "commander";
15645
+ import { createRequire as createRequire2 } from "node:module";
15646
+
15647
+ // ../../node_modules/@inquirer/core/dist/esm/lib/errors.js
15648
+ class ExitPromptError extends Error {
15649
+ name = "ExitPromptError";
15650
+ }
15651
+
15652
+ // ../../node_modules/signal-exit/dist/mjs/signals.js
15653
+ var signals = [];
15654
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
15655
+ if (process.platform !== "win32") {
15656
+ signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
15657
+ }
15658
+ if (process.platform === "linux") {
15659
+ signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
15660
+ }
15661
+
15662
+ // ../../node_modules/signal-exit/dist/mjs/index.js
15663
+ var processOk = (process2) => !!process2 && typeof process2 === "object" && typeof process2.removeListener === "function" && typeof process2.emit === "function" && typeof process2.reallyExit === "function" && typeof process2.listeners === "function" && typeof process2.kill === "function" && typeof process2.pid === "number" && typeof process2.on === "function";
15664
+ var kExitEmitter = Symbol.for("signal-exit emitter");
15665
+ var global2 = globalThis;
15666
+ var ObjectDefineProperty = Object.defineProperty.bind(Object);
15667
+
15668
+ class Emitter {
15669
+ emitted = {
15670
+ afterExit: false,
15671
+ exit: false
15672
+ };
15673
+ listeners = {
15674
+ afterExit: [],
15675
+ exit: []
15676
+ };
15677
+ count = 0;
15678
+ id = Math.random();
15679
+ constructor() {
15680
+ if (global2[kExitEmitter]) {
15681
+ return global2[kExitEmitter];
15682
+ }
15683
+ ObjectDefineProperty(global2, kExitEmitter, {
15684
+ value: this,
15685
+ writable: false,
15686
+ enumerable: false,
15687
+ configurable: false
15688
+ });
15689
+ }
15690
+ on(ev, fn) {
15691
+ this.listeners[ev].push(fn);
15692
+ }
15693
+ removeListener(ev, fn) {
15694
+ const list = this.listeners[ev];
15695
+ const i = list.indexOf(fn);
15696
+ if (i === -1) {
15697
+ return;
15698
+ }
15699
+ if (i === 0 && list.length === 1) {
15700
+ list.length = 0;
15701
+ } else {
15702
+ list.splice(i, 1);
15703
+ }
15704
+ }
15705
+ emit(ev, code, signal) {
15706
+ if (this.emitted[ev]) {
15707
+ return false;
15708
+ }
15709
+ this.emitted[ev] = true;
15710
+ let ret = false;
15711
+ for (const fn of this.listeners[ev]) {
15712
+ ret = fn(code, signal) === true || ret;
15713
+ }
15714
+ if (ev === "exit") {
15715
+ ret = this.emit("afterExit", code, signal) || ret;
15716
+ }
15717
+ return ret;
15718
+ }
15719
+ }
15720
+
15721
+ class SignalExitBase {
15722
+ }
15723
+ var signalExitWrap = (handler) => {
15724
+ return {
15725
+ onExit(cb, opts) {
15726
+ return handler.onExit(cb, opts);
15727
+ },
15728
+ load() {
15729
+ return handler.load();
15730
+ },
15731
+ unload() {
15732
+ return handler.unload();
15733
+ }
15734
+ };
15735
+ };
15736
+
15737
+ class SignalExitFallback extends SignalExitBase {
15738
+ onExit() {
15739
+ return () => {
15740
+ };
15741
+ }
15742
+ load() {
15743
+ }
15744
+ unload() {
15745
+ }
15746
+ }
15747
+
15748
+ class SignalExit extends SignalExitBase {
15749
+ #hupSig = process2.platform === "win32" ? "SIGINT" : "SIGHUP";
15750
+ #emitter = new Emitter;
15751
+ #process;
15752
+ #originalProcessEmit;
15753
+ #originalProcessReallyExit;
15754
+ #sigListeners = {};
15755
+ #loaded = false;
15756
+ constructor(process2) {
15757
+ super();
15758
+ this.#process = process2;
15759
+ this.#sigListeners = {};
15760
+ for (const sig of signals) {
15761
+ this.#sigListeners[sig] = () => {
15762
+ const listeners = this.#process.listeners(sig);
15763
+ let { count } = this.#emitter;
15764
+ const p = process2;
15765
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
15766
+ count += p.__signal_exit_emitter__.count;
15767
+ }
15768
+ if (listeners.length === count) {
15769
+ this.unload();
15770
+ const ret = this.#emitter.emit("exit", null, sig);
15771
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
15772
+ if (!ret)
15773
+ process2.kill(process2.pid, s);
15774
+ }
15775
+ };
15776
+ }
15777
+ this.#originalProcessReallyExit = process2.reallyExit;
15778
+ this.#originalProcessEmit = process2.emit;
15779
+ }
15780
+ onExit(cb, opts) {
15781
+ if (!processOk(this.#process)) {
15782
+ return () => {
15783
+ };
15784
+ }
15785
+ if (this.#loaded === false) {
15786
+ this.load();
15787
+ }
15788
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
15789
+ this.#emitter.on(ev, cb);
15790
+ return () => {
15791
+ this.#emitter.removeListener(ev, cb);
15792
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
15793
+ this.unload();
15794
+ }
15795
+ };
15796
+ }
15797
+ load() {
15798
+ if (this.#loaded) {
15799
+ return;
15800
+ }
15801
+ this.#loaded = true;
15802
+ this.#emitter.count += 1;
15803
+ for (const sig of signals) {
15804
+ try {
15805
+ const fn = this.#sigListeners[sig];
15806
+ if (fn)
15807
+ this.#process.on(sig, fn);
15808
+ } catch (_) {
15809
+ }
15810
+ }
15811
+ this.#process.emit = (ev, ...a) => {
15812
+ return this.#processEmit(ev, ...a);
15813
+ };
15814
+ this.#process.reallyExit = (code) => {
15815
+ return this.#processReallyExit(code);
15816
+ };
15817
+ }
15818
+ unload() {
15819
+ if (!this.#loaded) {
15820
+ return;
15821
+ }
15822
+ this.#loaded = false;
15823
+ signals.forEach((sig) => {
15824
+ const listener = this.#sigListeners[sig];
15825
+ if (!listener) {
15826
+ throw new Error("Listener not defined for signal: " + sig);
15827
+ }
15828
+ try {
15829
+ this.#process.removeListener(sig, listener);
15830
+ } catch (_) {
15831
+ }
15832
+ });
15833
+ this.#process.emit = this.#originalProcessEmit;
15834
+ this.#process.reallyExit = this.#originalProcessReallyExit;
15835
+ this.#emitter.count -= 1;
15836
+ }
15837
+ #processReallyExit(code) {
15838
+ if (!processOk(this.#process)) {
15839
+ return 0;
15840
+ }
15841
+ this.#process.exitCode = code || 0;
15842
+ this.#emitter.emit("exit", this.#process.exitCode, null);
15843
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
15844
+ }
15845
+ #processEmit(ev, ...args) {
15846
+ const og = this.#originalProcessEmit;
15847
+ if (ev === "exit" && processOk(this.#process)) {
15848
+ if (typeof args[0] === "number") {
15849
+ this.#process.exitCode = args[0];
15850
+ }
15851
+ const ret = og.call(this.#process, ev, ...args);
15852
+ this.#emitter.emit("exit", this.#process.exitCode, null);
15853
+ return ret;
15854
+ } else {
15855
+ return og.call(this.#process, ev, ...args);
15856
+ }
15857
+ }
15858
+ }
15859
+ var process2 = globalThis.process;
15860
+ var {
15861
+ onExit,
15862
+ load,
15863
+ unload
15864
+ } = signalExitWrap(processOk(process2) ? new SignalExit(process2) : new SignalExitFallback);
15645
15865
 
15646
15866
  // ../../node_modules/posthog-node/lib/node/index.mjs
15647
15867
  import { posix, dirname, sep } from "path";
@@ -19234,6 +19454,9 @@ import { join } from "node:path";
19234
19454
  import { homedir } from "node:os";
19235
19455
  var config;
19236
19456
  var client = null;
19457
+ function initialize(options) {
19458
+ config = options;
19459
+ }
19237
19460
  function setVersion(version2) {
19238
19461
  if (config) {
19239
19462
  config.version = version2;
@@ -23679,7 +23902,7 @@ init_utils();
23679
23902
  var never = import_promise_deferred2.deferred().promise;
23680
23903
  function completionDetectionPlugin({
23681
23904
  onClose = true,
23682
- onExit = 50
23905
+ onExit: onExit2 = 50
23683
23906
  } = {}) {
23684
23907
  function createEvents() {
23685
23908
  let exitCode = -1;
@@ -23691,10 +23914,10 @@ function completionDetectionPlugin({
23691
23914
  };
23692
23915
  const result = Promise.race([
23693
23916
  onClose === false ? never : events.closeTimeout.promise,
23694
- onExit === false ? never : events.exitTimeout.promise
23917
+ onExit2 === false ? never : events.exitTimeout.promise
23695
23918
  ]);
23696
23919
  configureTimeout(onClose, events.close, events.closeTimeout);
23697
- configureTimeout(onExit, events.exit, events.exitTimeout);
23920
+ configureTimeout(onExit2, events.exit, events.exitTimeout);
23698
23921
  return {
23699
23922
  close(code) {
23700
23923
  exitCode = code;
@@ -24665,7 +24888,7 @@ async function syncFortnoxInbox(client2, storage, options = {}) {
24665
24888
  import * as http from "node:http";
24666
24889
 
24667
24890
  // ../../node_modules/open/index.js
24668
- import process7 from "node:process";
24891
+ import process8 from "node:process";
24669
24892
  import { Buffer as Buffer3 } from "node:buffer";
24670
24893
  import path4 from "node:path";
24671
24894
  import { fileURLToPath } from "node:url";
@@ -24674,11 +24897,11 @@ import childProcess from "node:child_process";
24674
24897
  import fs8, { constants as fsConstants2 } from "node:fs/promises";
24675
24898
 
24676
24899
  // ../../node_modules/wsl-utils/index.js
24677
- import process3 from "node:process";
24900
+ import process4 from "node:process";
24678
24901
  import fs7, { constants as fsConstants } from "node:fs/promises";
24679
24902
 
24680
24903
  // ../../node_modules/is-wsl/index.js
24681
- import process2 from "node:process";
24904
+ import process3 from "node:process";
24682
24905
  import os from "node:os";
24683
24906
  import fs6 from "node:fs";
24684
24907
 
@@ -24729,7 +24952,7 @@ function isInsideContainer() {
24729
24952
 
24730
24953
  // ../../node_modules/is-wsl/index.js
24731
24954
  var isWsl = () => {
24732
- if (process2.platform !== "linux") {
24955
+ if (process3.platform !== "linux") {
24733
24956
  return false;
24734
24957
  }
24735
24958
  if (os.release().toLowerCase().includes("microsoft")) {
@@ -24744,7 +24967,7 @@ var isWsl = () => {
24744
24967
  return false;
24745
24968
  }
24746
24969
  };
24747
- var is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
24970
+ var is_wsl_default = process3.env.__IS_WSL_TEST__ ? isWsl : isWsl();
24748
24971
 
24749
24972
  // ../../node_modules/wsl-utils/index.js
24750
24973
  var wslDrivesMountPoint = (() => {
@@ -24782,7 +25005,7 @@ var powerShellPath = async () => {
24782
25005
  if (is_wsl_default) {
24783
25006
  return powerShellPathFromWsl();
24784
25007
  }
24785
- return `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
25008
+ return `${process4.env.SYSTEMROOT || process4.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
24786
25009
  };
24787
25010
 
24788
25011
  // ../../node_modules/define-lazy-prop/index.js
@@ -24805,16 +25028,16 @@ function defineLazyProperty(object, propertyName, valueGetter) {
24805
25028
 
24806
25029
  // ../../node_modules/default-browser/index.js
24807
25030
  import { promisify as promisify4 } from "node:util";
24808
- import process6 from "node:process";
25031
+ import process7 from "node:process";
24809
25032
  import { execFile as execFile4 } from "node:child_process";
24810
25033
 
24811
25034
  // ../../node_modules/default-browser-id/index.js
24812
25035
  import { promisify } from "node:util";
24813
- import process4 from "node:process";
25036
+ import process5 from "node:process";
24814
25037
  import { execFile } from "node:child_process";
24815
25038
  var execFileAsync = promisify(execFile);
24816
25039
  async function defaultBrowserId() {
24817
- if (process4.platform !== "darwin") {
25040
+ if (process5.platform !== "darwin") {
24818
25041
  throw new Error("macOS only");
24819
25042
  }
24820
25043
  const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
@@ -24827,12 +25050,12 @@ async function defaultBrowserId() {
24827
25050
  }
24828
25051
 
24829
25052
  // ../../node_modules/run-applescript/index.js
24830
- import process5 from "node:process";
25053
+ import process6 from "node:process";
24831
25054
  import { promisify as promisify2 } from "node:util";
24832
25055
  import { execFile as execFile2, execFileSync } from "node:child_process";
24833
25056
  var execFileAsync2 = promisify2(execFile2);
24834
25057
  async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
24835
- if (process5.platform !== "darwin") {
25058
+ if (process6.platform !== "darwin") {
24836
25059
  throw new Error("macOS only");
24837
25060
  }
24838
25061
  const outputArguments = humanReadableOutput ? [] : ["-ss"];
@@ -24899,18 +25122,18 @@ async function defaultBrowser(_execFileAsync = execFileAsync3) {
24899
25122
  var execFileAsync4 = promisify4(execFile4);
24900
25123
  var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
24901
25124
  async function defaultBrowser2() {
24902
- if (process6.platform === "darwin") {
25125
+ if (process7.platform === "darwin") {
24903
25126
  const id = await defaultBrowserId();
24904
25127
  const name = await bundleName(id);
24905
25128
  return { name, id };
24906
25129
  }
24907
- if (process6.platform === "linux") {
25130
+ if (process7.platform === "linux") {
24908
25131
  const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
24909
25132
  const id = stdout.trim();
24910
25133
  const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
24911
25134
  return { name, id };
24912
25135
  }
24913
- if (process6.platform === "win32") {
25136
+ if (process7.platform === "win32") {
24914
25137
  return defaultBrowser();
24915
25138
  }
24916
25139
  throw new Error("Only macOS, Linux, and Windows are supported");
@@ -24920,7 +25143,7 @@ async function defaultBrowser2() {
24920
25143
  var execFile5 = promisify5(childProcess.execFile);
24921
25144
  var __dirname2 = path4.dirname(fileURLToPath(import.meta.url));
24922
25145
  var localXdgOpenPath = path4.join(__dirname2, "xdg-open");
24923
- var { platform, arch } = process7;
25146
+ var { platform, arch } = process8;
24924
25147
  async function getWindowsDefaultBrowserFromWsl() {
24925
25148
  const powershellPath = await powerShellPath();
24926
25149
  const rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
@@ -25063,7 +25286,7 @@ var baseOpen = async (options) => {
25063
25286
  exeLocalXdgOpen = true;
25064
25287
  } catch {
25065
25288
  }
25066
- const useSystemXdgOpen = process7.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
25289
+ const useSystemXdgOpen = process8.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
25067
25290
  command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
25068
25291
  }
25069
25292
  if (appArguments.length > 0) {
@@ -28312,220 +28535,6 @@ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
28312
28535
  return 1;
28313
28536
  }
28314
28537
 
28315
- // ../../node_modules/signal-exit/dist/mjs/signals.js
28316
- var signals = [];
28317
- signals.push("SIGHUP", "SIGINT", "SIGTERM");
28318
- if (process.platform !== "win32") {
28319
- signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
28320
- }
28321
- if (process.platform === "linux") {
28322
- signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
28323
- }
28324
-
28325
- // ../../node_modules/signal-exit/dist/mjs/index.js
28326
- var processOk = (process8) => !!process8 && typeof process8 === "object" && typeof process8.removeListener === "function" && typeof process8.emit === "function" && typeof process8.reallyExit === "function" && typeof process8.listeners === "function" && typeof process8.kill === "function" && typeof process8.pid === "number" && typeof process8.on === "function";
28327
- var kExitEmitter = Symbol.for("signal-exit emitter");
28328
- var global2 = globalThis;
28329
- var ObjectDefineProperty = Object.defineProperty.bind(Object);
28330
-
28331
- class Emitter {
28332
- emitted = {
28333
- afterExit: false,
28334
- exit: false
28335
- };
28336
- listeners = {
28337
- afterExit: [],
28338
- exit: []
28339
- };
28340
- count = 0;
28341
- id = Math.random();
28342
- constructor() {
28343
- if (global2[kExitEmitter]) {
28344
- return global2[kExitEmitter];
28345
- }
28346
- ObjectDefineProperty(global2, kExitEmitter, {
28347
- value: this,
28348
- writable: false,
28349
- enumerable: false,
28350
- configurable: false
28351
- });
28352
- }
28353
- on(ev, fn) {
28354
- this.listeners[ev].push(fn);
28355
- }
28356
- removeListener(ev, fn) {
28357
- const list = this.listeners[ev];
28358
- const i = list.indexOf(fn);
28359
- if (i === -1) {
28360
- return;
28361
- }
28362
- if (i === 0 && list.length === 1) {
28363
- list.length = 0;
28364
- } else {
28365
- list.splice(i, 1);
28366
- }
28367
- }
28368
- emit(ev, code, signal) {
28369
- if (this.emitted[ev]) {
28370
- return false;
28371
- }
28372
- this.emitted[ev] = true;
28373
- let ret = false;
28374
- for (const fn of this.listeners[ev]) {
28375
- ret = fn(code, signal) === true || ret;
28376
- }
28377
- if (ev === "exit") {
28378
- ret = this.emit("afterExit", code, signal) || ret;
28379
- }
28380
- return ret;
28381
- }
28382
- }
28383
-
28384
- class SignalExitBase {
28385
- }
28386
- var signalExitWrap = (handler) => {
28387
- return {
28388
- onExit(cb, opts) {
28389
- return handler.onExit(cb, opts);
28390
- },
28391
- load() {
28392
- return handler.load();
28393
- },
28394
- unload() {
28395
- return handler.unload();
28396
- }
28397
- };
28398
- };
28399
-
28400
- class SignalExitFallback extends SignalExitBase {
28401
- onExit() {
28402
- return () => {
28403
- };
28404
- }
28405
- load() {
28406
- }
28407
- unload() {
28408
- }
28409
- }
28410
-
28411
- class SignalExit extends SignalExitBase {
28412
- #hupSig = process8.platform === "win32" ? "SIGINT" : "SIGHUP";
28413
- #emitter = new Emitter;
28414
- #process;
28415
- #originalProcessEmit;
28416
- #originalProcessReallyExit;
28417
- #sigListeners = {};
28418
- #loaded = false;
28419
- constructor(process8) {
28420
- super();
28421
- this.#process = process8;
28422
- this.#sigListeners = {};
28423
- for (const sig of signals) {
28424
- this.#sigListeners[sig] = () => {
28425
- const listeners = this.#process.listeners(sig);
28426
- let { count } = this.#emitter;
28427
- const p = process8;
28428
- if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
28429
- count += p.__signal_exit_emitter__.count;
28430
- }
28431
- if (listeners.length === count) {
28432
- this.unload();
28433
- const ret = this.#emitter.emit("exit", null, sig);
28434
- const s = sig === "SIGHUP" ? this.#hupSig : sig;
28435
- if (!ret)
28436
- process8.kill(process8.pid, s);
28437
- }
28438
- };
28439
- }
28440
- this.#originalProcessReallyExit = process8.reallyExit;
28441
- this.#originalProcessEmit = process8.emit;
28442
- }
28443
- onExit(cb, opts) {
28444
- if (!processOk(this.#process)) {
28445
- return () => {
28446
- };
28447
- }
28448
- if (this.#loaded === false) {
28449
- this.load();
28450
- }
28451
- const ev = opts?.alwaysLast ? "afterExit" : "exit";
28452
- this.#emitter.on(ev, cb);
28453
- return () => {
28454
- this.#emitter.removeListener(ev, cb);
28455
- if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
28456
- this.unload();
28457
- }
28458
- };
28459
- }
28460
- load() {
28461
- if (this.#loaded) {
28462
- return;
28463
- }
28464
- this.#loaded = true;
28465
- this.#emitter.count += 1;
28466
- for (const sig of signals) {
28467
- try {
28468
- const fn = this.#sigListeners[sig];
28469
- if (fn)
28470
- this.#process.on(sig, fn);
28471
- } catch (_) {
28472
- }
28473
- }
28474
- this.#process.emit = (ev, ...a) => {
28475
- return this.#processEmit(ev, ...a);
28476
- };
28477
- this.#process.reallyExit = (code) => {
28478
- return this.#processReallyExit(code);
28479
- };
28480
- }
28481
- unload() {
28482
- if (!this.#loaded) {
28483
- return;
28484
- }
28485
- this.#loaded = false;
28486
- signals.forEach((sig) => {
28487
- const listener = this.#sigListeners[sig];
28488
- if (!listener) {
28489
- throw new Error("Listener not defined for signal: " + sig);
28490
- }
28491
- try {
28492
- this.#process.removeListener(sig, listener);
28493
- } catch (_) {
28494
- }
28495
- });
28496
- this.#process.emit = this.#originalProcessEmit;
28497
- this.#process.reallyExit = this.#originalProcessReallyExit;
28498
- this.#emitter.count -= 1;
28499
- }
28500
- #processReallyExit(code) {
28501
- if (!processOk(this.#process)) {
28502
- return 0;
28503
- }
28504
- this.#process.exitCode = code || 0;
28505
- this.#emitter.emit("exit", this.#process.exitCode, null);
28506
- return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
28507
- }
28508
- #processEmit(ev, ...args) {
28509
- const og = this.#originalProcessEmit;
28510
- if (ev === "exit" && processOk(this.#process)) {
28511
- if (typeof args[0] === "number") {
28512
- this.#process.exitCode = args[0];
28513
- }
28514
- const ret = og.call(this.#process, ev, ...args);
28515
- this.#emitter.emit("exit", this.#process.exitCode, null);
28516
- return ret;
28517
- } else {
28518
- return og.call(this.#process, ev, ...args);
28519
- }
28520
- }
28521
- }
28522
- var process8 = globalThis.process;
28523
- var {
28524
- onExit,
28525
- load,
28526
- unload
28527
- } = signalExitWrap(processOk(process8) ? new SignalExit(process8) : new SignalExitFallback);
28528
-
28529
28538
  // node_modules/@inquirer/prompts/node_modules/@inquirer/confirm/node_modules/@inquirer/core/dist/lib/key.js
28530
28539
  var isTabKey = (key) => key.name === "tab";
28531
28540
  var isEnterKey = (key) => key.name === "enter" || key.name === "return";
@@ -28544,7 +28553,7 @@ class CancelPromptError extends Error {
28544
28553
  message = "Prompt was canceled";
28545
28554
  }
28546
28555
 
28547
- class ExitPromptError extends Error {
28556
+ class ExitPromptError2 extends Error {
28548
28557
  name = "ExitPromptError";
28549
28558
  }
28550
28559
 
@@ -29634,9 +29643,9 @@ function createPrompt(view) {
29634
29643
  cleanups.add(() => signal.removeEventListener("abort", abort));
29635
29644
  }
29636
29645
  cleanups.add(onExit((code, signal2) => {
29637
- reject(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
29646
+ reject(new ExitPromptError2(`User force closed the prompt with ${code} ${signal2}`));
29638
29647
  }));
29639
- const sigint = () => reject(new ExitPromptError(`User force closed the prompt with SIGINT`));
29648
+ const sigint = () => reject(new ExitPromptError2(`User force closed the prompt with SIGINT`));
29640
29649
  rl.on("SIGINT", sigint);
29641
29650
  cleanups.add(() => rl.removeListener("SIGINT", sigint));
29642
29651
  const checkCursorPos = () => screen.checkCursorPos();
@@ -29795,7 +29804,14 @@ async function updateCommand(options = {}) {
29795
29804
  }
29796
29805
 
29797
29806
  // src/index.ts
29798
- setVersion("0.4.6");
29807
+ var require2 = createRequire2(import.meta.url);
29808
+ var pkg = require2("../package.json");
29809
+ initialize({
29810
+ apiKey: "phc_BGMrllb0D2P9DCq7ZEeLp9VYhAK0lof2eTL524dEXoU",
29811
+ host: "https://eu.i.posthog.com",
29812
+ appName: "ledgit"
29813
+ });
29814
+ setVersion(pkg.version);
29799
29815
  function withTelemetry(command, action) {
29800
29816
  return async (...args) => {
29801
29817
  const start = Date.now();
@@ -29807,6 +29823,10 @@ function withTelemetry(command, action) {
29807
29823
  duration_ms: Date.now() - start
29808
29824
  });
29809
29825
  } catch (error) {
29826
+ if (error instanceof ExitPromptError) {
29827
+ await shutdown();
29828
+ process.exit(130);
29829
+ }
29810
29830
  track("cli_command", {
29811
29831
  command,
29812
29832
  success: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ledgit-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "CLI for ledgit bookkeeping repositories",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,12 +20,13 @@
20
20
  "type-check": "tsc --noEmit"
21
21
  },
22
22
  "dependencies": {
23
- "@moatless/bookkeeping": "^0.1.0",
24
- "@moatless/telemetry": "^0.1.0",
25
- "@moatless/bokio-client": "^0.1.0",
26
- "@moatless/api-client": "^0.1.0",
27
- "@moatless/fortnox-client": "^0.1.0",
28
- "@moatless/riksbank-client": "^0.1.0",
23
+ "@moatless/bookkeeping": "^0.1.2",
24
+ "@moatless/telemetry": "^0.1.2",
25
+ "@moatless/bokio-client": "^0.1.2",
26
+ "@moatless/api-client": "^0.1.2",
27
+ "@moatless/fortnox-client": "^0.1.2",
28
+ "@moatless/riksbank-client": "^0.1.2",
29
+ "@inquirer/core": "^10.0.0",
29
30
  "@inquirer/prompts": "^8.1.0",
30
31
  "commander": "^12.1.0",
31
32
  "dotenv": "^16.0.0",