@wocker/ws 1.0.22 → 1.0.23
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/lib/AppModule.js +36 -29
- package/lib/controllers/DebugController.d.ts +2 -1
- package/lib/controllers/DebugController.js +7 -7
- package/lib/controllers/ExperimentalController.d.ts +8 -0
- package/lib/controllers/ExperimentalController.js +77 -0
- package/lib/controllers/PluginController.d.ts +2 -1
- package/lib/controllers/PluginController.js +4 -3
- package/lib/controllers/PresetController.d.ts +5 -1
- package/lib/controllers/PresetController.js +11 -8
- package/lib/controllers/ProjectController.d.ts +6 -2
- package/lib/controllers/ProjectController.js +80 -59
- package/lib/controllers/index.d.ts +1 -3
- package/lib/controllers/index.js +1 -3
- package/lib/env.d.ts +1 -2
- package/lib/env.js +2 -3
- package/lib/main.js +7 -3
- package/lib/makes/Logger.d.ts +1 -1
- package/lib/makes/Plugin.d.ts +0 -1
- package/lib/makes/Plugin.js +0 -1
- package/lib/makes/index.d.ts +0 -1
- package/lib/makes/index.js +0 -1
- package/lib/modules/app/index.d.ts +2 -0
- package/lib/modules/app/index.js +16 -0
- package/lib/modules/docker/index.d.ts +8 -0
- package/lib/modules/docker/index.js +41 -0
- package/lib/modules/docker/services/ContainerService.d.ts +14 -0
- package/lib/modules/docker/services/ContainerService.js +115 -0
- package/lib/{services → modules/docker/services}/DockerService.d.ts +12 -5
- package/lib/{services → modules/docker/services}/DockerService.js +27 -114
- package/lib/modules/docker/services/ImageService.d.ts +18 -0
- package/lib/modules/docker/services/ImageService.js +68 -0
- package/lib/modules/docker/services/ModemService.d.ts +14 -0
- package/lib/modules/docker/services/ModemService.js +137 -0
- package/lib/modules/docker/services/ProtoService.d.ts +6 -0
- package/lib/modules/docker/services/ProtoService.js +20 -0
- package/lib/modules/index.d.ts +3 -0
- package/lib/{keystore → modules}/index.js +3 -1
- package/lib/{controllers → modules/keystore/controllers}/KeystoreController.d.ts +2 -2
- package/lib/{controllers → modules/keystore/controllers}/KeystoreController.js +5 -5
- package/lib/modules/keystore/index.d.ts +4 -0
- package/lib/modules/keystore/index.js +29 -0
- package/lib/{keystore → modules/keystore}/providers/FileKeystoreProvider.d.ts +1 -1
- package/lib/{keystore → modules/keystore}/providers/FileKeystoreProvider.js +1 -1
- package/lib/{keystore → modules/keystore}/providers/KeytarKeystoreProvider.js +1 -1
- package/lib/{keystore → modules/keystore/services}/KeystoreService.d.ts +1 -1
- package/lib/{keystore → modules/keystore/services}/KeystoreService.js +3 -3
- package/lib/{controllers → modules/proxy/controllers}/CertController.d.ts +2 -1
- package/lib/{controllers → modules/proxy/controllers}/CertController.js +4 -3
- package/lib/{controllers → modules/proxy/controllers}/ProxyController.d.ts +4 -1
- package/lib/{controllers → modules/proxy/controllers}/ProxyController.js +9 -6
- package/lib/modules/proxy/index.d.ts +5 -0
- package/lib/modules/proxy/index.js +39 -0
- package/lib/{services → modules/proxy/services}/CertService.d.ts +3 -3
- package/lib/{services → modules/proxy/services}/CertService.js +9 -9
- package/lib/{services → modules/proxy/services}/ProxyService.d.ts +2 -2
- package/lib/{services → modules/proxy/services}/ProxyService.js +15 -7
- package/lib/services/AppConfigService.d.ts +2 -13
- package/lib/services/AppConfigService.js +17 -26
- package/lib/services/PluginService.js +6 -8
- package/lib/services/PresetService.js +2 -3
- package/lib/services/ProjectService.d.ts +4 -4
- package/lib/services/ProjectService.js +9 -10
- package/lib/utils/followProgress2.d.ts +1 -0
- package/lib/utils/followProgress2.js +63 -0
- package/lib/utils/index.d.ts +1 -2
- package/lib/utils/index.js +1 -2
- package/package.json +5 -6
- package/proto/buildkit.proto +55 -0
- package/proto/solver/pb/ops.proto +443 -0
- package/lib/keystore/index.d.ts +0 -1
- package/lib/keystore/types/Encryption.d.ts +0 -9
- package/lib/keystore/types/Encryption.js +0 -81
- package/lib/keystore/types/Encryptor.d.ts +0 -10
- package/lib/keystore/types/Encryptor.js +0 -59
- package/lib/makes/FS.d.ts +0 -27
- package/lib/makes/FS.js +0 -284
- package/lib/makes/LineConvertStream.d.ts +0 -11
- package/lib/makes/LineConvertStream.js +0 -42
- package/lib/plugins/MongodbPlugin.d.ts +0 -20
- package/lib/plugins/MongodbPlugin.js +0 -288
- package/lib/plugins/index.d.ts +0 -1
- package/lib/plugins/index.js +0 -17
- package/lib/services/index.d.ts +0 -10
- package/lib/services/index.js +0 -26
- package/lib/utils/followProgress.d.ts +0 -1
- package/lib/utils/followProgress.js +0 -73
- /package/lib/{utils/format-size-units.d.ts → modules/docker/utils/formatSizeUnits.d.ts} +0 -0
- /package/lib/{utils/format-size-units.js → modules/docker/utils/formatSizeUnits.js} +0 -0
- /package/lib/{keystore → modules/keystore}/providers/KeytarKeystoreProvider.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/types/FileKeystore.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/types/FileKeystore.js +0 -0
- /package/lib/{keystore → modules/keystore}/types/Keytar.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/types/Keytar.js +0 -0
- /package/lib/{keystore → modules/keystore}/utils/createEncryptionKey.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/utils/createEncryptionKey.js +0 -0
- /package/lib/{keystore → modules/keystore}/utils/createPasswordHash.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/utils/createPasswordHash.js +0 -0
- /package/lib/{keystore → modules/keystore}/utils/decrypt.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/utils/decrypt.js +0 -0
- /package/lib/{keystore → modules/keystore}/utils/encrypt.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/utils/encrypt.js +0 -0
- /package/lib/{keystore → modules/keystore}/utils/index.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/utils/index.js +0 -0
- /package/lib/{keystore → modules/keystore}/utils/verifyPasswordHash.d.ts +0 -0
- /package/lib/{keystore → modules/keystore}/utils/verifyPasswordHash.js +0 -0
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Encryptor = void 0;
|
|
37
|
-
const crypto = __importStar(require("crypto"));
|
|
38
|
-
class Encryptor {
|
|
39
|
-
constructor(hash, salt) {
|
|
40
|
-
this._hash = hash;
|
|
41
|
-
this._salt = salt
|
|
42
|
-
? Buffer.from(salt, "hex")
|
|
43
|
-
: crypto.randomBytes(16);
|
|
44
|
-
}
|
|
45
|
-
get hash() {
|
|
46
|
-
return this._hash;
|
|
47
|
-
}
|
|
48
|
-
get salt() {
|
|
49
|
-
return this._salt.toString("hex");
|
|
50
|
-
}
|
|
51
|
-
setPassword(password) {
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
encrypt() {
|
|
55
|
-
}
|
|
56
|
-
decrypt() {
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.Encryptor = Encryptor;
|
package/lib/makes/FS.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { FS as CoreFS } from "@wocker/core";
|
|
2
|
-
import * as fs from "fs";
|
|
3
|
-
import { Stats, BigIntStats, PathLike, PathOrFileDescriptor, WriteFileOptions, MakeDirectoryOptions } from "fs";
|
|
4
|
-
import { PassThrough } from "readable-stream";
|
|
5
|
-
type ReaddirFilesOptions = {
|
|
6
|
-
recursive?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare class FS extends CoreFS {
|
|
9
|
-
static access(path: PathLike): Promise<any>;
|
|
10
|
-
static existsSync(path: PathLike): boolean;
|
|
11
|
-
static mkdir(dirPath: string, options?: MakeDirectoryOptions): Promise<void>;
|
|
12
|
-
static mkdirSync(path: string, options?: MakeDirectoryOptions): string;
|
|
13
|
-
static readdirFiles(path: string, options?: ReaddirFilesOptions): Promise<string[]>;
|
|
14
|
-
static appendFile(path: PathOrFileDescriptor, data: any, options?: WriteFileOptions): Promise<void>;
|
|
15
|
-
static appendFileSync(path: PathOrFileDescriptor, data: any, options?: WriteFileOptions): void;
|
|
16
|
-
static readBytes(filePath: PathLike, position?: number | bigint, size?: number | bigint): Promise<Buffer>;
|
|
17
|
-
static readFileSync(filePath: PathLike): NonSharedBuffer;
|
|
18
|
-
static writeFileSync(path: PathLike, data: any, options?: WriteFileOptions): void;
|
|
19
|
-
static createWriteStream(path: PathLike): fs.WriteStream;
|
|
20
|
-
static unlink(filePath: PathLike): Promise<void>;
|
|
21
|
-
static watch(filename: PathLike, options?: any): fs.FSWatcher;
|
|
22
|
-
static stat(filename: PathLike, options?: Parameters<typeof fs.stat>[1]): Promise<Stats | BigIntStats>;
|
|
23
|
-
static createReadStream(path: PathLike, options?: Parameters<typeof fs.createReadStream>[1]): fs.ReadStream;
|
|
24
|
-
static createReadLinesStream(path: PathLike, count?: number): PassThrough;
|
|
25
|
-
static copyFile(src: PathLike, dest: PathLike): Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
export {};
|
package/lib/makes/FS.js
DELETED
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.FS = void 0;
|
|
37
|
-
const core_1 = require("@wocker/core");
|
|
38
|
-
const fs = __importStar(require("fs"));
|
|
39
|
-
const Path = __importStar(require("path"));
|
|
40
|
-
const readable_stream_1 = require("readable-stream");
|
|
41
|
-
class FS extends core_1.FS {
|
|
42
|
-
static async access(path) {
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
fs.access(path, (err) => {
|
|
45
|
-
if (!err) {
|
|
46
|
-
resolve(null);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
reject(err);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
static existsSync(path) {
|
|
55
|
-
return fs.existsSync(path);
|
|
56
|
-
}
|
|
57
|
-
static async mkdir(dirPath, options = {}) {
|
|
58
|
-
return new Promise((resolve, reject) => {
|
|
59
|
-
fs.mkdir(dirPath, options, (err) => {
|
|
60
|
-
if (!err) {
|
|
61
|
-
resolve();
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
reject(err);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
static mkdirSync(path, options) {
|
|
70
|
-
return fs.mkdirSync(path, options);
|
|
71
|
-
}
|
|
72
|
-
static async readdirFiles(path, options) {
|
|
73
|
-
const { recursive = false } = options || {};
|
|
74
|
-
if (recursive) {
|
|
75
|
-
const names = await FS.readdir(path);
|
|
76
|
-
let res = [];
|
|
77
|
-
for (const name of names) {
|
|
78
|
-
const filePath = Path.join(path, name);
|
|
79
|
-
let sub = [
|
|
80
|
-
name
|
|
81
|
-
];
|
|
82
|
-
const stats = await FS.stat(filePath);
|
|
83
|
-
if (stats.isDirectory()) {
|
|
84
|
-
sub = (await FS.readdirFiles(filePath, { recursive: true })).map((subName) => {
|
|
85
|
-
return Path.join(name, subName);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
res = [
|
|
89
|
-
...res,
|
|
90
|
-
...sub
|
|
91
|
-
];
|
|
92
|
-
}
|
|
93
|
-
return res;
|
|
94
|
-
}
|
|
95
|
-
return new Promise((resolve, reject) => {
|
|
96
|
-
fs.readdir(path, {
|
|
97
|
-
withFileTypes: true
|
|
98
|
-
}, (err, files) => {
|
|
99
|
-
if (err) {
|
|
100
|
-
reject(err);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const names = files.filter((dirent) => {
|
|
104
|
-
return dirent.isFile();
|
|
105
|
-
}).map((dirent) => {
|
|
106
|
-
return dirent.name;
|
|
107
|
-
});
|
|
108
|
-
resolve(names);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
static async appendFile(path, data, options) {
|
|
113
|
-
return new Promise((resolve, reject) => {
|
|
114
|
-
fs.appendFile(path, data, options, (error) => {
|
|
115
|
-
if (error) {
|
|
116
|
-
reject(error);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
resolve(undefined);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
static appendFileSync(path, data, options) {
|
|
125
|
-
return fs.appendFileSync(path, data, options);
|
|
126
|
-
}
|
|
127
|
-
static async readBytes(filePath, position = 0, size) {
|
|
128
|
-
if (position < 0 && typeof size === "undefined") {
|
|
129
|
-
const stats = await FS.stat(filePath);
|
|
130
|
-
size = BigInt(position) * -1n;
|
|
131
|
-
position = BigInt(stats.size) - size;
|
|
132
|
-
if (position < 0n) {
|
|
133
|
-
position = 0;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else if (typeof size === "undefined") {
|
|
137
|
-
const stats = await FS.stat(filePath);
|
|
138
|
-
if (typeof stats.size !== "bigint" && typeof position !== "bigint") {
|
|
139
|
-
size = stats.size - position;
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
size = BigInt(stats.size) - BigInt(position);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
if (size < 0n) {
|
|
146
|
-
return Buffer.alloc(0);
|
|
147
|
-
}
|
|
148
|
-
const buffer = Buffer.alloc(Number(size));
|
|
149
|
-
return new Promise((resolve, reject) => {
|
|
150
|
-
fs.open(filePath, (err, file) => {
|
|
151
|
-
if (err) {
|
|
152
|
-
reject(err);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
fs.read(file, buffer, 0, buffer.length, position, (err, _, buffer) => {
|
|
156
|
-
if (err) {
|
|
157
|
-
reject(err);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
resolve(buffer);
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
static readFileSync(filePath) {
|
|
166
|
-
return fs.readFileSync(filePath);
|
|
167
|
-
}
|
|
168
|
-
static writeFileSync(path, data, options) {
|
|
169
|
-
return fs.writeFileSync(path, data, options);
|
|
170
|
-
}
|
|
171
|
-
static createWriteStream(path) {
|
|
172
|
-
return fs.createWriteStream(path);
|
|
173
|
-
}
|
|
174
|
-
static async unlink(filePath) {
|
|
175
|
-
return new Promise((resolve, reject) => {
|
|
176
|
-
fs.unlink(filePath, (err) => {
|
|
177
|
-
if (!err) {
|
|
178
|
-
resolve();
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
reject(err);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
static watch(filename, options) {
|
|
187
|
-
return fs.watch(filename, options);
|
|
188
|
-
}
|
|
189
|
-
static stat(filename, options) {
|
|
190
|
-
return new Promise((resolve, reject) => {
|
|
191
|
-
fs.stat(filename, options, (err, stats) => {
|
|
192
|
-
if (err) {
|
|
193
|
-
reject(err);
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
resolve(stats);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
static createReadStream(path, options) {
|
|
202
|
-
return fs.createReadStream(path, options);
|
|
203
|
-
}
|
|
204
|
-
static createReadLinesStream(path, count) {
|
|
205
|
-
const write = new readable_stream_1.PassThrough();
|
|
206
|
-
(async () => {
|
|
207
|
-
if (typeof count === "undefined" || count > 0) {
|
|
208
|
-
const stats = await FS.stat(path);
|
|
209
|
-
const resLines = [""];
|
|
210
|
-
let position = 0n;
|
|
211
|
-
while (position < stats.size) {
|
|
212
|
-
let size = BigInt(count ? 64 * count : 255);
|
|
213
|
-
if (position + size > stats.size) {
|
|
214
|
-
size = BigInt(stats.size) - position;
|
|
215
|
-
}
|
|
216
|
-
const buffer = await FS.readBytes(path, position, size);
|
|
217
|
-
const lines = buffer.toString("utf-8").split("\n");
|
|
218
|
-
position += size;
|
|
219
|
-
for (let i = 0; i < lines.length; i++) {
|
|
220
|
-
const line = lines[i];
|
|
221
|
-
if (i === 0) {
|
|
222
|
-
resLines[resLines.length - 1] = (resLines[resLines.length - 1] || "") + line;
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
resLines.push(line);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (resLines.length > count + 1) {
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
for (let i = 0; i < (count || resLines.length); i++) {
|
|
233
|
-
write.write(resLines[i]);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
else if (count < 0) {
|
|
237
|
-
const stats = await FS.stat(path);
|
|
238
|
-
const resLines = [""];
|
|
239
|
-
let position = BigInt(stats.size);
|
|
240
|
-
while (position > 0n) {
|
|
241
|
-
let size = BigInt(2 * count * -1);
|
|
242
|
-
position -= size;
|
|
243
|
-
if (position < 0) {
|
|
244
|
-
size = position + size;
|
|
245
|
-
position = 0n;
|
|
246
|
-
}
|
|
247
|
-
const buffer = await FS.readBytes(path, position, size);
|
|
248
|
-
const lines = buffer.toString("utf-8").split("\n").reverse();
|
|
249
|
-
for (let i = 0; i < lines.length; i++) {
|
|
250
|
-
const line = lines[i];
|
|
251
|
-
if (i === 0) {
|
|
252
|
-
resLines[0] = line + (resLines[0] || "");
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
resLines.unshift(line);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
if (resLines.length > count * -1 + 1) {
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
const lines = resLines.slice(count - 1);
|
|
263
|
-
for (let i = 0; i < lines.length; i++) {
|
|
264
|
-
write.write(lines[i]);
|
|
265
|
-
}
|
|
266
|
-
write.end();
|
|
267
|
-
}
|
|
268
|
-
})();
|
|
269
|
-
return write;
|
|
270
|
-
}
|
|
271
|
-
static async copyFile(src, dest) {
|
|
272
|
-
new Promise((resolve, reject) => {
|
|
273
|
-
fs.copyFile(src, dest, (err) => {
|
|
274
|
-
if (!err) {
|
|
275
|
-
resolve(undefined);
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
reject(err);
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
exports.FS = FS;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Readable } from "stream";
|
|
2
|
-
import { Mutex } from "async-mutex";
|
|
3
|
-
declare class LineConvertStream extends Readable {
|
|
4
|
-
protected stream: NodeJS.ReadableStream;
|
|
5
|
-
protected buf: string;
|
|
6
|
-
protected mutex: Mutex;
|
|
7
|
-
constructor(stream: NodeJS.ReadableStream);
|
|
8
|
-
_read(size: number): void;
|
|
9
|
-
process(chunk: any): Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
export { LineConvertStream };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LineConvertStream = void 0;
|
|
4
|
-
const stream_1 = require("stream");
|
|
5
|
-
const async_mutex_1 = require("async-mutex");
|
|
6
|
-
class LineConvertStream extends stream_1.Readable {
|
|
7
|
-
constructor(stream) {
|
|
8
|
-
super();
|
|
9
|
-
this.buf = "";
|
|
10
|
-
this.mutex = new async_mutex_1.Mutex();
|
|
11
|
-
this.stream = stream;
|
|
12
|
-
this.stream.on("data", (chunk) => this.process(chunk));
|
|
13
|
-
this.stream.on("end", () => {
|
|
14
|
-
this.push(null);
|
|
15
|
-
});
|
|
16
|
-
this.stream.on("close", () => {
|
|
17
|
-
this.destroy();
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
_read(size) {
|
|
21
|
-
}
|
|
22
|
-
async process(chunk) {
|
|
23
|
-
await this.mutex.acquire();
|
|
24
|
-
this.buf += chunk.toString();
|
|
25
|
-
try {
|
|
26
|
-
let pos;
|
|
27
|
-
while ((pos = this.buf.indexOf("\n")) >= 0) {
|
|
28
|
-
if (pos === 0) {
|
|
29
|
-
this.buf = this.buf.slice(0);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const line = this.buf.slice(0, pos);
|
|
33
|
-
this.buf = this.buf.slice(pos + 1);
|
|
34
|
-
this.push(line);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
38
|
-
this.mutex.release();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.LineConvertStream = LineConvertStream;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { DockerService } from "../services";
|
|
2
|
-
export declare class MongodbPlugin {
|
|
3
|
-
protected readonly dockerService: DockerService;
|
|
4
|
-
protected container: string;
|
|
5
|
-
protected adminContainer: string;
|
|
6
|
-
protected dataDir: string;
|
|
7
|
-
constructor(dockerService: DockerService);
|
|
8
|
-
protected dataPath(...parts: string[]): string;
|
|
9
|
-
getDatabases(): Promise<string[]>;
|
|
10
|
-
getDatabasesDumps(): Promise<string[]>;
|
|
11
|
-
start(): Promise<void>;
|
|
12
|
-
startAdmin(): Promise<void>;
|
|
13
|
-
stop(): Promise<void>;
|
|
14
|
-
stopDB(): Promise<void>;
|
|
15
|
-
stopAdmin(): Promise<void>;
|
|
16
|
-
restart(): Promise<void>;
|
|
17
|
-
backup(database?: string): Promise<void>;
|
|
18
|
-
deleteBackup(database?: string, filename?: string, yes?: boolean): Promise<void>;
|
|
19
|
-
restore(database?: string, filename?: string): Promise<void>;
|
|
20
|
-
}
|