[skip ci] some tooling work

This commit is contained in:
Brahim Hadriche committed 2026-06-17 10:47:50 -04:00
1 parent cdee8a713b
commit 2830311aa8
4 files changed
+34 -4

No files matched your search

+22 -2
View File
@@ -6,6 +6,10 @@
// - DEBUG_HOST_IP_ADDRESS would be replaced with the host IP address in the manifest file
// - This is to playlet app to pull playlet lib from the locally hosted server
// - This is only done when --debug is set
// - PLAYLET_DEVTOOLS (env) instead points playlet_lib_zip_debug_url at the dev-tools service:
// the freshly-built lib zip is registered with it and its URL baked in, so rebuilding the lib
// and relaunching hot-reloads it with no app redeploy. Opt-in; only the app manifest has the
// key, so the lib build and every normal build keep the :8086 host the VSCode launch serves.
import {
BeforeProgramDisposeEvent,
@@ -15,6 +19,7 @@ import {
} from 'brighterscript';
import path from 'path';
import fs from 'fs';
import { execFileSync } from 'child_process';
import { exitOnCriticalErrors } from './critical-exit';
const ip = require('ip');
@@ -36,8 +41,23 @@ export class ManifestEditPlugin implements CompilerPlugin {
manifestContent = manifestContent.replace(/DEBUG=(true|false)/i, `DEBUG=${debug}`);
if (debug) {
// Host IP address
manifestContent = manifestContent.replace(/DEBUG_HOST_IP_ADDRESS/i, `${ip.address()}`)
// dev-tools service hosts the lib (opt-in via PLAYLET_DEVTOOLS); the key lives only in
// the app manifest, so the lib build and normal builds fall through to the :8086 host.
if (process.env.PLAYLET_DEVTOOLS && /playlet_lib_zip_debug_url=/.test(manifestContent)) {
const serveScript = path.resolve(builder.options.rootDir!, '../../../../dev-tools/bin/serve.sh')
const libZip = path.resolve(builder.options.rootDir!, '../../dist/playlet-lib.zip')
let url: string
try {
url = execFileSync(serveScript, ['add', libZip], { encoding: 'utf8' }).trim()
} catch (err: any) {
throw new Error(`Could not host ${libZip} via the dev-tools service (is it running? cd dev-tools && npm start): ${err?.message ?? err}`)
}
builder.logger.log(`Hosting playlet-lib.zip via dev-tools service: ${url}`)
manifestContent = manifestContent.replace(/playlet_lib_zip_debug_url=.*/i, `playlet_lib_zip_debug_url=${url}`)
} else {
// Host IP address
manifestContent = manifestContent.replace(/DEBUG_HOST_IP_ADDRESS/i, `${ip.address()}`)
}
}
// Test flag