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,21 +1,18 @@
|
|
|
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 UserUpdate 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 UserUpdate 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(UserUpdate);
|
|
15
12
|
let userObject = { userName: "empty" };
|
|
16
13
|
// prompts
|
|
17
14
|
if (!flags.username) {
|
|
18
|
-
const name_answer = await
|
|
15
|
+
const name_answer = await enquirer.prompt([
|
|
19
16
|
{
|
|
20
17
|
type: 'input',
|
|
21
18
|
name: 'username',
|
|
@@ -26,18 +23,18 @@ class UserUpdate extends core_1.Command {
|
|
|
26
23
|
// @ts-ignore
|
|
27
24
|
flags.username = name_answer['username'];
|
|
28
25
|
// load user info
|
|
29
|
-
let user_object_response = await
|
|
26
|
+
let user_object_response = await client.getUser(flags.username);
|
|
30
27
|
if (user_object_response.status == 200) {
|
|
31
28
|
userObject = user_object_response.data;
|
|
32
29
|
}
|
|
33
30
|
else {
|
|
34
|
-
this.log(`${
|
|
31
|
+
this.log(`${chalk.red("Error:")} user ${flags.username} doesn't exist.`);
|
|
35
32
|
this.exit();
|
|
36
33
|
}
|
|
37
|
-
let test =
|
|
34
|
+
let test = client.getMeta(userObject.metadata, "lastName");
|
|
38
35
|
// console.log("last name: " + test);
|
|
39
36
|
//this.exit();
|
|
40
|
-
const res = await
|
|
37
|
+
const res = await enquirer.prompt([
|
|
41
38
|
{
|
|
42
39
|
type: 'password',
|
|
43
40
|
name: 'password',
|
|
@@ -78,8 +75,8 @@ class UserUpdate extends core_1.Command {
|
|
|
78
75
|
type: 'input',
|
|
79
76
|
name: 'firstName',
|
|
80
77
|
message: 'First name',
|
|
81
|
-
initial: (typeof
|
|
82
|
-
|
|
78
|
+
initial: (typeof client.getMeta(userObject.metadata, "firstName") !== null) ?
|
|
79
|
+
client.getMeta(userObject.metadata, "firstName") : '',
|
|
83
80
|
required: false,
|
|
84
81
|
skip: false
|
|
85
82
|
},
|
|
@@ -87,8 +84,8 @@ class UserUpdate extends core_1.Command {
|
|
|
87
84
|
type: 'input',
|
|
88
85
|
name: 'lastName',
|
|
89
86
|
message: 'Last name',
|
|
90
|
-
initial: (typeof
|
|
91
|
-
|
|
87
|
+
initial: (typeof client.getMeta(userObject.metadata, "lastName") !== null) ?
|
|
88
|
+
client.getMeta(userObject.metadata, "lastName") : '',
|
|
92
89
|
required: false,
|
|
93
90
|
skip: false
|
|
94
91
|
},
|
|
@@ -96,8 +93,8 @@ class UserUpdate extends core_1.Command {
|
|
|
96
93
|
type: 'input',
|
|
97
94
|
name: 'fullName',
|
|
98
95
|
message: 'Full name',
|
|
99
|
-
initial: (typeof
|
|
100
|
-
|
|
96
|
+
initial: (typeof client.getMeta(userObject.metadata, "fullName") !== null) ?
|
|
97
|
+
client.getMeta(userObject.metadata, "fullName") : '',
|
|
101
98
|
required: false,
|
|
102
99
|
skip: false
|
|
103
100
|
},
|
|
@@ -105,8 +102,8 @@ class UserUpdate extends core_1.Command {
|
|
|
105
102
|
type: 'input',
|
|
106
103
|
name: 'alias',
|
|
107
104
|
message: 'Alias',
|
|
108
|
-
initial: (typeof
|
|
109
|
-
|
|
105
|
+
initial: (typeof client.getMeta(userObject.metadata, "alias") !== null) ?
|
|
106
|
+
client.getMeta(userObject.metadata, "alias") : '',
|
|
110
107
|
required: false,
|
|
111
108
|
skip: false
|
|
112
109
|
},
|
|
@@ -114,8 +111,8 @@ class UserUpdate extends core_1.Command {
|
|
|
114
111
|
type: 'input',
|
|
115
112
|
name: 'email',
|
|
116
113
|
message: 'Email',
|
|
117
|
-
initial: (typeof
|
|
118
|
-
|
|
114
|
+
initial: (typeof client.getMeta(userObject.metadata, "email") !== null) ?
|
|
115
|
+
client.getMeta(userObject.metadata, "email") : '',
|
|
119
116
|
required: false,
|
|
120
117
|
skip: false
|
|
121
118
|
},
|
|
@@ -123,8 +120,8 @@ class UserUpdate extends core_1.Command {
|
|
|
123
120
|
type: 'input',
|
|
124
121
|
name: 'country',
|
|
125
122
|
message: 'Country',
|
|
126
|
-
initial: (typeof
|
|
127
|
-
|
|
123
|
+
initial: (typeof client.getMeta(userObject.metadata, "country") !== null) ?
|
|
124
|
+
client.getMeta(userObject.metadata, "country") : '',
|
|
128
125
|
required: false,
|
|
129
126
|
skip: false
|
|
130
127
|
},
|
|
@@ -132,8 +129,8 @@ class UserUpdate extends core_1.Command {
|
|
|
132
129
|
type: 'input',
|
|
133
130
|
name: 'language',
|
|
134
131
|
message: 'Language',
|
|
135
|
-
initial: (typeof
|
|
136
|
-
|
|
132
|
+
initial: (typeof client.getMeta(userObject.metadata, "language") !== null) ?
|
|
133
|
+
client.getMeta(userObject.metadata, "language") : '',
|
|
137
134
|
required: false,
|
|
138
135
|
skip: false
|
|
139
136
|
},
|
|
@@ -141,8 +138,8 @@ class UserUpdate extends core_1.Command {
|
|
|
141
138
|
type: 'input',
|
|
142
139
|
name: 'timezone',
|
|
143
140
|
message: 'Timezone',
|
|
144
|
-
initial: (typeof
|
|
145
|
-
|
|
141
|
+
initial: (typeof client.getMeta(userObject.metadata, "timezone") !== null) ?
|
|
142
|
+
client.getMeta(userObject.metadata, "timezone") : '',
|
|
146
143
|
required: false,
|
|
147
144
|
skip: false
|
|
148
145
|
},
|
|
@@ -150,8 +147,8 @@ class UserUpdate extends core_1.Command {
|
|
|
150
147
|
type: 'input',
|
|
151
148
|
name: 'description',
|
|
152
149
|
message: 'Description',
|
|
153
|
-
initial: (typeof
|
|
154
|
-
|
|
150
|
+
initial: (typeof client.getMeta(userObject.metadata, "description") !== null) ?
|
|
151
|
+
client.getMeta(userObject.metadata, "description") : '',
|
|
155
152
|
required: false,
|
|
156
153
|
skip: false
|
|
157
154
|
},
|
|
@@ -168,7 +165,7 @@ class UserUpdate extends core_1.Command {
|
|
|
168
165
|
userName: flags.username,
|
|
169
166
|
primaryGroup: (typeof flags.primaryGroup !== "undefined") ? flags.primaryGroup : env.group,
|
|
170
167
|
groups: (typeof flags.groups !== "undefined") ? `${flags.groups}`.split(",") : ['users', flags.username, env.group],
|
|
171
|
-
metadata:
|
|
168
|
+
metadata: client.setMeta(flags),
|
|
172
169
|
expired: (typeof flags.expired !== "undefined") ? flags.expired : false,
|
|
173
170
|
enabled: (typeof flags.enabled !== "undefined") ? flags.enabled : true,
|
|
174
171
|
umask: (typeof flags.umask !== "undefined") ? flags.umask : 18
|
|
@@ -180,88 +177,88 @@ class UserUpdate extends core_1.Command {
|
|
|
180
177
|
user.password = new RIPEMD160().update(flags.password).digest('base64');
|
|
181
178
|
}
|
|
182
179
|
// todo: create new groups if they don't exist
|
|
183
|
-
let update_user_response = await
|
|
184
|
-
let display_user_response = await
|
|
180
|
+
let update_user_response = await client.createUser(user);
|
|
181
|
+
let display_user_response = await client.getUser(flags.username);
|
|
185
182
|
if (display_user_response.status == 200) {
|
|
186
183
|
// this.log(JSON.stringify(display_user_response.data, null, 2));
|
|
187
|
-
this.log(`User ${
|
|
184
|
+
this.log(`User ${chalk.magenta(flags.username)} updated.`);
|
|
188
185
|
}
|
|
189
186
|
else {
|
|
190
|
-
this.log(`${
|
|
187
|
+
this.log(`${chalk.red("Error:")} user ${flags.username} doesn't exist.`);
|
|
191
188
|
}
|
|
192
189
|
this.exit();
|
|
193
190
|
}
|
|
194
191
|
}
|
|
192
|
+
static flags = {
|
|
193
|
+
username: Flags.string({
|
|
194
|
+
description: 'Username to create',
|
|
195
|
+
required: false
|
|
196
|
+
}),
|
|
197
|
+
groups: Flags.string({
|
|
198
|
+
description: 'Group memberships',
|
|
199
|
+
required: false
|
|
200
|
+
}),
|
|
201
|
+
email: Flags.string({
|
|
202
|
+
description: 'email',
|
|
203
|
+
required: false
|
|
204
|
+
}),
|
|
205
|
+
language: Flags.string({
|
|
206
|
+
description: 'language',
|
|
207
|
+
required: false
|
|
208
|
+
}),
|
|
209
|
+
description: Flags.string({
|
|
210
|
+
description: 'description',
|
|
211
|
+
required: false
|
|
212
|
+
}),
|
|
213
|
+
password: Flags.string({
|
|
214
|
+
description: 'password',
|
|
215
|
+
required: false
|
|
216
|
+
}),
|
|
217
|
+
primaryGroup: Flags.string({
|
|
218
|
+
description: 'primary group',
|
|
219
|
+
required: false
|
|
220
|
+
}),
|
|
221
|
+
alias: Flags.string({
|
|
222
|
+
description: 'alias',
|
|
223
|
+
required: false
|
|
224
|
+
}),
|
|
225
|
+
timezone: Flags.string({
|
|
226
|
+
description: 'timezone',
|
|
227
|
+
required: false
|
|
228
|
+
}),
|
|
229
|
+
firstName: Flags.string({
|
|
230
|
+
description: 'first name',
|
|
231
|
+
required: false
|
|
232
|
+
}),
|
|
233
|
+
lastName: Flags.string({
|
|
234
|
+
description: 'last name',
|
|
235
|
+
required: false
|
|
236
|
+
}),
|
|
237
|
+
country: Flags.string({
|
|
238
|
+
description: 'country',
|
|
239
|
+
required: false
|
|
240
|
+
}),
|
|
241
|
+
fullName: Flags.string({
|
|
242
|
+
description: 'full name',
|
|
243
|
+
required: false
|
|
244
|
+
}),
|
|
245
|
+
enabled: Flags.boolean({
|
|
246
|
+
description: 'User enabled?',
|
|
247
|
+
required: false,
|
|
248
|
+
default: true
|
|
249
|
+
}),
|
|
250
|
+
expired: Flags.boolean({
|
|
251
|
+
description: 'User expired?',
|
|
252
|
+
required: false,
|
|
253
|
+
default: false
|
|
254
|
+
}),
|
|
255
|
+
umask: Flags.integer({
|
|
256
|
+
description: 'User umask',
|
|
257
|
+
required: false,
|
|
258
|
+
default: 18
|
|
259
|
+
}),
|
|
260
|
+
};
|
|
261
|
+
static description = "Update user properties";
|
|
262
|
+
static examples = [`$ legispro user:update --name demo --password secret`,];
|
|
195
263
|
}
|
|
196
|
-
|
|
197
|
-
username: core_1.Flags.string({
|
|
198
|
-
description: 'Username to create',
|
|
199
|
-
required: false
|
|
200
|
-
}),
|
|
201
|
-
groups: core_1.Flags.string({
|
|
202
|
-
description: 'Group memberships',
|
|
203
|
-
required: false
|
|
204
|
-
}),
|
|
205
|
-
email: core_1.Flags.string({
|
|
206
|
-
description: 'email',
|
|
207
|
-
required: false
|
|
208
|
-
}),
|
|
209
|
-
language: core_1.Flags.string({
|
|
210
|
-
description: 'language',
|
|
211
|
-
required: false
|
|
212
|
-
}),
|
|
213
|
-
description: core_1.Flags.string({
|
|
214
|
-
description: 'description',
|
|
215
|
-
required: false
|
|
216
|
-
}),
|
|
217
|
-
password: core_1.Flags.string({
|
|
218
|
-
description: 'password',
|
|
219
|
-
required: false
|
|
220
|
-
}),
|
|
221
|
-
primaryGroup: core_1.Flags.string({
|
|
222
|
-
description: 'primary group',
|
|
223
|
-
required: false
|
|
224
|
-
}),
|
|
225
|
-
alias: core_1.Flags.string({
|
|
226
|
-
description: 'alias',
|
|
227
|
-
required: false
|
|
228
|
-
}),
|
|
229
|
-
timezone: core_1.Flags.string({
|
|
230
|
-
description: 'timezone',
|
|
231
|
-
required: false
|
|
232
|
-
}),
|
|
233
|
-
firstName: core_1.Flags.string({
|
|
234
|
-
description: 'first name',
|
|
235
|
-
required: false
|
|
236
|
-
}),
|
|
237
|
-
lastName: core_1.Flags.string({
|
|
238
|
-
description: 'last name',
|
|
239
|
-
required: false
|
|
240
|
-
}),
|
|
241
|
-
country: core_1.Flags.string({
|
|
242
|
-
description: 'country',
|
|
243
|
-
required: false
|
|
244
|
-
}),
|
|
245
|
-
fullName: core_1.Flags.string({
|
|
246
|
-
description: 'full name',
|
|
247
|
-
required: false
|
|
248
|
-
}),
|
|
249
|
-
enabled: core_1.Flags.boolean({
|
|
250
|
-
description: 'User enabled?',
|
|
251
|
-
required: false,
|
|
252
|
-
default: true
|
|
253
|
-
}),
|
|
254
|
-
expired: core_1.Flags.boolean({
|
|
255
|
-
description: 'User expired?',
|
|
256
|
-
required: false,
|
|
257
|
-
default: false
|
|
258
|
-
}),
|
|
259
|
-
umask: core_1.Flags.integer({
|
|
260
|
-
description: 'User umask',
|
|
261
|
-
required: false,
|
|
262
|
-
default: 18
|
|
263
|
-
}),
|
|
264
|
-
};
|
|
265
|
-
UserUpdate.description = "Update user properties";
|
|
266
|
-
UserUpdate.examples = [`$ legispro user:update --name demo --password secret`,];
|
|
267
|
-
exports.default = UserUpdate;
|
|
264
|
+
export default UserUpdate;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.run = void 0;
|
|
4
|
-
var core_1 = require("@oclif/core");
|
|
5
|
-
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
|
|
1
|
+
export { run } from '@oclif/core';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { Command } from '@oclif/core';
|
|
3
|
-
import { User, Group, Collection, Document, Metadata } from "./types
|
|
4
|
+
import { User, Group, Collection, Document, Metadata } from "./types";
|
|
4
5
|
export declare class FusiondbClient {
|
|
5
6
|
private _userName;
|
|
6
7
|
private _groupName;
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import path from "path";
|
|
3
|
+
import xpath from 'xpath';
|
|
4
|
+
import { DOMParser as dom } from 'xmldom';
|
|
5
|
+
export class FusiondbClient {
|
|
6
|
+
_userName;
|
|
7
|
+
_groupName;
|
|
8
|
+
_auth;
|
|
9
|
+
_headers;
|
|
10
|
+
_baseUrl;
|
|
11
|
+
// singleton
|
|
12
|
+
static _instance = new FusiondbClient();
|
|
9
13
|
constructor() {
|
|
10
14
|
}
|
|
11
15
|
static get instance() {
|
|
12
16
|
return this._instance;
|
|
13
17
|
}
|
|
14
18
|
setConfig(cmd) {
|
|
15
|
-
const configFile =
|
|
19
|
+
const configFile = path.join(cmd.config.configDir, 'config.json');
|
|
16
20
|
const env = require(configFile);
|
|
17
21
|
this._baseUrl = env.protocol + "://" + env.hostname + ":" + env.port;
|
|
18
22
|
this._auth = Buffer.from(`${env.user}:${env.password}`).toString('base64');
|
|
@@ -25,14 +29,14 @@ class FusiondbClient {
|
|
|
25
29
|
// ========================== HTTP METHODS =================================
|
|
26
30
|
// =========================================================================
|
|
27
31
|
get(url) {
|
|
28
|
-
return (
|
|
32
|
+
return axios({
|
|
29
33
|
method: 'GET',
|
|
30
34
|
url: this._baseUrl + "/exist/restxq/fusiondb" + url,
|
|
31
35
|
headers: this._headers
|
|
32
36
|
});
|
|
33
37
|
}
|
|
34
38
|
put(url, data) {
|
|
35
|
-
return (
|
|
39
|
+
return axios({
|
|
36
40
|
method: 'PUT',
|
|
37
41
|
url: this._baseUrl + "/exist/restxq/fusiondb" + url,
|
|
38
42
|
headers: this._headers,
|
|
@@ -40,7 +44,7 @@ class FusiondbClient {
|
|
|
40
44
|
});
|
|
41
45
|
}
|
|
42
46
|
putXml(url, data) {
|
|
43
|
-
return (
|
|
47
|
+
return axios({
|
|
44
48
|
method: 'PUT',
|
|
45
49
|
url: this._baseUrl + "/exist/restxq/fusiondb/document?uri=" + url,
|
|
46
50
|
headers: {
|
|
@@ -51,14 +55,14 @@ class FusiondbClient {
|
|
|
51
55
|
});
|
|
52
56
|
}
|
|
53
57
|
delete(url) {
|
|
54
|
-
return (
|
|
58
|
+
return axios({
|
|
55
59
|
method: 'DELETE',
|
|
56
60
|
url: this._baseUrl + "/exist/restxq/fusiondb" + url,
|
|
57
61
|
headers: this._headers
|
|
58
62
|
});
|
|
59
63
|
}
|
|
60
64
|
post(url, data) {
|
|
61
|
-
return (
|
|
65
|
+
return axios({
|
|
62
66
|
method: 'POST',
|
|
63
67
|
url: this._baseUrl + "/exist/restxq/fusiondb" + url,
|
|
64
68
|
headers: this._headers,
|
|
@@ -66,7 +70,7 @@ class FusiondbClient {
|
|
|
66
70
|
});
|
|
67
71
|
}
|
|
68
72
|
raw_post(url, headers, data) {
|
|
69
|
-
return (
|
|
73
|
+
return axios({
|
|
70
74
|
method: 'POST',
|
|
71
75
|
url: this._baseUrl + url,
|
|
72
76
|
headers: headers,
|
|
@@ -650,6 +654,3 @@ class FusiondbClient {
|
|
|
650
654
|
}
|
|
651
655
|
}
|
|
652
656
|
}
|
|
653
|
-
exports.FusiondbClient = FusiondbClient;
|
|
654
|
-
// singleton
|
|
655
|
-
FusiondbClient._instance = new FusiondbClient();
|
package/dist/lib/gh.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Octokit } from "@octokit/core";
|
|
2
|
+
import { Api } from "@octokit/plugin-rest-endpoint-methods";
|
|
3
|
+
export type Release = {
|
|
4
|
+
tag_name: string;
|
|
5
|
+
assets: {
|
|
6
|
+
browser_download_url: string;
|
|
7
|
+
id: any;
|
|
8
|
+
name: string;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
export type Connection = Octokit & Api;
|
|
12
|
+
export type ConnectionReleases = {
|
|
13
|
+
octokit: Connection;
|
|
14
|
+
releases: string[];
|
|
15
|
+
data: Release[];
|
|
16
|
+
repo: string;
|
|
17
|
+
};
|
|
18
|
+
export type ConnectParams = ({
|
|
19
|
+
auth: string;
|
|
20
|
+
});
|
|
21
|
+
export declare const connect: (auth: string) => Promise<Connection>;
|
|
22
|
+
export declare const listReleases: (octokit: Connection, repo: string) => Promise<ConnectionReleases>;
|
|
23
|
+
export declare const downloadAsset: (octokit: Connection, repo: string, release: Release) => Promise<{
|
|
24
|
+
sourcesDir: string;
|
|
25
|
+
tmpPath: string;
|
|
26
|
+
}>;
|
package/dist/lib/gh.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Octokit } from "@octokit/core";
|
|
2
|
+
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
|
|
3
|
+
import { promisify } from 'node:util';
|
|
4
|
+
import { writeFile, mkdir } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import unzipper from 'unzipper';
|
|
8
|
+
const write = promisify(writeFile);
|
|
9
|
+
const makeDir = promisify(mkdir);
|
|
10
|
+
const owner = 'Xcential-Corporation';
|
|
11
|
+
export const connect = async (auth) => {
|
|
12
|
+
const octokit = new (Octokit.plugin(restEndpointMethods))({ auth });
|
|
13
|
+
const { data: { login, name } } = await octokit.rest.users.getAuthenticated();
|
|
14
|
+
console.log("You are connected as: %s (%s)", name, login);
|
|
15
|
+
return octokit;
|
|
16
|
+
};
|
|
17
|
+
export const listReleases = async (octokit, repo) => {
|
|
18
|
+
const { data } = await octokit.rest.repos.listReleases({ owner, repo });
|
|
19
|
+
return { octokit, data, releases: data.map((v) => v.tag_name), repo };
|
|
20
|
+
};
|
|
21
|
+
export const downloadAsset = async (octokit, repo, release) => {
|
|
22
|
+
if (!release.assets[0]) {
|
|
23
|
+
throw new Error(`Assets not exported for tag: ${release.tag_name}`);
|
|
24
|
+
}
|
|
25
|
+
const { id: asset_id, name } = release.assets[0];
|
|
26
|
+
const tmpPath = join(tmpdir(), new Date().getTime().toString());
|
|
27
|
+
await makeDir(tmpPath);
|
|
28
|
+
const tmpFileName = join(tmpPath, name);
|
|
29
|
+
const { data } = (await octokit.rest.repos.getReleaseAsset({ owner, repo, asset_id, headers: { Accept: 'application/octet-stream' } }));
|
|
30
|
+
console.log(`Using asset temporary file: ${tmpFileName}`);
|
|
31
|
+
await write(tmpFileName, Buffer.from(data));
|
|
32
|
+
const sourcesDir = join(tmpPath, 'sources');
|
|
33
|
+
const directory = await unzipper.Open.file(tmpFileName);
|
|
34
|
+
console.log(`Using assets folder: ${sourcesDir}`);
|
|
35
|
+
await directory.extract({ path: sourcesDir });
|
|
36
|
+
return { sourcesDir, tmpPath };
|
|
37
|
+
};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import path from "path";
|
|
2
|
+
import rclone from "rclone.js";
|
|
3
|
+
export class RcloneClient {
|
|
4
|
+
_webdavUrl;
|
|
5
|
+
_webdavUser;
|
|
6
|
+
_webdavPassword;
|
|
7
|
+
// singleton
|
|
8
|
+
static _instance = new RcloneClient();
|
|
8
9
|
constructor() {
|
|
9
10
|
}
|
|
10
11
|
static get instance() {
|
|
11
12
|
return this._instance;
|
|
12
13
|
}
|
|
13
14
|
setConfig(cmd) {
|
|
14
|
-
const configFile =
|
|
15
|
+
const configFile = path.join(cmd.config.configDir, 'config.json');
|
|
15
16
|
const env = require(configFile);
|
|
16
17
|
this._webdavUrl = env.protocol + "://" + env.hostname + ":" + env.port;
|
|
17
18
|
this._webdavUser = env.user;
|
|
@@ -20,12 +21,11 @@ class RcloneClient {
|
|
|
20
21
|
list(url) {
|
|
21
22
|
let password = '';
|
|
22
23
|
(async () => {
|
|
23
|
-
const pass = await rclone.obscure(this._webdavPassword);
|
|
24
|
-
password = pass;
|
|
25
|
-
// console.log(pass);
|
|
24
|
+
const pass = await rclone.promises.obscure(this._webdavPassword || '');
|
|
25
|
+
password = pass.toString();
|
|
26
26
|
})();
|
|
27
27
|
(async () => {
|
|
28
|
-
const results = await rclone.ls(":webdav:" + url + "/", {
|
|
28
|
+
const results = await rclone.promises.ls(":webdav:" + url + "/", {
|
|
29
29
|
"webdav-url": this._webdavUrl,
|
|
30
30
|
"webdav-user": this._webdavUser,
|
|
31
31
|
"webdav-pass": password,
|
|
@@ -36,6 +36,3 @@ class RcloneClient {
|
|
|
36
36
|
return '';
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
exports.RcloneClient = RcloneClient;
|
|
40
|
-
// singleton
|
|
41
|
-
RcloneClient._instance = new RcloneClient();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export type ENV = 'ola-qa' | 'ola-dev';
|
|
3
|
+
export type SSHHost = {
|
|
4
|
+
env: ENV;
|
|
5
|
+
user: string;
|
|
6
|
+
installationFolder: string;
|
|
7
|
+
sourcesDir: string;
|
|
8
|
+
tmpPath: string;
|
|
9
|
+
print: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const runCommand: (command: string) => import("child_process").PromiseWithChild<{
|
|
12
|
+
stdout: string;
|
|
13
|
+
stderr: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const copySources: ({ print, user, sourcesDir, installationFolder, env }: SSHHost) => Promise<{
|
|
16
|
+
newInstallationPath: string;
|
|
17
|
+
mkDirCmd: string;
|
|
18
|
+
scpPath: string;
|
|
19
|
+
localDir: string;
|
|
20
|
+
customPath: string;
|
|
21
|
+
cwd: string;
|
|
22
|
+
dockerCmdLegispro: string;
|
|
23
|
+
dockerCmdDpms: string;
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { exec as execPromised } from "child_process";
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { writeFile } from 'node:fs';
|
|
5
|
+
const write = promisify(writeFile);
|
|
6
|
+
const exec = promisify(execPromised);
|
|
7
|
+
export const runCommand = (command) => exec(command);
|
|
8
|
+
const createEnvRollover = (envPath, basePath) => {
|
|
9
|
+
const data = [
|
|
10
|
+
`LEGISPRO_CUSTOM_PATH=${basePath}/custom`,
|
|
11
|
+
`EXISTDB_USER_MAPPING=${basePath}/custom/ExistDbMapping`,
|
|
12
|
+
`DOCS_PATH=${basePath}/custom/docs`,
|
|
13
|
+
`SAXON_LICENSE_FOLDER=${basePath}/custom/licenses/P0001`,
|
|
14
|
+
`HYPHENATION_DICTIONARY_PATH=${basePath}/custom/AKN/us-or/data/hyphenation`,
|
|
15
|
+
`MF_SCRIPTML_PATH=${basePath}/custom`,
|
|
16
|
+
];
|
|
17
|
+
return write(envPath, data.join('\r\n'), { encoding: 'utf8' });
|
|
18
|
+
};
|
|
19
|
+
export const copySources = async ({ print, user, sourcesDir, installationFolder, env }) => {
|
|
20
|
+
const serverTmpPath = new Date().getTime().toString();
|
|
21
|
+
const newInstallationPath = [installationFolder, serverTmpPath].join('');
|
|
22
|
+
const command = `mkdir "${newInstallationPath}"`;
|
|
23
|
+
const scpPath = newInstallationPath.replace(/\\/g, '/');
|
|
24
|
+
const customPath = join(sourcesDir, '*');
|
|
25
|
+
const envFiles1 = [];
|
|
26
|
+
const envFiles2 = [];
|
|
27
|
+
let host, host2;
|
|
28
|
+
switch (env) {
|
|
29
|
+
case 'ola-dev':
|
|
30
|
+
envFiles1.push('env.ola-dev');
|
|
31
|
+
envFiles2.push('env.ola-dev');
|
|
32
|
+
envFiles1.push('env.ola-dev-legispro');
|
|
33
|
+
envFiles2.push('env.ola-dev-dpms');
|
|
34
|
+
host = 'legddocker01';
|
|
35
|
+
host2 = 'legddocker02';
|
|
36
|
+
break;
|
|
37
|
+
case 'ola-qa':
|
|
38
|
+
envFiles1.push('env.ola-qa');
|
|
39
|
+
envFiles2.push('env.ola-qa');
|
|
40
|
+
envFiles1.push('env.ola-qa-legispro');
|
|
41
|
+
envFiles2.push('env.ola-qa-dpms');
|
|
42
|
+
host = 'dpmsdocktest01';
|
|
43
|
+
host2 = 'dpmsdocktest02';
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
const cmd1 = `scp -r ${customPath} ${user}@${host}:${scpPath}`;
|
|
47
|
+
const cmd2 = `scp -r ${customPath} ${user}@${host2}:${scpPath}`;
|
|
48
|
+
const customDPath = join(newInstallationPath, 'docker');
|
|
49
|
+
envFiles1.push('env.rollover');
|
|
50
|
+
envFiles2.push('env.rollover');
|
|
51
|
+
await createEnvRollover(join(sourcesDir, 'docker', 'env.rollover'), newInstallationPath);
|
|
52
|
+
const dockerCmdLegispro = `docker compose -f docker-compose.yml ${envFiles1.map(e => `--env-file ${e}`).join(' ')} --profile legispro_services up -d --wait --remove-orphans`;
|
|
53
|
+
const dockerCmdDpms = `docker compose -f docker-compose.yml ${envFiles2.map(e => `--env-file ${e}`).join(' ')} --profile dpms_services up -d --wait --remove-orphans`;
|
|
54
|
+
const cmdD1 = `cd ${customDPath} && ${dockerCmdLegispro}`;
|
|
55
|
+
const cmdD2 = `cd ${customDPath} && ${dockerCmdDpms}`;
|
|
56
|
+
if (print) {
|
|
57
|
+
console.log('Run these commands to copy the sources to servers using SCP:');
|
|
58
|
+
console.log(`ssh ${user}@${host} ${command}`);
|
|
59
|
+
console.log(cmd1);
|
|
60
|
+
console.log(`ssh ${user}@${host2} ${command}`);
|
|
61
|
+
console.log(cmd2);
|
|
62
|
+
console.log('');
|
|
63
|
+
console.log('Now, login to the servers using SSH and run the docker command');
|
|
64
|
+
console.log(cmdD1);
|
|
65
|
+
console.log(cmdD2);
|
|
66
|
+
}
|
|
67
|
+
return { newInstallationPath, mkDirCmd: command, scpPath, localDir: sourcesDir, customPath, cwd: customDPath, dockerCmdLegispro, dockerCmdDpms };
|
|
68
|
+
};
|
package/dist/lib/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FusiondbClient } from './fusiondb-client';
|
|
2
|
-
import { RcloneClient } from './rclone-client';
|
|
1
|
+
import { FusiondbClient } from './fusiondb-client.js';
|
|
2
|
+
import { RcloneClient } from './rclone-client.js';
|
|
3
3
|
export declare const client: FusiondbClient;
|
|
4
4
|
export declare const rclone: RcloneClient;
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const rclone_client_1 = require("./rclone-client");
|
|
6
|
-
exports.client = fusiondb_client_1.FusiondbClient.instance;
|
|
7
|
-
exports.rclone = rclone_client_1.RcloneClient.instance;
|
|
1
|
+
import { FusiondbClient } from './fusiondb-client.js';
|
|
2
|
+
import { RcloneClient } from './rclone-client.js';
|
|
3
|
+
export const client = FusiondbClient.instance;
|
|
4
|
+
export const rclone = RcloneClient.instance;
|