legispro-cli 1.0.7 → 1.0.9
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 +43 -17
- package/bin/dev.cmd +1 -1
- package/bin/dev.js +5 -0
- package/bin/run.js +5 -0
- package/dist/commands/backup/create.js +13 -16
- package/dist/commands/backup/list.js +15 -18
- package/dist/commands/collection/add.d.ts +3 -3
- package/dist/commands/collection/add.js +31 -34
- package/dist/commands/collection/create.d.ts +5 -5
- package/dist/commands/collection/create.js +40 -43
- package/dist/commands/collection/delete.d.ts +1 -1
- package/dist/commands/collection/delete.js +20 -23
- package/dist/commands/collection/download.d.ts +2 -2
- package/dist/commands/collection/download.js +28 -31
- package/dist/commands/collection/get.d.ts +1 -1
- package/dist/commands/collection/get.js +21 -24
- package/dist/commands/collection/list.js +13 -16
- package/dist/commands/collection/perms.d.ts +3 -3
- package/dist/commands/collection/perms.js +29 -32
- package/dist/commands/collection/update.d.ts +7 -7
- package/dist/commands/collection/update.js +50 -54
- package/dist/commands/collection/upload.d.ts +3 -3
- package/dist/commands/collection/upload.js +39 -42
- package/dist/commands/config/get.d.ts +5 -1
- package/dist/commands/config/get.js +7 -10
- package/dist/commands/config/set.d.ts +5 -1
- package/dist/commands/config/set.js +41 -24
- package/dist/commands/db/init.js +18 -21
- package/dist/commands/db/memory.js +10 -12
- package/dist/commands/db/uptime.js +8 -10
- package/dist/commands/db/version.js +8 -10
- package/dist/commands/deploy/index.d.ts +10 -0
- package/dist/commands/deploy/index.js +130 -0
- package/dist/commands/document/copy.js +15 -18
- package/dist/commands/document/list.js +15 -18
- package/dist/commands/group/create.d.ts +5 -5
- package/dist/commands/group/create.js +36 -39
- package/dist/commands/group/delete.d.ts +1 -1
- package/dist/commands/group/delete.js +19 -22
- package/dist/commands/group/get.d.ts +1 -1
- package/dist/commands/group/get.js +20 -23
- package/dist/commands/group/list.js +8 -10
- package/dist/commands/group/update.d.ts +5 -5
- package/dist/commands/group/update.js +36 -39
- package/dist/commands/locks/add.js +16 -18
- package/dist/commands/locks/clear.js +11 -13
- package/dist/commands/services/health.js +11 -14
- package/dist/commands/user/create.d.ts +17 -17
- package/dist/commands/user/create.js +104 -107
- package/dist/commands/user/delete.d.ts +1 -1
- package/dist/commands/user/delete.js +24 -27
- package/dist/commands/user/get.d.ts +1 -1
- package/dist/commands/user/get.js +20 -23
- package/dist/commands/user/list.js +10 -13
- package/dist/commands/user/login.d.ts +2 -2
- package/dist/commands/user/login.js +30 -33
- package/dist/commands/user/update.d.ts +16 -16
- package/dist/commands/user/update.js +108 -111
- package/dist/index.js +1 -5
- package/dist/lib/fusiondb-client.d.ts +2 -1
- package/dist/lib/fusiondb-client.js +19 -18
- package/dist/lib/gh.d.ts +26 -0
- package/dist/lib/gh.js +37 -0
- package/dist/lib/rclone-client.js +12 -15
- package/dist/lib/shell.d.ts +24 -0
- package/dist/lib/shell.js +76 -0
- package/dist/lib/types.js +1 -2
- package/dist/lib/utils.d.ts +2 -2
- package/dist/lib/utils.js +4 -7
- package/dist/lib/xml-templates.js +6 -10
- package/oclif.manifest.json +972 -533
- package/package.json +51 -47
- package/bin/dev +0 -17
- package/bin/run +0 -5
- package/dist/commands/locks/list.d.ts +0 -7
- package/dist/commands/locks/list.js +0 -86
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const ora_1 = tslib_1.__importDefault(require("ora"));
|
|
10
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
-
class UserCreate extends core_1.Command {
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { client } from "../../lib/utils.js";
|
|
3
|
+
import { XmlTemplates } from "../../lib/xml-templates.js";
|
|
4
|
+
import enquirer from 'enquirer';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import ora from 'ora';
|
|
7
|
+
import path from "path";
|
|
8
|
+
class UserCreate extends Command {
|
|
12
9
|
async run() {
|
|
13
|
-
const configFile =
|
|
10
|
+
const configFile = path.join(this.config.configDir, 'config.json');
|
|
14
11
|
const env = require(configFile);
|
|
15
|
-
|
|
12
|
+
client.setConfig(this);
|
|
16
13
|
const { flags } = await this.parse(UserCreate);
|
|
17
14
|
// prompts
|
|
18
15
|
if (!flags.username) {
|
|
19
|
-
const name_answer = await
|
|
16
|
+
const name_answer = await enquirer.prompt([
|
|
20
17
|
{
|
|
21
18
|
type: 'input',
|
|
22
19
|
name: 'username',
|
|
@@ -26,7 +23,7 @@ class UserCreate extends core_1.Command {
|
|
|
26
23
|
]);
|
|
27
24
|
// @ts-ignore
|
|
28
25
|
flags.username = name_answer['username'];
|
|
29
|
-
const res = await
|
|
26
|
+
const res = await enquirer.prompt([
|
|
30
27
|
{
|
|
31
28
|
type: 'password',
|
|
32
29
|
name: 'password',
|
|
@@ -140,8 +137,8 @@ class UserCreate extends core_1.Command {
|
|
|
140
137
|
}
|
|
141
138
|
}
|
|
142
139
|
if (flags.username && flags.password) {
|
|
143
|
-
const Spinner = (
|
|
144
|
-
text: `${
|
|
140
|
+
const Spinner = ora({
|
|
141
|
+
text: `${chalk.bold.blue('Creating user...')}`
|
|
145
142
|
}).start();
|
|
146
143
|
let scratchpad_uri = "/db/repository/" + flags.username + "/akn-" + env.group + "-data-scratchpad.xml";
|
|
147
144
|
let isEnabled = true;
|
|
@@ -240,20 +237,20 @@ class UserCreate extends core_1.Command {
|
|
|
240
237
|
enabled: isEnabled,
|
|
241
238
|
umask: umask
|
|
242
239
|
};
|
|
243
|
-
let check_user_response = await
|
|
240
|
+
let check_user_response = await client.getUser(flags.username);
|
|
244
241
|
if (check_user_response.status === 200) {
|
|
245
242
|
Spinner.stopAndPersist({
|
|
246
243
|
symbol: "✨",
|
|
247
|
-
text: `${
|
|
244
|
+
text: `${chalk.bold(chalk.red(`User '${flags.username}' exists already.`))}`
|
|
248
245
|
});
|
|
249
246
|
this.exit();
|
|
250
247
|
}
|
|
251
248
|
// 1. create user
|
|
252
|
-
let create_user_response = await
|
|
249
|
+
let create_user_response = await client.createUser(user);
|
|
253
250
|
// 2. create user group (need user first)
|
|
254
|
-
let create_user_group_response = await
|
|
251
|
+
let create_user_group_response = await client.createGroup(userGroup);
|
|
255
252
|
// 3. update user with new user group
|
|
256
|
-
let update_user_response = await
|
|
253
|
+
let update_user_response = await client.createUser(user);
|
|
257
254
|
// 4. create user collection
|
|
258
255
|
let user_collection = {
|
|
259
256
|
uri: '/db/repository/' + flags.username,
|
|
@@ -261,12 +258,12 @@ class UserCreate extends core_1.Command {
|
|
|
261
258
|
group: primaryGroup,
|
|
262
259
|
mode: 'rwxrwsr-T',
|
|
263
260
|
};
|
|
264
|
-
let create_response = await
|
|
265
|
-
let modify_response = await
|
|
261
|
+
let create_response = await client.createCollection(user_collection);
|
|
262
|
+
let modify_response = await client.modifyCollection(user_collection);
|
|
266
263
|
// todo: add a .project.xml
|
|
267
264
|
// 5. create scratchpad xml in user's collection
|
|
268
265
|
if (flags.scratchpad) {
|
|
269
|
-
const buffer = Buffer.from(
|
|
266
|
+
const buffer = Buffer.from(XmlTemplates.scratchpad.replace(/{{username}}/gmi, flags.username), "utf-8");
|
|
270
267
|
let scratchpad_document = {
|
|
271
268
|
uri: scratchpad_uri,
|
|
272
269
|
mediaType: "application/xml",
|
|
@@ -275,100 +272,100 @@ class UserCreate extends core_1.Command {
|
|
|
275
272
|
group: env.group,
|
|
276
273
|
mode: "rw-r--r--"
|
|
277
274
|
};
|
|
278
|
-
let scratchpad_response = await
|
|
279
|
-
let update_doc_props_response = await
|
|
275
|
+
let scratchpad_response = await client.createDocument(scratchpad_uri, buffer);
|
|
276
|
+
let update_doc_props_response = await client.updateDocumentProperties(scratchpad_document);
|
|
280
277
|
}
|
|
281
278
|
// 6. user list
|
|
282
|
-
let get_user_response = await
|
|
279
|
+
let get_user_response = await client.getUser(flags.username);
|
|
283
280
|
Spinner.stopAndPersist({
|
|
284
281
|
symbol: "✨",
|
|
285
|
-
text: `${
|
|
282
|
+
text: `${chalk.bold(chalk.green('User created'))}`
|
|
286
283
|
});
|
|
287
284
|
if (get_user_response.status == 200) {
|
|
288
285
|
this.log(JSON.stringify(get_user_response.data, null, 2));
|
|
289
286
|
this.exit();
|
|
290
287
|
}
|
|
291
288
|
else {
|
|
292
|
-
this.log(`${
|
|
289
|
+
this.log(`${chalk.red("Error:")} user ${flags.username} doesn't exist.`);
|
|
293
290
|
this.exit();
|
|
294
291
|
}
|
|
295
292
|
}
|
|
296
293
|
}
|
|
294
|
+
static flags = {
|
|
295
|
+
username: Flags.string({
|
|
296
|
+
description: 'Username to create',
|
|
297
|
+
required: false
|
|
298
|
+
}),
|
|
299
|
+
groups: Flags.string({
|
|
300
|
+
description: 'Group memberships',
|
|
301
|
+
required: false
|
|
302
|
+
}),
|
|
303
|
+
email: Flags.string({
|
|
304
|
+
description: 'email',
|
|
305
|
+
required: false
|
|
306
|
+
}),
|
|
307
|
+
language: Flags.string({
|
|
308
|
+
description: 'language',
|
|
309
|
+
required: false
|
|
310
|
+
}),
|
|
311
|
+
description: Flags.string({
|
|
312
|
+
description: 'description',
|
|
313
|
+
required: false
|
|
314
|
+
}),
|
|
315
|
+
password: Flags.string({
|
|
316
|
+
description: 'password',
|
|
317
|
+
required: false
|
|
318
|
+
}),
|
|
319
|
+
primaryGroup: Flags.string({
|
|
320
|
+
description: 'primary group',
|
|
321
|
+
required: false
|
|
322
|
+
}),
|
|
323
|
+
alias: Flags.string({
|
|
324
|
+
description: 'alias',
|
|
325
|
+
required: false
|
|
326
|
+
}),
|
|
327
|
+
timezone: Flags.string({
|
|
328
|
+
description: 'timezone',
|
|
329
|
+
required: false
|
|
330
|
+
}),
|
|
331
|
+
firstName: Flags.string({
|
|
332
|
+
description: 'first name',
|
|
333
|
+
required: false
|
|
334
|
+
}),
|
|
335
|
+
lastName: Flags.string({
|
|
336
|
+
description: 'last name',
|
|
337
|
+
required: false
|
|
338
|
+
}),
|
|
339
|
+
country: Flags.string({
|
|
340
|
+
description: 'country',
|
|
341
|
+
required: false
|
|
342
|
+
}),
|
|
343
|
+
fullName: Flags.string({
|
|
344
|
+
description: 'full name',
|
|
345
|
+
required: false
|
|
346
|
+
}),
|
|
347
|
+
enabled: Flags.boolean({
|
|
348
|
+
description: 'User enabled?',
|
|
349
|
+
required: false,
|
|
350
|
+
default: true
|
|
351
|
+
}),
|
|
352
|
+
expired: Flags.boolean({
|
|
353
|
+
description: 'User expired?',
|
|
354
|
+
required: false,
|
|
355
|
+
default: false
|
|
356
|
+
}),
|
|
357
|
+
umask: Flags.integer({
|
|
358
|
+
description: 'User umask',
|
|
359
|
+
required: false,
|
|
360
|
+
default: 18
|
|
361
|
+
}),
|
|
362
|
+
scratchpad: Flags.boolean({
|
|
363
|
+
description: 'Add scratchpad xml',
|
|
364
|
+
required: false,
|
|
365
|
+
default: true
|
|
366
|
+
}),
|
|
367
|
+
};
|
|
368
|
+
static description = "Create, delete and update users";
|
|
369
|
+
static examples = [`$ legispro user:create --name demo --password secret`,];
|
|
297
370
|
}
|
|
298
|
-
|
|
299
|
-
username: core_1.Flags.string({
|
|
300
|
-
description: 'Username to create',
|
|
301
|
-
required: false
|
|
302
|
-
}),
|
|
303
|
-
groups: core_1.Flags.string({
|
|
304
|
-
description: 'Group memberships',
|
|
305
|
-
required: false
|
|
306
|
-
}),
|
|
307
|
-
email: core_1.Flags.string({
|
|
308
|
-
description: 'email',
|
|
309
|
-
required: false
|
|
310
|
-
}),
|
|
311
|
-
language: core_1.Flags.string({
|
|
312
|
-
description: 'language',
|
|
313
|
-
required: false
|
|
314
|
-
}),
|
|
315
|
-
description: core_1.Flags.string({
|
|
316
|
-
description: 'description',
|
|
317
|
-
required: false
|
|
318
|
-
}),
|
|
319
|
-
password: core_1.Flags.string({
|
|
320
|
-
description: 'password',
|
|
321
|
-
required: false
|
|
322
|
-
}),
|
|
323
|
-
primaryGroup: core_1.Flags.string({
|
|
324
|
-
description: 'primary group',
|
|
325
|
-
required: false
|
|
326
|
-
}),
|
|
327
|
-
alias: core_1.Flags.string({
|
|
328
|
-
description: 'alias',
|
|
329
|
-
required: false
|
|
330
|
-
}),
|
|
331
|
-
timezone: core_1.Flags.string({
|
|
332
|
-
description: 'timezone',
|
|
333
|
-
required: false
|
|
334
|
-
}),
|
|
335
|
-
firstName: core_1.Flags.string({
|
|
336
|
-
description: 'first name',
|
|
337
|
-
required: false
|
|
338
|
-
}),
|
|
339
|
-
lastName: core_1.Flags.string({
|
|
340
|
-
description: 'last name',
|
|
341
|
-
required: false
|
|
342
|
-
}),
|
|
343
|
-
country: core_1.Flags.string({
|
|
344
|
-
description: 'country',
|
|
345
|
-
required: false
|
|
346
|
-
}),
|
|
347
|
-
fullName: core_1.Flags.string({
|
|
348
|
-
description: 'full name',
|
|
349
|
-
required: false
|
|
350
|
-
}),
|
|
351
|
-
enabled: core_1.Flags.boolean({
|
|
352
|
-
description: 'User enabled?',
|
|
353
|
-
required: false,
|
|
354
|
-
default: true
|
|
355
|
-
}),
|
|
356
|
-
expired: core_1.Flags.boolean({
|
|
357
|
-
description: 'User expired?',
|
|
358
|
-
required: false,
|
|
359
|
-
default: false
|
|
360
|
-
}),
|
|
361
|
-
umask: core_1.Flags.integer({
|
|
362
|
-
description: 'User umask',
|
|
363
|
-
required: false,
|
|
364
|
-
default: 18
|
|
365
|
-
}),
|
|
366
|
-
scratchpad: core_1.Flags.boolean({
|
|
367
|
-
description: 'Add scratchpad xml',
|
|
368
|
-
required: false,
|
|
369
|
-
default: true
|
|
370
|
-
}),
|
|
371
|
-
};
|
|
372
|
-
UserCreate.description = "Create, delete and update users";
|
|
373
|
-
UserCreate.examples = [`$ legispro user:create --name demo --password secret`,];
|
|
374
|
-
exports.default = UserCreate;
|
|
371
|
+
export default UserCreate;
|
|
@@ -2,7 +2,7 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
declare class UserDelete extends Command {
|
|
3
3
|
run(): Promise<void>;
|
|
4
4
|
static flags: {
|
|
5
|
-
username: import("@oclif/core/
|
|
5
|
+
username: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
6
|
};
|
|
7
7
|
static description: string;
|
|
8
8
|
static examples: string[];
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
|
-
class UserDelete extends core_1.Command {
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { client } from "../../lib/utils.js";
|
|
3
|
+
import enquirer from 'enquirer';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import path from "path";
|
|
6
|
+
class UserDelete extends Command {
|
|
10
7
|
async run() {
|
|
11
|
-
const configFile =
|
|
8
|
+
const configFile = path.join(this.config.configDir, 'config.json');
|
|
12
9
|
const env = require(configFile);
|
|
13
|
-
|
|
10
|
+
client.setConfig(this);
|
|
14
11
|
const { flags } = await this.parse(UserDelete);
|
|
15
12
|
// prompts
|
|
16
13
|
if (!flags.username) {
|
|
17
|
-
const res = await
|
|
14
|
+
const res = await enquirer.prompt([
|
|
18
15
|
{
|
|
19
16
|
type: 'input',
|
|
20
17
|
name: 'username',
|
|
@@ -30,29 +27,29 @@ class UserDelete extends core_1.Command {
|
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
if (flags.username) {
|
|
33
|
-
let delete_user_response = await
|
|
30
|
+
let delete_user_response = await client.deleteUser(flags.username);
|
|
34
31
|
// console.log(delete_user_response);
|
|
35
32
|
if (delete_user_response.status == 204) {
|
|
36
|
-
let delete_user_group_response = await
|
|
37
|
-
let delete_user_collection_response = await
|
|
38
|
-
this.log(`The user ${
|
|
33
|
+
let delete_user_group_response = await client.deleteGroup(flags.username);
|
|
34
|
+
let delete_user_collection_response = await client.deleteCollection(`/db/repository/${flags.username}`);
|
|
35
|
+
this.log(`The user ${chalk.green(flags.username)} has been deleted.`);
|
|
39
36
|
this.exit();
|
|
40
37
|
}
|
|
41
38
|
else {
|
|
42
39
|
// this.log(delete_user_response);
|
|
43
|
-
this.log(`Error deleting ${
|
|
40
|
+
this.log(`Error deleting ${chalk.green(flags.username)}: (${delete_user_response.statusText})`);
|
|
44
41
|
this.exit();
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
}
|
|
45
|
+
static flags = {
|
|
46
|
+
username: Flags.string({
|
|
47
|
+
char: 'u',
|
|
48
|
+
description: 'Username to delete',
|
|
49
|
+
required: false
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
static description = "Delete a user";
|
|
53
|
+
static examples = [`$ legispro user:delete --username demo`,];
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
username: core_1.Flags.string({
|
|
51
|
-
char: 'u',
|
|
52
|
-
description: 'Username to delete',
|
|
53
|
-
required: false
|
|
54
|
-
}),
|
|
55
|
-
};
|
|
56
|
-
UserDelete.description = "Delete a user";
|
|
57
|
-
UserDelete.examples = [`$ legispro user:delete --username demo`,];
|
|
58
|
-
exports.default = UserDelete;
|
|
55
|
+
export default UserDelete;
|
|
@@ -2,7 +2,7 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
declare class UserGet extends Command {
|
|
3
3
|
run(): Promise<void>;
|
|
4
4
|
static flags: {
|
|
5
|
-
username: import("@oclif/core/
|
|
5
|
+
username: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
6
|
};
|
|
7
7
|
static description: string;
|
|
8
8
|
static examples: string[];
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
|
-
class UserGet extends core_1.Command {
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { client } from "../../lib/utils.js";
|
|
3
|
+
import enquirer from 'enquirer';
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import path from "path";
|
|
6
|
+
class UserGet extends Command {
|
|
10
7
|
async run() {
|
|
11
|
-
const configFile =
|
|
8
|
+
const configFile = path.join(this.config.configDir, 'config.json');
|
|
12
9
|
const env = require(configFile);
|
|
13
|
-
|
|
10
|
+
client.setConfig(this);
|
|
14
11
|
const { flags } = await this.parse(UserGet);
|
|
15
12
|
// prompts
|
|
16
13
|
if (!flags.username) {
|
|
17
|
-
const res = await
|
|
14
|
+
const res = await enquirer.prompt([
|
|
18
15
|
{
|
|
19
16
|
type: 'input',
|
|
20
17
|
name: 'username',
|
|
@@ -30,24 +27,24 @@ class UserGet extends core_1.Command {
|
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
if (flags.username) {
|
|
33
|
-
let res = await
|
|
30
|
+
let res = await client.getUser(flags.username);
|
|
34
31
|
if (res.status == 200) {
|
|
35
32
|
this.log(JSON.stringify(res.data, null, 2));
|
|
36
33
|
this.exit();
|
|
37
34
|
}
|
|
38
35
|
else {
|
|
39
|
-
this.log(`${
|
|
36
|
+
this.log(`${chalk.red("Error:")} user ${flags.username} doesn't exist.`);
|
|
40
37
|
this.exit();
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
40
|
}
|
|
41
|
+
static flags = {
|
|
42
|
+
username: Flags.string({
|
|
43
|
+
description: 'Username to fetch',
|
|
44
|
+
required: false
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
static description = "Get user information";
|
|
48
|
+
static examples = [`$ legispro user:get --username demo`,];
|
|
44
49
|
}
|
|
45
|
-
|
|
46
|
-
username: core_1.Flags.string({
|
|
47
|
-
description: 'Username to fetch',
|
|
48
|
-
required: false
|
|
49
|
-
}),
|
|
50
|
-
};
|
|
51
|
-
UserGet.description = "Get user information";
|
|
52
|
-
UserGet.examples = [`$ legispro user:get --username demo`,];
|
|
53
|
-
exports.default = UserGet;
|
|
50
|
+
export default UserGet;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const utils_1 = require("../../lib/utils");
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
class UserList extends core_1.Command {
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { client } from "../../lib/utils.js";
|
|
3
|
+
import path from "path";
|
|
4
|
+
class UserList extends Command {
|
|
8
5
|
async run() {
|
|
9
|
-
const configFile =
|
|
6
|
+
const configFile = path.join(this.config.configDir, 'config.json');
|
|
10
7
|
const env = require(configFile);
|
|
11
|
-
|
|
12
|
-
let names = await
|
|
8
|
+
client.setConfig(this);
|
|
9
|
+
let names = await client.getUsers();
|
|
13
10
|
// const users: User[] = [];
|
|
14
11
|
// for (let name of names) {
|
|
15
12
|
// users.push({userName: name})
|
|
@@ -18,7 +15,7 @@ class UserList extends core_1.Command {
|
|
|
18
15
|
this.log(names);
|
|
19
16
|
this.exit();
|
|
20
17
|
}
|
|
18
|
+
static description = "Get list of all users";
|
|
19
|
+
static examples = [`$ legispro user:list`,];
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
UserList.examples = [`$ legispro user:list`,];
|
|
24
|
-
exports.default = UserList;
|
|
21
|
+
export default UserList;
|
|
@@ -4,8 +4,8 @@ declare class UserLogin extends Command {
|
|
|
4
4
|
getCollection(baseUrl: string, uri: string, headers: any): Promise<unknown>;
|
|
5
5
|
run(): Promise<void>;
|
|
6
6
|
static flags: {
|
|
7
|
-
username: import("@oclif/core/
|
|
8
|
-
password: import("@oclif/core/
|
|
7
|
+
username: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
};
|
|
10
10
|
static description: string;
|
|
11
11
|
static examples: string[];
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
10
|
-
const treeify = require('treeify');
|
|
11
|
-
class UserLogin extends core_1.Command {
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import enquirer from 'enquirer';
|
|
3
|
+
import { client } from "../../lib/utils.js";
|
|
4
|
+
import axios from "axios";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import treeify from 'treeify';
|
|
8
|
+
class UserLogin extends Command {
|
|
12
9
|
get(baseUrl, url, headers) {
|
|
13
|
-
return (
|
|
10
|
+
return axios({
|
|
14
11
|
method: 'GET',
|
|
15
12
|
url: baseUrl + "/exist/restxq/fusiondb" + url,
|
|
16
13
|
headers: headers
|
|
@@ -23,19 +20,19 @@ class UserLogin extends core_1.Command {
|
|
|
23
20
|
}
|
|
24
21
|
catch (error) {
|
|
25
22
|
if (error.response.status !== 200) {
|
|
26
|
-
this.log(`${
|
|
23
|
+
this.log(`${chalk.red("Login failed: bad password.")}`);
|
|
27
24
|
this.exit();
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
28
|
async run() {
|
|
32
|
-
const configFile =
|
|
29
|
+
const configFile = path.join(this.config.configDir, 'config.json');
|
|
33
30
|
const env = require(configFile);
|
|
34
|
-
|
|
31
|
+
client.setConfig(this);
|
|
35
32
|
const { flags } = await this.parse(UserLogin);
|
|
36
33
|
// prompts
|
|
37
34
|
if (!flags.username || !flags.password) {
|
|
38
|
-
const res = await
|
|
35
|
+
const res = await enquirer.prompt([
|
|
39
36
|
{
|
|
40
37
|
type: 'input',
|
|
41
38
|
name: 'username',
|
|
@@ -58,9 +55,9 @@ class UserLogin extends core_1.Command {
|
|
|
58
55
|
}
|
|
59
56
|
if (flags.username && flags.password) {
|
|
60
57
|
// check if user exists first
|
|
61
|
-
let user_exists_response = await
|
|
58
|
+
let user_exists_response = await client.getUser(flags.username);
|
|
62
59
|
if (user_exists_response.data.userName != flags.username) {
|
|
63
|
-
this.log(`${
|
|
60
|
+
this.log(`${chalk.red("Login failed: user doesn't exist.")}`);
|
|
64
61
|
this.exit();
|
|
65
62
|
}
|
|
66
63
|
// login with user credentials and list user collection contents
|
|
@@ -72,22 +69,22 @@ class UserLogin extends core_1.Command {
|
|
|
72
69
|
let user_collection_uri = `/db/repository/${flags.username}`;
|
|
73
70
|
let base_url = env.protocol + "://" + env.hostname + ":" + env.port;
|
|
74
71
|
let response = await this.getCollection(base_url, user_collection_uri, headers);
|
|
75
|
-
this.log(treeify.asTree(response, true));
|
|
76
|
-
this.log(`Login for ${
|
|
72
|
+
this.log(treeify.asTree(response, true, false));
|
|
73
|
+
this.log(`Login for ${chalk.green(flags.username)} succeeded.`);
|
|
77
74
|
this.exit();
|
|
78
75
|
}
|
|
79
76
|
}
|
|
77
|
+
static flags = {
|
|
78
|
+
username: Flags.string({
|
|
79
|
+
description: 'Username to create',
|
|
80
|
+
required: false
|
|
81
|
+
}),
|
|
82
|
+
password: Flags.string({
|
|
83
|
+
description: 'password',
|
|
84
|
+
required: false
|
|
85
|
+
}),
|
|
86
|
+
};
|
|
87
|
+
static description = "Test a user login";
|
|
88
|
+
static examples = [`$ legispro user:login --username=demo --password=secret`,];
|
|
80
89
|
}
|
|
81
|
-
|
|
82
|
-
username: core_1.Flags.string({
|
|
83
|
-
description: 'Username to create',
|
|
84
|
-
required: false
|
|
85
|
-
}),
|
|
86
|
-
password: core_1.Flags.string({
|
|
87
|
-
description: 'password',
|
|
88
|
-
required: false
|
|
89
|
-
}),
|
|
90
|
-
};
|
|
91
|
-
UserLogin.description = "Test a user login";
|
|
92
|
-
UserLogin.examples = [`$ legispro user:login --username=demo --password=secret`,];
|
|
93
|
-
exports.default = UserLogin;
|
|
90
|
+
export default UserLogin;
|
|
@@ -2,22 +2,22 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
declare class UserUpdate extends Command {
|
|
3
3
|
run(): Promise<void>;
|
|
4
4
|
static flags: {
|
|
5
|
-
username: import("@oclif/core/
|
|
6
|
-
groups: import("@oclif/core/
|
|
7
|
-
email: import("@oclif/core/
|
|
8
|
-
language: import("@oclif/core/
|
|
9
|
-
description: import("@oclif/core/
|
|
10
|
-
password: import("@oclif/core/
|
|
11
|
-
primaryGroup: import("@oclif/core/
|
|
12
|
-
alias: import("@oclif/core/
|
|
13
|
-
timezone: import("@oclif/core/
|
|
14
|
-
firstName: import("@oclif/core/
|
|
15
|
-
lastName: import("@oclif/core/
|
|
16
|
-
country: import("@oclif/core/
|
|
17
|
-
fullName: import("@oclif/core/
|
|
18
|
-
enabled: import("@oclif/core/
|
|
19
|
-
expired: import("@oclif/core/
|
|
20
|
-
umask: import("@oclif/core/
|
|
5
|
+
username: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
groups: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
email: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
language: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
primaryGroup: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
timezone: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
firstName: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
lastName: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
country: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
fullName: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
enabled: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
expired: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
umask: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
21
|
};
|
|
22
22
|
static description: string;
|
|
23
23
|
static examples: string[];
|