@supacloud/admin 0.14.1 → 0.14.2

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 +58 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -27252,7 +27252,7 @@ function buildRemotePreflightScript() {
27252
27252
  "export PATH",
27253
27253
  trustedInstalledGithubFunction(),
27254
27254
  "test -d /run/systemd/system || { echo 'systemd is not the active init system' >&2; exit 1; }",
27255
- 'for tool in systemctl systemd-run sha256sum stat realpath tar file find sort awk grep tail timeout flock; do command -v "$tool" >/dev/null 2>&1 || { echo "Required local-upgrade tool is missing: $tool" >&2; exit 127; }; done',
27255
+ 'for tool in systemctl systemd-run sha256sum stat realpath tar file find sort awk grep tail timeout flock install mktemp; do command -v "$tool" >/dev/null 2>&1 || { echo "Required local-upgrade tool is missing: $tool" >&2; exit 127; }; done',
27256
27256
  "tail -n 0 -- /dev/null >/dev/null 2>&1 || { echo 'A tail implementation with -n and -- support is required' >&2; exit 1; }",
27257
27257
  "systemd-run --help | grep -Eq -- '(^|[[:space:]])--collect([=[:space:]]|$)' || { echo 'systemd-run --collect is required' >&2; exit 1; }",
27258
27258
  "test -d /run/lock || { echo '/run/lock is unavailable' >&2; exit 1; }",
@@ -27328,6 +27328,54 @@ async function uploadBundleFiles(ssh, paths, bundle) {
27328
27328
  await ssh.upload(upload.localPath, `${paths.drop}/${upload.relativePath}`, { mode: 384, timeoutMs: 10 * 60000 });
27329
27329
  }
27330
27330
  }
27331
+ function managementRunnerFile(bundle) {
27332
+ const relativePath = `bundle/management-api/${bundle.managementBinaryName}`;
27333
+ const runner = bundle.files.find((file) => file.relativePath === relativePath);
27334
+ if (!runner)
27335
+ throw new Error(`Local upgrade bundle is missing ${relativePath}`);
27336
+ return runner;
27337
+ }
27338
+ function targetRunnerCapabilityCommands() {
27339
+ return [
27340
+ 'RUNNER=$(mktemp "$DROP/.runner-capability.XXXXXX")',
27341
+ `trap 'rm -f -- "$RUNNER"' EXIT`,
27342
+ `trap 'trap - EXIT HUP INT TERM; rm -f -- "$RUNNER"; exit 1' HUP INT TERM`,
27343
+ 'install -m 0700 "$RUNNER_ASSET" "$RUNNER"',
27344
+ `test "$(sha256sum "$RUNNER" | awk '{print $1}')" = "$EXPECTED_SHA256"`,
27345
+ 'VERSION_OUTPUT=$(timeout 5s "$RUNNER" --version 2>&1)',
27346
+ `[[ "$VERSION_OUTPUT" =~ ^SupaCloud[[:space:]]Version:[[:space:]]\${EXPECTED_VERSION//./\\.}$ ]] || { echo 'Target Management runner version mismatch' >&2; exit 1; }`,
27347
+ 'SYSTEMD_HELPER_OUTPUT=$(timeout 5s "$RUNNER" --systemd-unit-helper-sha256 2>&1)',
27348
+ `[[ "$SYSTEMD_HELPER_OUTPUT" =~ ^SupaCloud[[:space:]]systemd-unit[[:space:]]helper[[:space:]]SHA-256:[[:space:]][0-9a-f]{64}$ ]] || { echo 'Target Management runner lacks systemd-unit helper delivery' >&2; exit 1; }`,
27349
+ 'POSTGREST_LAUNCHER_OUTPUT=$(timeout 5s "$RUNNER" --postgrest-launcher-sha256 2>&1)',
27350
+ `[[ "$POSTGREST_LAUNCHER_OUTPUT" =~ ^SupaCloud[[:space:]]PostgREST[[:space:]]launcher[[:space:]]SHA-256:[[:space:]][0-9a-f]{64}$ ]] || { echo 'Target Management runner lacks PostgREST launcher delivery' >&2; exit 1; }`,
27351
+ 'rm -f -- "$RUNNER"',
27352
+ "trap - EXIT HUP INT TERM"
27353
+ ];
27354
+ }
27355
+ function buildTargetRunnerCapabilityScript(paths, bundle, request) {
27356
+ const runnerFile = managementRunnerFile(bundle);
27357
+ const runnerAsset = `${paths.drop}/${runnerFile.relativePath}`;
27358
+ return [
27359
+ "set -euo pipefail",
27360
+ "umask 077",
27361
+ `DROP=${quoteShell2(paths.drop)}`,
27362
+ `RUNNER_ASSET=${quoteShell2(runnerAsset)}`,
27363
+ `EXPECTED_SIZE=${runnerFile.size}`,
27364
+ `EXPECTED_SHA256=${quoteShell2(runnerFile.sha256)}`,
27365
+ `EXPECTED_VERSION=${quoteShell2(request.managementVersion)}`,
27366
+ `test -f "$RUNNER_ASSET" && test ! -L "$RUNNER_ASSET" && test "$(stat -c '%h' "$RUNNER_ASSET")" = 1 || { echo 'Target Management runner is not a direct single-link file' >&2; exit 1; }`,
27367
+ `test "$(stat -c '%s' "$RUNNER_ASSET")" = "$EXPECTED_SIZE"`,
27368
+ `test "$(sha256sum "$RUNNER_ASSET" | awk '{print $1}')" = "$EXPECTED_SHA256"`,
27369
+ ...targetRunnerCapabilityCommands()
27370
+ ].join(`
27371
+ `);
27372
+ }
27373
+ async function verifyTargetRunnerCapability(ssh, paths, bundle, request) {
27374
+ const verified = await ssh.exec(buildTargetRunnerCapabilityScript(paths, bundle, request), 30000);
27375
+ if (!verified.success) {
27376
+ throw remoteFailure("Target Management runner lacks required transactional helper delivery", verified);
27377
+ }
27378
+ }
27331
27379
  function expectedComponentFiles(bundle) {
27332
27380
  return {
27333
27381
  management: [
@@ -27475,6 +27523,7 @@ function upgradeScriptExecution(paths, bundle, request) {
27475
27523
  `test "$(sha256sum "$RUNNER"|awk '{print $1}')" = "$(sha256sum "$RUNNER_ASSET"|awk '{print $1}')"`,
27476
27524
  '"$RUNNER" --version | grep -Eq "(^|[^0-9])${MANAGEMENT_VERSION//./\\.}([^0-9]|$)"',
27477
27525
  `timeout 5s "$RUNNER" --systemd-unit-helper-sha256 | grep -Eq 'SupaCloud systemd-unit helper SHA-256: [0-9a-f]{64}'`,
27526
+ `timeout 5s "$RUNNER" --postgrest-launcher-sha256 | grep -Eq 'SupaCloud PostgREST launcher SHA-256: [0-9a-f]{64}'`,
27478
27527
  `env PATH="$VERIFIER_PATH:$PATH" "$RUNNER" upgrade --yes --target-version ${quoteShell2(request.managementVersion)} --edge-runtime-version ${quoteShell2(request.edgeRuntimeVersion)} --asset-bundle-dir "$BUNDLE"`
27479
27528
  ];
27480
27529
  }
@@ -27867,6 +27916,7 @@ async function executeLocalUpgradeTransfer(ssh, request) {
27867
27916
  try {
27868
27917
  await prepareRemoteDrop(ssh, paths, bundle);
27869
27918
  await uploadBundleFiles(ssh, paths, bundle);
27919
+ await verifyTargetRunnerCapability(ssh, paths, bundle, request);
27870
27920
  await uploadRunScript(ssh, paths, bundle, request, preflight.architecture);
27871
27921
  await adoptRemoteDrop(ssh, paths);
27872
27922
  adopted = true;
@@ -28077,10 +28127,13 @@ function componentBootstrapCommands(request) {
28077
28127
  `supacloud_download_release_asset "$MANAGEMENT_RELEASE" "$MANAGEMENT_ASSET" "$STAGED_MANAGEMENT" binary`,
28078
28128
  `chmod 0755 "$STAGED_MANAGEMENT"`,
28079
28129
  `TARGET_MANAGEMENT_VERSION=$(jq -er '.tag_name | capture("^management-api-v(?<version>(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*))$").version' <<< "$MANAGEMENT_RELEASE")`,
28080
- `STAGED_VERSION=$("$STAGED_MANAGEMENT" --version 2>&1 | grep -Eo '[0-9]+\\.[0-9]+\\.[0-9]+' | head -1 || true)`,
28130
+ `STAGED_VERSION=$(timeout 5s "$STAGED_MANAGEMENT" --version 2>&1 | grep -Eo '[0-9]+\\.[0-9]+\\.[0-9]+' | head -1 || true)`,
28081
28131
  `test "$STAGED_VERSION" = "$TARGET_MANAGEMENT_VERSION" || { echo 'Target Management binary version does not match its verified release' >&2; exit 1; }`,
28082
28132
  `supacloud_version_at_least "$STAGED_VERSION" ${quoteEnvValue(MINIMUM_COMPONENT_UPGRADE_VERSION)} || { echo 'Target Management release lacks component transaction capability' >&2; exit 1; }`,
28083
- `"$STAGED_MANAGEMENT" --systemd-unit-helper-sha256 >/dev/null 2>&1 || { echo 'Target Management release lacks target-bound systemd-unit helper delivery' >&2; exit 1; }`,
28133
+ `SYSTEMD_HELPER_OUTPUT=$(timeout 5s "$STAGED_MANAGEMENT" --systemd-unit-helper-sha256 2>&1)`,
28134
+ `[[ "$SYSTEMD_HELPER_OUTPUT" =~ ^SupaCloud[[:space:]]systemd-unit[[:space:]]helper[[:space:]]SHA-256:[[:space:]][0-9a-f]{64}$ ]] || { echo 'Target Management release lacks target-bound systemd-unit helper delivery' >&2; exit 1; }`,
28135
+ `POSTGREST_LAUNCHER_OUTPUT=$(timeout 5s "$STAGED_MANAGEMENT" --postgrest-launcher-sha256 2>&1)`,
28136
+ `[[ "$POSTGREST_LAUNCHER_OUTPUT" =~ ^SupaCloud[[:space:]]PostgREST[[:space:]]launcher[[:space:]]SHA-256:[[:space:]][0-9a-f]{64}$ ]] || { echo 'Target Management release lacks target-bound PostgREST launcher delivery' >&2; exit 1; }`,
28084
28137
  `UPGRADE_RUNNER="$STAGED_MANAGEMENT"`
28085
28138
  ];
28086
28139
  }
@@ -28127,7 +28180,7 @@ function buildRootUpgradeScript(request) {
28127
28180
  "export PATH",
28128
28181
  "unset SUPACLOUD_ALLOW_UNVERIFIED_RELEASE SUPACLOUD_GITHUB_REPOSITORY SUPACLOUD_RELEASES_API SUPACLOUD_ATTESTATION_SIGNER_WORKFLOW SUPACLOUD_ATTESTATION_TRUSTED_ROOT SUPACLOUD_GH_VERSION SUPACLOUD_GH_MIN_VERSION SUPACLOUD_GH_AMD64_SHA256 SUPACLOUD_GH_ARM64_SHA256 GH_PROXY",
28129
28182
  request.githubProxy ? `export SUPACLOUD_GITHUB_PROXY=${quoteEnvValue(request.githubProxy)}` : "unset SUPACLOUD_GITHUB_PROXY SUPACLOUD_GITHUB_PROXIES",
28130
- 'for tool in curl jq file sha256sum stat tar flock find sort chown; do command -v "$tool" >/dev/null 2>&1 || { echo "Required upgrade tool is missing: $tool" >&2; exit 127; }; done',
28183
+ 'for tool in curl jq file sha256sum stat tar flock find sort chown timeout; do command -v "$tool" >/dev/null 2>&1 || { echo "Required upgrade tool is missing: $tool" >&2; exit 127; }; done',
28131
28184
  "test -d /run/lock || { echo '/run/lock is unavailable' >&2; exit 1; }",
28132
28185
  "test -x /usr/local/bin/supacloud || { echo 'SupaCloud binary not found at /usr/local/bin/supacloud; run ssh install first.' >&2; exit 127; }",
28133
28186
  ...trustedRootPreflightCommands(request.helperPath),
@@ -31843,7 +31896,7 @@ Actions: list_releases, get_release, upload_release, activate_release`, {
31843
31896
  // package.json
31844
31897
  var package_default = {
31845
31898
  name: "@supacloud/admin",
31846
- version: "0.14.1",
31899
+ version: "0.14.2",
31847
31900
  description: "Platform administration CLI for SupaCloud operators",
31848
31901
  type: "module",
31849
31902
  main: "./dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/admin",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
4
4
  "description": "Platform administration CLI for SupaCloud operators",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",