@nocobase/ctl 0.1.5 → 0.1.7
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 +25 -25
- package/bin/dev.js +1 -1
- package/bin/run.js +1 -1
- package/dist/commands/env/index.js +1 -1
- package/dist/commands/env/list.js +1 -1
- package/dist/commands/resource/index.js +1 -1
- package/dist/generated/command-registry.js +1 -1
- package/dist/lib/api-client.js +1 -1
- package/dist/lib/bootstrap.js +3 -3
- package/dist/lib/runtime-generator.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ node ./bin/run.js --help
|
|
|
36
36
|
After packaging or linking, the executable name is:
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
nocobase
|
|
39
|
+
nocobase-ctl
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## Quick Start
|
|
@@ -44,40 +44,40 @@ nocobase
|
|
|
44
44
|
Add an environment:
|
|
45
45
|
|
|
46
46
|
```bash
|
|
47
|
-
nocobase env add --name local --base-url http://localhost:13000/api --token <token>
|
|
47
|
+
nocobase-ctl env add --name local --base-url http://localhost:13000/api --token <token>
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
Show the current environment:
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
|
-
nocobase env
|
|
53
|
+
nocobase-ctl env
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
List configured environments:
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
nocobase env list
|
|
59
|
+
nocobase-ctl env list
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
Switch the current environment:
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
|
-
nocobase env use local
|
|
65
|
+
nocobase-ctl env use local
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
Update the runtime command cache from `swagger:get`:
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
|
-
nocobase env update
|
|
72
|
-
nocobase env update -e local
|
|
71
|
+
nocobase-ctl env update
|
|
72
|
+
nocobase-ctl env update -e local
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
Use the generic resource commands:
|
|
76
76
|
|
|
77
77
|
```bash
|
|
78
|
-
nocobase resource list --resource users
|
|
79
|
-
nocobase resource get --resource users --filter-by-tk 1
|
|
80
|
-
nocobase resource create --resource users --values '{"nickname":"Ada"}'
|
|
78
|
+
nocobase-ctl resource list --resource users
|
|
79
|
+
nocobase-ctl resource get --resource users --filter-by-tk 1
|
|
80
|
+
nocobase-ctl resource create --resource users --values '{"nickname":"Ada"}'
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
## Runtime Commands
|
|
@@ -96,34 +96,34 @@ If the `API documentation plugin` is disabled, the CLI will prompt to enable it.
|
|
|
96
96
|
Use `-e, --env` to temporarily select an environment:
|
|
97
97
|
|
|
98
98
|
```bash
|
|
99
|
-
nocobase env update -e prod
|
|
100
|
-
nocobase resource list --resource users -e prod
|
|
99
|
+
nocobase-ctl env update -e prod
|
|
100
|
+
nocobase-ctl resource list --resource users -e prod
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
This does not change the current environment unless you explicitly run:
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
|
-
nocobase env use <name>
|
|
106
|
+
nocobase-ctl env use <name>
|
|
107
107
|
```
|
|
108
108
|
|
|
109
109
|
## Config Scope
|
|
110
110
|
|
|
111
111
|
The `env` command supports two config scopes:
|
|
112
112
|
|
|
113
|
-
- `project`: use `./.nocobase-
|
|
114
|
-
- `global`: use the global `.nocobase-
|
|
113
|
+
- `project`: use `./.nocobase-ctl` in the current working directory
|
|
114
|
+
- `global`: use the global `.nocobase-ctl` directory
|
|
115
115
|
|
|
116
116
|
Use `-s, --scope` to select one explicitly:
|
|
117
117
|
|
|
118
118
|
```bash
|
|
119
|
-
nocobase env list -s project
|
|
120
|
-
nocobase env add -s global --name prod --base-url http://example.com/api --token <token>
|
|
121
|
-
nocobase env use local -s project
|
|
119
|
+
nocobase-ctl env list -s project
|
|
120
|
+
nocobase-ctl env add -s global --name prod --base-url http://example.com/api --token <token>
|
|
121
|
+
nocobase-ctl env use local -s project
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
If you do not pass `--scope`, the CLI uses automatic resolution:
|
|
125
125
|
|
|
126
|
-
1. current working directory if `./.nocobase-
|
|
126
|
+
1. current working directory if `./.nocobase-ctl` exists
|
|
127
127
|
2. `NOCOBASE_HOME_CLI`
|
|
128
128
|
3. your home directory
|
|
129
129
|
|
|
@@ -137,9 +137,9 @@ Current built-in topics:
|
|
|
137
137
|
Check available commands at any time:
|
|
138
138
|
|
|
139
139
|
```bash
|
|
140
|
-
nocobase --help
|
|
141
|
-
nocobase env --help
|
|
142
|
-
nocobase resource --help
|
|
140
|
+
nocobase-ctl --help
|
|
141
|
+
nocobase-ctl env --help
|
|
142
|
+
nocobase-ctl resource --help
|
|
143
143
|
```
|
|
144
144
|
|
|
145
145
|
## Common Flags
|
|
@@ -152,13 +152,13 @@ nocobase resource --help
|
|
|
152
152
|
Example:
|
|
153
153
|
|
|
154
154
|
```bash
|
|
155
|
-
nocobase env update -e prod -s global
|
|
156
|
-
nocobase resource list --resource users -e prod -j
|
|
155
|
+
nocobase-ctl env update -e prod -s global
|
|
156
|
+
nocobase-ctl resource list --resource users -e prod -j
|
|
157
157
|
```
|
|
158
158
|
|
|
159
159
|
## Local Data
|
|
160
160
|
|
|
161
|
-
The CLI stores its local state in `.nocobase-
|
|
161
|
+
The CLI stores its local state in `.nocobase-ctl`, including:
|
|
162
162
|
|
|
163
163
|
- `config.json`: environment definitions and current selection
|
|
164
164
|
- `versions/<version>/commands.json`: cached runtime commands for a generated version
|
package/bin/dev.js
CHANGED
|
@@ -8,7 +8,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
8
8
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
9
|
|
|
10
10
|
await ensureRuntimeFromArgv(process.argv.slice(2), {
|
|
11
|
-
configFile: path.join(path.dirname(__dirname), 'nocobase-
|
|
11
|
+
configFile: path.join(path.dirname(__dirname), 'nocobase-ctl.config.json'),
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
await execute({ development: true, dir: import.meta.url });
|
package/bin/run.js
CHANGED
|
@@ -9,7 +9,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
9
9
|
|
|
10
10
|
try {
|
|
11
11
|
await ensureRuntimeFromArgv(process.argv.slice(2), {
|
|
12
|
-
configFile: path.join(path.dirname(__dirname), 'nocobase-
|
|
12
|
+
configFile: path.join(path.dirname(__dirname), 'nocobase-ctl.config.json'),
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
await execute({ dir: import.meta.url });
|
|
@@ -19,7 +19,7 @@ export default class Env extends Command {
|
|
|
19
19
|
const env = await getEnv(envName, { scope });
|
|
20
20
|
if (!env?.baseUrl) {
|
|
21
21
|
this.log(`No current env is configured${scope ? ` in ${formatCliHomeScope(scope)} scope` : ''}.`);
|
|
22
|
-
this.log('Run `nocobase env add --name <name> --base-url <url> --token <token>` to add one.');
|
|
22
|
+
this.log('Run `nocobase-ctl env add --name <name> --base-url <url> --token <token>` to add one.');
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
this.log(renderTable(['Name', 'Base URL', 'Runtime'], [[envName, env?.baseUrl ?? '', env?.runtime?.version ?? '']]));
|
|
@@ -19,7 +19,7 @@ export default class EnvList extends Command {
|
|
|
19
19
|
const names = Object.keys(envs).sort();
|
|
20
20
|
if (!names.length) {
|
|
21
21
|
this.log(`No envs configured${scope ? ` in ${formatCliHomeScope(scope)} scope` : ''}.`);
|
|
22
|
-
this.log('Run `nocobase env add --name <name> --base-url <url> --token <token>` to add one.');
|
|
22
|
+
this.log('Run `nocobase-ctl env add --name <name> --base-url <url> --token <token>` to add one.');
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
const rows = names.map((name) => {
|
|
@@ -2,6 +2,6 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
export default class Resource extends Command {
|
|
3
3
|
static summary = 'Work with generic collection resources';
|
|
4
4
|
async run() {
|
|
5
|
-
this.log('Use `nocobase resource --help` to view available subcommands.');
|
|
5
|
+
this.log('Use `nocobase-ctl resource --help` to view available subcommands.');
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -45,7 +45,7 @@ function createRuntimeIndexCommand(commandId, operation) {
|
|
|
45
45
|
static summary = operation.resourceDescription || operation.resourceDisplayName || `Work with ${commandId}`;
|
|
46
46
|
static description = operation.resourceDescription;
|
|
47
47
|
async run() {
|
|
48
|
-
this.log(`Use \`nocobase ${commandId} --help\` to view available subcommands.`);
|
|
48
|
+
this.log(`Use \`nocobase-ctl ${commandId} --help\` to view available subcommands.`);
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
}
|
package/dist/lib/api-client.js
CHANGED
|
@@ -9,7 +9,7 @@ async function resolveServerRequestTarget(options) {
|
|
|
9
9
|
const baseUrl = options.baseUrl ?? env?.baseUrl;
|
|
10
10
|
const token = options.token ?? env?.auth?.accessToken;
|
|
11
11
|
if (!baseUrl) {
|
|
12
|
-
throw new Error('Missing base URL. Use --base-url or configure one with `nocobase env add`.');
|
|
12
|
+
throw new Error('Missing base URL. Use --base-url or configure one with `nocobase-ctl env add`.');
|
|
13
13
|
}
|
|
14
14
|
return { baseUrl, token };
|
|
15
15
|
}
|
package/dist/lib/bootstrap.js
CHANGED
|
@@ -212,8 +212,8 @@ export async function ensureRuntimeFromArgv(argv, options) {
|
|
|
212
212
|
if (!baseUrl) {
|
|
213
213
|
throw new Error([
|
|
214
214
|
'No env is configured for runtime commands.',
|
|
215
|
-
'Run `nocobase env add --name <name> --base-url <url> --token <token>` first.',
|
|
216
|
-
'If you configure multiple environments later, switch with `nocobase env use <name>`.',
|
|
215
|
+
'Run `nocobase-ctl env add --name <name> --base-url <url> --token <token>` first.',
|
|
216
|
+
'If you configure multiple environments later, switch with `nocobase-ctl env use <name>`.',
|
|
217
217
|
].join('\n'));
|
|
218
218
|
}
|
|
219
219
|
updateTask('Loading command runtime...');
|
|
@@ -241,7 +241,7 @@ export async function updateEnvRuntime(options) {
|
|
|
241
241
|
if (!baseUrl) {
|
|
242
242
|
throw new Error([
|
|
243
243
|
`Env "${envName}" is missing a base URL.`,
|
|
244
|
-
'Update it with `nocobase env add --name <name> --base-url <url>` first.',
|
|
244
|
+
'Update it with `nocobase-ctl env add --name <name> --base-url <url>` first.',
|
|
245
245
|
].join('\n'));
|
|
246
246
|
}
|
|
247
247
|
updateTask('Loading command runtime...');
|
|
@@ -181,7 +181,7 @@ function formatFlagExample(parameter) {
|
|
|
181
181
|
}
|
|
182
182
|
function buildExamples(commandId, operation) {
|
|
183
183
|
const requiredFlags = operation.parameters.filter((parameter) => parameter.required).map(formatFlagExample);
|
|
184
|
-
const examples = [`nocobase ${commandId}${requiredFlags.length ? ` ${requiredFlags.join(' ')}` : ''}`];
|
|
184
|
+
const examples = [`nocobase-ctl ${commandId}${requiredFlags.length ? ` ${requiredFlags.join(' ')}` : ''}`];
|
|
185
185
|
const firstOptional = operation.parameters.find((parameter) => !parameter.required);
|
|
186
186
|
if (firstOptional) {
|
|
187
187
|
examples.push(`${examples[0]} ${formatFlagExample(firstOptional)}`);
|