openship 0.2.3 → 0.4.0
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/README.md +104 -61
- package/dist/bare-ITM45QBX.js +18 -0
- package/dist/bowser-MFQA6OS4.js +2821 -0
- package/dist/chunk-3U4SPZD5.js +241 -0
- package/dist/chunk-46YJFP4S.js +1771 -0
- package/dist/chunk-4CQWT2WL.js +116 -0
- package/dist/chunk-4FABQGQP.js +23 -0
- package/dist/chunk-4LEL3H2Z.js +84 -0
- package/dist/chunk-4MG3BVHE.js +326 -0
- package/dist/chunk-4VNS5WPM.js +42 -0
- package/dist/chunk-5N7VUGL6.js +2094 -0
- package/dist/chunk-5ZCKQ2MI.js +1360 -0
- package/dist/chunk-6ERIMTBC.js +1412 -0
- package/dist/chunk-7UOB5GGQ.js +132 -0
- package/dist/chunk-BUBSSKO6.js +1384 -0
- package/dist/chunk-E6W2JMMU.js +341 -0
- package/dist/chunk-E77LJWJK.js +1535 -0
- package/dist/chunk-F4DFVG6Q.js +573 -0
- package/dist/chunk-HFYDYK4D.js +1092 -0
- package/dist/chunk-JR2OCMJA.js +46 -0
- package/dist/chunk-JUJBBF5U.js +746 -0
- package/dist/chunk-JZLNHGLW.js +19145 -0
- package/dist/chunk-KD7VO4LG.js +2617 -0
- package/dist/chunk-LBFH7THC.js +435 -0
- package/dist/chunk-NB2VEIWG.js +129 -0
- package/dist/chunk-OJE6YWPQ.js +2866 -0
- package/dist/chunk-QKFRZNKN.js +4941 -0
- package/dist/chunk-RBZPFTHV.js +13354 -0
- package/dist/chunk-S6DSRLNE.js +121 -0
- package/dist/chunk-TEYJYSMT.js +409 -0
- package/dist/chunk-U2DPZSXA.js +112 -0
- package/dist/chunk-WJPCBU7Z.js +3147 -0
- package/dist/chunk-XIFRMKYT.js +13 -0
- package/dist/chunk-XVSAUO2I.js +7946 -0
- package/dist/chunk-Y37KHU7L.js +31 -0
- package/dist/chunk-YL67EWYZ.js +416 -0
- package/dist/chunk-ZKJOFWBJ.js +1879 -0
- package/dist/cloud-JMPHO3CW.js +7 -0
- package/dist/cloud-W5G6YXAY.js +24 -0
- package/dist/dist-L3MPOWCA.js +65 -0
- package/dist/dist-es-4C322O5D.js +22 -0
- package/dist/dist-es-GTAMF674.js +87 -0
- package/dist/dist-es-KE56MWYO.js +169 -0
- package/dist/dist-es-NRZIQY5B.js +484 -0
- package/dist/dist-es-WZCR7DHQ.js +317 -0
- package/dist/dist-es-XQCOTGC7.js +376 -0
- package/dist/dist-es-ZW3HFQUM.js +69 -0
- package/dist/docker-3FVJMFC3.js +12 -0
- package/dist/docker-edge-executor-ZIWAZWPL.js +9 -0
- package/dist/edge-import-53M5DGWZ.js +39 -0
- package/dist/event-streams-7LGDL56D.js +42 -0
- package/dist/executor-J7BHW5HF.js +26 -0
- package/dist/index.js +2459 -3461
- package/dist/loadSso-N273C5I7.js +577 -0
- package/dist/nginx-YZWKYKQU.js +16 -0
- package/dist/noop-RRNCIUI5.js +7 -0
- package/dist/openresty-lua-HAO4EUDY.js +32 -0
- package/dist/server/index.js +217916 -205055
- package/dist/server/migrations/0057_complete_prism.sql +18 -0
- package/dist/server/migrations/0058_add_server_is_local.sql +1 -0
- package/dist/server/migrations/0059_legal_fixer.sql +18 -0
- package/dist/server/migrations/0060_add_route_strategy_host_port.sql +3 -0
- package/dist/server/migrations/0061_notification_default_multi_kind.sql +3 -0
- package/dist/server/migrations/0062_add_incoming_webhook.sql +21 -0
- package/dist/server/migrations/0063_add_migration_logs.sql +1 -0
- package/dist/server/migrations/0064_add_migration_partial.sql +2 -0
- package/dist/server/migrations/0065_custom_app_template.sql +14 -0
- package/dist/server/migrations/0066_ensure_migration_partial_columns.sql +2 -0
- package/dist/server/migrations/0067_webhook_delivery.sql +28 -0
- package/dist/server/migrations/0068_add_migration_target_volumes.sql +1 -0
- package/dist/server/migrations/0069_add_project_composite_routes.sql +1 -0
- package/dist/server/migrations/0070_forward_git_to_server.sql +1 -0
- package/dist/server/migrations/meta/0057_snapshot.json +9326 -0
- package/dist/server/migrations/meta/0058_snapshot.json +9333 -0
- package/dist/server/migrations/meta/0059_snapshot.json +9495 -0
- package/dist/server/migrations/meta/0060_snapshot.json +9515 -0
- package/dist/server/migrations/meta/_journal.json +99 -1
- package/dist/setup-5X3WEEHA.js +14 -0
- package/dist/signin-DR462ERO.js +663 -0
- package/dist/sso-oidc-VBZLJUK5.js +830 -0
- package/dist/sts-EJLZ4Z77.js +1422 -0
- package/package.json +6 -2
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatDuration,
|
|
3
|
+
isRemoteConnectionError,
|
|
4
|
+
systemDebug
|
|
5
|
+
} from "./chunk-4LEL3H2Z.js";
|
|
6
|
+
import {
|
|
7
|
+
safeErrorMessage
|
|
8
|
+
} from "./chunk-JZLNHGLW.js";
|
|
9
|
+
|
|
10
|
+
// ../../packages/adapters/src/system/port-listen.ts
|
|
11
|
+
var PROC_NET_TCP_CMD = "cat /proc/net/tcp 2>/dev/null; cat /proc/net/tcp6 2>/dev/null; true";
|
|
12
|
+
var TCP_LISTEN = "0A";
|
|
13
|
+
function parseListeningPorts(procText) {
|
|
14
|
+
const ports = /* @__PURE__ */ new Set();
|
|
15
|
+
for (const rawLine of procText.split("\n")) {
|
|
16
|
+
const line = rawLine.trim();
|
|
17
|
+
if (!line) continue;
|
|
18
|
+
const fields = line.split(/\s+/);
|
|
19
|
+
if (fields.length < 4) continue;
|
|
20
|
+
if (fields[3] !== TCP_LISTEN) continue;
|
|
21
|
+
const local = fields[1];
|
|
22
|
+
const colon = local.lastIndexOf(":");
|
|
23
|
+
if (colon === -1) continue;
|
|
24
|
+
const hexPort = local.slice(colon + 1);
|
|
25
|
+
if (!/^[0-9A-Fa-f]{1,4}$/.test(hexPort)) continue;
|
|
26
|
+
const port = parseInt(hexPort, 16);
|
|
27
|
+
if (port > 0) ports.add(port);
|
|
28
|
+
}
|
|
29
|
+
return ports;
|
|
30
|
+
}
|
|
31
|
+
async function probePortListeningOnce(executor, port) {
|
|
32
|
+
try {
|
|
33
|
+
const out = await executor.exec(PROC_NET_TCP_CMD, { timeout: 5e3 });
|
|
34
|
+
return parseListeningPorts(out).has(port);
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ../../packages/adapters/src/runtime/port-conflict.ts
|
|
41
|
+
async function tryExec(executor, command) {
|
|
42
|
+
try {
|
|
43
|
+
return await executor.exec(command);
|
|
44
|
+
} catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function resolveSystemdUnit(executor, pid) {
|
|
49
|
+
const cgroup = await tryExec(executor, `cat /proc/${pid}/cgroup 2>/dev/null || true`);
|
|
50
|
+
const unitMatch = cgroup?.match(/(?:^|\/)([^/\n]+\.service)(?:$|\n|\/)/m) ?? cgroup?.match(/(?:^|\/)([^/\n]+\.service)(?:$|\n|\/)/m);
|
|
51
|
+
const systemdUnit = unitMatch?.[1]?.trim();
|
|
52
|
+
if (!systemdUnit || !/^[A-Za-z0-9@._:\\-]+\.service$/.test(systemdUnit)) {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
const description = await tryExec(
|
|
56
|
+
executor,
|
|
57
|
+
`systemctl show ${systemdUnit} --property=Description --value 2>/dev/null || true`
|
|
58
|
+
);
|
|
59
|
+
const managedMatch = systemdUnit.match(/^openship-(.+)\.service$/);
|
|
60
|
+
return {
|
|
61
|
+
systemdUnit,
|
|
62
|
+
systemdDescription: description?.trim() || void 0,
|
|
63
|
+
deploymentId: managedMatch?.[1],
|
|
64
|
+
isManagedDeployment: Boolean(managedMatch)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async function resolveListener(executor, port) {
|
|
68
|
+
const out = await tryExec(
|
|
69
|
+
executor,
|
|
70
|
+
`ss -tlnp sport = :${port} 2>/dev/null | grep LISTEN || lsof -ti tcp:${port} -sTCP:LISTEN 2>/dev/null || true`
|
|
71
|
+
);
|
|
72
|
+
if (out) {
|
|
73
|
+
const ssMatch = out.match(/pid=(\d+)/);
|
|
74
|
+
const lsofMatch = !ssMatch ? out.match(/^\s*(\d+)\s*$/m) : null;
|
|
75
|
+
const pid = ssMatch ? parseInt(ssMatch[1], 10) : lsofMatch ? parseInt(lsofMatch[1], 10) : null;
|
|
76
|
+
if (pid) return { pid, occupied: true };
|
|
77
|
+
}
|
|
78
|
+
const listening = await probePortListeningOnce(executor, port);
|
|
79
|
+
return { pid: null, occupied: listening === true };
|
|
80
|
+
}
|
|
81
|
+
async function probeListeningPort(executor, port) {
|
|
82
|
+
try {
|
|
83
|
+
const { pid, occupied } = await resolveListener(executor, port);
|
|
84
|
+
if (!occupied) return null;
|
|
85
|
+
if (pid === null) return { pid: null, command: "unknown listener" };
|
|
86
|
+
return await describeProcess(executor, pid);
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function describeProcess(executor, pid) {
|
|
92
|
+
let command = `PID ${pid}`;
|
|
93
|
+
let rawCommand;
|
|
94
|
+
const args = await tryExec(executor, `ps -p ${pid} -o args= 2>/dev/null || true`);
|
|
95
|
+
if (args?.trim()) {
|
|
96
|
+
rawCommand = args.trim();
|
|
97
|
+
command = `${rawCommand} (PID ${pid})`;
|
|
98
|
+
} else {
|
|
99
|
+
const cmd = await tryExec(executor, `ps -p ${pid} -o comm= 2>/dev/null || true`);
|
|
100
|
+
if (cmd?.trim()) {
|
|
101
|
+
rawCommand = cmd.trim();
|
|
102
|
+
command = `${rawCommand} (PID ${pid})`;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const systemd = await resolveSystemdUnit(executor, pid);
|
|
106
|
+
return { pid, command, rawCommand, ...systemd };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ../../packages/adapters/src/system/environment.ts
|
|
110
|
+
var profileCache = /* @__PURE__ */ new WeakMap();
|
|
111
|
+
async function execSafe(executor, command, timeout = 5e3) {
|
|
112
|
+
const startedAt = Date.now();
|
|
113
|
+
systemDebug("environment", `exec:start ${command}`);
|
|
114
|
+
try {
|
|
115
|
+
const result = await executor.exec(command, { timeout });
|
|
116
|
+
systemDebug(
|
|
117
|
+
"environment",
|
|
118
|
+
`exec:ok ${command} (${formatDuration(startedAt)})`
|
|
119
|
+
);
|
|
120
|
+
return result;
|
|
121
|
+
} catch (err) {
|
|
122
|
+
if (isRemoteConnectionError(err)) {
|
|
123
|
+
systemDebug(
|
|
124
|
+
"environment",
|
|
125
|
+
`exec:abort ${command} (${formatDuration(startedAt)}) ${safeErrorMessage(err)}`
|
|
126
|
+
);
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
const msg = safeErrorMessage(err);
|
|
130
|
+
systemDebug(
|
|
131
|
+
"environment",
|
|
132
|
+
`exec:fail ${command} (${formatDuration(startedAt)}) ${msg}`
|
|
133
|
+
);
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function parseOs(uname) {
|
|
138
|
+
const value = uname?.trim().toLowerCase();
|
|
139
|
+
if (value === "linux") return "linux";
|
|
140
|
+
if (value === "darwin") return "darwin";
|
|
141
|
+
return "unknown";
|
|
142
|
+
}
|
|
143
|
+
function parseArch(uname) {
|
|
144
|
+
const value = uname?.trim().toLowerCase() ?? "";
|
|
145
|
+
if (["x86_64", "amd64"].includes(value)) return "amd64";
|
|
146
|
+
if (["aarch64", "arm64"].includes(value)) return "arm64";
|
|
147
|
+
return "unknown";
|
|
148
|
+
}
|
|
149
|
+
function parseDistro(osRelease) {
|
|
150
|
+
if (!osRelease) return null;
|
|
151
|
+
const lower = osRelease.toLowerCase();
|
|
152
|
+
const match = lower.match(/^id=(.+)$/m);
|
|
153
|
+
const id = match?.[1]?.replaceAll('"', "").trim();
|
|
154
|
+
switch (id) {
|
|
155
|
+
case "ubuntu":
|
|
156
|
+
return "ubuntu";
|
|
157
|
+
case "debian":
|
|
158
|
+
return "debian";
|
|
159
|
+
case "fedora":
|
|
160
|
+
return "fedora";
|
|
161
|
+
case "rhel":
|
|
162
|
+
case "rhel server":
|
|
163
|
+
return "rhel";
|
|
164
|
+
case "centos":
|
|
165
|
+
return "centos";
|
|
166
|
+
case "alpine":
|
|
167
|
+
return "alpine";
|
|
168
|
+
default:
|
|
169
|
+
return "unknown";
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function detectPackageManager(executor) {
|
|
173
|
+
const checks = [
|
|
174
|
+
["apt", "command -v apt-get"],
|
|
175
|
+
["dnf", "command -v dnf"],
|
|
176
|
+
["yum", "command -v yum"],
|
|
177
|
+
["apk", "command -v apk"],
|
|
178
|
+
["brew", "command -v brew"]
|
|
179
|
+
];
|
|
180
|
+
for (const [pm, command] of checks) {
|
|
181
|
+
if (await execSafe(executor, command)) return pm;
|
|
182
|
+
}
|
|
183
|
+
return "none";
|
|
184
|
+
}
|
|
185
|
+
async function detectServiceManager(executor) {
|
|
186
|
+
if (await execSafe(executor, "command -v systemctl")) return "systemd";
|
|
187
|
+
if (await execSafe(executor, "command -v launchctl")) return "launchd";
|
|
188
|
+
return "none";
|
|
189
|
+
}
|
|
190
|
+
async function detectPrivilege(executor) {
|
|
191
|
+
const uid = await execSafe(executor, "id -u");
|
|
192
|
+
const isRoot = uid?.trim() === "0";
|
|
193
|
+
if (isRoot) return { isRoot: true, canSudo: false };
|
|
194
|
+
const sudo = await execSafe(
|
|
195
|
+
executor,
|
|
196
|
+
"sudo -n true 2>/dev/null && echo yes || echo no"
|
|
197
|
+
);
|
|
198
|
+
return { isRoot: false, canSudo: sudo?.trim() === "yes" };
|
|
199
|
+
}
|
|
200
|
+
async function detectProfile(executor) {
|
|
201
|
+
const startedAt = Date.now();
|
|
202
|
+
systemDebug("environment", "detect:start");
|
|
203
|
+
const unameOs = await execSafe(executor, "uname -s");
|
|
204
|
+
const unameArch = await execSafe(executor, "uname -m");
|
|
205
|
+
const osRelease = await execSafe(executor, "cat /etc/os-release");
|
|
206
|
+
const packageManager = await detectPackageManager(executor);
|
|
207
|
+
const serviceManager = await detectServiceManager(executor);
|
|
208
|
+
const { isRoot, canSudo } = await detectPrivilege(executor);
|
|
209
|
+
const os = parseOs(unameOs);
|
|
210
|
+
const profile = {
|
|
211
|
+
os,
|
|
212
|
+
arch: parseArch(unameArch),
|
|
213
|
+
distro: os === "linux" ? parseDistro(osRelease) : null,
|
|
214
|
+
packageManager,
|
|
215
|
+
serviceManager,
|
|
216
|
+
isRoot,
|
|
217
|
+
canSudo
|
|
218
|
+
};
|
|
219
|
+
systemDebug(
|
|
220
|
+
"environment",
|
|
221
|
+
`detect:done (${formatDuration(startedAt)}) ${JSON.stringify(profile)}`
|
|
222
|
+
);
|
|
223
|
+
return profile;
|
|
224
|
+
}
|
|
225
|
+
async function resolveEnvironment(executor) {
|
|
226
|
+
let promise = profileCache.get(executor);
|
|
227
|
+
if (!promise) {
|
|
228
|
+
systemDebug("environment", "cache:miss");
|
|
229
|
+
promise = detectProfile(executor);
|
|
230
|
+
profileCache.set(executor, promise);
|
|
231
|
+
} else {
|
|
232
|
+
systemDebug("environment", "cache:hit");
|
|
233
|
+
}
|
|
234
|
+
return promise;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export {
|
|
238
|
+
resolveEnvironment,
|
|
239
|
+
probeListeningPort,
|
|
240
|
+
describeProcess
|
|
241
|
+
};
|