diff --git a/package.json b/package.json index 4957827a..6f335e63 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "dev:web": "cd playlet-web && npm run dev", "prebuild": "node tools/rm.js dist", "build:dev": "npm run prebuild && npm run build:web && npm run build:lib:dev && npm run build:app:dev", + "build:dev:v2": "PLAYLET_DEVTOOLS=1 npm run build:dev", "build:prod": "npm run prebuild && npm run build:web && npm run build:lib:prod && npm run build:app:prod", "build:release": "npm run prebuild && npm run format:fix && npm run lint:fix && npm run version-sync && npm run manifest-git-hash && npm run build:prod", "build:app:dev": "cd playlet-app && npm run build:dev", @@ -55,6 +56,9 @@ "format": "cd playlet-lib && npm run format && cd ../playlet-app && npm run format", "format:fix": "cd playlet-lib && npm run format:fix && cd ../playlet-app && npm run format:fix", "test": "npm run test:lib && npm run test:app", + "test:v2": "npm run test:v2:lib && npm run test:v2:app", + "test:v2:lib": "cd playlet-lib && npm run test:v2", + "test:v2:app": "cd playlet-app && npm run test:v2", "test:build": "npm run test:build:lib && npm run test:build:app", "test:app": "cd playlet-app && npm run test", "test:build:app": "cd playlet-app && npm run test:build", diff --git a/playlet-app/package.json b/playlet-app/package.json index 3c7726db..b6f7245c 100644 --- a/playlet-app/package.json +++ b/playlet-app/package.json @@ -18,6 +18,9 @@ "format:fix": "npm run format:base -- --write", "test": "npm run test:build && npm run test:run", "test:build": "bsc --project bsconfig.tests.json --create-package --sourceMap=true --debug --test-mode --lintConfig ../config/bslint.jsonc", - "test:run": "node ../tools/run-test-app.js --package ../build/playlet-app-tests.zip" + "test:run": "node ../tools/run-test-app.js --package ../build/playlet-app-tests.zip", + "test:v2": "npm run test:build && npm run test:run:v2", + "pretest:run:v2": "../../../dev-tools/bin/ensure-service.sh", + "test:run:v2": "../../../dev-tools/bin/test-app.sh --package ../build/playlet-app-tests.zip --output ../build/playlet-app-tests.txt" } } diff --git a/playlet-lib/package.json b/playlet-lib/package.json index 548fb596..e41f42c9 100644 --- a/playlet-lib/package.json +++ b/playlet-lib/package.json @@ -20,6 +20,9 @@ "format:fix": "npm run format:base -- --write", "test": "npm run test:build && npm run test:run", "test:build": "bsc --project bsconfig.tests.json --create-package --sourceMap=true --debug --test-mode --lintConfig ../config/bslint.jsonc", - "test:run": "node ../tools/run-test-app.js --package ../build/playlet-lib-tests.zip" + "test:run": "node ../tools/run-test-app.js --package ../build/playlet-lib-tests.zip", + "test:v2": "npm run test:build && npm run test:run:v2", + "pretest:run:v2": "../../../dev-tools/bin/ensure-service.sh", + "test:run:v2": "../../../dev-tools/bin/test-app.sh --package ../build/playlet-lib-tests.zip --output ../build/playlet-lib-tests.txt" } } diff --git a/tools/bs-plugins/manifest-edit-plugin.ts b/tools/bs-plugins/manifest-edit-plugin.ts index e53e9fdf..8617c7de 100644 --- a/tools/bs-plugins/manifest-edit-plugin.ts +++ b/tools/bs-plugins/manifest-edit-plugin.ts @@ -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