@ubox-tools/deploy-xperience 1.1.9 → 1.1.11
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 +19 -3
- package/deploy.js +30 -2
- 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
|
|
|
@@ -94,7 +110,7 @@ Before injecting source files, `generateProxy()` applies three transforms to eac
|
|
|
94
110
|
|
|
95
111
|
| Transform | Applies to | What it does |
|
|
96
112
|
|---|---|---|
|
|
97
|
-
| Parameter substitution | JS | Replaces `const KEY =
|
|
113
|
+
| Parameter substitution | JS | Replaces `const KEY = <value>` with `const KEY = "{parameter:KEY}"` for every key in `parameters.json` (value may be a string, number, boolean, null, undefined, or template literal) |
|
|
98
114
|
| Asset path substitution | JS, CSS | Replaces `../assets/file.ext` references with `{resources:type/file.ext}` tokens |
|
|
99
115
|
| Emoji escaping | JS | Converts non-ASCII characters to `\uXXXX` Unicode escape sequences |
|
|
100
116
|
| Local tag stripping | HTML | Removes local `<link href>` and `<script src>` tags (CDN URLs are kept) |
|
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
|
|
|
@@ -224,7 +241,10 @@ function generateProxy(appName) {
|
|
|
224
241
|
// 1. Parameter token substitution (JS only — parameters live in JS files)
|
|
225
242
|
if (isJS) {
|
|
226
243
|
for (const key of Object.keys(params)) {
|
|
227
|
-
const re = new RegExp(
|
|
244
|
+
const re = new RegExp(
|
|
245
|
+
`((?:const|let|var)\\s+${key}\\s*=\\s*)(?:"[^"]*"|'[^']*'|\`[^\`]*\`|-?\\d+\\.?\\d*(?:[eE][+-]?\\d+)?|true|false|null|undefined)`,
|
|
246
|
+
'g'
|
|
247
|
+
);
|
|
228
248
|
content = content.replace(re, `$1"{parameter:${key}}"`);
|
|
229
249
|
}
|
|
230
250
|
}
|
|
@@ -1090,7 +1110,15 @@ async function main() {
|
|
|
1090
1110
|
if (noPlayer) console.log('Flags : --noplayer (skip Ubox creation)');
|
|
1091
1111
|
console.log('');
|
|
1092
1112
|
|
|
1093
|
-
|
|
1113
|
+
let credEmail = emailArg, credPassword = passwordArg;
|
|
1114
|
+
if (!credEmail || !credPassword) {
|
|
1115
|
+
const fileCreds = loadCredentialsFile();
|
|
1116
|
+
if (fileCreds) {
|
|
1117
|
+
if (!credEmail) credEmail = fileCreds.email;
|
|
1118
|
+
if (!credPassword) credPassword = fileCreds.password;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
const { email, password } = await promptCredentials(credEmail, credPassword);
|
|
1094
1122
|
|
|
1095
1123
|
const browser = await puppeteer.launch({
|
|
1096
1124
|
headless: !show,
|
package/package.json
CHANGED