system/packages/git-modules/dist/module.js
2024-07-02 21:56:23 +02:00

64 lines
1.9 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Module = exports.defaults = void 0;
const tslib_1 = require("tslib");
const class_transformer_1 = require("class-transformer");
const lodash = require("lodash");
const defaults = (options) => {
return {
clone: options.clone || { post: {} },
exists: false,
name: options.name || '',
options: options.options || {
directory: '',
profile: null,
repository: ''
}
};
};
exports.defaults = defaults;
class Module {
constructor() {
this.repoName = '';
this.cwd = '';
this.exists = false;
this.isGithub = false;
this.name = '';
this.options = {
directory: '',
profile: '',
repository: ''
};
}
pack() {
return lodash.omitBy(JSON.parse((0, class_transformer_1.serialize)(this)), lodash.isNil);
}
serialize() {
return (0, class_transformer_1.serialize)(this);
}
}
// tslint:disable-next-line:member-ordering
Module.from = (json) => {
const ret = new Module();
ret.name = json.name;
ret.options = json.options;
ret.repoName = json.repoName || '';
ret.isGithub = json.isGithub !== undefined ? json.isGithub : false;
ret.cwd = json.cwd || '';
ret.exists = 'exists' in json ? json.exists : false;
return ret;
};
tslib_1.__decorate([
(0, class_transformer_1.Exclude)()
], Module.prototype, "repoName", void 0);
tslib_1.__decorate([
(0, class_transformer_1.Exclude)()
], Module.prototype, "cwd", void 0);
tslib_1.__decorate([
(0, class_transformer_1.Exclude)()
], Module.prototype, "exists", void 0);
tslib_1.__decorate([
(0, class_transformer_1.Exclude)()
], Module.prototype, "isGithub", void 0);
exports.Module = Module;
//# sourceMappingURL=module.js.map