openship 0.6.6 → 0.6.7

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.
Files changed (58) hide show
  1. package/dist/bare-7QD623QV.js +29 -0
  2. package/dist/{chunk-Q7WGTQQ5.js → chunk-2ANV5ZQ5.js} +1 -1
  3. package/dist/{chunk-UJ6JZM65.js → chunk-2VSW6Q6C.js} +601 -382
  4. package/dist/{chunk-PCPVTH6M.js → chunk-5T4UVOM3.js} +6 -4
  5. package/dist/{chunk-YMMQRE5J.js → chunk-BLEXTYRK.js} +1 -1
  6. package/dist/{chunk-OBPKYXQL.js → chunk-CIJV43LH.js} +71 -32
  7. package/dist/{chunk-NK5N5LXN.js → chunk-DDFUESPJ.js} +24 -9
  8. package/dist/{chunk-6FH4AXVY.js → chunk-E2X26PXR.js} +1 -1
  9. package/dist/{chunk-HKRQXPTI.js → chunk-FYPFEDPZ.js} +1 -1
  10. package/dist/{chunk-UVNMQM7W.js → chunk-FZ6QCF6B.js} +8 -6
  11. package/dist/{chunk-MLYSEZQB.js → chunk-GGIAIGUL.js} +15 -66
  12. package/dist/{chunk-2YM3NI2E.js → chunk-GIPJNNI5.js} +38 -44
  13. package/dist/{chunk-ZFJXPCQP.js → chunk-H3WT3A6R.js} +4 -3
  14. package/dist/chunk-H4FS5BED.js +936 -0
  15. package/dist/{chunk-CBLD2HS5.js → chunk-J2XM3QSP.js} +8 -5
  16. package/dist/{chunk-FE7ZZQSE.js → chunk-J3K6XABC.js} +3 -3
  17. package/dist/{chunk-77QDF6UD.js → chunk-LHFXSC36.js} +428 -93
  18. package/dist/{chunk-YIMOCZBZ.js → chunk-MEE6OZFP.js} +3 -3
  19. package/dist/chunk-N5YZMO33.js +111 -0
  20. package/dist/{chunk-QVW76WDL.js → chunk-NRTJRNAE.js} +58 -16
  21. package/dist/{chunk-WVAML4H6.js → chunk-PPEBIY5F.js} +247 -61
  22. package/dist/{chunk-4I2BM2DT.js → chunk-PVP4RGWT.js} +3 -3
  23. package/dist/{chunk-RSR7PFIQ.js → chunk-QHMDCYZ3.js} +4 -4
  24. package/dist/chunk-R4VDPFLS.js +106 -0
  25. package/dist/{chunk-VTGPEC6B.js → chunk-RDXT4BQB.js} +6 -4
  26. package/dist/{chunk-LFE5KQ7Y.js → chunk-S6B2Z3OO.js} +142 -57
  27. package/dist/chunk-UWEV6XTS.js +249 -0
  28. package/dist/{chunk-5DMWSTOM.js → chunk-VQM6JHJB.js} +940 -224
  29. package/dist/{chunk-SM26HDS2.js → chunk-VSTFHUCV.js} +44 -50
  30. package/dist/chunk-WU54BXFE.js +70 -0
  31. package/dist/{chunk-LUKYPVJ4.js → chunk-XWHWTHEL.js} +313 -469
  32. package/dist/{chunk-A4GXYE4L.js → chunk-ZPJ74LXE.js} +22 -20
  33. package/dist/cloud-KNNABE3O.js +40 -0
  34. package/dist/{detect-OIE5V3VZ.js → detect-G4DR3U2N.js} +9 -6
  35. package/dist/{docker-VTR2GK5Y.js → docker-YOVPCIB4.js} +11 -8
  36. package/dist/{docker-edge-executor-22IBXNYJ.js → docker-edge-executor-QFXD3337.js} +8 -6
  37. package/dist/edge-import-CRFVSR6P.js +56 -0
  38. package/dist/{edge-preflight-GBNCPNVU.js → edge-preflight-MXERVAMG.js} +15 -12
  39. package/dist/{ensure-container-edge-KPI2CVXJ.js → ensure-container-edge-F4JUNQIK.js} +13 -10
  40. package/dist/{executor-7LXXZPBR.js → executor-CVPAYYHR.js} +8 -6
  41. package/dist/host-channel-preflight-QTDNGLCK.js +54 -0
  42. package/dist/index.js +84 -48
  43. package/dist/{local-executor-WOFZD72X.js → local-executor-ODC6RANU.js} +3 -2
  44. package/dist/{nginx-KUFMLMAC.js → nginx-KLFF43TC.js} +11 -8
  45. package/dist/{openresty-lua-ATTH35BE.js → openresty-lua-VKWUV4GB.js} +6 -5
  46. package/dist/{privilege-I4W3ZNZK.js → privilege-7D3SSOL3.js} +6 -5
  47. package/dist/server/index.js +8813 -5232
  48. package/dist/setup-I5AJC6NJ.js +25 -0
  49. package/dist/{ssh-client-JBMA7SN4.js → ssh-client-625VWGKP.js} +3 -2
  50. package/dist/up-QXTOOVXC.js +61 -0
  51. package/package.json +1 -1
  52. package/dist/bare-OXJVW3AK.js +0 -25
  53. package/dist/chunk-LH2PLRQO.js +0 -434
  54. package/dist/cloud-75VIT4KV.js +0 -37
  55. package/dist/edge-import-WJUB4M7F.js +0 -52
  56. package/dist/host-channel-preflight-KE6OONYK.js +0 -50
  57. package/dist/setup-XGLGUUFW.js +0 -22
  58. package/dist/up-K4BV7466.js +0 -57
@@ -3,43 +3,14 @@
3
3
  import { createRequire as __ospCreateRequire } from "node:module";
4
4
  const require = __ospCreateRequire(import.meta.url);
5
5
  import {
6
- formatDuration,
7
- isRemoteConnectionError,
8
- safeErrorMessage,
9
- systemDebug
10
- } from "./chunk-UJ6JZM65.js";
11
-
12
- // ../../packages/adapters/src/system/probe-exec.ts
13
- async function tryExec(executor, command, opts) {
14
- try {
15
- return opts ? await executor.exec(command, opts) : await executor.exec(command);
16
- } catch {
17
- return null;
18
- }
19
- }
20
- async function probeExec(executor, command, scope) {
21
- const startedAt = Date.now();
22
- systemDebug(scope, `exec:start ${command}`);
23
- try {
24
- const result = await executor.exec(command, { timeout: 1e4 });
25
- systemDebug(scope, `exec:ok ${command} (${formatDuration(startedAt)})`);
26
- return { output: result.trim(), error: null };
27
- } catch (err) {
28
- const msg = safeErrorMessage(err);
29
- if (isRemoteConnectionError(err)) {
30
- systemDebug(scope, `exec:abort ${command} (${formatDuration(startedAt)}) ${msg}`);
31
- throw err;
32
- }
33
- systemDebug(scope, `exec:fail ${command} (${formatDuration(startedAt)}) ${msg}`);
34
- return { output: "", error: msg || `\`${command}\` failed` };
35
- }
36
- }
37
- function withReason(message, error) {
38
- if (!error) return message;
39
- const first = error.split("\n").map((line) => line.trim()).find(Boolean);
40
- if (!first) return message;
41
- return `${message} \u2014 ${first.length > 200 ? `${first.slice(0, 199)}\u2026` : first}`;
42
- }
6
+ containerIdFromCgroup,
7
+ isContainerPortForwarder,
8
+ managedDeploymentIdFromUnit,
9
+ tryExec
10
+ } from "./chunk-UWEV6XTS.js";
11
+ import {
12
+ shellQuote
13
+ } from "./chunk-2VSW6Q6C.js";
43
14
 
44
15
  // ../../packages/adapters/src/system/port-listen.ts
45
16
  var PROC_NET_TCP_CMD = "cat /proc/net/tcp 2>/dev/null; cat /proc/net/tcp6 2>/dev/null; true";
@@ -113,23 +84,23 @@ async function waitForPortFree(executor, port, opts = {}) {
113
84
  }
114
85
 
115
86
  // ../../packages/adapters/src/runtime/port-conflict.ts
116
- async function resolveSystemdUnit(executor, pid) {
87
+ async function resolveListenerOwner(executor, pid) {
117
88
  const cgroup = await tryExec(executor, `cat /proc/${pid}/cgroup 2>/dev/null || true`);
118
- const unitMatch = cgroup?.match(/(?:^|\/)([^/\n]+\.service)(?:$|\n|\/)/m) ?? cgroup?.match(/(?:^|\/)([^/\n]+\.service)(?:$|\n|\/)/m);
119
- const systemdUnit = unitMatch?.[1]?.trim();
120
- if (!systemdUnit || !/^[A-Za-z0-9@._:\\-]+\.service$/.test(systemdUnit)) {
89
+ const containerId = containerIdFromCgroup(cgroup);
90
+ if (containerId) return { containerId };
91
+ const systemdUnit = cgroup?.match(/(?:^|\/)([^/\n]+\.service)(?:$|\n|\/)/m)?.[1]?.trim();
92
+ if (!systemdUnit || !/^[A-Za-z0-9@._:-]+\.service$/.test(systemdUnit)) {
121
93
  return {};
122
94
  }
123
95
  const description = await tryExec(
124
96
  executor,
125
- `systemctl show ${systemdUnit} --property=Description --value 2>/dev/null || true`
97
+ `systemctl show ${shellQuote(systemdUnit)} --property=Description --value 2>/dev/null || true`
126
98
  );
127
- const managedMatch = systemdUnit.match(/^openship-(.+)\.service$/);
99
+ const deploymentId = managedDeploymentIdFromUnit(systemdUnit);
128
100
  return {
129
101
  systemdUnit,
130
102
  systemdDescription: description?.trim() || void 0,
131
- deploymentId: managedMatch?.[1],
132
- isManagedDeployment: Boolean(managedMatch)
103
+ ...deploymentId ? { deploymentId, isManagedDeployment: true } : { isManagedDeployment: false }
133
104
  };
134
105
  }
135
106
  async function resolveListener(executor, port) {
@@ -170,16 +141,39 @@ async function describeProcess(executor, pid) {
170
141
  command = `${rawCommand} (PID ${pid})`;
171
142
  }
172
143
  }
173
- const systemd = await resolveSystemdUnit(executor, pid);
144
+ if (isContainerPortForwarder(rawCommand)) {
145
+ return { pid, command, rawCommand, dockerPublished: true };
146
+ }
147
+ const systemd = await resolveListenerOwner(executor, pid);
174
148
  return { pid, command, rawCommand, ...systemd };
175
149
  }
150
+ function portOccupantDetails(port, occupant, stopTarget) {
151
+ if (!occupant) return { port };
152
+ return {
153
+ port,
154
+ pid: occupant.pid,
155
+ command: occupant.command,
156
+ rawCommand: occupant.rawCommand,
157
+ systemdUnit: occupant.systemdUnit,
158
+ systemdDescription: occupant.systemdDescription,
159
+ deploymentId: occupant.deploymentId,
160
+ isManagedDeployment: occupant.isManagedDeployment,
161
+ containerId: occupant.containerId,
162
+ containerName: occupant.containerName,
163
+ containerImage: occupant.containerImage,
164
+ ownerProjectId: occupant.ownerProjectId,
165
+ serviceName: occupant.serviceName,
166
+ dockerPublished: occupant.dockerPublished,
167
+ platformContainer: occupant.platformContainer,
168
+ ambiguousOwners: occupant.ambiguousOwners,
169
+ ...stopTarget ? { stopTarget } : {}
170
+ };
171
+ }
176
172
 
177
173
  export {
178
- tryExec,
179
- probeExec,
180
- withReason,
181
174
  waitForPortListening,
182
175
  waitForPortFree,
183
176
  probeListeningPort,
184
- describeProcess
177
+ describeProcess,
178
+ portOccupantDetails
185
179
  };
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env sh
2
+ ":" //# ; exec "$(command -v node || command -v bun)" "$0" "$@"
3
+ import { createRequire as __ospCreateRequire } from "node:module";
4
+ const require = __ospCreateRequire(import.meta.url);
5
+ import {
6
+ sq
7
+ } from "./chunk-H3WT3A6R.js";
8
+
9
+ // ../../packages/adapters/src/runtime/managed-artifact.ts
10
+ var MANAGED_ARTIFACT_BASE = "/opt/openship";
11
+ var PROTECTED_ROOTS = /* @__PURE__ */ new Set([
12
+ MANAGED_ARTIFACT_BASE,
13
+ // BareRuntime's own layout (workDir = MANAGED_ARTIFACT_BASE): releases/<depId>,
14
+ // .builds/<sessionId>. The parents hold every project's releases at once.
15
+ `${MANAGED_ARTIFACT_BASE}/releases`,
16
+ `${MANAGED_ARTIFACT_BASE}/.builds`,
17
+ // The static tree, whose parent is ALSO the one directory bind-mounted into the
18
+ // edge container — removing it stops the box serving every static site it hosts.
19
+ `${MANAGED_ARTIFACT_BASE}/static`,
20
+ `${MANAGED_ARTIFACT_BASE}/static/releases`,
21
+ `${MANAGED_ARTIFACT_BASE}/static/.builds`
22
+ ]);
23
+ function canonical(ref) {
24
+ const trimmed = ref.trim();
25
+ return trimmed.length > 1 ? trimmed.replace(/\/+$/, "") : trimmed;
26
+ }
27
+ function assertManagedArtifactPath(ref) {
28
+ const target = canonical(ref);
29
+ if (!target.startsWith("/") || target.includes("..")) {
30
+ throw new Error(
31
+ `Refusing to remove "${ref}": an artifact path must be absolute and free of "..".`
32
+ );
33
+ }
34
+ if (PROTECTED_ROOTS.has(target)) {
35
+ throw new Error(
36
+ `Refusing to remove "${ref}": that is a shared parent directory, not one deployment's output.`
37
+ );
38
+ }
39
+ if (target !== MANAGED_ARTIFACT_BASE && !target.startsWith(`${MANAGED_ARTIFACT_BASE}/`)) {
40
+ throw new Error(
41
+ `Refusing to remove "${ref}": outside ${MANAGED_ARTIFACT_BASE}. Openship removes only directories it created (release dirs, static doc-roots, build dirs).`
42
+ );
43
+ }
44
+ }
45
+ async function removeManagedArtifact(executor, ref) {
46
+ assertManagedArtifactPath(ref);
47
+ const target = canonical(ref);
48
+ if (executor) {
49
+ await executor.exec(`rm -rf ${sq(target)}`);
50
+ if (await executor.exists(target)) {
51
+ throw new Error(`Failed to remove ${target}: still present after rm -rf.`);
52
+ }
53
+ return;
54
+ }
55
+ const { rm, access } = await import("fs/promises");
56
+ await rm(target, { recursive: true, force: true });
57
+ const stillThere = await access(target).then(
58
+ () => true,
59
+ () => false
60
+ );
61
+ if (stillThere) throw new Error(`Failed to remove ${target}: still present after rm.`);
62
+ }
63
+ function isArtifactPathRef(ref) {
64
+ return ref.startsWith("/");
65
+ }
66
+
67
+ export {
68
+ removeManagedArtifact,
69
+ isArtifactPathRef
70
+ };