semantic-version/lib/ConfigurationProvider.js
Paul Hatcherian 31f4e3fdf0 Rewrite/refactor for v5, migrate to TypeScript (MAJOR)
Set Jest config file in package script

Include module path

Include tests in project folders

Remove index module exports

Hardcode configuration parameters

Move parameter binding into main run function

Use alias imports

Run test sequentially

Remove cleanup (async conflict)

Revert Jest option

Increase test timeout to 15 seconds
2022-04-03 20:28:28 -04:00

37 lines
2.1 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigurationProvider = void 0;
const CsvUserFormatter_1 = require("./formatting/CsvUserFormatter");
const DefaultTagFormatter_1 = require("./formatting/DefaultTagFormatter");
const DefaultVersionFormatter_1 = require("./formatting/DefaultVersionFormatter");
const JsonUserFormatter_1 = require("./formatting/JsonUserFormatter");
const DefaultCommitsProvider_1 = require("./providers/DefaultCommitsProvider");
const DefaultCurrentCommitResolver_1 = require("./providers/DefaultCurrentCommitResolver");
const DefaultVersionClassifier_1 = require("./providers/DefaultVersionClassifier");
const TagLastReleaseResolver_1 = require("./providers/TagLastReleaseResolver");
const BumpAlwaysVersionClassifier_1 = require("./providers/BumpAlwaysVersionClassifier");
class ConfigurationProvider {
constructor(config) {
this.config = config;
}
GetCurrentCommitResolver() { return new DefaultCurrentCommitResolver_1.DefaultCurrentCommitResolver(this.config); }
GetLastReleaseResolver() { return new TagLastReleaseResolver_1.TagLastReleaseResolver(this.config); }
GetCommitsProvider() { return new DefaultCommitsProvider_1.DefaultCommitsProvider(this.config); }
GetVersionClassifier() {
if (this.config.bumpEachCommit) {
return new BumpAlwaysVersionClassifier_1.BumpAlwaysVersionClassifier(this.config);
}
return new DefaultVersionClassifier_1.DefaultVersionClassifier(this.config);
}
GetVersionFormatter() { return new DefaultVersionFormatter_1.DefaultVersionFormatter(this.config); }
GetTagFormatter() { return new DefaultTagFormatter_1.DefaultTagFormatter(this.config); }
GetUserFormatter() {
switch (this.config.userFormatType) {
case 'json': return new JsonUserFormatter_1.JsonUserFormatter(this.config);
case 'csv': return new CsvUserFormatter_1.CsvUserFormatter(this.config);
default:
throw new Error(`Unknown user format type: ${this.config.userFormatType}, supported types: json, csv`);
}
}
}
exports.ConfigurationProvider = ConfigurationProvider;