@supacloud/admin 0.16.0 → 0.17.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.
Files changed (2) hide show
  1. package/dist/index.js +37 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -27733,6 +27733,16 @@ function shellArray(name, entries) {
27733
27733
  }
27734
27734
  function finishUpgradeFunction() {
27735
27735
  return [
27736
+ "emit_wrapper_failure_receipt() {",
27737
+ " local code=$1 target_phase=${2:-${UPGRADE_PHASE:-}} phase",
27738
+ ` if [ -n "\${LOG:-}" ] && ! grep -q '^SUPACLOUD_UPGRADE_FAILURE=' "$LOG" 2>/dev/null; then`,
27739
+ ' case "$target_phase" in',
27740
+ ' bootstrap|filesystem_checks|transfer_verification|verifier_setup|runner_preflight|runner_upgrade|cleanup|status_publish) phase="$target_phase" ;;',
27741
+ ' *) phase="unknown" ;;',
27742
+ " esac",
27743
+ ` printf 'SUPACLOUD_UPGRADE_FAILURE={"causes":["exit_code=%s","phase=%s"],"schema":"supacloud.upgrade-failure.v1","summary":"Remote upgrade execution failed during %s (exit code %s)"}\\n' "$code" "$phase" "$phase" "$code" >> "$LOG" || true`,
27744
+ " fi",
27745
+ "}",
27736
27746
  "finish_upgrade() {",
27737
27747
  " local code=$?",
27738
27748
  " trap '' HUP INT TERM",
@@ -27740,15 +27750,27 @@ function finishUpgradeFunction() {
27740
27750
  " set +e",
27741
27751
  ' if [ "$code" -ne 0 ]; then',
27742
27752
  ' write_status "FAILED:${code}:TRANSACTION" || true',
27753
+ ' emit_wrapper_failure_receipt "$code"',
27743
27754
  ' if ! rm -rf -- "$STAGE"; then write_status "FAILED:${code}:TRANSACTION_AND_CLEANUP" || true; fi',
27744
27755
  ' exit "$code"',
27745
27756
  " fi",
27746
- " write_status CLEANING || { echo 'Unable to publish cleanup state' >&2; exit 1; }",
27757
+ " if ! write_status CLEANING; then",
27758
+ " echo 'Unable to publish cleanup state' >&2",
27759
+ " write_status 'FAILED:1:TRANSACTION' || true",
27760
+ " emit_wrapper_failure_receipt 1 status_publish",
27761
+ ` if ! rm -rf -- "$STAGE"; then write_status 'FAILED:1:TRANSACTION_AND_CLEANUP' || true; fi`,
27762
+ " exit 1",
27763
+ " fi",
27747
27764
  ' if ! rm -rf -- "$STAGE"; then',
27748
27765
  " write_status 'FAILED:1:CLEANUP_AFTER_TRANSACTION' || true",
27766
+ " emit_wrapper_failure_receipt 1 cleanup",
27767
+ " exit 1",
27768
+ " fi",
27769
+ " if ! write_status SUCCEEDED; then",
27770
+ " write_status 'FAILED:1:TRANSACTION' || true",
27771
+ " emit_wrapper_failure_receipt 1 status_publish",
27749
27772
  " exit 1",
27750
27773
  " fi",
27751
- " write_status SUCCEEDED || exit 1",
27752
27774
  " exit 0",
27753
27775
  "}"
27754
27776
  ].join(`
@@ -27768,6 +27790,7 @@ function upgradeScriptSetup(paths) {
27768
27790
  `BUNDLE=${quoteShell2(bundleDirectory)}`,
27769
27791
  `MANAGEMENT_DIR=${quoteShell2(`${bundleDirectory}/management-api`)}`,
27770
27792
  `EDGE_DIR=${quoteShell2(`${bundleDirectory}/edge-runtime`)}`,
27793
+ "UPGRADE_PHASE=bootstrap",
27771
27794
  `write_status() { local next="\${STATUS}.next"; printf '%s\\n' "$1" > "$next"; chmod 600 "$next"; mv -f "$next" "$STATUS"; }`,
27772
27795
  finishUpgradeFunction(),
27773
27796
  "trap finish_upgrade EXIT",
@@ -27785,6 +27808,7 @@ function upgradeScriptFilesystemChecks(bundle) {
27785
27808
  const componentFiles = expectedComponentFiles(bundle);
27786
27809
  const stageEntries = ["bundle", "run.sh", ...bundle.verifierArchive ? ["verifier"] : []];
27787
27810
  const checks = [
27811
+ "UPGRADE_PHASE=filesystem_checks",
27788
27812
  shellArray("MANAGEMENT_FILES", componentFiles.management),
27789
27813
  shellArray("EDGE_FILES", componentFiles.edge),
27790
27814
  `assert_directory() { local path=$1; test -d "$path" && test ! -L "$path"; test "$(stat -c '%u:%g' "$path")" = '0:0'; test "$(stat -c '%a' "$path")" = '700'; }`,
@@ -27812,6 +27836,7 @@ function upgradeScriptFilesystemChecks(bundle) {
27812
27836
  function upgradeScriptTransferVerification(bundle) {
27813
27837
  const files = [...bundle.files, ...bundle.verifierArchive ? [bundle.verifierArchive] : []];
27814
27838
  return [
27839
+ "UPGRADE_PHASE=transfer_verification",
27815
27840
  `verify_transfer() { local relative=$1 expected_size=$2 expected_sha=$3; local path=$STAGE/$relative; test "$(stat -c '%s' "$path")" = "$expected_size"; test "$(sha256sum "$path" | awk '{print $1}')" = "$expected_sha"; }`,
27816
27841
  ...files.map((file) => `verify_transfer ${quoteShell2(file.relativePath)} ${file.size} ${quoteShell2(file.sha256)}`)
27817
27842
  ];
@@ -27824,6 +27849,7 @@ function upgradeScriptVerifier(paths, bundle, architecture) {
27824
27849
  ];
27825
27850
  const capabilityFlags = STRICT_GITHUB_CAPABILITY_FLAGS.join(" ");
27826
27851
  return [
27852
+ "UPGRADE_PHASE=verifier_setup",
27827
27853
  ...setup,
27828
27854
  `GH_HELP=$(timeout 15s "$GH" attestation verify --help 2>&1) || { echo 'GitHub verifier capability check failed' >&2; exit 1; }`,
27829
27855
  `for flag in ${capabilityFlags}; do printf '%s\\n' "$GH_HELP" | grep -Eq -- "(^|[[:space:]])${"$"}{flag}([=[:space:]]|$)" || { echo "GitHub verifier lacks $flag" >&2; exit 1; }; done`,
@@ -27851,6 +27877,7 @@ function upgradeScriptExecution(paths, bundle, request) {
27851
27877
  const runner = `${paths.stage}/runner`;
27852
27878
  const preflight = 'CONTROL_PLANE_PREFLIGHT_RECEIPT=$(env PATH="$VERIFIER_PATH:$PATH" "$RUNNER" --control-plane-upgrade-preflight)';
27853
27879
  return [
27880
+ "UPGRADE_PHASE=runner_preflight",
27854
27881
  `MANAGEMENT_VERSION=${quoteShell2(request.managementVersion)}`,
27855
27882
  `RUNNER_ASSET=${quoteShell2(runnerAsset)}`,
27856
27883
  `RUNNER=${quoteShell2(runner)}`,
@@ -27861,6 +27888,7 @@ function upgradeScriptExecution(paths, bundle, request) {
27861
27888
  `timeout 5s "$RUNNER" --systemd-unit-helper-sha256 | grep -Eq 'SupaCloud systemd-unit helper SHA-256: [0-9a-f]{64}'`,
27862
27889
  `timeout 5s "$RUNNER" --postgrest-launcher-sha256 | grep -Eq 'SupaCloud PostgREST launcher SHA-256: [0-9a-f]{64}'`,
27863
27890
  preflight,
27891
+ "UPGRADE_PHASE=runner_upgrade",
27864
27892
  `env PATH="$VERIFIER_PATH:$PATH" "$RUNNER" upgrade --yes --target-version ${quoteShell2(request.managementVersion)} --edge-runtime-version ${quoteShell2(request.edgeRuntimeVersion)} --asset-bundle-dir "$BUNDLE"`,
27865
27893
  `printf '%s\\n' "$CONTROL_PLANE_PREFLIGHT_RECEIPT"`
27866
27894
  ];
@@ -31789,6 +31817,7 @@ Actions: routes, upsert_route, update_route, delete_route, config, get_certifica
31789
31817
  managed_upstream: optional(stringEnum(["edge-functions"]), "[upsert_route/update_route] 托管上游(同步 Edge Function)"),
31790
31818
  upstream_tls_insecure_skip_verify: optional(Type.Boolean(), "[upsert_route/update_route] 上游 TLS 跳过校验"),
31791
31819
  static_root: optional(Type.String(), "[upsert_route/update_route] 静态站点根目录"),
31820
+ spa: optional(Type.Boolean(), "[upsert_route/update_route] 是否启用 SPA 单页回退"),
31792
31821
  protocol: optional(stringEnum(["http", "https"]), "[upsert_route/update_route] 可选请求协议匹配"),
31793
31822
  redirect_to: optional(Type.String(), "[upsert_route/update_route] 带固定 host 的绝对 http(s) 目标,可在末尾使用 {http.request.uri}"),
31794
31823
  redirect_status: withDescription(redirectStatus, "[upsert_route/update_route] 重定向状态码,默认 308"),
@@ -31835,6 +31864,7 @@ Actions: routes, upsert_route, update_route, delete_route, config, get_certifica
31835
31864
  managed_upstream,
31836
31865
  upstream_tls_insecure_skip_verify,
31837
31866
  static_root,
31867
+ spa,
31838
31868
  protocol,
31839
31869
  redirect_to,
31840
31870
  redirect_status,
@@ -31884,6 +31914,8 @@ Actions: routes, upsert_route, update_route, delete_route, config, get_certifica
31884
31914
  body.upstream_tls_insecure_skip_verify = upstream_tls_insecure_skip_verify;
31885
31915
  if (static_root !== undefined)
31886
31916
  body.static_root = static_root;
31917
+ if (spa !== undefined)
31918
+ body.spa = spa;
31887
31919
  if (protocol !== undefined)
31888
31920
  body.protocol = protocol;
31889
31921
  if (redirect_to !== undefined)
@@ -31921,6 +31953,8 @@ Actions: routes, upsert_route, update_route, delete_route, config, get_certifica
31921
31953
  body.upstream_tls_insecure_skip_verify = upstream_tls_insecure_skip_verify;
31922
31954
  if (static_root !== undefined)
31923
31955
  body.static_root = static_root;
31956
+ if (spa !== undefined)
31957
+ body.spa = spa;
31924
31958
  if (protocol !== undefined)
31925
31959
  body.protocol = protocol;
31926
31960
  if (redirect_to !== undefined)
@@ -32514,7 +32548,7 @@ Actions: list_releases, get_release, upload_release, activate_release`, {
32514
32548
  // package.json
32515
32549
  var package_default = {
32516
32550
  name: "@supacloud/admin",
32517
- version: "0.16.0",
32551
+ version: "0.17.0",
32518
32552
  description: "Platform administration CLI for SupaCloud operators",
32519
32553
  type: "module",
32520
32554
  main: "./dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/admin",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Platform administration CLI for SupaCloud operators",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",