decova-gotcha
Version:
It's my personal trial for automating daunting tasks
72 lines • 2.12 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PackageJson = void 0;
const decova_json_1 = require("decova-json");
require("decova-dotnet");
const decova_dotnet_1 = require("decova-dotnet");
class PackageJson {
constructor(FilePath) {
this.FilePath = FilePath;
this.name = '';
this.version = '';
this.liscense = '';
this.main = '';
this.module = '';
this.description = '';
this.sourceMap = true;
this.inlineSourceMap = false;
this.outDir = '';
this.scripts = [];
this.files = [];
this.keywords = [];
this.dependencies = new Object();
this.bin = new Object();
this.devDependencies = new Object();
decova_json_1.Json.Populate(this, this.FilePath);
}
get Scripts() {
return this.scripts;
}
get Files() {
return this.files;
}
get Keywords() {
return this.keywords;
}
get Dependencies() {
return Map.FromObjectProps(this.dependencies);
}
HasAsDependency(depName) {
return Object.getOwnPropertyNames(this.dependencies).xAny(p => p == depName);
}
get Bin() {
return Map.FromObjectProps(this.bin);
}
get DevDependencies() {
return Map.FromObjectProps(this.devDependencies);
}
SaveAs(filePath) {
const objToSave = Object.assign({}, this);
delete objToSave.FilePath;
decova_json_1.Json.TrySave(filePath, objToSave, true, true);
}
Save() {
this.SaveAs(this.FilePath);
}
IncrementVersionPatch(autoSave = false) {
try {
const version = new decova_dotnet_1.SemVersion(this.version);
version.Patch++;
this.version = version.Text;
if (autoSave) {
this.Save();
}
}
catch (err) {
console.log(err);
throw err;
}
}
}
exports.PackageJson = PackageJson;
//# sourceMappingURL=PackageJson.js.map