@hasna/microservices 0.0.20 → 0.0.21

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/bin/index.js CHANGED
@@ -2383,6 +2383,8 @@ var {
2383
2383
 
2384
2384
  // src/lib/installer.ts
2385
2385
  import { execFileSync, execSync } from "child_process";
2386
+ import { accessSync, constants } from "fs";
2387
+ import { join } from "path";
2386
2388
 
2387
2389
  // src/lib/registry.ts
2388
2390
  var MICROSERVICES = [
@@ -2808,23 +2810,41 @@ function searchMicroservices(query) {
2808
2810
  }
2809
2811
 
2810
2812
  // src/lib/installer.ts
2811
- function microserviceExists(name) {
2813
+ function getBunGlobalBinDir(env2 = process.env) {
2814
+ const bunInstall = env2.BUN_INSTALL?.trim();
2815
+ if (bunInstall) {
2816
+ return join(bunInstall, "bin");
2817
+ }
2818
+ const home = env2.HOME?.trim();
2819
+ if (!home) {
2820
+ throw new Error("Unable to determine Bun global bin path: HOME is not set.");
2821
+ }
2822
+ return join(home, ".bun", "bin");
2823
+ }
2824
+ function resolveMicroserviceBinary(name) {
2812
2825
  const meta = getMicroservice(name);
2813
2826
  if (!meta)
2814
- return false;
2815
- try {
2816
- execSync(`which ${meta.binary}`, { stdio: "ignore" });
2817
- return true;
2818
- } catch {
2819
- return false;
2827
+ return null;
2828
+ const binDir = getBunGlobalBinDir();
2829
+ const accessMode = process.platform === "win32" ? constants.F_OK : constants.X_OK;
2830
+ const candidates = process.platform === "win32" ? [join(binDir, `${meta.binary}.cmd`), join(binDir, `${meta.binary}.exe`)] : [join(binDir, meta.binary)];
2831
+ for (const candidate of candidates) {
2832
+ try {
2833
+ accessSync(candidate, accessMode);
2834
+ return candidate;
2835
+ } catch {}
2820
2836
  }
2837
+ return null;
2838
+ }
2839
+ function microserviceExists(name) {
2840
+ return resolveMicroserviceBinary(name) !== null;
2821
2841
  }
2822
2842
  function getMicroserviceVersion(name) {
2823
- const meta = getMicroservice(name);
2824
- if (!meta)
2843
+ const binaryPath = resolveMicroserviceBinary(name);
2844
+ if (!binaryPath)
2825
2845
  return null;
2826
2846
  try {
2827
- const out = execFileSync(meta.binary, ["--version"], {
2847
+ const out = execFileSync(binaryPath, ["--version"], {
2828
2848
  encoding: "utf8"
2829
2849
  }).trim();
2830
2850
  return out || null;
@@ -2882,13 +2902,13 @@ function getMicroserviceStatus(name) {
2882
2902
 
2883
2903
  // src/lib/package-info.ts
2884
2904
  import { existsSync, readFileSync } from "fs";
2885
- import { dirname, join, resolve } from "path";
2905
+ import { dirname, join as join2, resolve } from "path";
2886
2906
  import { fileURLToPath } from "url";
2887
2907
  var DEFAULT_VERSION = "0.0.1";
2888
2908
  function findNearestPackageJson(startDir) {
2889
2909
  let dir = resolve(startDir);
2890
2910
  while (true) {
2891
- const candidate = join(dir, "package.json");
2911
+ const candidate = join2(dir, "package.json");
2892
2912
  if (existsSync(candidate)) {
2893
2913
  return candidate;
2894
2914
  }
@@ -2928,12 +2948,21 @@ async function runMicroserviceCommand(name, args, timeout = 30000) {
2928
2948
  return {
2929
2949
  success: false,
2930
2950
  stdout: "",
2931
- stderr: `microservice-${name} is not installed. Run: bun install -g ${meta.package}`,
2951
+ stderr: `${meta.binary} is not installed. Run: bun install -g ${meta.package}`,
2952
+ exitCode: 1
2953
+ };
2954
+ }
2955
+ const binaryPath = resolveMicroserviceBinary(name);
2956
+ if (!binaryPath) {
2957
+ return {
2958
+ success: false,
2959
+ stdout: "",
2960
+ stderr: `Could not resolve global binary for ${meta.binary}.`,
2932
2961
  exitCode: 1
2933
2962
  };
2934
2963
  }
2935
2964
  return new Promise((resolve2) => {
2936
- execFile(meta.binary, args, { timeout, maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {
2965
+ execFile(binaryPath, args, { timeout, maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {
2937
2966
  if (error && "killed" in error && error.killed) {
2938
2967
  resolve2({
2939
2968
  success: false,
package/bin/mcp.js CHANGED
@@ -19476,6 +19476,8 @@ class StdioServerTransport {
19476
19476
 
19477
19477
  // src/lib/installer.ts
19478
19478
  import { execFileSync, execSync } from "child_process";
19479
+ import { accessSync, constants } from "fs";
19480
+ import { join } from "path";
19479
19481
 
19480
19482
  // src/lib/registry.ts
19481
19483
  var MICROSERVICES = [
@@ -19901,23 +19903,41 @@ function searchMicroservices(query) {
19901
19903
  }
19902
19904
 
19903
19905
  // src/lib/installer.ts
19904
- function microserviceExists(name) {
19906
+ function getBunGlobalBinDir(env = process.env) {
19907
+ const bunInstall = env.BUN_INSTALL?.trim();
19908
+ if (bunInstall) {
19909
+ return join(bunInstall, "bin");
19910
+ }
19911
+ const home = env.HOME?.trim();
19912
+ if (!home) {
19913
+ throw new Error("Unable to determine Bun global bin path: HOME is not set.");
19914
+ }
19915
+ return join(home, ".bun", "bin");
19916
+ }
19917
+ function resolveMicroserviceBinary(name) {
19905
19918
  const meta = getMicroservice(name);
19906
19919
  if (!meta)
19907
- return false;
19908
- try {
19909
- execSync(`which ${meta.binary}`, { stdio: "ignore" });
19910
- return true;
19911
- } catch {
19912
- return false;
19920
+ return null;
19921
+ const binDir = getBunGlobalBinDir();
19922
+ const accessMode = process.platform === "win32" ? constants.F_OK : constants.X_OK;
19923
+ const candidates = process.platform === "win32" ? [join(binDir, `${meta.binary}.cmd`), join(binDir, `${meta.binary}.exe`)] : [join(binDir, meta.binary)];
19924
+ for (const candidate of candidates) {
19925
+ try {
19926
+ accessSync(candidate, accessMode);
19927
+ return candidate;
19928
+ } catch {}
19913
19929
  }
19930
+ return null;
19931
+ }
19932
+ function microserviceExists(name) {
19933
+ return resolveMicroserviceBinary(name) !== null;
19914
19934
  }
19915
19935
  function getMicroserviceVersion(name) {
19916
- const meta = getMicroservice(name);
19917
- if (!meta)
19936
+ const binaryPath = resolveMicroserviceBinary(name);
19937
+ if (!binaryPath)
19918
19938
  return null;
19919
19939
  try {
19920
- const out = execFileSync(meta.binary, ["--version"], {
19940
+ const out = execFileSync(binaryPath, ["--version"], {
19921
19941
  encoding: "utf8"
19922
19942
  }).trim();
19923
19943
  return out || null;
@@ -19972,13 +19992,13 @@ function getMicroserviceStatus(name) {
19972
19992
 
19973
19993
  // src/lib/package-info.ts
19974
19994
  import { existsSync, readFileSync } from "fs";
19975
- import { dirname, join, resolve } from "path";
19995
+ import { dirname, join as join2, resolve } from "path";
19976
19996
  import { fileURLToPath } from "url";
19977
19997
  var DEFAULT_VERSION = "0.0.1";
19978
19998
  function findNearestPackageJson(startDir) {
19979
19999
  let dir = resolve(startDir);
19980
20000
  while (true) {
19981
- const candidate = join(dir, "package.json");
20001
+ const candidate = join2(dir, "package.json");
19982
20002
  if (existsSync(candidate)) {
19983
20003
  return candidate;
19984
20004
  }
@@ -20018,12 +20038,21 @@ async function runMicroserviceCommand(name, args, timeout = 30000) {
20018
20038
  return {
20019
20039
  success: false,
20020
20040
  stdout: "",
20021
- stderr: `microservice-${name} is not installed. Run: bun install -g ${meta.package}`,
20041
+ stderr: `${meta.binary} is not installed. Run: bun install -g ${meta.package}`,
20042
+ exitCode: 1
20043
+ };
20044
+ }
20045
+ const binaryPath = resolveMicroserviceBinary(name);
20046
+ if (!binaryPath) {
20047
+ return {
20048
+ success: false,
20049
+ stdout: "",
20050
+ stderr: `Could not resolve global binary for ${meta.binary}.`,
20022
20051
  exitCode: 1
20023
20052
  };
20024
20053
  }
20025
20054
  return new Promise((resolve2) => {
20026
- execFile(meta.binary, args, { timeout, maxBuffer: 10 * 1024 * 1024 }, (error2, stdout, stderr) => {
20055
+ execFile(binaryPath, args, { timeout, maxBuffer: 10 * 1024 * 1024 }, (error2, stdout, stderr) => {
20027
20056
  if (error2 && "killed" in error2 && error2.killed) {
20028
20057
  resolve2({
20029
20058
  success: false,
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  // @bun
2
2
  // src/lib/installer.ts
3
3
  import { execFileSync, execSync } from "child_process";
4
+ import { accessSync, constants } from "fs";
5
+ import { join } from "path";
4
6
 
5
7
  // src/lib/registry.ts
6
8
  var CATEGORIES = [
@@ -440,23 +442,41 @@ function searchMicroservices(query) {
440
442
  }
441
443
 
442
444
  // src/lib/installer.ts
443
- function microserviceExists(name) {
445
+ function getBunGlobalBinDir(env = process.env) {
446
+ const bunInstall = env.BUN_INSTALL?.trim();
447
+ if (bunInstall) {
448
+ return join(bunInstall, "bin");
449
+ }
450
+ const home = env.HOME?.trim();
451
+ if (!home) {
452
+ throw new Error("Unable to determine Bun global bin path: HOME is not set.");
453
+ }
454
+ return join(home, ".bun", "bin");
455
+ }
456
+ function resolveMicroserviceBinary(name) {
444
457
  const meta = getMicroservice(name);
445
458
  if (!meta)
446
- return false;
447
- try {
448
- execSync(`which ${meta.binary}`, { stdio: "ignore" });
449
- return true;
450
- } catch {
451
- return false;
459
+ return null;
460
+ const binDir = getBunGlobalBinDir();
461
+ const accessMode = process.platform === "win32" ? constants.F_OK : constants.X_OK;
462
+ const candidates = process.platform === "win32" ? [join(binDir, `${meta.binary}.cmd`), join(binDir, `${meta.binary}.exe`)] : [join(binDir, meta.binary)];
463
+ for (const candidate of candidates) {
464
+ try {
465
+ accessSync(candidate, accessMode);
466
+ return candidate;
467
+ } catch {}
452
468
  }
469
+ return null;
470
+ }
471
+ function microserviceExists(name) {
472
+ return resolveMicroserviceBinary(name) !== null;
453
473
  }
454
474
  function getMicroserviceVersion(name) {
455
- const meta = getMicroservice(name);
456
- if (!meta)
475
+ const binaryPath = resolveMicroserviceBinary(name);
476
+ if (!binaryPath)
457
477
  return null;
458
478
  try {
459
- const out = execFileSync(meta.binary, ["--version"], {
479
+ const out = execFileSync(binaryPath, ["--version"], {
460
480
  encoding: "utf8"
461
481
  }).trim();
462
482
  return out || null;
@@ -530,12 +550,21 @@ async function runMicroserviceCommand(name, args, timeout = 30000) {
530
550
  return {
531
551
  success: false,
532
552
  stdout: "",
533
- stderr: `microservice-${name} is not installed. Run: bun install -g ${meta.package}`,
553
+ stderr: `${meta.binary} is not installed. Run: bun install -g ${meta.package}`,
554
+ exitCode: 1
555
+ };
556
+ }
557
+ const binaryPath = resolveMicroserviceBinary(name);
558
+ if (!binaryPath) {
559
+ return {
560
+ success: false,
561
+ stdout: "",
562
+ stderr: `Could not resolve global binary for ${meta.binary}.`,
534
563
  exitCode: 1
535
564
  };
536
565
  }
537
566
  return new Promise((resolve) => {
538
- execFile(meta.binary, args, { timeout, maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {
567
+ execFile(binaryPath, args, { timeout, maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {
539
568
  if (error && "killed" in error && error.killed) {
540
569
  resolve({
541
570
  success: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/microservices",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "21 production-grade microservice building blocks for AI-native SaaS — auth, billing, LLM gateway, agent registry, RAG, guardrails, tracing, and more. Each with PostgreSQL, HTTP API, MCP server, and CLI.",
5
5
  "type": "module",
6
6
  "bin": {