@nocobase/cli-v1 2.1.0-alpha.45 → 2.1.0-alpha.46

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/nocobase.conf.tpl CHANGED
@@ -30,6 +30,9 @@ server {
30
30
  client_max_body_size 0;
31
31
  access_log /var/log/nginx/nocobase.log apm;
32
32
 
33
+ include /etc/nginx/mime.types;
34
+ types { application/javascript mjs; }
35
+
33
36
  gzip on;
34
37
  gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
35
38
 
@@ -88,7 +91,7 @@ server {
88
91
  }
89
92
 
90
93
  location {{v2PublicPath}}assets/ {
91
- alias {{cwd}}/node_modules/@nocobase/app/dist/client/v2/assets/;
94
+ alias {{cwd}}/node_modules/@nocobase/app/dist/client/v/assets/;
92
95
  expires 365d;
93
96
  add_header Cache-Control "public";
94
97
  access_log off;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli-v1",
3
- "version": "2.1.0-alpha.45",
3
+ "version": "2.1.0-alpha.46",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./src/index.js",
@@ -8,9 +8,9 @@
8
8
  "nocobase-v1": "./bin/index.js"
9
9
  },
10
10
  "dependencies": {
11
- "@nocobase/cli": "2.1.0-alpha.45",
11
+ "@nocobase/cli": "2.1.0-alpha.46",
12
12
  "@nocobase/license-kit": "^0.3.8",
13
- "@nocobase/utils": "2.1.0-alpha.45",
13
+ "@nocobase/utils": "2.1.0-alpha.46",
14
14
  "chalk": "^4.1.1",
15
15
  "commander": "^9.2.0",
16
16
  "deepmerge": "^4.3.1",
@@ -25,7 +25,7 @@
25
25
  "tree-kill": "^1.2.2"
26
26
  },
27
27
  "devDependencies": {
28
- "@nocobase/devtools": "2.1.0-alpha.45",
28
+ "@nocobase/devtools": "2.1.0-alpha.46",
29
29
  "@types/fs-extra": "^11.0.1"
30
30
  },
31
31
  "repository": {
@@ -33,5 +33,5 @@
33
33
  "url": "git+https://github.com/nocobase/nocobase.git",
34
34
  "directory": "packages/core/cli"
35
35
  },
36
- "gitHead": "e9e24987e12d0ad10a5db8815b1e1b7b447f1938"
36
+ "gitHead": "42b269944cdd1908d7a848c0af4936fe94c03bb7"
37
37
  }
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  const { resolve, posix } = require('path');
11
- const { storagePathJoin, resolvePublicPath, resolveV2PublicPath } = require('../util');
11
+ const { storagePathJoin, resolvePublicPath, resolveV2PublicPath, normalizeModernClientPrefix } = require('../util');
12
12
  const { Command } = require('commander');
13
13
  const { readFileSync, writeFileSync } = require('fs');
14
14
 
@@ -21,17 +21,20 @@ module.exports = (cli) => {
21
21
  const rawAppPublicPath = process.env.APP_PUBLIC_PATH || '/';
22
22
  const appPublicPath = resolvePublicPath(rawAppPublicPath);
23
23
  const v2PublicPath = resolveV2PublicPath(rawAppPublicPath);
24
+ const modernClientPrefix = normalizeModernClientPrefix(process.env.APP_MODERN_CLIENT_PREFIX);
24
25
  const appPublicPathWithoutTrailingSlash = appPublicPath.replace(/\/$/, '');
25
26
  const v2PublicPathWithoutTrailingSlash = v2PublicPath.replace(/\/$/, '');
26
27
  const file = resolve(__dirname, '../../nocobase.conf.tpl');
27
28
  const data = readFileSync(file, 'utf-8');
28
29
  let otherLocation = '';
29
30
  if (appPublicPath !== '/') {
30
- otherLocation = `location = /v2 {
31
+ // When the app is mounted under a sub-path, redirect the root-level
32
+ // `/<prefix>` and `/<prefix>/` to the real (sub-path-prefixed) location.
33
+ otherLocation = `location = /${modernClientPrefix} {
31
34
  return 302 ${v2PublicPath}$is_args$args;
32
35
  }
33
36
 
34
- location /v2/ {
37
+ location /${modernClientPrefix}/ {
35
38
  return 302 ${appPublicPathWithoutTrailingSlash}$uri$is_args$args;
36
39
  }
37
40
 
package/src/util.js CHANGED
@@ -367,9 +367,32 @@ function resolvePublicPath(appPublicPath = '/') {
367
367
 
368
368
  exports.resolvePublicPath = resolvePublicPath;
369
369
 
370
+ // Default URL segment under which the modern (v2) client is served.
371
+ // Kept local here so the CLI bootstrap (bin/index.js -> initEnv) stays lightweight
372
+ // and does not have to require heavier packages. A second copy of the fixed
373
+ // build-output directory name lives in:
374
+ // - packages/core/app/client-v2/rsbuild.config.ts (output.distPath)
375
+ // - packages/core/server/src/gateway/index.ts (MODERN_CLIENT_DIST_DIR)
376
+ // Keep them in sync. See docs/adr/0001-modern-client-prefix.md.
377
+ const DEFAULT_MODERN_CLIENT_PREFIX = 'v';
378
+
379
+ exports.DEFAULT_MODERN_CLIENT_PREFIX = DEFAULT_MODERN_CLIENT_PREFIX;
380
+
381
+ // Normalize APP_MODERN_CLIENT_PREFIX (accepts `v`, `/v`, `/v/`)
382
+ // down to a bare segment like `v`.
383
+ function normalizeModernClientPrefix(value) {
384
+ const segment = String(value || '')
385
+ .trim()
386
+ .replace(/^\/+|\/+$/g, '');
387
+ return segment || DEFAULT_MODERN_CLIENT_PREFIX;
388
+ }
389
+
390
+ exports.normalizeModernClientPrefix = normalizeModernClientPrefix;
391
+
370
392
  function resolveV2PublicPath(appPublicPath = '/') {
371
393
  const publicPath = resolvePublicPath(appPublicPath);
372
- return `${publicPath.replace(/\/$/, '')}/v2/`;
394
+ const prefix = normalizeModernClientPrefix(process.env.APP_MODERN_CLIENT_PREFIX);
395
+ return `${publicPath.replace(/\/$/, '')}/${prefix}/`;
373
396
  }
374
397
 
375
398
  exports.resolveV2PublicPath = resolveV2PublicPath;
@@ -533,6 +556,7 @@ exports.initEnv = function initEnv() {
533
556
  APP_BASE_URL: '',
534
557
  CDN_BASE_URL: '',
535
558
  APP_PUBLIC_PATH: '/',
559
+ APP_MODERN_CLIENT_PREFIX: DEFAULT_MODERN_CLIENT_PREFIX,
536
560
  ESM_CDN_BASE_URL: 'https://esm.sh',
537
561
  ESM_CDN_SUFFIX: '',
538
562
  };