@nocobase/cli 2.1.0-beta.19 → 2.1.0-beta.20

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/README.md CHANGED
@@ -138,6 +138,7 @@ In non-interactive mode, pass these setup-only flags again because they are not
138
138
  | `nb download` | Advanced command used by `nb init` or `nb upgrade` to fetch NocoBase from Docker, npm, or Git. It is rarely used directly. |
139
139
  | `nb start` | Start the selected local app or Docker container. |
140
140
  | `nb stop` | Stop the selected local app or Docker container. |
141
+ | `nb restart` | Stop, then start the selected local app or Docker container. |
141
142
  | `nb dev` | Run development mode for npm/Git source envs. |
142
143
  | `nb logs` | Show app logs for npm/Git or Docker envs. |
143
144
  | `nb ps` | Show runtime status for configured envs. |
@@ -154,6 +155,7 @@ Recommended style: use `--env` explicitly for app/runtime commands. `-e` is the
154
155
 
155
156
  ```bash
156
157
  nb start --env app1
158
+ nb restart --env app1
157
159
  nb logs --env app1
158
160
  nb ps --env app1
159
161
  nb db ps --env app1
@@ -163,6 +165,7 @@ Equivalent shorthand examples:
163
165
 
164
166
  ```bash
165
167
  nb start -e app1
168
+ nb restart -e app1
166
169
  nb logs -e app1
167
170
  nb upgrade -e app1
168
171
  nb db start -e app1
@@ -206,6 +209,7 @@ Docker envs are managed through saved Docker containers and images:
206
209
  ```bash
207
210
  nb init --env app1 --yes --source docker --version alpha
208
211
  nb start --env app1
212
+ nb restart --env app1
209
213
  nb logs --env app1
210
214
  nb stop --env app1
211
215
  ```
package/README.zh-CN.md CHANGED
@@ -133,6 +133,7 @@ nb install --env app1 --resume
133
133
  | `nb download` | `nb init` 或 `nb upgrade` 会使用的高级命令,用于从 Docker、npm 或 Git 获取 NocoBase。通常很少直接使用。 |
134
134
  | `nb start` | 启动选中的本地应用或 Docker 容器。 |
135
135
  | `nb stop` | 停止选中的本地应用或 Docker 容器。 |
136
+ | `nb restart` | 先停止,再启动选中的本地应用或 Docker 容器。 |
136
137
  | `nb dev` | 为 npm/Git 源码 env 启动开发模式。 |
137
138
  | `nb logs` | 查看 npm/Git 或 Docker env 的应用日志。 |
138
139
  | `nb ps` | 查看已配置 env 的运行状态。 |
@@ -147,6 +148,7 @@ nb install --env app1 --resume
147
148
 
148
149
  ```bash
149
150
  nb start --env app1
151
+ nb restart --env app1
150
152
  nb logs --env app1
151
153
  nb ps --env app1
152
154
  nb db ps --env app1
@@ -156,6 +158,7 @@ nb db ps --env app1
156
158
 
157
159
  ```bash
158
160
  nb start -e app1
161
+ nb restart -e app1
159
162
  nb logs -e app1
160
163
  nb upgrade -e app1
161
164
  nb db start -e app1
@@ -170,6 +173,7 @@ Docker env 会通过已保存的 Docker 容器和镜像进行管理:
170
173
  ```bash
171
174
  nb init --env app1 --yes --source docker --version alpha
172
175
  nb start --env app1
176
+ nb restart --env app1
173
177
  nb logs --env app1
174
178
  nb stop --env app1
175
179
  ```
@@ -0,0 +1,74 @@
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
+ function argvHasToken(argv, tokens) {
11
+ return tokens.some((token) => argv.includes(token));
12
+ }
13
+ function pushFlag(argv, flag, value) {
14
+ if (value !== undefined) {
15
+ argv.push(flag, String(value));
16
+ }
17
+ }
18
+ export default class Restart extends Command {
19
+ static description = 'Restart NocoBase for the selected env by stopping it first, then starting it again.';
20
+ static examples = [
21
+ '<%= config.bin %> <%= command.id %>',
22
+ '<%= config.bin %> <%= command.id %> --env local',
23
+ '<%= config.bin %> <%= command.id %> --env local --quickstart',
24
+ '<%= config.bin %> <%= command.id %> --env local --port 12000',
25
+ '<%= config.bin %> <%= command.id %> --env local --daemon',
26
+ '<%= config.bin %> <%= command.id %> --env local --no-daemon',
27
+ '<%= config.bin %> <%= command.id %> --env local --instances 2',
28
+ '<%= config.bin %> <%= command.id %> --env local --launch-mode pm2',
29
+ '<%= config.bin %> <%= command.id %> --env local --verbose',
30
+ '<%= config.bin %> <%= command.id %> --env local-docker',
31
+ ];
32
+ static flags = {
33
+ env: Flags.string({
34
+ char: 'e',
35
+ description: 'CLI env name to restart. Defaults to the current env when omitted',
36
+ }),
37
+ quickstart: Flags.boolean({ description: 'Quickstart the application after stopping it', required: false }),
38
+ port: Flags.string({ description: 'Port (overrides appPort from env config when set)', char: 'p', required: false }),
39
+ daemon: Flags.boolean({
40
+ description: 'Run the application as a daemon after stopping it (default: true; use --no-daemon to stay in the foreground)',
41
+ char: 'd',
42
+ required: false,
43
+ default: true,
44
+ allowNo: true,
45
+ }),
46
+ instances: Flags.integer({ description: 'Number of instances to run after stopping it', char: 'i', required: false }),
47
+ 'launch-mode': Flags.string({ description: 'Launch Mode', required: false, options: ['pm2', 'node'] }),
48
+ verbose: Flags.boolean({
49
+ description: 'Show raw shutdown/startup output from the underlying local or Docker command',
50
+ default: false,
51
+ }),
52
+ };
53
+ async run() {
54
+ const { flags } = await this.parse(Restart);
55
+ const stopArgv = [];
56
+ const daemonFlagWasProvided = argvHasToken(this.argv, ['--daemon', '--no-daemon']);
57
+ pushFlag(stopArgv, '--env', flags.env?.trim() || undefined);
58
+ if (flags.verbose) {
59
+ stopArgv.push('--verbose');
60
+ }
61
+ await this.config.runCommand('stop', stopArgv);
62
+ const startArgv = [...stopArgv];
63
+ if (flags.quickstart) {
64
+ startArgv.push('--quickstart');
65
+ }
66
+ pushFlag(startArgv, '--port', flags.port);
67
+ if (daemonFlagWasProvided) {
68
+ startArgv.push(flags.daemon === false ? '--no-daemon' : '--daemon');
69
+ }
70
+ pushFlag(startArgv, '--instances', flags.instances);
71
+ pushFlag(startArgv, '--launch-mode', flags['launch-mode']);
72
+ await this.config.runCommand('start', startArgv);
73
+ }
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "2.1.0-beta.19",
3
+ "version": "2.1.0-beta.20",
4
4
  "description": "NocoBase Command Line Tool",
5
5
  "type": "module",
6
6
  "main": "dist/generated/command-registry.js",
@@ -68,5 +68,5 @@
68
68
  "type": "git",
69
69
  "url": "git+https://github.com/nocobase/nocobase.git"
70
70
  },
71
- "gitHead": "d89ab08dbcb25877de69827d5bad6823c27b2cbb"
71
+ "gitHead": "5515f27380c0c5410f7d1e5e5858364fcd838e5e"
72
72
  }