@nocobase/cli 2.1.0-beta.24 → 2.1.0-beta.25

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 (58) hide show
  1. package/README.md +19 -0
  2. package/dist/commands/app/down.js +12 -6
  3. package/dist/commands/app/logs.js +2 -2
  4. package/dist/commands/app/start.js +2 -1
  5. package/dist/commands/app/stop.js +2 -1
  6. package/dist/commands/app/upgrade.js +116 -129
  7. package/dist/commands/config/delete.js +30 -0
  8. package/dist/commands/config/get.js +29 -0
  9. package/dist/commands/config/index.js +20 -0
  10. package/dist/commands/config/list.js +29 -0
  11. package/dist/commands/config/set.js +35 -0
  12. package/dist/commands/db/check.js +171 -65
  13. package/dist/commands/db/logs.js +2 -2
  14. package/dist/commands/db/shared.js +6 -5
  15. package/dist/commands/db/start.js +2 -1
  16. package/dist/commands/db/stop.js +2 -1
  17. package/dist/commands/env/info.js +6 -2
  18. package/dist/commands/env/shared.js +1 -1
  19. package/dist/commands/install.js +50 -35
  20. package/dist/commands/license/activate.js +360 -0
  21. package/dist/commands/license/env.js +94 -0
  22. package/dist/commands/license/generate-id.js +108 -0
  23. package/dist/commands/license/id.js +56 -0
  24. package/dist/commands/license/index.js +20 -0
  25. package/dist/commands/license/plugins/clean.js +101 -0
  26. package/dist/commands/license/plugins/index.js +20 -0
  27. package/dist/commands/license/plugins/list.js +50 -0
  28. package/dist/commands/license/plugins/shared.js +325 -0
  29. package/dist/commands/license/plugins/sync.js +269 -0
  30. package/dist/commands/license/shared.js +414 -0
  31. package/dist/commands/license/status.js +50 -0
  32. package/dist/commands/plugin/disable.js +2 -0
  33. package/dist/commands/plugin/enable.js +2 -0
  34. package/dist/commands/source/dev.js +2 -1
  35. package/dist/lib/api-client.js +74 -3
  36. package/dist/lib/app-managed-resources.js +10 -6
  37. package/dist/lib/app-runtime.js +29 -11
  38. package/dist/lib/auth-store.js +36 -68
  39. package/dist/lib/bootstrap.js +0 -4
  40. package/dist/lib/build-config.js +8 -0
  41. package/dist/lib/builtin-db.js +86 -0
  42. package/dist/lib/cli-config.js +176 -0
  43. package/dist/lib/cli-home.js +6 -21
  44. package/dist/lib/env-config.js +7 -0
  45. package/dist/lib/generated-command.js +24 -3
  46. package/dist/lib/plugin-storage.js +127 -0
  47. package/dist/lib/prompt-validators.js +4 -4
  48. package/dist/lib/run-npm.js +53 -0
  49. package/dist/lib/runtime-env-vars.js +32 -0
  50. package/dist/lib/runtime-generator.js +89 -10
  51. package/dist/lib/self-manager.js +57 -2
  52. package/dist/lib/skills-manager.js +2 -2
  53. package/dist/lib/startup-update.js +81 -6
  54. package/dist/lib/ui.js +3 -0
  55. package/dist/locale/en-US.json +0 -4
  56. package/dist/locale/zh-CN.json +0 -4
  57. package/nocobase-ctl.config.json +82 -0
  58. package/package.json +13 -4
@@ -1,3 +1,11 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
1
9
  /**
2
10
  * This file is part of the NocoBase (R) project.
3
11
  * Copyright (c) 2020-2024 NocoBase Co., Ltd.
@@ -60,12 +68,59 @@ function toGeneratedParameter(parameter, usedFlagNames) {
60
68
  required: parameter.required,
61
69
  description: parameter.description,
62
70
  type: inferParameterType(parameter.schema),
71
+ format: parameter.schema?.format,
63
72
  isArray: parameter.schema?.type === 'array',
73
+ isFile: parameter.schema?.type === 'string' && parameter.schema?.format === 'binary',
64
74
  };
65
75
  }
66
76
  function getJsonRequestSchema(requestBody) {
67
77
  return requestBody?.content?.['application/json']?.schema;
68
78
  }
79
+ function getMultipartRequestSchema(requestBody) {
80
+ return requestBody?.content?.['multipart/form-data']?.schema;
81
+ }
82
+ function getRequestContentType(requestBody) {
83
+ if (!requestBody || '$ref' in requestBody) {
84
+ return undefined;
85
+ }
86
+ if (requestBody.content?.['multipart/form-data']) {
87
+ return 'multipart/form-data';
88
+ }
89
+ if (requestBody.content?.['application/json']) {
90
+ return 'application/json';
91
+ }
92
+ return undefined;
93
+ }
94
+ function getRequestSchema(requestBody) {
95
+ return getMultipartRequestSchema(requestBody) ?? getJsonRequestSchema(requestBody);
96
+ }
97
+ function isBinarySchema(schema) {
98
+ if (!schema || typeof schema !== 'object') {
99
+ return false;
100
+ }
101
+ if (schema.type === 'string' && schema.format === 'binary') {
102
+ return true;
103
+ }
104
+ return [...(schema.oneOf ?? []), ...(schema.anyOf ?? []), ...(schema.allOf ?? [])].some(isBinarySchema);
105
+ }
106
+ function getResponseType(operation) {
107
+ for (const response of Object.values(operation.responses ?? {})) {
108
+ const content = response?.content ?? {};
109
+ const mediaTypes = Object.keys(content);
110
+ const hasJson = mediaTypes.some((mediaType) => mediaType.includes('json'));
111
+ if (hasJson) {
112
+ return 'json';
113
+ }
114
+ const hasBinary = mediaTypes.some((mediaType) => {
115
+ const schema = content[mediaType]?.schema;
116
+ return mediaType === 'application/octet-stream' || mediaType.includes('zip') || isBinarySchema(schema);
117
+ });
118
+ if (hasBinary) {
119
+ return 'binary';
120
+ }
121
+ }
122
+ return undefined;
123
+ }
69
124
  function normalizeCompositeSchema(schema) {
70
125
  if (!schema || typeof schema !== 'object') {
71
126
  return schema;
@@ -139,7 +194,7 @@ function describeSchemaShape(schema, options = {}) {
139
194
  return type;
140
195
  }
141
196
  function extractBodyParameters(requestBody, usedFlagNames) {
142
- const schema = getJsonRequestSchema(requestBody);
197
+ const schema = getRequestSchema(requestBody);
143
198
  const properties = normalizeCompositeSchema(schema)?.properties;
144
199
  const required = new Set(normalizeCompositeSchema(schema)?.required ?? []);
145
200
  return Object.entries(properties ?? {}).map(([name, propertySchema]) => ({
@@ -149,7 +204,9 @@ function extractBodyParameters(requestBody, usedFlagNames) {
149
204
  required: required.has(name),
150
205
  description: propertySchema.description,
151
206
  type: inferParameterType(propertySchema),
207
+ format: propertySchema.format,
152
208
  isArray: propertySchema.type === 'array',
209
+ isFile: propertySchema.type === 'string' && propertySchema.format === 'binary',
153
210
  jsonEncoded: propertySchema.type === 'object' || propertySchema.type === 'array',
154
211
  jsonShape: describeSchemaShape(propertySchema),
155
212
  }));
@@ -179,6 +236,9 @@ function formatFlagExample(parameter) {
179
236
  if (parameter.type === 'boolean') {
180
237
  return `--${parameter.flagName}`;
181
238
  }
239
+ if (parameter.isFile) {
240
+ return `--${parameter.flagName} <path>`;
241
+ }
182
242
  if (parameter.type === 'object' || parameter.jsonEncoded) {
183
243
  if (parameter.type === 'array' || parameter.isArray) {
184
244
  return `--${parameter.flagName} '[]'`;
@@ -216,12 +276,13 @@ export function buildExamples(commandId, operation) {
216
276
  const requiredParameters = operation.parameters.filter((parameter) => parameter.required);
217
277
  const requiredFlags = requiredParameters.map(formatFlagExample);
218
278
  const requiredNonBodyFlags = requiredParameters.filter((parameter) => parameter.in !== 'body').map(formatFlagExample);
219
- const examples = [`nb api ${commandId}${requiredFlags.length ? ` ${requiredFlags.join(' ')}` : ''}`];
279
+ const outputFlag = operation.responseType === 'binary' ? ' --output <path>' : '';
280
+ const examples = [`nb api ${commandId}${requiredFlags.length ? ` ${requiredFlags.join(' ')}` : ''}${outputFlag}`];
220
281
  const firstOptional = operation.parameters.find((parameter) => !parameter.required);
221
282
  if (firstOptional) {
222
- examples.push(`${examples[0]} ${formatFlagExample(firstOptional)}`);
283
+ examples.push(`${examples[0]} ${formatFlagExample(firstOptional)}`.trim());
223
284
  }
224
- if (operation.hasBody) {
285
+ if (operation.hasBody && operation.requestContentType !== 'multipart/form-data') {
225
286
  const prefix = `nb api ${commandId}${requiredNonBodyFlags.length ? ` ${requiredNonBodyFlags.join(' ')}` : ''}`;
226
287
  examples.push(`${prefix} --body '${buildSampleBody(operation.parameters)}'`);
227
288
  }
@@ -248,9 +309,17 @@ function buildDescription(operation) {
248
309
  }
249
310
  if (operation.hasBody) {
250
311
  const bodyFlags = operation.parameters.filter((parameter) => parameter.in === 'body').map((parameter) => `--${parameter.flagName}`);
251
- sections.push(bodyFlags.length
252
- ? `Request body: use body field flags (${bodyFlags.join(', ')}) or pass raw JSON via \`--body\` / \`--body-file\`.`
253
- : 'Request body: JSON via `--body` or `--body-file`.');
312
+ if (operation.requestContentType === 'multipart/form-data') {
313
+ sections.push(bodyFlags.length ? `Request body: multipart form fields (${bodyFlags.join(', ')}).` : 'Request body: multipart form data.');
314
+ }
315
+ else {
316
+ sections.push(bodyFlags.length
317
+ ? `Request body: use body field flags (${bodyFlags.join(', ')}) or pass raw JSON via \`--body\` / \`--body-file\`.`
318
+ : 'Request body: JSON via `--body` or `--body-file`.');
319
+ }
320
+ }
321
+ if (operation.responseType === 'binary') {
322
+ sections.push('Response body: binary download written to `--output`.');
254
323
  }
255
324
  return sections.join('\n\n');
256
325
  }
@@ -357,6 +426,8 @@ export async function generateRuntime(document, configFile, baseUrl) {
357
426
  const bodyParameters = extractBodyParameters(operation.requestBody, usedFlagNames);
358
427
  const allParameters = [...parameters, ...bodyParameters];
359
428
  const hasBody = Boolean(operation.requestBody && !('$ref' in operation.requestBody));
429
+ const requestContentType = getRequestContentType(operation.requestBody);
430
+ const responseType = getResponseType(operation);
360
431
  const moduleDisplayName = moduleConfig.name ?? moduleKey;
361
432
  const moduleDescription = moduleConfig.description;
362
433
  const resourceDisplayName = resourceConfig?.name ?? resourceKey;
@@ -366,9 +437,11 @@ export async function generateRuntime(document, configFile, baseUrl) {
366
437
  description: operation.description,
367
438
  });
368
439
  const resourceSegments = toResourceSegments(pathTemplate);
369
- const mappedResourceSegments = resourceSegments.length && resourceConfig?.name
370
- ? [toKebabCase(resourceConfig.name), ...resourceSegments.slice(1)]
371
- : resourceSegments;
440
+ const mappedResourceSegments = resourceSegments.length && resourceConfig?.segments?.length
441
+ ? [...resourceConfig.segments.map(toKebabCase), ...resourceSegments.slice(1)]
442
+ : resourceSegments.length && resourceConfig?.name
443
+ ? [toKebabCase(resourceConfig.name), ...resourceSegments.slice(1)]
444
+ : resourceSegments;
372
445
  const segments = [
373
446
  ...(resourceConfig?.topLevel ? [] : [toKebabCase(moduleDisplayName)]),
374
447
  ...mappedResourceSegments,
@@ -397,15 +470,21 @@ export async function generateRuntime(document, configFile, baseUrl) {
397
470
  tags: operation.tags,
398
471
  description: operationText.description,
399
472
  hasBody,
473
+ requestContentType,
474
+ responseType,
400
475
  parameters: allParameters,
401
476
  }),
402
477
  examples: buildExamples(segments.join(' '), {
403
478
  parameters: allParameters,
404
479
  hasBody,
480
+ requestContentType,
481
+ responseType,
405
482
  }),
406
483
  parameters: allParameters,
407
484
  hasBody,
408
485
  bodyRequired: operation.requestBody && !('$ref' in operation.requestBody) ? operation.requestBody.required : undefined,
486
+ requestContentType,
487
+ responseType,
409
488
  });
410
489
  }
411
490
  const schemaHash = createHash('sha1').update(JSON.stringify(document)).digest('hex').slice(0, 8);
@@ -7,11 +7,14 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import fs from 'node:fs';
10
+ import fsp from 'node:fs/promises';
10
11
  import path from 'node:path';
11
12
  import { fileURLToPath } from 'node:url';
13
+ import { resolveCliHomeDir } from './cli-home.js';
12
14
  import { commandOutput, run } from './run-npm.js';
13
15
  const DEFAULT_PACKAGE_NAME = '@nocobase/cli';
14
16
  const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
17
+ const INSTALL_METHOD_CACHE_FILE = 'self-install-methods.json';
15
18
  function normalizePath(value) {
16
19
  return path.resolve(value);
17
20
  }
@@ -115,6 +118,38 @@ function detectInstallMethod(packageRoot, globalPrefix) {
115
118
  }
116
119
  return 'unknown';
117
120
  }
121
+ function getInstallMethodCacheFile() {
122
+ return path.join(resolveCliHomeDir('global'), INSTALL_METHOD_CACHE_FILE);
123
+ }
124
+ function getInstallMethodCacheKey(packageRoot) {
125
+ return normalizePath(path.join(packageRoot, 'bin', 'run.js'));
126
+ }
127
+ async function readInstallMethodCache() {
128
+ try {
129
+ const raw = await fsp.readFile(getInstallMethodCacheFile(), 'utf8');
130
+ return JSON.parse(raw);
131
+ }
132
+ catch {
133
+ return {};
134
+ }
135
+ }
136
+ async function writeInstallMethodCache(state) {
137
+ const filePath = getInstallMethodCacheFile();
138
+ await fsp.mkdir(path.dirname(filePath), { recursive: true });
139
+ await fsp.writeFile(filePath, JSON.stringify(state, null, 2));
140
+ }
141
+ async function readCachedInstallMethod(packageRoot) {
142
+ const state = await readInstallMethodCache();
143
+ return state.entries?.[getInstallMethodCacheKey(packageRoot)];
144
+ }
145
+ async function writeCachedInstallMethod(packageRoot, entry) {
146
+ const state = await readInstallMethodCache();
147
+ const entries = {
148
+ ...(state.entries ?? {}),
149
+ [getInstallMethodCacheKey(packageRoot)]: entry,
150
+ };
151
+ await writeInstallMethodCache({ entries });
152
+ }
118
153
  async function readGlobalPrefix(commandOutputFn) {
119
154
  try {
120
155
  return (await commandOutputFn('npm', ['prefix', '-g'], {
@@ -177,14 +212,34 @@ export function formatSelfUpdateUnavailableMessage(status) {
177
212
  export function getSelfUpdatePackageSpec(status) {
178
213
  return `${status.packageName}@${status.channel}`;
179
214
  }
215
+ export async function inspectSelfInstall(options = {}) {
216
+ const packageRoot = options.packageRoot ? normalizePath(options.packageRoot) : PACKAGE_ROOT;
217
+ const commandOutputFn = options.commandOutputFn ?? commandOutput;
218
+ const cachedInstallMethod = await readCachedInstallMethod(packageRoot);
219
+ const globalPrefix = cachedInstallMethod?.globalPrefix ?? await readGlobalPrefix(commandOutputFn);
220
+ const installMethod = cachedInstallMethod?.installMethod ?? detectInstallMethod(packageRoot, globalPrefix);
221
+ if (!cachedInstallMethod) {
222
+ await writeCachedInstallMethod(packageRoot, {
223
+ installMethod,
224
+ globalPrefix,
225
+ });
226
+ }
227
+ return {
228
+ packageRoot,
229
+ installMethod,
230
+ globalPrefix,
231
+ };
232
+ }
180
233
  export async function inspectSelfStatus(options = {}) {
181
234
  const packageRoot = options.packageRoot ? normalizePath(options.packageRoot) : PACKAGE_ROOT;
182
235
  const packageName = options.packageName ?? DEFAULT_PACKAGE_NAME;
183
236
  const currentVersion = options.currentVersion ?? readCurrentVersion(packageRoot);
184
237
  const channel = options.channel && options.channel !== 'auto' ? options.channel : detectChannel(currentVersion);
185
238
  const commandOutputFn = options.commandOutputFn ?? commandOutput;
186
- const globalPrefix = await readGlobalPrefix(commandOutputFn);
187
- const installMethod = detectInstallMethod(packageRoot, globalPrefix);
239
+ const { installMethod, globalPrefix } = await inspectSelfInstall({
240
+ packageRoot,
241
+ commandOutputFn,
242
+ });
188
243
  let latestVersion;
189
244
  let registryError;
190
245
  try {
@@ -10,7 +10,7 @@ import fsp from 'node:fs/promises';
10
10
  import path from 'node:path';
11
11
  import { resolveCliHomeDir } from './cli-home.js';
12
12
  import { compareVersions } from './self-manager.js';
13
- import { commandOutput, run } from './run-npm.js';
13
+ import { commandOutput, commandOutputViaFile, run } from './run-npm.js';
14
14
  export const NOCOBASE_SKILLS_SOURCE = 'nocobase/skills';
15
15
  export const NOCOBASE_SKILLS_PACKAGE_NAME = '@nocobase/skills';
16
16
  const NOCOBASE_SKILLS_NAME_PREFIX = 'nocobase-';
@@ -57,7 +57,7 @@ async function writeManagedSkillsState(workspaceRoot, state) {
57
57
  export async function listGlobalSkills(options = {}) {
58
58
  const globalRoot = resolveSkillsRoot(options);
59
59
  await ensureSkillsWorkspaceRoot(globalRoot);
60
- const output = await (options.commandOutputFn ?? commandOutput)('npx', ['-y', 'skills', 'list', '-g', '--json'], {
60
+ const output = await (options.commandOutputFn ?? commandOutputViaFile)('npx', ['-y', 'skills', 'list', '-g', '--json'], {
61
61
  cwd: globalRoot,
62
62
  errorName: 'skills list',
63
63
  });
@@ -8,8 +8,9 @@
8
8
  */
9
9
  import fs from 'node:fs/promises';
10
10
  import path from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
11
12
  import * as p from '@clack/prompts';
12
- import { inspectSelfStatus, } from './self-manager.js';
13
+ import { inspectSelfInstall, inspectSelfStatus, } from './self-manager.js';
13
14
  import { inspectSkillsStatus } from './skills-manager.js';
14
15
  import { resolveCliHomeDir } from './cli-home.js';
15
16
  import { isInteractiveTerminal, printWarning } from './ui.js';
@@ -19,7 +20,33 @@ const NB_SKIP_STARTUP_UPDATE_ENV = 'NB_SKIP_STARTUP_UPDATE';
19
20
  function getStateFile() {
20
21
  return path.join(resolveCliHomeDir('global'), STARTUP_UPDATE_STATE_FILE);
21
22
  }
23
+ function getCurrentInstallBinPath() {
24
+ return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'bin', 'run.js');
25
+ }
26
+ function getCurrentInstallEntry(state) {
27
+ return state.entries?.[getCurrentInstallBinPath()];
28
+ }
22
29
  function todayStamp(now = new Date()) {
30
+ const timeZone = String(process.env.TZ ?? '').trim();
31
+ if (timeZone) {
32
+ try {
33
+ const parts = new Intl.DateTimeFormat('en-CA', {
34
+ timeZone,
35
+ year: 'numeric',
36
+ month: '2-digit',
37
+ day: '2-digit',
38
+ }).formatToParts(now);
39
+ const year = parts.find((part) => part.type === 'year')?.value;
40
+ const month = parts.find((part) => part.type === 'month')?.value;
41
+ const day = parts.find((part) => part.type === 'day')?.value;
42
+ if (year && month && day) {
43
+ return `${year}-${month}-${day}`;
44
+ }
45
+ }
46
+ catch {
47
+ // Fall back to the host local timezone.
48
+ }
49
+ }
23
50
  const year = now.getFullYear();
24
51
  const month = String(now.getMonth() + 1).padStart(2, '0');
25
52
  const day = String(now.getDate()).padStart(2, '0');
@@ -49,8 +76,46 @@ async function writeState(state) {
49
76
  await fs.mkdir(path.dirname(filePath), { recursive: true });
50
77
  await fs.writeFile(filePath, JSON.stringify(state, null, 2));
51
78
  }
79
+ function readCurrentInstallLastCheckedDate(state) {
80
+ return getCurrentInstallEntry(state)?.lastCheckedDate ?? state.lastCheckedDate;
81
+ }
82
+ async function writeCurrentInstallEntry(updater) {
83
+ const state = await readState();
84
+ const installBinPath = getCurrentInstallBinPath();
85
+ const nextEntry = updater(getCurrentInstallEntry(state), state);
86
+ await writeState({
87
+ ...state,
88
+ entries: {
89
+ ...(state.entries ?? {}),
90
+ [installBinPath]: nextEntry,
91
+ },
92
+ });
93
+ }
52
94
  async function markChecked(now = new Date()) {
53
- await writeState({ lastCheckedDate: todayStamp(now) });
95
+ await writeCurrentInstallEntry((current, state) => {
96
+ return {
97
+ policy: current?.policy ?? 'daily',
98
+ lastCheckedDate: todayStamp(now),
99
+ };
100
+ });
101
+ }
102
+ async function disableStartupUpdateForCurrentInstall() {
103
+ await writeCurrentInstallEntry((current, state) => {
104
+ return {
105
+ policy: 'disabled',
106
+ lastCheckedDate: current?.lastCheckedDate
107
+ ?? state.lastCheckedDate,
108
+ };
109
+ });
110
+ }
111
+ async function enableDailyStartupUpdateForCurrentInstall() {
112
+ await writeCurrentInstallEntry((current, state) => {
113
+ return {
114
+ policy: 'daily',
115
+ lastCheckedDate: current?.lastCheckedDate
116
+ ?? state.lastCheckedDate,
117
+ };
118
+ });
54
119
  }
55
120
  export async function shouldRunStartupUpdateCheck(argv, now = new Date()) {
56
121
  if (process.env[NB_SKIP_STARTUP_UPDATE_ENV] === '1') {
@@ -60,7 +125,20 @@ export async function shouldRunStartupUpdateCheck(argv, now = new Date()) {
60
125
  return false;
61
126
  }
62
127
  const state = await readState();
63
- return state.lastCheckedDate !== todayStamp(now);
128
+ const currentEntry = getCurrentInstallEntry(state);
129
+ if (currentEntry?.policy === 'disabled') {
130
+ return false;
131
+ }
132
+ if (currentEntry?.policy === 'daily') {
133
+ return readCurrentInstallLastCheckedDate(state) !== todayStamp(now);
134
+ }
135
+ const selfInstall = await inspectSelfInstall();
136
+ if (!shouldEnableStartupUpdateForInstallMethod(selfInstall.installMethod)) {
137
+ await disableStartupUpdateForCurrentInstall();
138
+ return false;
139
+ }
140
+ await enableDailyStartupUpdateForCurrentInstall();
141
+ return readCurrentInstallLastCheckedDate(state) !== todayStamp(now);
64
142
  }
65
143
  export function shouldEnableStartupUpdateForInstallMethod(installMethod) {
66
144
  return installMethod === 'npm-global';
@@ -176,9 +254,6 @@ export async function maybeRunStartupUpdatePrompt(argv) {
176
254
  return { kind: 'skipped' };
177
255
  }
178
256
  const selfStatus = await inspectSelfStatus();
179
- if (!shouldEnableStartupUpdateForInstallMethod(selfStatus.installMethod)) {
180
- return { kind: 'skipped' };
181
- }
182
257
  const skillsStatus = await inspectSkillsStatus();
183
258
  if (!hasPendingUpdates(selfStatus, skillsStatus)) {
184
259
  await markChecked();
package/dist/lib/ui.js CHANGED
@@ -88,6 +88,9 @@ export function printInfo(message) {
88
88
  }
89
89
  console.log(pc.cyan(message));
90
90
  }
91
+ export function announceTargetEnv(envName) {
92
+ printInfo(`Target env: ${envName}`);
93
+ }
91
94
  export function printVerbose(message) {
92
95
  if (!verboseMode) {
93
96
  return;
@@ -80,10 +80,6 @@
80
80
  },
81
81
  "scope": {
82
82
  "message": "Where should this connection be saved?",
83
- "autoLabel": "Auto",
84
- "autoHint": "project if this repo already has .nocobase, otherwise global",
85
- "projectLabel": "Project",
86
- "projectHint": ".nocobase in this repo",
87
83
  "globalLabel": "Global",
88
84
  "globalHint": "user-level config"
89
85
  },
@@ -80,10 +80,6 @@
80
80
  },
81
81
  "scope": {
82
82
  "message": "这个连接要保存到哪里?",
83
- "autoLabel": "自动",
84
- "autoHint": "当前仓库已有 .nocobase 时保存到项目内,否则保存到全局",
85
- "projectLabel": "项目内",
86
- "projectHint": "保存在当前仓库的 .nocobase 中",
87
83
  "globalLabel": "全局",
88
84
  "globalHint": "保存在用户级配置中"
89
85
  },
@@ -215,6 +215,88 @@
215
215
  }
216
216
  }
217
217
  },
218
+ "backup": {
219
+ "name": "backup",
220
+ "description": "Create, inspect, download, remove, and restore NocoBase backups.",
221
+ "include": true,
222
+ "resources": {
223
+ "includes": ["backup"],
224
+ "excludes": [],
225
+ "overrides": {
226
+ "backup": {
227
+ "name": "backup",
228
+ "description": "Manage backup and restore files.",
229
+ "topLevel": true,
230
+ "operations": {
231
+ "includes": [
232
+ "backup:list",
233
+ "backup:create",
234
+ "backup:status",
235
+ "backup:download",
236
+ "backup:remove",
237
+ "backup:restore",
238
+ "backup:restoreUpload",
239
+ "backup:restoreStatus"
240
+ ]
241
+ }
242
+ }
243
+ }
244
+ }
245
+ },
246
+ "migration": {
247
+ "name": "migration",
248
+ "description": "Create, check, execute, and inspect migration packages.",
249
+ "include": true,
250
+ "resources": {
251
+ "includes": ["migration", "migrationLog", "migrationRule", "migrationRules"],
252
+ "excludes": [],
253
+ "overrides": {
254
+ "migration": {
255
+ "name": "migration",
256
+ "description": "Manage migration files and executions.",
257
+ "topLevel": true,
258
+ "operations": {
259
+ "includes": [
260
+ "migration:list",
261
+ "migration:get",
262
+ "migration:create",
263
+ "migration:download",
264
+ "migration:remove",
265
+ "migration:check",
266
+ "migration:execute"
267
+ ]
268
+ }
269
+ },
270
+ "migrationRule": {
271
+ "name": "migration rules",
272
+ "segments": ["migration", "rules"],
273
+ "description": "Create migration rules with global user/system policies.",
274
+ "topLevel": true,
275
+ "operations": {
276
+ "includes": ["migrationRule:create"]
277
+ }
278
+ },
279
+ "migrationRules": {
280
+ "name": "migration rules",
281
+ "segments": ["migration", "rules"],
282
+ "description": "List and inspect migration rules.",
283
+ "topLevel": true,
284
+ "operations": {
285
+ "includes": ["migrationRules:list", "migrationRules:get"]
286
+ }
287
+ },
288
+ "migrationLog": {
289
+ "name": "migration logs",
290
+ "segments": ["migration", "logs"],
291
+ "description": "List, inspect, and download migration logs.",
292
+ "topLevel": true,
293
+ "operations": {
294
+ "includes": ["migrationLog:list", "migrationLog:get", "migrationLog:download"]
295
+ }
296
+ }
297
+ }
298
+ }
299
+ },
218
300
  "system-settings": {
219
301
  "name": "system-settings",
220
302
  "description": "Adjust system title, logo, language, and other global settings.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "2.1.0-beta.24",
3
+ "version": "2.1.0-beta.25",
4
4
  "description": "NocoBase Command Line Tool",
5
5
  "type": "module",
6
6
  "main": "dist/generated/command-registry.js",
@@ -58,6 +58,12 @@
58
58
  "env": {
59
59
  "description": "Manage NocoBase project environments, status, details, and command runtimes."
60
60
  },
61
+ "license": {
62
+ "description": "Manage NocoBase commercial licensing and licensed plugins."
63
+ },
64
+ "config": {
65
+ "description": "Manage CLI configuration defaults."
66
+ },
61
67
  "self": {
62
68
  "description": "Inspect or update the NocoBase CLI itself."
63
69
  },
@@ -75,6 +81,7 @@
75
81
  },
76
82
  "dependencies": {
77
83
  "@clack/prompts": "^0.9.1",
84
+ "@nocobase/license-kit": "^0.3.8",
78
85
  "@oclif/core": "^4.10.4",
79
86
  "cross-spawn": "^7.0.6",
80
87
  "lodash": "^4.17.21",
@@ -83,16 +90,18 @@
83
90
  "openapi-types": "^12.1.3",
84
91
  "ora": "^8.2.0",
85
92
  "pg": "^8.14.1",
86
- "picocolors": "^1.1.1"
93
+ "picocolors": "^1.1.1",
94
+ "tar": "^7.4.3"
87
95
  },
88
96
  "devDependencies": {
89
97
  "@types/node": "^18.19.130",
90
98
  "tsx": "^4.20.6",
91
- "typescript": "^6.0.2"
99
+ "typescript": "^6.0.2",
100
+ "vitest": "^1.5.0"
92
101
  },
93
102
  "repository": {
94
103
  "type": "git",
95
104
  "url": "git+https://github.com/nocobase/nocobase.git"
96
105
  },
97
- "gitHead": "f77b85530a2d127d9bfe4dca3a26fbb02c1139ba"
106
+ "gitHead": "824f8b8200e9fe086135768934d3ef427b212446"
98
107
  }