@wocker/mongodb-plugin 1.0.11 → 1.0.13
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginConfig } from "@wocker/core";
|
|
2
2
|
import { Database, DatabaseProps } from "./Database";
|
|
3
3
|
export type AdminConfig = {
|
|
4
4
|
enabled: boolean;
|
|
@@ -8,18 +8,16 @@ export type ConfigProps = {
|
|
|
8
8
|
databases?: DatabaseProps[];
|
|
9
9
|
admin?: AdminConfig;
|
|
10
10
|
};
|
|
11
|
-
export declare
|
|
11
|
+
export declare class MongodbPluginConfig extends PluginConfig {
|
|
12
12
|
default?: string;
|
|
13
13
|
databases: Database[];
|
|
14
14
|
admin: AdminConfig;
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(data: ConfigProps);
|
|
16
16
|
setDatabase(database: Database): void;
|
|
17
17
|
hasDatabase(name: string): boolean;
|
|
18
18
|
getDefault(): Database;
|
|
19
19
|
getDatabaseOrDefault(name?: string): Database;
|
|
20
20
|
getDatabase(name: string): Database;
|
|
21
21
|
removeDatabase(name: string): void;
|
|
22
|
-
abstract save(): void;
|
|
23
22
|
toObject(): ConfigProps;
|
|
24
|
-
static make(fs: FileSystem): Config;
|
|
25
23
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MongodbPluginConfig = void 0;
|
|
4
|
+
const core_1 = require("@wocker/core");
|
|
4
5
|
const Database_1 = require("./Database");
|
|
5
|
-
class
|
|
6
|
-
constructor(
|
|
7
|
-
|
|
6
|
+
class MongodbPluginConfig extends core_1.PluginConfig {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
super(data);
|
|
9
|
+
const { default: defaultDatabase, databases = [], admin: { enabled: enabledAdmin = true } = {} } = data;
|
|
8
10
|
this.default = defaultDatabase;
|
|
9
11
|
this.databases = databases.map(database => new Database_1.Database(database));
|
|
10
12
|
this.admin = {
|
|
@@ -68,20 +70,5 @@ class Config {
|
|
|
68
70
|
admin: this.admin
|
|
69
71
|
};
|
|
70
72
|
}
|
|
71
|
-
static make(fs) {
|
|
72
|
-
const data = fs.exists("config.json")
|
|
73
|
-
? fs.readJSON("config.json")
|
|
74
|
-
: {};
|
|
75
|
-
return new class extends Config {
|
|
76
|
-
save() {
|
|
77
|
-
if (!fs.exists()) {
|
|
78
|
-
fs.mkdir("", {
|
|
79
|
-
recursive: true
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
fs.writeJSON("config.json", this.toObject());
|
|
83
|
-
}
|
|
84
|
-
}(data);
|
|
85
|
-
}
|
|
86
73
|
}
|
|
87
|
-
exports.
|
|
74
|
+
exports.MongodbPluginConfig = MongodbPluginConfig;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { PluginConfigService, DockerService, ProxyService, FileSystem } from "@wocker/core";
|
|
2
|
+
import { MongodbPluginConfig } from "../makes/MongodbPluginConfig";
|
|
3
3
|
import { Database, DatabaseProps } from "../makes/Database";
|
|
4
4
|
export declare class MongodbService {
|
|
5
|
-
protected readonly appConfigService: AppConfigService;
|
|
6
5
|
protected readonly pluginConfigService: PluginConfigService;
|
|
7
6
|
protected readonly dockerService: DockerService;
|
|
8
7
|
protected readonly proxyService: ProxyService;
|
|
9
|
-
protected _config?:
|
|
8
|
+
protected _config?: MongodbPluginConfig;
|
|
10
9
|
adminContainerName: string;
|
|
11
|
-
constructor(
|
|
12
|
-
get config():
|
|
10
|
+
constructor(pluginConfigService: PluginConfigService, dockerService: DockerService, proxyService: ProxyService);
|
|
11
|
+
get config(): MongodbPluginConfig;
|
|
13
12
|
get fs(): FileSystem;
|
|
14
13
|
create(props?: Partial<DatabaseProps>): Promise<void>;
|
|
15
14
|
upgrade(props: Partial<DatabaseProps>): Promise<void>;
|
|
@@ -26,11 +26,10 @@ const core_1 = require("@wocker/core");
|
|
|
26
26
|
const utils_1 = require("@wocker/utils");
|
|
27
27
|
const format_1 = require("date-fns/format");
|
|
28
28
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
29
|
-
const
|
|
29
|
+
const MongodbPluginConfig_1 = require("../makes/MongodbPluginConfig");
|
|
30
30
|
const Database_1 = require("../makes/Database");
|
|
31
31
|
let MongodbService = class MongodbService {
|
|
32
|
-
constructor(
|
|
33
|
-
this.appConfigService = appConfigService;
|
|
32
|
+
constructor(pluginConfigService, dockerService, proxyService) {
|
|
34
33
|
this.pluginConfigService = pluginConfigService;
|
|
35
34
|
this.dockerService = dockerService;
|
|
36
35
|
this.proxyService = proxyService;
|
|
@@ -38,7 +37,7 @@ let MongodbService = class MongodbService {
|
|
|
38
37
|
}
|
|
39
38
|
get config() {
|
|
40
39
|
if (!this._config) {
|
|
41
|
-
this._config =
|
|
40
|
+
this._config = this.pluginConfigService.getConfig(MongodbPluginConfig_1.MongodbPluginConfig);
|
|
42
41
|
}
|
|
43
42
|
return this._config;
|
|
44
43
|
}
|
|
@@ -108,7 +107,8 @@ let MongodbService = class MongodbService {
|
|
|
108
107
|
imageName: props.imageName,
|
|
109
108
|
imageVersion: props.imageVersion,
|
|
110
109
|
username: props.username,
|
|
111
|
-
password: props.password
|
|
110
|
+
password: props.password,
|
|
111
|
+
containerPort: props.containerPort
|
|
112
112
|
});
|
|
113
113
|
this.config.setDatabase(database);
|
|
114
114
|
this.config.save();
|
|
@@ -482,8 +482,7 @@ let MongodbService = class MongodbService {
|
|
|
482
482
|
exports.MongodbService = MongodbService;
|
|
483
483
|
exports.MongodbService = MongodbService = __decorate([
|
|
484
484
|
(0, core_1.Injectable)(),
|
|
485
|
-
__metadata("design:paramtypes", [core_1.
|
|
486
|
-
core_1.PluginConfigService,
|
|
485
|
+
__metadata("design:paramtypes", [core_1.PluginConfigService,
|
|
487
486
|
core_1.DockerService,
|
|
488
487
|
core_1.ProxyService])
|
|
489
488
|
], MongodbService);
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wocker/mongodb-plugin",
|
|
3
|
-
"
|
|
3
|
+
"type": "commonjs",
|
|
4
|
+
"version": "1.0.13",
|
|
4
5
|
"author": "Kris Papercut <krispcut@gmail.com>",
|
|
5
6
|
"description": "Mongodb plugin for wocker",
|
|
6
7
|
"license": "MIT",
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@wocker/core": "^1.0
|
|
30
|
+
"@wocker/core": "^1.1.0",
|
|
30
31
|
"@wocker/utils": "^2.0.3",
|
|
31
32
|
"cli-table3": "^0.6.5",
|
|
32
33
|
"date-fns": "^4.1.0"
|