@dhruv2mars/offdex 0.0.2 → 0.0.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/bin/offdex-lib.js CHANGED
@@ -1,7 +1,12 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { dirname, join } from "node:path";
4
- import { readInstalledVersion, resolveInstalledBin, shouldInstallBinary } from "./install-lib.js";
4
+ import {
5
+ isWorkspaceCheckout,
6
+ readInstalledVersion,
7
+ resolveInstalledBin,
8
+ shouldInstallBinary
9
+ } from "./install-lib.js";
5
10
 
6
11
  export function resolvePackageBinDir(moduleUrl = import.meta.url) {
7
12
  return dirname(fileURLToPath(moduleUrl));
@@ -18,4 +23,16 @@ export function installedVersion(env = process.env) {
18
23
  return readInstalledVersion(env);
19
24
  }
20
25
 
26
+ export function resolveWorkspaceBridgeCli(moduleUrl = import.meta.url) {
27
+ const binDir = resolvePackageBinDir(moduleUrl);
28
+ const packageRoot = join(binDir, "..");
29
+ const workspaceRootPackageJson = join(packageRoot, "..", "..", "package.json");
30
+ if (!isWorkspaceCheckout(workspaceRootPackageJson)) {
31
+ return null;
32
+ }
33
+
34
+ const bridgeCli = join(packageRoot, "..", "bridge", "src", "cli.ts");
35
+ return existsSync(bridgeCli) ? bridgeCli : null;
36
+ }
37
+
21
38
  export { resolveInstalledBin, shouldInstallBinary };
package/bin/offdex.js CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  readPackageVersion,
9
9
  resolveInstalledBin,
10
10
  resolvePackageBinDir,
11
+ resolveWorkspaceBridgeCli,
11
12
  shouldInstallBinary
12
13
  } from "./offdex-lib.js";
13
14
 
@@ -15,6 +16,15 @@ const args = process.argv.slice(2);
15
16
  const installedBin = resolveInstalledBin(process.env, process.platform);
16
17
  const packageVersion = readPackageVersion();
17
18
  const currentInstalledVersion = installedVersion(process.env);
19
+ const workspaceBridgeCli = resolveWorkspaceBridgeCli();
20
+
21
+ if (workspaceBridgeCli && !existsSync(installedBin)) {
22
+ const result = spawnSync("bun", [workspaceBridgeCli, ...args], {
23
+ stdio: "inherit",
24
+ env: process.env
25
+ });
26
+ process.exit(result.status ?? 1);
27
+ }
18
28
 
19
29
  if (
20
30
  shouldInstallBinary({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhruv2mars/offdex",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Codex mobile bridge CLI for Offdex",
5
5
  "type": "module",
6
6
  "bin": {