@ubox-tools/deploy-xperience 1.1.22 → 1.1.24
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 +16 -4
- package/deploy.js +22 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,15 +106,25 @@ When `--ubox-id` is provided, the search/create step is skipped entirely and the
|
|
|
106
106
|
|
|
107
107
|
## Proxy / Source Transformation
|
|
108
108
|
|
|
109
|
-
Before injecting source files, `generateProxy()` applies
|
|
109
|
+
Before injecting source files, `generateProxy()` applies transforms to each file:
|
|
110
110
|
|
|
111
111
|
| Transform | Applies to | What it does |
|
|
112
112
|
|---|---|---|
|
|
113
|
-
|
|
|
114
|
-
| Asset path substitution | JS, CSS | Replaces `../assets/file.ext` references with `{resources:type/file.ext}` tokens |
|
|
113
|
+
| Asset path substitution | JS, CSS, HTML | Replaces `assets/file.ext` references with `{resources:type/file.ext}` tokens |
|
|
115
114
|
| Emoji escaping | JS | Converts non-ASCII characters to `\uXXXX` Unicode escape sequences |
|
|
116
115
|
| Local tag stripping | HTML | Removes local `<link href>` and `<script src>` tags (CDN URLs are kept) |
|
|
117
116
|
|
|
117
|
+
Asset references are resolved by their actual relative path, so both a root-level shared folder and a per-app folder work:
|
|
118
|
+
|
|
119
|
+
| Reference in source | Resolved from |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `../../assets/logo.png` | `<project-root>/assets/logo.png` |
|
|
122
|
+
| `assets/logo.png` | `apps/<appName>/assets/logo.png` |
|
|
123
|
+
|
|
124
|
+
Files inside subdirectories (e.g. `assets/img/logo.png`) are supported — the token uses only the filename: `{resources:images/logo.png}`.
|
|
125
|
+
|
|
126
|
+
> **Parameter tokens are embedded at authoring time** — `data.js` uses inline `{parameter:key}` tokens with local fallbacks. No deploy-time regex substitution is performed.
|
|
127
|
+
|
|
118
128
|
## Project Layout Expected
|
|
119
129
|
|
|
120
130
|
```
|
|
@@ -130,7 +140,9 @@ Before injecting source files, `generateProxy()` applies three transforms to eac
|
|
|
130
140
|
parameters.json (optional)
|
|
131
141
|
main/
|
|
132
142
|
...same files...
|
|
133
|
-
|
|
143
|
+
assets/ (optional, app-specific assets)
|
|
144
|
+
*.jpg / *.png / ...
|
|
145
|
+
assets/ (shared across all apps)
|
|
134
146
|
*.jpg / *.png / *.woff2 / ...
|
|
135
147
|
deploy.js
|
|
136
148
|
```
|
package/deploy.js
CHANGED
|
@@ -238,33 +238,27 @@ function generateProxy(appName) {
|
|
|
238
238
|
const isHTML = ext === 'html';
|
|
239
239
|
|
|
240
240
|
if (isJS || isCSS) {
|
|
241
|
-
// 1.
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// 2. Asset path substitution: "...assets/file.ext" → "{resources:type/file.ext}"
|
|
250
|
-
const assetInStringRe = /(['"])(?:\.\.\/)*assets\/([^'"]+)\1/g;
|
|
251
|
-
content = content.replace(assetInStringRe, (match, quote, assetFile) => {
|
|
252
|
-
const assetExt = path.extname(assetFile).slice(1).toLowerCase();
|
|
241
|
+
// 1. Asset path substitution: "...assets/file.ext" → "{resources:type/file.ext}"
|
|
242
|
+
const assetInStringRe = /(['"])((?:\.\.\/)*assets\/([^'"]+))\1/g;
|
|
243
|
+
content = content.replace(assetInStringRe, (match, quote, relativePath, assetFile) => {
|
|
244
|
+
const fileName = path.basename(assetFile);
|
|
245
|
+
const assetExt = path.extname(fileName).slice(1).toLowerCase();
|
|
253
246
|
const type = assetResourceType(assetExt);
|
|
254
|
-
const absPath = path.
|
|
255
|
-
if (fs.existsSync(absPath)) assets[
|
|
256
|
-
return `"{resources:${type}/${
|
|
247
|
+
const absPath = path.resolve(appDir, relativePath);
|
|
248
|
+
if (fs.existsSync(absPath)) assets[fileName] = { type, absPath };
|
|
249
|
+
return `"{resources:${type}/${fileName}}"`;
|
|
257
250
|
});
|
|
258
251
|
|
|
259
252
|
// CSS url() pattern
|
|
260
253
|
if (isCSS) {
|
|
261
|
-
const assetUrlRe = /url\((['"]?)(?:\.\.\/)*assets\/([^'")\s]+)\1\)/g;
|
|
262
|
-
content = content.replace(assetUrlRe, (match, quote, assetFile) => {
|
|
263
|
-
const
|
|
254
|
+
const assetUrlRe = /url\((['"]?)((?:\.\.\/)*assets\/([^'")\s]+))\1\)/g;
|
|
255
|
+
content = content.replace(assetUrlRe, (match, quote, relativePath, assetFile) => {
|
|
256
|
+
const fileName = path.basename(assetFile);
|
|
257
|
+
const assetExt = path.extname(fileName).slice(1).toLowerCase();
|
|
264
258
|
const type = assetResourceType(assetExt);
|
|
265
|
-
const absPath = path.
|
|
266
|
-
if (fs.existsSync(absPath)) assets[
|
|
267
|
-
return `url("{resources:${type}/${
|
|
259
|
+
const absPath = path.resolve(appDir, relativePath);
|
|
260
|
+
if (fs.existsSync(absPath)) assets[fileName] = { type, absPath };
|
|
261
|
+
return `url("{resources:${type}/${fileName}}")`;
|
|
268
262
|
});
|
|
269
263
|
}
|
|
270
264
|
|
|
@@ -274,13 +268,14 @@ function generateProxy(appName) {
|
|
|
274
268
|
|
|
275
269
|
if (isHTML) {
|
|
276
270
|
// Asset path substitution for HTML src/href attributes
|
|
277
|
-
const assetInStringRe = /(['"])(?:\.\.\/)*assets\/([^'"]+)\1/g;
|
|
278
|
-
content = content.replace(assetInStringRe, (match, quote, assetFile) => {
|
|
279
|
-
const
|
|
271
|
+
const assetInStringRe = /(['"])((?:\.\.\/)*assets\/([^'"]+))\1/g;
|
|
272
|
+
content = content.replace(assetInStringRe, (match, quote, relativePath, assetFile) => {
|
|
273
|
+
const fileName = path.basename(assetFile);
|
|
274
|
+
const assetExt = path.extname(fileName).slice(1).toLowerCase();
|
|
280
275
|
const type = assetResourceType(assetExt);
|
|
281
|
-
const absPath = path.
|
|
282
|
-
if (fs.existsSync(absPath)) assets[
|
|
283
|
-
return `"{resources:${type}/${
|
|
276
|
+
const absPath = path.resolve(appDir, relativePath);
|
|
277
|
+
if (fs.existsSync(absPath)) assets[fileName] = { type, absPath };
|
|
278
|
+
return `"{resources:${type}/${fileName}}"`;
|
|
284
279
|
});
|
|
285
280
|
|
|
286
281
|
// Strip local <link> tags (keep CDN ones with https://)
|
package/package.json
CHANGED