@buildautomaton/cli 0.1.9 → 0.1.10
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 +88 -37
- package/dist/cli.js.map +4 -4
- package/dist/index.js +88 -37
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5232,7 +5232,7 @@ var require_websocket = __commonJS({
|
|
|
5232
5232
|
"../../node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/websocket.js"(exports, module) {
|
|
5233
5233
|
"use strict";
|
|
5234
5234
|
var EventEmitter2 = __require("events");
|
|
5235
|
-
var
|
|
5235
|
+
var https2 = __require("https");
|
|
5236
5236
|
var http = __require("http");
|
|
5237
5237
|
var net = __require("net");
|
|
5238
5238
|
var tls = __require("tls");
|
|
@@ -5767,7 +5767,7 @@ var require_websocket = __commonJS({
|
|
|
5767
5767
|
}
|
|
5768
5768
|
const defaultPort = isSecure ? 443 : 80;
|
|
5769
5769
|
const key = randomBytes(16).toString("base64");
|
|
5770
|
-
const request = isSecure ?
|
|
5770
|
+
const request = isSecure ? https2.request : http.request;
|
|
5771
5771
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
5772
5772
|
let perMessageDeflate;
|
|
5773
5773
|
opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
|
|
@@ -25177,9 +25177,6 @@ var import_websocket = __toESM(require_websocket(), 1);
|
|
|
25177
25177
|
var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
25178
25178
|
var wrapper_default = import_websocket.default;
|
|
25179
25179
|
|
|
25180
|
-
// src/bridge/connection/create-ws-bridge.ts
|
|
25181
|
-
import https from "node:https";
|
|
25182
|
-
|
|
25183
25180
|
// src/net/apply-cli-outbound-network-prefs.ts
|
|
25184
25181
|
import dns from "node:dns";
|
|
25185
25182
|
var applied = false;
|
|
@@ -25192,20 +25189,44 @@ function applyCliOutboundNetworkPreferences() {
|
|
|
25192
25189
|
}
|
|
25193
25190
|
}
|
|
25194
25191
|
|
|
25192
|
+
// src/bridge/connection/cli-ws-client.ts
|
|
25193
|
+
import https from "node:https";
|
|
25194
|
+
function buildCliWebSocketClientOptions(wsUrl) {
|
|
25195
|
+
const wsOptions = { perMessageDeflate: false, family: 4 };
|
|
25196
|
+
if (wsUrl.startsWith("wss://")) {
|
|
25197
|
+
wsOptions.agent = new https.Agent({ rejectUnauthorized: false, family: 4 });
|
|
25198
|
+
}
|
|
25199
|
+
return wsOptions;
|
|
25200
|
+
}
|
|
25201
|
+
function logCliWebSocketError(log2, serviceLabel, err, detail) {
|
|
25202
|
+
const mid = detail ? ` ${detail}` : "";
|
|
25203
|
+
log2(`${serviceLabel} WebSocket error${mid}: ${err.message}`);
|
|
25204
|
+
}
|
|
25205
|
+
function safeCloseWebSocket(ws) {
|
|
25206
|
+
try {
|
|
25207
|
+
if (ws.readyState === wrapper_default.CLOSED) {
|
|
25208
|
+
ws.removeAllListeners();
|
|
25209
|
+
return;
|
|
25210
|
+
}
|
|
25211
|
+
ws.once("close", () => {
|
|
25212
|
+
ws.removeAllListeners();
|
|
25213
|
+
});
|
|
25214
|
+
ws.close();
|
|
25215
|
+
} catch {
|
|
25216
|
+
try {
|
|
25217
|
+
ws.removeAllListeners();
|
|
25218
|
+
} catch {
|
|
25219
|
+
}
|
|
25220
|
+
}
|
|
25221
|
+
}
|
|
25222
|
+
|
|
25195
25223
|
// src/bridge/connection/create-ws-bridge.ts
|
|
25196
25224
|
var BRIDGE_AUTH_ERROR_HEADER = "x-bridge-auth-error";
|
|
25197
25225
|
var BRIDGE_AUTH_ERROR_TOKEN_INVALID = "token_invalid";
|
|
25198
25226
|
function createWsBridge(options) {
|
|
25199
25227
|
const { url: url2, onMessage, onOpen, onClose, onError: onError2, onAuthInvalid, clientPingIntervalMs } = options;
|
|
25200
25228
|
applyCliOutboundNetworkPreferences();
|
|
25201
|
-
const
|
|
25202
|
-
perMessageDeflate: false,
|
|
25203
|
-
family: 4
|
|
25204
|
-
};
|
|
25205
|
-
if (url2.startsWith("wss://")) {
|
|
25206
|
-
wsOptions.agent = new https.Agent({ rejectUnauthorized: false, family: 4 });
|
|
25207
|
-
}
|
|
25208
|
-
const ws = new wrapper_default(url2, wsOptions);
|
|
25229
|
+
const ws = new wrapper_default(url2, buildCliWebSocketClientOptions(url2));
|
|
25209
25230
|
let clientPingTimer = null;
|
|
25210
25231
|
function clearClientPing() {
|
|
25211
25232
|
if (clientPingTimer != null) {
|
|
@@ -25528,9 +25549,9 @@ function runPendingAuth(options) {
|
|
|
25528
25549
|
keepaliveInterval = null;
|
|
25529
25550
|
}
|
|
25530
25551
|
if (ws) {
|
|
25531
|
-
ws
|
|
25532
|
-
ws.close();
|
|
25552
|
+
const w = ws;
|
|
25533
25553
|
ws = null;
|
|
25554
|
+
safeCloseWebSocket(w);
|
|
25534
25555
|
}
|
|
25535
25556
|
}
|
|
25536
25557
|
function connect() {
|
|
@@ -25573,7 +25594,7 @@ function runPendingAuth(options) {
|
|
|
25573
25594
|
connect();
|
|
25574
25595
|
}, delay2);
|
|
25575
25596
|
},
|
|
25576
|
-
onError: (err) => logFn
|
|
25597
|
+
onError: (err) => logCliWebSocketError(logFn, "[Bridge service]", err, "while waiting for sign-in"),
|
|
25577
25598
|
onMessage: (data) => {
|
|
25578
25599
|
const msg = data;
|
|
25579
25600
|
if (msg.type === "auth_token" && typeof msg.token === "string") {
|
|
@@ -32793,14 +32814,50 @@ async function removeSessionWorktrees(paths, log2) {
|
|
|
32793
32814
|
}
|
|
32794
32815
|
|
|
32795
32816
|
// src/git/working-tree-status.ts
|
|
32796
|
-
async function
|
|
32797
|
-
|
|
32817
|
+
async function tryConfigGet(g, key) {
|
|
32818
|
+
try {
|
|
32819
|
+
const out = await g.raw(["config", "--get", key]);
|
|
32820
|
+
const v = String(out).trim();
|
|
32821
|
+
return v || null;
|
|
32822
|
+
} catch {
|
|
32823
|
+
return null;
|
|
32824
|
+
}
|
|
32825
|
+
}
|
|
32826
|
+
async function resolveRemoteTrackingRefForAhead(g) {
|
|
32798
32827
|
try {
|
|
32799
32828
|
await g.raw(["rev-parse", "--verify", "@{u}"]);
|
|
32829
|
+
return "@{u}";
|
|
32800
32830
|
} catch {
|
|
32801
|
-
return 0;
|
|
32802
32831
|
}
|
|
32803
|
-
const
|
|
32832
|
+
const branch = (await g.raw(["rev-parse", "--abbrev-ref", "HEAD"])).trim();
|
|
32833
|
+
if (!branch || branch === "HEAD") return null;
|
|
32834
|
+
const remote = await tryConfigGet(g, `branch.${branch}.remote`) ?? "origin";
|
|
32835
|
+
const merge2 = await tryConfigGet(g, `branch.${branch}.merge`);
|
|
32836
|
+
if (merge2) {
|
|
32837
|
+
const upstreamBranch = merge2.replace(/^refs\/heads\//, "");
|
|
32838
|
+
const ref = `refs/remotes/${remote}/${upstreamBranch}`;
|
|
32839
|
+
try {
|
|
32840
|
+
await g.raw(["rev-parse", "--verify", ref]);
|
|
32841
|
+
return ref;
|
|
32842
|
+
} catch {
|
|
32843
|
+
}
|
|
32844
|
+
}
|
|
32845
|
+
const fallbackRef = `refs/remotes/${remote}/${branch}`;
|
|
32846
|
+
try {
|
|
32847
|
+
await g.raw(["rev-parse", "--verify", fallbackRef]);
|
|
32848
|
+
return fallbackRef;
|
|
32849
|
+
} catch {
|
|
32850
|
+
return null;
|
|
32851
|
+
}
|
|
32852
|
+
}
|
|
32853
|
+
async function commitsAheadOfRemoteTracking(repoDir) {
|
|
32854
|
+
const g = simpleGit(repoDir);
|
|
32855
|
+
const trackingRef = await resolveRemoteTrackingRefForAhead(g);
|
|
32856
|
+
if (!trackingRef) return 0;
|
|
32857
|
+
const localSha = (await g.raw(["rev-parse", "HEAD"])).trim();
|
|
32858
|
+
const remoteSha = (await g.raw(["rev-parse", trackingRef])).trim();
|
|
32859
|
+
if (localSha === remoteSha) return 0;
|
|
32860
|
+
const out = await g.raw(["rev-list", "--count", `${trackingRef}..HEAD`]);
|
|
32804
32861
|
const n = parseInt(String(out).trim(), 10);
|
|
32805
32862
|
return Number.isNaN(n) ? 0 : n;
|
|
32806
32863
|
}
|
|
@@ -32808,7 +32865,7 @@ async function getRepoWorkingTreeStatus(repoDir) {
|
|
|
32808
32865
|
const g = simpleGit(repoDir);
|
|
32809
32866
|
const st = await g.status();
|
|
32810
32867
|
const hasUncommittedChanges = (st.files?.length ?? 0) > 0;
|
|
32811
|
-
const ahead = await
|
|
32868
|
+
const ahead = await commitsAheadOfRemoteTracking(repoDir);
|
|
32812
32869
|
return { hasUncommittedChanges, hasUnpushedCommits: ahead > 0 };
|
|
32813
32870
|
}
|
|
32814
32871
|
async function aggregateSessionPathsWorkingTreeStatus(paths) {
|
|
@@ -32824,7 +32881,7 @@ async function aggregateSessionPathsWorkingTreeStatus(paths) {
|
|
|
32824
32881
|
async function pushAheadOfUpstreamForPaths(paths) {
|
|
32825
32882
|
for (const p of paths) {
|
|
32826
32883
|
const g = simpleGit(p);
|
|
32827
|
-
const ahead = await
|
|
32884
|
+
const ahead = await commitsAheadOfRemoteTracking(p);
|
|
32828
32885
|
if (ahead <= 0) continue;
|
|
32829
32886
|
await g.push();
|
|
32830
32887
|
}
|
|
@@ -34099,9 +34156,6 @@ var DevServerManager = class {
|
|
|
34099
34156
|
}
|
|
34100
34157
|
};
|
|
34101
34158
|
|
|
34102
|
-
// src/firehose/connect-firehose.ts
|
|
34103
|
-
import https2 from "node:https";
|
|
34104
|
-
|
|
34105
34159
|
// src/firehose/proxy/local-proxy.ts
|
|
34106
34160
|
var ALLOWED_HOSTS = ["localhost", "127.0.0.1", "::1"];
|
|
34107
34161
|
function isAllowedHost(host) {
|
|
@@ -34348,11 +34402,7 @@ function connectFirehose(options) {
|
|
|
34348
34402
|
const { firehoseServerUrl, workspaceId, bridgeName, proxyPorts, log: log2, devServerManager, onOpen, onClose } = options;
|
|
34349
34403
|
const wsUrl = buildFirehoseCliWsUrl(firehoseServerUrl);
|
|
34350
34404
|
applyCliOutboundNetworkPreferences();
|
|
34351
|
-
const
|
|
34352
|
-
if (wsUrl.startsWith("wss://")) {
|
|
34353
|
-
wsOptions.agent = new https2.Agent({ rejectUnauthorized: false, family: 4 });
|
|
34354
|
-
}
|
|
34355
|
-
const ws = new wrapper_default(wsUrl, wsOptions);
|
|
34405
|
+
const ws = new wrapper_default(wsUrl, buildCliWebSocketClientOptions(wsUrl));
|
|
34356
34406
|
let clientPingTimer = null;
|
|
34357
34407
|
function clearClientPing() {
|
|
34358
34408
|
if (clientPingTimer != null) {
|
|
@@ -34403,17 +34453,13 @@ function connectFirehose(options) {
|
|
|
34403
34453
|
});
|
|
34404
34454
|
ws.on("error", (err) => {
|
|
34405
34455
|
clearClientPing();
|
|
34406
|
-
log2
|
|
34456
|
+
logCliWebSocketError(log2, "[Proxy and log service]", err);
|
|
34407
34457
|
});
|
|
34408
34458
|
return {
|
|
34409
34459
|
close() {
|
|
34410
34460
|
clearClientPing();
|
|
34411
34461
|
devServerManager.detachFirehose();
|
|
34412
|
-
|
|
34413
|
-
ws.removeAllListeners();
|
|
34414
|
-
ws.close();
|
|
34415
|
-
} catch {
|
|
34416
|
-
}
|
|
34462
|
+
safeCloseWebSocket(ws);
|
|
34417
34463
|
},
|
|
34418
34464
|
isConnected: () => ws.readyState === wrapper_default.OPEN
|
|
34419
34465
|
};
|
|
@@ -35824,6 +35870,11 @@ function createMainBridgeWebSocketLifecycle(params) {
|
|
|
35824
35870
|
const prev = state.currentWs;
|
|
35825
35871
|
if (prev) {
|
|
35826
35872
|
prev.removeAllListeners();
|
|
35873
|
+
prev.once("error", () => {
|
|
35874
|
+
});
|
|
35875
|
+
prev.once("close", () => {
|
|
35876
|
+
prev.removeAllListeners();
|
|
35877
|
+
});
|
|
35827
35878
|
try {
|
|
35828
35879
|
prev.close();
|
|
35829
35880
|
} catch {
|
|
@@ -35869,7 +35920,7 @@ function createMainBridgeWebSocketLifecycle(params) {
|
|
|
35869
35920
|
},
|
|
35870
35921
|
onOpen: handleOpen,
|
|
35871
35922
|
onClose: handleClose,
|
|
35872
|
-
onError: (err) => logFn
|
|
35923
|
+
onError: (err) => logCliWebSocketError(logFn, "[Bridge service]", err),
|
|
35873
35924
|
onMessage: (data) => handleBridgeMessage(data, messageDeps)
|
|
35874
35925
|
});
|
|
35875
35926
|
}
|