"use strict";
/*
 * Copyright © 2020 Atomist, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.Version = void 0;
const GoalNameGenerator_1 = require("../../../api/goal/GoalNameGenerator");
const GoalWithFulfillment_1 = require("../../../api/goal/GoalWithFulfillment");
const commonPushTests_1 = require("../../../api/mapping/support/commonPushTests");
const projectVersioner_1 = require("../../delivery/build/local/projectVersioner");
/**
 * Goal that performs project visioning: For example using Maven to increment the project version number
 */
class Version extends GoalWithFulfillment_1.FulfillableGoalWithRegistrations {
    constructor(goalDetailsOrUniqueName = GoalNameGenerator_1.DefaultGoalNameGenerator.generateName("version"), ...dependsOn) {
        super(Object.assign(Object.assign({ workingDescription: "Calculating project version", completedDescription: "Versioned" }, GoalWithFulfillment_1.getGoalDefinitionFrom(goalDetailsOrUniqueName, GoalNameGenerator_1.DefaultGoalNameGenerator.generateName("version"))), { displayName: "version" }), ...dependsOn);
    }
    with(registration) {
        this.addFulfillment(Object.assign({ goalExecutor: projectVersioner_1.executeVersioner(registration.versioner), name: GoalNameGenerator_1.DefaultGoalNameGenerator.generateName("versioner") }, registration));
        return this;
    }
    withVersioner(versioner) {
        this.with({
            name: GoalNameGenerator_1.DefaultGoalNameGenerator.generateName("versioner"),
            pushTest: commonPushTests_1.AnyPush,
            versioner,
        });
        return this;
    }
}
exports.Version = Version;
//# sourceMappingURL=Version.js.map