legispro-cli 1.0.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.
Files changed (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +696 -0
  3. package/bin/dev +17 -0
  4. package/bin/dev.cmd +3 -0
  5. package/bin/run +5 -0
  6. package/bin/run.cmd +3 -0
  7. package/dist/commands/backup/create.d.ts +7 -0
  8. package/dist/commands/backup/create.js +26 -0
  9. package/dist/commands/backup/list.d.ts +7 -0
  10. package/dist/commands/backup/list.js +38 -0
  11. package/dist/commands/collection/add.d.ts +12 -0
  12. package/dist/commands/collection/add.js +108 -0
  13. package/dist/commands/collection/create.d.ts +14 -0
  14. package/dist/commands/collection/create.js +132 -0
  15. package/dist/commands/collection/delete.d.ts +10 -0
  16. package/dist/commands/collection/delete.js +53 -0
  17. package/dist/commands/collection/download.d.ts +11 -0
  18. package/dist/commands/collection/download.js +87 -0
  19. package/dist/commands/collection/get.d.ts +10 -0
  20. package/dist/commands/collection/get.js +54 -0
  21. package/dist/commands/collection/list.d.ts +7 -0
  22. package/dist/commands/collection/list.js +25 -0
  23. package/dist/commands/collection/perms.d.ts +12 -0
  24. package/dist/commands/collection/perms.js +82 -0
  25. package/dist/commands/collection/update.d.ts +16 -0
  26. package/dist/commands/collection/update.js +174 -0
  27. package/dist/commands/collection/upload.d.ts +12 -0
  28. package/dist/commands/collection/upload.js +127 -0
  29. package/dist/commands/config/get.d.ts +1 -0
  30. package/dist/commands/config/get.js +19 -0
  31. package/dist/commands/config/set.d.ts +1 -0
  32. package/dist/commands/config/set.js +125 -0
  33. package/dist/commands/db/init.d.ts +7 -0
  34. package/dist/commands/db/init.js +90 -0
  35. package/dist/commands/db/memory.d.ts +7 -0
  36. package/dist/commands/db/memory.js +27 -0
  37. package/dist/commands/db/uptime.d.ts +7 -0
  38. package/dist/commands/db/uptime.js +17 -0
  39. package/dist/commands/db/version.d.ts +7 -0
  40. package/dist/commands/db/version.js +17 -0
  41. package/dist/commands/document/copy.d.ts +7 -0
  42. package/dist/commands/document/copy.js +35 -0
  43. package/dist/commands/document/list.d.ts +7 -0
  44. package/dist/commands/document/list.js +34 -0
  45. package/dist/commands/group/create.d.ts +14 -0
  46. package/dist/commands/group/create.js +132 -0
  47. package/dist/commands/group/delete.d.ts +10 -0
  48. package/dist/commands/group/delete.js +50 -0
  49. package/dist/commands/group/get.d.ts +10 -0
  50. package/dist/commands/group/get.js +51 -0
  51. package/dist/commands/group/list.d.ts +7 -0
  52. package/dist/commands/group/list.js +20 -0
  53. package/dist/commands/group/update.d.ts +14 -0
  54. package/dist/commands/group/update.js +132 -0
  55. package/dist/commands/locks/add.d.ts +7 -0
  56. package/dist/commands/locks/add.js +80 -0
  57. package/dist/commands/locks/clear.d.ts +7 -0
  58. package/dist/commands/locks/clear.js +23 -0
  59. package/dist/commands/locks/list.d.ts +7 -0
  60. package/dist/commands/locks/list.js +86 -0
  61. package/dist/commands/services/health.d.ts +8 -0
  62. package/dist/commands/services/health.js +66 -0
  63. package/dist/commands/user/create.d.ts +26 -0
  64. package/dist/commands/user/create.js +374 -0
  65. package/dist/commands/user/delete.d.ts +10 -0
  66. package/dist/commands/user/delete.js +58 -0
  67. package/dist/commands/user/get.d.ts +10 -0
  68. package/dist/commands/user/get.js +53 -0
  69. package/dist/commands/user/list.d.ts +7 -0
  70. package/dist/commands/user/list.js +24 -0
  71. package/dist/commands/user/login.d.ts +13 -0
  72. package/dist/commands/user/login.js +93 -0
  73. package/dist/commands/user/update.d.ts +25 -0
  74. package/dist/commands/user/update.js +267 -0
  75. package/dist/index.d.ts +1 -0
  76. package/dist/index.js +5 -0
  77. package/dist/lib/fusiondb-client.d.ts +52 -0
  78. package/dist/lib/fusiondb-client.js +655 -0
  79. package/dist/lib/rclone-client.d.ts +11 -0
  80. package/dist/lib/rclone-client.js +41 -0
  81. package/dist/lib/types.d.ts +79 -0
  82. package/dist/lib/types.js +2 -0
  83. package/dist/lib/utils.d.ts +4 -0
  84. package/dist/lib/utils.js +7 -0
  85. package/dist/lib/xml-templates.d.ts +6 -0
  86. package/dist/lib/xml-templates.js +66 -0
  87. package/oclif.manifest.json +1063 -0
  88. package/package.json +98 -0
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const utils_1 = require("../../lib/utils");
5
+ class DbMemory extends core_1.Command {
6
+ async run() {
7
+ utils_1.client.setConfig(this);
8
+ let mem_total_response = await utils_1.client.memoryTotal();
9
+ let mem_max_response = await utils_1.client.memoryMax();
10
+ let mem_free_response = await utils_1.client.memoryFree();
11
+ this.log(" Memory Status");
12
+ this.log("================");
13
+ if (mem_total_response.status == 200) {
14
+ this.log(`Total: ${mem_total_response.data.results}`);
15
+ }
16
+ if (mem_max_response.status == 200) {
17
+ this.log(`Max: ${mem_max_response.data.results}`);
18
+ }
19
+ if (mem_free_response.status == 200) {
20
+ this.log(`Free: ${mem_free_response.data.results}`);
21
+ }
22
+ this.exit();
23
+ }
24
+ }
25
+ DbMemory.description = "Database memory status";
26
+ DbMemory.examples = [`$ legispro db:memory`,];
27
+ exports.default = DbMemory;
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class DbUptime extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default DbUptime;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const utils_1 = require("../../lib/utils");
5
+ class DbUptime extends core_1.Command {
6
+ async run() {
7
+ utils_1.client.setConfig(this);
8
+ let response = await utils_1.client.uptime();
9
+ if (response.status == 200) {
10
+ this.log(response.data.results);
11
+ this.exit();
12
+ }
13
+ }
14
+ }
15
+ DbUptime.description = "Get database uptime";
16
+ DbUptime.examples = [`$ legispro db:uptime`,];
17
+ exports.default = DbUptime;
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class DbVersion extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default DbVersion;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const utils_1 = require("../../lib/utils");
5
+ class DbVersion extends core_1.Command {
6
+ async run() {
7
+ utils_1.client.setConfig(this);
8
+ let response = await utils_1.client.get("/version");
9
+ if (response.status == 200) {
10
+ this.log(JSON.stringify(response.data, null, 2));
11
+ this.exit();
12
+ }
13
+ }
14
+ }
15
+ DbVersion.description = "Get database version";
16
+ DbVersion.examples = [`$ legispro db:version`,];
17
+ exports.default = DbVersion;
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class DocumentCopy extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default DocumentCopy;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const utils_1 = require("../../lib/utils");
7
+ const path_1 = tslib_1.__importDefault(require("path"));
8
+ const rclone = require("rclone.js").promises;
9
+ class DocumentCopy extends core_1.Command {
10
+ async run() {
11
+ const configFile = path_1.default.join(this.config.configDir, 'config.json');
12
+ const env = require(configFile);
13
+ utils_1.client.setConfig(this);
14
+ let source = '/db/repository/demo';
15
+ let dest = '/home/bmckinney/rclone-tests/demo';
16
+ // check if source exists
17
+ let exists = await utils_1.client.existsCollection(source);
18
+ if (!exists) {
19
+ this.log(`Collection: ${chalk_1.default.magenta("repository")} not found.`);
20
+ this.exit();
21
+ }
22
+ let obscured_password = await rclone.obscure(env.password);
23
+ let copy_response = await rclone.copy(":webdav:" + source, dest, {
24
+ "webdav-url": env.protocol + "://" + env.hostname + ":" + env.port + "/exist/webdav/",
25
+ "webdav-user": env.user,
26
+ "webdav-pass": obscured_password
27
+ });
28
+ console.log(JSON.stringify(copy_response, null, '\t'));
29
+ //console.log(copy_response.toString());
30
+ this.exit();
31
+ }
32
+ }
33
+ DocumentCopy.description = "List documents";
34
+ DocumentCopy.examples = [`$ legispro document:list`,];
35
+ exports.default = DocumentCopy;
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class DocumentList extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default DocumentList;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const utils_1 = require("../../lib/utils");
7
+ const path_1 = tslib_1.__importDefault(require("path"));
8
+ const rclone = require("rclone.js").promises;
9
+ class DocumentList extends core_1.Command {
10
+ async run() {
11
+ const configFile = path_1.default.join(this.config.configDir, 'config.json');
12
+ const env = require(configFile);
13
+ utils_1.client.setConfig(this);
14
+ let uri = '/db/repository';
15
+ // check if collection exists
16
+ let exists = await utils_1.client.existsCollection(uri);
17
+ if (!exists) {
18
+ this.log(`Collection: ${chalk_1.default.magenta("repository")} not found.`);
19
+ this.exit();
20
+ }
21
+ let obscured_password = await rclone.obscure(env.password);
22
+ let list_response = await rclone.ls(":webdav:" + uri, {
23
+ "webdav-url": env.protocol + "://" + env.hostname + ":" + env.port + "/exist/webdav/",
24
+ "webdav-user": env.user,
25
+ "webdav-pass": obscured_password,
26
+ "max-depth": 2,
27
+ });
28
+ console.log(list_response.toString());
29
+ this.exit();
30
+ }
31
+ }
32
+ DocumentList.description = "List documents";
33
+ DocumentList.examples = [`$ legispro document:list`,];
34
+ exports.default = DocumentList;
@@ -0,0 +1,14 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class GroupCreate extends Command {
3
+ run(): Promise<void>;
4
+ static flags: {
5
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
+ managers: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ email: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ language: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ description: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ };
11
+ static description: string;
12
+ static examples: string[];
13
+ }
14
+ export default GroupCreate;
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../../lib/utils");
6
+ const enquirer_1 = require("enquirer");
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ class GroupCreate extends core_1.Command {
9
+ async run() {
10
+ utils_1.client.setConfig(this);
11
+ const { flags } = await this.parse(GroupCreate);
12
+ // prompts
13
+ if (!flags.name) {
14
+ const name_answer = await (0, enquirer_1.prompt)([
15
+ {
16
+ type: 'input',
17
+ name: 'name',
18
+ message: 'Name',
19
+ required: true
20
+ },
21
+ ]);
22
+ // @ts-ignore
23
+ flags.name = name_answer['name'];
24
+ const res = await (0, enquirer_1.prompt)([
25
+ {
26
+ type: 'input',
27
+ name: 'description',
28
+ message: 'Description',
29
+ required: false
30
+ },
31
+ {
32
+ type: 'input',
33
+ name: 'managers',
34
+ message: 'Managers',
35
+ initial: `admin,${flags.name}`,
36
+ required: true
37
+ },
38
+ {
39
+ type: 'input',
40
+ name: 'email',
41
+ message: 'Email',
42
+ required: false
43
+ },
44
+ {
45
+ type: 'input',
46
+ name: 'language',
47
+ message: 'Language',
48
+ required: false,
49
+ skip: false
50
+ },
51
+ ]);
52
+ for (const key in res) {
53
+ if (res.hasOwnProperty(key)) {
54
+ // @ts-ignore
55
+ flags[key] = res[key];
56
+ }
57
+ }
58
+ }
59
+ if (flags.name) {
60
+ // const Spinner = ora({
61
+ // text: `${chalk.bold(chalk.blue('Creating group...'))}`
62
+ // }).start()
63
+ let manager_list = ['admin', flags.name];
64
+ if (flags.managers) {
65
+ manager_list = `${flags.managers}`.split(",");
66
+ }
67
+ let meta = [];
68
+ if (flags.email) {
69
+ meta.push({
70
+ key: "http://axschema.org/contact/email",
71
+ value: flags.email
72
+ });
73
+ }
74
+ if (flags.description) {
75
+ meta.push({
76
+ key: "http://exist-db.org/security/description",
77
+ value: flags.description
78
+ });
79
+ }
80
+ if (flags.language) {
81
+ meta.push({
82
+ key: "http://axschema.org/pref/language",
83
+ value: flags.language
84
+ });
85
+ }
86
+ let group = {
87
+ groupName: flags.name,
88
+ managers: manager_list,
89
+ metadata: meta,
90
+ };
91
+ let create_group_response = await utils_1.client.createGroup(group);
92
+ // Spinner.stopAndPersist({
93
+ // symbol: "✨",
94
+ // text: `${chalk.bold(chalk.green('Group created'))}`
95
+ // })
96
+ if (create_group_response.status == 204) {
97
+ this.log(`${chalk_1.default.bold.green('Group created')}`);
98
+ this.exit();
99
+ }
100
+ else {
101
+ this.log(`${chalk_1.default.red("Error:")} (${create_group_response.status}) ${create_group_response.statusText}.`);
102
+ // this.log(create_group_response);
103
+ this.exit();
104
+ }
105
+ }
106
+ }
107
+ }
108
+ GroupCreate.flags = {
109
+ name: core_1.Flags.string({
110
+ description: 'Name',
111
+ required: false
112
+ }),
113
+ managers: core_1.Flags.string({
114
+ description: 'Managers',
115
+ required: false
116
+ }),
117
+ email: core_1.Flags.string({
118
+ description: 'email',
119
+ required: false
120
+ }),
121
+ language: core_1.Flags.string({
122
+ description: 'language',
123
+ required: false
124
+ }),
125
+ description: core_1.Flags.string({
126
+ description: 'description',
127
+ required: false
128
+ }),
129
+ };
130
+ GroupCreate.description = "Create group";
131
+ GroupCreate.examples = [`$ legispro groupr:create`,];
132
+ exports.default = GroupCreate;
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class GroupDelete extends Command {
3
+ run(): Promise<void>;
4
+ static flags: {
5
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ }
10
+ export default GroupDelete;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../../lib/utils");
6
+ const enquirer_1 = require("enquirer");
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ class GroupDelete extends core_1.Command {
9
+ async run() {
10
+ utils_1.client.setConfig(this);
11
+ const { flags } = await this.parse(GroupDelete);
12
+ if (!flags.name) {
13
+ const res = await (0, enquirer_1.prompt)([
14
+ {
15
+ type: 'input',
16
+ name: 'name',
17
+ message: 'Name',
18
+ required: true
19
+ }
20
+ ]);
21
+ for (const key in res) {
22
+ if (res.hasOwnProperty(key)) {
23
+ // @ts-ignore
24
+ flags[key] = res[key];
25
+ }
26
+ }
27
+ }
28
+ if (flags.name) {
29
+ let res = await utils_1.client.deleteGroup(flags.name);
30
+ if (res.status == 204) {
31
+ // this.log(JSON.stringify(res.data, null, 2));
32
+ this.log(`${chalk_1.default.bold(chalk_1.default.green('Group deleted'))}`);
33
+ this.exit();
34
+ }
35
+ else {
36
+ this.log(`${chalk_1.default.red("Error:")} (${res.status}) ${res.statusText}.`);
37
+ this.exit();
38
+ }
39
+ }
40
+ }
41
+ }
42
+ GroupDelete.flags = {
43
+ name: core_1.Flags.string({
44
+ description: 'Name',
45
+ required: false
46
+ }),
47
+ };
48
+ GroupDelete.description = "Get group information";
49
+ GroupDelete.examples = [`$ legispro group:get --name demo`,];
50
+ exports.default = GroupDelete;
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class GroupGet extends Command {
3
+ run(): Promise<void>;
4
+ static flags: {
5
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ }
10
+ export default GroupGet;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../../lib/utils");
6
+ const enquirer_1 = require("enquirer");
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ const treeify = require('treeify');
9
+ class GroupGet extends core_1.Command {
10
+ async run() {
11
+ utils_1.client.setConfig(this);
12
+ const { flags } = await this.parse(GroupGet);
13
+ if (!flags.name) {
14
+ const res = await (0, enquirer_1.prompt)([
15
+ {
16
+ type: 'input',
17
+ name: 'name',
18
+ message: 'Name',
19
+ required: true
20
+ }
21
+ ]);
22
+ for (const key in res) {
23
+ if (res.hasOwnProperty(key)) {
24
+ // @ts-ignore
25
+ flags[key] = res[key];
26
+ }
27
+ }
28
+ }
29
+ if (flags.name) {
30
+ let res = await utils_1.client.getGroup(flags.name);
31
+ if (res.status == 200) {
32
+ // this.log(JSON.stringify(res.data, null, 2));
33
+ this.log(treeify.asTree(res.data, true));
34
+ this.exit();
35
+ }
36
+ else {
37
+ this.log(`${chalk_1.default.red("Error:")} group ${flags.name} doesn't exist.`);
38
+ this.exit();
39
+ }
40
+ }
41
+ }
42
+ }
43
+ GroupGet.flags = {
44
+ name: core_1.Flags.string({
45
+ description: 'Name',
46
+ required: false
47
+ }),
48
+ };
49
+ GroupGet.description = "Get group information";
50
+ GroupGet.examples = [`$ legispro group:get --name demo`,];
51
+ exports.default = GroupGet;
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class GroupList extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default GroupList;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const utils_1 = require("../../lib/utils");
5
+ class GroupList extends core_1.Command {
6
+ async run() {
7
+ utils_1.client.setConfig(this);
8
+ let groups = await utils_1.client.getGroups();
9
+ // const users: User[] = [];
10
+ // for (let name of names) {
11
+ // users.push({userName: name})
12
+ // }
13
+ // this.log(JSON.stringify(users, null, 2));
14
+ this.log(groups);
15
+ this.exit();
16
+ }
17
+ }
18
+ GroupList.description = "Get list of all groups";
19
+ GroupList.examples = [`$ legispro group:list`,];
20
+ exports.default = GroupList;
@@ -0,0 +1,14 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class GroupUpdate extends Command {
3
+ run(): Promise<void>;
4
+ static flags: {
5
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
+ managers: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ email: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ language: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ description: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ };
11
+ static description: string;
12
+ static examples: string[];
13
+ }
14
+ export default GroupUpdate;
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../../lib/utils");
6
+ const enquirer_1 = require("enquirer");
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ class GroupUpdate extends core_1.Command {
9
+ async run() {
10
+ utils_1.client.setConfig(this);
11
+ const { flags } = await this.parse(GroupUpdate);
12
+ // prompts
13
+ if (!flags.name) {
14
+ const name_answer = await (0, enquirer_1.prompt)([
15
+ {
16
+ type: 'input',
17
+ name: 'name',
18
+ message: 'Name',
19
+ required: true
20
+ },
21
+ ]);
22
+ // @ts-ignore
23
+ flags.name = name_answer['name'];
24
+ const res = await (0, enquirer_1.prompt)([
25
+ {
26
+ type: 'input',
27
+ name: 'description',
28
+ message: 'Description',
29
+ required: false
30
+ },
31
+ {
32
+ type: 'input',
33
+ name: 'managers',
34
+ message: 'Managers',
35
+ initial: `admin,${flags.name}`,
36
+ required: true
37
+ },
38
+ {
39
+ type: 'input',
40
+ name: 'email',
41
+ message: 'Email',
42
+ required: false
43
+ },
44
+ {
45
+ type: 'input',
46
+ name: 'language',
47
+ message: 'Language',
48
+ required: false,
49
+ skip: false
50
+ },
51
+ ]);
52
+ for (const key in res) {
53
+ if (res.hasOwnProperty(key)) {
54
+ // @ts-ignore
55
+ flags[key] = res[key];
56
+ }
57
+ }
58
+ }
59
+ if (flags.name) {
60
+ // const Spinner = ora({
61
+ // text: `${chalk.bold(chalk.blue('Creating group...'))}`
62
+ // }).start()
63
+ let manager_list = ['admin', flags.name];
64
+ if (flags.managers) {
65
+ manager_list = `${flags.managers}`.split(",");
66
+ }
67
+ let meta = [];
68
+ if (flags.email) {
69
+ meta.push({
70
+ key: "http://axschema.org/contact/email",
71
+ value: flags.email
72
+ });
73
+ }
74
+ if (flags.description) {
75
+ meta.push({
76
+ key: "http://exist-db.org/security/description",
77
+ value: flags.description
78
+ });
79
+ }
80
+ if (flags.language) {
81
+ meta.push({
82
+ key: "http://axschema.org/pref/language",
83
+ value: flags.language
84
+ });
85
+ }
86
+ let group = {
87
+ groupName: flags.name,
88
+ managers: manager_list,
89
+ metadata: meta,
90
+ };
91
+ let create_group_response = await utils_1.client.createGroup(group);
92
+ // Spinner.stopAndPersist({
93
+ // symbol: "✨",
94
+ // text: `${chalk.bold(chalk.green('Group created'))}`
95
+ // })
96
+ if (create_group_response.status == 204) {
97
+ this.log(`${chalk_1.default.bold(chalk_1.default.green('Group created'))}`);
98
+ this.exit();
99
+ }
100
+ else {
101
+ this.log(`${chalk_1.default.red("Error:")} (${create_group_response.status}) ${create_group_response.statusText}.`);
102
+ // this.log(create_group_response);
103
+ this.exit();
104
+ }
105
+ }
106
+ }
107
+ }
108
+ GroupUpdate.flags = {
109
+ name: core_1.Flags.string({
110
+ description: 'Name',
111
+ required: false
112
+ }),
113
+ managers: core_1.Flags.string({
114
+ description: 'Managers',
115
+ required: false
116
+ }),
117
+ email: core_1.Flags.string({
118
+ description: 'email',
119
+ required: false
120
+ }),
121
+ language: core_1.Flags.string({
122
+ description: 'language',
123
+ required: false
124
+ }),
125
+ description: core_1.Flags.string({
126
+ description: 'description',
127
+ required: false
128
+ }),
129
+ };
130
+ GroupUpdate.description = "Create group";
131
+ GroupUpdate.examples = [`$ legispro groupr:create`,];
132
+ exports.default = GroupUpdate;
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class LocksAdd extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default LocksAdd;