@nocobase/cli 2.1.0-beta.42 → 2.1.0-beta.42-test.2

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.
@@ -10,6 +10,7 @@ import fs from 'node:fs/promises';
10
10
  import path from 'node:path';
11
11
  import { fileURLToPath } from 'node:url';
12
12
  import { confirm } from "./inquirer.js";
13
+ import { DEFAULT_UPDATE_POLICY, getExplicitCliConfigValue, loadCliConfig, } from './cli-config.js';
13
14
  import { inspectSelfInstall, inspectSelfStatus, } from './self-manager.js';
14
15
  import { inspectSkillsStatus } from './skills-manager.js';
15
16
  import { resolveCliHomeDir } from './cli-home.js';
@@ -83,39 +84,53 @@ async function writeCurrentInstallEntry(updater) {
83
84
  const state = await readState();
84
85
  const installBinPath = getCurrentInstallBinPath();
85
86
  const nextEntry = updater(getCurrentInstallEntry(state), state);
87
+ const entries = {
88
+ ...(state.entries ?? {}),
89
+ };
90
+ if (nextEntry?.policy || nextEntry?.lastCheckedDate) {
91
+ entries[installBinPath] = nextEntry;
92
+ }
93
+ else {
94
+ delete entries[installBinPath];
95
+ }
86
96
  await writeState({
87
97
  ...state,
88
- entries: {
89
- ...(state.entries ?? {}),
90
- [installBinPath]: nextEntry,
91
- },
98
+ entries: Object.keys(entries).length ? entries : undefined,
92
99
  });
93
100
  }
94
101
  async function markChecked(now = new Date()) {
95
- await writeCurrentInstallEntry((current, state) => {
102
+ await writeCurrentInstallEntry((current) => {
96
103
  return {
97
- policy: current?.policy ?? 'daily',
104
+ ...current,
98
105
  lastCheckedDate: todayStamp(now),
99
106
  };
100
107
  });
101
108
  }
102
- async function disableStartupUpdateForCurrentInstall() {
103
- await writeCurrentInstallEntry((current, state) => {
104
- return {
105
- policy: 'disabled',
106
- lastCheckedDate: current?.lastCheckedDate
107
- ?? state.lastCheckedDate,
108
- };
109
- });
109
+ function resolveLegacyStartupUpdatePolicy(state) {
110
+ const policy = getCurrentInstallEntry(state)?.policy;
111
+ if (policy === 'disabled') {
112
+ return 'off';
113
+ }
114
+ if (policy === 'daily') {
115
+ return 'prompt';
116
+ }
117
+ return undefined;
110
118
  }
111
- async function enableDailyStartupUpdateForCurrentInstall() {
112
- await writeCurrentInstallEntry((current, state) => {
113
- return {
114
- policy: 'daily',
115
- lastCheckedDate: current?.lastCheckedDate
116
- ?? state.lastCheckedDate,
117
- };
118
- });
119
+ async function resolveStartupUpdatePolicy(state) {
120
+ const config = await loadCliConfig({ scope: 'global' });
121
+ const explicit = getExplicitCliConfigValue(config, 'update.policy');
122
+ return explicit ?? resolveLegacyStartupUpdatePolicy(state) ?? DEFAULT_UPDATE_POLICY;
123
+ }
124
+ export async function clearLegacyStartupUpdatePolicyForCurrentInstall() {
125
+ const state = await readState();
126
+ const current = getCurrentInstallEntry(state);
127
+ if (!current?.policy) {
128
+ return false;
129
+ }
130
+ await writeCurrentInstallEntry(() => ({
131
+ lastCheckedDate: current.lastCheckedDate,
132
+ }));
133
+ return true;
119
134
  }
120
135
  export async function shouldRunStartupUpdateCheck(argv, now = new Date()) {
121
136
  if (process.env[NB_SKIP_STARTUP_UPDATE_ENV] === '1') {
@@ -125,19 +140,14 @@ export async function shouldRunStartupUpdateCheck(argv, now = new Date()) {
125
140
  return false;
126
141
  }
127
142
  const state = await readState();
128
- const currentEntry = getCurrentInstallEntry(state);
129
- if (currentEntry?.policy === 'disabled') {
143
+ const policy = await resolveStartupUpdatePolicy(state);
144
+ if (policy === 'off') {
130
145
  return false;
131
146
  }
132
- if (currentEntry?.policy === 'daily') {
133
- return readCurrentInstallLastCheckedDate(state) !== todayStamp(now);
134
- }
135
147
  const selfInstall = await inspectSelfInstall();
136
148
  if (!shouldEnableStartupUpdateForInstallMethod(selfInstall.installMethod)) {
137
- await disableStartupUpdateForCurrentInstall();
138
149
  return false;
139
150
  }
140
- await enableDailyStartupUpdateForCurrentInstall();
141
151
  return readCurrentInstallLastCheckedDate(state) !== todayStamp(now);
142
152
  }
143
153
  export function shouldEnableStartupUpdateForInstallMethod(installMethod) {
@@ -189,14 +199,13 @@ function buildPromptMessage(selfStatus, skillsStatus) {
189
199
  return lines.join('\n');
190
200
  }
191
201
  function buildUpdateCommands(selfStatus, skillsStatus) {
192
- const commands = [];
193
202
  if (selfStatus.updateAvailable && selfStatus.updatable) {
194
- commands.push('nb self update --yes');
203
+ return [skillsStatus.updateAvailable === true ? 'nb self update --yes --skills' : 'nb self update --yes'];
195
204
  }
196
205
  if (skillsStatus.updateAvailable === true) {
197
- commands.push('nb skills update --yes');
206
+ return ['nb skills update --yes'];
198
207
  }
199
- return commands;
208
+ return [];
200
209
  }
201
210
  function buildNonInteractiveWarning(selfStatus, skillsStatus) {
202
211
  const commands = buildUpdateCommands(selfStatus, skillsStatus);
@@ -233,26 +242,36 @@ function buildDeclinedWarning(selfStatus, skillsStatus) {
233
242
  'You may run into compatibility issues until you update.',
234
243
  ].join(' ');
235
244
  }
236
- async function runStartupUpdates() {
237
- await run('nb', ['self', 'update', '--yes'], {
238
- stdio: 'inherit',
239
- env: {
240
- [NB_SKIP_STARTUP_UPDATE_ENV]: '1',
241
- },
242
- errorName: 'nb self update',
243
- });
244
- await run('nb', ['skills', 'update', '--yes'], {
245
- stdio: 'inherit',
246
- env: {
247
- [NB_SKIP_STARTUP_UPDATE_ENV]: '1',
248
- },
249
- errorName: 'nb skills update',
250
- });
245
+ async function runStartupUpdates(selfStatus, skillsStatus) {
246
+ if (selfStatus.updateAvailable && selfStatus.updatable) {
247
+ const args = ['self', 'update', '--yes'];
248
+ if (skillsStatus.updateAvailable === true) {
249
+ args.push('--skills');
250
+ }
251
+ await run('nb', args, {
252
+ stdio: 'inherit',
253
+ env: {
254
+ [NB_SKIP_STARTUP_UPDATE_ENV]: '1',
255
+ },
256
+ errorName: 'nb self update',
257
+ });
258
+ return;
259
+ }
260
+ if (skillsStatus.updateAvailable === true) {
261
+ await run('nb', ['skills', 'update', '--yes'], {
262
+ stdio: 'inherit',
263
+ env: {
264
+ [NB_SKIP_STARTUP_UPDATE_ENV]: '1',
265
+ },
266
+ errorName: 'nb skills update',
267
+ });
268
+ }
251
269
  }
252
- export async function maybeRunStartupUpdatePrompt(argv) {
270
+ export async function maybeRunStartupUpdate(argv) {
253
271
  if (!(await shouldRunStartupUpdateCheck(argv))) {
254
272
  return { kind: 'skipped' };
255
273
  }
274
+ const policy = await resolveStartupUpdatePolicy(await readState());
256
275
  const selfStatus = await inspectSelfStatus();
257
276
  const skillsStatus = await inspectSkillsStatus();
258
277
  if (!hasPendingUpdates(selfStatus, skillsStatus)) {
@@ -264,6 +283,11 @@ export async function maybeRunStartupUpdatePrompt(argv) {
264
283
  await markChecked();
265
284
  return { kind: 'warned' };
266
285
  }
286
+ if (policy === 'auto') {
287
+ await runStartupUpdates(selfStatus, skillsStatus);
288
+ await markChecked();
289
+ return { kind: 'updated' };
290
+ }
267
291
  let answer = false;
268
292
  try {
269
293
  answer = await confirm({
@@ -279,7 +303,7 @@ export async function maybeRunStartupUpdatePrompt(argv) {
279
303
  await markChecked();
280
304
  return { kind: 'declined' };
281
305
  }
282
- await runStartupUpdates();
306
+ await runStartupUpdates(selfStatus, skillsStatus);
283
307
  await markChecked();
284
308
  return { kind: 'updated' };
285
309
  }
@@ -370,6 +370,12 @@
370
370
  "description": "Set up the first admin."
371
371
  }
372
372
  }
373
+ },
374
+ "env": {
375
+ "messages": {
376
+ "noEnvsConfigured": "No envs configured.",
377
+ "noEnvsConfiguredHelp": "Run `nb init --ui` to create one first."
378
+ }
373
379
  }
374
380
  },
375
381
  "apiCommandCompat": {
@@ -370,6 +370,12 @@
370
370
  "description": "设置第一个管理员账号。"
371
371
  }
372
372
  }
373
+ },
374
+ "env": {
375
+ "messages": {
376
+ "noEnvsConfigured": "尚未配置任何 env。",
377
+ "noEnvsConfiguredHelp": "请先运行 `nb init --ui` 创建一个。"
378
+ }
373
379
  }
374
380
  },
375
381
  "apiCommandCompat": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "2.1.0-beta.42",
3
+ "version": "2.1.0-beta.42-test.2",
4
4
  "description": "NocoBase Command Line Tool",
5
5
  "type": "module",
6
6
  "main": "dist/generated/command-registry.js",
@@ -139,6 +139,5 @@
139
139
  "repository": {
140
140
  "type": "git",
141
141
  "url": "git+https://github.com/nocobase/nocobase.git"
142
- },
143
- "gitHead": "619b4d06c934bf3266ba7f388438db018217c87d"
142
+ }
144
143
  }
package/LICENSE.txt DELETED
@@ -1,107 +0,0 @@
1
- Updated Date: February 24, 2026
2
-
3
- NocoBase License Agreement
4
-
5
- NOCOBASE PTE. LTD.,a Singaporean Exempt Private Company Limited by Shares with its principal place of business located at 112 ROBINSON ROAD, #03-01, SINGAPORE ("The Company") https://www.nocobase.com/ issues this License Agreement ("Agreement") to you. You, as an individual or a company ("The User"), will be deemed to voluntarily accept all terms of this Agreement by using NocoBase (including but not limited to obtaining NocoBase source code or installation package in any form, installing and using NocoBase, purchasing NocoBase commercial license and services, purchasing NocoBase commercial plugins). If the User does not agree to any term of this Agreement, or cannot accurately understand our interpretation of the relevant terms, please stop using it immediately.
6
-
7
- This Agreement applies to any use, quotation, contract, invoice, and all software delivered by the Company. The User and the Company or NocoBase's agents can no longer sign a separate license agreement for the sale and delivery of the software.
8
-
9
- The Company reserves the right to formulate and modify this Agreement from time to time as needed. If there are changes, the Company will announce them in the form of website announcements, without further individual notification. The changed Agreement will automatically take effect once it is announced, becoming part of this Agreement.
10
-
11
- ==============
12
- 1. Definitions
13
- ==============
14
-
15
- 1.1 "Software" refers to the NocoBase kernel and plugins placed in the same code repository as the kernel, including their source code, installation packages, images, and all their modifications, updates, and upgrades.
16
-
17
- 1.2 "Community Edition" refers to the free version of the Software provided to the User through public channels.
18
-
19
- 1.3 "Commercial Edition" refers to the paid version of the Software purchased by the User from the Company or its agents, downloaded through exclusive channels, and includes additional benefits. It consists of three versions: Standard Edition, Professional Edition, and Enterprise Edition.
20
-
21
- 1.4 "Upper Layer Application" refers to a specific business use case application serving internal or external customers of the User, developed based on Software and Commercial Plugins, such as ERP/CRM.
22
-
23
- 1.5 "Customer" refers to the clients who purchase the User's Upper Layer Application.
24
-
25
- 1.6 "Third-Party Open Source Software" refers to open source software provided with Software and Commercial Plugins. They are licensed through various published open source software licenses or copyright notices accompanying such software.
26
-
27
- ===================================
28
- 2. Intellectual Property Protection
29
- ===================================
30
-
31
- Except for Third-Party Open Source Software, the Company owns all copyrights, trademark rights, patent rights, trade secrets, and other intellectual property rights of the Software, and has registered and protected them in relevant countries and regions according to the "Paris Convention" or "TRIPS Agreement", ensuring that the intellectual property rights of the Software and Commercial Plugins are internationally recognized and protected.
32
-
33
- =============
34
- 3. Disclaimer
35
- =============
36
-
37
- 3.1 The User shall not use the Software and Commercial Plugins to engage in activities that contravene applicable laws and regulations or offend against public order or religious prohibitions. All legal liabilities and consequences arising from the User’s use shall be borne by the User.
38
-
39
- 3.2 The Company shall not be liable for any direct, indirect, special, incidental, or consequential damages (including but not limited to loss of profits, business interruption, data loss, or business information disclosure) caused by the User's use of the Software and Commercial Plugins, even if it has been previously informed of the possibility of such damages.
40
-
41
- ===============
42
- 4. License Type
43
- ===============
44
-
45
- 4.1 This Agreement serves as the unified license agreement for NocoBase Software, applying to both the Community Edition and the Commercial Editions.
46
-
47
- 4.2 This Agreement incorporates and references the full text of the Apache License, Version 2.0 ("Apache-2.0", available at: https://www.apache.org/licenses/LICENSE-2.0 ). Users must comply with the Apache-2.0 License as well as the supplementary terms set forth in this Agreement. In case of any inconsistency between Apache-2.0 and this Agreement, the supplementary terms of this Agreement shall prevail.
48
-
49
- ================================================
50
- 5. Rights and Obligations of Open Source License
51
- ================================================
52
-
53
- 5.1 The Software can be used for commercial purposes.
54
-
55
- 5.2 It is not allowed to remove or change the brand, name, link, version number, license, and other information about NocoBase on the Software interface, except for the main LOGO in the upper left corner of the page.
56
-
57
- 5.3 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
58
-
59
- 5.4 It is not allowed to provide to the public any form of no-code, zero-code, low-code, AI platform SaaS/PaaS products using the original or modified Software.
60
-
61
- ===============================
62
- 6. Rights of Commercial License
63
- ===============================
64
-
65
- 6.1 Obtain a permanent commercial license of the Software.
66
-
67
- 6.2 Get software upgrades and exclusive technical support during the upgrade validity period.
68
-
69
- 6.3 The licensed Software can be used for commercial purposes with no restrictions on the number of applications and users.
70
-
71
- 6.4 Can remove or change the brand, name, link, version number, license, and other information about NocoBase on the Software interface.
72
-
73
- 6.5 The User holding a Professional or Enterprise Edition License can sell Upper Layer Application to its Customers.
74
-
75
- 6.6 If there are other agreements in the contract for the above rights, the contract agreement shall prevail.
76
-
77
- ====================================
78
- 7. Obligations of Commercial License
79
- ====================================
80
-
81
- 7.1 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
82
-
83
- 7.2 It is not allowed to sell, transfer, lease, share, gift, or distribute the Commercial License.
84
-
85
- 7.3 It is not allowed to sell, transfer, lease, share, or distribute any form of no-code, zero-code, low-code, AI platform, or developer tools developed based on Software.
86
-
87
- 7.4 It is not allowed to provide any form of no-code, zero-code, low-code, AI platform SaaS/PaaS products to the public using the original or modified Software.
88
-
89
- 7.5 It is not allowed for the User holding a Standard Edition license to sell Upper Layer Application to Customers without a Commercial license.
90
-
91
- 7.6 It is not allowed for the User holding a Professional or Enterprise Edition license to sell Upper Layer Application to Customers without a Commercial license with access to further development and configuration.
92
-
93
- 7.7 If there is a violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
94
-
95
- 7.8 If there are other agreements in the contract for the above obligations, the contract agreement shall prevail.
96
-
97
- =============================================================
98
- 8. Legal Jurisdiction, Interpretation, and Dispute Resolution
99
- =============================================================
100
-
101
- 8.1 Except for Mainland China, the interpretation, application, and all matters related to this agreement are subject to the jurisdiction of Singapore law.
102
-
103
- 8.2 Any dispute related to this Agreement should first be resolved through friendly negotiation. If the negotiation fails to resolve the dispute, the dispute should be submitted to the International Chamber of Commerce (ICC) for arbitration. The arbitration venue should be Singapore, conducted in English.
104
-
105
- 8.3 All terms and conditions of this Agreement shall be deemed enforceable to the maximum extent permitted by applicable law. If any term of this Agreement is deemed invalid by any applicable law, the invalidity of that term does not affect the validity of any other term of this Agreement, and it should be deemed that the invalid term has been modified as much as possible to make it valid and enforceable, or if the term cannot be modified, it should be deemed to have been deleted from this Agreement.
106
-
107
- 8.4 The arbitration award is final, binding on both parties, and can be enforced in any court with jurisdiction.