itwillsync 1.7.0 → 1.7.1
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/hub/daemon.js +2 -2
- package/dist/hub/daemon.js.map +1 -1
- package/dist/index.js +68 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3772,19 +3772,26 @@ function validateToken(provided, expected) {
|
|
|
3772
3772
|
import { networkInterfaces } from "os";
|
|
3773
3773
|
import { createServer } from "net";
|
|
3774
3774
|
|
|
3775
|
-
// src/
|
|
3775
|
+
// src/exec-utils.ts
|
|
3776
3776
|
import { execFile } from "child_process";
|
|
3777
|
-
function
|
|
3777
|
+
function execFileAsync(cmd, args, opts) {
|
|
3778
3778
|
return new Promise((resolve, reject) => {
|
|
3779
|
-
execFile(
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3779
|
+
execFile(
|
|
3780
|
+
cmd,
|
|
3781
|
+
args,
|
|
3782
|
+
{ timeout: opts?.timeout ?? 5e3 },
|
|
3783
|
+
(error, stdout, stderr) => {
|
|
3784
|
+
if (error) {
|
|
3785
|
+
reject(error);
|
|
3786
|
+
} else {
|
|
3787
|
+
resolve({ stdout: stdout.trim(), stderr: stderr.trim() });
|
|
3788
|
+
}
|
|
3784
3789
|
}
|
|
3785
|
-
|
|
3790
|
+
);
|
|
3786
3791
|
});
|
|
3787
3792
|
}
|
|
3793
|
+
|
|
3794
|
+
// src/tailscale.ts
|
|
3788
3795
|
function getTailscalePaths() {
|
|
3789
3796
|
const paths = ["tailscale"];
|
|
3790
3797
|
if (process.platform === "darwin") {
|
|
@@ -3796,7 +3803,7 @@ async function tryExec(args) {
|
|
|
3796
3803
|
let lastError = null;
|
|
3797
3804
|
for (const bin of getTailscalePaths()) {
|
|
3798
3805
|
try {
|
|
3799
|
-
const result = await
|
|
3806
|
+
const result = await execFileAsync(bin, args);
|
|
3800
3807
|
return { status: "success", ...result };
|
|
3801
3808
|
} catch (err) {
|
|
3802
3809
|
if (err.code === "ENOENT") {
|
|
@@ -4744,6 +4751,40 @@ Hub Management:
|
|
|
4744
4751
|
`);
|
|
4745
4752
|
}
|
|
4746
4753
|
|
|
4754
|
+
// src/resolve-command.ts
|
|
4755
|
+
async function resolveCommand(command) {
|
|
4756
|
+
if (process.platform !== "win32") {
|
|
4757
|
+
return command;
|
|
4758
|
+
}
|
|
4759
|
+
if (/^[a-zA-Z]:[/\\]/.test(command) || command.startsWith("\\\\")) {
|
|
4760
|
+
return command;
|
|
4761
|
+
}
|
|
4762
|
+
try {
|
|
4763
|
+
const { stdout } = await execFileAsync("where.exe", [command]);
|
|
4764
|
+
const firstMatch = stdout.split("\n")[0]?.trim();
|
|
4765
|
+
if (firstMatch) {
|
|
4766
|
+
return firstMatch;
|
|
4767
|
+
}
|
|
4768
|
+
throw new Error(`where.exe returned empty output for "${command}"`);
|
|
4769
|
+
} catch (err) {
|
|
4770
|
+
if (err.code === "ENOENT") {
|
|
4771
|
+
return command;
|
|
4772
|
+
}
|
|
4773
|
+
throw new Error(
|
|
4774
|
+
`Could not find "${command}" on this system.
|
|
4775
|
+
|
|
4776
|
+
To fix this:
|
|
4777
|
+
1. Make sure "${command}" is installed
|
|
4778
|
+
2. Open a new terminal and run: ${command} --version
|
|
4779
|
+
3. If that works, try running itwillsync again
|
|
4780
|
+
|
|
4781
|
+
If "${command}" was just installed, you may need to restart your
|
|
4782
|
+
terminal so Windows can find it in your PATH.`,
|
|
4783
|
+
{ cause: err }
|
|
4784
|
+
);
|
|
4785
|
+
}
|
|
4786
|
+
}
|
|
4787
|
+
|
|
4747
4788
|
// src/index.ts
|
|
4748
4789
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
4749
4790
|
import { join as join7, dirname as dirname4 } from "path";
|
|
@@ -4883,14 +4924,7 @@ async function main() {
|
|
|
4883
4924
|
}
|
|
4884
4925
|
const headless = options.headless;
|
|
4885
4926
|
const config = loadConfig();
|
|
4886
|
-
|
|
4887
|
-
if (options.tailscale) {
|
|
4888
|
-
networkingMode = "tailscale";
|
|
4889
|
-
} else if (options.local) {
|
|
4890
|
-
networkingMode = "local";
|
|
4891
|
-
} else {
|
|
4892
|
-
networkingMode = config.networkingMode;
|
|
4893
|
-
}
|
|
4927
|
+
const networkingMode = options.tailscale ? "tailscale" : options.local ? "local" : config.networkingMode;
|
|
4894
4928
|
const [cmd, ...cmdArgs] = options.command;
|
|
4895
4929
|
const isFirstSession = await ensureHub();
|
|
4896
4930
|
const hubConfig = getHubConfig();
|
|
@@ -4900,7 +4934,23 @@ async function main() {
|
|
|
4900
4934
|
const ip = await resolveSessionIP(networkingMode, options.localhost);
|
|
4901
4935
|
const __dirname2 = dirname4(fileURLToPath4(import.meta.url));
|
|
4902
4936
|
const webClientPath = join7(__dirname2, "web-client");
|
|
4903
|
-
const
|
|
4937
|
+
const resolvedCmd = await resolveCommand(cmd);
|
|
4938
|
+
let ptyManager;
|
|
4939
|
+
try {
|
|
4940
|
+
ptyManager = new PtyManager(resolvedCmd, cmdArgs);
|
|
4941
|
+
} catch {
|
|
4942
|
+
console.error(
|
|
4943
|
+
`
|
|
4944
|
+
Could not start "${cmd}".
|
|
4945
|
+
|
|
4946
|
+
To fix this:
|
|
4947
|
+
1. Make sure "${cmd}" is installed
|
|
4948
|
+
2. Open a new terminal and run: ${cmd} --version
|
|
4949
|
+
3. If that works, try running itwillsync again
|
|
4950
|
+
`
|
|
4951
|
+
);
|
|
4952
|
+
process.exit(1);
|
|
4953
|
+
}
|
|
4904
4954
|
const sessionId = `${cmd}-${Date.now().toString(36)}`;
|
|
4905
4955
|
const sessionLogger = new SessionLogger(sessionId);
|
|
4906
4956
|
const server = createSyncServer({
|