@chatbotkit/cli 1.7.0 → 1.9.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/README.md +1 -0
- package/bin/cbk.js +7 -0
- package/dist/cjs/command/api/conversation/index.cjs +9 -4
- package/dist/cjs/command/api/conversation/message/index.cjs +9 -4
- package/dist/cjs/command/api/dataset/index.cjs +9 -4
- package/dist/cjs/command/api/partner/user/index.cjs +9 -4
- package/dist/cjs/command/api/skillset/index.cjs +9 -4
- package/dist/cjs/command/chat/index.cjs +7 -4
- package/dist/cjs/command/solution/index.cjs +52 -0
- package/dist/cjs/command/solution/index.d.ts +7 -0
- package/dist/cjs/command/solution/resource/index.cjs +44 -0
- package/dist/cjs/command/solution/resource/index.d.ts +5 -0
- package/dist/cjs/index.cjs +4 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/input.cjs +18 -0
- package/dist/cjs/input.d.ts +1 -0
- package/dist/cjs/output.cjs +10 -2
- package/dist/cjs/output.d.ts +2 -0
- package/dist/cjs/proxy.cjs +22 -0
- package/dist/cjs/proxy.d.ts +7 -0
- package/dist/cjs/solution/index.cjs +288 -0
- package/dist/cjs/solution/index.d.ts +815 -0
- package/dist/esm/command/api/conversation/index.js +9 -4
- package/dist/esm/command/api/conversation/message/index.js +9 -4
- package/dist/esm/command/api/dataset/index.js +9 -4
- package/dist/esm/command/api/partner/user/index.js +9 -4
- package/dist/esm/command/api/skillset/index.js +9 -4
- package/dist/esm/command/chat/index.js +7 -4
- package/dist/esm/command/solution/index.d.ts +7 -0
- package/dist/esm/command/solution/index.js +48 -0
- package/dist/esm/command/solution/resource/index.d.ts +5 -0
- package/dist/esm/command/solution/resource/index.js +40 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +4 -2
- package/dist/esm/input.d.ts +1 -0
- package/dist/esm/input.js +13 -0
- package/dist/esm/output.d.ts +2 -0
- package/dist/esm/output.js +8 -1
- package/dist/esm/proxy.d.ts +7 -0
- package/dist/esm/proxy.js +17 -0
- package/dist/esm/solution/index.d.ts +815 -0
- package/dist/esm/solution/index.js +271 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +135 -2
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
[](https://twitter.com/chatbotkit)
|
|
2
2
|
[](https://chatbotkit.com)
|
|
3
|
+
[](https://cbk.ai)
|
|
3
4
|
[](https://www.npmjs.com/package/@chatbotkit/cli)
|
|
4
5
|
|
|
5
6
|
# ChatBotKit CLI
|
package/bin/cbk.js
CHANGED
|
@@ -7,16 +7,19 @@ const output_js_1 = require("../../../output.cjs");
|
|
|
7
7
|
const index_js_1 = tslib_1.__importDefault(require("./message/index.cjs"));
|
|
8
8
|
const index_js_2 = require("@chatbotkit/sdk/conversation/index.js");
|
|
9
9
|
const commander_1 = require("commander");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
function getClient() {
|
|
11
|
+
return new index_js_2.ConversationClient({
|
|
12
|
+
secret: (0, env_js_1.getSECRET)(),
|
|
13
|
+
runAsUserId: (0, env_js_1.getRUNAS_USERID)(),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
14
16
|
exports.conversationList = new commander_1.Command()
|
|
15
17
|
.name('list')
|
|
16
18
|
.description('List conversations')
|
|
17
19
|
.option('-s, --stream', 'Stream conversations')
|
|
18
20
|
.action(async (str, options) => {
|
|
19
21
|
const { stream } = options;
|
|
22
|
+
const client = getClient();
|
|
20
23
|
if (stream) {
|
|
21
24
|
for await (const conversation of client.list().stream()) {
|
|
22
25
|
(0, output_js_1.print)(conversation);
|
|
@@ -34,6 +37,7 @@ exports.conversationFetch = new commander_1.Command()
|
|
|
34
37
|
.description('Fetch conversation')
|
|
35
38
|
.argument('<conversationId>', 'Conversation ID')
|
|
36
39
|
.action(async (conversationId) => {
|
|
40
|
+
const client = getClient();
|
|
37
41
|
const conversation = await client.fetch(conversationId);
|
|
38
42
|
(0, output_js_1.print)(conversation);
|
|
39
43
|
});
|
|
@@ -42,6 +46,7 @@ exports.conversationDelete = new commander_1.Command()
|
|
|
42
46
|
.description('Delete conversation')
|
|
43
47
|
.argument('<conversationId>', 'Conversation ID')
|
|
44
48
|
.action(async (conversationId) => {
|
|
49
|
+
const client = getClient();
|
|
45
50
|
await client.delete(conversationId);
|
|
46
51
|
});
|
|
47
52
|
exports.command = new commander_1.Command()
|
|
@@ -5,10 +5,12 @@ const env_js_1 = require("../../../../env.cjs");
|
|
|
5
5
|
const output_js_1 = require("../../../../output.cjs");
|
|
6
6
|
const index_js_1 = require("@chatbotkit/sdk/conversation/message/index.js");
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
function getClient() {
|
|
9
|
+
return new index_js_1.ConversationMessageClient({
|
|
10
|
+
secret: (0, env_js_1.getSECRET)(),
|
|
11
|
+
runAsUserId: (0, env_js_1.getRUNAS_USERID)(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
12
14
|
exports.messageList = new commander_1.Command()
|
|
13
15
|
.name('list')
|
|
14
16
|
.description('List messages')
|
|
@@ -16,6 +18,7 @@ exports.messageList = new commander_1.Command()
|
|
|
16
18
|
.argument('<conversationId>', 'Conversation ID')
|
|
17
19
|
.action(async (conversationId, options) => {
|
|
18
20
|
const { stream } = options;
|
|
21
|
+
const client = getClient();
|
|
19
22
|
if (stream) {
|
|
20
23
|
for await (const message of client.list(conversationId).stream()) {
|
|
21
24
|
(0, output_js_1.print)(message);
|
|
@@ -34,6 +37,7 @@ exports.messageFetch = new commander_1.Command()
|
|
|
34
37
|
.argument('<conversationId>', 'Conversation ID')
|
|
35
38
|
.argument('<messageId>', 'Message ID')
|
|
36
39
|
.action(async (conversationId, messageId) => {
|
|
40
|
+
const client = getClient();
|
|
37
41
|
const message = await client.fetch(conversationId, messageId);
|
|
38
42
|
(0, output_js_1.print)(message);
|
|
39
43
|
});
|
|
@@ -43,6 +47,7 @@ exports.messageDelete = new commander_1.Command()
|
|
|
43
47
|
.argument('<conversationId>', 'Conversation ID')
|
|
44
48
|
.argument('<messageId>', 'Message ID')
|
|
45
49
|
.action(async (conversationId, messageId) => {
|
|
50
|
+
const client = getClient();
|
|
46
51
|
await client.delete(conversationId, messageId);
|
|
47
52
|
});
|
|
48
53
|
exports.command = new commander_1.Command()
|
|
@@ -5,16 +5,19 @@ const env_js_1 = require("../../../env.cjs");
|
|
|
5
5
|
const output_js_1 = require("../../../output.cjs");
|
|
6
6
|
const index_js_1 = require("@chatbotkit/sdk/dataset/index.js");
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
function getClient() {
|
|
9
|
+
return new index_js_1.DatasetClient({
|
|
10
|
+
secret: (0, env_js_1.getSECRET)(),
|
|
11
|
+
runAsUserId: (0, env_js_1.getRUNAS_USERID)(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
12
14
|
exports.datasetList = new commander_1.Command()
|
|
13
15
|
.name('list')
|
|
14
16
|
.description('List datasets')
|
|
15
17
|
.option('-s, --stream', 'Stream datasets')
|
|
16
18
|
.action(async (str, options) => {
|
|
17
19
|
const { stream } = options;
|
|
20
|
+
const client = getClient();
|
|
18
21
|
if (stream) {
|
|
19
22
|
for await (const dataset of client.list().stream()) {
|
|
20
23
|
(0, output_js_1.print)(dataset);
|
|
@@ -32,6 +35,7 @@ exports.datasetFetch = new commander_1.Command()
|
|
|
32
35
|
.description('Fetch dataset')
|
|
33
36
|
.argument('<datasetId>', 'Dataset ID')
|
|
34
37
|
.action(async (datasetId) => {
|
|
38
|
+
const client = getClient();
|
|
35
39
|
const dataset = await client.fetch(datasetId);
|
|
36
40
|
(0, output_js_1.print)(dataset);
|
|
37
41
|
});
|
|
@@ -40,6 +44,7 @@ exports.datasetDelete = new commander_1.Command()
|
|
|
40
44
|
.description('Delete dataset')
|
|
41
45
|
.argument('<datasetId>', 'Dataset ID')
|
|
42
46
|
.action(async (datasetId) => {
|
|
47
|
+
const client = getClient();
|
|
43
48
|
await client.delete(datasetId);
|
|
44
49
|
});
|
|
45
50
|
exports.command = new commander_1.Command()
|
|
@@ -5,16 +5,19 @@ const env_js_1 = require("../../../../env.cjs");
|
|
|
5
5
|
const output_js_1 = require("../../../../output.cjs");
|
|
6
6
|
const index_js_1 = require("@chatbotkit/sdk/partner/user/index.js");
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
function getClient() {
|
|
9
|
+
return new index_js_1.PartnerUserClient({
|
|
10
|
+
secret: (0, env_js_1.getSECRET)(),
|
|
11
|
+
runAsUserId: (0, env_js_1.getRUNAS_USERID)(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
12
14
|
exports.userList = new commander_1.Command()
|
|
13
15
|
.name('list')
|
|
14
16
|
.description('List users')
|
|
15
17
|
.option('-s, --stream', 'Stream users')
|
|
16
18
|
.action(async (_arg, options) => {
|
|
17
19
|
const { stream } = options;
|
|
20
|
+
const client = getClient();
|
|
18
21
|
if (stream) {
|
|
19
22
|
for await (const user of client.list().stream()) {
|
|
20
23
|
(0, output_js_1.print)(user);
|
|
@@ -32,6 +35,7 @@ exports.userFetch = new commander_1.Command()
|
|
|
32
35
|
.description('Fetch user')
|
|
33
36
|
.argument('User ID')
|
|
34
37
|
.action(async (userId) => {
|
|
38
|
+
const client = getClient();
|
|
35
39
|
const user = await client.fetch(userId);
|
|
36
40
|
(0, output_js_1.print)(user);
|
|
37
41
|
});
|
|
@@ -40,6 +44,7 @@ exports.userDelete = new commander_1.Command()
|
|
|
40
44
|
.description('Delete user')
|
|
41
45
|
.argument('<userId>', 'User ID')
|
|
42
46
|
.action(async (userId) => {
|
|
47
|
+
const client = getClient();
|
|
43
48
|
await client.delete(userId);
|
|
44
49
|
});
|
|
45
50
|
exports.command = new commander_1.Command()
|
|
@@ -5,16 +5,19 @@ const env_js_1 = require("../../../env.cjs");
|
|
|
5
5
|
const output_js_1 = require("../../../output.cjs");
|
|
6
6
|
const index_js_1 = require("@chatbotkit/sdk/skillset/index.js");
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
function getClient() {
|
|
9
|
+
return new index_js_1.SkillsetClient({
|
|
10
|
+
secret: (0, env_js_1.getSECRET)(),
|
|
11
|
+
runAsUserId: (0, env_js_1.getRUNAS_USERID)(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
12
14
|
exports.skillsetList = new commander_1.Command()
|
|
13
15
|
.name('list')
|
|
14
16
|
.description('List skillsets')
|
|
15
17
|
.option('-s, --stream', 'Stream skillsets')
|
|
16
18
|
.action(async (str, options) => {
|
|
17
19
|
const { stream } = options;
|
|
20
|
+
const client = getClient();
|
|
18
21
|
if (stream) {
|
|
19
22
|
for await (const skillset of client.list().stream()) {
|
|
20
23
|
(0, output_js_1.print)(skillset);
|
|
@@ -32,6 +35,7 @@ exports.skillsetFetch = new commander_1.Command()
|
|
|
32
35
|
.description('Fetch skillset')
|
|
33
36
|
.argument('<skillsetId>', 'Skillset ID')
|
|
34
37
|
.action(async (skillsetId) => {
|
|
38
|
+
const client = getClient();
|
|
35
39
|
const skillset = await client.fetch(skillsetId);
|
|
36
40
|
(0, output_js_1.print)(skillset);
|
|
37
41
|
});
|
|
@@ -40,6 +44,7 @@ exports.skillsetDelete = new commander_1.Command()
|
|
|
40
44
|
.description('Delete skillset')
|
|
41
45
|
.argument('<skillsetId>', 'Skillset ID')
|
|
42
46
|
.action(async (skillsetId) => {
|
|
47
|
+
const client = getClient();
|
|
43
48
|
await client.delete(skillsetId);
|
|
44
49
|
});
|
|
45
50
|
exports.command = new commander_1.Command()
|
|
@@ -6,15 +6,18 @@ const env_js_1 = require("../../env.cjs");
|
|
|
6
6
|
const index_js_1 = require("@chatbotkit/sdk/conversation/index.js");
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
8
|
const promises_1 = tslib_1.__importDefault(require("readline/promises"));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
function getClient() {
|
|
10
|
+
return new index_js_1.ConversationClient({
|
|
11
|
+
secret: (0, env_js_1.getSECRET)(),
|
|
12
|
+
runAsUserId: (0, env_js_1.getRUNAS_USERID)(),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
13
15
|
exports.command = new commander_1.Command()
|
|
14
16
|
.name('chat')
|
|
15
17
|
.description('Start a chat session')
|
|
16
18
|
.addOption(new commander_1.Option('-m, --model <model>', 'Model name').default('gpt-4'))
|
|
17
19
|
.action(async (_arg, options) => {
|
|
20
|
+
const client = getClient();
|
|
18
21
|
const rl = promises_1.default.createInterface({
|
|
19
22
|
input: process.stdin,
|
|
20
23
|
output: process.stdout,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = exports.solutionSync = exports.solutionDelete = exports.solutionCreate = exports.solutionList = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const input_js_1 = require("../../input.cjs");
|
|
6
|
+
const output_js_1 = require("../../output.cjs");
|
|
7
|
+
const index_js_1 = require("../../solution/index.cjs");
|
|
8
|
+
const index_js_2 = tslib_1.__importDefault(require("./resource/index.cjs"));
|
|
9
|
+
const commander_1 = require("commander");
|
|
10
|
+
exports.solutionList = new commander_1.Command()
|
|
11
|
+
.name('list')
|
|
12
|
+
.description('List solutions')
|
|
13
|
+
.action(async () => {
|
|
14
|
+
for (const name of await index_js_1.Solution.list()) {
|
|
15
|
+
(0, output_js_1.print)({ name });
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.solutionCreate = new commander_1.Command()
|
|
19
|
+
.name('create')
|
|
20
|
+
.description('Create a new solution')
|
|
21
|
+
.argument('<name>', 'The name of the solution')
|
|
22
|
+
.action(async (name) => {
|
|
23
|
+
await index_js_1.Solution.create(name);
|
|
24
|
+
});
|
|
25
|
+
exports.solutionDelete = new commander_1.Command()
|
|
26
|
+
.name('delete')
|
|
27
|
+
.description('Delete a solution')
|
|
28
|
+
.argument('<name>', 'The name of the solution')
|
|
29
|
+
.action(async (name) => {
|
|
30
|
+
const fileName = (0, index_js_1.getSolutionFileName)(name);
|
|
31
|
+
if (!(await (0, input_js_1.confirm)(`Are you sure you want to delete solution ${fileName}?`))) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
await index_js_1.Solution.delete(name);
|
|
35
|
+
});
|
|
36
|
+
exports.solutionSync = new commander_1.Command()
|
|
37
|
+
.name('sync')
|
|
38
|
+
.description('Sync a solution')
|
|
39
|
+
.argument('<name>', 'The name of the solution')
|
|
40
|
+
.action(async (name) => {
|
|
41
|
+
const solution = await index_js_1.Solution.load(name);
|
|
42
|
+
await solution.sync();
|
|
43
|
+
});
|
|
44
|
+
exports.command = new commander_1.Command()
|
|
45
|
+
.name('solution')
|
|
46
|
+
.description('Manage ChatBotKit solutions')
|
|
47
|
+
.addCommand(exports.solutionList)
|
|
48
|
+
.addCommand(exports.solutionCreate)
|
|
49
|
+
.addCommand(exports.solutionDelete)
|
|
50
|
+
.addCommand(exports.solutionSync)
|
|
51
|
+
.addCommand(index_js_2.default);
|
|
52
|
+
exports.default = exports.command;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = exports.resourceDelete = exports.resourceCreate = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const input_js_1 = require("../../../input.cjs");
|
|
6
|
+
const output_js_1 = require("../../../output.cjs");
|
|
7
|
+
const index_js_1 = require("../../../solution/index.cjs");
|
|
8
|
+
const commander_1 = require("commander");
|
|
9
|
+
const promises_1 = tslib_1.__importDefault(require("fs/promises"));
|
|
10
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
exports.resourceCreate = new commander_1.Command()
|
|
12
|
+
.name('create')
|
|
13
|
+
.description('Create a new resource')
|
|
14
|
+
.argument('<name>', 'The name of the resource')
|
|
15
|
+
.action(async (name) => {
|
|
16
|
+
await promises_1.default.mkdir('.chatbotkit/resources', { recursive: true });
|
|
17
|
+
const fileName = (0, index_js_1.getSolutionFileName)(name);
|
|
18
|
+
const filePath = path_1.default.join('.chatbotkit', 'resources', fileName);
|
|
19
|
+
if (await promises_1.default.stat(filePath).catch(() => null)) {
|
|
20
|
+
throw new output_js_1.CommandError(`Resource ${fileName} already exists`);
|
|
21
|
+
}
|
|
22
|
+
await promises_1.default.writeFile(filePath, JSON.stringify({}));
|
|
23
|
+
});
|
|
24
|
+
exports.resourceDelete = new commander_1.Command()
|
|
25
|
+
.name('delete')
|
|
26
|
+
.description('Delete a resource')
|
|
27
|
+
.argument('<name>', 'The name of the resource')
|
|
28
|
+
.action(async (name) => {
|
|
29
|
+
const fileName = (0, index_js_1.getSolutionFileName)(name);
|
|
30
|
+
const filePath = path_1.default.join('.chatbotkit', 'resources', fileName);
|
|
31
|
+
if (!(await promises_1.default.stat(filePath).catch(() => null))) {
|
|
32
|
+
throw new output_js_1.CommandError(`Resource ${fileName} does not exist`);
|
|
33
|
+
}
|
|
34
|
+
if (!(await (0, input_js_1.confirm)(`Are you sure you want to delete resource ${fileName}?`))) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
await promises_1.default.unlink(filePath);
|
|
38
|
+
});
|
|
39
|
+
exports.command = new commander_1.Command()
|
|
40
|
+
.name('resource')
|
|
41
|
+
.description('Manage ChatBotKit solution resources')
|
|
42
|
+
.addCommand(exports.resourceCreate)
|
|
43
|
+
.addCommand(exports.resourceDelete);
|
|
44
|
+
exports.default = exports.command;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const index_js_1 = tslib_1.__importDefault(require("./command/api/index.cjs"));
|
|
5
5
|
const index_js_2 = tslib_1.__importDefault(require("./command/chat/index.cjs"));
|
|
6
|
+
const index_js_3 = tslib_1.__importDefault(require("./command/solution/index.cjs"));
|
|
6
7
|
const commander_1 = require("commander");
|
|
7
|
-
async function cbk() {
|
|
8
|
+
async function cbk(argv = process.argv) {
|
|
8
9
|
const program = new commander_1.Command();
|
|
9
10
|
program.name('cbk').description('Command line tools for ChatBotKit');
|
|
10
11
|
program.addCommand(index_js_1.default);
|
|
11
12
|
program.addCommand(index_js_2.default);
|
|
12
|
-
program.
|
|
13
|
+
program.addCommand(index_js_3.default);
|
|
14
|
+
program.parse(argv);
|
|
13
15
|
}
|
|
14
16
|
exports.default = cbk;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function cbk(): Promise<void>;
|
|
1
|
+
export default function cbk(argv?: string[]): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.confirm = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const readline_1 = tslib_1.__importDefault(require("readline"));
|
|
6
|
+
async function confirm(question) {
|
|
7
|
+
const rl = readline_1.default.createInterface({
|
|
8
|
+
input: process.stdin,
|
|
9
|
+
output: process.stdout,
|
|
10
|
+
});
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
rl.question(question + ' [y/N]', (answer) => {
|
|
13
|
+
rl.close();
|
|
14
|
+
resolve(answer.toLowerCase().startsWith('y'));
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.confirm = confirm;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function confirm(question: string): Promise<boolean>;
|
package/dist/cjs/output.cjs
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printError = exports.print = exports.config = void 0;
|
|
3
|
+
exports.printError = exports.print = exports.CommandError = exports.config = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
6
6
|
const util_1 = tslib_1.__importDefault(require("util"));
|
|
7
7
|
exports.config = {
|
|
8
8
|
output: 'yaml',
|
|
9
9
|
};
|
|
10
|
+
class CommandError extends Error {
|
|
11
|
+
}
|
|
12
|
+
exports.CommandError = CommandError;
|
|
10
13
|
function print(input) {
|
|
11
14
|
switch (true) {
|
|
12
15
|
case exports.config.output === 'yaml': {
|
|
@@ -29,6 +32,11 @@ function print(input) {
|
|
|
29
32
|
}
|
|
30
33
|
exports.print = print;
|
|
31
34
|
function printError(error) {
|
|
32
|
-
|
|
35
|
+
if (error instanceof CommandError) {
|
|
36
|
+
console.error(error.message);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.error(error);
|
|
40
|
+
}
|
|
33
41
|
}
|
|
34
42
|
exports.printError = printError;
|
package/dist/cjs/output.d.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getArrayBackedObject = exports.ArrayBackedObject = void 0;
|
|
4
|
+
class ArrayBackedObject {
|
|
5
|
+
constructor(array) {
|
|
6
|
+
this.array = array;
|
|
7
|
+
return new Proxy(this, {
|
|
8
|
+
get: (target, property) => {
|
|
9
|
+
const item = target.array.find((item) => { var _a; return ((_a = (item)) === null || _a === void 0 ? void 0 : _a.name) === property; });
|
|
10
|
+
if (item) {
|
|
11
|
+
return item;
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ArrayBackedObject = ArrayBackedObject;
|
|
19
|
+
function getArrayBackedObject(array) {
|
|
20
|
+
return new ArrayBackedObject(array);
|
|
21
|
+
}
|
|
22
|
+
exports.getArrayBackedObject = getArrayBackedObject;
|