@supacloud/admin 0.24.1 → 0.24.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 +93 -68
  2. package/package.json +5 -2
package/dist/index.js CHANGED
@@ -29364,14 +29364,13 @@ function quoteShell(shellText) {
29364
29364
  }
29365
29365
 
29366
29366
  // src/shared/releases/local-upgrade-bundle.ts
29367
- import { spawn } from "node:child_process";
29368
29367
  import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
29369
29368
  import { accessSync, chmodSync as chmodSync2, constants as fsConstants, copyFileSync, createWriteStream, lstatSync, mkdirSync, mkdtempSync as mkdtempSync2, readFileSync as readFileSync3, readdirSync, rmSync as rmSync2, statSync, writeFileSync as writeFileSync2 } from "node:fs";
29370
29369
  import { get } from "node:https";
29371
29370
  import { tmpdir as tmpdir2 } from "node:os";
29372
29371
  import { basename, delimiter, isAbsolute, join } from "node:path";
29373
29372
  import { pipeline as pipeline3 } from "node:stream/promises";
29374
- import { Transform } from "node:stream";
29373
+ import { Readable, Transform } from "node:stream";
29375
29374
 
29376
29375
  // ../management-api/src/release-manifest.ts
29377
29376
  var RELEASE_MANIFEST_NAME = "SUPACLOUD-RELEASE.json";
@@ -30015,70 +30014,81 @@ function spawnGithubCli(arguments_, download = false) {
30015
30014
  environment[key] = process.env[key];
30016
30015
  }
30017
30016
  }
30018
- return spawn(githubCliExecutable(environment), arguments_, {
30017
+ return Bun.spawn([githubCliExecutable(environment), ...arguments_], {
30019
30018
  env: environment,
30020
30019
  stdio: ["ignore", "pipe", "pipe"]
30021
30020
  });
30022
30021
  }
30023
- function githubCliExitCode(child, timeoutMs) {
30024
- return new Promise((resolve, reject) => {
30025
- let timedOut = false;
30026
- let settled = false;
30027
- let forceKillTimer;
30028
- const timeout = setTimeout(() => {
30029
- timedOut = true;
30030
- child.kill("SIGTERM");
30031
- forceKillTimer = setTimeout(() => child.kill("SIGKILL"), GH_TERMINATION_GRACE_MS);
30032
- }, timeoutMs);
30033
- const settleExecution = (error, exitCode) => {
30034
- if (settled)
30035
- return;
30036
- settled = true;
30037
- clearTimeout(timeout);
30038
- if (forceKillTimer)
30039
- clearTimeout(forceKillTimer);
30040
- if (error)
30041
- reject(error);
30042
- else
30043
- resolve(timedOut ? 124 : exitCode);
30044
- };
30045
- child.once("error", (error) => settleExecution(error, 127));
30046
- child.once("close", (code) => settleExecution(undefined, code ?? 1));
30047
- });
30048
- }
30049
30022
  async function runGithubCli(arguments_, timeoutMs) {
30050
30023
  const child = spawnGithubCli(arguments_);
30051
- let stdout = "";
30052
- let stderr = "";
30053
- child.stdout.on("data", (chunk) => {
30054
- stdout = `${stdout}${chunk.toString()}`.slice(-8000);
30055
- });
30056
- child.stderr.on("data", (chunk) => {
30057
- stderr = `${stderr}${chunk.toString()}`.slice(-8000);
30058
- });
30059
- const exitCode = await githubCliExitCode(child, timeoutMs);
30060
- return { exitCode, stdout, stderr };
30024
+ let timedOut = false;
30025
+ let forceKillTimer;
30026
+ const timeout = setTimeout(() => {
30027
+ timedOut = true;
30028
+ child.kill("SIGTERM");
30029
+ forceKillTimer = setTimeout(() => child.kill("SIGKILL"), GH_TERMINATION_GRACE_MS);
30030
+ }, timeoutMs);
30031
+ try {
30032
+ const [rawStdout, rawStderr, exitCode] = await Promise.all([
30033
+ child.stdout ? new Response(child.stdout).text() : Promise.resolve(""),
30034
+ child.stderr ? new Response(child.stderr).text() : Promise.resolve(""),
30035
+ child.exited
30036
+ ]);
30037
+ clearTimeout(timeout);
30038
+ if (forceKillTimer)
30039
+ clearTimeout(forceKillTimer);
30040
+ const stdout = rawStdout.slice(-8000);
30041
+ const stderr = rawStderr.slice(-8000);
30042
+ return { exitCode: timedOut ? 124 : exitCode ?? 1, stdout, stderr };
30043
+ } catch (error) {
30044
+ clearTimeout(timeout);
30045
+ if (forceKillTimer)
30046
+ clearTimeout(forceKillTimer);
30047
+ child.kill("SIGKILL");
30048
+ throw error;
30049
+ }
30061
30050
  }
30062
30051
  async function runGithubCliDownload(arguments_, destination, maxBytes, timeoutMs) {
30063
30052
  const child = spawnGithubCli(arguments_, true);
30064
- let stderr = "";
30065
- child.stderr.on("data", (chunk) => {
30066
- stderr = `${stderr}${chunk.toString()}`.slice(-8000);
30067
- });
30068
- const write = pipeline3(child.stdout, boundedWriter(maxBytes), createWriteStream(destination, { flags: "wx", mode: 384 })).catch((error) => {
30053
+ let timedOut = false;
30054
+ let forceKillTimer;
30055
+ const timeout = setTimeout(() => {
30056
+ timedOut = true;
30057
+ child.kill("SIGTERM");
30058
+ forceKillTimer = setTimeout(() => child.kill("SIGKILL"), GH_TERMINATION_GRACE_MS);
30059
+ }, timeoutMs);
30060
+ const stderrPromise = (async () => {
30061
+ try {
30062
+ return child.stderr ? (await new Response(child.stderr).text()).slice(-8000) : "";
30063
+ } catch {
30064
+ return "";
30065
+ }
30066
+ })();
30067
+ const write = pipeline3(Readable.fromWeb(child.stdout), boundedWriter(maxBytes), createWriteStream(destination, { flags: "wx", mode: 384 })).catch((error) => {
30069
30068
  child.kill("SIGKILL");
30070
30069
  throw error;
30071
30070
  });
30072
- const [writeState, exitState] = await Promise.allSettled([write, githubCliExitCode(child, timeoutMs)]);
30073
- if (writeState.status === "rejected") {
30074
- rmSync2(destination, { force: true });
30075
- throw writeState.reason;
30076
- }
30077
- if (exitState.status === "rejected") {
30071
+ try {
30072
+ const [writeState, exitState, stderrState] = await Promise.allSettled([
30073
+ write,
30074
+ child.exited,
30075
+ stderrPromise
30076
+ ]);
30077
+ if (writeState.status === "rejected")
30078
+ throw writeState.reason;
30079
+ if (exitState.status === "rejected")
30080
+ throw exitState.reason;
30081
+ if (stderrState.status === "rejected")
30082
+ throw stderrState.reason;
30083
+ return { exitCode: timedOut ? 124 : exitState.value, stdout: "", stderr: stderrState.value };
30084
+ } catch (error) {
30078
30085
  rmSync2(destination, { force: true });
30079
- throw exitState.reason;
30086
+ throw error;
30087
+ } finally {
30088
+ clearTimeout(timeout);
30089
+ if (forceKillTimer)
30090
+ clearTimeout(forceKillTimer);
30080
30091
  }
30081
- return { exitCode: exitState.value, stdout: "", stderr };
30082
30092
  }
30083
30093
  function supportsStrictGithubVerification(execution) {
30084
30094
  const tokens = `${execution.stdout}
@@ -33137,18 +33147,25 @@ Actions: list, deploy, deploy_bundle, source, delete, check`, {
33137
33147
  };
33138
33148
  let text;
33139
33149
  const checkSyntax = async (sourceCode) => {
33140
- const fs = __require("fs");
33141
33150
  const os = __require("os");
33142
- const { promisify } = __require("util");
33143
- const execAsync = promisify(__require("child_process").exec);
33151
+ const fs = __require("fs");
33144
33152
  const tmpFile = `${os.tmpdir()}/supacloud_edge_${Date.now()}.ts`;
33145
- fs.writeFileSync(tmpFile, sourceCode);
33153
+ await Bun.write(tmpFile, sourceCode);
33146
33154
  try {
33147
- await execAsync(`bun build ${tmpFile} --external='*'`);
33148
- return { ok: true };
33155
+ const proc = Bun.spawn(["bun", "build", tmpFile, "--external=*"], {
33156
+ stdout: "pipe",
33157
+ stderr: "pipe"
33158
+ });
33159
+ const exitCode = await proc.exited;
33160
+ if (exitCode === 0) {
33161
+ return { ok: true };
33162
+ }
33163
+ const stdout = await new Response(proc.stdout).text();
33164
+ const stderr = await new Response(proc.stderr).text();
33165
+ return { ok: false, err: stdout + `
33166
+ ` + (stderr || `exit code ${exitCode}`) };
33149
33167
  } catch (e) {
33150
- return { ok: false, err: e.stdout + `
33151
- ` + (e.stderr || e.message) };
33168
+ return { ok: false, err: e.message || String(e) };
33152
33169
  } finally {
33153
33170
  try {
33154
33171
  fs.unlinkSync(tmpFile);
@@ -33159,8 +33176,6 @@ Actions: list, deploy, deploy_bundle, source, delete, check`, {
33159
33176
  try {
33160
33177
  const fs = __require("fs");
33161
33178
  const os = __require("os");
33162
- const { promisify } = __require("util");
33163
- const execAsync = promisify(__require("child_process").exec);
33164
33179
  const stat = fs.statSync(pathArg);
33165
33180
  let entrypoint = pathArg;
33166
33181
  if (stat.isDirectory()) {
@@ -33171,10 +33186,17 @@ Actions: list, deploy, deploy_bundle, source, delete, check`, {
33171
33186
  }
33172
33187
  const tmpOut = `${os.tmpdir()}/supacloud_bundled_${Date.now()}.js`;
33173
33188
  try {
33174
- const { stderr } = await execAsync(`bun build ${entrypoint} --target bun --outfile ${tmpOut}`);
33175
- if (!fs.existsSync(tmpOut))
33176
- throw new Error(`Bundle failed: ${stderr}`);
33177
- code = fs.readFileSync(tmpOut, "utf-8");
33189
+ const proc = Bun.spawn(["bun", "build", entrypoint, "--target", "bun", "--outfile", tmpOut], {
33190
+ stdout: "pipe",
33191
+ stderr: "pipe"
33192
+ });
33193
+ const exitCode = await proc.exited;
33194
+ const stderr = await new Response(proc.stderr).text();
33195
+ const fileHandle = Bun.file(tmpOut);
33196
+ if (exitCode !== 0 || !await fileHandle.exists()) {
33197
+ throw new Error(`Bundle failed: ${stderr || `exit code ${exitCode}`}`);
33198
+ }
33199
+ code = await fileHandle.text();
33178
33200
  } finally {
33179
33201
  try {
33180
33202
  fs.unlinkSync(tmpOut);
@@ -35610,7 +35632,7 @@ Actions: list_releases, get_release, upload_release, activate_release`, {
35610
35632
  // package.json
35611
35633
  var package_default = {
35612
35634
  name: "@supacloud/admin",
35613
- version: "0.24.1",
35635
+ version: "0.24.2",
35614
35636
  description: "Platform administration CLI for SupaCloud operators",
35615
35637
  type: "module",
35616
35638
  main: "./dist/index.js",
@@ -35643,13 +35665,16 @@ var package_default = {
35643
35665
  },
35644
35666
  dependencies: {
35645
35667
  typebox: "1.3.34",
35646
- "@supacloud/cli": "0.67.0",
35668
+ "@supacloud/cli": "0.68.1",
35647
35669
  ssh2: "^1.17.0"
35648
35670
  },
35649
35671
  devDependencies: {
35650
35672
  "@types/bun": "^1.4.2",
35651
35673
  "@types/ssh2": "^1.15.6",
35652
35674
  typescript: "^7.0.2"
35675
+ },
35676
+ overrides: {
35677
+ "@graphql-tools/utils": "^12.0.3"
35653
35678
  }
35654
35679
  };
35655
35680
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/admin",
3
- "version": "0.24.1",
3
+ "version": "0.24.2",
4
4
  "description": "Platform administration CLI for SupaCloud operators",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,12 +33,15 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "typebox": "1.3.34",
36
- "@supacloud/cli": "0.67.0",
36
+ "@supacloud/cli": "0.68.1",
37
37
  "ssh2": "^1.17.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/bun": "^1.4.2",
41
41
  "@types/ssh2": "^1.15.6",
42
42
  "typescript": "^7.0.2"
43
+ },
44
+ "overrides": {
45
+ "@graphql-tools/utils": "^12.0.3"
43
46
  }
44
47
  }