UNPKG

@atomist/sample-sdm

Version:

Sample Atomist automation for software delivery

59 lines 3.95 kB
"use strict"; /* * Copyright © 2018 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 }); const sdm_1 = require("@atomist/sdm"); const SetDeployEnablement_1 = require("@atomist/sdm/handlers/commands/SetDeployEnablement"); const machineFactory_1 = require("@atomist/sdm/machine/machineFactory"); const jvmPushTests_1 = require("@atomist/sdm/mapping/pushtest/jvm/jvmPushTests"); const tagRepo_1 = require("@atomist/sdm/util/github/tagRepo"); const nodeTagger_1 = require("@atomist/spring-automation/commands/tag/nodeTagger"); const springTagger_1 = require("@atomist/spring-automation/commands/tag/springTagger"); const demoEditors_1 = require("../pack/demo-editors/demoEditors"); const addCloudFoundryManifest_1 = require("../pack/pcf/addCloudFoundryManifest"); const cloudFoundryDeploy_1 = require("../pack/pcf/cloudFoundryDeploy"); const suggestAddingCloudFoundryManifest_1 = require("../pack/pcf/suggestAddingCloudFoundryManifest"); const materialChangeToJavaRepo_1 = require("../pack/spring/pushtest/materialChangeToJavaRepo"); const springPushTests_1 = require("../pack/spring/pushtest/springPushTests"); exports.ImmaterialChangeToJava = new sdm_1.MessageGoal("immaterialChangeToJava"); exports.EnableSpringBoot = new sdm_1.MessageGoal("enableSpringBoot"); /** * Assemble a machine that suggests the potential to use more SDM features */ function evangelicalMachine(configuration) { const sdm = machineFactory_1.createSoftwareDeliveryMachine({ name: "Helpful software delivery machine. You need to be saved.", configuration }, sdm_1.whenPushSatisfies(jvmPushTests_1.IsMaven, springPushTests_1.HasSpringBootApplicationClass, sdm_1.not(materialChangeToJavaRepo_1.MaterialChangeToJavaRepo)) .itMeans("No material change to Java") .setGoals(exports.ImmaterialChangeToJava), sdm_1.whenPushSatisfies(sdm_1.ToDefaultBranch, jvmPushTests_1.IsMaven, springPushTests_1.HasSpringBootApplicationClass) .itMeans("Spring Boot service to deploy") .setGoals(exports.EnableSpringBoot)); // TODO check if we've sent the message before. // Could do in a PushTest sdm.addGoalImplementation("ImmaterialChangeToJava", exports.ImmaterialChangeToJava, sdm_1.executeSendMessageToSlack("Looks like you didn't change Java in a material way. " + "Atomist could prevent you needing to build! :atomist_build_started:")) .addGoalImplementation("EnableSpringBoot", exports.EnableSpringBoot, sdm_1.executeSendMessageToSlack("Congratulations. You're using Spring Boot. It's cool :sunglasses: and so is Atomist. " + "Atomist knows lots about Spring Boot and would love to help")) .addChannelLinkListeners(suggestAddingCloudFoundryManifest_1.SuggestAddingCloudFoundryManifest) .addNewRepoWithCodeActions( // TODO suggest creating projects with generator tagRepo_1.tagRepo(springTagger_1.springBootTagger), tagRepo_1.tagRepo(nodeTagger_1.nodeTagger)) .addSupportingCommands(() => addCloudFoundryManifest_1.AddCloudFoundryManifest, SetDeployEnablement_1.enableDeploy, SetDeployEnablement_1.disableDeploy) .addExtensionPacks(demoEditors_1.DemoEditors) .addPushReactions(cloudFoundryDeploy_1.EnableDeployOnCloudFoundryManifestAddition); // addTeamPolicies(sdm); return sdm; } exports.evangelicalMachine = evangelicalMachine; //# sourceMappingURL=evangelicalMachine.js.map