repowise 0.1.6 → 0.1.8
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/bin/repowise.js +49 -46
- package/package.json +1 -1
package/dist/bin/repowise.js
CHANGED
|
@@ -618,6 +618,7 @@ async function handleInterview(syncId, questionId, questionText, questionContext
|
|
|
618
618
|
console.log(chalk2.dim(` ${questionContext}`));
|
|
619
619
|
}
|
|
620
620
|
console.log(` ${questionText}`);
|
|
621
|
+
console.log(chalk2.dim(' (Type "skip" to skip, "done" to finish early)'));
|
|
621
622
|
let answer;
|
|
622
623
|
try {
|
|
623
624
|
answer = await Promise.race([
|
|
@@ -865,7 +866,7 @@ var init_progress_renderer = __esm({
|
|
|
865
866
|
}
|
|
866
867
|
});
|
|
867
868
|
|
|
868
|
-
// ../listener/
|
|
869
|
+
// ../listener/dist/service-installer.js
|
|
869
870
|
var service_installer_exports = {};
|
|
870
871
|
__export(service_installer_exports, {
|
|
871
872
|
install: () => install,
|
|
@@ -1085,7 +1086,7 @@ async function isInstalled() {
|
|
|
1085
1086
|
}
|
|
1086
1087
|
var PLIST_LABEL, SYSTEMD_SERVICE, TASK_NAME;
|
|
1087
1088
|
var init_service_installer = __esm({
|
|
1088
|
-
"../listener/
|
|
1089
|
+
"../listener/dist/service-installer.js"() {
|
|
1089
1090
|
"use strict";
|
|
1090
1091
|
PLIST_LABEL = "com.repowise.listener";
|
|
1091
1092
|
SYSTEMD_SERVICE = "repowise-listener";
|
|
@@ -1093,7 +1094,7 @@ var init_service_installer = __esm({
|
|
|
1093
1094
|
}
|
|
1094
1095
|
});
|
|
1095
1096
|
|
|
1096
|
-
// ../listener/
|
|
1097
|
+
// ../listener/dist/process-manager.js
|
|
1097
1098
|
var process_manager_exports = {};
|
|
1098
1099
|
__export(process_manager_exports, {
|
|
1099
1100
|
getStatus: () => getStatus,
|
|
@@ -1117,7 +1118,8 @@ async function readPid() {
|
|
|
1117
1118
|
const pid = parseInt(content.trim(), 10);
|
|
1118
1119
|
return Number.isNaN(pid) ? null : pid;
|
|
1119
1120
|
} catch (err) {
|
|
1120
|
-
if (err.code === "ENOENT")
|
|
1121
|
+
if (err.code === "ENOENT")
|
|
1122
|
+
return null;
|
|
1121
1123
|
throw err;
|
|
1122
1124
|
}
|
|
1123
1125
|
}
|
|
@@ -1144,13 +1146,15 @@ async function startBackground() {
|
|
|
1144
1146
|
closeSync(stdoutFd);
|
|
1145
1147
|
closeSync(stderrFd);
|
|
1146
1148
|
const pid = child.pid;
|
|
1147
|
-
if (!pid)
|
|
1149
|
+
if (!pid)
|
|
1150
|
+
throw new Error("Failed to spawn listener process");
|
|
1148
1151
|
await writeFile5(PID_PATH, String(pid));
|
|
1149
1152
|
return pid;
|
|
1150
1153
|
}
|
|
1151
1154
|
async function stopProcess() {
|
|
1152
1155
|
const pid = await readPid();
|
|
1153
|
-
if (pid === null)
|
|
1156
|
+
if (pid === null)
|
|
1157
|
+
return;
|
|
1154
1158
|
if (!isAlive(pid)) {
|
|
1155
1159
|
await removePidFile();
|
|
1156
1160
|
return;
|
|
@@ -1173,12 +1177,14 @@ async function stopProcess() {
|
|
|
1173
1177
|
}
|
|
1174
1178
|
async function isRunning() {
|
|
1175
1179
|
const pid = await readPid();
|
|
1176
|
-
if (pid === null)
|
|
1180
|
+
if (pid === null)
|
|
1181
|
+
return false;
|
|
1177
1182
|
return isAlive(pid);
|
|
1178
1183
|
}
|
|
1179
1184
|
async function getStatus() {
|
|
1180
1185
|
const pid = await readPid();
|
|
1181
|
-
if (pid === null)
|
|
1186
|
+
if (pid === null)
|
|
1187
|
+
return { running: false, pid: null };
|
|
1182
1188
|
const alive = isAlive(pid);
|
|
1183
1189
|
return { running: alive, pid: alive ? pid : null };
|
|
1184
1190
|
}
|
|
@@ -1190,7 +1196,7 @@ async function removePidFile() {
|
|
|
1190
1196
|
}
|
|
1191
1197
|
var REPOWISE_DIR, PID_PATH, LOG_DIR;
|
|
1192
1198
|
var init_process_manager = __esm({
|
|
1193
|
-
"../listener/
|
|
1199
|
+
"../listener/dist/process-manager.js"() {
|
|
1194
1200
|
"use strict";
|
|
1195
1201
|
REPOWISE_DIR = join5(homedir4(), ".repowise");
|
|
1196
1202
|
PID_PATH = join5(REPOWISE_DIR, "listener.pid");
|
|
@@ -1612,7 +1618,7 @@ var init_sync = __esm({
|
|
|
1612
1618
|
}
|
|
1613
1619
|
});
|
|
1614
1620
|
|
|
1615
|
-
// ../listener/
|
|
1621
|
+
// ../listener/dist/lib/config.js
|
|
1616
1622
|
import { readFile as readFile6 } from "fs/promises";
|
|
1617
1623
|
import { homedir as homedir6 } from "os";
|
|
1618
1624
|
import { join as join7 } from "path";
|
|
@@ -1621,9 +1627,7 @@ async function getListenerConfig() {
|
|
|
1621
1627
|
try {
|
|
1622
1628
|
const data = await readFile6(CONFIG_PATH2, "utf-8");
|
|
1623
1629
|
const raw = JSON.parse(data);
|
|
1624
|
-
const validRepos = (raw.repos ?? []).filter(
|
|
1625
|
-
(r) => typeof r === "object" && r !== null && typeof r.repoId === "string" && typeof r.localPath === "string"
|
|
1626
|
-
);
|
|
1630
|
+
const validRepos = (raw.repos ?? []).filter((r) => typeof r === "object" && r !== null && typeof r.repoId === "string" && typeof r.localPath === "string");
|
|
1627
1631
|
return {
|
|
1628
1632
|
apiUrl: raw.apiUrl ?? apiUrl,
|
|
1629
1633
|
repos: validRepos
|
|
@@ -1634,7 +1638,7 @@ async function getListenerConfig() {
|
|
|
1634
1638
|
}
|
|
1635
1639
|
var CONFIG_DIR3, CONFIG_PATH2, DEFAULT_API_URL;
|
|
1636
1640
|
var init_config2 = __esm({
|
|
1637
|
-
"../listener/
|
|
1641
|
+
"../listener/dist/lib/config.js"() {
|
|
1638
1642
|
"use strict";
|
|
1639
1643
|
CONFIG_DIR3 = join7(homedir6(), ".repowise");
|
|
1640
1644
|
CONFIG_PATH2 = join7(CONFIG_DIR3, "config.json");
|
|
@@ -1642,7 +1646,7 @@ var init_config2 = __esm({
|
|
|
1642
1646
|
}
|
|
1643
1647
|
});
|
|
1644
1648
|
|
|
1645
|
-
// ../listener/
|
|
1649
|
+
// ../listener/dist/lib/state.js
|
|
1646
1650
|
import { readFile as readFile7, writeFile as writeFile6, mkdir as mkdir6, chmod as chmod2 } from "fs/promises";
|
|
1647
1651
|
import { homedir as homedir7 } from "os";
|
|
1648
1652
|
import { join as join8 } from "path";
|
|
@@ -1667,14 +1671,14 @@ async function saveState(state) {
|
|
|
1667
1671
|
}
|
|
1668
1672
|
var CONFIG_DIR4, STATE_PATH2;
|
|
1669
1673
|
var init_state = __esm({
|
|
1670
|
-
"../listener/
|
|
1674
|
+
"../listener/dist/lib/state.js"() {
|
|
1671
1675
|
"use strict";
|
|
1672
1676
|
CONFIG_DIR4 = join8(homedir7(), ".repowise");
|
|
1673
1677
|
STATE_PATH2 = join8(CONFIG_DIR4, "listener-state.json");
|
|
1674
1678
|
}
|
|
1675
1679
|
});
|
|
1676
1680
|
|
|
1677
|
-
// ../listener/
|
|
1681
|
+
// ../listener/dist/lib/auth.js
|
|
1678
1682
|
import { readFile as readFile8, writeFile as writeFile7, mkdir as mkdir7, chmod as chmod3 } from "fs/promises";
|
|
1679
1683
|
import { homedir as homedir8 } from "os";
|
|
1680
1684
|
import { join as join9 } from "path";
|
|
@@ -1728,7 +1732,8 @@ async function storeCredentials2(credentials) {
|
|
|
1728
1732
|
}
|
|
1729
1733
|
async function getValidCredentials2() {
|
|
1730
1734
|
const creds = await getStoredCredentials2();
|
|
1731
|
-
if (!creds)
|
|
1735
|
+
if (!creds)
|
|
1736
|
+
return null;
|
|
1732
1737
|
if (Date.now() > creds.expiresAt - 5 * 60 * 1e3) {
|
|
1733
1738
|
try {
|
|
1734
1739
|
const refreshed = await refreshTokens2(creds.refreshToken);
|
|
@@ -1742,17 +1747,17 @@ async function getValidCredentials2() {
|
|
|
1742
1747
|
}
|
|
1743
1748
|
var CONFIG_DIR5, CREDENTIALS_PATH2;
|
|
1744
1749
|
var init_auth2 = __esm({
|
|
1745
|
-
"../listener/
|
|
1750
|
+
"../listener/dist/lib/auth.js"() {
|
|
1746
1751
|
"use strict";
|
|
1747
1752
|
CONFIG_DIR5 = join9(homedir8(), ".repowise");
|
|
1748
1753
|
CREDENTIALS_PATH2 = join9(CONFIG_DIR5, "credentials.json");
|
|
1749
1754
|
}
|
|
1750
1755
|
});
|
|
1751
1756
|
|
|
1752
|
-
// ../listener/
|
|
1757
|
+
// ../listener/dist/poll-client.js
|
|
1753
1758
|
var POLL_TIMEOUT_MS, AuthError, PollClient;
|
|
1754
1759
|
var init_poll_client = __esm({
|
|
1755
|
-
"../listener/
|
|
1760
|
+
"../listener/dist/poll-client.js"() {
|
|
1756
1761
|
"use strict";
|
|
1757
1762
|
init_auth2();
|
|
1758
1763
|
POLL_TIMEOUT_MS = 3e4;
|
|
@@ -1802,10 +1807,10 @@ var init_poll_client = __esm({
|
|
|
1802
1807
|
}
|
|
1803
1808
|
});
|
|
1804
1809
|
|
|
1805
|
-
// ../listener/
|
|
1810
|
+
// ../listener/dist/reconnection.js
|
|
1806
1811
|
var DEFAULT_CONFIG, BackoffCalculator;
|
|
1807
1812
|
var init_reconnection = __esm({
|
|
1808
|
-
"../listener/
|
|
1813
|
+
"../listener/dist/reconnection.js"() {
|
|
1809
1814
|
"use strict";
|
|
1810
1815
|
DEFAULT_CONFIG = {
|
|
1811
1816
|
initialDelay: 1e3,
|
|
@@ -1819,10 +1824,7 @@ var init_reconnection = __esm({
|
|
|
1819
1824
|
this.config = { ...DEFAULT_CONFIG, ...config2 };
|
|
1820
1825
|
}
|
|
1821
1826
|
nextDelay() {
|
|
1822
|
-
const baseDelay = Math.min(
|
|
1823
|
-
this.config.initialDelay * Math.pow(2, this.attempt),
|
|
1824
|
-
this.config.maxDelay
|
|
1825
|
-
);
|
|
1827
|
+
const baseDelay = Math.min(this.config.initialDelay * Math.pow(2, this.attempt), this.config.maxDelay);
|
|
1826
1828
|
const jitter = Math.random() * this.config.jitterMax;
|
|
1827
1829
|
this.attempt++;
|
|
1828
1830
|
return baseDelay + jitter;
|
|
@@ -1837,7 +1839,7 @@ var init_reconnection = __esm({
|
|
|
1837
1839
|
}
|
|
1838
1840
|
});
|
|
1839
1841
|
|
|
1840
|
-
// ../listener/
|
|
1842
|
+
// ../listener/dist/notification.js
|
|
1841
1843
|
import notifier from "node-notifier";
|
|
1842
1844
|
function notifyConnectionLost() {
|
|
1843
1845
|
try {
|
|
@@ -1868,14 +1870,14 @@ function notifyContextUpdated(repoId, fileCount) {
|
|
|
1868
1870
|
}
|
|
1869
1871
|
var TITLE, notify;
|
|
1870
1872
|
var init_notification = __esm({
|
|
1871
|
-
"../listener/
|
|
1873
|
+
"../listener/dist/notification.js"() {
|
|
1872
1874
|
"use strict";
|
|
1873
1875
|
TITLE = "RepoWise";
|
|
1874
1876
|
notify = notifier.notify.bind(notifier);
|
|
1875
1877
|
}
|
|
1876
1878
|
});
|
|
1877
1879
|
|
|
1878
|
-
// ../listener/
|
|
1880
|
+
// ../listener/dist/file-writer.js
|
|
1879
1881
|
import { access } from "fs/promises";
|
|
1880
1882
|
import { join as join10 } from "path";
|
|
1881
1883
|
async function verifyContextFolder(localPath) {
|
|
@@ -1887,12 +1889,12 @@ async function verifyContextFolder(localPath) {
|
|
|
1887
1889
|
}
|
|
1888
1890
|
}
|
|
1889
1891
|
var init_file_writer = __esm({
|
|
1890
|
-
"../listener/
|
|
1892
|
+
"../listener/dist/file-writer.js"() {
|
|
1891
1893
|
"use strict";
|
|
1892
1894
|
}
|
|
1893
1895
|
});
|
|
1894
1896
|
|
|
1895
|
-
// ../listener/
|
|
1897
|
+
// ../listener/dist/context-fetcher.js
|
|
1896
1898
|
import { execFile as execFile2 } from "child_process";
|
|
1897
1899
|
import { promisify } from "util";
|
|
1898
1900
|
async function fetchContextUpdates(localPath) {
|
|
@@ -1934,14 +1936,14 @@ async function fetchContextUpdates(localPath) {
|
|
|
1934
1936
|
}
|
|
1935
1937
|
var execFileAsync;
|
|
1936
1938
|
var init_context_fetcher = __esm({
|
|
1937
|
-
"../listener/
|
|
1939
|
+
"../listener/dist/context-fetcher.js"() {
|
|
1938
1940
|
"use strict";
|
|
1939
1941
|
init_file_writer();
|
|
1940
1942
|
execFileAsync = promisify(execFile2);
|
|
1941
1943
|
}
|
|
1942
1944
|
});
|
|
1943
1945
|
|
|
1944
|
-
// ../listener/
|
|
1946
|
+
// ../listener/dist/main.js
|
|
1945
1947
|
var main_exports = {};
|
|
1946
1948
|
__export(main_exports, {
|
|
1947
1949
|
startListener: () => startListener,
|
|
@@ -1967,9 +1969,7 @@ async function handleStalePid() {
|
|
|
1967
1969
|
if (!Number.isNaN(pid) && pid !== process.pid) {
|
|
1968
1970
|
try {
|
|
1969
1971
|
process.kill(pid, 0);
|
|
1970
|
-
console.error(
|
|
1971
|
-
`Listener already running (PID: ${pid}). Stop it first with \`repowise stop\`.`
|
|
1972
|
-
);
|
|
1972
|
+
console.error(`Listener already running (PID: ${pid}). Stop it first with \`repowise stop\`.`);
|
|
1973
1973
|
process.exitCode = 1;
|
|
1974
1974
|
return true;
|
|
1975
1975
|
} catch {
|
|
@@ -1993,7 +1993,8 @@ function sleep(ms) {
|
|
|
1993
1993
|
sleepResolve = null;
|
|
1994
1994
|
resolve();
|
|
1995
1995
|
}, ms);
|
|
1996
|
-
if (typeof timer === "object" && "unref" in timer)
|
|
1996
|
+
if (typeof timer === "object" && "unref" in timer)
|
|
1997
|
+
timer.unref();
|
|
1997
1998
|
});
|
|
1998
1999
|
}
|
|
1999
2000
|
async function processNotifications(notifications, state, repoLocalPaths) {
|
|
@@ -2017,13 +2018,15 @@ async function processNotifications(notifications, state, repoLocalPaths) {
|
|
|
2017
2018
|
return updateCount;
|
|
2018
2019
|
}
|
|
2019
2020
|
async function handleCatchUp(offlineState, pollClient, repoIds, state, repoLocalPaths) {
|
|
2020
|
-
if (!offlineState.offlineSince)
|
|
2021
|
+
if (!offlineState.offlineSince)
|
|
2022
|
+
return;
|
|
2021
2023
|
const offlineDuration = Date.now() - new Date(offlineState.offlineSince).getTime();
|
|
2022
2024
|
if (offlineDuration >= TWENTY_FOUR_HOURS_MS) {
|
|
2023
2025
|
let syncCount = 0;
|
|
2024
2026
|
for (const [, localPath] of repoLocalPaths) {
|
|
2025
2027
|
const result = await fetchContextUpdates(localPath);
|
|
2026
|
-
if (result.success)
|
|
2028
|
+
if (result.success)
|
|
2029
|
+
syncCount++;
|
|
2027
2030
|
}
|
|
2028
2031
|
notifyBackOnline(syncCount);
|
|
2029
2032
|
} else {
|
|
@@ -2037,7 +2040,8 @@ async function handleCatchUp(offlineState, pollClient, repoIds, state, repoLocal
|
|
|
2037
2040
|
async function startListener() {
|
|
2038
2041
|
running = true;
|
|
2039
2042
|
const alreadyRunning = await handleStalePid();
|
|
2040
|
-
if (alreadyRunning)
|
|
2043
|
+
if (alreadyRunning)
|
|
2044
|
+
return;
|
|
2041
2045
|
await writePidFile();
|
|
2042
2046
|
const config2 = await getListenerConfig();
|
|
2043
2047
|
if (config2.repos.length === 0) {
|
|
@@ -2097,7 +2101,8 @@ async function startListener() {
|
|
|
2097
2101
|
pollIntervalMs = response.pollIntervalMs;
|
|
2098
2102
|
await sleep(pollIntervalMs);
|
|
2099
2103
|
} catch (err) {
|
|
2100
|
-
if (!running)
|
|
2104
|
+
if (!running)
|
|
2105
|
+
break;
|
|
2101
2106
|
if (err instanceof AuthError) {
|
|
2102
2107
|
console.error(err.message);
|
|
2103
2108
|
process.exitCode = 1;
|
|
@@ -2112,9 +2117,7 @@ async function startListener() {
|
|
|
2112
2117
|
offlineState.attemptCount++;
|
|
2113
2118
|
const delay = backoff.nextDelay();
|
|
2114
2119
|
const message = err instanceof Error ? err.message : "Unknown error";
|
|
2115
|
-
console.error(
|
|
2116
|
-
`Poll failed (attempt ${offlineState.attemptCount}): ${message}. Retrying in ${Math.round(delay / 1e3)}s`
|
|
2117
|
-
);
|
|
2120
|
+
console.error(`Poll failed (attempt ${offlineState.attemptCount}): ${message}. Retrying in ${Math.round(delay / 1e3)}s`);
|
|
2118
2121
|
await sleep(delay);
|
|
2119
2122
|
}
|
|
2120
2123
|
}
|
|
@@ -2122,7 +2125,7 @@ async function startListener() {
|
|
|
2122
2125
|
}
|
|
2123
2126
|
var TWENTY_FOUR_HOURS_MS, PID_PATH2, running, sleepResolve, isDirectRun;
|
|
2124
2127
|
var init_main = __esm({
|
|
2125
|
-
"../listener/
|
|
2128
|
+
"../listener/dist/main.js"() {
|
|
2126
2129
|
"use strict";
|
|
2127
2130
|
init_config2();
|
|
2128
2131
|
init_state();
|