@wocker/core 1.0.6 → 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.
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { WriteFileOptions, MakeDirectoryOptions, RmOptions } from "fs";
|
|
1
4
|
export declare class PluginConfigService {
|
|
2
5
|
protected readonly pluginDir: string;
|
|
3
6
|
constructor(pluginDir: string);
|
|
4
7
|
dataPath(...parts: string[]): string;
|
|
8
|
+
mkdir(path: string, options?: MakeDirectoryOptions): Promise<void>;
|
|
9
|
+
writeFile(path: string, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): Promise<void>;
|
|
10
|
+
writeJSON(path: string, data: any, options?: WriteFileOptions): Promise<void>;
|
|
11
|
+
readJSON(path: string): Promise<any>;
|
|
12
|
+
exists(path: string): boolean;
|
|
13
|
+
rm(path: string, options?: RmOptions): Promise<unknown>;
|
|
14
|
+
readdir(path: string): Promise<string[]>;
|
|
15
|
+
createWriteSteam(path: string): import("fs").WriteStream;
|
|
16
|
+
createReadStream(path: string): import("fs").ReadStream;
|
|
5
17
|
}
|
|
@@ -34,10 +34,20 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
34
34
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
35
35
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
36
36
|
};
|
|
37
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
38
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
39
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
40
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
41
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
42
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
43
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
44
|
+
});
|
|
45
|
+
};
|
|
37
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
47
|
exports.PluginConfigService = void 0;
|
|
39
48
|
const Path = __importStar(require("path"));
|
|
40
49
|
const fs_1 = require("fs");
|
|
50
|
+
const makes_1 = require("../makes");
|
|
41
51
|
const decorators_1 = require("../decorators");
|
|
42
52
|
const env_1 = require("../env");
|
|
43
53
|
let PluginConfigService = class PluginConfigService {
|
|
@@ -46,7 +56,7 @@ let PluginConfigService = class PluginConfigService {
|
|
|
46
56
|
}
|
|
47
57
|
dataPath(...parts) {
|
|
48
58
|
if (!this.pluginDir) {
|
|
49
|
-
throw new Error("");
|
|
59
|
+
throw new Error("Plugin dir missed");
|
|
50
60
|
}
|
|
51
61
|
if (!(0, fs_1.existsSync)(this.pluginDir)) {
|
|
52
62
|
(0, fs_1.mkdirSync)(this.pluginDir, {
|
|
@@ -55,6 +65,63 @@ let PluginConfigService = class PluginConfigService {
|
|
|
55
65
|
}
|
|
56
66
|
return Path.join(this.pluginDir, ...parts);
|
|
57
67
|
}
|
|
68
|
+
mkdir(path, options) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
yield makes_1.FS.mkdir(this.dataPath(path), options);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
writeFile(path, data, options) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
yield makes_1.FS.writeFile(this.dataPath(path), data, options);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
writeJSON(path, data, options) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
yield makes_1.FS.writeJSON(this.dataPath(path), data, options);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
readJSON(path) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
return makes_1.FS.readJSON(this.dataPath(path));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
exists(path) {
|
|
89
|
+
return (0, fs_1.existsSync)(this.dataPath(path));
|
|
90
|
+
}
|
|
91
|
+
rm(path_1) {
|
|
92
|
+
return __awaiter(this, arguments, void 0, function* (path, options = {}) {
|
|
93
|
+
const fullPath = this.dataPath(path);
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
(0, fs_1.rm)(fullPath, options, (err) => {
|
|
96
|
+
if (err) {
|
|
97
|
+
reject(err);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
resolve(undefined);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
readdir(path) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
const fullPath = this.dataPath(path);
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
(0, fs_1.readdir)(fullPath, (err, files) => {
|
|
110
|
+
if (err) {
|
|
111
|
+
reject(err);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
resolve(files);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
createWriteSteam(path) {
|
|
120
|
+
return (0, fs_1.createWriteStream)(this.dataPath(path));
|
|
121
|
+
}
|
|
122
|
+
createReadStream(path) {
|
|
123
|
+
return (0, fs_1.createReadStream)(this.dataPath(path));
|
|
124
|
+
}
|
|
58
125
|
};
|
|
59
126
|
exports.PluginConfigService = PluginConfigService;
|
|
60
127
|
exports.PluginConfigService = PluginConfigService = __decorate([
|