@contextual-io/cli 0.2.0 → 0.2.2
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 +8 -38
- package/dist/base.d.ts +2 -1
- package/dist/base.js +28 -4
- package/dist/commands/config/index.d.ts +1 -0
- package/dist/commands/config/index.js +4 -2
- package/dist/commands/records/index.d.ts +1 -0
- package/dist/commands/records/index.js +4 -2
- package/dist/models/uri.js +1 -1
- package/oclif.manifest.json +7 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
contextual-cli
|
|
1
|
+
@contextual-io/cli
|
|
2
2
|
=================
|
|
3
3
|
|
|
4
4
|
Contextual CLI
|
|
@@ -20,7 +20,7 @@ $ npm install -g @contextual-io/cli
|
|
|
20
20
|
$ ctxl COMMAND
|
|
21
21
|
running command...
|
|
22
22
|
$ ctxl (--version)
|
|
23
|
-
@contextual-io/cli/0.2.
|
|
23
|
+
@contextual-io/cli/0.2.2 linux-x64 node-v25.2.1
|
|
24
24
|
$ ctxl --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ ctxl COMMAND
|
|
@@ -29,7 +29,7 @@ USAGE
|
|
|
29
29
|
<!-- usagestop -->
|
|
30
30
|
# Commands
|
|
31
31
|
<!-- commands -->
|
|
32
|
-
* [`ctxl config
|
|
32
|
+
* [`ctxl config <COMMAND>`](#ctxl-config-command)
|
|
33
33
|
* [`ctxl config add CONFIG-ID`](#ctxl-config-add-config-id)
|
|
34
34
|
* [`ctxl config current`](#ctxl-config-current)
|
|
35
35
|
* [`ctxl config delete CONFIG-ID`](#ctxl-config-delete-config-id)
|
|
@@ -38,7 +38,7 @@ USAGE
|
|
|
38
38
|
* [`ctxl config login`](#ctxl-config-login)
|
|
39
39
|
* [`ctxl config use CONFIG-ID`](#ctxl-config-use-config-id)
|
|
40
40
|
* [`ctxl help [COMMAND]`](#ctxl-help-command)
|
|
41
|
-
* [`ctxl records
|
|
41
|
+
* [`ctxl records <COMMAND>`](#ctxl-records-command)
|
|
42
42
|
* [`ctxl records add [URI]`](#ctxl-records-add-uri)
|
|
43
43
|
* [`ctxl records create [URI]`](#ctxl-records-create-uri)
|
|
44
44
|
* [`ctxl records delete [URI]`](#ctxl-records-delete-uri)
|
|
@@ -48,20 +48,18 @@ USAGE
|
|
|
48
48
|
* [`ctxl records query [URI]`](#ctxl-records-query-uri)
|
|
49
49
|
* [`ctxl records replace [URI]`](#ctxl-records-replace-uri)
|
|
50
50
|
|
|
51
|
-
## `ctxl config
|
|
51
|
+
## `ctxl config <COMMAND>`
|
|
52
52
|
|
|
53
53
|
manage configs
|
|
54
54
|
|
|
55
55
|
```
|
|
56
56
|
USAGE
|
|
57
|
-
$ ctxl config
|
|
57
|
+
$ ctxl config <COMMAND>
|
|
58
58
|
|
|
59
59
|
DESCRIPTION
|
|
60
60
|
manage configs
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
_See code: [src/commands/config/index.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/config/index.ts)_
|
|
64
|
-
|
|
65
63
|
## `ctxl config add CONFIG-ID`
|
|
66
64
|
|
|
67
65
|
add a new config
|
|
@@ -85,8 +83,6 @@ EXAMPLES
|
|
|
85
83
|
$ ctxl config add some-config-id --tenant-id my-tenant
|
|
86
84
|
```
|
|
87
85
|
|
|
88
|
-
_See code: [src/commands/config/add.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/config/add.ts)_
|
|
89
|
-
|
|
90
86
|
## `ctxl config current`
|
|
91
87
|
|
|
92
88
|
get the current config
|
|
@@ -105,8 +101,6 @@ EXAMPLES
|
|
|
105
101
|
$ ctxl config current
|
|
106
102
|
```
|
|
107
103
|
|
|
108
|
-
_See code: [src/commands/config/current.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/config/current.ts)_
|
|
109
|
-
|
|
110
104
|
## `ctxl config delete CONFIG-ID`
|
|
111
105
|
|
|
112
106
|
delete a config
|
|
@@ -125,8 +119,6 @@ EXAMPLES
|
|
|
125
119
|
$ ctxl config delete some-config-id
|
|
126
120
|
```
|
|
127
121
|
|
|
128
|
-
_See code: [src/commands/config/delete.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/config/delete.ts)_
|
|
129
|
-
|
|
130
122
|
## `ctxl config get [CONFIG-ID]`
|
|
131
123
|
|
|
132
124
|
get a specific config
|
|
@@ -150,8 +142,6 @@ EXAMPLES
|
|
|
150
142
|
$ ctxl config get some-config-id
|
|
151
143
|
```
|
|
152
144
|
|
|
153
|
-
_See code: [src/commands/config/get.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/config/get.ts)_
|
|
154
|
-
|
|
155
145
|
## `ctxl config list`
|
|
156
146
|
|
|
157
147
|
list all available configs
|
|
@@ -170,8 +160,6 @@ EXAMPLES
|
|
|
170
160
|
$ ctxl config list
|
|
171
161
|
```
|
|
172
162
|
|
|
173
|
-
_See code: [src/commands/config/list.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/config/list.ts)_
|
|
174
|
-
|
|
175
163
|
## `ctxl config login`
|
|
176
164
|
|
|
177
165
|
login using the current config
|
|
@@ -187,8 +175,6 @@ EXAMPLES
|
|
|
187
175
|
$ ctxl config login
|
|
188
176
|
```
|
|
189
177
|
|
|
190
|
-
_See code: [src/commands/config/login.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/config/login.ts)_
|
|
191
|
-
|
|
192
178
|
## `ctxl config use CONFIG-ID`
|
|
193
179
|
|
|
194
180
|
use a config
|
|
@@ -207,8 +193,6 @@ EXAMPLES
|
|
|
207
193
|
$ ctxl config use some-config-id
|
|
208
194
|
```
|
|
209
195
|
|
|
210
|
-
_See code: [src/commands/config/use.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/config/use.ts)_
|
|
211
|
-
|
|
212
196
|
## `ctxl help [COMMAND]`
|
|
213
197
|
|
|
214
198
|
Display help for ctxl.
|
|
@@ -229,20 +213,18 @@ DESCRIPTION
|
|
|
229
213
|
|
|
230
214
|
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.36/src/commands/help.ts)_
|
|
231
215
|
|
|
232
|
-
## `ctxl records
|
|
216
|
+
## `ctxl records <COMMAND>`
|
|
233
217
|
|
|
234
218
|
manage records
|
|
235
219
|
|
|
236
220
|
```
|
|
237
221
|
USAGE
|
|
238
|
-
$ ctxl records
|
|
222
|
+
$ ctxl records <COMMAND>
|
|
239
223
|
|
|
240
224
|
DESCRIPTION
|
|
241
225
|
manage records
|
|
242
226
|
```
|
|
243
227
|
|
|
244
|
-
_See code: [src/commands/records/index.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/records/index.ts)_
|
|
245
|
-
|
|
246
228
|
## `ctxl records add [URI]`
|
|
247
229
|
|
|
248
230
|
create record(s)
|
|
@@ -274,8 +256,6 @@ EXAMPLES
|
|
|
274
256
|
$ ctxl records add --type my-type --input-file records.json
|
|
275
257
|
```
|
|
276
258
|
|
|
277
|
-
_See code: [src/commands/records/add.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/records/add.ts)_
|
|
278
|
-
|
|
279
259
|
## `ctxl records create [URI]`
|
|
280
260
|
|
|
281
261
|
create record(s)
|
|
@@ -340,8 +320,6 @@ EXAMPLES
|
|
|
340
320
|
$ ctxl records delete --type my-type --id instance-1 --id instance-2
|
|
341
321
|
```
|
|
342
322
|
|
|
343
|
-
_See code: [src/commands/records/delete.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/records/delete.ts)_
|
|
344
|
-
|
|
345
323
|
## `ctxl records get [URI]`
|
|
346
324
|
|
|
347
325
|
get a record
|
|
@@ -375,8 +353,6 @@ EXAMPLES
|
|
|
375
353
|
$ ctxl records get --type my-type --id instance-1 --id instance-2
|
|
376
354
|
```
|
|
377
355
|
|
|
378
|
-
_See code: [src/commands/records/get.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/records/get.ts)_
|
|
379
|
-
|
|
380
356
|
## `ctxl records import [URI]`
|
|
381
357
|
|
|
382
358
|
create record(s)
|
|
@@ -449,8 +425,6 @@ EXAMPLES
|
|
|
449
425
|
$ ctxl records list --type my-type -s field1=value1 -s field2=value2 --include-total
|
|
450
426
|
```
|
|
451
427
|
|
|
452
|
-
_See code: [src/commands/records/list.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/records/list.ts)_
|
|
453
|
-
|
|
454
428
|
## `ctxl records query [URI]`
|
|
455
429
|
|
|
456
430
|
query records
|
|
@@ -489,8 +463,6 @@ EXAMPLES
|
|
|
489
463
|
$ ctxl records query --type my-type --include-total --query-file query.json
|
|
490
464
|
```
|
|
491
465
|
|
|
492
|
-
_See code: [src/commands/records/query.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/records/query.ts)_
|
|
493
|
-
|
|
494
466
|
## `ctxl records replace [URI]`
|
|
495
467
|
|
|
496
468
|
replace a record
|
|
@@ -520,6 +492,4 @@ EXAMPLES
|
|
|
520
492
|
|
|
521
493
|
$ ctxl records replace --type my-type --id instance-1 --input-file record.json
|
|
522
494
|
```
|
|
523
|
-
|
|
524
|
-
_See code: [src/commands/records/replace.ts](https://github.com/ContextualIO/contextual-cli/blob/v0.2.0/src/commands/records/replace.ts)_
|
|
525
495
|
<!-- commandsstop -->
|
package/dist/base.d.ts
CHANGED
|
@@ -25,9 +25,10 @@ export declare abstract class BaseConfigCommand<T extends typeof Command> extend
|
|
|
25
25
|
protected userConfig: CommandConfig;
|
|
26
26
|
protected catch(err: Error & {
|
|
27
27
|
exitCode?: number;
|
|
28
|
-
}): Promise<
|
|
28
|
+
}): Promise<void>;
|
|
29
29
|
protected finally(_: Error | undefined): Promise<unknown>;
|
|
30
30
|
init(): Promise<void>;
|
|
31
|
+
protected showHelp(argv?: string[]): Promise<void>;
|
|
31
32
|
}
|
|
32
33
|
export declare abstract class BaseCommand<T extends typeof Command> extends BaseConfigCommand<T> {
|
|
33
34
|
static baseFlags: {
|
package/dist/base.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { Command, Flags } from "@oclif/core";
|
|
1
|
+
import { Command, Flags, loadHelpClass } from "@oclif/core";
|
|
2
|
+
// eslint-disable-next-line unicorn/import-style
|
|
3
|
+
import { chalkStderr } from "chalk";
|
|
2
4
|
import fetch from "cross-fetch";
|
|
3
5
|
import fs from "node:fs";
|
|
4
6
|
import path from "node:path";
|
|
7
|
+
import { z, ZodError } from "zod";
|
|
5
8
|
import { HttpError } from "./models/errors.js";
|
|
6
9
|
import { UserConfig } from "./models/user-config.js";
|
|
7
10
|
import { rehydrateToken } from "./utils/auth.js";
|
|
@@ -97,9 +100,23 @@ export class BaseConfigCommand extends Command {
|
|
|
97
100
|
flags;
|
|
98
101
|
userConfig;
|
|
99
102
|
async catch(err) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
const exitCode = err.exitCode ?? process.exitCode ?? 1;
|
|
104
|
+
if (this.jsonEnabled()) {
|
|
105
|
+
this.logJson(this.toErrorJson(err));
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
if (!err.message)
|
|
109
|
+
throw err;
|
|
110
|
+
let { message } = err;
|
|
111
|
+
if (err instanceof ZodError) {
|
|
112
|
+
const flattened = z.flattenError(err);
|
|
113
|
+
message = flattened.formErrors.join("\n");
|
|
114
|
+
}
|
|
115
|
+
this.logToStderr(chalkStderr.red(chalkStderr.bold(" Error: ") + message));
|
|
116
|
+
this.logToStderr();
|
|
117
|
+
await this.showHelp();
|
|
118
|
+
}
|
|
119
|
+
this.exit(exitCode);
|
|
103
120
|
}
|
|
104
121
|
async finally(_) {
|
|
105
122
|
// called after run and catch regardless of whether or not the command errored
|
|
@@ -118,6 +135,13 @@ export class BaseConfigCommand extends Command {
|
|
|
118
135
|
this.args = args;
|
|
119
136
|
this.userConfig = new CommandConfig(this.config.configDir);
|
|
120
137
|
}
|
|
138
|
+
async showHelp(argv) {
|
|
139
|
+
const toShow = argv ?? this.id ? [this.id] : undefined;
|
|
140
|
+
if (!toShow)
|
|
141
|
+
return;
|
|
142
|
+
const help = new (await loadHelpClass(this.config))(this.config);
|
|
143
|
+
await help.showHelp(toShow);
|
|
144
|
+
}
|
|
121
145
|
}
|
|
122
146
|
export class BaseCommand extends BaseConfigCommand {
|
|
123
147
|
// define flags that can be inherited by any command that extends BaseCommand
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { loadHelpClass } from "@oclif/core";
|
|
2
1
|
import { BaseConfigCommand } from "../../base.js";
|
|
3
2
|
export default class Config extends BaseConfigCommand {
|
|
4
3
|
static args = {};
|
|
5
4
|
static description = "manage configs";
|
|
6
5
|
static examples = [];
|
|
7
6
|
static flags = {};
|
|
7
|
+
static usage = [
|
|
8
|
+
"<%= command.id %> <COMMAND>",
|
|
9
|
+
];
|
|
8
10
|
async run() {
|
|
9
|
-
await
|
|
11
|
+
await this.showHelp();
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { loadHelpClass } from "@oclif/core";
|
|
2
1
|
import { BaseConfigCommand } from "../../base.js";
|
|
3
2
|
export default class Records extends BaseConfigCommand {
|
|
4
3
|
static args = {};
|
|
5
4
|
static description = "manage records";
|
|
6
5
|
static examples = [];
|
|
7
6
|
static flags = {};
|
|
7
|
+
static usage = [
|
|
8
|
+
"<%= command.id %> <COMMAND>",
|
|
9
|
+
];
|
|
8
10
|
async run() {
|
|
9
|
-
await
|
|
11
|
+
await this.showHelp();
|
|
10
12
|
}
|
|
11
13
|
}
|
package/dist/models/uri.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export const Uri = z.string().regex(/^native-object:[a-z0-9-]+(\/.+)
|
|
2
|
+
export const Uri = z.string().regex(/^native-object:[a-z0-9-]+(\/.+)?/, { error: "URI must match one of the following formats: 'native-object:<type-id>' or 'native-object:<type-id>/<instance-id>'" });
|
|
3
3
|
export const parseUri = (uri) => {
|
|
4
4
|
const parsed = Uri.parse(uri);
|
|
5
5
|
const [type, id] = parsed.replace(/^native-object:/, "").split("/");
|
package/oclif.manifest.json
CHANGED
|
@@ -166,6 +166,9 @@
|
|
|
166
166
|
"pluginName": "@contextual-io/cli",
|
|
167
167
|
"pluginType": "core",
|
|
168
168
|
"strict": true,
|
|
169
|
+
"usage": [
|
|
170
|
+
"<%= command.id %> <COMMAND>"
|
|
171
|
+
],
|
|
169
172
|
"enableJsonFlag": false,
|
|
170
173
|
"isESM": true,
|
|
171
174
|
"relativePath": [
|
|
@@ -452,6 +455,9 @@
|
|
|
452
455
|
"pluginName": "@contextual-io/cli",
|
|
453
456
|
"pluginType": "core",
|
|
454
457
|
"strict": true,
|
|
458
|
+
"usage": [
|
|
459
|
+
"<%= command.id %> <COMMAND>"
|
|
460
|
+
],
|
|
455
461
|
"enableJsonFlag": false,
|
|
456
462
|
"isESM": true,
|
|
457
463
|
"relativePath": [
|
|
@@ -753,5 +759,5 @@
|
|
|
753
759
|
]
|
|
754
760
|
}
|
|
755
761
|
},
|
|
756
|
-
"version": "0.2.
|
|
762
|
+
"version": "0.2.2"
|
|
757
763
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contextual-io/cli",
|
|
3
3
|
"description": "Contextual CLI",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"author": "Nasser Oloumi",
|
|
6
6
|
"bin": {
|
|
7
7
|
"ctxl": "./bin/run.js"
|
|
8
8
|
},
|
|
9
|
-
"bugs": "https://github.com/ContextualIO/contextual-cli/issues",
|
|
10
9
|
"dependencies": {
|
|
11
10
|
"@oclif/core": "^4",
|
|
12
11
|
"@oclif/plugin-help": "^6",
|
|
12
|
+
"@oclif/plugin-not-found": "^3.2.73",
|
|
13
13
|
"@oclif/table": "^0.5.1",
|
|
14
14
|
"chalk": "^5.6.2",
|
|
15
15
|
"cross-fetch": "^4.1.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"./dist",
|
|
46
46
|
"./oclif.manifest.json"
|
|
47
47
|
],
|
|
48
|
-
"homepage": "https://
|
|
48
|
+
"homepage": "https://www.contextual.io/",
|
|
49
49
|
"keywords": [
|
|
50
50
|
"oclif"
|
|
51
51
|
],
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
"dirname": "ctxl",
|
|
58
58
|
"commands": "./dist/commands",
|
|
59
59
|
"plugins": [
|
|
60
|
-
"@oclif/plugin-help"
|
|
60
|
+
"@oclif/plugin-help",
|
|
61
|
+
"@oclif/plugin-not-found"
|
|
61
62
|
],
|
|
62
63
|
"topicSeparator": " ",
|
|
63
64
|
"topics": {
|
|
@@ -66,7 +67,6 @@
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
},
|
|
69
|
-
"repository": "ContextualIO/contextual-cli",
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "shx rm -rf dist && tsc -b",
|
|
72
72
|
"lint": "eslint",
|