@phreshos/cli 0.1.64 → 0.1.65

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.
@@ -30,3 +30,12 @@ export async function waitForGateway(path, running, timeout = 15_000) {
30
30
  }
31
31
  throw new Error(`The PhreshOS System did not become ready within ${Math.ceil(timeout / 1000)} seconds`);
32
32
  }
33
+ export async function waitForGatewayClose(path, timeout = 15_000) {
34
+ const until = Date.now() + timeout;
35
+ while (Date.now() < until) {
36
+ if (!await gatewayReady(path))
37
+ return;
38
+ await new Promise(resolve => setTimeout(resolve, 100));
39
+ }
40
+ throw new Error(`The PhreshOS System gateway did not close within ${Math.ceil(timeout / 1000)} seconds`);
41
+ }
@@ -1,6 +1,6 @@
1
1
  import SystemInstallation from "./installation.js";
2
2
  import { downloadSystemRelease, resolveSystemRelease } from "./release.js";
3
- import { gatewayReady, waitForGateway } from "./gateway-readiness.js";
3
+ import { gatewayReady, waitForGateway, waitForGatewayClose } from "./gateway-readiness.js";
4
4
  import systemPaths from "./paths.js";
5
5
  import systemService from "./service/index.js";
6
6
  import nodeExecutable from "./node.js";
@@ -21,6 +21,7 @@ export default class SystemLifecycle {
21
21
  downloadRelease: dependencies?.downloadRelease ?? downloadSystemRelease,
22
22
  ready: dependencies?.ready ?? gatewayReady,
23
23
  wait: dependencies?.wait ?? waitForGateway,
24
+ waitForStop: dependencies?.waitForStop ?? waitForGatewayClose,
24
25
  provisionSetup: dependencies?.provisionSetup ?? provisionSetup
25
26
  };
26
27
  }
@@ -45,7 +46,7 @@ export default class SystemLifecycle {
45
46
  await activation.commit();
46
47
  }
47
48
  catch (error) {
48
- await service.stop().catch(() => undefined);
49
+ await this.stopService().catch(() => undefined);
49
50
  await activation.rollback();
50
51
  return await this.restoredFailure(error, previous, previousService);
51
52
  }
@@ -69,7 +70,7 @@ export default class SystemLifecycle {
69
70
  const { installation, service } = this.dependencies;
70
71
  const state = await service.inspect();
71
72
  if (state.running)
72
- await service.stop();
73
+ await this.stopService();
73
74
  if (state.enabled)
74
75
  await service.disable();
75
76
  if (state.registered)
@@ -92,7 +93,7 @@ export default class SystemLifecycle {
92
93
  }
93
94
  async stopExclusive() {
94
95
  await this.requireInstalledService();
95
- await this.dependencies.service.stop();
96
+ await this.stopService();
96
97
  return await this.status();
97
98
  }
98
99
  async enable() {
@@ -148,10 +149,10 @@ export default class SystemLifecycle {
148
149
  }
149
150
  }
150
151
  async activate(prepared, previous, state, purge) {
151
- const { installation, service } = this.dependencies;
152
+ const { installation } = this.dependencies;
152
153
  try {
153
154
  if (state.running)
154
- await service.stop();
155
+ await this.stopService();
155
156
  if (purge)
156
157
  await installation.purgeStorage();
157
158
  return await installation.activate(prepared, previous);
@@ -205,6 +206,11 @@ export default class SystemLifecycle {
205
206
  throw error;
206
207
  }
207
208
  }
209
+ async stopService() {
210
+ const { installation, service } = this.dependencies;
211
+ await service.stop();
212
+ await this.dependencies.waitForStop(installation.paths.gateway);
213
+ }
208
214
  }
209
215
  async function provisionSetup() {
210
216
  await installProgram({ name: "setup", announce: false });
@@ -22,7 +22,7 @@
22
22
  "react-dom": "^19.2.8"
23
23
  },
24
24
  "devDependencies": {
25
- "@phreshos/cli": "^0.1.64",
25
+ "@phreshos/cli": "^0.1.65",
26
26
  "@types/node": "^26.4.0",
27
27
  "@types/react": "^19.2.18",
28
28
  "@types/react-dom": "^19.2.5",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@phreshos/cli",
3
3
  "type": "module",
4
- "version": "0.1.64",
4
+ "version": "0.1.65",
5
5
  "description": "The Phresh command-line interface for Program projects and system management.",
6
6
  "engines": {
7
7
  "node": ">=20.10"