@nocobase/cli 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/bin/run.js +6 -35
- package/dist/commands/app/restart.js +12 -5
- package/dist/commands/app/start.js +1 -0
- package/dist/commands/app/upgrade.js +2 -2
- package/dist/commands/config/delete.js +4 -1
- package/dist/commands/config/get.js +1 -0
- package/dist/commands/config/set.js +6 -1
- package/dist/commands/db/ps.js +5 -18
- package/dist/commands/env/auth.js +1 -1
- package/dist/commands/env/list.js +4 -5
- package/dist/commands/env/status.js +10 -7
- package/dist/commands/init.js +18 -0
- package/dist/commands/install.js +53 -29
- package/dist/commands/self/update.js +58 -1
- package/dist/commands/source/dev.js +5 -5
- package/dist/lib/app-health.js +34 -27
- package/dist/lib/app-managed-resources.js +1 -1
- package/dist/lib/app-runtime.js +2 -2
- package/dist/lib/auth-store.js +9 -0
- package/dist/lib/backup.js +3 -3
- package/dist/lib/bootstrap.js +14 -8
- package/dist/lib/cli-config.js +38 -0
- package/dist/lib/cli-entry-error.js +44 -0
- package/dist/lib/docker-log-stream.js +45 -0
- package/dist/lib/env-auth.js +21 -13
- package/dist/lib/source-publish.js +4 -1
- package/dist/lib/startup-update.js +74 -50
- package/dist/locale/en-US.json +6 -0
- package/dist/locale/zh-CN.json +6 -0
- package/package.json +2 -2
|
@@ -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
|
|
102
|
+
await writeCurrentInstallEntry((current) => {
|
|
96
103
|
return {
|
|
97
|
-
|
|
104
|
+
...current,
|
|
98
105
|
lastCheckedDate: todayStamp(now),
|
|
99
106
|
};
|
|
100
107
|
});
|
|
101
108
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
|
112
|
-
await
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
|
129
|
-
if (
|
|
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
|
-
|
|
203
|
+
return [skillsStatus.updateAvailable === true ? 'nb self update --yes --skills' : 'nb self update --yes'];
|
|
195
204
|
}
|
|
196
205
|
if (skillsStatus.updateAvailable === true) {
|
|
197
|
-
|
|
206
|
+
return ['nb skills update --yes'];
|
|
198
207
|
}
|
|
199
|
-
return
|
|
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
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
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
|
|
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
|
}
|
package/dist/locale/en-US.json
CHANGED
|
@@ -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": {
|
package/dist/locale/zh-CN.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/cli",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.46",
|
|
4
4
|
"description": "NocoBase Command Line Tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/generated/command-registry.js",
|
|
@@ -140,5 +140,5 @@
|
|
|
140
140
|
"type": "git",
|
|
141
141
|
"url": "git+https://github.com/nocobase/nocobase.git"
|
|
142
142
|
},
|
|
143
|
-
"gitHead": "
|
|
143
|
+
"gitHead": "42b269944cdd1908d7a848c0af4936fe94c03bb7"
|
|
144
144
|
}
|