@wocker/mongodb-plugin 1.0.9 → 1.0.10

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/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ###### Docker workspace for web projects
4
4
 
5
+ [![npm version](https://img.shields.io/npm/v/@wocker/mongodb-plugin.svg)](https://www.npmjs.com/package/@wocker/mongodb-plugin)
6
+ [![Publish](https://github.com/kearisp/wocker-mongodb-plugin/actions/workflows/publish-latest.yml/badge.svg?event=release)](https://github.com/kearisp/wocker-mongodb-plugin/actions/workflows/publish-latest.yml)
7
+ [![License](https://img.shields.io/npm/l/@wocker/mongodb-plugin)](https://github.com/kearisp/wocker-mongodb-plugin/blob/master/LICENSE)
8
+
9
+ [![npm total downloads](https://img.shields.io/npm/dt/@wocker/mongodb-plugin.svg)](https://www.npmjs.com/package/@wocker/mongodb-plugin)
10
+
5
11
  ## Installation
6
12
 
7
13
  **Note:** It is recommended to install Wocker globally to ensure accessibility from any directory in your terminal.
@@ -1,3 +1,4 @@
1
+ import { FileSystem } from "@wocker/core";
1
2
  import { Database, DatabaseProps } from "./Database";
2
3
  export type AdminConfig = {
3
4
  enabled: boolean;
@@ -20,4 +21,5 @@ export declare abstract class Config {
20
21
  removeDatabase(name: string): void;
21
22
  abstract save(): void;
22
23
  toObject(): ConfigProps;
24
+ static make(fs: FileSystem): Config;
23
25
  }
@@ -68,5 +68,20 @@ class Config {
68
68
  admin: this.admin
69
69
  };
70
70
  }
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
+ }
71
86
  }
72
87
  exports.Config = Config;
@@ -38,20 +38,7 @@ let MongodbService = class MongodbService {
38
38
  }
39
39
  get config() {
40
40
  if (!this._config) {
41
- const fs = this.pluginConfigService.fs;
42
- const data = fs.exists("config.json")
43
- ? fs.readJSON("config.json")
44
- : {};
45
- this._config = new class extends Config_1.Config {
46
- save() {
47
- if (!fs.exists()) {
48
- fs.mkdir("", {
49
- recursive: true
50
- });
51
- }
52
- fs.writeJSON("config.json", this.toObject());
53
- }
54
- }(data);
41
+ this._config = Config_1.Config.make(this.pluginConfigService.fs);
55
42
  }
56
43
  return this._config;
57
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wocker/mongodb-plugin",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "author": "Kris Papercut <krispcut@gmail.com>",
5
5
  "description": "Mongodb plugin for wocker",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "test": "echo \"Error: no test specified\" && exit 1"
27
27
  },
28
28
  "dependencies": {
29
- "@wocker/core": "^1.0.24",
29
+ "@wocker/core": "^1.0.25",
30
30
  "@wocker/utils": "^2.0.3",
31
31
  "cli-table3": "^0.6.5",
32
32
  "date-fns": "^4.1.0"