locus-product-planning 1.2.2 → 1.2.4

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/dist/index.cjs CHANGED
@@ -12477,46 +12477,92 @@ var import_fs = require("fs");
12477
12477
  var import_path = require("path");
12478
12478
  var import_url = require("url");
12479
12479
  var import_meta = {};
12480
+ var _cachedDirname = null;
12481
+ function safeString(value) {
12482
+ if (typeof value === "string" && value.length > 0) {
12483
+ return value;
12484
+ }
12485
+ return null;
12486
+ }
12480
12487
  function getCurrentDirname() {
12488
+ if (typeof _cachedDirname === "string" && _cachedDirname.length > 0) {
12489
+ return _cachedDirname;
12490
+ }
12481
12491
  try {
12482
12492
  const meta = import_meta;
12483
- if (meta?.url && typeof meta.url === "string" && meta.url.startsWith("file:")) {
12484
- const result = (0, import_path.dirname)((0, import_url.fileURLToPath)(meta.url));
12485
- if (typeof result === "string" && result.length > 0) {
12493
+ const url2 = safeString(meta?.url);
12494
+ if (url2 && url2.startsWith("file:")) {
12495
+ const result = safeString((0, import_path.dirname)((0, import_url.fileURLToPath)(url2)));
12496
+ if (result) {
12497
+ _cachedDirname = result;
12486
12498
  return result;
12487
12499
  }
12488
12500
  }
12489
12501
  } catch {
12490
12502
  }
12491
12503
  try {
12492
- const packageJsonPath = require.resolve("locus-product-planning/package.json");
12493
- if (typeof packageJsonPath === "string") {
12494
- return (0, import_path.join)((0, import_path.dirname)(packageJsonPath), "dist");
12504
+ const globalDirname = safeString(globalThis.__dirname);
12505
+ if (globalDirname) {
12506
+ _cachedDirname = globalDirname;
12507
+ return globalDirname;
12495
12508
  }
12496
12509
  } catch {
12497
12510
  }
12498
- const cacheLocations = [
12499
- (0, import_path.join)(process.env.HOME || "", ".cache", "opencode", "node_modules", "locus-product-planning"),
12500
- (0, import_path.join)(process.env.HOME || "", ".config", "opencode", "node_modules", "locus-product-planning")
12501
- ];
12502
- for (const loc of cacheLocations) {
12503
- const distPath = (0, import_path.join)(loc, "dist");
12504
- if ((0, import_fs.existsSync)(distPath)) {
12505
- return distPath;
12506
- }
12507
- }
12508
- const cwd = process.cwd();
12509
12511
  try {
12510
- const pkgPath = (0, import_path.resolve)(cwd, "package.json");
12511
- if ((0, import_fs.existsSync)(pkgPath)) {
12512
- const pkg = JSON.parse((0, import_fs.readFileSync)(pkgPath, "utf-8"));
12513
- if (pkg.name === "locus-product-planning") {
12514
- return (0, import_path.resolve)(cwd, "dist");
12512
+ const packageJsonPath = safeString(require.resolve("locus-product-planning/package.json"));
12513
+ if (packageJsonPath) {
12514
+ const result = safeString((0, import_path.join)((0, import_path.dirname)(packageJsonPath), "dist"));
12515
+ if (result) {
12516
+ _cachedDirname = result;
12517
+ return result;
12515
12518
  }
12516
12519
  }
12517
12520
  } catch {
12518
12521
  }
12519
- return (0, import_path.resolve)(cwd, "dist");
12522
+ const homeDir = safeString(process.env.USERPROFILE) || safeString(process.env.HOME);
12523
+ if (homeDir) {
12524
+ const cacheLocations = [
12525
+ (0, import_path.join)(homeDir, ".cache", "opencode", "node_modules", "locus-product-planning", "dist"),
12526
+ (0, import_path.join)(homeDir, ".config", "opencode", "node_modules", "locus-product-planning", "dist")
12527
+ ];
12528
+ for (const loc of cacheLocations) {
12529
+ try {
12530
+ if ((0, import_fs.existsSync)(loc)) {
12531
+ const result = safeString(loc);
12532
+ if (result) {
12533
+ _cachedDirname = result;
12534
+ return result;
12535
+ }
12536
+ }
12537
+ } catch {
12538
+ }
12539
+ }
12540
+ }
12541
+ const cwd = safeString(process.cwd());
12542
+ if (cwd) {
12543
+ try {
12544
+ const pkgPath = (0, import_path.resolve)(cwd, "package.json");
12545
+ if ((0, import_fs.existsSync)(pkgPath)) {
12546
+ const pkg = JSON.parse((0, import_fs.readFileSync)(pkgPath, "utf-8"));
12547
+ if (pkg.name === "locus-product-planning") {
12548
+ const result = safeString((0, import_path.resolve)(cwd, "dist"));
12549
+ if (result) {
12550
+ _cachedDirname = result;
12551
+ return result;
12552
+ }
12553
+ }
12554
+ }
12555
+ } catch {
12556
+ }
12557
+ const fallback = safeString((0, import_path.resolve)(cwd, "dist"));
12558
+ if (fallback) {
12559
+ _cachedDirname = fallback;
12560
+ return fallback;
12561
+ }
12562
+ }
12563
+ const absoluteFallback = "/tmp/locus-product-planning/dist";
12564
+ _cachedDirname = absoluteFallback;
12565
+ return absoluteFallback;
12520
12566
  }
12521
12567
  var currentDirname = getCurrentDirname();
12522
12568
  function getPackageRoot() {