legispro-cli 1.0.7 → 1.0.8
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/LICENSE +21 -21
- package/README.md +45 -17
- package/bin/dev.cmd +3 -3
- package/bin/dev.js +5 -0
- package/bin/run.cmd +3 -3
- 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 +46 -49
- 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 +126 -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 +68 -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 +61 -65
- package/oclif.manifest.json +958 -520
- package/package.json +102 -98
- 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 rclone = require("rclone.js").promises;
|
|
10
|
-
const fs = require('fs');
|
|
11
|
-
class CollectionDownload 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
|
+
import rclone from "rclone.js";
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
class CollectionDownload 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(CollectionDownload);
|
|
17
14
|
// prompts
|
|
18
15
|
if (Object.keys(flags).length == 0) {
|
|
19
|
-
const res = await
|
|
16
|
+
const res = await enquirer.prompt([
|
|
20
17
|
{
|
|
21
18
|
type: 'input',
|
|
22
19
|
name: 'name',
|
|
@@ -40,9 +37,9 @@ class CollectionDownload extends core_1.Command {
|
|
|
40
37
|
if (flags.name && flags.dest) {
|
|
41
38
|
let collection_uri = '/db/repository/' + flags.name;
|
|
42
39
|
// check if collection exists
|
|
43
|
-
let exists = await
|
|
40
|
+
let exists = await client.existsCollection(collection_uri);
|
|
44
41
|
if (!exists) {
|
|
45
|
-
this.log(`Collection: ${
|
|
42
|
+
this.log(`Collection: ${chalk.magenta(flags.name)} not found.`);
|
|
46
43
|
this.exit();
|
|
47
44
|
}
|
|
48
45
|
// check if local folder exists
|
|
@@ -53,10 +50,10 @@ class CollectionDownload extends core_1.Command {
|
|
|
53
50
|
process.exit();
|
|
54
51
|
}
|
|
55
52
|
});
|
|
56
|
-
let obscured_password = (await rclone.obscure(env.password)).toString().trim();
|
|
53
|
+
let obscured_password = (await rclone.promises.obscure(env.password)).toString().trim();
|
|
57
54
|
let copy_response;
|
|
58
55
|
try {
|
|
59
|
-
copy_response = await rclone.copy(":webdav:" + collection_uri, flags.dest, {
|
|
56
|
+
copy_response = await rclone.promises.copy(":webdav:" + collection_uri, flags.dest, {
|
|
60
57
|
"webdav-url": env.protocol + "://" + env.hostname + ":" + env.port + "/exist/webdav/",
|
|
61
58
|
"webdav-user": env.user,
|
|
62
59
|
"webdav-pass": obscured_password
|
|
@@ -71,17 +68,17 @@ class CollectionDownload extends core_1.Command {
|
|
|
71
68
|
this.exit();
|
|
72
69
|
}
|
|
73
70
|
}
|
|
71
|
+
static flags = {
|
|
72
|
+
name: Flags.string({
|
|
73
|
+
description: 'Name',
|
|
74
|
+
required: false
|
|
75
|
+
}),
|
|
76
|
+
dest: Flags.string({
|
|
77
|
+
description: 'Destination folder',
|
|
78
|
+
required: false
|
|
79
|
+
}),
|
|
80
|
+
};
|
|
81
|
+
static description = "Download files from collection";
|
|
82
|
+
static examples = [`$ legispro collection:download`,];
|
|
74
83
|
}
|
|
75
|
-
|
|
76
|
-
name: core_1.Flags.string({
|
|
77
|
-
description: 'Name',
|
|
78
|
-
required: false
|
|
79
|
-
}),
|
|
80
|
-
dest: core_1.Flags.string({
|
|
81
|
-
description: 'Destination folder',
|
|
82
|
-
required: false
|
|
83
|
-
}),
|
|
84
|
-
};
|
|
85
|
-
CollectionDownload.description = "Download files from collection";
|
|
86
|
-
CollectionDownload.examples = [`$ legispro collection:download`,];
|
|
87
|
-
exports.default = CollectionDownload;
|
|
84
|
+
export default CollectionDownload;
|
|
@@ -2,7 +2,7 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
declare class CollectionGet extends Command {
|
|
3
3
|
run(): Promise<void>;
|
|
4
4
|
static flags: {
|
|
5
|
-
name: import("@oclif/core/
|
|
5
|
+
name: 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,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const treeify = require('treeify');
|
|
8
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
9
|
-
class CollectionGet 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 treeify from 'treeify';
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
class CollectionGet extends Command {
|
|
10
7
|
async run() {
|
|
11
|
-
|
|
8
|
+
client.setConfig(this);
|
|
12
9
|
const { flags } = await this.parse(CollectionGet);
|
|
13
10
|
// prompts
|
|
14
11
|
if (Object.keys(flags).length == 0) {
|
|
15
|
-
const res = await
|
|
12
|
+
const res = await enquirer.prompt([
|
|
16
13
|
{
|
|
17
14
|
type: 'input',
|
|
18
15
|
name: 'name',
|
|
@@ -30,25 +27,25 @@ class CollectionGet extends core_1.Command {
|
|
|
30
27
|
if (flags.name) {
|
|
31
28
|
let collection_uri = '/db/repository/' + flags.name;
|
|
32
29
|
// check if collection exists
|
|
33
|
-
let exists = await
|
|
30
|
+
let exists = await client.existsCollection(collection_uri);
|
|
34
31
|
if (!exists) {
|
|
35
|
-
this.log(`Collection: ${
|
|
32
|
+
this.log(`Collection: ${chalk.magenta(flags.name)} not found.`);
|
|
36
33
|
this.exit();
|
|
37
34
|
}
|
|
38
|
-
let list_response = await
|
|
35
|
+
let list_response = await client.getCollection(collection_uri);
|
|
39
36
|
//if (list_response.status == 200) {
|
|
40
|
-
this.log(treeify.asTree(list_response, true));
|
|
37
|
+
this.log(treeify.asTree(list_response, true, false));
|
|
41
38
|
this.exit();
|
|
42
39
|
//}
|
|
43
40
|
}
|
|
44
41
|
}
|
|
42
|
+
static flags = {
|
|
43
|
+
name: Flags.string({
|
|
44
|
+
description: 'Name',
|
|
45
|
+
required: false
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
static description = "Get collection info & contents";
|
|
49
|
+
static examples = [`$ legispro collection:get`,];
|
|
45
50
|
}
|
|
46
|
-
|
|
47
|
-
name: core_1.Flags.string({
|
|
48
|
-
description: 'Name',
|
|
49
|
-
required: false
|
|
50
|
-
}),
|
|
51
|
-
};
|
|
52
|
-
CollectionGet.description = "Get collection info & contents";
|
|
53
|
-
CollectionGet.examples = [`$ legispro collection:get`,];
|
|
54
|
-
exports.default = CollectionGet;
|
|
51
|
+
export default CollectionGet;
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const treeify = require('treeify');
|
|
7
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
-
class CollectionList extends core_1.Command {
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { client } from "../../lib/utils.js";
|
|
3
|
+
import treeify from 'treeify';
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
class CollectionList extends Command {
|
|
9
6
|
async run() {
|
|
10
|
-
|
|
7
|
+
client.setConfig(this);
|
|
11
8
|
let collection_uri = '/db/repository';
|
|
12
9
|
// check if collection exists
|
|
13
|
-
let exists = await
|
|
10
|
+
let exists = await client.existsCollection(collection_uri);
|
|
14
11
|
if (!exists) {
|
|
15
|
-
this.log(`Collection: ${
|
|
12
|
+
this.log(`Collection: ${chalk.magenta("repository")} not found.`);
|
|
16
13
|
this.exit();
|
|
17
14
|
}
|
|
18
|
-
let list_response = await
|
|
19
|
-
this.log(treeify.asTree(list_response, true));
|
|
15
|
+
let list_response = await client.getCollection(collection_uri);
|
|
16
|
+
this.log(treeify.asTree(list_response, true, false));
|
|
20
17
|
this.exit();
|
|
21
18
|
}
|
|
19
|
+
static description = "List collections";
|
|
20
|
+
static examples = [`$ legispro collection:list`,];
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
CollectionList.examples = [`$ legispro collection:list`,];
|
|
25
|
-
exports.default = CollectionList;
|
|
22
|
+
export default CollectionList;
|
|
@@ -2,9 +2,9 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
declare class CollectionPerms extends Command {
|
|
3
3
|
run(): Promise<void>;
|
|
4
4
|
static flags: {
|
|
5
|
-
name: import("@oclif/core/
|
|
6
|
-
source: import("@oclif/core/
|
|
7
|
-
type: import("@oclif/core/
|
|
5
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
source: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
};
|
|
9
9
|
static description: string;
|
|
10
10
|
static examples: string[];
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const enquirer_1 = require("enquirer");
|
|
7
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
-
class CollectionPerms 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
|
+
class CollectionPerms extends Command {
|
|
9
6
|
async run() {
|
|
10
|
-
|
|
7
|
+
client.setConfig(this);
|
|
11
8
|
const { flags } = await this.parse(CollectionPerms);
|
|
12
9
|
// prompts
|
|
13
10
|
if (Object.keys(flags).length == 0) {
|
|
14
|
-
const res = await
|
|
11
|
+
const res = await enquirer.prompt([
|
|
15
12
|
{
|
|
16
13
|
type: 'input',
|
|
17
14
|
name: 'name',
|
|
@@ -36,22 +33,22 @@ class CollectionPerms extends core_1.Command {
|
|
|
36
33
|
if (flags.name && flags.type) {
|
|
37
34
|
let collection_uri = '/db/repository/' + flags.name;
|
|
38
35
|
// check if collection exists
|
|
39
|
-
let exists = await
|
|
36
|
+
let exists = await client.existsCollection(collection_uri);
|
|
40
37
|
if (!exists) {
|
|
41
|
-
this.log(`Collection: ${
|
|
38
|
+
this.log(`Collection: ${chalk.magenta(flags.name)} not found.`);
|
|
42
39
|
this.exit();
|
|
43
40
|
}
|
|
44
41
|
// update collection modes and owners based on type
|
|
45
42
|
let update_perms_response = {};
|
|
46
43
|
if (flags.type == 'user') {
|
|
47
|
-
update_perms_response = await
|
|
44
|
+
update_perms_response = await client.updateUserCollectionPerms(flags.name);
|
|
48
45
|
this.log(update_perms_response);
|
|
49
46
|
}
|
|
50
47
|
if (flags.type == 'shared') {
|
|
51
|
-
update_perms_response = await
|
|
48
|
+
update_perms_response = await client.updateSharedCollectionPerms(flags.name);
|
|
52
49
|
}
|
|
53
50
|
if (flags.type == 'library') {
|
|
54
|
-
update_perms_response = await
|
|
51
|
+
update_perms_response = await client.updateLibraryCollectionPerms(flags.name);
|
|
55
52
|
}
|
|
56
53
|
if (update_perms_response.status == 200) {
|
|
57
54
|
this.log("Collection permissions complete.");
|
|
@@ -62,21 +59,21 @@ class CollectionPerms extends core_1.Command {
|
|
|
62
59
|
this.exit();
|
|
63
60
|
}
|
|
64
61
|
}
|
|
62
|
+
static flags = {
|
|
63
|
+
name: Flags.string({
|
|
64
|
+
description: 'Collection name',
|
|
65
|
+
required: false
|
|
66
|
+
}),
|
|
67
|
+
source: Flags.string({
|
|
68
|
+
description: 'Source folder',
|
|
69
|
+
required: false
|
|
70
|
+
}),
|
|
71
|
+
type: Flags.string({
|
|
72
|
+
description: 'Collection type',
|
|
73
|
+
required: false
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
static description = "Update file permissions for a collection.";
|
|
77
|
+
static examples = [`$ legispro collection:perms`,];
|
|
65
78
|
}
|
|
66
|
-
|
|
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;
|
|
79
|
+
export default CollectionPerms;
|
|
@@ -2,13 +2,13 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
declare class CollectionUpdate extends Command {
|
|
3
3
|
run(): Promise<void>;
|
|
4
4
|
static flags: {
|
|
5
|
-
name: import("@oclif/core/
|
|
6
|
-
title: import("@oclif/core/
|
|
7
|
-
baseURI: import("@oclif/core/
|
|
8
|
-
defaultExt: import("@oclif/core/
|
|
9
|
-
type: import("@oclif/core/
|
|
10
|
-
owner: import("@oclif/core/
|
|
11
|
-
group: import("@oclif/core/
|
|
5
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
title: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
baseURI: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
defaultExt: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
owner: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
group: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
};
|
|
13
13
|
static description: string;
|
|
14
14
|
static examples: string[];
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 {
|
|
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 CollectionUpdate extends Command {
|
|
11
7
|
async run() {
|
|
12
|
-
const configFile =
|
|
8
|
+
const configFile = path.join(this.config.configDir, 'config.json');
|
|
13
9
|
const env = require(configFile);
|
|
14
|
-
|
|
10
|
+
client.setConfig(this);
|
|
15
11
|
const { flags } = await this.parse(CollectionUpdate);
|
|
16
12
|
// get existing collection properties
|
|
17
13
|
let projectObject = {};
|
|
18
14
|
let collectionObject = {};
|
|
19
15
|
let collection_uri = '';
|
|
20
16
|
if (Object.keys(flags).length == 0) {
|
|
21
|
-
const answers1 = await
|
|
17
|
+
const answers1 = await enquirer.prompt([
|
|
22
18
|
{
|
|
23
19
|
type: 'input',
|
|
24
20
|
name: 'name',
|
|
@@ -30,21 +26,21 @@ class CollectionUpdate extends core_1.Command {
|
|
|
30
26
|
// @ts-ignore
|
|
31
27
|
flags['name'] = answers1['name'];
|
|
32
28
|
collection_uri = '/db/repository/' + flags.name;
|
|
33
|
-
let collection_exists = await
|
|
29
|
+
let collection_exists = await client.existsCollection(collection_uri);
|
|
34
30
|
if (!collection_exists) {
|
|
35
|
-
this.log(`${
|
|
31
|
+
this.log(`${chalk.red("Error")} : collection ${flags.name} not found`);
|
|
36
32
|
this.exit();
|
|
37
33
|
}
|
|
38
|
-
projectObject = await
|
|
34
|
+
projectObject = await client.getCollectionProject(collection_uri);
|
|
39
35
|
this.log(projectObject);
|
|
40
36
|
if (projectObject == null) {
|
|
41
|
-
this.log(`${
|
|
37
|
+
this.log(`${chalk.red("Error")} : no .project.xml file found in ${flags.name}`);
|
|
42
38
|
this.exit();
|
|
43
39
|
}
|
|
44
|
-
collectionObject = await
|
|
40
|
+
collectionObject = await client.getCollectionObject(collection_uri);
|
|
45
41
|
this.log(collectionObject);
|
|
46
42
|
}
|
|
47
|
-
const answers2 = await
|
|
43
|
+
const answers2 = await enquirer.prompt([
|
|
48
44
|
{
|
|
49
45
|
type: 'input',
|
|
50
46
|
name: 'title',
|
|
@@ -125,10 +121,10 @@ class CollectionUpdate extends core_1.Command {
|
|
|
125
121
|
};
|
|
126
122
|
// @ts-ignore
|
|
127
123
|
this.log(collection);
|
|
128
|
-
let modify_response = await
|
|
124
|
+
let modify_response = await client.modifyCollection(collection);
|
|
129
125
|
// this.log(modify_response);
|
|
130
126
|
this.exit();
|
|
131
|
-
let list_response = await
|
|
127
|
+
let list_response = await client.getCollection(collection.uri);
|
|
132
128
|
// this.log(treeify.asTree(list_response, true));
|
|
133
129
|
if (list_response.status == 200) {
|
|
134
130
|
this.log(`Collection: ${flags.name} updated`);
|
|
@@ -138,37 +134,37 @@ class CollectionUpdate extends core_1.Command {
|
|
|
138
134
|
}
|
|
139
135
|
this.exit();
|
|
140
136
|
}
|
|
137
|
+
static flags = {
|
|
138
|
+
name: Flags.string({
|
|
139
|
+
description: 'Name',
|
|
140
|
+
required: false
|
|
141
|
+
}),
|
|
142
|
+
title: Flags.string({
|
|
143
|
+
description: 'Title',
|
|
144
|
+
required: false
|
|
145
|
+
}),
|
|
146
|
+
baseURI: Flags.string({
|
|
147
|
+
description: 'Base URI',
|
|
148
|
+
required: false
|
|
149
|
+
}),
|
|
150
|
+
defaultExt: Flags.string({
|
|
151
|
+
description: 'Default extension',
|
|
152
|
+
required: false
|
|
153
|
+
}),
|
|
154
|
+
type: Flags.string({
|
|
155
|
+
description: 'Collection type',
|
|
156
|
+
required: false
|
|
157
|
+
}),
|
|
158
|
+
owner: Flags.string({
|
|
159
|
+
description: 'Collection owner',
|
|
160
|
+
required: false
|
|
161
|
+
}),
|
|
162
|
+
group: Flags.string({
|
|
163
|
+
description: 'Collection group',
|
|
164
|
+
required: false
|
|
165
|
+
}),
|
|
166
|
+
};
|
|
167
|
+
static description = "Update a collection";
|
|
168
|
+
static examples = [`$ legispro collection:update`,];
|
|
141
169
|
}
|
|
142
|
-
|
|
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;
|
|
170
|
+
export default CollectionUpdate;
|
|
@@ -2,9 +2,9 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
declare class CollectionUpload extends Command {
|
|
3
3
|
run(): Promise<void>;
|
|
4
4
|
static flags: {
|
|
5
|
-
name: import("@oclif/core/
|
|
6
|
-
source: import("@oclif/core/
|
|
7
|
-
type: import("@oclif/core/
|
|
5
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
source: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
};
|
|
9
9
|
static description: string;
|
|
10
10
|
static examples: string[];
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const rclone = require("rclone.js").promises;
|
|
11
|
-
const fs = require('fs');
|
|
12
|
-
class CollectionUpload 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
|
+
import ora from "ora";
|
|
7
|
+
import rclone from "rclone.js";
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
class CollectionUpload extends Command {
|
|
13
10
|
async run() {
|
|
14
|
-
const configFile =
|
|
11
|
+
const configFile = path.join(this.config.configDir, 'config.json');
|
|
15
12
|
const env = require(configFile);
|
|
16
|
-
|
|
13
|
+
client.setConfig(this);
|
|
17
14
|
const { flags } = await this.parse(CollectionUpload);
|
|
18
15
|
// prompts
|
|
19
16
|
if (Object.keys(flags).length == 0) {
|
|
20
|
-
const res = await
|
|
17
|
+
const res = await enquirer.prompt([
|
|
21
18
|
{
|
|
22
19
|
type: 'input',
|
|
23
20
|
name: 'name',
|
|
@@ -48,9 +45,9 @@ class CollectionUpload extends core_1.Command {
|
|
|
48
45
|
if (flags.name && flags.source) {
|
|
49
46
|
let collection_uri = '/db/repository/' + flags.name;
|
|
50
47
|
// check if collection exists
|
|
51
|
-
let exists = await
|
|
48
|
+
let exists = await client.existsCollection(collection_uri);
|
|
52
49
|
if (!exists) {
|
|
53
|
-
this.log(`Collection: ${
|
|
50
|
+
this.log(`Collection: ${chalk.magenta(flags.name)} not found.`);
|
|
54
51
|
this.exit();
|
|
55
52
|
}
|
|
56
53
|
// check if local folder exists
|
|
@@ -61,13 +58,13 @@ class CollectionUpload extends core_1.Command {
|
|
|
61
58
|
process.exit();
|
|
62
59
|
}
|
|
63
60
|
});
|
|
64
|
-
const Spinner = (
|
|
65
|
-
text: `${
|
|
61
|
+
const Spinner = ora({
|
|
62
|
+
text: `${chalk.bold(chalk.blue('Uploading files...'))}`
|
|
66
63
|
}).start();
|
|
67
|
-
let obscured_password = (await rclone.obscure(env.password)).toString().trim();
|
|
64
|
+
let obscured_password = (await rclone.promises.obscure(env.password)).toString().trim();
|
|
68
65
|
let copy_response;
|
|
69
66
|
try {
|
|
70
|
-
copy_response = await rclone.copy(flags.source, ":webdav:" + collection_uri, {
|
|
67
|
+
copy_response = await rclone.promises.copy(flags.source, ":webdav:" + collection_uri, {
|
|
71
68
|
"webdav-url": env.protocol + "://" + env.hostname + ":" + env.port + "/exist/webdav/",
|
|
72
69
|
"webdav-user": env.user,
|
|
73
70
|
"webdav-pass": obscured_password,
|
|
@@ -85,20 +82,20 @@ class CollectionUpload extends core_1.Command {
|
|
|
85
82
|
// update collection modes and owners based on type
|
|
86
83
|
let update_perms_response = {};
|
|
87
84
|
if (flags.type == 'user') {
|
|
88
|
-
update_perms_response = await
|
|
85
|
+
update_perms_response = await client.updateUserCollectionPerms(flags.name);
|
|
89
86
|
this.log(update_perms_response);
|
|
90
87
|
}
|
|
91
88
|
if (flags.type == 'shared') {
|
|
92
|
-
update_perms_response = await
|
|
89
|
+
update_perms_response = await client.updateSharedCollectionPerms(flags.name);
|
|
93
90
|
}
|
|
94
91
|
if (flags.type == 'library') {
|
|
95
|
-
update_perms_response = await
|
|
92
|
+
update_perms_response = await client.updateLibraryCollectionPerms(flags.name);
|
|
96
93
|
}
|
|
97
94
|
let response_buffer = copy_response;
|
|
98
95
|
//console.log(response_buffer.toJSON());
|
|
99
96
|
Spinner.stopAndPersist({
|
|
100
97
|
symbol: "✨",
|
|
101
|
-
text: `${
|
|
98
|
+
text: `${chalk.bold(chalk.green('File upload complete'))}`
|
|
102
99
|
});
|
|
103
100
|
// success or failure?
|
|
104
101
|
if (update_perms_response.status != 200) {
|
|
@@ -107,21 +104,21 @@ class CollectionUpload extends core_1.Command {
|
|
|
107
104
|
this.exit();
|
|
108
105
|
}
|
|
109
106
|
}
|
|
107
|
+
static flags = {
|
|
108
|
+
name: Flags.string({
|
|
109
|
+
description: 'Collection name',
|
|
110
|
+
required: false
|
|
111
|
+
}),
|
|
112
|
+
source: Flags.string({
|
|
113
|
+
description: 'Source folder',
|
|
114
|
+
required: false
|
|
115
|
+
}),
|
|
116
|
+
type: Flags.string({
|
|
117
|
+
description: 'Collection type',
|
|
118
|
+
required: false
|
|
119
|
+
}),
|
|
120
|
+
};
|
|
121
|
+
static description = "Upload files to collection";
|
|
122
|
+
static examples = [`$ legispro collection:upload`,];
|
|
110
123
|
}
|
|
111
|
-
|
|
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;
|
|
124
|
+
export default CollectionUpload;
|