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,82 @@
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 CollectionPerms extends core_1.Command {
9
+ async run() {
10
+ utils_1.client.setConfig(this);
11
+ const { flags } = await this.parse(CollectionPerms);
12
+ // prompts
13
+ if (Object.keys(flags).length == 0) {
14
+ const res = await (0, enquirer_1.prompt)([
15
+ {
16
+ type: 'input',
17
+ name: 'name',
18
+ message: 'Collection name',
19
+ required: true
20
+ },
21
+ {
22
+ type: 'select',
23
+ name: 'type',
24
+ message: 'Collection type',
25
+ required: true,
26
+ choices: ['shared', 'library', 'user']
27
+ },
28
+ ]);
29
+ for (const key in res) {
30
+ if (res.hasOwnProperty(key)) {
31
+ // @ts-ignore
32
+ flags[key] = res[key];
33
+ }
34
+ }
35
+ }
36
+ if (flags.name && flags.type) {
37
+ let collection_uri = '/db/repository/' + flags.name;
38
+ // check if collection exists
39
+ let exists = await utils_1.client.existsCollection(collection_uri);
40
+ if (!exists) {
41
+ this.log(`Collection: ${chalk_1.default.magenta(flags.name)} not found.`);
42
+ this.exit();
43
+ }
44
+ // update collection modes and owners based on type
45
+ let update_perms_response = {};
46
+ if (flags.type == 'user') {
47
+ update_perms_response = await utils_1.client.updateUserCollectionPerms(flags.name);
48
+ this.log(update_perms_response);
49
+ }
50
+ if (flags.type == 'shared') {
51
+ update_perms_response = await utils_1.client.updateSharedCollectionPerms(flags.name);
52
+ }
53
+ if (flags.type == 'library') {
54
+ update_perms_response = await utils_1.client.updateLibraryCollectionPerms(flags.name);
55
+ }
56
+ if (update_perms_response.status == 200) {
57
+ this.log("Collection permissions complete.");
58
+ }
59
+ else {
60
+ this.log("Error updating collection permissions...");
61
+ }
62
+ this.exit();
63
+ }
64
+ }
65
+ }
66
+ CollectionPerms.flags = {
67
+ name: core_1.Flags.string({
68
+ description: 'Collection name',
69
+ required: false
70
+ }),
71
+ source: core_1.Flags.string({
72
+ description: 'Source folder',
73
+ required: false
74
+ }),
75
+ type: core_1.Flags.string({
76
+ description: 'Collection type',
77
+ required: false
78
+ }),
79
+ };
80
+ CollectionPerms.description = "Update file permissions for a collection.";
81
+ CollectionPerms.examples = [`$ legispro collection:perms`,];
82
+ exports.default = CollectionPerms;
@@ -0,0 +1,16 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class CollectionUpdate 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
+ title: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ baseURI: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ defaultExt: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ type: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ owner: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ group: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
+ };
13
+ static description: string;
14
+ static examples: string[];
15
+ }
16
+ export default CollectionUpdate;
@@ -0,0 +1,174 @@
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 treeify = require('treeify');
8
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
9
+ const path_1 = tslib_1.__importDefault(require("path"));
10
+ class CollectionUpdate extends core_1.Command {
11
+ async run() {
12
+ const configFile = path_1.default.join(this.config.configDir, 'config.json');
13
+ const env = require(configFile);
14
+ utils_1.client.setConfig(this);
15
+ const { flags } = await this.parse(CollectionUpdate);
16
+ // get existing collection properties
17
+ let projectObject = {};
18
+ let collectionObject = {};
19
+ let collection_uri = '';
20
+ if (Object.keys(flags).length == 0) {
21
+ const answers1 = await (0, enquirer_1.prompt)([
22
+ {
23
+ type: 'input',
24
+ name: 'name',
25
+ message: 'Name',
26
+ required: true
27
+ },
28
+ ]);
29
+ if (answers1.hasOwnProperty('name')) {
30
+ // @ts-ignore
31
+ flags['name'] = answers1['name'];
32
+ collection_uri = '/db/repository/' + flags.name;
33
+ let collection_exists = await utils_1.client.existsCollection(collection_uri);
34
+ if (!collection_exists) {
35
+ this.log(`${chalk_1.default.red("Error")} : collection ${flags.name} not found`);
36
+ this.exit();
37
+ }
38
+ projectObject = await utils_1.client.getCollectionProject(collection_uri);
39
+ this.log(projectObject);
40
+ if (projectObject == null) {
41
+ this.log(`${chalk_1.default.red("Error")} : no .project.xml file found in ${flags.name}`);
42
+ this.exit();
43
+ }
44
+ collectionObject = await utils_1.client.getCollectionObject(collection_uri);
45
+ this.log(collectionObject);
46
+ }
47
+ const answers2 = await (0, enquirer_1.prompt)([
48
+ {
49
+ type: 'input',
50
+ name: 'title',
51
+ message: 'Title',
52
+ initial: (typeof projectObject.title !== "undefined") ? projectObject.title.toString() : '',
53
+ required: true,
54
+ skip: false
55
+ },
56
+ {
57
+ type: 'input',
58
+ name: 'baseURI',
59
+ message: 'Base URI',
60
+ initial: (typeof projectObject.baseURI !== "undefined") ? projectObject.baseURI.toString() : '',
61
+ required: true,
62
+ skip: false
63
+ },
64
+ {
65
+ type: 'input',
66
+ name: 'defaultExt',
67
+ message: 'Default Extension',
68
+ initial: (typeof projectObject.defaultExt !== "undefined") ? projectObject.defaultExt.toString() : '',
69
+ required: true,
70
+ skip: false
71
+ },
72
+ {
73
+ type: 'select',
74
+ name: 'type',
75
+ message: 'Type',
76
+ initial: (typeof projectObject.type !== "undefined") ?
77
+ ['shared', 'library', 'user'].indexOf(projectObject.type.toString()) : 0,
78
+ required: true,
79
+ choices: ['shared', 'library', 'user'],
80
+ skip: false
81
+ },
82
+ {
83
+ type: 'input',
84
+ name: 'owner',
85
+ message: 'Owner',
86
+ initial: (typeof collectionObject.owner !== "undefined") ? collectionObject.owner.toString() : 'admin',
87
+ required: true,
88
+ skip: false
89
+ },
90
+ {
91
+ type: 'input',
92
+ name: 'group',
93
+ message: 'Group',
94
+ initial: (typeof collectionObject.group !== "undefined") ? collectionObject.group.toString() : 'users',
95
+ required: true,
96
+ skip: false
97
+ },
98
+ ]);
99
+ for (const key in answers2) {
100
+ if (answers2.hasOwnProperty(key)) {
101
+ // @ts-ignore
102
+ flags[key] = answers2[key];
103
+ //this.log("key: "+key);
104
+ // @ts-ignore
105
+ //this.log("value: "+answers2[key]);
106
+ }
107
+ }
108
+ }
109
+ // mode types
110
+ let mode = '';
111
+ if (flags.type == 'shared') {
112
+ mode = 'rwxrwsr-T';
113
+ }
114
+ if (flags.type == 'library') {
115
+ mode = 'rwxr-sr-T';
116
+ }
117
+ if (flags.type == 'user') {
118
+ mode = 'rwxrwsr-T';
119
+ }
120
+ let collection = {
121
+ uri: '/db/repository/' + flags.name,
122
+ owner: flags.owner,
123
+ group: flags.group,
124
+ mode: mode,
125
+ };
126
+ // @ts-ignore
127
+ this.log(collection);
128
+ let modify_response = await utils_1.client.modifyCollection(collection);
129
+ // this.log(modify_response);
130
+ this.exit();
131
+ let list_response = await utils_1.client.getCollection(collection.uri);
132
+ // this.log(treeify.asTree(list_response, true));
133
+ if (list_response.status == 200) {
134
+ this.log(`Collection: ${flags.name} updated`);
135
+ }
136
+ else {
137
+ this.log(list_response);
138
+ }
139
+ this.exit();
140
+ }
141
+ }
142
+ CollectionUpdate.flags = {
143
+ name: core_1.Flags.string({
144
+ description: 'Name',
145
+ required: false
146
+ }),
147
+ title: core_1.Flags.string({
148
+ description: 'Title',
149
+ required: false
150
+ }),
151
+ baseURI: core_1.Flags.string({
152
+ description: 'Base URI',
153
+ required: false
154
+ }),
155
+ defaultExt: core_1.Flags.string({
156
+ description: 'Default extension',
157
+ required: false
158
+ }),
159
+ type: core_1.Flags.string({
160
+ description: 'Collection type',
161
+ required: false
162
+ }),
163
+ owner: core_1.Flags.string({
164
+ description: 'Collection owner',
165
+ required: false
166
+ }),
167
+ group: core_1.Flags.string({
168
+ description: 'Collection group',
169
+ required: false
170
+ }),
171
+ };
172
+ CollectionUpdate.description = "Update a collection";
173
+ CollectionUpdate.examples = [`$ legispro collection:update`,];
174
+ exports.default = CollectionUpdate;
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class CollectionUpload 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
+ source: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ type: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ };
9
+ static description: string;
10
+ static examples: string[];
11
+ }
12
+ export default CollectionUpload;
@@ -0,0 +1,127 @@
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 path_1 = tslib_1.__importDefault(require("path"));
9
+ const ora_1 = tslib_1.__importDefault(require("ora"));
10
+ const rclone = require("rclone.js").promises;
11
+ const fs = require('fs');
12
+ class CollectionUpload extends core_1.Command {
13
+ async run() {
14
+ const configFile = path_1.default.join(this.config.configDir, 'config.json');
15
+ const env = require(configFile);
16
+ utils_1.client.setConfig(this);
17
+ const { flags } = await this.parse(CollectionUpload);
18
+ // prompts
19
+ if (Object.keys(flags).length == 0) {
20
+ const res = await (0, enquirer_1.prompt)([
21
+ {
22
+ type: 'input',
23
+ name: 'name',
24
+ message: 'Collection name',
25
+ required: true
26
+ },
27
+ {
28
+ type: 'select',
29
+ name: 'type',
30
+ message: 'Collection type',
31
+ required: true,
32
+ choices: ['shared', 'library', 'user']
33
+ },
34
+ {
35
+ type: 'input',
36
+ name: 'source',
37
+ message: 'Source folder',
38
+ required: true
39
+ },
40
+ ]);
41
+ for (const key in res) {
42
+ if (res.hasOwnProperty(key)) {
43
+ // @ts-ignore
44
+ flags[key] = res[key];
45
+ }
46
+ }
47
+ }
48
+ if (flags.name && flags.source) {
49
+ let collection_uri = '/db/repository/' + flags.name;
50
+ // check if collection exists
51
+ let exists = await utils_1.client.existsCollection(collection_uri);
52
+ if (!exists) {
53
+ this.log(`Collection: ${chalk_1.default.magenta(flags.name)} not found.`);
54
+ this.exit();
55
+ }
56
+ // check if local folder exists
57
+ fs.access(flags.source, (err) => {
58
+ if (err) {
59
+ this.log(`Source folder: ${flags.source} not found.`);
60
+ //this.exit();
61
+ process.exit();
62
+ }
63
+ });
64
+ const Spinner = (0, ora_1.default)({
65
+ text: `${chalk_1.default.bold(chalk_1.default.blue('Uploading files...'))}`
66
+ }).start();
67
+ let obscured_password = (await rclone.obscure(env.password)).toString().trim();
68
+ let copy_response;
69
+ try {
70
+ copy_response = await rclone.copy(flags.source, ":webdav:" + collection_uri, {
71
+ "webdav-url": env.protocol + "://" + env.hostname + ":" + env.port + "/exist/webdav/",
72
+ "webdav-user": env.user,
73
+ "webdav-pass": obscured_password,
74
+ "ignore-size": true,
75
+ "update": true
76
+ });
77
+ }
78
+ catch (error) {
79
+ console.log('\r\n');
80
+ console.log(error.toString());
81
+ }
82
+ //(JSON.stringify(copy_response,null, '\t'));
83
+ // console.log("response: " + copy_response);
84
+ // this.exit();
85
+ // update collection modes and owners based on type
86
+ let update_perms_response = {};
87
+ if (flags.type == 'user') {
88
+ update_perms_response = await utils_1.client.updateUserCollectionPerms(flags.name);
89
+ this.log(update_perms_response);
90
+ }
91
+ if (flags.type == 'shared') {
92
+ update_perms_response = await utils_1.client.updateSharedCollectionPerms(flags.name);
93
+ }
94
+ if (flags.type == 'library') {
95
+ update_perms_response = await utils_1.client.updateLibraryCollectionPerms(flags.name);
96
+ }
97
+ let response_buffer = copy_response;
98
+ //console.log(response_buffer.toJSON());
99
+ Spinner.stopAndPersist({
100
+ symbol: "✨",
101
+ text: `${chalk_1.default.bold(chalk_1.default.green('File upload complete'))}`
102
+ });
103
+ // success or failure?
104
+ if (update_perms_response.status != 200) {
105
+ this.log("Error uploading files...");
106
+ }
107
+ this.exit();
108
+ }
109
+ }
110
+ }
111
+ CollectionUpload.flags = {
112
+ name: core_1.Flags.string({
113
+ description: 'Collection name',
114
+ required: false
115
+ }),
116
+ source: core_1.Flags.string({
117
+ description: 'Source folder',
118
+ required: false
119
+ }),
120
+ type: core_1.Flags.string({
121
+ description: 'Collection type',
122
+ required: false
123
+ }),
124
+ };
125
+ CollectionUpload.description = "Upload files to collection";
126
+ CollectionUpload.examples = [`$ legispro collection:upload`,];
127
+ exports.default = CollectionUpload;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
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 path_1 = tslib_1.__importDefault(require("path"));
6
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
7
+ class ConfigGet extends core_1.Command {
8
+ async run() {
9
+ const configPath = path_1.default.join(this.config.configDir, 'config.json');
10
+ const data = fs_extra_1.default.readFileSync(configPath);
11
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
+ // @ts-ignore
13
+ const config = JSON.parse(data);
14
+ this.log(config);
15
+ this.exit();
16
+ }
17
+ }
18
+ ConfigGet.description = 'Get your current configuration.';
19
+ module.exports.ConfigSet = ConfigGet;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,125 @@
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 enquirer_1 = require("enquirer");
6
+ const path_1 = tslib_1.__importDefault(require("path"));
7
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
8
+ class ConfigSet extends core_1.Command {
9
+ async run() {
10
+ const { flags } = await this.parse(ConfigSet);
11
+ const config = path_1.default.join(this.config.configDir, 'config.json');
12
+ if (!flags.hostname ||
13
+ !flags.protocol ||
14
+ !flags.port ||
15
+ !flags.user ||
16
+ !flags.password ||
17
+ !flags.webdav ||
18
+ !flags.group) {
19
+ const res = await (0, enquirer_1.prompt)([
20
+ {
21
+ type: 'input',
22
+ name: 'hostname',
23
+ message: 'What is the hostname?',
24
+ required: true,
25
+ },
26
+ {
27
+ type: 'input',
28
+ name: 'protocol',
29
+ message: 'What is the protocol?',
30
+ initial: 'http',
31
+ required: true,
32
+ },
33
+ {
34
+ type: 'numeral',
35
+ name: 'port',
36
+ message: 'What is the db port number?',
37
+ initial: 8080,
38
+ required: true,
39
+ },
40
+ {
41
+ type: 'input',
42
+ name: 'user',
43
+ message: 'What is the db admin username?',
44
+ initial: 'admin',
45
+ required: true,
46
+ },
47
+ {
48
+ type: 'password',
49
+ name: 'password',
50
+ message: 'What is the db admin password?',
51
+ required: true,
52
+ },
53
+ {
54
+ type: 'input',
55
+ name: 'webdav',
56
+ message: 'What the path to the WebDAV interface?',
57
+ initial: 'exist/webdav',
58
+ required: true,
59
+ },
60
+ {
61
+ type: 'input',
62
+ name: 'group',
63
+ message: 'What the default user group?',
64
+ required: true,
65
+ },
66
+ ]);
67
+ for (const key in res) {
68
+ // eslint-disable-next-line no-prototype-builtins
69
+ if (res.hasOwnProperty(key)) {
70
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
71
+ // @ts-ignore
72
+ flags[key] = res[key];
73
+ }
74
+ }
75
+ }
76
+ await fs_extra_1.default.ensureDir(this.config.configDir);
77
+ await fs_extra_1.default.writeJson(config, {
78
+ hostname: flags.hostname,
79
+ protocol: flags.protocol,
80
+ port: flags.port,
81
+ user: flags.user,
82
+ password: flags.password,
83
+ webdav: flags.webdav,
84
+ group: flags.group,
85
+ });
86
+ // if (flags.json) {
87
+ // this.log(JSON.stringify(await credentials(this)));
88
+ // this.exit();
89
+ // }
90
+ this.log('Your LegisPro CLI configuration has been generated!');
91
+ this.exit();
92
+ }
93
+ }
94
+ ConfigSet.flags = {
95
+ hostname: core_1.Flags.string({
96
+ description: 'Hostname',
97
+ required: false,
98
+ }),
99
+ protocol: core_1.Flags.string({
100
+ description: 'Protocol',
101
+ required: false,
102
+ }),
103
+ port: core_1.Flags.string({
104
+ description: 'Port',
105
+ required: false,
106
+ }),
107
+ user: core_1.Flags.string({
108
+ description: 'Admin user',
109
+ required: false,
110
+ }),
111
+ password: core_1.Flags.string({
112
+ description: 'Admin password',
113
+ required: false,
114
+ }),
115
+ webdav: core_1.Flags.string({
116
+ description: 'WebDAV path',
117
+ required: false,
118
+ }),
119
+ group: core_1.Flags.string({
120
+ description: 'User group',
121
+ required: false,
122
+ }),
123
+ };
124
+ ConfigSet.description = 'Sets your user configuration.';
125
+ module.exports.ConfigSet = ConfigSet;
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class DbInit extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default DbInit;
@@ -0,0 +1,90 @@
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 path_1 = tslib_1.__importDefault(require("path"));
7
+ const add_1 = tslib_1.__importDefault(require("../locks/add"));
8
+ class DbInit extends core_1.Command {
9
+ async run() {
10
+ const configFile = path_1.default.join(this.config.configDir, 'config.json');
11
+ const env = require(configFile);
12
+ utils_1.client.setConfig(this);
13
+ // [1] create repository collection
14
+ let collection_exists = await utils_1.client.existsCollection('/db/repository');
15
+ if (!collection_exists) {
16
+ this.log("Creating /db/repository collection...");
17
+ let collection = {
18
+ uri: '/db/repository',
19
+ owner: 'admin',
20
+ group: 'dba',
21
+ mode: 'rwxr-xr-x',
22
+ };
23
+ let create_response = await utils_1.client.createCollection(collection);
24
+ let modify_response = await utils_1.client.modifyCollection(collection);
25
+ }
26
+ else {
27
+ this.log("/db/repository already exists.");
28
+ }
29
+ // [2] create users group
30
+ let res = await utils_1.client.getGroup('users');
31
+ if (res.status != 200) {
32
+ this.log("Creating users group...");
33
+ let meta = [];
34
+ meta.push({
35
+ key: "http://axschema.org/contact/email",
36
+ value: ""
37
+ });
38
+ meta.push({
39
+ key: "http://exist-db.org/security/description",
40
+ value: "Users"
41
+ });
42
+ meta.push({
43
+ key: "http://axschema.org/pref/language",
44
+ value: "en-US"
45
+ });
46
+ let users_group = {
47
+ groupName: 'users',
48
+ managers: ["admin"],
49
+ metadata: meta,
50
+ };
51
+ let create_group_response = await utils_1.client.createGroup(users_group);
52
+ }
53
+ else {
54
+ this.log("Users group already exists.");
55
+ }
56
+ // [3] create primary group
57
+ let res_primary_group = await utils_1.client.getGroup(env.group);
58
+ if (res_primary_group.status != 200) {
59
+ this.log("Creating primary group...");
60
+ let meta = [];
61
+ meta.push({
62
+ key: "http://axschema.org/contact/email",
63
+ value: ""
64
+ });
65
+ meta.push({
66
+ key: "http://exist-db.org/security/description",
67
+ value: "Primary user group"
68
+ });
69
+ meta.push({
70
+ key: "http://axschema.org/pref/language",
71
+ value: "en-US"
72
+ });
73
+ let primary_user_group = {
74
+ groupName: env.group,
75
+ managers: ["admin"],
76
+ metadata: meta,
77
+ };
78
+ let create_primary_user_group_response = await utils_1.client.createGroup(primary_user_group);
79
+ }
80
+ else {
81
+ this.log("Primary user group already exists.");
82
+ }
83
+ // [4] add locks
84
+ await add_1.default.run();
85
+ this.exit();
86
+ }
87
+ }
88
+ DbInit.description = "Initialize a new database";
89
+ DbInit.examples = [`$ legispro db:init`];
90
+ exports.default = DbInit;
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class DbMemory extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default DbMemory;