@astroscope/health 0.2.1 → 0.2.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.
package/README.md CHANGED
@@ -20,8 +20,6 @@ npm install @astroscope/health
20
20
 
21
21
  ### 1. Add both integrations to your Astro config
22
22
 
23
- **Important:** `health()` must come **after** `boot()` in the integrations array.
24
-
25
23
  ```ts
26
24
  // astro.config.ts
27
25
  import { defineConfig } from 'astro/config';
@@ -97,6 +95,7 @@ Host to bind the health server to. Defaults to `127.0.0.1` (localhost only). Set
97
95
 
98
96
  - **Type**: `string`
99
97
  - **Default**: `"127.0.0.1"`
98
+ - **Env**: `HEALTH_HOST`
100
99
 
101
100
  ### `port`
102
101
 
@@ -104,6 +103,7 @@ Port for the health server.
104
103
 
105
104
  - **Type**: `number`
106
105
  - **Default**: `9090`
106
+ - **Env**: `HEALTH_PORT`
107
107
 
108
108
  ### `paths`
109
109
 
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-VKEMDBBI.js";
4
4
 
5
5
  // src/index.ts
6
- import MagicString from "magic-string";
6
+ import { prepend } from "@astroscope/boot/prepend";
7
7
  import { checks, K8sPaths, SimplePaths } from "health-probes";
8
8
  function health(options = {}) {
9
9
  const enableDev = options.dev ?? false;
@@ -15,20 +15,14 @@ function health(options = {}) {
15
15
  return {
16
16
  name: "@astroscope/health",
17
17
  hooks: {
18
- "astro:config:setup": ({ config, command, updateConfig }) => {
19
- const bootIndex = config.integrations.findIndex((i) => i.name === "@astroscope/boot");
20
- const healthIndex = config.integrations.findIndex((i) => i.name === "@astroscope/health");
21
- if (bootIndex === -1) {
22
- throw new Error(
23
- "@astroscope/health requires @astroscope/boot. Add boot() before health() in your integrations array."
24
- );
18
+ "astro:config:setup": ({ config, updateConfig }) => {
19
+ if (!config.integrations.some((i) => i.name === "@astroscope/boot")) {
20
+ throw new Error("@astroscope/health requires @astroscope/boot. Add boot() to your integrations array.");
25
21
  }
26
- if (healthIndex !== -1 && bootIndex > healthIndex) {
27
- throw new Error(
28
- "@astroscope/health must come after @astroscope/boot. Swap the order in your integrations array."
29
- );
30
- }
31
- const isBuild = command === "build";
22
+ prepend(
23
+ `import { registerHealth as __astroscope_registerHealth } from '@astroscope/health/setup';
24
+ __astroscope_registerHealth(${JSON.stringify(serverOptions)});`
25
+ );
32
26
  updateConfig({
33
27
  vite: {
34
28
  plugins: [
@@ -37,21 +31,6 @@ function health(options = {}) {
37
31
  configureServer() {
38
32
  if (!enableDev) return;
39
33
  registerHealth(serverOptions);
40
- },
41
- generateBundle(_, bundle) {
42
- if (!isBuild) return;
43
- const entryChunk = bundle["entry.mjs"];
44
- if (!entryChunk || entryChunk.type !== "chunk") return;
45
- const s = new MagicString(entryChunk.code);
46
- s.prepend(
47
- `import { registerHealth as __astroscope_registerHealth } from '@astroscope/health/setup';
48
- __astroscope_registerHealth(${JSON.stringify(serverOptions)});
49
- `
50
- );
51
- entryChunk.code = s.toString();
52
- if (entryChunk.map) {
53
- entryChunk.map = s.generateMap({ hires: true });
54
- }
55
34
  }
56
35
  }
57
36
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astroscope/health",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Kubernetes-style health probes integration for Astro",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -51,8 +51,7 @@
51
51
  "lint:fix": "eslint 'src/**/*.ts' --fix"
52
52
  },
53
53
  "dependencies": {
54
- "health-probes": "^1.0.0",
55
- "magic-string": "^0.30.21"
54
+ "health-probes": "^1.1.0"
56
55
  },
57
56
  "devDependencies": {
58
57
  "@astroscope/boot": "workspace:*",
@@ -61,7 +60,7 @@
61
60
  "typescript": "^5.9.3"
62
61
  },
63
62
  "peerDependencies": {
64
- "@astroscope/boot": ">=0.3.2",
63
+ "@astroscope/boot": ">=0.3.3",
65
64
  "astro": "^5.0.0"
66
65
  }
67
66
  }