@nocobase/cli 2.1.0-alpha.4 → 2.1.0-alpha.40
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/LICENSE.txt +107 -0
- package/README.md +393 -19
- package/README.zh-CN.md +343 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +135 -0
- package/bin/session-env.js +39 -0
- package/dist/commands/api/resource/create.js +15 -0
- package/dist/commands/api/resource/destroy.js +15 -0
- package/dist/commands/api/resource/get.js +15 -0
- package/dist/commands/api/resource/index.js +20 -0
- package/dist/commands/api/resource/list.js +16 -0
- package/dist/commands/api/resource/query.js +15 -0
- package/dist/commands/api/resource/update.js +15 -0
- package/dist/commands/app/down.js +301 -0
- package/dist/commands/app/logs.js +114 -0
- package/dist/commands/app/restart.js +158 -0
- package/dist/commands/app/start.js +305 -0
- package/dist/commands/app/stop.js +115 -0
- package/dist/commands/app/upgrade.js +636 -0
- package/dist/commands/backup/create.js +147 -0
- package/dist/commands/backup/index.js +20 -0
- package/dist/commands/backup/restore.js +105 -0
- package/{src/cli.js → dist/commands/build.js} +4 -11
- package/dist/commands/config/delete.js +30 -0
- package/dist/commands/config/get.js +29 -0
- package/dist/commands/config/index.js +20 -0
- package/dist/commands/config/list.js +29 -0
- package/dist/commands/config/set.js +35 -0
- package/dist/commands/db/check.js +240 -0
- package/dist/commands/db/logs.js +85 -0
- package/dist/commands/db/ps.js +60 -0
- package/dist/commands/db/shared.js +96 -0
- package/dist/commands/db/start.js +71 -0
- package/dist/commands/db/stop.js +71 -0
- package/{templates/plugin/src/client/models/index.ts → dist/commands/dev.js} +4 -4
- package/{src/commands/locale/react-js-cron/index.js → dist/commands/down.js} +3 -8
- package/dist/commands/download.js +13 -0
- package/dist/commands/env/add.js +366 -0
- package/dist/commands/env/auth.js +130 -0
- package/dist/commands/env/current.js +21 -0
- package/dist/commands/env/info.js +157 -0
- package/dist/commands/env/list.js +44 -0
- package/dist/commands/env/remove.js +84 -0
- package/dist/commands/env/shared.js +158 -0
- package/dist/commands/env/status.js +90 -0
- package/dist/commands/env/update.js +74 -0
- package/dist/commands/env/use.js +38 -0
- package/dist/commands/examples/prompts-stages.js +150 -0
- package/dist/commands/examples/prompts-test.js +181 -0
- package/dist/commands/init.js +1092 -0
- package/dist/commands/install.js +2378 -0
- package/dist/commands/license/activate.js +360 -0
- package/dist/commands/license/env.js +94 -0
- package/dist/commands/license/generate-id.js +108 -0
- package/dist/commands/license/id.js +70 -0
- package/dist/commands/license/index.js +20 -0
- package/dist/commands/license/plugins/clean.js +115 -0
- package/dist/commands/license/plugins/index.js +20 -0
- package/dist/commands/license/plugins/list.js +64 -0
- package/dist/commands/license/plugins/shared.js +325 -0
- package/dist/commands/license/plugins/sync.js +285 -0
- package/dist/commands/license/shared.js +423 -0
- package/dist/commands/license/status.js +64 -0
- package/dist/commands/logs.js +12 -0
- package/dist/commands/plugin/disable.js +86 -0
- package/dist/commands/plugin/enable.js +86 -0
- package/dist/commands/plugin/list.js +82 -0
- package/dist/commands/pm/disable.js +12 -0
- package/dist/commands/pm/enable.js +12 -0
- package/dist/commands/pm/list.js +12 -0
- package/dist/commands/restart.js +12 -0
- package/dist/commands/scaffold/migration.js +38 -0
- package/dist/commands/scaffold/plugin.js +37 -0
- package/dist/commands/self/check.js +71 -0
- package/dist/commands/self/index.js +20 -0
- package/dist/commands/self/update.js +95 -0
- package/dist/commands/session/id.js +24 -0
- package/dist/commands/session/remove.js +57 -0
- package/dist/commands/session/setup.js +62 -0
- package/dist/commands/skills/check.js +69 -0
- package/dist/commands/skills/index.js +20 -0
- package/dist/commands/skills/install.js +80 -0
- package/dist/commands/skills/remove.js +80 -0
- package/dist/commands/skills/update.js +87 -0
- package/dist/commands/source/build.js +58 -0
- package/dist/commands/source/dev.js +182 -0
- package/dist/commands/source/download.js +880 -0
- package/dist/commands/source/publish.js +109 -0
- package/dist/commands/source/registry/logs.js +70 -0
- package/dist/commands/source/registry/start.js +57 -0
- package/dist/commands/source/registry/status.js +33 -0
- package/dist/commands/source/registry/stop.js +48 -0
- package/dist/commands/source/test.js +477 -0
- package/dist/commands/start.js +12 -0
- package/dist/commands/stop.js +12 -0
- package/dist/commands/test.js +12 -0
- package/dist/commands/upgrade.js +12 -0
- package/dist/commands/v1.js +210 -0
- package/dist/generated/command-registry.js +133 -0
- package/dist/help/runtime-help.js +23 -0
- package/dist/lib/api-client.js +329 -0
- package/dist/lib/app-health.js +126 -0
- package/dist/lib/app-managed-resources.js +316 -0
- package/dist/lib/app-runtime.js +180 -0
- package/dist/lib/auth-store.js +368 -0
- package/dist/lib/backup.js +171 -0
- package/dist/lib/bootstrap.js +403 -0
- package/dist/lib/build-config.js +18 -0
- package/dist/lib/builtin-db.js +86 -0
- package/dist/lib/cli-config.js +176 -0
- package/dist/lib/cli-home.js +47 -0
- package/dist/lib/cli-locale.js +129 -0
- package/dist/lib/command-discovery.js +39 -0
- package/dist/lib/db-connection-check.js +158 -0
- package/dist/lib/docker-env-file.js +52 -0
- package/dist/lib/docker-image.js +37 -0
- package/dist/lib/env-auth.js +873 -0
- package/dist/lib/env-config.js +94 -0
- package/dist/lib/env-guard.js +62 -0
- package/dist/lib/generated-command.js +186 -0
- package/dist/lib/http-request.js +49 -0
- package/dist/lib/inquirer-theme.js +17 -0
- package/dist/lib/inquirer.js +244 -0
- package/dist/lib/naming.js +70 -0
- package/dist/lib/object-utils.js +76 -0
- package/dist/lib/openapi.js +62 -0
- package/dist/lib/plugin-storage.js +64 -0
- package/dist/lib/post-processors.js +23 -0
- package/dist/lib/prompt-catalog-core.js +185 -0
- package/dist/lib/prompt-catalog-terminal.js +375 -0
- package/{src/index.js → dist/lib/prompt-catalog.js} +2 -6
- package/dist/lib/prompt-validators.js +240 -0
- package/dist/lib/prompt-web-ui.js +2103 -0
- package/dist/lib/resource-command.js +357 -0
- package/dist/lib/resource-request.js +104 -0
- package/dist/lib/run-npm.js +275 -0
- package/dist/lib/runtime-env-vars.js +32 -0
- package/dist/lib/runtime-generator.js +498 -0
- package/dist/lib/runtime-store.js +56 -0
- package/dist/lib/self-manager.js +301 -0
- package/dist/lib/session-id.js +17 -0
- package/dist/lib/session-integration.js +703 -0
- package/dist/lib/session-store.js +118 -0
- package/dist/lib/skills-manager.js +360 -0
- package/dist/lib/source-publish.js +306 -0
- package/dist/lib/source-registry.js +188 -0
- package/dist/lib/startup-update.js +285 -0
- package/dist/lib/ui.js +155 -0
- package/dist/locale/en-US.json +344 -0
- package/dist/locale/zh-CN.json +344 -0
- package/dist/post-processors/data-modeling.js +84 -0
- package/dist/post-processors/data-source-manager.js +138 -0
- package/dist/post-processors/index.js +19 -0
- package/nocobase-ctl.config.json +388 -0
- package/package.json +100 -26
- package/LICENSE +0 -661
- package/bin/index.js +0 -39
- package/nocobase.conf.tpl +0 -95
- package/src/commands/benchmark.js +0 -73
- package/src/commands/build.js +0 -49
- package/src/commands/clean.js +0 -30
- package/src/commands/client.js +0 -166
- package/src/commands/create-nginx-conf.js +0 -37
- package/src/commands/create-plugin.js +0 -33
- package/src/commands/dev.js +0 -200
- package/src/commands/doc.js +0 -76
- package/src/commands/e2e.js +0 -265
- package/src/commands/global.js +0 -43
- package/src/commands/index.js +0 -45
- package/src/commands/instance-id.js +0 -47
- package/src/commands/locale/cronstrue.js +0 -122
- package/src/commands/locale/react-js-cron/en-US.json +0 -75
- package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
- package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
- package/src/commands/locale.js +0 -81
- package/src/commands/p-test.js +0 -88
- package/src/commands/perf.js +0 -63
- package/src/commands/pkg.js +0 -321
- package/src/commands/pm2.js +0 -37
- package/src/commands/postinstall.js +0 -88
- package/src/commands/start.js +0 -148
- package/src/commands/tar.js +0 -36
- package/src/commands/test-coverage.js +0 -55
- package/src/commands/test.js +0 -107
- package/src/commands/umi.js +0 -33
- package/src/commands/update-deps.js +0 -72
- package/src/commands/upgrade.js +0 -47
- package/src/commands/view-license-key.js +0 -44
- package/src/license.js +0 -76
- package/src/logger.js +0 -75
- package/src/plugin-generator.js +0 -80
- package/src/util.js +0 -517
- package/templates/bundle-status.html +0 -338
- package/templates/create-app-package.json +0 -39
- package/templates/plugin/.npmignore.tpl +0 -2
- package/templates/plugin/README.md.tpl +0 -1
- package/templates/plugin/client.d.ts +0 -2
- package/templates/plugin/client.js +0 -1
- package/templates/plugin/package.json.tpl +0 -11
- package/templates/plugin/server.d.ts +0 -2
- package/templates/plugin/server.js +0 -1
- package/templates/plugin/src/client/client.d.ts +0 -249
- package/templates/plugin/src/client/index.tsx.tpl +0 -1
- package/templates/plugin/src/client/locale.ts +0 -21
- package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
- package/templates/plugin/src/index.ts +0 -2
- package/templates/plugin/src/locale/en-US.json +0 -1
- package/templates/plugin/src/locale/zh-CN.json +0 -1
- package/templates/plugin/src/server/collections/.gitkeep +0 -0
- package/templates/plugin/src/server/index.ts.tpl +0 -1
- package/templates/plugin/src/server/plugin.ts.tpl +0 -19
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
*/
|
|
9
|
+
import { Command, Flags } from '@oclif/core';
|
|
10
|
+
import { formatMissingManagedAppEnvMessage } from '../../lib/app-runtime.js';
|
|
11
|
+
import { run } from '../../lib/run-npm.js';
|
|
12
|
+
import { printInfo } from '../../lib/ui.js';
|
|
13
|
+
import { formatUnmanagedDbLogsMessage, resolveDbRuntime } from './shared.js';
|
|
14
|
+
function formatDbLogsFailure(envName, message) {
|
|
15
|
+
if (/does not exist/i.test(message)) {
|
|
16
|
+
return [
|
|
17
|
+
`Can't show database logs for "${envName}" yet.`,
|
|
18
|
+
'The saved built-in database container for this env could not be found on this machine.',
|
|
19
|
+
'Try reinstalling the env, or check whether the container was removed outside the CLI.',
|
|
20
|
+
`Details: ${message}`,
|
|
21
|
+
].join('\n');
|
|
22
|
+
}
|
|
23
|
+
return [
|
|
24
|
+
`Couldn't show database logs for "${envName}".`,
|
|
25
|
+
'Check that the built-in database runtime for this env is still available, then try again.',
|
|
26
|
+
`Details: ${message}`,
|
|
27
|
+
].join('\n');
|
|
28
|
+
}
|
|
29
|
+
export default class DbLogs extends Command {
|
|
30
|
+
static description = 'Show logs for the built-in database container of the selected env.';
|
|
31
|
+
static examples = [
|
|
32
|
+
'<%= config.bin %> <%= command.id %>',
|
|
33
|
+
'<%= config.bin %> <%= command.id %> --env app1',
|
|
34
|
+
'<%= config.bin %> <%= command.id %> --env app1 --tail 200',
|
|
35
|
+
'<%= config.bin %> <%= command.id %> --env app1 --no-follow',
|
|
36
|
+
];
|
|
37
|
+
static flags = {
|
|
38
|
+
env: Flags.string({
|
|
39
|
+
char: 'e',
|
|
40
|
+
description: 'CLI env name to inspect built-in database logs for. Defaults to the current env when omitted',
|
|
41
|
+
}),
|
|
42
|
+
tail: Flags.integer({
|
|
43
|
+
description: 'Number of recent log lines to show before following',
|
|
44
|
+
default: 100,
|
|
45
|
+
min: 0,
|
|
46
|
+
}),
|
|
47
|
+
follow: Flags.boolean({
|
|
48
|
+
char: 'f',
|
|
49
|
+
description: 'Keep streaming new log lines',
|
|
50
|
+
default: false,
|
|
51
|
+
allowNo: true,
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
async run() {
|
|
55
|
+
const { flags } = await this.parse(DbLogs);
|
|
56
|
+
const requestedEnv = flags.env?.trim() || undefined;
|
|
57
|
+
const runtime = await resolveDbRuntime(requestedEnv);
|
|
58
|
+
if (!runtime) {
|
|
59
|
+
this.error(formatMissingManagedAppEnvMessage(requestedEnv));
|
|
60
|
+
}
|
|
61
|
+
if (runtime.kind !== 'builtin') {
|
|
62
|
+
this.error(formatUnmanagedDbLogsMessage(runtime));
|
|
63
|
+
}
|
|
64
|
+
const tail = String(flags.tail ?? 100);
|
|
65
|
+
const follow = flags.follow === true;
|
|
66
|
+
printInfo(follow
|
|
67
|
+
? `Showing built-in database logs for "${runtime.envName}" (press Ctrl+C to stop).`
|
|
68
|
+
: `Showing recent built-in database logs for "${runtime.envName}".`);
|
|
69
|
+
const dockerArgs = ['logs', '--tail', tail];
|
|
70
|
+
if (follow) {
|
|
71
|
+
dockerArgs.push('--follow');
|
|
72
|
+
}
|
|
73
|
+
dockerArgs.push(runtime.containerName);
|
|
74
|
+
try {
|
|
75
|
+
await run('docker', dockerArgs, {
|
|
76
|
+
errorName: 'docker logs',
|
|
77
|
+
stdio: 'inherit',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
82
|
+
this.error(formatDbLogsFailure(runtime.envName, message));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
*/
|
|
9
|
+
import { Command, Flags } from '@oclif/core';
|
|
10
|
+
import { formatMissingManagedAppEnvMessage } from '../../lib/app-runtime.js';
|
|
11
|
+
import { listEnvs } from '../../lib/auth-store.js';
|
|
12
|
+
import { renderTable } from '../../lib/ui.js';
|
|
13
|
+
import { builtinDbStatus, resolveDbRuntime } from './shared.js';
|
|
14
|
+
export default class DbPs extends Command {
|
|
15
|
+
static description = 'Show built-in database runtime status for configured envs without starting or stopping anything.';
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> <%= command.id %>',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> --env app1',
|
|
19
|
+
];
|
|
20
|
+
static flags = {
|
|
21
|
+
env: Flags.string({
|
|
22
|
+
char: 'e',
|
|
23
|
+
description: 'CLI env name to inspect built-in database status for. Omit to show all configured envs',
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
async run() {
|
|
27
|
+
const { flags } = await this.parse(DbPs);
|
|
28
|
+
const requestedEnv = flags.env?.trim() || undefined;
|
|
29
|
+
const envNames = requestedEnv
|
|
30
|
+
? [requestedEnv]
|
|
31
|
+
: Object.keys((await listEnvs()).envs).sort();
|
|
32
|
+
if (!envNames.length) {
|
|
33
|
+
this.log('No NocoBase env is configured yet. Run `nb init` to create one first.');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const rows = [];
|
|
37
|
+
for (const envName of envNames) {
|
|
38
|
+
const runtime = await resolveDbRuntime(envName);
|
|
39
|
+
if (!runtime) {
|
|
40
|
+
if (requestedEnv) {
|
|
41
|
+
this.error(formatMissingManagedAppEnvMessage(envName));
|
|
42
|
+
}
|
|
43
|
+
rows.push([envName, '-', '-', 'missing', '']);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const type = runtime.kind === 'builtin' ? 'builtin' : runtime.status;
|
|
47
|
+
const status = runtime.kind === 'builtin'
|
|
48
|
+
? await builtinDbStatus(runtime.containerName)
|
|
49
|
+
: runtime.status;
|
|
50
|
+
rows.push([
|
|
51
|
+
runtime.envName,
|
|
52
|
+
type,
|
|
53
|
+
runtime.dbDialect,
|
|
54
|
+
status,
|
|
55
|
+
runtime.address,
|
|
56
|
+
]);
|
|
57
|
+
}
|
|
58
|
+
this.log(renderTable(['Env', 'Type', 'Dialect', 'Status', 'Address'], rows));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
*/
|
|
9
|
+
import { dockerContainerExists, dockerContainerIsRunning, resolveManagedAppRuntime, } from '../../lib/app-runtime.js';
|
|
10
|
+
import { resolveBuiltinDbConnection } from '../../lib/builtin-db.js';
|
|
11
|
+
function formatAddress(host, port, fallbackHost) {
|
|
12
|
+
const normalizedHost = String(host ?? '').trim() || String(fallbackHost ?? '').trim();
|
|
13
|
+
const normalizedPort = String(port ?? '').trim();
|
|
14
|
+
if (normalizedHost && normalizedPort) {
|
|
15
|
+
return `${normalizedHost}:${normalizedPort}`;
|
|
16
|
+
}
|
|
17
|
+
return normalizedHost || normalizedPort || '';
|
|
18
|
+
}
|
|
19
|
+
export async function resolveDbRuntime(envName) {
|
|
20
|
+
const runtime = await resolveManagedAppRuntime(envName);
|
|
21
|
+
if (!runtime) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const source = runtime.kind === 'http' || runtime.kind === 'ssh' ? runtime.kind : runtime.source;
|
|
25
|
+
const dbDialect = String(runtime.env.config.dbDialect ?? 'postgres').trim() || 'postgres';
|
|
26
|
+
if ((runtime.kind === 'local' || runtime.kind === 'docker') && runtime.env.config.builtinDb) {
|
|
27
|
+
const connection = await resolveBuiltinDbConnection(runtime);
|
|
28
|
+
return {
|
|
29
|
+
kind: 'builtin',
|
|
30
|
+
envName: runtime.envName,
|
|
31
|
+
source,
|
|
32
|
+
dbDialect: connection.dbDialect,
|
|
33
|
+
containerName: connection.containerName,
|
|
34
|
+
address: formatAddress(connection.dbHost, connection.dbPort, connection.containerName),
|
|
35
|
+
appRuntime: runtime,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
kind: 'external',
|
|
40
|
+
envName: runtime.envName,
|
|
41
|
+
source,
|
|
42
|
+
dbDialect,
|
|
43
|
+
address: formatAddress(runtime.env.config.dbHost, runtime.env.config.dbPort),
|
|
44
|
+
status: runtime.kind === 'http' || runtime.kind === 'ssh' ? runtime.kind : 'external',
|
|
45
|
+
appRuntime: runtime,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export async function builtinDbStatus(containerName) {
|
|
49
|
+
if (!(await dockerContainerExists(containerName))) {
|
|
50
|
+
return 'missing';
|
|
51
|
+
}
|
|
52
|
+
return await dockerContainerIsRunning(containerName) ? 'running' : 'stopped';
|
|
53
|
+
}
|
|
54
|
+
export function formatUnmanagedDbMessage(action, runtime) {
|
|
55
|
+
const verb = action === 'start' ? 'start' : 'stop';
|
|
56
|
+
if (runtime.appRuntime.kind === 'http') {
|
|
57
|
+
return [
|
|
58
|
+
`Can't ${verb} the database for "${runtime.envName}" from this machine.`,
|
|
59
|
+
'This env only has an API connection, so there is no CLI-managed database container here.',
|
|
60
|
+
'If you need CLI-managed database start and stop, create a local env with the built-in database option enabled.',
|
|
61
|
+
].join('\n');
|
|
62
|
+
}
|
|
63
|
+
if (runtime.appRuntime.kind === 'ssh') {
|
|
64
|
+
return [
|
|
65
|
+
`Can't ${verb} the database for "${runtime.envName}" yet.`,
|
|
66
|
+
'SSH env support is reserved but not implemented yet.',
|
|
67
|
+
'Use a local env with the built-in database option enabled if you need CLI-managed database operations right now.',
|
|
68
|
+
].join('\n');
|
|
69
|
+
}
|
|
70
|
+
return [
|
|
71
|
+
`Can't ${verb} the database for "${runtime.envName}" from this machine.`,
|
|
72
|
+
'This env does not use a CLI-managed built-in database, so there is no saved database container to manage here.',
|
|
73
|
+
'If you need CLI-managed database start and stop, recreate the env with the built-in database option enabled.',
|
|
74
|
+
].join('\n');
|
|
75
|
+
}
|
|
76
|
+
export function formatUnmanagedDbLogsMessage(runtime) {
|
|
77
|
+
if (runtime.appRuntime.kind === 'http') {
|
|
78
|
+
return [
|
|
79
|
+
`Can't show database logs for "${runtime.envName}" from this machine.`,
|
|
80
|
+
'This env only has an API connection, so there is no CLI-managed database container here.',
|
|
81
|
+
'If you need CLI-managed database logs, create a local env with the built-in database option enabled.',
|
|
82
|
+
].join('\n');
|
|
83
|
+
}
|
|
84
|
+
if (runtime.appRuntime.kind === 'ssh') {
|
|
85
|
+
return [
|
|
86
|
+
`Can't show database logs for "${runtime.envName}" yet.`,
|
|
87
|
+
'SSH env support is reserved but not implemented yet.',
|
|
88
|
+
'Use a local env with the built-in database option enabled if you need CLI-managed database logs right now.',
|
|
89
|
+
].join('\n');
|
|
90
|
+
}
|
|
91
|
+
return [
|
|
92
|
+
`Can't show database logs for "${runtime.envName}" from this machine.`,
|
|
93
|
+
'This env does not use a CLI-managed built-in database, so there is no saved database container to read logs from here.',
|
|
94
|
+
'If you need CLI-managed database logs, recreate the env with the built-in database option enabled.',
|
|
95
|
+
].join('\n');
|
|
96
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
*/
|
|
9
|
+
import { Command, Flags } from '@oclif/core';
|
|
10
|
+
import { formatMissingManagedAppEnvMessage, startDockerContainer, } from '../../lib/app-runtime.js';
|
|
11
|
+
import { announceTargetEnv, failTask, startTask, succeedTask } from '../../lib/ui.js';
|
|
12
|
+
import { formatUnmanagedDbMessage, resolveDbRuntime } from './shared.js';
|
|
13
|
+
function formatDbStartFailure(envName, message) {
|
|
14
|
+
if (/does not exist/i.test(message)) {
|
|
15
|
+
return [
|
|
16
|
+
`Can't start the database for "${envName}" yet.`,
|
|
17
|
+
'The saved built-in database container for this env could not be found on this machine.',
|
|
18
|
+
'Try reinstalling the env, or check whether the container was removed outside the CLI.',
|
|
19
|
+
`Details: ${message}`,
|
|
20
|
+
].join('\n');
|
|
21
|
+
}
|
|
22
|
+
return [
|
|
23
|
+
`Couldn't start the database for "${envName}".`,
|
|
24
|
+
'Check that the built-in database runtime for this env is still available, then try again.',
|
|
25
|
+
`Details: ${message}`,
|
|
26
|
+
].join('\n');
|
|
27
|
+
}
|
|
28
|
+
export default class DbStart extends Command {
|
|
29
|
+
static description = 'Start the built-in database container for the selected env.';
|
|
30
|
+
static examples = [
|
|
31
|
+
'<%= config.bin %> <%= command.id %>',
|
|
32
|
+
'<%= config.bin %> <%= command.id %> --env app1',
|
|
33
|
+
'<%= config.bin %> <%= command.id %> --env app1 --verbose',
|
|
34
|
+
];
|
|
35
|
+
static flags = {
|
|
36
|
+
env: Flags.string({
|
|
37
|
+
char: 'e',
|
|
38
|
+
description: 'CLI env name to start the built-in database for. Defaults to the current env when omitted',
|
|
39
|
+
}),
|
|
40
|
+
verbose: Flags.boolean({
|
|
41
|
+
description: 'Show raw startup output from the underlying Docker command',
|
|
42
|
+
default: false,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
async run() {
|
|
46
|
+
const { flags } = await this.parse(DbStart);
|
|
47
|
+
const requestedEnv = flags.env?.trim() || undefined;
|
|
48
|
+
const runtime = await resolveDbRuntime(requestedEnv);
|
|
49
|
+
if (!runtime) {
|
|
50
|
+
this.error(formatMissingManagedAppEnvMessage(requestedEnv));
|
|
51
|
+
}
|
|
52
|
+
if (runtime.kind !== 'builtin') {
|
|
53
|
+
this.error(formatUnmanagedDbMessage('start', runtime));
|
|
54
|
+
}
|
|
55
|
+
announceTargetEnv(runtime.envName);
|
|
56
|
+
startTask(`Starting the built-in database for "${runtime.envName}"...`);
|
|
57
|
+
try {
|
|
58
|
+
const state = await startDockerContainer(runtime.containerName, {
|
|
59
|
+
stdio: flags.verbose ? 'inherit' : 'ignore',
|
|
60
|
+
});
|
|
61
|
+
succeedTask(state === 'already-running'
|
|
62
|
+
? `The built-in database is already running for "${runtime.envName}"${runtime.address ? ` at ${runtime.address}` : ''}.`
|
|
63
|
+
: `The built-in database is running for "${runtime.envName}"${runtime.address ? ` at ${runtime.address}` : ''}.`);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
67
|
+
failTask(`Failed to start the built-in database for "${runtime.envName}".`);
|
|
68
|
+
this.error(formatDbStartFailure(runtime.envName, message));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
*/
|
|
9
|
+
import { Command, Flags } from '@oclif/core';
|
|
10
|
+
import { formatMissingManagedAppEnvMessage, stopDockerContainer, } from '../../lib/app-runtime.js';
|
|
11
|
+
import { announceTargetEnv, failTask, startTask, succeedTask } from '../../lib/ui.js';
|
|
12
|
+
import { formatUnmanagedDbMessage, resolveDbRuntime } from './shared.js';
|
|
13
|
+
function formatDbStopFailure(envName, message) {
|
|
14
|
+
if (/does not exist/i.test(message)) {
|
|
15
|
+
return [
|
|
16
|
+
`Can't stop the database for "${envName}" yet.`,
|
|
17
|
+
'The saved built-in database container for this env could not be found on this machine.',
|
|
18
|
+
'If it was removed manually, reinstall or reconnect the env before trying again.',
|
|
19
|
+
`Details: ${message}`,
|
|
20
|
+
].join('\n');
|
|
21
|
+
}
|
|
22
|
+
return [
|
|
23
|
+
`Couldn't stop the database for "${envName}".`,
|
|
24
|
+
'Check that the built-in database runtime for this env is still available, then try again.',
|
|
25
|
+
`Details: ${message}`,
|
|
26
|
+
].join('\n');
|
|
27
|
+
}
|
|
28
|
+
export default class DbStop extends Command {
|
|
29
|
+
static description = 'Stop the built-in database container for the selected env.';
|
|
30
|
+
static examples = [
|
|
31
|
+
'<%= config.bin %> <%= command.id %>',
|
|
32
|
+
'<%= config.bin %> <%= command.id %> --env app1',
|
|
33
|
+
'<%= config.bin %> <%= command.id %> --env app1 --verbose',
|
|
34
|
+
];
|
|
35
|
+
static flags = {
|
|
36
|
+
env: Flags.string({
|
|
37
|
+
char: 'e',
|
|
38
|
+
description: 'CLI env name to stop the built-in database for. Defaults to the current env when omitted',
|
|
39
|
+
}),
|
|
40
|
+
verbose: Flags.boolean({
|
|
41
|
+
description: 'Show raw shutdown output from the underlying Docker command',
|
|
42
|
+
default: false,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
async run() {
|
|
46
|
+
const { flags } = await this.parse(DbStop);
|
|
47
|
+
const requestedEnv = flags.env?.trim() || undefined;
|
|
48
|
+
const runtime = await resolveDbRuntime(requestedEnv);
|
|
49
|
+
if (!runtime) {
|
|
50
|
+
this.error(formatMissingManagedAppEnvMessage(requestedEnv));
|
|
51
|
+
}
|
|
52
|
+
if (runtime.kind !== 'builtin') {
|
|
53
|
+
this.error(formatUnmanagedDbMessage('stop', runtime));
|
|
54
|
+
}
|
|
55
|
+
announceTargetEnv(runtime.envName);
|
|
56
|
+
startTask(`Stopping the built-in database for "${runtime.envName}"...`);
|
|
57
|
+
try {
|
|
58
|
+
const state = await stopDockerContainer(runtime.containerName, {
|
|
59
|
+
stdio: flags.verbose ? 'inherit' : 'ignore',
|
|
60
|
+
});
|
|
61
|
+
succeedTask(state === 'already-stopped'
|
|
62
|
+
? `The built-in database is already stopped for "${runtime.envName}".`
|
|
63
|
+
: `The built-in database has stopped for "${runtime.envName}".`);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
67
|
+
failTask(`Failed to stop the built-in database for "${runtime.envName}".`);
|
|
68
|
+
this.error(formatDbStopFailure(runtime.envName, message));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
import SourceDev from './source/dev.js';
|
|
10
|
+
export default class Dev extends SourceDev {
|
|
11
|
+
static hidden = true;
|
|
12
|
+
}
|
|
@@ -6,12 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'en-US': require('./en-US.json'),
|
|
13
|
-
'zh-CN': require('./zh-CN.json'),
|
|
14
|
-
'z-TW': require('./zh-TW.json'),
|
|
15
|
-
}
|
|
16
|
-
return langs[lang] || langs['en-US'];
|
|
9
|
+
import AppDown from './app/down.js';
|
|
10
|
+
export default class Down extends AppDown {
|
|
11
|
+
static hidden = true;
|
|
17
12
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
*/
|
|
9
|
+
export { defaultDockerRegistryForLang } from './source/download.js';
|
|
10
|
+
import SourceDownload from './source/download.js';
|
|
11
|
+
export default class Download extends SourceDownload {
|
|
12
|
+
static hidden = true;
|
|
13
|
+
}
|