@sprintdock/backend 0.4.2 → 0.4.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @sprintdock/backend
2
2
 
3
+ ## 0.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: health version reader
8
+
3
9
  ## 0.4.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1606,12 +1606,23 @@ var TaskController = class {
1606
1606
  };
1607
1607
 
1608
1608
  // src/http/controllers/health.controller.ts
1609
- import { readFileSync } from "fs";
1609
+ import { existsSync, readFileSync } from "fs";
1610
+ import { dirname, join } from "path";
1611
+ import { fileURLToPath } from "url";
1610
1612
  function readPackageVersion() {
1611
- const path = new URL("../../../package.json", import.meta.url);
1612
- const raw = readFileSync(path, "utf8");
1613
- const pkg = JSON.parse(raw);
1614
- return pkg.version ?? "0.0.0";
1613
+ let currentDir = dirname(fileURLToPath(import.meta.url));
1614
+ for (let i = 0; i < 8; i += 1) {
1615
+ const candidatePath = join(currentDir, "package.json");
1616
+ if (existsSync(candidatePath)) {
1617
+ const raw = readFileSync(candidatePath, "utf8");
1618
+ const pkg = JSON.parse(raw);
1619
+ return pkg.version ?? "0.0.0";
1620
+ }
1621
+ const parentDir = dirname(currentDir);
1622
+ if (parentDir === currentDir) break;
1623
+ currentDir = parentDir;
1624
+ }
1625
+ return "0.0.0";
1615
1626
  }
1616
1627
  var HealthController = class {
1617
1628
  version = readPackageVersion();
@@ -2081,7 +2092,7 @@ var InMemoryBackendRateLimiter = class {
2081
2092
 
2082
2093
  // src/mcp/bootstrap-sprintdock-sqlite.ts
2083
2094
  import { mkdirSync } from "fs";
2084
- import { dirname as dirname2, isAbsolute, join as join2 } from "path";
2095
+ import { dirname as dirname3, isAbsolute, join as join3 } from "path";
2085
2096
  import {
2086
2097
  ensureSprintdockDirectory,
2087
2098
  resolveSprintdockDbPath,
@@ -2142,18 +2153,18 @@ function createSqliteConnection(dbPath) {
2142
2153
  }
2143
2154
 
2144
2155
  // src/db/migrator.ts
2145
- import { existsSync } from "fs";
2156
+ import { existsSync as existsSync2 } from "fs";
2146
2157
  import { migrate } from "drizzle-orm/better-sqlite3/migrator";
2147
- import { dirname, join } from "path";
2148
- import { fileURLToPath } from "url";
2158
+ import { dirname as dirname2, join as join2 } from "path";
2159
+ import { fileURLToPath as fileURLToPath2 } from "url";
2149
2160
  function resolveMigrationsFolder() {
2150
- let dir = dirname(fileURLToPath(import.meta.url));
2161
+ let dir = dirname2(fileURLToPath2(import.meta.url));
2151
2162
  for (let i = 0; i < 8; i++) {
2152
- const candidate = join(dir, "drizzle");
2153
- if (existsSync(join(candidate, "meta", "_journal.json"))) {
2163
+ const candidate = join2(dir, "drizzle");
2164
+ if (existsSync2(join2(candidate, "meta", "_journal.json"))) {
2154
2165
  return candidate;
2155
2166
  }
2156
- const parent = dirname(dir);
2167
+ const parent = dirname2(dir);
2157
2168
  if (parent === dir) {
2158
2169
  break;
2159
2170
  }
@@ -2173,8 +2184,8 @@ async function bootstrapSprintdockSqlite() {
2173
2184
  const workspaceRoot = resolveWorkspaceRoot();
2174
2185
  await ensureSprintdockDirectory({ workspaceRoot });
2175
2186
  const envPath = process.env.SPRINTDOCK_DB_PATH?.trim();
2176
- const dbPath = envPath && envPath.length > 0 ? isAbsolute(envPath) ? envPath : join2(workspaceRoot, envPath) : resolveSprintdockDbPath({ workspaceRoot });
2177
- mkdirSync(dirname2(dbPath), { recursive: true });
2187
+ const dbPath = envPath && envPath.length > 0 ? isAbsolute(envPath) ? envPath : join3(workspaceRoot, envPath) : resolveSprintdockDbPath({ workspaceRoot });
2188
+ mkdirSync(dirname3(dbPath), { recursive: true });
2178
2189
  const db = createSqliteConnection(dbPath);
2179
2190
  runMigrations(db);
2180
2191
  const repos = createRepositories("sqlite", { sqlite: { db } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprintdock/backend",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -13,12 +13,12 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@modelcontextprotocol/sdk": "^1.27.1",
16
+ "@sprintdock/env-manager": "0.2.2",
17
+ "@sprintdock/shared": "0.2.2",
16
18
  "better-sqlite3": "^12.8.0",
17
19
  "drizzle-orm": "^0.38.4",
18
20
  "express": "^5.1.0",
19
- "zod": "^4.1.11",
20
- "@sprintdock/env-manager": "0.2.2",
21
- "@sprintdock/shared": "0.2.2"
21
+ "zod": "^4.1.11"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/better-sqlite3": "^7.6.13",
@@ -3,14 +3,31 @@
3
3
  * author: vikash sharma
4
4
  * description: Lightweight health probe for load balancers and smoke tests.
5
5
  */
6
- import { readFileSync } from "node:fs";
6
+ import { existsSync, readFileSync } from "node:fs";
7
+ import { dirname, join } from "node:path";
7
8
  import type { NextFunction, Request, Response } from "express";
9
+ import { fileURLToPath } from "node:url";
8
10
 
9
11
  function readPackageVersion(): string {
10
- const path = new URL("../../../package.json", import.meta.url);
11
- const raw = readFileSync(path, "utf8");
12
- const pkg = JSON.parse(raw) as { version?: string };
13
- return pkg.version ?? "0.0.0";
12
+ // The backend is bundled into `dist/index.js`, so relative paths like
13
+ // "../../../package.json" can resolve incorrectly depending on install layout.
14
+ // Instead, walk up directories until we find the nearest package.json.
15
+ let currentDir = dirname(fileURLToPath(import.meta.url));
16
+
17
+ for (let i = 0; i < 8; i += 1) {
18
+ const candidatePath = join(currentDir, "package.json");
19
+ if (existsSync(candidatePath)) {
20
+ const raw = readFileSync(candidatePath, "utf8");
21
+ const pkg = JSON.parse(raw) as { version?: string };
22
+ return pkg.version ?? "0.0.0";
23
+ }
24
+
25
+ const parentDir = dirname(currentDir);
26
+ if (parentDir === currentDir) break;
27
+ currentDir = parentDir;
28
+ }
29
+
30
+ return "0.0.0";
14
31
  }
15
32
 
16
33
  /**
@@ -33,6 +33,7 @@ test("GET /api/v1/health returns ok, version, timestamp and X-Request-Id", async
33
33
  const res = await request(app).get(`${v1}/health`).expect(200);
34
34
  assert.equal(res.body.status, "ok");
35
35
  assert.ok(typeof res.body.version === "string");
36
+ assert.notEqual(res.body.version, "0.0.0");
36
37
  assert.ok(typeof res.body.timestamp === "string");
37
38
  assert.ok(res.headers["x-request-id"]);
38
39
  });