@ubox-tools/deploy-xperience 1.1.23 → 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.
Files changed (3) hide show
  1. package/README.md +13 -2
  2. package/deploy.js +21 -18
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -110,10 +110,19 @@ Before injecting source files, `generateProxy()` applies transforms to each file
110
110
 
111
111
  | Transform | Applies to | What it does |
112
112
  |---|---|---|
113
- | 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 |
114
114
  | Emoji escaping | JS | Converts non-ASCII characters to `\uXXXX` Unicode escape sequences |
115
115
  | Local tag stripping | HTML | Removes local `<link href>` and `<script src>` tags (CDN URLs are kept) |
116
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
+
117
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.
118
127
 
119
128
  ## Project Layout Expected
@@ -131,7 +140,9 @@ Before injecting source files, `generateProxy()` applies transforms to each file
131
140
  parameters.json (optional)
132
141
  main/
133
142
  ...same files...
134
- assets/
143
+ assets/ (optional, app-specific assets)
144
+ *.jpg / *.png / ...
145
+ assets/ (shared across all apps)
135
146
  *.jpg / *.png / *.woff2 / ...
136
147
  deploy.js
137
148
  ```
package/deploy.js CHANGED
@@ -239,24 +239,26 @@ function generateProxy(appName) {
239
239
 
240
240
  if (isJS || isCSS) {
241
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, assetFile) => {
244
- const assetExt = path.extname(assetFile).slice(1).toLowerCase();
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();
245
246
  const type = assetResourceType(assetExt);
246
- const absPath = path.join(ASSETS_DIR, assetFile);
247
- if (fs.existsSync(absPath)) assets[assetFile] = { type, absPath };
248
- return `"{resources:${type}/${assetFile}}"`;
247
+ const absPath = path.resolve(appDir, relativePath);
248
+ if (fs.existsSync(absPath)) assets[fileName] = { type, absPath };
249
+ return `"{resources:${type}/${fileName}}"`;
249
250
  });
250
251
 
251
252
  // CSS url() pattern
252
253
  if (isCSS) {
253
- const assetUrlRe = /url\((['"]?)(?:\.\.\/)*assets\/([^'")\s]+)\1\)/g;
254
- content = content.replace(assetUrlRe, (match, quote, assetFile) => {
255
- const assetExt = path.extname(assetFile).slice(1).toLowerCase();
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();
256
258
  const type = assetResourceType(assetExt);
257
- const absPath = path.join(ASSETS_DIR, assetFile);
258
- if (fs.existsSync(absPath)) assets[assetFile] = { type, absPath };
259
- return `url("{resources:${type}/${assetFile}}")`;
259
+ const absPath = path.resolve(appDir, relativePath);
260
+ if (fs.existsSync(absPath)) assets[fileName] = { type, absPath };
261
+ return `url("{resources:${type}/${fileName}}")`;
260
262
  });
261
263
  }
262
264
 
@@ -266,13 +268,14 @@ function generateProxy(appName) {
266
268
 
267
269
  if (isHTML) {
268
270
  // Asset path substitution for HTML src/href attributes
269
- const assetInStringRe = /(['"])(?:\.\.\/)*assets\/([^'"]+)\1/g;
270
- content = content.replace(assetInStringRe, (match, quote, assetFile) => {
271
- const assetExt = path.extname(assetFile).slice(1).toLowerCase();
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();
272
275
  const type = assetResourceType(assetExt);
273
- const absPath = path.join(ASSETS_DIR, assetFile);
274
- if (fs.existsSync(absPath)) assets[assetFile] = { type, absPath };
275
- return `"{resources:${type}/${assetFile}}"`;
276
+ const absPath = path.resolve(appDir, relativePath);
277
+ if (fs.existsSync(absPath)) assets[fileName] = { type, absPath };
278
+ return `"{resources:${type}/${fileName}}"`;
276
279
  });
277
280
 
278
281
  // Strip local <link> tags (keep CDN ones with https://)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubox-tools/deploy-xperience",
3
- "version": "1.1.23",
3
+ "version": "1.1.24",
4
4
  "description": "Deploy a Ubox experience to studio.ubox.world",
5
5
  "bin": { "deploy-xperience": "./deploy.js" },
6
6
  "dependencies": { "puppeteer": "*" },