@pmate/cli 0.46.0 → 0.46.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 +14 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8886,6 +8886,17 @@ var PackageInstaller = class {
8886
8886
  const cwd = step.cwd ? this.local(root, step.cwd) : root;
8887
8887
  return this.execute(step.command, step.args, cwd);
8888
8888
  }
8889
+ async healthy(root, step) {
8890
+ for (let attempt = 0; attempt < 15; attempt++) {
8891
+ try {
8892
+ const result = JSON.parse(await this.step(root, step));
8893
+ if (result.healthy === true) return;
8894
+ } catch {
8895
+ }
8896
+ if (attempt < 14) await (this.ports.wait ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(2e3);
8897
+ }
8898
+ throw Error("Package did not become healthy after startup");
8899
+ }
8889
8900
  async metadata(name) {
8890
8901
  const ref = packageRef(name), url = this.ports.registryUrl ?? "https://apps-api.pmate.chat";
8891
8902
  const response = await (this.ports.fetch ?? fetch)(url + "/packages/" + ref.namespace + "/" + ref.name, { signal: AbortSignal.timeout(15e3), headers: { "cache-control": "no-cache" }, redirect: "error" });
@@ -8990,8 +9001,7 @@ var PackageInstaller = class {
8990
9001
  const commit = await this.execute("git", ["rev-parse", "HEAD"], root);
8991
9002
  if (wasRunning && metadata.lifecycle) {
8992
9003
  await this.step(root, metadata.lifecycle.start);
8993
- const health = JSON.parse(await this.step(root, metadata.lifecycle.health));
8994
- if (health.healthy !== true) throw Error("Updated package failed its health check");
9004
+ await this.healthy(root, metadata.lifecycle.health);
8995
9005
  }
8996
9006
  for (const [name, target] of Object.entries(bins)) {
8997
9007
  const link = import_node_path.default.join(this.binDirectory, name), temporary = link + ".install-" + process.pid;
@@ -9010,8 +9020,7 @@ var PackageInstaller = class {
9010
9020
  await this.execute("git", ["checkout", "--detach", previousCommit], root);
9011
9021
  for (const step of old.definition.prepare) await this.step(root, step);
9012
9022
  await this.step(root, old.definition.lifecycle.start);
9013
- const health = JSON.parse(await this.step(root, old.definition.lifecycle.health));
9014
- if (health.healthy !== true) throw Error("Previous package health check failed");
9023
+ await this.healthy(root, old.definition.lifecycle.health);
9015
9024
  this.say("Upgrade failed; restored the previously installed package " + old.version);
9016
9025
  } catch {
9017
9026
  this.say("Upgrade failed and automatic recovery could not complete. Previous commit: " + previousCommit + ". Credentials, data and the installation record were preserved.");
@@ -21641,7 +21650,7 @@ function remoteGitAuthorization(command, token) {
21641
21650
  if (!token) return command;
21642
21651
  const header = "AUTHORIZATION: basic " + Buffer.from("x-access-token:" + token).toString("base64");
21643
21652
  const values = { GIT_CONFIG_COUNT: "3", GIT_CONFIG_KEY_0: "url.https://github.com/.insteadOf", GIT_CONFIG_VALUE_0: "git@github.com:", GIT_CONFIG_KEY_1: "url.https://github.com/.insteadOf", GIT_CONFIG_VALUE_1: "git@ramroll:", GIT_CONFIG_KEY_2: "http.https://github.com/.extraHeader", GIT_CONFIG_VALUE_2: header };
21644
- return Object.entries(values).map(([key, value]) => "export " + key + "=" + shellQuote2(value)).join("\n") + "\n" + command;
21653
+ return "git() { " + Object.entries(values).map(([key, value]) => key + "=" + shellQuote2(value)).join(" ") + ' command git "$@"; }\n' + command;
21645
21654
  }
21646
21655
 
21647
21656
  // src/commands/ServiceCommandHandler.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.46.0",
3
+ "version": "0.46.2",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {