@nocobase/cli-v1 2.2.0-alpha.7 → 2.2.0-beta.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli-v1",
3
- "version": "2.2.0-alpha.7",
3
+ "version": "2.2.0-beta.10",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./src/index.js",
@@ -9,9 +9,9 @@
9
9
  "nocobase-v1": "./bin/index.js"
10
10
  },
11
11
  "dependencies": {
12
- "@nocobase/cli": "2.2.0-alpha.7",
12
+ "@nocobase/cli": "2.2.0-beta.10",
13
13
  "@nocobase/license-kit": "^0.3.8",
14
- "@nocobase/utils": "2.2.0-alpha.7",
14
+ "@nocobase/utils": "2.2.0-beta.10",
15
15
  "chalk": "^4.1.1",
16
16
  "commander": "^9.2.0",
17
17
  "deepmerge": "^4.3.1",
@@ -33,5 +33,5 @@
33
33
  "url": "git+https://github.com/nocobase/nocobase.git",
34
34
  "directory": "packages/core/cli"
35
35
  },
36
- "gitHead": "34ba02960fca9ab0b6881d3db7040a8a64067bba"
36
+ "gitHead": "d572beec24de46df948f28db72b25303a63bf62d"
37
37
  }
@@ -24,8 +24,6 @@ function createAppPackageRoot() {
24
24
  [
25
25
  "window['__nocobase_app_dev__'] = {{env.NOCOBASE_APP_DEV}};",
26
26
  "window['__nocobase_public_path__'] = '{{env.APP_PUBLIC_PATH}}';",
27
- "window['__nocobase_modern_client_prefix__'] = '{{env.APP_MODERN_CLIENT_PREFIX}}';",
28
- "window['__nocobase_app_client_entry_mode__'] = '{{env.APP_CLIENT_ENTRY_MODE}}';",
29
27
  ].join('\n'),
30
28
  'utf-8',
31
29
  );
@@ -75,43 +73,11 @@ describe('cli-v1 buildIndexHtml', () => {
75
73
  process.env.APP_PACKAGE_ROOT = appRoot;
76
74
  process.env.APP_PUBLIC_PATH = '/';
77
75
  process.env.NOCOBASE_APP_DEV = '';
78
- process.env.APP_MODERN_CLIENT_PREFIX = 'console';
79
- process.env.APP_CLIENT_ENTRY_MODE = 'modern-default';
80
76
 
81
77
  buildIndexHtml();
82
78
 
83
79
  const html = fs.readFileSync(path.join(appRoot, 'dist/client/index.html'), 'utf-8');
84
80
  expect(html).toContain("window['__nocobase_app_dev__'] = false;");
85
- expect(html).toContain("window['__nocobase_modern_client_prefix__'] = 'console';");
86
- expect(html).toContain("window['__nocobase_app_client_entry_mode__'] = 'modern-default';");
87
- fs.removeSync(appRoot);
88
- });
89
-
90
- test('refreshes cached tpl when new runtime placeholders are missing', () => {
91
- const appRoot = createAppPackageRoot();
92
- const tplPath = path.join(appRoot, 'dist/client/index.html.tpl');
93
- const indexPath = path.join(appRoot, 'dist/client/index.html');
94
- fs.writeFileSync(tplPath, "window['__nocobase_public_path__'] = '{{env.APP_PUBLIC_PATH}}';", 'utf-8');
95
- fs.writeFileSync(
96
- indexPath,
97
- [
98
- "window['__nocobase_public_path__'] = '{{env.APP_PUBLIC_PATH}}';",
99
- "window['__nocobase_modern_client_prefix__'] = '{{env.APP_MODERN_CLIENT_PREFIX}}';",
100
- "window['__nocobase_app_client_entry_mode__'] = '{{env.APP_CLIENT_ENTRY_MODE}}';",
101
- ].join('\n'),
102
- 'utf-8',
103
- );
104
- process.argv = ['node', 'nocobase-v1', 'start'];
105
- process.env.APP_PACKAGE_ROOT = appRoot;
106
- process.env.APP_PUBLIC_PATH = '/';
107
- process.env.APP_MODERN_CLIENT_PREFIX = 'v';
108
- process.env.APP_CLIENT_ENTRY_MODE = 'modern-only';
109
-
110
- buildIndexHtml();
111
-
112
- const tpl = fs.readFileSync(tplPath, 'utf-8');
113
- expect(tpl).toContain('__nocobase_modern_client_prefix__');
114
- expect(tpl).toContain('__nocobase_app_client_entry_mode__');
115
81
  fs.removeSync(appRoot);
116
82
  });
117
83
  });
@@ -9,7 +9,7 @@
9
9
 
10
10
  /* eslint-env jest */
11
11
 
12
- const { buildAppDevForwardArgs, forwardDevToAppDev, resolveDevRuntimeMode } = require('../commands/dev')._test;
12
+ const { buildAppDevForwardArgs, forwardDevToAppDev } = require('../commands/dev')._test;
13
13
 
14
14
  describe('cli-v1 dev command', () => {
15
15
  test('buildAppDevForwardArgs rewrites dev argv to app-dev while preserving extra args', () => {
@@ -31,31 +31,4 @@ describe('cli-v1 dev command', () => {
31
31
 
32
32
  expect(calls).toEqual([['nocobase-v1', ['app-dev', '--port', '13000', '--db-sync']]]);
33
33
  });
34
-
35
- test('resolveDevRuntimeMode keeps both clients in legacy-default', () => {
36
- expect(resolveDevRuntimeMode({ appClientEntryMode: 'legacy-default' })).toMatchObject({
37
- useModernOnlyEntryMode: false,
38
- shouldRunClient: true,
39
- shouldRunClientV2: true,
40
- shouldRunServer: true,
41
- });
42
- });
43
-
44
- test('resolveDevRuntimeMode only runs v2 client and server in modern-only', () => {
45
- expect(resolveDevRuntimeMode({ appClientEntryMode: 'modern-only' })).toMatchObject({
46
- useModernOnlyEntryMode: true,
47
- shouldRunClient: false,
48
- shouldRunClientV2: true,
49
- shouldRunServer: true,
50
- });
51
- });
52
-
53
- test('resolveDevRuntimeMode preserves explicit client-v2-only flag behavior', () => {
54
- expect(resolveDevRuntimeMode({ clientV2Only: true, appClientEntryMode: 'legacy-default' })).toMatchObject({
55
- useModernOnlyEntryMode: false,
56
- shouldRunClient: false,
57
- shouldRunClientV2: true,
58
- shouldRunServer: false,
59
- });
60
- });
61
34
  });
@@ -20,7 +20,6 @@ const {
20
20
  isPortReachable,
21
21
  buildWSURL,
22
22
  checkDBDialect,
23
- resolveAppClientEntryMode,
24
23
  } = require('../util');
25
24
  const { getPortPromise } = require('portfinder');
26
25
  const chokidar = require('chokidar');
@@ -48,25 +47,6 @@ function buildAppDevForwardArgs(argv = process.argv) {
48
47
  return ['app-dev', ...argv.slice(3)];
49
48
  }
50
49
 
51
- function resolveDevRuntimeMode(opts = {}) {
52
- const appClientEntryMode = opts.appClientEntryMode || resolveAppClientEntryMode();
53
- const useModernOnlyEntryMode = appClientEntryMode === 'modern-only';
54
- const clientV2Only = !!opts.clientV2Only;
55
- const forceClient = !!opts.client;
56
- const forceServer = !!opts.server;
57
- const shouldRunClientV2 = clientV2Only || useModernOnlyEntryMode || forceClient || !forceServer;
58
- const shouldRunClient = !clientV2Only && !useModernOnlyEntryMode && (forceClient || !forceServer);
59
- const shouldRunServer = !clientV2Only && (forceServer || !forceClient || useModernOnlyEntryMode);
60
-
61
- return {
62
- appClientEntryMode,
63
- useModernOnlyEntryMode,
64
- shouldRunClientV2,
65
- shouldRunClient,
66
- shouldRunServer,
67
- };
68
- }
69
-
70
50
  async function forwardDevToAppDev({ argv = process.argv, runCommand = run } = {}) {
71
51
  await runCommand('nocobase-v1', buildAppDevForwardArgs(argv));
72
52
  }
@@ -127,9 +107,9 @@ module.exports = (cli) => {
127
107
  nodeCheck();
128
108
  await postCheck(opts);
129
109
 
130
- const { useModernOnlyEntryMode, shouldRunClientV2, shouldRunClient, shouldRunServer } = resolveDevRuntimeMode(
131
- opts,
132
- );
110
+ const shouldRunClientV2 = clientV2Only || client || !server;
111
+ const shouldRunClient = !clientV2Only && (client || !server);
112
+ const shouldRunServer = !clientV2Only && (server || !client);
133
113
  const shouldRunClientWithRsbuild = shouldRunClient && !!rsbuild;
134
114
 
135
115
  if (shouldRunServer && server) {
@@ -140,16 +120,12 @@ module.exports = (cli) => {
140
120
  });
141
121
  }
142
122
 
143
- if (shouldRunClientV2 && !clientV2Only && !useModernOnlyEntryMode) {
123
+ if (shouldRunClientV2 && !clientV2Only) {
144
124
  clientV2Port = await getPortPromise({
145
125
  port: 1 * clientPort + 2,
146
126
  });
147
127
  }
148
128
 
149
- if (useModernOnlyEntryMode) {
150
- clientV2Port = APP_PORT;
151
- }
152
-
153
129
  let subprocessClient;
154
130
  let subprocessClientV2;
155
131
 
@@ -330,5 +306,4 @@ module.exports = (cli) => {
330
306
  module.exports._test = {
331
307
  buildAppDevForwardArgs,
332
308
  forwardDevToAppDev,
333
- resolveDevRuntimeMode,
334
309
  };
package/src/util.js CHANGED
@@ -432,30 +432,6 @@ const DEFAULT_MODERN_CLIENT_PREFIX = 'v';
432
432
 
433
433
  exports.DEFAULT_MODERN_CLIENT_PREFIX = DEFAULT_MODERN_CLIENT_PREFIX;
434
434
 
435
- const DEFAULT_APP_CLIENT_ENTRY_MODE = 'legacy-default';
436
- const APP_CLIENT_ENTRY_MODES = new Set(['legacy-default', 'modern-default', 'modern-only']);
437
-
438
- exports.DEFAULT_APP_CLIENT_ENTRY_MODE = DEFAULT_APP_CLIENT_ENTRY_MODE;
439
-
440
- function isAppClientEntryMode(value) {
441
- return APP_CLIENT_ENTRY_MODES.has(String(value || '').trim());
442
- }
443
-
444
- exports.isAppClientEntryMode = isAppClientEntryMode;
445
-
446
- function normalizeAppClientEntryMode(value) {
447
- const normalized = String(value || '').trim();
448
- return isAppClientEntryMode(normalized) ? normalized : DEFAULT_APP_CLIENT_ENTRY_MODE;
449
- }
450
-
451
- exports.normalizeAppClientEntryMode = normalizeAppClientEntryMode;
452
-
453
- function resolveAppClientEntryMode() {
454
- return normalizeAppClientEntryMode(process.env.APP_CLIENT_ENTRY_MODE);
455
- }
456
-
457
- exports.resolveAppClientEntryMode = resolveAppClientEntryMode;
458
-
459
435
  // Normalize APP_MODERN_CLIENT_PREFIX (accepts `v`, `/v`, `/v/`)
460
436
  // down to a bare segment like `v`.
461
437
  function normalizeModernClientPrefix(value) {
@@ -479,13 +455,6 @@ function isAppDevHtml() {
479
455
  return process.argv[2] === 'app-dev' || process.env.NOCOBASE_APP_DEV === 'true';
480
456
  }
481
457
 
482
- function shouldRefreshLegacyIndexTemplate(data = '') {
483
- return (
484
- !data.includes("window['__nocobase_modern_client_prefix__']") ||
485
- !data.includes("window['__nocobase_app_client_entry_mode__']")
486
- );
487
- }
488
-
489
458
  function buildIndexHtml(force = false) {
490
459
  if (process.env.NOCOBASE_EXTRACT_CLIENT_ASSETS === 'true') {
491
460
  return;
@@ -500,15 +469,11 @@ function buildIndexHtml(force = false) {
500
469
  }
501
470
  if (!fs.existsSync(tpl)) {
502
471
  fs.copyFileSync(file, tpl);
503
- } else if (shouldRefreshLegacyIndexTemplate(fs.readFileSync(tpl, 'utf-8'))) {
504
- fs.copyFileSync(file, tpl);
505
472
  }
506
473
  const data = fs.readFileSync(tpl, 'utf-8');
507
474
  let replacedData = data
508
475
  .replace(/\{\{env.CDN_BASE_URL\}\}/g, process.env.CDN_BASE_URL)
509
476
  .replace(/\{\{env.APP_PUBLIC_PATH\}\}/g, process.env.APP_PUBLIC_PATH)
510
- .replace(/\{\{env.APP_MODERN_CLIENT_PREFIX\}\}/g, normalizeModernClientPrefix(process.env.APP_MODERN_CLIENT_PREFIX))
511
- .replace(/\{\{env.APP_CLIENT_ENTRY_MODE\}\}/g, resolveAppClientEntryMode())
512
477
  .replace(/\{\{env.API_CLIENT_SHARE_TOKEN\}\}/g, process.env.API_CLIENT_SHARE_TOKEN || 'false')
513
478
  .replace(/\{\{env.API_CLIENT_STORAGE_TYPE\}\}/g, process.env.API_CLIENT_STORAGE_TYPE)
514
479
  .replace(/\{\{env.API_CLIENT_STORAGE_PREFIX\}\}/g, process.env.API_CLIENT_STORAGE_PREFIX)
@@ -649,7 +614,6 @@ exports.initEnv = function initEnv() {
649
614
  CDN_BASE_URL: '',
650
615
  APP_PUBLIC_PATH: '/',
651
616
  APP_MODERN_CLIENT_PREFIX: DEFAULT_MODERN_CLIENT_PREFIX,
652
- APP_CLIENT_ENTRY_MODE: DEFAULT_APP_CLIENT_ENTRY_MODE,
653
617
  ESM_CDN_BASE_URL: 'https://esm.sh',
654
618
  ESM_CDN_SUFFIX: '',
655
619
  };
@@ -701,14 +665,6 @@ exports.initEnv = function initEnv() {
701
665
  }
702
666
  }
703
667
 
704
- const rawAppClientEntryMode = String(process.env.APP_CLIENT_ENTRY_MODE || '').trim();
705
- if (rawAppClientEntryMode && !isAppClientEntryMode(rawAppClientEntryMode)) {
706
- console.warn(
707
- `Unknown APP_CLIENT_ENTRY_MODE "${rawAppClientEntryMode}", falling back to ${DEFAULT_APP_CLIENT_ENTRY_MODE}.`,
708
- );
709
- }
710
- process.env.APP_CLIENT_ENTRY_MODE = normalizeAppClientEntryMode(rawAppClientEntryMode);
711
-
712
668
  if (!process.env.__env_modified__ && process.env.APP_PUBLIC_PATH) {
713
669
  const publicPath = process.env.APP_PUBLIC_PATH.replace(/\/$/g, '');
714
670
  const keys = ['API_BASE_PATH', 'WS_PATH', 'PLUGIN_STATICS_PATH'];