@contextual-io/cli 0.2.1 → 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 +7 -7
- 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 +4 -2
package/README.md
CHANGED
|
@@ -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,13 +48,13 @@ 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
|
|
@@ -213,13 +213,13 @@ DESCRIPTION
|
|
|
213
213
|
|
|
214
214
|
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.36/src/commands/help.ts)_
|
|
215
215
|
|
|
216
|
-
## `ctxl records
|
|
216
|
+
## `ctxl records <COMMAND>`
|
|
217
217
|
|
|
218
218
|
manage records
|
|
219
219
|
|
|
220
220
|
```
|
|
221
221
|
USAGE
|
|
222
|
-
$ ctxl records
|
|
222
|
+
$ ctxl records <COMMAND>
|
|
223
223
|
|
|
224
224
|
DESCRIPTION
|
|
225
225
|
manage records
|
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,7 +1,7 @@
|
|
|
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"
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@oclif/core": "^4",
|
|
11
11
|
"@oclif/plugin-help": "^6",
|
|
12
|
+
"@oclif/plugin-not-found": "^3.2.73",
|
|
12
13
|
"@oclif/table": "^0.5.1",
|
|
13
14
|
"chalk": "^5.6.2",
|
|
14
15
|
"cross-fetch": "^4.1.0",
|
|
@@ -56,7 +57,8 @@
|
|
|
56
57
|
"dirname": "ctxl",
|
|
57
58
|
"commands": "./dist/commands",
|
|
58
59
|
"plugins": [
|
|
59
|
-
"@oclif/plugin-help"
|
|
60
|
+
"@oclif/plugin-help",
|
|
61
|
+
"@oclif/plugin-not-found"
|
|
60
62
|
],
|
|
61
63
|
"topicSeparator": " ",
|
|
62
64
|
"topics": {
|