repowise 0.1.8 → 0.1.9
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 +37 -16
- package/package.json +1 -1
package/dist/bin/repowise.js
CHANGED
|
@@ -878,9 +878,16 @@ import { writeFile as writeFile4, mkdir as mkdir4, unlink as unlink2 } from "fs/
|
|
|
878
878
|
import { homedir as homedir3 } from "os";
|
|
879
879
|
import { join as join4 } from "path";
|
|
880
880
|
import { createRequire } from "module";
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
881
|
+
import { fileURLToPath } from "url";
|
|
882
|
+
function resolveListenerCommand() {
|
|
883
|
+
try {
|
|
884
|
+
const require2 = createRequire(import.meta.url);
|
|
885
|
+
const mainPath = require2.resolve("@repowise/listener/main");
|
|
886
|
+
return { script: mainPath, args: [] };
|
|
887
|
+
} catch {
|
|
888
|
+
const bundlePath = fileURLToPath(import.meta.url);
|
|
889
|
+
return { script: bundlePath, args: ["__listener"] };
|
|
890
|
+
}
|
|
884
891
|
}
|
|
885
892
|
function exec(cmd, args) {
|
|
886
893
|
return new Promise((resolve, reject) => {
|
|
@@ -900,8 +907,9 @@ function logDir() {
|
|
|
900
907
|
return join4(homedir3(), ".repowise", "logs");
|
|
901
908
|
}
|
|
902
909
|
function buildPlist() {
|
|
903
|
-
const
|
|
910
|
+
const cmd = resolveListenerCommand();
|
|
904
911
|
const logs = logDir();
|
|
912
|
+
const programArgs = [process.execPath, cmd.script, ...cmd.args].map((a) => ` <string>${a}</string>`).join("\n");
|
|
905
913
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
906
914
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
|
907
915
|
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
@@ -911,8 +919,7 @@ function buildPlist() {
|
|
|
911
919
|
<string>${PLIST_LABEL}</string>
|
|
912
920
|
<key>ProgramArguments</key>
|
|
913
921
|
<array>
|
|
914
|
-
|
|
915
|
-
<string>${listenerPath}</string>
|
|
922
|
+
${programArgs}
|
|
916
923
|
</array>
|
|
917
924
|
<key>RunAtLoad</key>
|
|
918
925
|
<true/>
|
|
@@ -955,7 +962,8 @@ function unitPath() {
|
|
|
955
962
|
return join4(homedir3(), ".config", "systemd", "user", `${SYSTEMD_SERVICE}.service`);
|
|
956
963
|
}
|
|
957
964
|
function buildUnit() {
|
|
958
|
-
const
|
|
965
|
+
const cmd = resolveListenerCommand();
|
|
966
|
+
const execStart = [process.execPath, cmd.script, ...cmd.args].join(" ");
|
|
959
967
|
const logs = logDir();
|
|
960
968
|
return `[Unit]
|
|
961
969
|
Description=RepoWise Listener
|
|
@@ -964,7 +972,7 @@ Wants=network-online.target
|
|
|
964
972
|
|
|
965
973
|
[Service]
|
|
966
974
|
Type=simple
|
|
967
|
-
ExecStart=${
|
|
975
|
+
ExecStart=${execStart}
|
|
968
976
|
Restart=on-failure
|
|
969
977
|
RestartSec=10
|
|
970
978
|
StandardOutput=append:${join4(logs, "listener-stdout.log")}
|
|
@@ -1009,13 +1017,14 @@ async function linuxIsInstalled() {
|
|
|
1009
1017
|
}
|
|
1010
1018
|
async function win32Install() {
|
|
1011
1019
|
await mkdir4(logDir(), { recursive: true });
|
|
1012
|
-
const
|
|
1020
|
+
const cmd = resolveListenerCommand();
|
|
1021
|
+
const taskCmd = [process.execPath, cmd.script, ...cmd.args].map((a) => `"${a}"`).join(" ");
|
|
1013
1022
|
await exec("schtasks", [
|
|
1014
1023
|
"/create",
|
|
1015
1024
|
"/tn",
|
|
1016
1025
|
TASK_NAME,
|
|
1017
1026
|
"/tr",
|
|
1018
|
-
|
|
1027
|
+
taskCmd,
|
|
1019
1028
|
"/sc",
|
|
1020
1029
|
"onlogon",
|
|
1021
1030
|
"/ru",
|
|
@@ -1108,9 +1117,16 @@ import { readFile as readFile4, writeFile as writeFile5, mkdir as mkdir5, unlink
|
|
|
1108
1117
|
import { homedir as homedir4 } from "os";
|
|
1109
1118
|
import { join as join5 } from "path";
|
|
1110
1119
|
import { createRequire as createRequire2 } from "module";
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1120
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1121
|
+
function resolveListenerCommand2() {
|
|
1122
|
+
try {
|
|
1123
|
+
const require2 = createRequire2(import.meta.url);
|
|
1124
|
+
const mainPath = require2.resolve("@repowise/listener/main");
|
|
1125
|
+
return { script: mainPath, args: [] };
|
|
1126
|
+
} catch {
|
|
1127
|
+
const bundlePath = fileURLToPath2(import.meta.url);
|
|
1128
|
+
return { script: bundlePath, args: ["__listener"] };
|
|
1129
|
+
}
|
|
1114
1130
|
}
|
|
1115
1131
|
async function readPid() {
|
|
1116
1132
|
try {
|
|
@@ -1133,10 +1149,10 @@ function isAlive(pid) {
|
|
|
1133
1149
|
}
|
|
1134
1150
|
async function startBackground() {
|
|
1135
1151
|
await mkdir5(LOG_DIR, { recursive: true });
|
|
1136
|
-
const
|
|
1152
|
+
const cmd = resolveListenerCommand2();
|
|
1137
1153
|
const stdoutFd = openSync(join5(LOG_DIR, "listener-stdout.log"), "a");
|
|
1138
1154
|
const stderrFd = openSync(join5(LOG_DIR, "listener-stderr.log"), "a");
|
|
1139
|
-
const child = spawn(process.execPath, [
|
|
1155
|
+
const child = spawn(process.execPath, [cmd.script, ...cmd.args], {
|
|
1140
1156
|
detached: true,
|
|
1141
1157
|
stdio: ["ignore", stdoutFd, stderrFd],
|
|
1142
1158
|
cwd: homedir4(),
|
|
@@ -2312,4 +2328,9 @@ program.command("config").description("Manage configuration").action(async () =>
|
|
|
2312
2328
|
const { config: config2 } = await Promise.resolve().then(() => (init_config3(), config_exports));
|
|
2313
2329
|
config2();
|
|
2314
2330
|
});
|
|
2315
|
-
|
|
2331
|
+
if (process.argv[2] === "__listener") {
|
|
2332
|
+
const { startListener: startListener2 } = await Promise.resolve().then(() => (init_main(), main_exports));
|
|
2333
|
+
await startListener2();
|
|
2334
|
+
} else {
|
|
2335
|
+
program.parse();
|
|
2336
|
+
}
|