@nocobase/cli 2.0.0-beta.7 → 2.0.0-beta.8

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 (2) hide show
  1. package/package.json +4 -4
  2. package/src/util.js +16 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "2.0.0-beta.7",
3
+ "version": "2.0.0-beta.8",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./src/index.js",
@@ -8,7 +8,7 @@
8
8
  "nocobase": "./bin/index.js"
9
9
  },
10
10
  "dependencies": {
11
- "@nocobase/app": "2.0.0-beta.7",
11
+ "@nocobase/app": "2.0.0-beta.8",
12
12
  "@nocobase/license-kit": "^0.3.5",
13
13
  "@types/fs-extra": "^11.0.1",
14
14
  "@umijs/utils": "3.5.20",
@@ -27,12 +27,12 @@
27
27
  "tsx": "^4.19.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@nocobase/devtools": "2.0.0-beta.7"
30
+ "@nocobase/devtools": "2.0.0-beta.8"
31
31
  },
32
32
  "repository": {
33
33
  "type": "git",
34
34
  "url": "git+https://github.com/nocobase/nocobase.git",
35
35
  "directory": "packages/core/cli"
36
36
  },
37
- "gitHead": "17b6e4042a4814e38b256c7b3ae34e6d0b08fd57"
37
+ "gitHead": "6bd912b1028eb8bc09a823d35e4d37b3000861b1"
38
38
  }
package/src/util.js CHANGED
@@ -295,7 +295,8 @@ function buildIndexHtml(force = false) {
295
295
  fs.copyFileSync(file, tpl);
296
296
  }
297
297
  const data = fs.readFileSync(tpl, 'utf-8');
298
- const replacedData = data
298
+ let replacedData = data
299
+ .replace(/\{\{env.CDN_BASE_URL\}\}/g, process.env.CDN_BASE_URL)
299
300
  .replace(/\{\{env.APP_PUBLIC_PATH\}\}/g, process.env.APP_PUBLIC_PATH)
300
301
  .replace(/\{\{env.API_CLIENT_SHARE_TOKEN\}\}/g, process.env.API_CLIENT_SHARE_TOKEN || 'false')
301
302
  .replace(/\{\{env.API_CLIENT_STORAGE_TYPE\}\}/g, process.env.API_CLIENT_STORAGE_TYPE)
@@ -304,6 +305,14 @@ function buildIndexHtml(force = false) {
304
305
  .replace(/\{\{env.WS_URL\}\}/g, process.env.WEBSOCKET_URL || '')
305
306
  .replace(/\{\{env.WS_PATH\}\}/g, process.env.WS_PATH)
306
307
  .replace('src="/umi.', `src="${process.env.APP_PUBLIC_PATH}umi.`);
308
+
309
+ if (process.env.CDN_BASE_URL) {
310
+ const appBaseUrl = process.env.CDN_BASE_URL.replace(/\/+$/, '');
311
+ const appPublicPath = process.env.APP_PUBLIC_PATH.replace(/\/+$/, '');
312
+ const re1 = new RegExp(`src="${appPublicPath}/`, 'g');
313
+ const re2 = new RegExp(`href="${appPublicPath}/`, 'g');
314
+ replacedData = replacedData.replace(re1, `src="${appBaseUrl}/`).replace(re2, `href="${appBaseUrl}/`);
315
+ }
307
316
  fs.writeFileSync(file, replacedData, 'utf-8');
308
317
  }
309
318
 
@@ -385,6 +394,8 @@ exports.initEnv = function initEnv() {
385
394
  PLUGIN_STATICS_PATH: '/static/plugins/',
386
395
  LOGGER_BASE_PATH: 'storage/logs',
387
396
  APP_SERVER_BASE_URL: '',
397
+ APP_BASE_URL: '',
398
+ CDN_BASE_URL: '',
388
399
  APP_PUBLIC_PATH: '/',
389
400
  WATCH_FILE: resolve(process.cwd(), 'storage/app.watch.ts'),
390
401
  };
@@ -440,6 +451,10 @@ exports.initEnv = function initEnv() {
440
451
  process.env.__env_modified__ = true;
441
452
  }
442
453
 
454
+ if (!process.env.CDN_BASE_URL && process.env.APP_PUBLIC_PATH !== '/') {
455
+ process.env.CDN_BASE_URL = process.env.APP_PUBLIC_PATH;
456
+ }
457
+
443
458
  if (!process.env.TZ) {
444
459
  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
445
460
  process.env.TZ = getTimezonesByOffset(process.env.DB_TIMEZONE || timeZone);