greview-cli 0.13.1 → 0.13.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.
- package/dist/cli.js +90 -79
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -330,8 +330,8 @@ var Store = class {
|
|
|
330
330
|
this.path = dbPathFor(repo);
|
|
331
331
|
mkdirSync(dirname(this.path), { recursive: true });
|
|
332
332
|
this.db = new (sqlite()).DatabaseSync(this.path);
|
|
333
|
-
this.db.exec("PRAGMA journal_mode = WAL");
|
|
334
333
|
this.db.exec("PRAGMA busy_timeout = 5000");
|
|
334
|
+
this.db.exec("PRAGMA journal_mode = DELETE");
|
|
335
335
|
this.db.exec("PRAGMA foreign_keys = ON");
|
|
336
336
|
this.migrate();
|
|
337
337
|
}
|
|
@@ -1719,7 +1719,17 @@ Try: greview help
|
|
|
1719
1719
|
process.stdout.write(text);
|
|
1720
1720
|
return 0;
|
|
1721
1721
|
}
|
|
1722
|
-
|
|
1722
|
+
var BUSY_ATTEMPTS = 4;
|
|
1723
|
+
function isBusy(e) {
|
|
1724
|
+
if (!(e instanceof Error)) return false;
|
|
1725
|
+
const errcode = e.errcode;
|
|
1726
|
+
if (typeof errcode === "number") return (errcode & 255) === 5;
|
|
1727
|
+
return e.message === "database is locked";
|
|
1728
|
+
}
|
|
1729
|
+
function sleep(ms) {
|
|
1730
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
1731
|
+
}
|
|
1732
|
+
async function main(argv) {
|
|
1723
1733
|
let values;
|
|
1724
1734
|
let positionals;
|
|
1725
1735
|
try {
|
|
@@ -1738,88 +1748,89 @@ function main(argv) {
|
|
|
1738
1748
|
return 0;
|
|
1739
1749
|
}
|
|
1740
1750
|
if (command === "setup") return cmdSetup(positionals);
|
|
1741
|
-
let
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1751
|
+
for (let attempt = 1; ; attempt++) {
|
|
1752
|
+
let ctx = null;
|
|
1753
|
+
try {
|
|
1754
|
+
const repo = findRepo(cwdOf(values));
|
|
1755
|
+
ctx = { repo, store: new Store(repo), json: values.json === true };
|
|
1756
|
+
switch (command) {
|
|
1757
|
+
case "repo":
|
|
1758
|
+
cmdRepo(ctx);
|
|
1759
|
+
break;
|
|
1760
|
+
case "add":
|
|
1761
|
+
cmdAdd(ctx, values);
|
|
1762
|
+
break;
|
|
1763
|
+
case "list":
|
|
1764
|
+
case "ls":
|
|
1765
|
+
cmdList(ctx, values);
|
|
1766
|
+
break;
|
|
1767
|
+
case "show":
|
|
1768
|
+
cmdShow(ctx, values, positionals);
|
|
1769
|
+
break;
|
|
1770
|
+
case "reply":
|
|
1771
|
+
cmdReply(ctx, values, positionals);
|
|
1772
|
+
break;
|
|
1773
|
+
case "edit":
|
|
1774
|
+
cmdEdit(ctx, values, positionals);
|
|
1775
|
+
break;
|
|
1776
|
+
case "resolve":
|
|
1777
|
+
cmdSetStatus(ctx, values, positionals, true);
|
|
1778
|
+
break;
|
|
1779
|
+
case "unresolve":
|
|
1780
|
+
case "reopen":
|
|
1781
|
+
cmdSetStatus(ctx, values, positionals, false);
|
|
1782
|
+
break;
|
|
1783
|
+
case "rm":
|
|
1784
|
+
case "delete":
|
|
1785
|
+
cmdRm(ctx, positionals);
|
|
1786
|
+
break;
|
|
1787
|
+
case "sync":
|
|
1788
|
+
cmdSync(ctx);
|
|
1789
|
+
break;
|
|
1790
|
+
case "stats":
|
|
1791
|
+
cmdStats(ctx);
|
|
1792
|
+
break;
|
|
1793
|
+
case "onsubmit": {
|
|
1794
|
+
const pending = cmdOnsubmit(ctx, values, positionals);
|
|
1795
|
+
if (pending) return pending.then(() => 0);
|
|
1796
|
+
break;
|
|
1797
|
+
}
|
|
1798
|
+
default:
|
|
1799
|
+
process.stderr.write(`greview: unknown command "${command}"
|
|
1789
1800
|
Try: greview help
|
|
1790
1801
|
`);
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1802
|
+
return 2;
|
|
1803
|
+
}
|
|
1804
|
+
return 0;
|
|
1805
|
+
} catch (e) {
|
|
1806
|
+
if (isBusy(e) && attempt < BUSY_ATTEMPTS) {
|
|
1807
|
+
await sleep(attempt * 150 + Math.random() * 100);
|
|
1808
|
+
continue;
|
|
1809
|
+
}
|
|
1810
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
1811
|
+
if (values.json) {
|
|
1812
|
+
process.stdout.write(`${JSON.stringify({ ok: false, error: message })}
|
|
1798
1813
|
`);
|
|
1799
|
-
|
|
1800
|
-
|
|
1814
|
+
} else {
|
|
1815
|
+
process.stderr.write(`greview: ${message}
|
|
1801
1816
|
`);
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1817
|
+
}
|
|
1818
|
+
return e instanceof UsageError ? 2 : e instanceof GitError ? 3 : 1;
|
|
1819
|
+
} finally {
|
|
1820
|
+
try {
|
|
1821
|
+
ctx?.store.close();
|
|
1822
|
+
} catch {
|
|
1823
|
+
}
|
|
1808
1824
|
}
|
|
1809
1825
|
}
|
|
1810
1826
|
}
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
(
|
|
1817
|
-
if (process.exitCode === void 0 || process.exitCode === 0) process.exitCode = code;
|
|
1818
|
-
},
|
|
1819
|
-
(e) => {
|
|
1820
|
-
process.stderr.write(`greview: ${e instanceof Error ? e.message : String(e)}
|
|
1827
|
+
void main(process.argv.slice(2)).then(
|
|
1828
|
+
(code) => {
|
|
1829
|
+
if (process.exitCode === void 0 || process.exitCode === 0) process.exitCode = code;
|
|
1830
|
+
},
|
|
1831
|
+
(e) => {
|
|
1832
|
+
process.stderr.write(`greview: ${e instanceof Error ? e.message : String(e)}
|
|
1821
1833
|
`);
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
}
|
|
1834
|
+
process.exitCode = 1;
|
|
1835
|
+
}
|
|
1836
|
+
);
|