@orbit-work/oem-dev-host 0.1.1 → 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 +1 -1
- package/src/cli.mjs +18 -3
- package/src/compiler.mjs +11 -1
- package/src/server.mjs +4 -0
package/package.json
CHANGED
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 =
|
|
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/compiler.mjs
CHANGED
|
@@ -132,6 +132,16 @@ export async function compileOemDevelopmentProject(projectRoot, { expectedIdenti
|
|
|
132
132
|
)
|
|
133
133
|
const logoFile = path.resolve(root, audit.manifest.assets.logo)
|
|
134
134
|
const logo = dataUrl(logoFile, await readFile(logoFile))
|
|
135
|
+
// Native-brand surfaces (Dock, window icon, tray) read the live snapshot too:
|
|
136
|
+
// the compiled dev host has no embedded manifest, so these travel alongside
|
|
137
|
+
// the renderer logo as data URLs.
|
|
138
|
+
const appIconFile = path.resolve(root, audit.manifest.assets.appIcon)
|
|
139
|
+
const appIcon = dataUrl(appIconFile, await readFile(appIconFile))
|
|
140
|
+
let tray = null
|
|
141
|
+
if (audit.manifest.assets.tray) {
|
|
142
|
+
const trayFile = path.resolve(root, audit.manifest.assets.tray)
|
|
143
|
+
tray = dataUrl(trayFile, await readFile(trayFile))
|
|
144
|
+
}
|
|
135
145
|
let javascript = ""
|
|
136
146
|
let css = ""
|
|
137
147
|
if (audit.manifest.entry) {
|
|
@@ -164,7 +174,7 @@ export async function compileOemDevelopmentProject(projectRoot, { expectedIdenti
|
|
|
164
174
|
}
|
|
165
175
|
return {
|
|
166
176
|
identity,
|
|
167
|
-
snapshot: { manifest: audit.manifest, locales, logo, development },
|
|
177
|
+
snapshot: { manifest: audit.manifest, locales, logo, appIcon, tray, development },
|
|
168
178
|
javascript,
|
|
169
179
|
css,
|
|
170
180
|
}
|
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()
|