@wocker/core
Version:
Core of the Wocker
107 lines (106 loc) • 4.18 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PluginConfigService = void 0;
const AppConfigService_1 = require("./AppConfigService");
const makes_1 = require("../makes");
const decorators_1 = require("../decorators");
const env_1 = require("../env");
let PluginConfigService = class PluginConfigService {
constructor(appConfigService, pluginDir) {
this.appConfigService = appConfigService;
this.pluginDir = pluginDir;
}
get fs() {
if (!this._fs) {
if (!this.pluginDir) {
throw new Error("Plugin dir missed");
}
this._fs = new makes_1.FileSystem(this.pluginDir);
if (!this._fs.exists()) {
this._fs.mkdir("", {
recursive: true
});
}
}
return this._fs;
}
isVersionGTE(version) {
if (!this.appConfigService.isVersionGTE) {
return false;
}
return this.appConfigService.isVersionGTE(version);
}
/** @deprecated */
dataPath(...parts) {
return this.fs.path(...parts);
}
/** @deprecated */
mkdir(path, options) {
this.fs.mkdir(path, options);
}
/** @deprecated */
writeFile(path, data, options) {
return __awaiter(this, void 0, void 0, function* () {
yield this.fs.writeFile(path, data, options);
});
}
/** @deprecated */
writeJSON(path, data, options) {
this.fs.writeJSON(path, data, options);
}
/** @deprecated */
readJSON(path) {
return this.fs.readJSON(path);
}
/** @deprecated */
exists(path) {
return this.fs.exists(path);
}
/** @deprecated */
rm(path, options) {
return __awaiter(this, void 0, void 0, function* () {
this.fs.rm(path, options);
});
}
/** @deprecated */
readdir(path) {
return __awaiter(this, void 0, void 0, function* () {
return this.fs.readdir(path);
});
}
/** @deprecated */
createWriteSteam(path) {
return this.fs.createWriteStream(path);
}
/** @deprecated */
createReadStream(path) {
return this.fs.createReadStream(path);
}
};
exports.PluginConfigService = PluginConfigService;
exports.PluginConfigService = PluginConfigService = __decorate([
(0, decorators_1.Injectable)(),
__param(1, (0, decorators_1.Inject)(env_1.PLUGIN_DIR_KEY)),
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService, String])
], PluginConfigService);