@sylphx/cli 0.14.7 → 0.14.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @sylphx/cli
2
2
 
3
+ ## 0.14.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1546](https://github.com/SylphxAI/platform/pull/1546) [`0412606`](https://github.com/SylphxAI/platform/commit/04126068505391fa9a7aee21681e18dc083bb0a1) Thanks [@shtse8](https://github.com/shtse8)! - Scope deploy log terminal status to the active build record and verify the deployment rollout separately before reporting success.
8
+
9
+ ## 0.14.8
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1523](https://github.com/SylphxAI/platform/pull/1523) [`c6297fa`](https://github.com/SylphxAI/platform/commit/c6297fa1fab2a8fa7fd4bb83705ffbea9f17b7d2) Thanks [@shtse8](https://github.com/shtse8)! - Keep deploy log streaming attached across transient SSE disconnects so native
14
+ EventSource reconnect can recover without prematurely failing `sylphx deploy`.
15
+
3
16
  ## 0.14.7
4
17
 
5
18
  ### Patch Changes
package/dist/main.js CHANGED
@@ -15,7 +15,7 @@ var init_package = __esm({
15
15
  "package.json"() {
16
16
  package_default = {
17
17
  name: "@sylphx/cli",
18
- version: "0.14.7",
18
+ version: "0.14.9",
19
19
  description: "Sylphx Platform CLI \u2014 deploy and manage your applications from the terminal. 63 commands across deployment, logs, env vars, domains, databases, storage, monitoring, self-service (user), admin (users/quotas/audit/invitations/jwt-keys/project-migrate), and more.",
20
20
  type: "module",
21
21
  homepage: "https://sylphx.com",
@@ -20595,6 +20595,7 @@ async function createEnvironmentLogStream(envId, options = {}) {
20595
20595
  limit: String(options.limit ?? 200)
20596
20596
  });
20597
20597
  if (options.deploymentId) params.set("deploymentId", options.deploymentId);
20598
+ if (options.buildId) params.set("buildId", options.buildId);
20598
20599
  if (options.since) params.set("since", options.since);
20599
20600
  if (options.level) params.set("level", options.level);
20600
20601
  const preferredOrgId = options.orgId ?? resolvePreferredOrgId();
@@ -26768,6 +26769,19 @@ var TERMINAL_GRACE_MS = 500;
26768
26769
  var LogStreamTransportError = class extends Error {
26769
26770
  name = "LogStreamTransportError";
26770
26771
  };
26772
+ function statusFromEventSourceError(event) {
26773
+ const raw = event.status ?? event.code;
26774
+ if (typeof raw === "number") return Number.isInteger(raw) ? raw : void 0;
26775
+ if (typeof raw === "string" && /^\d+$/.test(raw)) return Number.parseInt(raw, 10);
26776
+ return void 0;
26777
+ }
26778
+ function isFatalEventSourceError(event) {
26779
+ const status3 = statusFromEventSourceError(event);
26780
+ if (!status3) return false;
26781
+ if (status3 === 204 || status3 === 401 || status3 === 403 || status3 === 404) return true;
26782
+ if (status3 === 408 || status3 === 429) return false;
26783
+ return status3 >= 400 && status3 < 500;
26784
+ }
26771
26785
  function streamLogs(url, token, opts = {}) {
26772
26786
  return new Promise((resolve2, reject) => {
26773
26787
  const headers = {
@@ -26883,14 +26897,18 @@ function streamLogs(url, token, opts = {}) {
26883
26897
  }
26884
26898
  });
26885
26899
  es.addEventListener("error", (event) => {
26900
+ touchIdle();
26886
26901
  const errorEvent = event;
26887
26902
  const message = errorEvent.message ?? "log stream connection closed unexpectedly";
26888
26903
  if (gracefulDone || terminalStatus) {
26889
26904
  finishAfterDone();
26890
- } else {
26905
+ } else if (isFatalEventSourceError(errorEvent)) {
26891
26906
  opts.onTransportError?.(message);
26892
26907
  console.log(chalk_default.red(` Stream error: ${message}`));
26893
26908
  failTransport(message);
26909
+ } else {
26910
+ opts.onTransportError?.(message);
26911
+ console.log(chalk_default.yellow(` Stream reconnecting: ${message}`));
26894
26912
  }
26895
26913
  });
26896
26914
  if (!opts.follow) {
@@ -26914,12 +26932,29 @@ function deployLogStreamEffect(api2, projectId, envType, result, orgId) {
26914
26932
  return api2.createEnvironmentLogStream(result.envId, {
26915
26933
  type: "build",
26916
26934
  deploymentId: deploymentId2,
26935
+ ...result.buildRecordId ? { buildId: result.buildRecordId } : {},
26917
26936
  ...orgId ? { orgId } : {}
26918
26937
  });
26919
26938
  }
26920
26939
  const logScope = orgId || result.envId ? { ...orgId ? { orgId } : {}, ...result.envId ? { envId: result.envId } : {} } : void 0;
26921
26940
  return api2.createLogStream(projectId, envType, logScope);
26922
26941
  }
26942
+ function verifyDeploymentAfterBuildLogs(api2, id, orgId, timeoutMs) {
26943
+ return Effect28.gen(function* () {
26944
+ yield* Console17.log("");
26945
+ yield* Console17.log(chalk_default.dim(" Verifying authoritative deployment state..."));
26946
+ yield* withSpinner(
26947
+ `Waiting for deployment ${chalk_default.bold(id)} rollout...`,
26948
+ waitForDeploymentSuccessEffect(api2, {
26949
+ id,
26950
+ ...orgId ? { orgId } : {},
26951
+ command: "deploy",
26952
+ timeoutMs
26953
+ })
26954
+ );
26955
+ return true;
26956
+ });
26957
+ }
26923
26958
  function reconcileDeploymentAfterLogStreamIssue(api2, id, orgId, reason, timeoutMs) {
26924
26959
  return Effect28.gen(function* () {
26925
26960
  yield* Console17.log("");
@@ -27080,6 +27115,12 @@ The trigger response did not include a deployment id, so the authoritative deplo
27080
27115
  })
27081
27116
  );
27082
27117
  }
27118
+ if (result.buildRecordId) {
27119
+ const id = deploymentRecordId(result);
27120
+ if (id) {
27121
+ yield* verifyDeploymentAfterBuildLogs(api2, id, orgId, reconcileTimeoutMs);
27122
+ }
27123
+ }
27083
27124
  yield* Console17.log("");
27084
27125
  yield* Console17.log(chalk_default.green.bold(" \u2713 Deployment successful!"));
27085
27126
  yield* Console17.log("");