@wocker/mongodb-plugin 1.0.1 → 1.0.2

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.
@@ -2,7 +2,7 @@ import { MongodbService } from "../services/MongodbService";
2
2
  export declare class MongodbController {
3
3
  protected readonly mongodbService: MongodbService;
4
4
  constructor(mongodbService: MongodbService);
5
- create(name?: string, image?: string, imageVersion?: string): Promise<void>;
5
+ create(name?: string, imageName?: string, imageVersion?: string): Promise<void>;
6
6
  destroy(name: string, yes?: boolean, force?: boolean): Promise<void>;
7
7
  use(name: string): Promise<void>;
8
8
  start(name?: string, restart?: boolean): Promise<void>;
@@ -28,9 +28,13 @@ let MongodbController = class MongodbController {
28
28
  constructor(mongodbService) {
29
29
  this.mongodbService = mongodbService;
30
30
  }
31
- create(name, image, imageVersion) {
31
+ create(name, imageName, imageVersion) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
- yield this.mongodbService.create(name, image, imageVersion);
33
+ yield this.mongodbService.create({
34
+ name,
35
+ imageName,
36
+ imageVersion
37
+ });
34
38
  });
35
39
  }
36
40
  destroy(name, yes, force) {
@@ -1,5 +1,6 @@
1
1
  import { AppConfigService, PluginConfigService, DockerService, ProxyService } from "@wocker/core";
2
2
  import { Config } from "../makes/Config";
3
+ import { DatabaseProps } from "../makes/Database";
3
4
  export declare class MongodbService {
4
5
  protected readonly appConfigService: AppConfigService;
5
6
  protected readonly pluginConfigService: PluginConfigService;
@@ -9,7 +10,7 @@ export declare class MongodbService {
9
10
  adminContainerName: string;
10
11
  constructor(appConfigService: AppConfigService, pluginConfigService: PluginConfigService, dockerService: DockerService, proxyService: ProxyService);
11
12
  get config(): Config;
12
- create(name?: string, imageName?: string, imageVersion?: string, username?: string, password?: string): Promise<void>;
13
+ create(props?: Partial<DatabaseProps>): Promise<void>;
13
14
  upgrade(name?: string, imageName?: string, imageVersion?: string): Promise<void>;
14
15
  destroy(name: string, yes?: boolean, force?: boolean): Promise<void>;
15
16
  use(name: string): void;
@@ -54,13 +54,14 @@ let MongodbService = class MongodbService {
54
54
  }
55
55
  return this._config;
56
56
  }
57
- create(name_1, imageName_1, imageVersion_1) {
58
- return __awaiter(this, arguments, void 0, function* (name, imageName, imageVersion, username = "", password = "") {
59
- if (name && this.config.hasDatabase(name)) {
60
- throw new Error(`Database name "${name}" is already taken`);
57
+ create() {
58
+ return __awaiter(this, arguments, void 0, function* (props = {}) {
59
+ if (props.name && this.config.hasDatabase(props.name)) {
60
+ console.info(`Database name "${props.name}" is already taken`);
61
+ delete props.name;
61
62
  }
62
- if (!name) {
63
- name = (yield (0, utils_1.promptText)({
63
+ if (!props.name) {
64
+ props.name = (yield (0, utils_1.promptText)({
64
65
  message: "Mongodb name:",
65
66
  type: "string",
66
67
  validate: (name) => {
@@ -74,34 +75,34 @@ let MongodbService = class MongodbService {
74
75
  }
75
76
  }));
76
77
  }
77
- if (!username) {
78
- username = yield (0, utils_1.promptText)({
78
+ if (!props.username) {
79
+ props.username = yield (0, utils_1.promptText)({
79
80
  message: "Username:",
80
81
  type: "string",
81
82
  required: true
82
83
  });
83
84
  }
84
- if (!password) {
85
- password = yield (0, utils_1.promptText)({
85
+ if (!props.password) {
86
+ props.password = (yield (0, utils_1.promptText)({
86
87
  message: "Password:",
87
88
  type: "password",
88
89
  required: true
89
- });
90
+ }));
90
91
  const confirmPassword = yield (0, utils_1.promptText)({
91
92
  message: "Confirm password:",
92
93
  type: "password",
93
94
  required: true
94
95
  });
95
- if (password !== confirmPassword) {
96
+ if (props.password !== confirmPassword) {
96
97
  throw new Error("Passwords do not match");
97
98
  }
98
99
  }
99
100
  const database = new Database_1.Database({
100
- name,
101
- imageName,
102
- imageVersion,
103
- username,
104
- password
101
+ name: props.name,
102
+ imageName: props.imageName,
103
+ imageVersion: props.imageVersion,
104
+ username: props.username,
105
+ password: props.password
105
106
  });
106
107
  this.config.setDatabase(database);
107
108
  this.config.save();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wocker/mongodb-plugin",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "author": "Kris Papercut <krispcut@gmail.com>",
5
5
  "description": "Mongodb plugin for wocker",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "cli-table3": "^0.6.5"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/node": "^22.7.8",
35
- "typescript": "^5.6.3"
34
+ "@types/node": "^22.12.0",
35
+ "typescript": "^5.7.3"
36
36
  }
37
37
  }