@ubox-tools/deploy-xperience 1.1.19 → 1.1.20
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 +10 -29
- package/package.json +1 -1
package/deploy.js
CHANGED
|
@@ -241,10 +241,7 @@ function generateProxy(appName) {
|
|
|
241
241
|
// 1. Parameter token substitution (JS only — parameters live in JS files)
|
|
242
242
|
if (isJS) {
|
|
243
243
|
for (const key of Object.keys(params)) {
|
|
244
|
-
const re = new RegExp(
|
|
245
|
-
`((?:const|let|var)\\s+${key}\\s*=\\s*)(?:"[^"]*"|'[^']*'|\`[^\`]*\`|-?\\d+\\.?\\d*(?:[eE][+-]?\\d+)?|true|false|null|undefined)`,
|
|
246
|
-
'g'
|
|
247
|
-
);
|
|
244
|
+
const re = new RegExp(`((?:const|let|var)\\s+${key}\\s*=\\s*)(?:"[^"]*"|'[^']*')`, 'g');
|
|
248
245
|
content = content.replace(re, `$1"{parameter:${key}}"`);
|
|
249
246
|
}
|
|
250
247
|
}
|
|
@@ -429,7 +426,7 @@ async function injectToEditor(page, content) {
|
|
|
429
426
|
}
|
|
430
427
|
return false;
|
|
431
428
|
}, content);
|
|
432
|
-
if (monacoOk)
|
|
429
|
+
if (monacoOk) return;
|
|
433
430
|
|
|
434
431
|
// Try CodeMirror API
|
|
435
432
|
const cmOk = await page.evaluate(text => {
|
|
@@ -437,10 +434,9 @@ async function injectToEditor(page, content) {
|
|
|
437
434
|
if (cm?.CodeMirror) { cm.CodeMirror.setValue(text); return true; }
|
|
438
435
|
return false;
|
|
439
436
|
}, content);
|
|
440
|
-
if (cmOk)
|
|
437
|
+
if (cmOk) return;
|
|
441
438
|
|
|
442
439
|
// Fallback: clipboard paste into Ace / generic textarea
|
|
443
|
-
console.log(' [editor] clipboard');
|
|
444
440
|
writeClipboard(content);
|
|
445
441
|
const ed = await page.$('.ace_editor, .cm-editor, .monaco-editor, textarea');
|
|
446
442
|
if (!ed) throw new Error('No code editor found on page');
|
|
@@ -609,6 +605,9 @@ async function configureParameters(page, params) {
|
|
|
609
605
|
|
|
610
606
|
console.log(` [params] Creating ${toCreate.length} new parameter(s) (${existingKeys.length} already exist)...`);
|
|
611
607
|
|
|
608
|
+
// Accept any confirm() dialogs that Save triggers
|
|
609
|
+
page.on('dialog', async d => { await d.accept(); });
|
|
610
|
+
|
|
612
611
|
await clickByText(page, 'Edit', 'button');
|
|
613
612
|
await sleep(1000);
|
|
614
613
|
|
|
@@ -662,20 +661,11 @@ async function configureParameters(page, params) {
|
|
|
662
661
|
|
|
663
662
|
async function injectSource(page, proxy) {
|
|
664
663
|
console.log(' [source] Injecting source files...');
|
|
665
|
-
console.log(` [source] URL: ${page.url()}`);
|
|
666
664
|
await clickByText(page, 'Source');
|
|
667
665
|
await sleep(1500);
|
|
668
666
|
|
|
669
667
|
await clickByText(page, 'Edit source');
|
|
670
668
|
await sleep(3000);
|
|
671
|
-
// Wait for the editor (Monaco or CodeMirror) to fully initialize.
|
|
672
|
-
// On first-ever source editor visit in a session, Monaco may still be loading
|
|
673
|
-
// after 3 s — this ensures injection happens only once it's ready.
|
|
674
|
-
await page.waitForFunction(() => {
|
|
675
|
-
return !!(window.monaco?.editor?.getModels) ||
|
|
676
|
-
!!(document.querySelector('.CodeMirror')?.CodeMirror);
|
|
677
|
-
}, { timeout: 15000 }).catch(() => null);
|
|
678
|
-
console.log(` [source] URL after Edit source: ${page.url()}`);
|
|
679
669
|
|
|
680
670
|
// Tab label → filename
|
|
681
671
|
const tabs = [
|
|
@@ -696,11 +686,8 @@ async function injectSource(page, proxy) {
|
|
|
696
686
|
await sleep(500);
|
|
697
687
|
}
|
|
698
688
|
|
|
699
|
-
const navPromise = page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 15000 }).catch(() => null);
|
|
700
689
|
await clickByText(page, 'Save and back to app');
|
|
701
|
-
|
|
702
|
-
await sleep(1000);
|
|
703
|
-
console.log(` [source] URL after save: ${page.url()} (navigated: ${navResult ? 'yes' : 'no'})`);
|
|
690
|
+
await sleep(3000);
|
|
704
691
|
}
|
|
705
692
|
|
|
706
693
|
async function deployApp(page, appName, projectName, { noAssets = false, noSource = false } = {}) {
|
|
@@ -729,7 +716,7 @@ async function deployApp(page, appName, projectName, { noAssets = false, noSourc
|
|
|
729
716
|
// Extract app ID from current URL
|
|
730
717
|
const appId = page.url().match(/#\/application(?:-source)?\/(\d+)/)?.[1] || '?';
|
|
731
718
|
console.log(` [app] Done — ID: ${appId}`);
|
|
732
|
-
return
|
|
719
|
+
return appId;
|
|
733
720
|
}
|
|
734
721
|
|
|
735
722
|
// ─── Phase 3: Ubox Deployment ─────────────────────────────────────────────────
|
|
@@ -1143,12 +1130,6 @@ async function main() {
|
|
|
1143
1130
|
const state = {};
|
|
1144
1131
|
|
|
1145
1132
|
try {
|
|
1146
|
-
// Always accept any confirm() dialogs the studio may show during deployment
|
|
1147
|
-
page.on('dialog', async d => {
|
|
1148
|
-
console.log(` [dialog] type=${d.type()} msg="${d.message()}" → accepted`);
|
|
1149
|
-
await d.accept();
|
|
1150
|
-
});
|
|
1151
|
-
|
|
1152
1133
|
// Phase 1 — Login
|
|
1153
1134
|
await login(page, email, password);
|
|
1154
1135
|
|
|
@@ -1156,9 +1137,9 @@ async function main() {
|
|
|
1156
1137
|
const appParamsMap = {};
|
|
1157
1138
|
for (const appName of apps) {
|
|
1158
1139
|
state[appName] = {};
|
|
1159
|
-
const {
|
|
1160
|
-
state[appName].appId = appId;
|
|
1140
|
+
const { params } = generateProxy(appName);
|
|
1161
1141
|
appParamsMap[appName] = params;
|
|
1142
|
+
state[appName].appId = await deployApp(page, appName, projectName, { noAssets, noSource });
|
|
1162
1143
|
}
|
|
1163
1144
|
|
|
1164
1145
|
// Phase 3 — Deploy Uboxes
|
package/package.json
CHANGED