@ubox-tools/deploy-xperience 1.1.8 → 1.1.10
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/README.md +18 -2
- package/deploy.js +36 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,13 +35,29 @@ npx @ubox-tools/deploy-xperience [app1 app2 ...] [options]
|
|
|
35
35
|
| `--show` | Show the browser window (default: headless) |
|
|
36
36
|
| `--help` | Print usage and exit |
|
|
37
37
|
|
|
38
|
-
Credentials
|
|
38
|
+
Credentials are resolved in this order:
|
|
39
|
+
|
|
40
|
+
1. CLI flags (`--email`, `--password`)
|
|
41
|
+
2. Environment variables (`UBOX_EMAIL`, `UBOX_PASSWORD`)
|
|
42
|
+
3. `ubox-credentials.json` in the project root
|
|
43
|
+
4. Interactive prompt (if the terminal is interactive)
|
|
44
|
+
|
|
45
|
+
**`ubox-credentials.json`** (place in the experience project root):
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"email": "me@example.com",
|
|
50
|
+
"password": "secret"
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Environment variables:**
|
|
39
55
|
|
|
40
56
|
```
|
|
41
57
|
UBOX_EMAIL=me@example.com UBOX_PASSWORD=secret npx @ubox-tools/deploy-xperience
|
|
42
58
|
```
|
|
43
59
|
|
|
44
|
-
If
|
|
60
|
+
If a credential is provided by a higher-priority source, the file value for that field is ignored.
|
|
45
61
|
|
|
46
62
|
## Examples
|
|
47
63
|
|
package/deploy.js
CHANGED
|
@@ -141,6 +141,23 @@ Examples:
|
|
|
141
141
|
|
|
142
142
|
// ─── Credentials ──────────────────────────────────────────────────────────────
|
|
143
143
|
|
|
144
|
+
function loadCredentialsFile() {
|
|
145
|
+
const filePath = path.join(process.cwd(), 'ubox-credentials.json');
|
|
146
|
+
try {
|
|
147
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
148
|
+
const data = JSON.parse(raw);
|
|
149
|
+
const email = typeof data.email === 'string' && data.email.trim();
|
|
150
|
+
const password = typeof data.password === 'string' && data.password.trim();
|
|
151
|
+
if (email && password) {
|
|
152
|
+
console.log('Using credentials from ubox-credentials.json');
|
|
153
|
+
return { email, password };
|
|
154
|
+
}
|
|
155
|
+
} catch (_) {
|
|
156
|
+
// File missing or invalid — continue with normal credential flow
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
144
161
|
async function promptCredentials(email, password) {
|
|
145
162
|
if (email && password) return { email, password };
|
|
146
163
|
|
|
@@ -256,6 +273,16 @@ function generateProxy(appName) {
|
|
|
256
273
|
}
|
|
257
274
|
|
|
258
275
|
if (isHTML) {
|
|
276
|
+
// Asset path substitution for HTML src/href attributes
|
|
277
|
+
const assetInStringRe = /(['"])(?:\.\.\/)*assets\/([^'"]+)\1/g;
|
|
278
|
+
content = content.replace(assetInStringRe, (match, quote, assetFile) => {
|
|
279
|
+
const assetExt = path.extname(assetFile).slice(1).toLowerCase();
|
|
280
|
+
const type = assetResourceType(assetExt);
|
|
281
|
+
const absPath = path.join(ASSETS_DIR, assetFile);
|
|
282
|
+
if (fs.existsSync(absPath)) assets[assetFile] = { type, absPath };
|
|
283
|
+
return `"{resources:${type}/${assetFile}}"`;
|
|
284
|
+
});
|
|
285
|
+
|
|
259
286
|
// Strip local <link> tags (keep CDN ones with https://)
|
|
260
287
|
content = content.replace(/<link\b[^>]*\bhref=["'](?!https?:\/\/)[^"']*["'][^>]*\/?>/gi, '');
|
|
261
288
|
// Strip local <script src> tags (keep CDN ones)
|
|
@@ -1080,7 +1107,15 @@ async function main() {
|
|
|
1080
1107
|
if (noPlayer) console.log('Flags : --noplayer (skip Ubox creation)');
|
|
1081
1108
|
console.log('');
|
|
1082
1109
|
|
|
1083
|
-
|
|
1110
|
+
let credEmail = emailArg, credPassword = passwordArg;
|
|
1111
|
+
if (!credEmail || !credPassword) {
|
|
1112
|
+
const fileCreds = loadCredentialsFile();
|
|
1113
|
+
if (fileCreds) {
|
|
1114
|
+
if (!credEmail) credEmail = fileCreds.email;
|
|
1115
|
+
if (!credPassword) credPassword = fileCreds.password;
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
const { email, password } = await promptCredentials(credEmail, credPassword);
|
|
1084
1119
|
|
|
1085
1120
|
const browser = await puppeteer.launch({
|
|
1086
1121
|
headless: !show,
|
package/package.json
CHANGED