@nocobase/cli 2.1.0-alpha.40 → 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.
Files changed (56) hide show
  1. package/README.md +20 -8
  2. package/README.zh-CN.md +20 -8
  3. package/bin/run.js +9 -37
  4. package/dist/commands/app/destroy.js +225 -0
  5. package/dist/commands/app/down.js +24 -254
  6. package/dist/commands/app/restart.js +12 -5
  7. package/dist/commands/app/shared.js +122 -0
  8. package/dist/commands/app/start.js +41 -59
  9. package/dist/commands/app/stop.js +72 -26
  10. package/dist/commands/app/upgrade.js +312 -429
  11. package/dist/commands/config/delete.js +8 -1
  12. package/dist/commands/config/get.js +5 -0
  13. package/dist/commands/config/set.js +10 -1
  14. package/dist/commands/db/ps.js +5 -18
  15. package/dist/commands/db/start.js +23 -8
  16. package/dist/commands/env/add.js +66 -6
  17. package/dist/commands/env/auth.js +86 -27
  18. package/dist/commands/env/info.js +52 -8
  19. package/dist/commands/env/list.js +6 -7
  20. package/dist/commands/env/shared.js +41 -3
  21. package/dist/commands/env/status.js +10 -7
  22. package/dist/commands/init.js +214 -136
  23. package/dist/commands/install.js +364 -294
  24. package/dist/commands/license/plugins/shared.js +9 -3
  25. package/dist/commands/license/plugins/sync.js +54 -25
  26. package/dist/commands/self/update.js +58 -1
  27. package/dist/commands/source/dev.js +5 -5
  28. package/dist/commands/source/download.js +29 -25
  29. package/dist/generated/command-registry.js +3 -2
  30. package/dist/lib/api-client.js +6 -0
  31. package/dist/lib/api-command-compat.js +641 -0
  32. package/dist/lib/app-health.js +31 -18
  33. package/dist/lib/app-managed-resources.js +1 -1
  34. package/dist/lib/app-runtime.js +2 -2
  35. package/dist/lib/auth-store.js +56 -19
  36. package/dist/lib/backup.js +3 -3
  37. package/dist/lib/bootstrap.js +14 -8
  38. package/dist/lib/cli-config.js +137 -4
  39. package/dist/lib/cli-entry-error.js +44 -0
  40. package/dist/lib/cli-locale.js +19 -7
  41. package/dist/lib/db-connection-check.js +61 -0
  42. package/dist/lib/docker-log-stream.js +45 -0
  43. package/dist/lib/env-auth.js +98 -11
  44. package/dist/lib/env-config.js +3 -2
  45. package/dist/lib/env-guard.js +1 -1
  46. package/dist/lib/generated-command.js +17 -0
  47. package/dist/lib/prompt-validators.js +23 -5
  48. package/dist/lib/prompt-web-ui.js +143 -19
  49. package/dist/lib/run-npm.js +133 -23
  50. package/dist/lib/skills-manager.js +80 -4
  51. package/dist/lib/source-publish.js +4 -1
  52. package/dist/lib/startup-update.js +74 -50
  53. package/dist/lib/ui.js +4 -1
  54. package/dist/locale/en-US.json +92 -5
  55. package/dist/locale/zh-CN.json +92 -5
  56. package/package.json +34 -2
@@ -7,15 +7,14 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { Command } from '@oclif/core';
10
- import { getCurrentEnvName, listEnvs } from '../../lib/auth-store.js';
10
+ import { getCurrentEnvName, listEnvs, resolveConfiguredAuthType } from '../../lib/auth-store.js';
11
11
  import { resolveDefaultConfigScope } from '../../lib/cli-home.js';
12
+ import { translateCli } from '../../lib/cli-locale.js';
12
13
  import { renderTable } from '../../lib/ui.js';
13
14
  import { resolveApiBaseUrl } from './shared.js';
14
15
  export default class EnvList extends Command {
15
16
  static summary = 'List configured environments';
16
- static examples = [
17
- '<%= config.bin %> <%= command.id %>',
18
- ];
17
+ static examples = ['<%= config.bin %> <%= command.id %>'];
19
18
  async run() {
20
19
  await this.parse(EnvList);
21
20
  const scope = resolveDefaultConfigScope();
@@ -23,8 +22,8 @@ export default class EnvList extends Command {
23
22
  const currentEnv = await getCurrentEnvName({ scope });
24
23
  const names = Object.keys(envs).sort();
25
24
  if (!names.length) {
26
- this.log('No envs configured.');
27
- this.log('Run `nb env add <name> --api-base-url <url>` to add one.');
25
+ this.log(translateCli('commands.env.messages.noEnvsConfigured'));
26
+ this.log(translateCli('commands.env.messages.noEnvsConfiguredHelp'));
28
27
  return;
29
28
  }
30
29
  const rows = [];
@@ -35,7 +34,7 @@ export default class EnvList extends Command {
35
34
  name,
36
35
  env.kind ?? '-',
37
36
  resolveApiBaseUrl(env),
38
- env.auth?.type ?? '',
37
+ resolveConfiguredAuthType(env) ?? env.auth?.type ?? '',
39
38
  env.runtime?.version ?? '',
40
39
  ]);
41
40
  }
@@ -11,13 +11,51 @@ import { executeRawApiRequest } from '../../lib/api-client.js';
11
11
  export function resolveApiBaseUrl(config) {
12
12
  return String(config.apiBaseUrl ?? config.baseUrl ?? config.apibaseUrl ?? '').trim();
13
13
  }
14
+ function buildAppPath(publicPath, subapp) {
15
+ const normalizedPublicPath = publicPath.replace(/\/+$/, '');
16
+ if (!subapp) {
17
+ return normalizedPublicPath ? `${normalizedPublicPath}/` : '/';
18
+ }
19
+ const normalizedSubapp = subapp.replace(/^\/+|\/+$/g, '');
20
+ return `${normalizedPublicPath ? normalizedPublicPath : ''}/apps/${normalizedSubapp}/`;
21
+ }
22
+ export function resolveAppUrlFromApiBaseUrl(apiBaseUrl) {
23
+ const value = String(apiBaseUrl ?? '').trim();
24
+ if (!value) {
25
+ return '';
26
+ }
27
+ try {
28
+ const url = new URL(value);
29
+ const subappMatch = url.pathname.match(/^(.*)\/api\/__app\/([^/]+)\/?$/);
30
+ if (subappMatch) {
31
+ url.pathname = buildAppPath(subappMatch[1] ?? '', subappMatch[2]);
32
+ url.search = '';
33
+ url.hash = '';
34
+ return url.toString();
35
+ }
36
+ const appMatch = url.pathname.match(/^(.*)\/api\/?$/);
37
+ if (appMatch) {
38
+ url.pathname = buildAppPath(appMatch[1] ?? '');
39
+ url.search = '';
40
+ url.hash = '';
41
+ return url.toString();
42
+ }
43
+ }
44
+ catch {
45
+ return value;
46
+ }
47
+ return value;
48
+ }
14
49
  export function appUrl(runtime) {
50
+ const resolvedFromApiBaseUrl = resolveAppUrlFromApiBaseUrl(runtime.env.apiBaseUrl ?? resolveApiBaseUrl(runtime.env.config));
51
+ if (resolvedFromApiBaseUrl) {
52
+ return resolvedFromApiBaseUrl;
53
+ }
15
54
  const port = String(runtime.env.config.appPort ?? '').trim();
16
55
  if (port) {
17
- return `http://127.0.0.1:${port}`;
56
+ return `http://127.0.0.1:${port}/`;
18
57
  }
19
- const baseUrl = resolveApiBaseUrl(runtime.env.config);
20
- return baseUrl.replace(/\/api\/?$/, '');
58
+ return '';
21
59
  }
22
60
  export function appRootPath(runtime) {
23
61
  if (runtime.kind === 'http' || runtime.kind === 'docker') {
@@ -10,6 +10,7 @@ import { Args, Command, Flags } from '@oclif/core';
10
10
  import { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime } from '../../lib/app-runtime.js';
11
11
  import { getCurrentEnvName, listEnvs } from '../../lib/auth-store.js';
12
12
  import { resolveDefaultConfigScope } from '../../lib/cli-home.js';
13
+ import { translateCli } from '../../lib/cli-locale.js';
13
14
  import { renderTable } from '../../lib/ui.js';
14
15
  import { apiStatus, runtimeStatus } from './shared.js';
15
16
  export default class EnvStatus extends Command {
@@ -46,13 +47,11 @@ export default class EnvStatus extends Command {
46
47
  const { envs } = await listEnvs({ scope });
47
48
  const configuredEnvNames = Object.keys(envs).sort();
48
49
  if (!configuredEnvNames.length) {
49
- this.log('No envs configured.');
50
- this.log('Run `nb env add <name> --api-base-url <url>` to add one.');
50
+ this.log(translateCli('commands.env.messages.noEnvsConfigured'));
51
+ this.log(translateCli('commands.env.messages.noEnvsConfiguredHelp'));
51
52
  return;
52
53
  }
53
- const envNames = flags.all
54
- ? configuredEnvNames
55
- : [requestedEnv || (await getCurrentEnvName({ scope }))];
54
+ const envNames = flags.all ? configuredEnvNames : [requestedEnv || (await getCurrentEnvName({ scope }))];
56
55
  const rows = [];
57
56
  for (const envName of envNames) {
58
57
  const runtime = await resolveManagedAppRuntime(envName);
@@ -76,8 +75,12 @@ export default class EnvStatus extends Command {
76
75
  rows.push({
77
76
  env: runtime.envName,
78
77
  status,
79
- apiBaseUrl: runtime.env.apiBaseUrl
80
- || String(runtime.env.config.apiBaseUrl ?? runtime.env.config.baseUrl ?? envs[envName]?.apiBaseUrl ?? envs[envName]?.baseUrl ?? '').trim(),
78
+ apiBaseUrl: runtime.env.apiBaseUrl ||
79
+ String(runtime.env.config.apiBaseUrl ??
80
+ runtime.env.config.baseUrl ??
81
+ envs[envName]?.apiBaseUrl ??
82
+ envs[envName]?.baseUrl ??
83
+ '').trim(),
81
84
  });
82
85
  }
83
86
  if (flags['json-output']) {