@nocobase/cli 2.1.0-beta.21 → 2.1.0-beta.22

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 (50) hide show
  1. package/README.md +28 -46
  2. package/README.zh-CN.md +27 -44
  3. package/dist/commands/app/down.js +260 -0
  4. package/dist/commands/app/info.js +140 -0
  5. package/dist/commands/app/logs.js +98 -0
  6. package/dist/commands/app/ps.js +60 -0
  7. package/dist/commands/app/restart.js +75 -0
  8. package/dist/commands/app/shared.js +95 -0
  9. package/dist/commands/app/start.js +252 -0
  10. package/dist/commands/app/stop.js +98 -0
  11. package/dist/commands/app/upgrade.js +595 -0
  12. package/dist/commands/build.js +3 -48
  13. package/dist/commands/dev.js +3 -147
  14. package/dist/commands/down.js +3 -188
  15. package/dist/commands/download.js +4 -856
  16. package/dist/commands/env/add.js +28 -23
  17. package/dist/commands/{prompts-stages.js → examples/prompts-stages.js} +3 -3
  18. package/dist/commands/{prompts-test.js → examples/prompts-test.js} +3 -3
  19. package/dist/commands/init.js +76 -5
  20. package/dist/commands/install.js +288 -61
  21. package/dist/commands/logs.js +3 -88
  22. package/dist/commands/plugin/disable.js +64 -0
  23. package/dist/commands/plugin/enable.js +64 -0
  24. package/dist/commands/plugin/list.js +62 -0
  25. package/dist/commands/pm/disable.js +3 -54
  26. package/dist/commands/pm/enable.js +3 -54
  27. package/dist/commands/pm/list.js +3 -52
  28. package/dist/commands/ps.js +3 -110
  29. package/dist/commands/restart.js +3 -65
  30. package/dist/commands/scaffold/migration.js +1 -1
  31. package/dist/commands/scaffold/plugin.js +1 -1
  32. package/dist/commands/skills/remove.js +71 -0
  33. package/dist/commands/skills/update.js +7 -0
  34. package/dist/commands/source/build.js +58 -0
  35. package/dist/commands/source/dev.js +157 -0
  36. package/dist/commands/source/download.js +866 -0
  37. package/dist/commands/source/test.js +467 -0
  38. package/dist/commands/start.js +3 -209
  39. package/dist/commands/stop.js +3 -88
  40. package/dist/commands/test.js +3 -457
  41. package/dist/commands/upgrade.js +3 -585
  42. package/dist/help/runtime-help.js +3 -0
  43. package/dist/lib/app-health.js +126 -0
  44. package/dist/lib/app-managed-resources.js +264 -0
  45. package/dist/lib/auth-store.js +5 -2
  46. package/dist/lib/cli-home.js +7 -6
  47. package/dist/lib/cli-locale.js +15 -1
  48. package/dist/lib/env-config.js +80 -0
  49. package/dist/lib/skills-manager.js +34 -7
  50. package/package.json +26 -3
@@ -9,6 +9,7 @@
9
9
  import { Args, Command, Flags } from '@oclif/core';
10
10
  import { upsertEnv } from '../../lib/auth-store.js';
11
11
  import { resolveDefaultConfigScope } from '../../lib/cli-home.js';
12
+ import { buildStoredEnvConfig, } from '../../lib/env-config.js';
12
13
  import { runPromptCatalog, } from '../../lib/prompt-catalog.js';
13
14
  import { applyCliLocale, CLI_LOCALE_FLAG_DESCRIPTION, CLI_LOCALE_FLAG_OPTIONS, localeText, } from '../../lib/cli-locale.js';
14
15
  import { validateApiBaseUrl } from '../../lib/prompt-validators.js';
@@ -33,6 +34,10 @@ const ENV_RUNTIME_FLAG_MAP = {
33
34
  'db-database': 'dbDatabase',
34
35
  'db-user': 'dbUser',
35
36
  'db-password': 'dbPassword',
37
+ 'root-username': 'rootUsername',
38
+ 'root-email': 'rootEmail',
39
+ 'root-password': 'rootPassword',
40
+ 'root-nickname': 'rootNickname',
36
41
  };
37
42
  const ENV_BOOLEAN_RUNTIME_FLAG_MAP = {
38
43
  'builtin-db': 'builtinDb',
@@ -185,6 +190,22 @@ export default class EnvAdd extends Command {
185
190
  hidden: true,
186
191
  description: 'Database password saved with this env',
187
192
  }),
193
+ 'root-username': Flags.string({
194
+ hidden: true,
195
+ description: 'Initial root username saved with this env',
196
+ }),
197
+ 'root-email': Flags.string({
198
+ hidden: true,
199
+ description: 'Initial root email saved with this env',
200
+ }),
201
+ 'root-password': Flags.string({
202
+ hidden: true,
203
+ description: 'Initial root password saved with this env',
204
+ }),
205
+ 'root-nickname': Flags.string({
206
+ hidden: true,
207
+ description: 'Initial root nickname saved with this env',
208
+ }),
188
209
  };
189
210
  static prompts = {
190
211
  name: {
@@ -250,36 +271,20 @@ export default class EnvAdd extends Command {
250
271
  return initialValues;
251
272
  }
252
273
  buildEnvConfig(results, flags) {
253
- const source = String(flags.source ?? '').trim();
254
- const appRootPath = String(flags['app-root-path'] ?? '').trim();
255
- const kind = source === 'docker'
256
- ? 'docker'
257
- : source === 'npm' || source === 'git' || source === 'local' || appRootPath
258
- ? 'local'
259
- : 'http';
260
- const envConfig = {
261
- kind,
262
- apiBaseUrl: String(results.apiBaseUrl ?? ''),
274
+ const envConfigInput = {
275
+ apiBaseUrl: results.apiBaseUrl,
276
+ authType: results.authType,
277
+ accessToken: results.accessToken,
263
278
  };
264
279
  for (const [flagName, configKey] of Object.entries(ENV_RUNTIME_FLAG_MAP)) {
265
280
  const value = flags[flagName];
266
- if (typeof value === 'string' && value.trim() !== '') {
267
- envConfig[configKey] = value.trim();
268
- }
281
+ envConfigInput[configKey] = value;
269
282
  }
270
283
  for (const [flagName, configKey] of Object.entries(ENV_BOOLEAN_RUNTIME_FLAG_MAP)) {
271
284
  const value = flags[flagName];
272
- if (typeof value === 'boolean') {
273
- envConfig[configKey] = value;
274
- }
275
- }
276
- if (flags['builtin-db'] === false) {
277
- envConfig.builtinDbImage = undefined;
278
- }
279
- if (results.authType === 'token' && results.accessToken != null) {
280
- envConfig.accessToken = String(results.accessToken);
285
+ envConfigInput[configKey] = value;
281
286
  }
282
- return envConfig;
287
+ return buildStoredEnvConfig(envConfigInput);
283
288
  }
284
289
  async run() {
285
290
  const { args, flags } = await this.parse(EnvAdd);
@@ -7,9 +7,9 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { Args, Command, Flags } from '@oclif/core';
10
- import { runPromptCatalog, } from "../lib/prompt-catalog.js";
11
- import { applyCliLocale, CLI_LOCALE_FLAG_DESCRIPTION, CLI_LOCALE_FLAG_OPTIONS, } from "../lib/cli-locale.js";
12
- import { runPromptCatalogWebUI } from "../lib/prompt-web-ui.js";
10
+ import { runPromptCatalog, } from "../../lib/prompt-catalog.js";
11
+ import { applyCliLocale, CLI_LOCALE_FLAG_DESCRIPTION, CLI_LOCALE_FLAG_OPTIONS, } from "../../lib/cli-locale.js";
12
+ import { runPromptCatalogWebUI } from "../../lib/prompt-web-ui.js";
13
13
  import PromptsTest from "./prompts-test.js";
14
14
  function buildWebUiStagesFromTestPrompts(c) {
15
15
  return [
@@ -8,9 +8,9 @@
8
8
  */
9
9
  import * as p from '@clack/prompts';
10
10
  import { Args, Command, Flags } from '@oclif/core';
11
- import { runPromptCatalog, } from "../lib/prompt-catalog.js";
12
- import { applyCliLocale, CLI_LOCALE_FLAG_DESCRIPTION, CLI_LOCALE_FLAG_OPTIONS, } from "../lib/cli-locale.js";
13
- import { runPromptCatalogWebUI, } from "../lib/prompt-web-ui.js";
11
+ import { runPromptCatalog, } from "../../lib/prompt-catalog.js";
12
+ import { applyCliLocale, CLI_LOCALE_FLAG_DESCRIPTION, CLI_LOCALE_FLAG_OPTIONS, } from "../../lib/cli-locale.js";
13
+ import { runPromptCatalogWebUI, } from "../../lib/prompt-web-ui.js";
14
14
  export default class PromptsTest extends Command {
15
15
  static hidden = true;
16
16
  static args = {
@@ -171,6 +171,26 @@ Prompt modes:
171
171
  '<%= config.bin %> <%= command.id %> --ui --ui-port 3000',
172
172
  ];
173
173
  static prompts = {
174
+ seedResume: {
175
+ type: 'run',
176
+ run: (values, command) => {
177
+ const record = values;
178
+ if (record.resume === undefined) {
179
+ const flags = command?.parsedFlagsForPromptSeeds;
180
+ record.resume = Boolean(flags?.resume);
181
+ }
182
+ },
183
+ },
184
+ seedEnvName: {
185
+ type: 'run',
186
+ run: (values) => {
187
+ const record = values;
188
+ const appName = String(record.appName ?? '').trim();
189
+ if (appName && record.env === undefined) {
190
+ record.env = appName;
191
+ }
192
+ },
193
+ },
174
194
  appName: {
175
195
  type: 'text',
176
196
  message: initText('prompts.appName.message'),
@@ -256,6 +276,7 @@ Prompt modes:
256
276
  rootPassword: newInstallOnly(Install.rootUserPrompts.rootPassword),
257
277
  rootNickname: newInstallOnly(Install.rootUserPrompts.rootNickname),
258
278
  };
279
+ parsedFlagsForPromptSeeds;
259
280
  static flags = {
260
281
  yes: Flags.boolean({
261
282
  char: 'y',
@@ -274,6 +295,11 @@ Prompt modes:
274
295
  description: 'Show detailed command output',
275
296
  default: false,
276
297
  }),
298
+ 'skip-skills': Flags.boolean({
299
+ description: 'Skip installing or updating NocoBase AI coding skills during init',
300
+ hidden: true,
301
+ default: false,
302
+ }),
277
303
  'ui-host': Flags.string({
278
304
  description: 'Host for the local --ui setup server (default: 127.0.0.1)',
279
305
  }),
@@ -290,6 +316,9 @@ Prompt modes:
290
316
  applyCliLocale(parsedResult.flags.locale);
291
317
  const flags = parsedResult.flags;
292
318
  const normalizedFlags = { ...flags };
319
+ this.parsedFlagsForPromptSeeds = {
320
+ resume: Boolean(normalizedFlags.resume),
321
+ };
293
322
  if (normalizedFlags.ui && normalizedFlags.yes) {
294
323
  this.error('--ui cannot be used with --yes.');
295
324
  }
@@ -307,7 +336,9 @@ Prompt modes:
307
336
  this.exit(1);
308
337
  }
309
338
  p.intro(initTitle());
310
- await this.syncNocoBaseSkills();
339
+ await this.syncNocoBaseSkills({
340
+ skip: Boolean(normalizedFlags['skip-skills']),
341
+ });
311
342
  try {
312
343
  await this.config.runCommand('install', this.buildResumeInstallArgv(normalizedFlags));
313
344
  }
@@ -321,6 +352,24 @@ Prompt modes:
321
352
  const interactive = Boolean(stdinStream.isTTY && stdoutStream.isTTY);
322
353
  const useBrowserUi = Boolean(normalizedFlags.ui);
323
354
  let presetValues = this.buildPresetValuesFromFlags(normalizedFlags);
355
+ if (normalizedFlags.resume) {
356
+ const resumeEnvName = String(normalizedFlags.env ?? '').trim();
357
+ if (resumeEnvName) {
358
+ const resumeEnv = await getEnv(resumeEnvName, {
359
+ scope: resolveDefaultConfigScope(),
360
+ });
361
+ if (resumeEnv) {
362
+ const savedAppPort = String(resumeEnv.config.appPort ?? '').trim();
363
+ const savedDbPort = String(resumeEnv.config.dbPort ?? '').trim();
364
+ if (savedAppPort) {
365
+ presetValues.resumeSavedAppPort = savedAppPort;
366
+ }
367
+ if (savedDbPort) {
368
+ presetValues.resumeSavedDbPort = savedDbPort;
369
+ }
370
+ }
371
+ }
372
+ }
324
373
  if (normalizedFlags.yes && !String(presetValues.appName ?? '').trim()) {
325
374
  const formatted = formatSkippedAppNameRequiredMessage();
326
375
  p.log.error(highlightInitValidationMessage(formatted));
@@ -385,7 +434,9 @@ Prompt modes:
385
434
  if (existingEnv && Boolean(normalizedFlags.force)) {
386
435
  p.log.warn(`Reconfiguring existing env ${pc.cyan(pc.bold(`"${existingEnv.name}"`))} from the global config because ${pc.bold('--force')} was set. The env config will be updated before install starts, then refreshed again after install succeeds.`);
387
436
  }
388
- await this.syncNocoBaseSkills();
437
+ await this.syncNocoBaseSkills({
438
+ skip: Boolean(normalizedFlags['skip-skills']),
439
+ });
389
440
  let managedInstallResults;
390
441
  try {
391
442
  // oclif explicit registry keys use `:` (e.g. `env:add`); users still type `nb env add`.
@@ -397,7 +448,7 @@ Prompt modes:
397
448
  p.log.step('Saving the local env config');
398
449
  await this.persistManagedEnvConfig(results, normalizedFlags);
399
450
  managedInstallResults = results;
400
- p.log.step('Running nb install');
451
+ p.log.step('Running nb init');
401
452
  await this.config.runCommand('install', this.buildInstallArgv(results, normalizedFlags));
402
453
  }
403
454
  }
@@ -647,7 +698,11 @@ Prompt modes:
647
698
  hasAgentsDirInCwd() {
648
699
  return existsSync(path.resolve(process.cwd(), '.agents'));
649
700
  }
650
- async syncNocoBaseSkills() {
701
+ async syncNocoBaseSkills(options) {
702
+ if (options?.skip) {
703
+ p.log.step('Skipped NocoBase agent skills sync.');
704
+ return;
705
+ }
651
706
  try {
652
707
  const status = await inspectSkillsStatus();
653
708
  if (!status.installed) {
@@ -682,6 +737,9 @@ Prompt modes:
682
737
  const dbDatabase = String(results.dbDatabase ?? '').trim();
683
738
  const dbUser = String(results.dbUser ?? '').trim();
684
739
  const dbPassword = String(results.dbPassword ?? '');
740
+ const apiBaseUrl = String(results.apiBaseUrl ?? '').trim();
741
+ const authType = String(results.authType ?? '').trim() || 'oauth';
742
+ const accessToken = String(results.accessToken ?? '');
685
743
  const builtinDb = explicitDbHostFlag(flags)
686
744
  ? false
687
745
  : results.builtinDb === undefined
@@ -695,7 +753,8 @@ Prompt modes:
695
753
  : appPort
696
754
  ? { kind: 'http' }
697
755
  : {}),
698
- ...(appPort ? { apiBaseUrl: `http://127.0.0.1:${appPort}/api` } : {}),
756
+ ...(apiBaseUrl ? { apiBaseUrl } : appPort ? { apiBaseUrl: `http://127.0.0.1:${appPort}/api` } : {}),
757
+ ...(authType === 'token' && accessToken ? { accessToken } : {}),
699
758
  ...(source ? { source } : {}),
700
759
  ...(version ? { downloadVersion: version } : {}),
701
760
  ...(dockerRegistry ? { dockerRegistry } : {}),
@@ -736,6 +795,9 @@ Prompt modes:
736
795
  const processArgv = process.argv.slice(2);
737
796
  const envName = String(results.appName ?? DEFAULT_INIT_APP_NAME).trim() || DEFAULT_INIT_APP_NAME;
738
797
  const source = String(results.source ?? '').trim();
798
+ const apiBaseUrl = String(results.apiBaseUrl ?? '').trim();
799
+ const authType = String(results.authType ?? '').trim();
800
+ const accessToken = String(results.accessToken ?? '');
739
801
  argv.push('--env', envName);
740
802
  if (options?.resume) {
741
803
  argv.push('--resume');
@@ -743,6 +805,15 @@ Prompt modes:
743
805
  if (Boolean(flags.verbose)) {
744
806
  argv.push('--verbose');
745
807
  }
808
+ if (apiBaseUrl) {
809
+ argv.push('--api-base-url', apiBaseUrl);
810
+ }
811
+ if (authType) {
812
+ argv.push('--auth-type', authType);
813
+ }
814
+ if (authType === 'token' && accessToken) {
815
+ argv.push('--access-token', accessToken);
816
+ }
746
817
  const lang = String(results.lang ?? '').trim();
747
818
  if (lang) {
748
819
  argv.push('--lang', lang);