declapract
Version:
A tool to declaratively define best practices, maintainable evolve them, and scalably enforce them.
60 lines • 2.42 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileCheckDeclaration = exports.isOfFileCheckType = exports.FileCheckType = exports.FileCheckPurpose = void 0;
const domain_objects_1 = require("domain-objects");
const joi_1 = __importDefault(require("joi"));
const type_fns_1 = require("type-fns");
var FileCheckPurpose;
(function (FileCheckPurpose) {
FileCheckPurpose["BAD_PRACTICE"] = "BAD_PRACTICE";
FileCheckPurpose["BEST_PRACTICE"] = "BEST_PRACTICE";
})(FileCheckPurpose || (exports.FileCheckPurpose = FileCheckPurpose = {}));
var FileCheckType;
(function (FileCheckType) {
/**
* simply checks that the file exists, without considering contents
*/
FileCheckType["EXISTS"] = "EXISTS";
/**
* checks that the file contents equal the declared contents
*
* e.g., `expect(foundContents).toEqual(declaredContents)`
*
* (default when file contents are declared)
*/
FileCheckType["EQUALS"] = "EQUALS";
/**
* check that the file contents contain the declared contents
*
* e.g., `expect(foundContents).toContain(declaredContents)`
*/
FileCheckType["CONTAINS"] = "CONTAINS";
/**
* check that the file contents satisfy a custom check function
*
* (default when the `.declapract.ts` file exports a `check` function)
*/
FileCheckType["CUSTOM"] = "CUSTOM";
})(FileCheckType || (exports.FileCheckType = FileCheckType = {}));
exports.isOfFileCheckType = (0, type_fns_1.createIsOfEnum)(FileCheckType);
const schema = joi_1.default.object().keys({
pathGlob: joi_1.default.string().required(),
purpose: joi_1.default.string()
.valid(...Object.values(FileCheckPurpose))
.required(),
type: joi_1.default.string()
.valid(...Object.values(FileCheckType))
.required(),
required: joi_1.default.boolean().required(),
check: joi_1.default.function().required(),
fix: joi_1.default.function().required().allow(null),
contents: joi_1.default.function().required().allow(null),
});
class FileCheckDeclaration extends domain_objects_1.DomainObject {
}
exports.FileCheckDeclaration = FileCheckDeclaration;
FileCheckDeclaration.schema = schema;
//# sourceMappingURL=FileCheckDeclaration.js.map