@atomist/sdm
Version:
Atomist Software Delivery Machine SDK
77 lines • 3.3 kB
JavaScript
;
/*
* Copyright © 2019 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.Autofix = void 0;
const executeAutofixes_1 = require("../../../api-helper/listener/executeAutofixes");
const logInterpreters_1 = require("../../../api-helper/log/logInterpreters");
const GoalNameGenerator_1 = require("../GoalNameGenerator");
const GoalWithFulfillment_1 = require("../GoalWithFulfillment");
const environment_1 = require("../support/environment");
/**
* Goal that performs autofixes: For example, linting and adding license headers.
*/
class Autofix extends GoalWithFulfillment_1.FulfillableGoalWithRegistrations {
constructor(goalDetailsOrUniqueName = GoalNameGenerator_1.DefaultGoalNameGenerator.generateName("autofix"), ...dependsOn) {
super(Object.assign({}, GoalWithFulfillment_1.getGoalDefinitionFrom(goalDetailsOrUniqueName, GoalNameGenerator_1.DefaultGoalNameGenerator.generateName("autofix"), AutofixDefinition)), ...dependsOn);
let transformPresentation;
let extractAuthor;
if (!!goalDetailsOrUniqueName) {
const autofixDetails = goalDetailsOrUniqueName;
if (!!autofixDetails.transformPresentation) {
transformPresentation = autofixDetails.transformPresentation;
}
if (!!autofixDetails.setAuthor) {
if (typeof autofixDetails.setAuthor === "boolean") {
extractAuthor = executeAutofixes_1.DefaultExtractAuthor;
}
else {
extractAuthor = autofixDetails.setAuthor;
}
}
}
this.addFulfillment({
name: `autofix-${this.definition.uniqueName}`,
logInterpreter: logInterpreters_1.LogSuppressor,
goalExecutor: executeAutofixes_1.executeAutofixes(this.registrations, transformPresentation, extractAuthor),
progressReporter: executeAutofixes_1.AutofixProgressReporter,
});
}
/**
* Add given transform to this Autofix goal
* @param transform
* @param name
*/
withTransform(transform, name = GoalNameGenerator_1.DefaultGoalNameGenerator.generateName("autofix-transform")) {
this.with({
name,
transform,
});
return this;
}
}
exports.Autofix = Autofix;
const AutofixDefinition = {
uniqueName: "autofix",
displayName: "autofix",
environment: environment_1.IndependentOfEnvironment,
workingDescription: "Evaluating autofixes",
completedDescription: "No autofixes applied",
failedDescription: "Autofixes failed",
stoppedDescription: "Autofixes applied",
isolated: true,
};
//# sourceMappingURL=Autofix.js.map