@ubox-tools/deploy-xperience 1.1.0 → 1.1.2
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/deploy.js +19 -7
- package/package.json +1 -1
package/deploy.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
const puppeteer = require('puppeteer');
|
|
@@ -966,25 +967,37 @@ async function setMobileLink(page, appFullName, mobileVirtualLink) {
|
|
|
966
967
|
console.log(` [ubox] mobileLink = ${mobileVirtualLink}`);
|
|
967
968
|
}
|
|
968
969
|
|
|
970
|
+
async function isAppInstalled(page, appFullName) {
|
|
971
|
+
return page.evaluate(name => {
|
|
972
|
+
for (const card of document.querySelectorAll('.card-body.ubox-app-installed')) {
|
|
973
|
+
const title = card.querySelector('p.card-text');
|
|
974
|
+
if (title && title.textContent.trim() === name) return true;
|
|
975
|
+
}
|
|
976
|
+
return false;
|
|
977
|
+
}, appFullName);
|
|
978
|
+
}
|
|
979
|
+
|
|
969
980
|
async function deployUbox(page, appName, projectName, appParams, mobileVirtualLink, targetUboxId = null) {
|
|
970
981
|
const fullName = `${projectName} ${appName}`;
|
|
971
982
|
console.log(`\n[Phase 3] Ubox: ${fullName}`);
|
|
972
983
|
|
|
973
|
-
let uboxUrl
|
|
984
|
+
let uboxUrl;
|
|
974
985
|
if (targetUboxId) {
|
|
975
986
|
uboxUrl = `${BASE_URL}/#/ubox/${targetUboxId}`;
|
|
976
987
|
console.log(` [ubox] Using pre-existing Ubox ID ${targetUboxId} — navigating directly...`);
|
|
977
988
|
await page.goto(uboxUrl, { waitUntil: 'networkidle2' });
|
|
978
989
|
await sleep(2000);
|
|
979
|
-
created = false;
|
|
980
990
|
} else {
|
|
981
|
-
({ url: uboxUrl
|
|
991
|
+
({ url: uboxUrl } = await findOrCreateUbox(page, fullName));
|
|
982
992
|
}
|
|
983
993
|
|
|
984
994
|
let virtualLink = null;
|
|
985
995
|
|
|
986
|
-
|
|
987
|
-
|
|
996
|
+
const installed = await isAppInstalled(page, fullName);
|
|
997
|
+
|
|
998
|
+
if (!installed) {
|
|
999
|
+
// App not installed — make public, install, get virtual link, set params
|
|
1000
|
+
console.log(` [ubox] "${fullName}" not installed — proceeding with install...`);
|
|
988
1001
|
await checkMakePublic(page);
|
|
989
1002
|
await installApp(page, fullName);
|
|
990
1003
|
|
|
@@ -1002,8 +1015,7 @@ async function deployUbox(page, appName, projectName, appParams, mobileVirtualLi
|
|
|
1002
1015
|
await setMobileLink(page, fullName, mobileVirtualLink);
|
|
1003
1016
|
}
|
|
1004
1017
|
} else {
|
|
1005
|
-
|
|
1006
|
-
console.log(' [ubox] Already exists — skipping install, params, and virtual link');
|
|
1018
|
+
console.log(` [ubox] "${fullName}" already installed — skipping install`);
|
|
1007
1019
|
|
|
1008
1020
|
// Still retrieve the virtual link for mobile so main can use it
|
|
1009
1021
|
if (appName === 'mobile') {
|
package/package.json
CHANGED