"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.NpmPublish = void 0;
const GoalNameGenerator_1 = require("../../../api/goal/GoalNameGenerator");
const GoalWithFulfillment_1 = require("../../../api/goal/GoalWithFulfillment");
const environment_1 = require("../../../api/goal/support/environment");
const executePublish_1 = require("../build/executePublish");
const nodeProjectIdentifier_1 = require("../build/nodeProjectIdentifier");
/**
 * Goal that performs NPM registry publication
 */
class NpmPublish extends GoalWithFulfillment_1.FulfillableGoalWithRegistrations {
    constructor(goalDetailsOrUniqueName = NpmPublish.defaultGoalName, ...dependsOn) {
        super(Object.assign(Object.assign({}, PublishDefiniton), GoalWithFulfillment_1.getGoalDefinitionFrom(goalDetailsOrUniqueName, NpmPublish.defaultGoalName)), ...dependsOn);
    }
    with(registration) {
        this.addFulfillment({
            name: registration.name,
            goalExecutor: executePublish_1.executePublish(nodeProjectIdentifier_1.NodeProjectIdentifier, registration.options),
            pushTest: registration.pushTest,
            logInterpreter: registration.logInterpreter,
            progressReporter: registration.progressReporter,
        });
        return this;
    }
}
exports.NpmPublish = NpmPublish;
NpmPublish.defaultGoalName = GoalNameGenerator_1.DefaultGoalNameGenerator.generateName("npm-publish");
const PublishDefiniton = {
    uniqueName: "publish",
    environment: environment_1.IndependentOfEnvironment,
    displayName: "publish",
    workingDescription: "Publishing",
    completedDescription: "Published",
    failedDescription: "Publish failed",
    isolated: true,
};
//# sourceMappingURL=NpmPublish.js.map