@nocobase/cli 2.1.0-beta.9 → 2.1.0
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/assets/env-proxy/nginx/app.conf.tpl +23 -0
- package/assets/env-proxy/nginx/nocobase.conf.tpl +5 -0
- package/assets/env-proxy/nginx/snippets/dist-location.conf +5 -0
- package/assets/env-proxy/nginx/snippets/gzip.conf +17 -0
- package/assets/env-proxy/nginx/snippets/log-format-http.conf +13 -0
- package/assets/env-proxy/nginx/snippets/maps-http.conf +14 -0
- package/assets/env-proxy/nginx/snippets/mime-types.conf +98 -0
- package/assets/env-proxy/nginx/snippets/proxy-location.conf +17 -0
- package/assets/env-proxy/nginx/snippets/spa-location.conf +6 -0
- package/assets/env-proxy/nginx/snippets/uploads-location.conf +21 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +145 -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/autostart/disable.js +55 -0
- package/dist/commands/app/autostart/enable.js +55 -0
- package/dist/commands/app/autostart/list.js +37 -0
- package/dist/commands/app/autostart/run.js +84 -0
- package/dist/commands/app/autostart/shared.js +49 -0
- package/dist/commands/app/destroy.js +234 -0
- package/dist/commands/app/down.js +71 -0
- package/dist/commands/app/logs.js +115 -0
- package/dist/commands/app/restart.js +229 -0
- package/dist/commands/app/shared.js +123 -0
- package/dist/commands/app/start.js +416 -0
- package/dist/commands/app/stop.js +183 -0
- package/dist/commands/app/upgrade.js +523 -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 +42 -0
- package/dist/commands/config/get.js +39 -0
- package/dist/commands/config/index.js +20 -0
- package/dist/commands/config/list.js +29 -0
- package/dist/commands/config/set.js +49 -0
- package/dist/commands/db/check.js +240 -0
- package/dist/commands/db/logs.js +85 -0
- package/dist/commands/db/ps.js +47 -0
- package/dist/commands/db/shared.js +96 -0
- package/dist/commands/db/start.js +86 -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 +406 -0
- package/dist/commands/env/auth.js +189 -0
- package/dist/commands/env/current.js +21 -0
- package/dist/commands/env/info.js +202 -0
- package/dist/commands/env/list.js +43 -0
- package/dist/commands/env/remove.js +174 -0
- package/dist/commands/env/shared.js +204 -0
- package/dist/commands/env/status.js +93 -0
- package/dist/commands/env/update.js +448 -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 +1390 -0
- package/dist/commands/install.js +2609 -0
- package/dist/commands/license/activate.js +179 -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 +382 -0
- package/dist/commands/license/plugins/sync.js +314 -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/import.js +108 -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/proxy/caddy/current.js +17 -0
- package/dist/commands/proxy/caddy/generate.js +69 -0
- package/dist/commands/proxy/caddy/index.js +28 -0
- package/dist/commands/proxy/caddy/info.js +31 -0
- package/dist/commands/proxy/caddy/reload.js +30 -0
- package/dist/commands/proxy/caddy/restart.js +28 -0
- package/dist/commands/proxy/caddy/start.js +30 -0
- package/dist/commands/proxy/caddy/status.js +19 -0
- package/dist/commands/proxy/caddy/stop.js +30 -0
- package/dist/commands/proxy/caddy/use.js +26 -0
- package/dist/commands/proxy/index.js +28 -0
- package/dist/commands/proxy/nginx/current.js +18 -0
- package/dist/commands/proxy/nginx/generate.js +68 -0
- package/dist/commands/proxy/nginx/index.js +28 -0
- package/dist/commands/proxy/nginx/info.js +34 -0
- package/dist/commands/proxy/nginx/reload.js +30 -0
- package/dist/commands/proxy/nginx/restart.js +28 -0
- package/dist/commands/proxy/nginx/start.js +30 -0
- package/dist/commands/proxy/nginx/status.js +19 -0
- package/dist/commands/proxy/nginx/stop.js +30 -0
- package/dist/commands/proxy/nginx/use.js +31 -0
- package/dist/commands/restart.js +12 -0
- package/dist/commands/revision/create.js +118 -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 +152 -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 +884 -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 +476 -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 +134 -0
- package/dist/help/runtime-help.js +23 -0
- package/dist/lib/api-client.js +335 -0
- package/dist/lib/api-command-compat.js +641 -0
- package/dist/lib/app-health.js +139 -0
- package/dist/lib/app-managed-resources.js +337 -0
- package/dist/lib/app-public-path.js +80 -0
- package/dist/lib/app-runtime.js +189 -0
- package/dist/lib/auth-store.js +528 -0
- package/dist/lib/backup.js +171 -0
- package/dist/lib/bootstrap.js +409 -0
- package/dist/lib/build-config.js +18 -0
- package/dist/lib/builtin-db.js +86 -0
- package/dist/lib/cli-config.js +569 -0
- package/dist/lib/cli-entry-error.js +52 -0
- package/dist/lib/cli-home.js +47 -0
- package/dist/lib/cli-locale.js +141 -0
- package/dist/lib/command-discovery.js +39 -0
- package/dist/lib/command-log.js +284 -0
- package/dist/lib/db-connection-check.js +219 -0
- package/dist/lib/docker-env-file.js +60 -0
- package/dist/lib/docker-image.js +37 -0
- package/dist/lib/docker-log-stream.js +45 -0
- package/dist/lib/env-auth.js +963 -0
- package/dist/lib/env-command-config.js +45 -0
- package/dist/lib/env-config.js +108 -0
- package/dist/lib/env-guard.js +61 -0
- package/dist/lib/env-paths.js +101 -0
- package/dist/lib/env-proxy.js +1325 -0
- package/dist/lib/generated-command.js +203 -0
- package/dist/lib/http-request.js +49 -0
- package/dist/lib/inquirer-theme.js +17 -0
- package/dist/lib/inquirer.js +243 -0
- package/dist/lib/managed-env-file.js +101 -0
- package/dist/lib/managed-init-env.js +32 -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-import.js +279 -0
- package/dist/lib/plugin-storage.js +64 -0
- package/dist/lib/post-processors.js +23 -0
- package/dist/lib/prompt-catalog-core.js +186 -0
- package/dist/lib/prompt-catalog-terminal.js +374 -0
- package/{src/index.js → dist/lib/prompt-catalog.js} +2 -6
- package/dist/lib/prompt-validators.js +278 -0
- package/dist/lib/prompt-web-ui.js +2234 -0
- package/dist/lib/proxy-caddy.js +274 -0
- package/dist/lib/proxy-nginx.js +330 -0
- package/dist/lib/resource-command.js +357 -0
- package/dist/lib/resource-request.js +104 -0
- package/dist/lib/run-npm.js +429 -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 +438 -0
- package/dist/lib/source-publish.js +326 -0
- package/dist/lib/source-registry.js +188 -0
- package/dist/lib/startup-update.js +309 -0
- package/dist/lib/ui.js +159 -0
- package/dist/locale/en-US.json +526 -0
- package/dist/locale/zh-CN.json +526 -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 +128 -24
- package/scripts/build.mjs +34 -0
- package/scripts/clean.mjs +9 -0
- package/tsconfig.json +19 -0
- 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,406 @@
|
|
|
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 { Args, Command, Flags } from '@oclif/core';
|
|
10
|
+
import { setCurrentEnv, upsertEnv } from '../../lib/auth-store.js';
|
|
11
|
+
import { resolveDefaultConfigScope } from '../../lib/cli-home.js';
|
|
12
|
+
import { ENV_BOOLEAN_CONFIG_FLAG_MAP, ENV_STRING_CONFIG_FLAG_MAP } from '../../lib/env-command-config.js';
|
|
13
|
+
import { buildStoredEnvConfig } from '../../lib/env-config.js';
|
|
14
|
+
import { runPromptCatalog, } from '../../lib/prompt-catalog.js';
|
|
15
|
+
import { applyCliLocale, CLI_LOCALE_FLAG_DESCRIPTION, CLI_LOCALE_FLAG_OPTIONS, localeText, } from '../../lib/cli-locale.js';
|
|
16
|
+
import { validateApiBaseUrl } from '../../lib/prompt-validators.js';
|
|
17
|
+
import { printInfo, printStage, printSuccess, printVerbose, setVerboseMode } from '../../lib/ui.js';
|
|
18
|
+
const envAddText = (key, values) => localeText(`commands.envAdd.${key}`, values);
|
|
19
|
+
const envAddAccessTokenPrompt = {
|
|
20
|
+
type: 'text',
|
|
21
|
+
message: envAddText('prompts.accessToken.message'),
|
|
22
|
+
required: true,
|
|
23
|
+
hidden: (values) => values.authType !== 'token' || values.skipAuth === true,
|
|
24
|
+
};
|
|
25
|
+
const envAddUsernamePrompt = {
|
|
26
|
+
type: 'text',
|
|
27
|
+
message: envAddText('prompts.username.message'),
|
|
28
|
+
placeholder: envAddText('prompts.username.placeholder'),
|
|
29
|
+
required: true,
|
|
30
|
+
hidden: (values) => values.authType !== 'basic' || values.skipAuth === true,
|
|
31
|
+
};
|
|
32
|
+
const envAddPasswordPrompt = {
|
|
33
|
+
type: 'password',
|
|
34
|
+
message: envAddText('prompts.password.message'),
|
|
35
|
+
required: true,
|
|
36
|
+
hidden: (values) => values.authType !== 'basic' || values.skipAuth === true,
|
|
37
|
+
};
|
|
38
|
+
function formatDeferredAuthMessage(envName, authType) {
|
|
39
|
+
const normalizedAuthType = String(authType ?? '').trim();
|
|
40
|
+
const nextStep = `Authentication was skipped for env "${envName}". Run \`nb env auth ${envName}\` to finish setup.`;
|
|
41
|
+
if (normalizedAuthType === 'basic') {
|
|
42
|
+
return `${nextStep} You will be prompted for a username and password.`;
|
|
43
|
+
}
|
|
44
|
+
if (normalizedAuthType === 'token') {
|
|
45
|
+
return `${nextStep} You will be prompted for an access token.`;
|
|
46
|
+
}
|
|
47
|
+
if (normalizedAuthType === 'oauth') {
|
|
48
|
+
return `${nextStep} A browser sign-in flow will be started.`;
|
|
49
|
+
}
|
|
50
|
+
return nextStep;
|
|
51
|
+
}
|
|
52
|
+
export default class EnvAdd extends Command {
|
|
53
|
+
static summary = 'Save a named NocoBase API endpoint (basic, token, or OAuth), then switch the CLI to use it';
|
|
54
|
+
static examples = [
|
|
55
|
+
'<%= config.bin %> <%= command.id %>',
|
|
56
|
+
'<%= config.bin %> <%= command.id %> local',
|
|
57
|
+
'<%= config.bin %> <%= command.id %> local --api-base-url http://localhost:13000/api --auth-type oauth',
|
|
58
|
+
];
|
|
59
|
+
static args = {
|
|
60
|
+
name: Args.string({
|
|
61
|
+
description: 'Environment name to save (optional first argument; in a TTY, prompted when omitted; required when not using a TTY)',
|
|
62
|
+
required: false,
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
static flags = {
|
|
66
|
+
env: Flags.string({
|
|
67
|
+
char: 'e',
|
|
68
|
+
hidden: true,
|
|
69
|
+
deprecated: true,
|
|
70
|
+
description: 'Environment name (same as the optional positional argument; for compatibility with -e/--env on other commands)',
|
|
71
|
+
}),
|
|
72
|
+
verbose: Flags.boolean({
|
|
73
|
+
description: 'Print detailed progress while writing config',
|
|
74
|
+
default: false,
|
|
75
|
+
}),
|
|
76
|
+
locale: Flags.string({
|
|
77
|
+
description: CLI_LOCALE_FLAG_DESCRIPTION,
|
|
78
|
+
options: CLI_LOCALE_FLAG_OPTIONS,
|
|
79
|
+
}),
|
|
80
|
+
'no-intro': Flags.boolean({
|
|
81
|
+
hidden: true,
|
|
82
|
+
description: 'Skip command intro when invoked by another CLI command',
|
|
83
|
+
default: false,
|
|
84
|
+
}),
|
|
85
|
+
'default-api-base-url': Flags.string({
|
|
86
|
+
char: 'd',
|
|
87
|
+
hidden: true,
|
|
88
|
+
description: 'Default API base URL for HTTP API calls, including the /api prefix (e.g. http://localhost:13000/api); prompted in a TTY when omitted',
|
|
89
|
+
}),
|
|
90
|
+
'api-base-url': Flags.string({
|
|
91
|
+
char: 'u',
|
|
92
|
+
description: 'Root URL for HTTP API calls, including the /api prefix (e.g. http://localhost:13000/api); prompted in a TTY when omitted',
|
|
93
|
+
}),
|
|
94
|
+
'auth-type': Flags.string({
|
|
95
|
+
char: 'a',
|
|
96
|
+
description: 'Authentication: basic (username/password login), token (API key), or oauth (browser login via `nb env auth`); prompted in a TTY when omitted',
|
|
97
|
+
options: ['basic', 'token', 'oauth'],
|
|
98
|
+
}),
|
|
99
|
+
'access-token': Flags.string({
|
|
100
|
+
char: 't',
|
|
101
|
+
aliases: ['token'],
|
|
102
|
+
description: 'API key or access token when using --auth-type token (prompted in a TTY when omitted)',
|
|
103
|
+
}),
|
|
104
|
+
username: Flags.string({
|
|
105
|
+
description: 'Username when using --auth-type basic (prompted in a TTY when omitted)',
|
|
106
|
+
}),
|
|
107
|
+
password: Flags.string({
|
|
108
|
+
description: 'Password when using --auth-type basic (prompted in a TTY when omitted)',
|
|
109
|
+
}),
|
|
110
|
+
'skip-auth': Flags.boolean({
|
|
111
|
+
description: 'Save the env now and finish authentication later with `nb env auth`',
|
|
112
|
+
default: false,
|
|
113
|
+
}),
|
|
114
|
+
source: Flags.string({
|
|
115
|
+
hidden: true,
|
|
116
|
+
description: 'Application source saved with this env',
|
|
117
|
+
}),
|
|
118
|
+
'download-version': Flags.string({
|
|
119
|
+
hidden: true,
|
|
120
|
+
description: 'Downloaded app version saved with this env',
|
|
121
|
+
}),
|
|
122
|
+
'docker-registry': Flags.string({
|
|
123
|
+
hidden: true,
|
|
124
|
+
description: 'Docker registry saved with this env',
|
|
125
|
+
}),
|
|
126
|
+
'docker-platform': Flags.string({
|
|
127
|
+
hidden: true,
|
|
128
|
+
description: 'Docker image platform saved with this env',
|
|
129
|
+
}),
|
|
130
|
+
'git-url': Flags.string({
|
|
131
|
+
hidden: true,
|
|
132
|
+
description: 'Git repository URL saved with this env',
|
|
133
|
+
}),
|
|
134
|
+
'npm-registry': Flags.string({
|
|
135
|
+
hidden: true,
|
|
136
|
+
description: 'npm registry saved with this env',
|
|
137
|
+
}),
|
|
138
|
+
'dev-dependencies': Flags.boolean({
|
|
139
|
+
allowNo: true,
|
|
140
|
+
hidden: true,
|
|
141
|
+
description: 'Whether development dependencies were installed for this env',
|
|
142
|
+
}),
|
|
143
|
+
build: Flags.boolean({
|
|
144
|
+
allowNo: true,
|
|
145
|
+
hidden: true,
|
|
146
|
+
description: 'Whether the app was built after download for this env',
|
|
147
|
+
}),
|
|
148
|
+
'build-dts': Flags.boolean({
|
|
149
|
+
allowNo: true,
|
|
150
|
+
hidden: true,
|
|
151
|
+
description: 'Whether declaration files were emitted during build for this env',
|
|
152
|
+
}),
|
|
153
|
+
'app-path': Flags.string({
|
|
154
|
+
hidden: true,
|
|
155
|
+
description: 'App path saved with this env',
|
|
156
|
+
}),
|
|
157
|
+
'app-root-path': Flags.string({
|
|
158
|
+
hidden: true,
|
|
159
|
+
deprecated: true,
|
|
160
|
+
description: 'Application root path saved with this env',
|
|
161
|
+
}),
|
|
162
|
+
'storage-path': Flags.string({
|
|
163
|
+
hidden: true,
|
|
164
|
+
deprecated: true,
|
|
165
|
+
description: 'Storage path saved with this env',
|
|
166
|
+
}),
|
|
167
|
+
'app-public-path': Flags.string({
|
|
168
|
+
hidden: true,
|
|
169
|
+
description: 'Application public path saved with this env',
|
|
170
|
+
}),
|
|
171
|
+
'env-file': Flags.string({
|
|
172
|
+
hidden: true,
|
|
173
|
+
description: 'Docker env file saved with this env',
|
|
174
|
+
}),
|
|
175
|
+
'app-port': Flags.string({
|
|
176
|
+
hidden: true,
|
|
177
|
+
description: 'Application HTTP port saved with this env',
|
|
178
|
+
}),
|
|
179
|
+
'app-key': Flags.string({
|
|
180
|
+
hidden: true,
|
|
181
|
+
description: 'Application secret key saved with this env',
|
|
182
|
+
}),
|
|
183
|
+
timezone: Flags.string({
|
|
184
|
+
hidden: true,
|
|
185
|
+
description: 'Application timezone saved with this env',
|
|
186
|
+
}),
|
|
187
|
+
'builtin-db': Flags.boolean({
|
|
188
|
+
allowNo: true,
|
|
189
|
+
hidden: true,
|
|
190
|
+
description: 'Whether this env uses a CLI-managed built-in database',
|
|
191
|
+
}),
|
|
192
|
+
'db-dialect': Flags.string({
|
|
193
|
+
hidden: true,
|
|
194
|
+
description: 'Database dialect saved with this env',
|
|
195
|
+
}),
|
|
196
|
+
'builtin-db-image': Flags.string({
|
|
197
|
+
hidden: true,
|
|
198
|
+
description: 'Built-in database image saved with this env',
|
|
199
|
+
}),
|
|
200
|
+
'db-host': Flags.string({
|
|
201
|
+
hidden: true,
|
|
202
|
+
description: 'Database host saved with this env',
|
|
203
|
+
}),
|
|
204
|
+
'db-port': Flags.string({
|
|
205
|
+
hidden: true,
|
|
206
|
+
description: 'Database port saved with this env',
|
|
207
|
+
}),
|
|
208
|
+
'db-database': Flags.string({
|
|
209
|
+
hidden: true,
|
|
210
|
+
description: 'Database name saved with this env',
|
|
211
|
+
}),
|
|
212
|
+
'db-user': Flags.string({
|
|
213
|
+
hidden: true,
|
|
214
|
+
description: 'Database user saved with this env',
|
|
215
|
+
}),
|
|
216
|
+
'db-password': Flags.string({
|
|
217
|
+
hidden: true,
|
|
218
|
+
description: 'Database password saved with this env',
|
|
219
|
+
}),
|
|
220
|
+
'db-schema': Flags.string({
|
|
221
|
+
hidden: true,
|
|
222
|
+
description: 'Database schema saved with this env',
|
|
223
|
+
}),
|
|
224
|
+
'db-table-prefix': Flags.string({
|
|
225
|
+
hidden: true,
|
|
226
|
+
description: 'Database table prefix saved with this env',
|
|
227
|
+
}),
|
|
228
|
+
'db-underscored': Flags.boolean({
|
|
229
|
+
allowNo: true,
|
|
230
|
+
hidden: true,
|
|
231
|
+
description: 'Whether this env uses underscored database naming',
|
|
232
|
+
}),
|
|
233
|
+
'root-username': Flags.string({
|
|
234
|
+
hidden: true,
|
|
235
|
+
description: 'Initial root username saved with this env',
|
|
236
|
+
}),
|
|
237
|
+
'root-email': Flags.string({
|
|
238
|
+
hidden: true,
|
|
239
|
+
description: 'Initial root email saved with this env',
|
|
240
|
+
}),
|
|
241
|
+
'root-password': Flags.string({
|
|
242
|
+
hidden: true,
|
|
243
|
+
description: 'Initial root password saved with this env',
|
|
244
|
+
}),
|
|
245
|
+
'root-nickname': Flags.string({
|
|
246
|
+
hidden: true,
|
|
247
|
+
description: 'Initial root nickname saved with this env',
|
|
248
|
+
}),
|
|
249
|
+
};
|
|
250
|
+
static prompts = {
|
|
251
|
+
name: {
|
|
252
|
+
type: 'text',
|
|
253
|
+
message: envAddText('prompts.name.message'),
|
|
254
|
+
placeholder: envAddText('prompts.name.placeholder'),
|
|
255
|
+
required: true,
|
|
256
|
+
},
|
|
257
|
+
apiBaseUrl: {
|
|
258
|
+
type: 'text',
|
|
259
|
+
message: envAddText('prompts.apiBaseUrl.message'),
|
|
260
|
+
placeholder: envAddText('prompts.apiBaseUrl.placeholder'),
|
|
261
|
+
required: true,
|
|
262
|
+
validate: validateApiBaseUrl,
|
|
263
|
+
},
|
|
264
|
+
authType: {
|
|
265
|
+
type: 'select',
|
|
266
|
+
message: envAddText('prompts.authType.message'),
|
|
267
|
+
options: [
|
|
268
|
+
{
|
|
269
|
+
value: 'oauth',
|
|
270
|
+
label: envAddText('prompts.authType.oauthLabel'),
|
|
271
|
+
hint: envAddText('prompts.authType.oauthHint'),
|
|
272
|
+
},
|
|
273
|
+
{ value: 'token', label: envAddText('prompts.authType.tokenLabel') },
|
|
274
|
+
{
|
|
275
|
+
value: 'basic',
|
|
276
|
+
label: envAddText('prompts.authType.basicLabel'),
|
|
277
|
+
hint: envAddText('prompts.authType.basicHint'),
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
initialValue: 'oauth',
|
|
281
|
+
required: true,
|
|
282
|
+
},
|
|
283
|
+
username: envAddUsernamePrompt,
|
|
284
|
+
password: envAddPasswordPrompt,
|
|
285
|
+
accessToken: envAddAccessTokenPrompt,
|
|
286
|
+
};
|
|
287
|
+
buildPromptValues(nameArg, flags) {
|
|
288
|
+
const values = {};
|
|
289
|
+
const name = nameArg?.trim() || flags.env?.trim();
|
|
290
|
+
if (name) {
|
|
291
|
+
values.name = name;
|
|
292
|
+
}
|
|
293
|
+
const apiFromFlag = flags['api-base-url'];
|
|
294
|
+
if (typeof apiFromFlag === 'string' && apiFromFlag.trim() !== '') {
|
|
295
|
+
values.apiBaseUrl = apiFromFlag.trim();
|
|
296
|
+
}
|
|
297
|
+
if (flags['auth-type']) {
|
|
298
|
+
values.authType = flags['auth-type'];
|
|
299
|
+
}
|
|
300
|
+
if (flags['skip-auth']) {
|
|
301
|
+
values.skipAuth = true;
|
|
302
|
+
}
|
|
303
|
+
const token = flags['access-token'] ?? flags.token;
|
|
304
|
+
if (typeof token === 'string' && token !== '') {
|
|
305
|
+
values.accessToken = token;
|
|
306
|
+
}
|
|
307
|
+
if (flags.username !== undefined) {
|
|
308
|
+
values.username = String(flags.username ?? '').trim();
|
|
309
|
+
}
|
|
310
|
+
if (flags.password !== undefined) {
|
|
311
|
+
values.password = String(flags.password ?? '');
|
|
312
|
+
}
|
|
313
|
+
return values;
|
|
314
|
+
}
|
|
315
|
+
buildPromptInitialValues(flags) {
|
|
316
|
+
const initialValues = {};
|
|
317
|
+
const defaultApiBaseUrl = flags['default-api-base-url']?.trim();
|
|
318
|
+
if (defaultApiBaseUrl) {
|
|
319
|
+
initialValues.apiBaseUrl = defaultApiBaseUrl;
|
|
320
|
+
}
|
|
321
|
+
return initialValues;
|
|
322
|
+
}
|
|
323
|
+
buildPromptCatalog(flags) {
|
|
324
|
+
if (!flags['skip-auth']) {
|
|
325
|
+
return EnvAdd.prompts;
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
...EnvAdd.prompts,
|
|
329
|
+
username: {
|
|
330
|
+
...envAddUsernamePrompt,
|
|
331
|
+
hidden: () => true,
|
|
332
|
+
},
|
|
333
|
+
password: {
|
|
334
|
+
...envAddPasswordPrompt,
|
|
335
|
+
hidden: () => true,
|
|
336
|
+
},
|
|
337
|
+
accessToken: {
|
|
338
|
+
...envAddAccessTokenPrompt,
|
|
339
|
+
hidden: () => true,
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
buildEnvConfig(results, flags) {
|
|
344
|
+
const authType = String(results.authType ?? '').trim();
|
|
345
|
+
const authUsername = authType === 'basic' ? String(results.username ?? flags.username ?? '').trim() : '';
|
|
346
|
+
const envConfigInput = {
|
|
347
|
+
apiBaseUrl: results.apiBaseUrl,
|
|
348
|
+
authType,
|
|
349
|
+
authUsername: authUsername || undefined,
|
|
350
|
+
accessToken: results.accessToken,
|
|
351
|
+
};
|
|
352
|
+
for (const [flagName, configKey] of Object.entries(ENV_STRING_CONFIG_FLAG_MAP)) {
|
|
353
|
+
const value = flags[flagName];
|
|
354
|
+
envConfigInput[configKey] = value;
|
|
355
|
+
}
|
|
356
|
+
for (const [flagName, configKey] of Object.entries(ENV_BOOLEAN_CONFIG_FLAG_MAP)) {
|
|
357
|
+
const value = flags[flagName];
|
|
358
|
+
envConfigInput[configKey] = value;
|
|
359
|
+
}
|
|
360
|
+
return buildStoredEnvConfig(envConfigInput);
|
|
361
|
+
}
|
|
362
|
+
async run() {
|
|
363
|
+
const { args, flags } = await this.parse(EnvAdd);
|
|
364
|
+
const parsedFlags = flags;
|
|
365
|
+
if (parsedFlags['skip-auth'] && (parsedFlags['access-token'] !== undefined || parsedFlags.token !== undefined)) {
|
|
366
|
+
this.error('--skip-auth cannot be used with --access-token or --token.');
|
|
367
|
+
}
|
|
368
|
+
applyCliLocale(parsedFlags.locale);
|
|
369
|
+
setVerboseMode(parsedFlags.verbose);
|
|
370
|
+
if (!parsedFlags['no-intro']) {
|
|
371
|
+
printStage('Connect to NocoBase');
|
|
372
|
+
}
|
|
373
|
+
const results = await runPromptCatalog(this.buildPromptCatalog(parsedFlags), {
|
|
374
|
+
values: this.buildPromptValues(args.name, parsedFlags),
|
|
375
|
+
initialValues: this.buildPromptInitialValues(parsedFlags),
|
|
376
|
+
command: this,
|
|
377
|
+
});
|
|
378
|
+
const envName = String(results.name);
|
|
379
|
+
const envConfig = this.buildEnvConfig(results, parsedFlags);
|
|
380
|
+
printVerbose(`Saving env "${envName}" globally.`);
|
|
381
|
+
await upsertEnv(envName, envConfig, { scope: resolveDefaultConfigScope() });
|
|
382
|
+
await setCurrentEnv(envName, { scope: resolveDefaultConfigScope() });
|
|
383
|
+
if (parsedFlags['skip-auth']) {
|
|
384
|
+
printSuccess(`✔ Env "${envName}" was saved.`);
|
|
385
|
+
printInfo(formatDeferredAuthMessage(envName, results.authType));
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (results.authType === 'oauth' || results.authType === 'basic') {
|
|
389
|
+
const authArgv = [envName];
|
|
390
|
+
if (results.authType === 'basic') {
|
|
391
|
+
authArgv.push('--auth-type', 'basic');
|
|
392
|
+
const username = String(results.username ?? '').trim();
|
|
393
|
+
const password = String(results.password ?? '');
|
|
394
|
+
if (username) {
|
|
395
|
+
authArgv.push('--username', username);
|
|
396
|
+
}
|
|
397
|
+
if (password) {
|
|
398
|
+
authArgv.push('--password', password);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
await this.config.runCommand('env:auth', authArgv);
|
|
402
|
+
}
|
|
403
|
+
await this.config.runCommand('env:update', [envName]);
|
|
404
|
+
printSuccess(`✔ Env "${envName}" is ready.`);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
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 { Args, Command, Flags } from '@oclif/core';
|
|
10
|
+
import { getCurrentEnvName, getEnv, resolveConfiguredAuthType, updateEnvConnection } from '../../lib/auth-store.js';
|
|
11
|
+
import { resolveDefaultConfigScope } from '../../lib/cli-home.js';
|
|
12
|
+
import { authenticateEnvWithBasic, authenticateEnvWithOauth } from '../../lib/env-auth.js';
|
|
13
|
+
import { runPromptCatalog } from '../../lib/prompt-catalog.js';
|
|
14
|
+
import { failTask, isInteractiveTerminal, printStage, startTask, stopTask, succeedTask } from '../../lib/ui.js';
|
|
15
|
+
import EnvAdd from "./add.js";
|
|
16
|
+
const envAuthPrompts = {
|
|
17
|
+
authType: EnvAdd.prompts.authType,
|
|
18
|
+
username: EnvAdd.prompts.username,
|
|
19
|
+
password: EnvAdd.prompts.password,
|
|
20
|
+
accessToken: EnvAdd.prompts.accessToken,
|
|
21
|
+
};
|
|
22
|
+
function resolveExplicitAuthType(value) {
|
|
23
|
+
return value === 'basic' || value === 'token' || value === 'oauth' ? value : undefined;
|
|
24
|
+
}
|
|
25
|
+
function formatMissingEnvMessage(envName) {
|
|
26
|
+
return [`Env "${envName}" is not configured.`, `Run \`nb init --ui --env ${envName}\` first.`].join('\n');
|
|
27
|
+
}
|
|
28
|
+
export default class EnvAuth extends Command {
|
|
29
|
+
static summary = 'Authenticate a saved NocoBase environment with basic login, a token, or OAuth';
|
|
30
|
+
static examples = [
|
|
31
|
+
'<%= config.bin %> <%= command.id %>',
|
|
32
|
+
'<%= config.bin %> <%= command.id %> prod',
|
|
33
|
+
'<%= config.bin %> <%= command.id %> prod --auth-type basic --username admin --password secret',
|
|
34
|
+
'<%= config.bin %> <%= command.id %> prod --auth-type token --access-token <api-key>',
|
|
35
|
+
];
|
|
36
|
+
static args = {
|
|
37
|
+
name: Args.string({
|
|
38
|
+
description: 'Configured environment name to sign in to. Defaults to the current env when omitted',
|
|
39
|
+
required: false,
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
static flags = {
|
|
43
|
+
env: Flags.string({
|
|
44
|
+
char: 'e',
|
|
45
|
+
hidden: true,
|
|
46
|
+
deprecated: true,
|
|
47
|
+
description: 'Environment name (same as the optional positional argument; for compatibility with -e/--env on other commands)',
|
|
48
|
+
}),
|
|
49
|
+
'auth-type': Flags.string({
|
|
50
|
+
char: 'a',
|
|
51
|
+
description: 'Authentication: basic (username/password login), token (API key), or oauth (browser login)',
|
|
52
|
+
options: ['basic', 'token', 'oauth'],
|
|
53
|
+
}),
|
|
54
|
+
'access-token': Flags.string({
|
|
55
|
+
char: 't',
|
|
56
|
+
description: 'API key or access token when using token authentication',
|
|
57
|
+
}),
|
|
58
|
+
username: Flags.string({
|
|
59
|
+
description: 'Username when using basic authentication (prompted in a TTY when omitted)',
|
|
60
|
+
}),
|
|
61
|
+
password: Flags.string({
|
|
62
|
+
description: 'Password when using basic authentication (prompted in a TTY when omitted)',
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
async run() {
|
|
66
|
+
const { args, flags } = await this.parse(EnvAuth);
|
|
67
|
+
const nameArg = args.name?.trim();
|
|
68
|
+
const nameFlag = flags.env?.trim() || undefined;
|
|
69
|
+
if (nameArg && nameFlag && nameArg !== nameFlag) {
|
|
70
|
+
this.error(`Environment name was provided both as the argument ("${nameArg}") and as --env ("${nameFlag}"). Please use only one.`);
|
|
71
|
+
}
|
|
72
|
+
const envName = nameArg || nameFlag || (await getCurrentEnvName({ scope: resolveDefaultConfigScope() }));
|
|
73
|
+
const env = await getEnv(envName, { scope: resolveDefaultConfigScope() });
|
|
74
|
+
if (!env) {
|
|
75
|
+
this.error(formatMissingEnvMessage(envName));
|
|
76
|
+
}
|
|
77
|
+
const tokenFromFlags = flags['access-token'];
|
|
78
|
+
const tokenFlagProvided = tokenFromFlags !== undefined;
|
|
79
|
+
const tokenValue = typeof tokenFromFlags === 'string' ? tokenFromFlags.trim() : '';
|
|
80
|
+
const tokenProvided = tokenValue !== '';
|
|
81
|
+
if (tokenFlagProvided && !tokenProvided) {
|
|
82
|
+
this.error('--access-token cannot be empty.');
|
|
83
|
+
}
|
|
84
|
+
const usernameFromFlags = flags.username;
|
|
85
|
+
const usernameFlagProvided = usernameFromFlags !== undefined;
|
|
86
|
+
const usernameProvided = typeof usernameFromFlags === 'string' && usernameFromFlags.trim() !== '';
|
|
87
|
+
if (usernameFlagProvided && !usernameProvided) {
|
|
88
|
+
this.error('--username cannot be empty.');
|
|
89
|
+
}
|
|
90
|
+
const passwordFromFlags = flags.password;
|
|
91
|
+
const passwordFlagProvided = passwordFromFlags !== undefined;
|
|
92
|
+
const passwordProvided = typeof passwordFromFlags === 'string' && passwordFromFlags.trim() !== '';
|
|
93
|
+
if (passwordFlagProvided && !passwordProvided) {
|
|
94
|
+
this.error('--password cannot be empty.');
|
|
95
|
+
}
|
|
96
|
+
const explicitAuthType = resolveExplicitAuthType(flags['auth-type']);
|
|
97
|
+
if (tokenFlagProvided && (usernameFlagProvided || passwordFlagProvided)) {
|
|
98
|
+
this.error('--access-token cannot be used with --username or --password.');
|
|
99
|
+
}
|
|
100
|
+
if (explicitAuthType === 'oauth' && (tokenFlagProvided || usernameFlagProvided || passwordFlagProvided)) {
|
|
101
|
+
this.error('--auth-type oauth cannot be used with --access-token, --username, or --password.');
|
|
102
|
+
}
|
|
103
|
+
if (explicitAuthType === 'token' && (usernameFlagProvided || passwordFlagProvided)) {
|
|
104
|
+
this.error('--auth-type token cannot be used with --username or --password.');
|
|
105
|
+
}
|
|
106
|
+
if (explicitAuthType === 'basic' && tokenFlagProvided) {
|
|
107
|
+
this.error('--auth-type basic cannot be used with --access-token.');
|
|
108
|
+
}
|
|
109
|
+
const savedAuthType = resolveConfiguredAuthType(env.config);
|
|
110
|
+
const resolvedAuthType = explicitAuthType ??
|
|
111
|
+
(tokenProvided ? 'token' : usernameFlagProvided || passwordFlagProvided ? 'basic' : savedAuthType);
|
|
112
|
+
if (resolvedAuthType === 'basic' && !usernameProvided && !isInteractiveTerminal()) {
|
|
113
|
+
this.error('--username is required when using basic authentication in non-interactive mode.');
|
|
114
|
+
}
|
|
115
|
+
if (resolvedAuthType === 'basic' && !passwordProvided && !isInteractiveTerminal()) {
|
|
116
|
+
this.error('--password is required when using basic authentication in non-interactive mode.');
|
|
117
|
+
}
|
|
118
|
+
const prompted = (resolvedAuthType === 'oauth'
|
|
119
|
+
? { authType: 'oauth' }
|
|
120
|
+
: await runPromptCatalog(envAuthPrompts, {
|
|
121
|
+
values: {
|
|
122
|
+
...(resolvedAuthType ? { authType: resolvedAuthType } : {}),
|
|
123
|
+
...(usernameFlagProvided ? { username: String(usernameFromFlags ?? '').trim() } : {}),
|
|
124
|
+
...(passwordFlagProvided ? { password: String(passwordFromFlags ?? '') } : {}),
|
|
125
|
+
...(tokenFlagProvided ? { accessToken: tokenValue } : {}),
|
|
126
|
+
},
|
|
127
|
+
command: this,
|
|
128
|
+
})) ?? {};
|
|
129
|
+
const authType = resolveExplicitAuthType(prompted.authType ?? resolvedAuthType);
|
|
130
|
+
if (!authType) {
|
|
131
|
+
this.error('Choose an authentication type before continuing.');
|
|
132
|
+
}
|
|
133
|
+
printStage('Authenticating');
|
|
134
|
+
try {
|
|
135
|
+
if (authType === 'basic') {
|
|
136
|
+
const username = String(prompted.username ?? usernameFromFlags ?? '').trim();
|
|
137
|
+
const password = String(prompted.password ?? passwordFromFlags ?? '');
|
|
138
|
+
if (!username) {
|
|
139
|
+
this.error('--username is required when using basic authentication.');
|
|
140
|
+
}
|
|
141
|
+
if (!password) {
|
|
142
|
+
this.error('--password cannot be empty.');
|
|
143
|
+
}
|
|
144
|
+
startTask(`Signing in with username and password for "${envName}"...`);
|
|
145
|
+
const accessToken = await authenticateEnvWithBasic({
|
|
146
|
+
envName,
|
|
147
|
+
username,
|
|
148
|
+
password,
|
|
149
|
+
scope: resolveDefaultConfigScope(),
|
|
150
|
+
});
|
|
151
|
+
await updateEnvConnection(envName, {
|
|
152
|
+
authType: 'basic',
|
|
153
|
+
authUsername: username,
|
|
154
|
+
accessToken,
|
|
155
|
+
}, { scope: resolveDefaultConfigScope() });
|
|
156
|
+
stopTask();
|
|
157
|
+
}
|
|
158
|
+
else if (authType === 'token') {
|
|
159
|
+
const accessToken = String(prompted.accessToken ?? tokenFromFlags ?? '').trim();
|
|
160
|
+
if (accessToken === '') {
|
|
161
|
+
this.error('--access-token cannot be empty.');
|
|
162
|
+
}
|
|
163
|
+
startTask(`Saving access token for "${envName}"...`);
|
|
164
|
+
await updateEnvConnection(envName, {
|
|
165
|
+
authType: 'token',
|
|
166
|
+
accessToken,
|
|
167
|
+
}, { scope: resolveDefaultConfigScope() });
|
|
168
|
+
stopTask();
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
startTask(`Starting browser sign-in for "${envName}"...`);
|
|
172
|
+
await updateEnvConnection(envName, {
|
|
173
|
+
authType: 'oauth',
|
|
174
|
+
}, { scope: resolveDefaultConfigScope() });
|
|
175
|
+
await authenticateEnvWithOauth({
|
|
176
|
+
envName,
|
|
177
|
+
scope: resolveDefaultConfigScope(),
|
|
178
|
+
});
|
|
179
|
+
stopTask();
|
|
180
|
+
}
|
|
181
|
+
await this.config.runCommand('env:update', [envName]);
|
|
182
|
+
succeedTask(`✔ Authenticated "${envName}".`);
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
failTask(`Authentication failed for "${envName}".`);
|
|
186
|
+
throw error;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 } from '@oclif/core';
|
|
10
|
+
import { getCurrentEnvName } from '../../lib/auth-store.js';
|
|
11
|
+
import { resolveDefaultConfigScope } from '../../lib/cli-home.js';
|
|
12
|
+
export default class EnvCurrent extends Command {
|
|
13
|
+
static summary = 'Show the current environment name';
|
|
14
|
+
static examples = [
|
|
15
|
+
'<%= config.bin %> <%= command.id %>',
|
|
16
|
+
];
|
|
17
|
+
async run() {
|
|
18
|
+
await this.parse(EnvCurrent);
|
|
19
|
+
this.log(await getCurrentEnvName({ scope: resolveDefaultConfigScope() }));
|
|
20
|
+
}
|
|
21
|
+
}
|