@orbit-work/oem-dev-host 0.1.2 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbit-work/oem-dev-host",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Live OEM bridge for full Desktop, isolated-profile sandbox, and Slot workbench modes.",
5
5
  "type": "module",
6
6
  "publishConfig": {
package/src/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { realpathSync } from "node:fs"
4
- import { access } from "node:fs/promises"
3
+ import { realpathSync, statSync } from "node:fs"
4
+ import { access, readFile } from "node:fs/promises"
5
5
  import path from "node:path"
6
6
  import { fileURLToPath } from "node:url"
7
7
  import { startDevelopmentServer } from "./server.mjs"
@@ -27,6 +27,21 @@ export function parseArgs(argv, env = process.env) {
27
27
  return result
28
28
  }
29
29
 
30
+ /**
31
+ * Accept a bare macOS .app bundle: spawn needs the executable inside it, so
32
+ * resolve Contents/MacOS/<CFBundleExecutable> from the bundle's Info.plist.
33
+ */
34
+ async function resolveHostExecutable(hostPath) {
35
+ const resolved = path.resolve(hostPath)
36
+ if (!resolved.endsWith(".app") || !statSync(resolved, { throwIfNoEntry: false })?.isDirectory()) {
37
+ return resolved
38
+ }
39
+ const plist = await readFile(path.join(resolved, "Contents", "Info.plist"), "utf8").catch(() => "")
40
+ const executable = /<key>CFBundleExecutable<\/key>\s*<string>([^<]+)<\/string>/.exec(plist)?.[1]
41
+ if (!executable) throw new Error(`could not read CFBundleExecutable from ${resolved}/Contents/Info.plist`)
42
+ return path.join(resolved, "Contents", "MacOS", executable)
43
+ }
44
+
30
45
  export async function main(argv = process.argv.slice(2)) {
31
46
  const args = parseArgs(argv)
32
47
  if (args.help) {
@@ -41,7 +56,7 @@ export async function main(argv = process.argv.slice(2)) {
41
56
  if (!args.host) {
42
57
  throw new Error("Install the compiled Orbitwork OEM Dev Host, then set ORBIT_OEM_DEV_HOST_EXECUTABLE or pass --host")
43
58
  }
44
- const executable = path.resolve(args.host)
59
+ const executable = await resolveHostExecutable(args.host)
45
60
  await access(executable)
46
61
  const server = await startDevelopmentServer(path.resolve(args.project), { launch: executable, mode: args.mode })
47
62
  console.log(
package/src/server.mjs CHANGED
@@ -158,6 +158,10 @@ export async function startDevelopmentServer(
158
158
  }),
159
159
  })
160
160
  : null
161
+ child?.once("error", (error) => {
162
+ console.error(`[oem-dev-host] failed to launch ${launch}: ${error.message}`)
163
+ void close().finally(() => process.exit(1))
164
+ })
161
165
  const close = async () => {
162
166
  clearTimeout(timer)
163
167
  watcher.close()