├── .gitattributes ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── docs ├── Setup.md ├── create_sample1.png ├── dry_run_upgrade.png └── sample1_channel.png ├── legal └── THIRD_PARTY.md ├── lib ├── api-helper │ ├── code │ │ ├── autofix │ │ │ └── spawnAutofix.ts │ │ └── review │ │ │ ├── goalReviewListener.ts │ │ │ ├── patternMatchReviewer.ts │ │ │ └── slackReviewListener.ts │ ├── command │ │ ├── createCommand.ts │ │ ├── generator │ │ │ └── generatorCommand.ts │ │ └── transform │ │ │ ├── allReposInTeam.ts │ │ │ ├── chattyDryRunAwareEditor.ts │ │ │ ├── codeTransformWrapping.ts │ │ │ ├── confirmEditedness.ts │ │ │ ├── onTransformResult.ts │ │ │ └── spawnCodeTransform.ts │ ├── goal │ │ ├── DefaultGoalImplementationMapper.ts │ │ ├── chooseAndSetGoals.ts │ │ ├── executeGoal.ts │ │ ├── executeSendMessageToSlack.ts │ │ ├── fetchGoalsOnCommit.ts │ │ ├── goalPreconditions.ts │ │ ├── minimalClone.ts │ │ ├── mock.ts │ │ ├── progress │ │ │ └── progress.ts │ │ ├── sdmGoal.ts │ │ └── storeGoals.ts │ ├── listener │ │ ├── cancelGoals.ts │ │ ├── createPushImpactListenerInvocation.ts │ │ ├── executeAutoInspects.ts │ │ ├── executeAutofixes.ts │ │ ├── executeCancel.ts │ │ ├── executePushImpact.ts │ │ ├── goalSetListener.ts │ │ └── relevantCodeActions.ts │ ├── log │ │ ├── DelimitedWriteProgressLogDecorator.ts │ │ ├── EphemeralProgressLog.ts │ │ ├── LoggingProgressLog.ts │ │ ├── StringCapturingProgressLog.ts │ │ ├── WriteToAllProgressLog.ts │ │ ├── addressChannelsProgressLog.ts │ │ ├── firstAvailableProgressLog.ts │ │ ├── format.ts │ │ └── logInterpreters.ts │ ├── machine │ │ ├── AbstractSoftwareDeliveryMachine.ts │ │ ├── HandlerRegistrationManagerSupport.ts │ │ ├── ListenerRegistrationManagerSupport.ts │ │ ├── RepoTargetingParameters.ts │ │ ├── adaptHandleCommand.ts │ │ ├── handlerRegistrations.ts │ │ ├── projectLoaderRepoLoader.ts │ │ └── toMachineOptions.ts │ ├── misc │ │ ├── base64.ts │ │ ├── child_process.ts │ │ ├── credentials │ │ │ └── toToken.ts │ │ ├── dateFormat.ts │ │ ├── extensionPack.ts │ │ ├── git │ │ │ ├── GitHubIssueRouter.ts │ │ │ └── filesChangedSince.ts │ │ ├── job │ │ │ └── createJob.ts │ │ ├── project │ │ │ └── filteredView.ts │ │ ├── reportFailureInterpretation.ts │ │ ├── result.ts │ │ ├── sha.ts │ │ └── slack │ │ │ └── messages.ts │ ├── project │ │ ├── CachingProjectLoader.ts │ │ ├── GitHubLazyProjectLoader.ts │ │ ├── ProjectListenerInvokingProjectLoader.ts │ │ ├── appendOrCreate.ts │ │ ├── cloningProjectLoader.ts │ │ ├── configuration │ │ │ └── projectConfiguration.ts │ │ ├── fileCopy.ts │ │ ├── globPatterns.ts │ │ ├── support │ │ │ ├── LruCache.ts │ │ │ ├── SimpleCache.ts │ │ │ └── cacheKey.ts │ │ ├── withProject.ts │ │ └── withRepos.ts │ ├── pushtest │ │ ├── ci │ │ │ └── ciPushTests.ts │ │ ├── commit.ts │ │ ├── configuration │ │ │ └── configurationTests.ts │ │ └── materialChangeTest.ts │ ├── testsupport │ │ ├── README.md │ │ ├── SingleProjectLoader.ts │ │ ├── fakeCommandListenerInvocation.ts │ │ ├── fakeContext.ts │ │ ├── fakeGoalInvocation.ts │ │ └── fakePush.ts │ └── voter │ │ └── githubTeamVoter.ts ├── api │ ├── command │ │ ├── generator │ │ │ ├── BitBucketRepoCreationParameters.ts │ │ │ ├── GeneratorConfig.ts │ │ │ └── SeedDrivenGeneratorParametersSupport.ts │ │ ├── support │ │ │ ├── buttons.ts │ │ │ └── commonValidationPatterns.ts │ │ └── target │ │ │ ├── BitBucketRepoTargets.ts │ │ │ ├── GitHubRepoTargets.ts │ │ │ ├── GitlabRepoTargets.ts │ │ │ └── TransformModeSuggestion.ts │ ├── context │ │ ├── AdminCommunicationContext.ts │ │ ├── SdmContext.ts │ │ ├── addressChannels.ts │ │ ├── parameterPrompt.ts │ │ ├── preferenceStore.ts │ │ └── skillContext.ts │ ├── dsl │ │ ├── GoalComponent.ts │ │ ├── allOf.ts │ │ ├── decisionTree.ts │ │ ├── goalContribution.ts │ │ └── goalDsl.ts │ ├── goal │ │ ├── ExecuteGoalResult.ts │ │ ├── GitHubContext.ts │ │ ├── Goal.ts │ │ ├── GoalInvocation.ts │ │ ├── GoalNameGenerator.ts │ │ ├── GoalWithFulfillment.ts │ │ ├── Goals.ts │ │ ├── SdmGoalEvent.ts │ │ ├── SdmGoalMessage.ts │ │ ├── SdmGoalSetMessage.ts │ │ ├── common │ │ │ ├── AutoCodeInspection.ts │ │ │ ├── Autofix.ts │ │ │ ├── Cancel.ts │ │ │ ├── Immaterial.ts │ │ │ ├── Locking.ts │ │ │ ├── PushImpact.ts │ │ │ ├── Queue.ts │ │ │ ├── createGoal.ts │ │ │ └── suggestAction.ts │ │ ├── enrichGoal.ts │ │ ├── progress │ │ │ └── ReportProgress.ts │ │ ├── support │ │ │ ├── GoalImplementationMapper.ts │ │ │ ├── GoalScheduler.ts │ │ │ └── environment.ts │ │ └── tagGoalSet.ts │ ├── listener │ │ ├── BuildListener.ts │ │ ├── ChannelLinkListenerInvocation.ts │ │ ├── ClosedIssueListener.ts │ │ ├── CommandListener.ts │ │ ├── EndpointVerificationListener.ts │ │ ├── GoalCompletionListener.ts │ │ ├── GoalStatusListener.ts │ │ ├── GoalsSetListener.ts │ │ ├── IssueListenerInvocation.ts │ │ ├── Listener.ts │ │ ├── NewIssueListener.ts │ │ ├── ParametersInvocation.ts │ │ ├── ProjectListener.ts │ │ ├── PullRequestListener.ts │ │ ├── PushImpactListener.ts │ │ ├── PushListener.ts │ │ ├── RepoCreationListener.ts │ │ ├── ReviewListener.ts │ │ ├── StartupListener.ts │ │ ├── TagListener.ts │ │ ├── TriggeredListener.ts │ │ ├── UpdatedIssueListener.ts │ │ └── UserJoiningChannelListener.ts │ ├── machine │ │ ├── CommandRegistrationManager.ts │ │ ├── ConfigurationValues.ts │ │ ├── ExtensionPack.ts │ │ ├── FunctionalUnit.ts │ │ ├── GoalDrivenMachine.ts │ │ ├── ListenerRegistrationManager.ts │ │ ├── MachineConfiguration.ts │ │ ├── MachineConfigurer.ts │ │ ├── Registerable.ts │ │ ├── RepoTargets.ts │ │ ├── SigningKeys.ts │ │ ├── SoftwareDeliveryMachine.ts │ │ ├── SoftwareDeliveryMachineOptions.ts │ │ └── WellKnownGoals.ts │ ├── mapping │ │ ├── GoalSetter.ts │ │ ├── Mapping.ts │ │ ├── PredicateMapping.ts │ │ ├── PushMapping.ts │ │ ├── PushTest.ts │ │ ├── goalTest.ts │ │ └── support │ │ │ ├── PredicateMappingCostAnalyzer.ts │ │ │ ├── PredicateMappingTerm.ts │ │ │ ├── PushRule.ts │ │ │ ├── PushRules.ts │ │ │ ├── StaticPushMapping.ts │ │ │ ├── commonPushTests.ts │ │ │ ├── defaultPredicateMappingCostAnalyzer.ts │ │ │ ├── deployPushTests.ts │ │ │ ├── namedSeedRepo.ts │ │ │ ├── predicateUtils.ts │ │ │ ├── projectPredicateUtils.ts │ │ │ └── pushTestUtils.ts │ └── registration │ │ ├── AutoInspectRegistration.ts │ │ ├── AutofixRegistration.ts │ │ ├── CodeInspectionRegistration.ts │ │ ├── CodeTransform.ts │ │ ├── CodeTransformRegistration.ts │ │ ├── CommandHandlerRegistration.ts │ │ ├── CommandRegistration.ts │ │ ├── EventHandlerRegistration.ts │ │ ├── EventRegistrationManager.ts │ │ ├── GeneratorRegistration.ts │ │ ├── IngesterRegistration.ts │ │ ├── IngesterRegistrationManager.ts │ │ ├── ParametersBuilder.ts │ │ ├── ParametersDefinition.ts │ │ ├── ProjectOperationRegistration.ts │ │ ├── ProjectsOperationRegistration.ts │ │ ├── PushAwareParametersInvocation.ts │ │ ├── PushImpactListenerRegistration.ts │ │ ├── PushRegistration.ts │ │ ├── ReviewListenerRegistration.ts │ │ ├── ReviewerError.ts │ │ ├── ReviewerRegistration.ts │ │ ├── ServiceRegistration.ts │ │ ├── TriggeredListenerRegistration.ts │ │ ├── goalApprovalRequestVote.ts │ │ └── transformUtils.ts ├── client │ └── index.ts ├── core │ ├── delivery │ │ ├── build │ │ │ ├── executeTag.ts │ │ │ └── local │ │ │ │ ├── projectIdentifier.ts │ │ │ │ └── projectVersioner.ts │ │ └── goals │ │ │ └── support │ │ │ └── validateGoal.ts │ ├── goal │ │ ├── cache │ │ │ ├── CompressingGoalCache.ts │ │ │ ├── FileSystemGoalCacheArchiveStore.ts │ │ │ ├── NoOpGoalCache.ts │ │ │ └── goalCaching.ts │ │ ├── common │ │ │ ├── Tag.ts │ │ │ ├── Version.ts │ │ │ ├── pipeline.ts │ │ │ └── skill.ts │ │ └── container │ │ │ ├── action.ts │ │ │ ├── container.ts │ │ │ ├── docker.ts │ │ │ ├── encrypt.ts │ │ │ ├── execute.ts │ │ │ ├── provider.ts │ │ │ ├── repositoryDrivenContainer.ts │ │ │ └── util.ts │ ├── handlers │ │ ├── commands │ │ │ ├── DisplayDeployEnablement.ts │ │ │ ├── SetDeployEnablement.ts │ │ │ ├── deleteRepository.ts │ │ │ └── disposeCommand.ts │ │ ├── common │ │ │ ├── ConfigurationBasedBasicCredentialsResolver.ts │ │ │ ├── DefaultRepoRefResolver.ts │ │ │ └── GitHubCredentialsResolver.ts │ │ └── events │ │ │ ├── delivery │ │ │ └── goals │ │ │ │ ├── CancelGoalOnCanceled.ts │ │ │ │ ├── FulfillGoalOnRequested.ts │ │ │ │ ├── RequestDownstreamGoalsOnGoalSuccess.ts │ │ │ │ ├── RespondOnGoalCompletion.ts │ │ │ │ ├── SetGoalsOnGoal.ts │ │ │ │ ├── SetGoalsOnPush.ts │ │ │ │ ├── SkipDownstreamGoalsOnGoalFailure.ts │ │ │ │ ├── VoteOnGoalApprovalRequest.ts │ │ │ │ ├── goalExecution.ts │ │ │ │ └── k8s │ │ │ │ └── CacheCleanupAutomationEventListener.ts │ │ │ ├── issue │ │ │ ├── ClosedIssueHandler.ts │ │ │ ├── NewIssueHandler.ts │ │ │ └── UpdatedIssueHandler.ts │ │ │ └── repo │ │ │ ├── OnChannelLink.ts │ │ │ ├── OnFirstPushToRepo.ts │ │ │ ├── OnPullRequest.ts │ │ │ ├── OnRepoCreation.ts │ │ │ ├── OnRepoOnboarded.ts │ │ │ ├── OnTag.ts │ │ │ └── OnUserJoiningChannel.ts │ ├── index.ts │ ├── ingesters │ │ ├── sdmDeployEnablement.ts │ │ └── sdmVersionIngester.ts │ ├── log │ │ ├── DashboardDisplayProgressLog.ts │ │ ├── RolarProgressLog.ts │ │ └── rolarAndDashboardLogFactory.ts │ ├── machine │ │ ├── HandlerBasedSoftwareDeliveryMachine.ts │ │ ├── InvokeSdmStartupListenersAutomationEventListener.ts │ │ ├── LocalSoftwareDeliveryMachineOptions.ts │ │ ├── configure.ts │ │ ├── configureSdm.ts │ │ ├── defaultSoftwareDeliveryMachineConfiguration.ts │ │ ├── machineFactory.ts │ │ ├── modes.ts │ │ └── yaml │ │ │ ├── configureYaml.ts │ │ │ ├── mapCommand.ts │ │ │ ├── mapGoals.ts │ │ │ ├── mapPushTests.ts │ │ │ ├── mapRules.ts │ │ │ ├── resolvePlaceholder.ts │ │ │ ├── schema.ts │ │ │ └── util.ts │ ├── mapping │ │ └── pushtest │ │ │ ├── isSkillConfigured.ts │ │ │ └── toPublicRepo.ts │ ├── preferences │ │ ├── AbstractPreferenceStore.ts │ │ ├── FilePreferenceStore.ts │ │ ├── InMemoryPreferenceStore.ts │ │ └── TeamConfigurationPreferenceStore.ts │ ├── repo │ │ └── publishTags.ts │ ├── signing │ │ ├── atomist-public.pem │ │ ├── eventSigning.ts │ │ ├── goalSigning.ts │ │ ├── jwtGoalSigning.ts │ │ └── rsaGoalSigning.ts │ └── util │ │ ├── SdmGoalMetricReportingAutomationEventListener.ts │ │ ├── github │ │ ├── ghub.ts │ │ ├── gitHubProvider.ts │ │ ├── gitHubTagRouter.ts │ │ └── tagRepo.ts │ │ ├── graph │ │ └── queryCommits.ts │ │ ├── lifecycleHelpers.ts │ │ ├── misc │ │ ├── array.ts │ │ └── time.ts │ │ ├── slack │ │ └── diffRendering.ts │ │ ├── startupMessage.ts │ │ └── webhook │ │ └── ImageLink.ts ├── graphql │ ├── fragment │ │ ├── CoreCommitFields.graphql │ │ ├── CoreRepoFieldsAndChannels.graphql │ │ ├── PersonFields.graphql │ │ ├── PushFields.graphql │ │ ├── ScmProviderFields.graphql │ │ ├── SdmGoalFields.graphql │ │ ├── SdmGoalRepo.graphql │ │ ├── SdmGoalSetFields.graphql │ │ └── SdmGoalWithGoalsFields.graphql │ ├── mutation │ │ ├── CreateJob.graphql │ │ ├── DeleteResourceProvider.graphql │ │ ├── DeleteTeamConfiguration.graphql │ │ ├── SetJobTaskState.graphql │ │ ├── SetResourceProviderState.graphql │ │ ├── SetTeamConfiguration.graphql │ │ ├── UpdateGoal.graphql │ │ ├── UpdateGoalSet.graphql │ │ ├── UpdateSdmVersion.graphql │ │ ├── addTasks.graphql │ │ └── resumeJob.graphql │ ├── query │ │ ├── BinaryRepositoryProvider.graphql │ │ ├── BranchForName.graphql │ │ ├── BuildUrlBySha.graphql │ │ ├── CanceledSdmGoal.graphql │ │ ├── CommitForSdmGoal.graphql │ │ ├── DockerRegistryProvider.graphql │ │ ├── DockerRegistryProviderAll.graphql │ │ ├── GenericResourceProvider.graphql │ │ ├── GitHubAppInstallationByOwner.graphql │ │ ├── GitHubAppResourceProvider.graphql │ │ ├── GitHubLogin.graphql │ │ ├── InProcessSdmGoalSets.graphql │ │ ├── InProcessSdmGoals.graphql │ │ ├── LastEndpoint.graphql │ │ ├── Password.graphql │ │ ├── PersonByChatId.graphql │ │ ├── PersonQuery.graphql │ │ ├── PullRequestForSha.graphql │ │ ├── PullRequestsForBranch.graphql │ │ ├── PushForCommit.graphql │ │ ├── PushForSdmGoal.graphql │ │ ├── RepoBranchTips.graphql │ │ ├── RepoScmProvider.graphql │ │ ├── ReposInTeam.graphql │ │ ├── RepositoryByOwnerAndName.graphql │ │ ├── RepositoryMappedChannels.graphql │ │ ├── ResourceUser.graphql │ │ ├── ScmProvider.graphql │ │ ├── ScmProviderByType.graphql │ │ ├── ScmProviders.graphql │ │ ├── SdmGoalByGoalSetIdAndUniqueName.graphql │ │ ├── SdmGoalSetForId.graphql │ │ ├── SdmGoalsByShaAndBranch.graphql │ │ ├── SdmGoalsForCommit.graphql │ │ ├── SdmPreferenceByKey.graphql │ │ ├── SdmVersionForCommit.graphql │ │ ├── TeamConfiguratoinByNamespace.graphql │ │ └── WhatIsRunning.graphql │ ├── schema.json │ └── subscription │ │ ├── KubernetesDeployRequestedSdmGoal.graphql │ │ ├── OnAnyApprovedSdmGoal.graphql │ │ ├── OnAnyCompletedSdmGoal.graphql │ │ ├── OnAnyFailedSdmGoal.graphql │ │ ├── OnAnyJobTask.graphql │ │ ├── OnAnyRequestedSdmGoal.graphql │ │ ├── OnAnySdmGoalSet.graphql │ │ ├── OnAnySuccessfulSdmGoal.graphql │ │ ├── OnBuildComplete.graphql │ │ ├── OnBuildCompleteForDryRun.graphql │ │ ├── OnChannelLink.graphql │ │ ├── OnClosedIssue.graphql │ │ ├── OnFirstPushToRepo.graphql │ │ ├── OnIssueAction.graphql │ │ ├── OnNewIssue.graphql │ │ ├── OnPullRequest.graphql │ │ ├── OnPushToAnyBranch.graphql │ │ ├── OnRepoCreation.graphql │ │ ├── OnRepoOnboarded.graphql │ │ ├── OnSpecificCanceledSdmGoal.graphql │ │ ├── OnSuccessStatus.graphql │ │ ├── OnTag.graphql │ │ └── OnUserJoiningChannel.graphql ├── pack │ ├── aws │ │ ├── cache.ts │ │ └── index.ts │ ├── docker │ │ ├── build │ │ │ ├── DockerBuild.ts │ │ │ ├── DockerProgressReporter.ts │ │ │ └── executeDockerBuild.ts │ │ ├── index.ts │ │ ├── parse │ │ │ └── DockerFileParser.ts │ │ └── support │ │ │ ├── dockerPushTests.ts │ │ │ └── name.ts │ ├── gcp │ │ ├── cache.ts │ │ └── index.ts │ ├── github-goal-status │ │ ├── github.ts │ │ ├── index.ts │ │ └── statusSetters.ts │ ├── goal-state │ │ ├── cancelGoals.ts │ │ ├── goalState.ts │ │ ├── index.ts │ │ ├── manageGoalSets.ts │ │ ├── resetGoals.ts │ │ ├── setGoalState.ts │ │ └── updateGoal.ts │ ├── info │ │ ├── SelfDescribe.ts │ │ ├── exposeInfo.ts │ │ ├── index.ts │ │ ├── listGenerators.ts │ │ └── support │ │ │ └── commandSearch.ts │ ├── job │ │ ├── executeTask.ts │ │ ├── helpers.ts │ │ ├── index.ts │ │ ├── invokeCommand.ts │ │ └── job.ts │ ├── jvm │ │ ├── index.ts │ │ ├── java │ │ │ ├── JavaProjectStructure.ts │ │ │ ├── generate │ │ │ │ └── JavaProjectCreationParameters.ts │ │ │ ├── javaPatterns.ts │ │ │ ├── javaProjectUtils.ts │ │ │ ├── pushTests.ts │ │ │ └── query │ │ │ │ ├── javaPathExpressions.ts │ │ │ │ └── packageInfo.ts │ │ ├── maven │ │ │ ├── MavenProgressReporter.ts │ │ │ ├── Plugin.ts │ │ │ ├── VersionedArtifact.ts │ │ │ ├── build │ │ │ │ └── helpers.ts │ │ │ ├── inspection │ │ │ │ └── findDependencies.ts │ │ │ ├── mavenCommand.ts │ │ │ ├── parse │ │ │ │ ├── fromPom.ts │ │ │ │ └── pomParser.ts │ │ │ └── pushTests.ts │ │ ├── spring.ts │ │ ├── spring │ │ │ └── generate │ │ │ │ ├── SpringBootProjectStructure.ts │ │ │ │ ├── SpringProjectCreationParameters.ts │ │ │ │ └── springBootUtils.ts │ │ ├── util │ │ │ └── BoundedElement.ts │ │ └── xml │ │ │ └── XmldocFileParser.ts │ ├── k8s │ │ ├── commands │ │ │ └── kubernetesUndeploy.ts │ │ ├── config.ts │ │ ├── container.ts │ │ ├── deploy │ │ │ ├── cluster.ts │ │ │ ├── data.ts │ │ │ ├── deploy.ts │ │ │ ├── externalUrls.ts │ │ │ ├── fulfiller.ts │ │ │ ├── goal.ts │ │ │ └── spec.ts │ │ ├── events │ │ │ └── kubernetesDeploy.ts │ │ ├── index.ts │ │ ├── k8s.ts │ │ ├── kubernetes │ │ │ ├── api.ts │ │ │ ├── application.ts │ │ │ ├── apply.ts │ │ │ ├── clients.ts │ │ │ ├── config.ts │ │ │ ├── delete.ts │ │ │ ├── deployment.ts │ │ │ ├── fetch.ts │ │ │ ├── ingress.ts │ │ │ ├── labels.ts │ │ │ ├── metadata.ts │ │ │ ├── name.ts │ │ │ ├── namespace.ts │ │ │ ├── patch.ts │ │ │ ├── rbac.ts │ │ │ ├── request.ts │ │ │ ├── resource.ts │ │ │ ├── role.ts │ │ │ ├── roleBinding.ts │ │ │ ├── secret.ts │ │ │ ├── service.ts │ │ │ ├── serviceAccount.ts │ │ │ └── spec.ts │ │ ├── scheduler │ │ │ ├── KubernetesFulfillmentGoalScheduler.ts │ │ │ ├── KubernetesGoalScheduler.ts │ │ │ ├── goalScheduling.ts │ │ │ └── service.ts │ │ ├── support │ │ │ ├── crypto.ts │ │ │ ├── error.ts │ │ │ ├── name.ts │ │ │ ├── namespace.ts │ │ │ └── retry.ts │ │ └── sync │ │ │ ├── application.ts │ │ │ ├── change.ts │ │ │ ├── clone.ts │ │ │ ├── diff.ts │ │ │ ├── goals.ts │ │ │ ├── previousSpecVersion.ts │ │ │ ├── repo.ts │ │ │ ├── startup.ts │ │ │ ├── sync.ts │ │ │ └── tag.ts │ ├── node │ │ ├── autofix │ │ │ ├── addBuildScript.ts │ │ │ ├── eslintAutofix.ts │ │ │ ├── npmAuditAutofix.ts │ │ │ ├── packageJsonFormat.ts │ │ │ ├── packageLockUrlRewriteAutofix.ts │ │ │ ├── thirdPartyLicense.ts │ │ │ └── typescript │ │ │ │ └── tslintAutofix.ts │ │ ├── build │ │ │ ├── executePublish.ts │ │ │ ├── nodeOptions.ts │ │ │ ├── nodeProjectIdentifier.ts │ │ │ ├── npmLogInterpreter.ts │ │ │ ├── npmProgressReporter.ts │ │ │ └── npmVersioner.ts │ │ ├── generator │ │ │ └── NodeProjectCreationParameters.ts │ │ ├── goal │ │ │ └── NpmPublish.ts │ │ ├── index.ts │ │ ├── inspection │ │ │ ├── eslint.ts │ │ │ ├── npmAudit.ts │ │ │ └── tslint.ts │ │ ├── listener │ │ │ └── npm.ts │ │ ├── nodeSupport.ts │ │ ├── npm │ │ │ └── spawn.ts │ │ ├── pushtest │ │ │ ├── materialChangeToNodeRepo.ts │ │ │ ├── nodePushTests.ts │ │ │ └── tsPushTests.ts │ │ ├── transform │ │ │ ├── findAuthorName.ts │ │ │ ├── tryToUpdateDependency.ts │ │ │ ├── updatePackageJsonIdentification.ts │ │ │ ├── updatePackageVersion.ts │ │ │ └── updateReadmeTitle.ts │ │ ├── typings │ │ │ └── spdx-license-list.ts │ │ └── util │ │ │ └── PackageJson.ts │ ├── notification │ │ ├── index.ts │ │ └── notification.ts │ ├── universal-generator │ │ ├── generator.ts │ │ ├── generatorSupport.ts │ │ ├── index.ts │ │ └── test │ │ │ └── assertGenerator.ts │ └── version │ │ ├── file.ts │ │ ├── github.ts │ │ ├── increment.ts │ │ ├── index.ts │ │ ├── octokit.ts │ │ ├── release.ts │ │ ├── semver.ts │ │ └── version.ts └── spi │ ├── credentials │ └── CredentialsResolver.ts │ ├── issue │ ├── IssueCreationOptions.ts │ └── IssueRouter.ts │ ├── log │ ├── InterpretedLog.ts │ └── ProgressLog.ts │ ├── project │ ├── LazyProjectLoader.ts │ └── ProjectLoader.ts │ └── repo-ref │ └── RepoRefResolver.ts ├── package-lock.json ├── package.json ├── test ├── .gitignore ├── api-helper │ ├── TestSoftwareDeliveryMachine.ts │ ├── code │ │ ├── autofix │ │ │ └── spawnAutofix.test.ts │ │ └── review │ │ │ ├── goalReviewListener.test.ts │ │ │ └── patternMatchReviewer.test.ts │ ├── command │ │ └── transform │ │ │ └── spawnCodeTransform.test.ts │ ├── goal │ │ ├── DefaultGoalImplementationMapper.test.ts │ │ ├── chooseAndSetGoals.test.ts │ │ ├── executeGoal.test.ts │ │ ├── fetchGoalsOnCommit.test.ts │ │ ├── mock.test.ts │ │ ├── progress │ │ │ └── progress.test.ts │ │ └── storeGoals.test.ts │ ├── listener │ │ ├── cancelGoals.test.ts │ │ ├── executeAutoInspect.test.ts │ │ ├── executeAutofixes.test.ts │ │ ├── executeCancel.test.ts │ │ ├── executePushReactions.test.ts │ │ └── relevantCodeActions.test.ts │ ├── log │ │ ├── DelimitedWriteProgressLogDecorator.test.ts │ │ ├── LoggingProgressLog.test.ts │ │ └── firstAvailableProgressLog.test.ts │ ├── machine │ │ ├── AbstractSoftwareDeliveryMachine.test.ts │ │ ├── adaptHandleCommand.test.ts │ │ └── handlerRegistration.test.ts │ ├── misc │ │ ├── child_process.test.ts │ │ ├── extensionPack.test.ts │ │ ├── git │ │ │ └── filesChangedSince.test.ts │ │ ├── job │ │ │ └── createJob.test.ts │ │ ├── project │ │ │ └── filteredView.test.ts │ │ ├── reportFailureInterpretation.test.ts │ │ ├── result.test.ts │ │ └── sha.test.ts │ ├── project │ │ ├── GitHubLazyProjectLoader.test.ts │ │ ├── appendOrCreate.test.ts │ │ ├── cachingProjectLoader.test.ts │ │ ├── configuration │ │ │ └── projectConfiguration.test.ts │ │ ├── fileCopy.test.ts │ │ └── withProject.test.ts │ └── pushtest │ │ ├── commit.test.ts │ │ └── materialChangeTest.test.ts ├── api │ ├── command │ │ └── support │ │ │ ├── buttons.test.ts │ │ │ └── commonValidationPatterns.test.ts │ ├── context │ │ ├── parameterPrompt.test.ts │ │ └── skillContext.test.ts │ ├── dsl │ │ ├── allOf.test.ts │ │ ├── decisionTree.test.ts │ │ ├── goalContribution.test.ts │ │ └── whenPushSatisfies.test.ts │ ├── goal │ │ ├── ExecuteGoalResult.test.ts │ │ ├── Goal.test.ts │ │ ├── GoalNameGenerator.test.ts │ │ ├── GoalWithFulfillment.test.ts │ │ ├── Goals.test.ts │ │ └── common │ │ │ ├── Queue.test.ts │ │ │ └── createGoal.test.ts │ ├── machine │ │ └── ConfigureValues.test.ts │ ├── mapping │ │ ├── introspectPushMap.test.ts │ │ ├── predicateMapping.test.ts │ │ ├── predictGoals.ts │ │ └── support │ │ │ ├── commonPushTests.test.ts │ │ │ ├── deployPushTests.test.ts │ │ │ ├── projectPredicateUtils.test.ts │ │ │ ├── pushRule.test.ts │ │ │ ├── pushRules.test.ts │ │ │ └── pushTestUtils.test.ts │ └── registration │ │ ├── commandRegistration.test.ts │ │ ├── goalApprovalRequestVote.test.ts │ │ ├── toScalarProjectEditor.test.ts │ │ └── transformCompatibility.test.ts ├── core │ ├── blueprint │ │ └── sdmGoalImplementation.test.ts │ ├── common │ │ └── pipeline.test.ts │ ├── delivery │ │ └── goals │ │ │ └── support │ │ │ └── validateGoal.test.ts │ ├── goal │ │ ├── cache │ │ │ ├── CompressingGoalCache.test.ts │ │ │ └── goalCaching.test.ts │ │ └── container │ │ │ ├── container.test.ts │ │ │ ├── docker.test.ts │ │ │ ├── util.test.ts │ │ │ └── util.ts │ ├── handlers │ │ └── common │ │ │ └── GitHubCredentialsResolver.test.ts │ ├── log │ │ ├── DashboardDisplayProgressLog.test.ts │ │ └── RolarProgressLog.test.ts │ ├── machine │ │ ├── HandlerBasedSoftwareDeliveryMachine.test.ts │ │ ├── configure.test.ts │ │ └── yaml │ │ │ ├── mapGoals.test.ts │ │ │ ├── mapPushTests.test.ts │ │ │ └── resolvePlaceholder.test.ts │ ├── mapping │ │ └── pushtest │ │ │ ├── isSkillConfigured.test.ts │ │ │ └── toPublicRepo.test.ts │ ├── preferences │ │ ├── FilePreferenceStore.test.ts │ │ ├── InMemoryPreferenceStore.test.ts │ │ ├── TeamConfigurationPreferenceStore.test.ts │ │ └── preferences.ts │ ├── signing │ │ ├── es512-private.pem │ │ ├── es512-public.pem │ │ ├── goalSigning.test.ts │ │ ├── jwtGoalSigning.test.ts │ │ ├── sdm-test-public.pem │ │ └── sdm-test.pem │ └── util │ │ └── slack │ │ └── diffRendering.test.ts └── pack │ ├── aws │ └── cache.test.ts │ ├── docker │ ├── parse │ │ └── dockerFileParser.test.ts │ └── support │ │ └── name.test.ts │ ├── gcp │ └── cache.test.ts │ ├── job │ └── executeTask.test.ts │ ├── jvm │ ├── java │ │ ├── JavaProjectStructure.test.ts │ │ ├── javaPatterns.test.ts │ │ ├── javaProjectUtils.test.ts │ │ └── pushTests.test.ts │ ├── maven │ │ ├── mavenCommand.test.ts │ │ ├── parse │ │ │ └── pomParser.test.ts │ │ └── pushTests.test.ts │ ├── spring │ │ └── generator │ │ │ ├── SpringBootProjectStructure.test.ts │ │ │ └── springProjects.ts │ ├── util.ts │ └── xml │ │ ├── xmldocFileParser.test.ts │ │ └── zipkinPom.ts │ ├── k8s │ ├── commands │ │ └── kubernetesUndeploy.test.ts │ ├── config.test.ts │ ├── container.test.ts │ ├── deploy │ │ ├── cluster.test.ts │ │ ├── data.test.ts │ │ ├── deploy.test.ts │ │ ├── externalUrls.test.ts │ │ ├── goal.test.ts │ │ └── spec.test.ts │ ├── k8s.ts │ ├── kubernetes │ │ ├── api.test.ts │ │ ├── application.test.ts │ │ ├── clients.test.ts │ │ ├── delete.test.ts │ │ ├── deployment.test.ts │ │ ├── fetch.test.ts │ │ ├── ingress.test.ts │ │ ├── labels.test.ts │ │ ├── metadata.test.ts │ │ ├── name.test.ts │ │ ├── namespace.test.ts │ │ ├── patch.test.ts │ │ ├── rbac.test.ts │ │ ├── request.test.ts │ │ ├── resource.test.ts │ │ ├── role.test.ts │ │ ├── roleBinding.test.ts │ │ ├── secret.test.ts │ │ ├── service.test.ts │ │ ├── serviceAccount.test.ts │ │ └── spec.test.ts │ ├── scheduler │ │ ├── KubernetesFulfillmentGoalScheduler.test.ts │ │ └── KubernetesGoalScheduler.test.ts │ ├── support │ │ ├── crypto.test.ts │ │ ├── error.test.ts │ │ ├── name.test.ts │ │ └── retry.test.ts │ └── sync │ │ ├── application.test.ts │ │ ├── change.test.ts │ │ ├── diff.test.ts │ │ ├── goals.test.ts │ │ ├── previousSpecVersion.test.ts │ │ ├── repo.test.ts │ │ ├── startup.test.ts │ │ ├── sync.test.ts │ │ └── tag.test.ts │ ├── node │ ├── autofix │ │ ├── thirdPartyLicense.test.ts │ │ └── tslintFix.test.ts │ ├── build │ │ ├── gitBranchToNpmTag.test.ts │ │ ├── npmLogInterpreter.test.ts │ │ └── npmVersioner.test.ts │ └── pushtest │ │ ├── nodePushTests.test.ts │ │ └── tsPushTests.test.ts │ ├── notification │ └── notification.test.ts │ ├── universal-generator │ └── universalGenerator.test.ts │ └── version │ ├── file.test.ts │ ├── github.test.ts │ └── semver.test.ts ├── tsconfig.json └── tslint.json /.gitattributes: -------------------------------------------------------------------------------- 1 | legal/THIRD_PARTY.md linguist-generated=true 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | .vscode/ 4 | *~ 5 | .#* 6 | .npmrc 7 | node_modules/ 8 | *.d.ts 9 | *.d.ts.map 10 | *.js 11 | *.js.map 12 | *.log 13 | *.txt 14 | /.nyc_output/ 15 | /build/ 16 | /coverage/ 17 | /doc/ 18 | /log/ 19 | /lib/typings/ 20 | git-info.json 21 | /index.ts 22 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | .vscode/ 4 | *~ 5 | .#* 6 | .dockerignore 7 | .git* 8 | .npmrc* 9 | .travis.yml 10 | .atomist/ 11 | .nyc_output/ 12 | /build/ 13 | /doc/ 14 | /config/ 15 | /coverage/ 16 | /log/ 17 | /scripts/ 18 | /src/test 19 | /test/ 20 | /CO*.md 21 | /Dockerfile 22 | /assets/kubectl/ 23 | *.log 24 | *.txt 25 | /graphql.*.json 26 | /schema.json 27 | -------------------------------------------------------------------------------- /docs/create_sample1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atomist/sdm/d5a9863d985d2c8136c4ee066a4b7cd182719f53/docs/create_sample1.png -------------------------------------------------------------------------------- /docs/dry_run_upgrade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atomist/sdm/d5a9863d985d2c8136c4ee066a4b7cd182719f53/docs/dry_run_upgrade.png -------------------------------------------------------------------------------- /docs/sample1_channel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atomist/sdm/d5a9863d985d2c8136c4ee066a4b7cd182719f53/docs/sample1_channel.png -------------------------------------------------------------------------------- /lib/api-helper/code/autofix/spawnAutofix.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { SpawnLogInvocation } from "../../../api-helper/misc/child_process"; 18 | import { PushTest } from "../../../api/mapping/PushTest"; 19 | import { 20 | AutofixRegistration, 21 | AutofixRegistrationOptions, 22 | } from "../../../api/registration/AutofixRegistration"; 23 | import { spawnCodeTransform } from "../../command/transform/spawnCodeTransform"; 24 | 25 | /** 26 | * Create an autofix registration from one or more external commands. 27 | */ 28 | export function spawnAutofix(name: string, 29 | pushTest: PushTest, 30 | options: AutofixRegistrationOptions, 31 | command1: SpawnLogInvocation, 32 | ...additionalCommands: SpawnLogInvocation[]): AutofixRegistration { 33 | return { 34 | name, 35 | transform: spawnCodeTransform([command1, ...additionalCommands]), 36 | pushTest, 37 | options, 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /lib/api-helper/command/transform/confirmEditedness.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { EditResult } from "@atomist/automation-client/lib/operations/edit/projectEditor"; 18 | import { GitProject } from "@atomist/automation-client/lib/project/git/GitProject"; 19 | 20 | /** 21 | * Try to work out whether a project was edited, looking at git status 22 | * if we can't find out from the edit result 23 | * @param {EditResult} editResult 24 | * @return {Promise} 25 | */ 26 | export async function confirmEditedness(editResult: EditResult): Promise { 27 | if (editResult.edited === undefined) { 28 | const gs = await (editResult.target as GitProject).gitStatus(); 29 | return { 30 | ...editResult, 31 | edited: !gs.isClean, 32 | }; 33 | } else { 34 | return editResult; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/api-helper/goal/executeSendMessageToSlack.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Success } from "@atomist/automation-client/lib/HandlerResult"; 18 | import { SlackMessage } from "@atomist/slack-messages"; 19 | import { ExecuteGoalResult } from "../../api/goal/ExecuteGoalResult"; 20 | import { 21 | ExecuteGoal, 22 | GoalInvocation, 23 | } from "../../api/goal/GoalInvocation"; 24 | 25 | /*** 26 | * Execute a goal by sending a message to the linked Slack channels 27 | * @param {string | SlackMessage} msg 28 | * @return {ExecuteGoal} 29 | */ 30 | export function executeSendMessageToSlack(msg: string | SlackMessage): ExecuteGoal { 31 | return async (goalInvocation: GoalInvocation): Promise => { 32 | await goalInvocation.addressChannels(msg); 33 | return Success; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /lib/api-helper/goal/minimalClone.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { CloneOptions } from "@atomist/automation-client/lib/spi/clone/DirectoryManager"; 18 | import { PushFields } from "../../typings/types"; 19 | 20 | export function minimalClone(push: PushFields.Fragment, extras: Partial = {}): CloneOptions { 21 | // we need at least the commits of the push + 1 to be able to diff it 22 | return { depth: push.commits.length + 1, ...extras }; 23 | } 24 | -------------------------------------------------------------------------------- /lib/api-helper/log/firstAvailableProgressLog.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { ProgressLog } from "../../spi/log/ProgressLog"; 18 | 19 | /** 20 | * Return the first available progress log. 21 | * Error if none is available: Pass in a fallback that's always available. 22 | * @param log first log 23 | * @param {ProgressLog} moreLogs 24 | * @return {Promise} 25 | */ 26 | export async function firstAvailableProgressLog(log: ProgressLog, ...moreLogs: ProgressLog[]): Promise { 27 | const logs = [log].concat(...moreLogs); 28 | for (const pl of logs) { 29 | const avail = await pl.isAvailable(); 30 | if (avail) { 31 | return pl; 32 | } 33 | } 34 | throw new Error("No logger available: Please pass in at least one fallback that's always available"); 35 | } 36 | -------------------------------------------------------------------------------- /lib/api-helper/log/format.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { sprintf } from "sprintf-js"; 18 | 19 | /** 20 | * Returns a formatted string replacing any placeholders in msg with 21 | * provided args 22 | * 23 | * See npm springf-js for more details on what args and placeholder 24 | * patterns are supported. 25 | */ 26 | export function format(msg: string, ...args: any[]): string { 27 | if (!args || args.length === 0) { 28 | return msg; 29 | } else { 30 | try { 31 | return sprintf(msg, ...args); 32 | } catch (e) { 33 | return msg; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/api-helper/machine/RepoTargetingParameters.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { RepoTargets } from "../../api/machine/RepoTargets"; 18 | 19 | export interface RepoTargetingParameters { 20 | 21 | targets: RepoTargets; 22 | } 23 | 24 | export function isRepoTargetingParameters(p: any): p is RepoTargetingParameters { 25 | return !!p && !!(p as RepoTargetingParameters).targets; 26 | } 27 | -------------------------------------------------------------------------------- /lib/api-helper/machine/toMachineOptions.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { MachineConfiguration } from "../../api/machine/MachineConfiguration"; 18 | import { SoftwareDeliveryMachineOptions } from "../../api/machine/SoftwareDeliveryMachineOptions"; 19 | 20 | export type MachineOrMachineOptions = MachineConfiguration | SoftwareDeliveryMachineOptions; 21 | 22 | export function toMachineOptions(m: MachineOrMachineOptions): SoftwareDeliveryMachineOptions { 23 | return isMachineConfiguration(m) ? 24 | m.configuration.sdm : 25 | m; 26 | } 27 | 28 | function isMachineConfiguration(o: object): o is MachineConfiguration { 29 | const maybe = o as MachineConfiguration; 30 | return !!maybe.configuration; 31 | } 32 | -------------------------------------------------------------------------------- /lib/api-helper/misc/base64.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2021 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Base 64 encode the given string 19 | * @param {string} str 20 | * @return {string} 21 | */ 22 | export function encode(str: string): string { 23 | return Buffer.from(str, "utf8").toString("base64"); 24 | } 25 | 26 | /** 27 | * Decode the given Base 64 string 28 | * @param {string} coded 29 | * @return {string} 30 | */ 31 | export function decode(coded: string): string { 32 | return Buffer.from(coded, "base64").toString("utf8"); 33 | } 34 | -------------------------------------------------------------------------------- /lib/api-helper/misc/credentials/toToken.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { 18 | isTokenCredentials, 19 | ProjectOperationCredentials, 20 | } from "@atomist/automation-client/lib/operations/common/ProjectOperationCredentials"; 21 | 22 | /** 23 | * Convert the given credentials or token string to a token string 24 | * if possible. Otherwise throw an exception. 25 | * @param {ProjectOperationCredentials | string} credentials 26 | * @return {string} 27 | * @ModuleExport 28 | */ 29 | export function toToken(credentials: ProjectOperationCredentials | string): string { 30 | if (typeof credentials === "string") { 31 | return credentials; 32 | } 33 | if (isTokenCredentials(credentials)) { 34 | return credentials.token; 35 | } 36 | throw new Error("Cannot convert credentials to token"); 37 | } 38 | -------------------------------------------------------------------------------- /lib/api-helper/misc/dateFormat.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as df from "dateformat"; 18 | 19 | /** 20 | * Format the date with provided format. 21 | * Defaults to formatting the current UTC date with 'yyyymmddHHMMss' format. 22 | * 23 | * @param date Date object to format 24 | * @param format dateformat compatible format 25 | * @param utc if true, use UTC time, otherwise use local time zone 26 | * @return properly formatted date string 27 | */ 28 | export function formatDate(date: Date = new Date(), 29 | format: string = "yyyymmddHHMMss", 30 | utc: boolean = true): string { 31 | return df(date, format, utc); 32 | } 33 | -------------------------------------------------------------------------------- /lib/api-helper/misc/extensionPack.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as findUp from "find-up"; 18 | import * as path from "path"; 19 | import * as trace from "stack-trace"; 20 | import { ExtensionPackMetadata } from "../../api/machine/ExtensionPack"; 21 | 22 | /** 23 | * Read ExtensionPackMetadata from the modules package.json. 24 | * @param {string} name 25 | * @returns {ExtensionPackMetadata} 26 | */ 27 | export function metadata(name?: string): ExtensionPackMetadata { 28 | const pathToCallingFunction = trace.get()[1].getFileName(); 29 | const pj = require(findUp.sync("package.json", { cwd: path.resolve(path.dirname(pathToCallingFunction)) })); 30 | 31 | return { 32 | name: name ? `${pj.name}:${name.toLocaleLowerCase()}` : pj.name, 33 | vendor: pj.author && pj.author.name ? pj.author.name : pj.author, 34 | version: pj.version ? pj.version : "", 35 | tags: pj.keywords ? pj.keywords : [], 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /lib/api-helper/misc/git/GitHubIssueRouter.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { 18 | isTokenCredentials, 19 | ProjectOperationCredentials, 20 | } from "@atomist/automation-client/lib/operations/common/ProjectOperationCredentials"; 21 | import { RemoteRepoRef } from "@atomist/automation-client/lib/operations/common/RepoId"; 22 | import { 23 | Issue, 24 | raiseIssue, 25 | } from "@atomist/automation-client/lib/util/gitHub"; 26 | import { IssueRouter } from "../../../spi/issue/IssueRouter"; 27 | 28 | /** 29 | * GitHub implementation of IssueRouter 30 | */ 31 | export class GitHubIssueRouter implements IssueRouter { 32 | 33 | public async raiseIssue(credentials: ProjectOperationCredentials, 34 | id: RemoteRepoRef, 35 | issue: Issue): Promise { 36 | if (!isTokenCredentials(credentials)) { 37 | throw new Error("Only token credentials are supported"); 38 | } 39 | await raiseIssue(credentials.token, id, issue); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /lib/api-helper/misc/result.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as stringify from "json-stringify-safe"; 18 | 19 | export function serializeResult(result: any): string { 20 | return stringify(result, replacer, 0); 21 | } 22 | 23 | const KeysToIgnore = ["childProcess"]; 24 | 25 | function replacer(key: string, value: any): any { 26 | if ((key === "request" || key === "response") && !!value && stringify(value).length > 200) { 27 | return `<...elided because it might be a really long axios ${key}...>`; 28 | } else if (!KeysToIgnore.includes(key)) { 29 | return value; 30 | } 31 | return undefined; 32 | } 33 | -------------------------------------------------------------------------------- /lib/api-helper/misc/sha.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as crypto from "crypto"; 18 | 19 | /** 20 | * Compute the sha of the given string 21 | * @param {string} s 22 | * @return {string} 23 | */ 24 | export function computeShaOf(s: string): string { 25 | if (s === undefined || s === null) { 26 | throw new Error("Cannot compute SHA of undefined or null"); 27 | } 28 | return crypto.createHash("sha512").update(s).digest("hex"); 29 | } 30 | -------------------------------------------------------------------------------- /lib/api-helper/project/globPatterns.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Glob patterns for C family languages 19 | */ 20 | export const CFamilyLanguageSourceFiles = "**/{*.ts,*.java,*.js,*.scala,*.c,*.cpp,*.kt}"; 21 | -------------------------------------------------------------------------------- /lib/api-helper/project/support/SimpleCache.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export interface CacheStats { 18 | gets: number; 19 | hits: number; 20 | } 21 | 22 | /** 23 | * Simple interface for a string-keyed cache 24 | */ 25 | export interface SimpleCache { 26 | 27 | put(key: string, value: T): void; 28 | 29 | get(key: string): T; 30 | 31 | evict(key: string): void; 32 | 33 | stats: CacheStats; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /lib/api-helper/project/support/cacheKey.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { sprintf } from "sprintf-js"; 18 | import { ProjectLoadingParameters } from "../../../spi/project/ProjectLoader"; 19 | 20 | /** 21 | * Compute a cache key from the given ProjectLoadingParameters. 22 | * 23 | * In this context undefined and false are functionally equivalent, so 24 | * undefined values are coerced to false. 25 | * 26 | * @param {RemoteRepoRef} id 27 | * @return {any} 28 | */ 29 | export function cacheKey(params: ProjectLoadingParameters): string { 30 | return sprintf("%s:%s:%s:%s:%s:%s:%s:%s:%s@%s", 31 | params.id.owner, 32 | params.id.repo, 33 | params.id.branch, 34 | params.id.sha, 35 | params.cloneOptions?.keep || false, 36 | params.cloneOptions?.alwaysDeep || false, 37 | params.cloneOptions?.noSingleBranch || false, 38 | params.cloneOptions?.depth || 1, 39 | params.cloneOptions?.detachHead || false, 40 | params.id.url); 41 | } 42 | -------------------------------------------------------------------------------- /lib/api-helper/pushtest/ci/ciPushTests.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { 18 | predicatePushTest, 19 | PredicatePushTest, 20 | } from "../../../api/mapping/PushTest"; 21 | import { hasFile } from "../../../api/mapping/support/commonPushTests"; 22 | 23 | /** 24 | * Does this project use Travis? 25 | */ 26 | export const HasTravisFile: PredicatePushTest = predicatePushTest( 27 | "Is Travis", 28 | hasFile(".travis.yml").predicate); 29 | -------------------------------------------------------------------------------- /lib/api-helper/pushtest/commit.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { PushTest } from "../../api/mapping/PushTest"; 18 | 19 | /** 20 | * Push test that tests commit messages for a provided regular expression match 21 | */ 22 | export function hasCommit(test: RegExp): PushTest { 23 | return { 24 | name: `hasCommit '${test.source}'`, 25 | mapping: async pi => { 26 | return pi.push.commits.some(c => test.test(c.message)); 27 | }, 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /lib/api-helper/pushtest/configuration/configurationTests.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { 18 | pushTest, 19 | PushTest, 20 | } from "../../../api/mapping/PushTest"; 21 | import { projectConfigurationValue } from "../../project/configuration/projectConfiguration"; 22 | 23 | /** 24 | * Is this SDM enabled on the current project. 25 | * Checks the .atomist/config.json at key sdm.enabled to see if the current SDM is listed. 26 | */ 27 | export function isSdmEnabled(name: string): PushTest { 28 | return pushTest( 29 | `Is ${name} enabled`, 30 | async p => { 31 | const enabled = await projectConfigurationValue("sdm.enabled", p.project, []); 32 | if (!Array.isArray(enabled)) { 33 | return enabled === name; 34 | } else { 35 | return enabled.some(e => e === name); 36 | } 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /lib/api-helper/testsupport/README.md: -------------------------------------------------------------------------------- 1 | Useful functions for testing -------------------------------------------------------------------------------- /lib/api-helper/testsupport/SingleProjectLoader.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { GitProject } from "@atomist/automation-client/lib/project/git/GitProject"; 18 | import { Project } from "@atomist/automation-client/lib/project/Project"; 19 | import { 20 | ProjectLoader, 21 | ProjectLoadingParameters, 22 | WithLoadedProject, 23 | } from "../../spi/project/ProjectLoader"; 24 | 25 | /** 26 | * ProjectLoader that can only return one project. 27 | * Normally used in testing. 28 | */ 29 | export class SingleProjectLoader implements ProjectLoader { 30 | 31 | constructor(private readonly project: Project) {} 32 | 33 | public doWithProject(params: ProjectLoadingParameters, action: WithLoadedProject): Promise { 34 | return action(this.project as GitProject); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/api/command/generator/GeneratorConfig.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { RemoteRepoRef } from "@atomist/automation-client/lib/operations/common/RepoId"; 18 | 19 | /** 20 | * Basic config for all parameter creation 21 | */ 22 | export interface GeneratorConfig { 23 | 24 | /** 25 | * The seed repo 26 | */ 27 | seed: () => RemoteRepoRef; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /lib/api/command/target/TransformModeSuggestion.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Interface that can be implemented by CodeTransform parameters that can suggest the mode 19 | * to present changes to users. 20 | */ 21 | export interface TransformModeSuggestion { 22 | 23 | desiredBranchName: string; 24 | 25 | desiredPullRequestTitle?: string; 26 | 27 | desiredCommitMessage?: string; 28 | 29 | } 30 | 31 | export function isTransformModeSuggestion(p: any): p is TransformModeSuggestion { 32 | const maybe = p as TransformModeSuggestion; 33 | return !!maybe.desiredBranchName; 34 | } 35 | -------------------------------------------------------------------------------- /lib/api/context/AdminCommunicationContext.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { SoftwareDeliveryMachine } from "../machine/SoftwareDeliveryMachine"; 18 | import { AddressChannels } from "./addressChannels"; 19 | 20 | /** 21 | * Context allowing us to communicate with an admin 22 | */ 23 | export interface AdminCommunicationContext { 24 | 25 | /** 26 | * Address the admin of this SDM 27 | */ 28 | addressAdmin: AddressChannels; 29 | 30 | /** 31 | * The SDM that is currently running 32 | */ 33 | sdm: SoftwareDeliveryMachine; 34 | } 35 | -------------------------------------------------------------------------------- /lib/api/dsl/GoalComponent.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Goal } from "../goal/Goal"; 18 | import { 19 | Goals, 20 | isGoals, 21 | } from "../goal/Goals"; 22 | 23 | /** 24 | * Type used in constructing goals 25 | */ 26 | export type GoalComponent = Goal | Goal[] | Goals; 27 | 28 | /** 29 | * Convert a GoalComponent to Goals 30 | * @param {GoalComponent} gc 31 | * @return {Goals} 32 | */ 33 | export function toGoals(gc: GoalComponent): Goals { 34 | if (!gc) { 35 | return undefined; 36 | } 37 | return isGoals(gc) ? gc : 38 | Array.isArray(gc) ? new Goals(gc.map(g => g.name).join("/"), ...gc) : 39 | new Goals(gc.name, gc); 40 | } 41 | -------------------------------------------------------------------------------- /lib/api/goal/GitHubContext.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // convention: "sdm/atomist/#-env/#-goal" (the numbers are for ordering) 18 | import { StatusState } from "../../typings/types"; 19 | 20 | export type GitHubStatusContext = string; 21 | 22 | export interface GitHubStatus { 23 | context?: GitHubStatusContext; 24 | description?: string; 25 | state?: StatusState; 26 | targetUrl?: string; 27 | } 28 | 29 | export interface GitHubStatusAndFriends extends GitHubStatus { 30 | siblings: GitHubStatus[]; 31 | } 32 | 33 | export const BaseContext = "sdm/atomist/"; 34 | -------------------------------------------------------------------------------- /lib/api/goal/SdmGoalSetMessage.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { SdmGoalState } from "../../typings/types"; 18 | import { SdmProvenance } from "./SdmGoalMessage"; 19 | import { GoalSetTag } from "./tagGoalSet"; 20 | 21 | /** 22 | * Data persisted in the Atomist Cortex 23 | */ 24 | export interface SdmGoalSetMessage { 25 | sha: string; 26 | branch: string; 27 | 28 | repo: { 29 | name: string; 30 | owner: string; 31 | providerId: string; 32 | }; 33 | 34 | state: SdmGoalState; 35 | 36 | goalSet: string; 37 | goalSetId: string; 38 | ts: number; 39 | 40 | goals: Array<{ name: string, uniqueName: string }>; 41 | 42 | provenance: SdmProvenance; 43 | 44 | tags?: GoalSetTag[]; 45 | } 46 | -------------------------------------------------------------------------------- /lib/api/goal/common/Immaterial.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Success } from "@atomist/automation-client/lib/HandlerResult"; 18 | import { logger } from "@atomist/automation-client/lib/util/logger"; 19 | import { 20 | goals, 21 | Goals, 22 | } from "../Goals"; 23 | import { GoalWithFulfillment } from "../GoalWithFulfillment"; 24 | 25 | /** 26 | * Goal that should be scheduled for immaterial changes. 27 | * Uses a no-op goalExecutor. 28 | */ 29 | export const Immaterial = new GoalWithFulfillment({ 30 | uniqueName: "nevermind", 31 | displayName: "immaterial", 32 | completedDescription: "No material changes", 33 | }).with({ 34 | name: "immaterial", 35 | goalExecutor: async () => { 36 | logger.debug("Immaterial: Nothing to execute"); 37 | return Success; 38 | }, 39 | }); 40 | 41 | /** 42 | * Goals instance for Immaterial changes 43 | */ 44 | export const ImmaterialGoals: Goals = goals("Immaterial change").plan(Immaterial); 45 | -------------------------------------------------------------------------------- /lib/api/goal/common/Locking.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Goal } from "../Goal"; 18 | import { IndependentOfEnvironment } from "../support/environment"; 19 | 20 | export const Locking = new Goal({ 21 | uniqueName: "lock", 22 | displayName: "lock", 23 | completedDescription: "Lock goals", 24 | environment: IndependentOfEnvironment, 25 | }); 26 | -------------------------------------------------------------------------------- /lib/api/goal/enrichGoal.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { PushListenerInvocation } from "../listener/PushListener"; 18 | import { SdmGoalMessage } from "./SdmGoalMessage"; 19 | 20 | /** 21 | * Enrich provided goal before it gets persisted and planned 22 | */ 23 | export type EnrichGoal = (goal: SdmGoalMessage, pli: PushListenerInvocation) => Promise; 24 | -------------------------------------------------------------------------------- /lib/api/goal/progress/ReportProgress.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { SdmGoalEvent } from "../SdmGoalEvent"; 18 | 19 | /** 20 | * Signals a certain phase was entered during Goal execution. 21 | */ 22 | export interface Progress { 23 | 24 | /** Simple string label indicating the phase */ 25 | phase?: string; 26 | 27 | } 28 | 29 | /** 30 | * Report on the Progress of a Goal execution based on given log extract. 31 | * Usually this is the most current log line produced by the Goal execution. 32 | * 33 | * The returned Progress.phase will be stored on the Goal and overridden when 34 | * a new phase has been reported. 35 | * 36 | * If the goal fails, the failing phase is preserved. In all other cases the 37 | * phase will be reset on goal completion. 38 | */ 39 | export type ReportProgress = (log: string, sdmGoal: SdmGoalEvent) => Progress; 40 | 41 | /** 42 | * Don't report any progress 43 | */ 44 | export const NoProgressReport: ReportProgress = () => undefined; 45 | -------------------------------------------------------------------------------- /lib/api/goal/support/GoalScheduler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Configuration } from "@atomist/automation-client/lib/configuration"; 18 | import { ExecuteGoalResult } from "../ExecuteGoalResult"; 19 | import { GoalInvocation } from "../GoalInvocation"; 20 | 21 | /** 22 | * Schedule a goal in an environment (container or process) for fulfillment. 23 | */ 24 | export interface GoalScheduler { 25 | 26 | /** 27 | * Optionally initialize the GoalScheduler 28 | * @param configuration 29 | */ 30 | initialize?(configuration: Configuration): Promise; 31 | 32 | /** 33 | * Indicate if this GoalScheduler supports scheduling provided goal 34 | * @param gi 35 | */ 36 | supports(gi: GoalInvocation): Promise; 37 | 38 | /** 39 | * Schedule the provided goal 40 | * @param gi 41 | */ 42 | schedule(gi: GoalInvocation): Promise; 43 | } 44 | -------------------------------------------------------------------------------- /lib/api/goal/support/environment.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export type GoalEnvironment = "0-code/" | "1-staging/" | "2-prod/" | "8-doom/"; 18 | 19 | export const IndependentOfEnvironment: GoalEnvironment = "0-code/"; 20 | 21 | export const StagingEnvironment: GoalEnvironment = "1-staging/"; 22 | // should always be number dash name. The number may be a decimal 23 | export const ProductionEnvironment: GoalEnvironment = "2-prod/"; 24 | export const ProjectDisposalEnvironment: GoalEnvironment = "8-doom/"; 25 | -------------------------------------------------------------------------------- /lib/api/goal/tagGoalSet.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { PushListenerInvocation } from "../listener/PushListener"; 18 | import { SdmGoalMessage } from "./SdmGoalMessage"; 19 | 20 | export interface GoalSetTag { 21 | name: string; 22 | value?: string; 23 | } 24 | 25 | /** 26 | * Create Tags for the goal set containing the provided goals 27 | */ 28 | export type TagGoalSet = (goals: SdmGoalMessage[], pli: PushListenerInvocation) => Promise; 29 | -------------------------------------------------------------------------------- /lib/api/listener/BuildListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { OnBuildComplete } from "../../typings/types"; 18 | import { 19 | RepoListenerInvocation, 20 | SdmListener, 21 | } from "./Listener"; 22 | import Build = OnBuildComplete.Build; 23 | 24 | /** 25 | * Invocation for a build on a project. Not a part of delivery control: 26 | * Purely for observational purposes, such as determining the time 27 | * a build took. 28 | */ 29 | export interface BuildListenerInvocation extends RepoListenerInvocation { 30 | 31 | /** 32 | * Build that has just completed. 33 | */ 34 | build: Build; 35 | 36 | } 37 | 38 | export type BuildListener = SdmListener; 39 | -------------------------------------------------------------------------------- /lib/api/listener/ChannelLinkListenerInvocation.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { AddressChannels } from "../context/addressChannels"; 18 | import { SdmListener } from "./Listener"; 19 | import { ProjectListenerInvocation } from "./ProjectListener"; 20 | 21 | /** 22 | * Listener invoked when a repo has been linked to a channel 23 | */ 24 | export interface ChannelLinkListenerInvocation extends ProjectListenerInvocation { 25 | 26 | newlyLinkedChannelName: string; 27 | 28 | /** 29 | * Convenient method to address the newly linked channel only. 30 | * The inherited addressChannels method will address all linked channels. 31 | */ 32 | addressNewlyLinkedChannel: AddressChannels; 33 | 34 | } 35 | 36 | export type ChannelLinkListener = SdmListener; 37 | -------------------------------------------------------------------------------- /lib/api/listener/ClosedIssueListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as schema from "../../typings/types"; 18 | import { IssueListenerInvocation } from "./IssueListenerInvocation"; 19 | import { SdmListener } from "./Listener"; 20 | 21 | /** 22 | * Invoked when an issue has been closed. 23 | */ 24 | export interface ClosedIssueListenerInvocation extends IssueListenerInvocation { 25 | 26 | issue: schema.OnClosedIssue.Issue; 27 | } 28 | 29 | export type ClosedIssueListener = SdmListener; 30 | -------------------------------------------------------------------------------- /lib/api/listener/EndpointVerificationListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { 18 | RepoListenerInvocation, 19 | SdmListener, 20 | } from "./Listener"; 21 | 22 | export interface EndpointVerificationInvocation extends RepoListenerInvocation { 23 | 24 | /** 25 | * Reported endpoint base url 26 | */ 27 | url: string; 28 | } 29 | 30 | export type EndpointVerificationListener = SdmListener; 31 | -------------------------------------------------------------------------------- /lib/api/listener/GoalCompletionListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { SdmGoalEvent } from "../goal/SdmGoalEvent"; 18 | import { 19 | RepoListenerInvocation, 20 | SdmListener, 21 | } from "./Listener"; 22 | 23 | /** 24 | * Invocation on goal that has succeeded or failed. 25 | * This could come from any SDM. GoalExecutionListener focuses only on goals 26 | * from the present SDM. 27 | */ 28 | export interface GoalCompletionListenerInvocation extends RepoListenerInvocation { 29 | completedGoal: SdmGoalEvent; 30 | allGoals: SdmGoalEvent[]; 31 | } 32 | 33 | export type GoalCompletionListener = SdmListener; 34 | -------------------------------------------------------------------------------- /lib/api/listener/GoalsSetListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { PushFields } from "../../typings/types"; 18 | import { Goals } from "../goal/Goals"; 19 | import { 20 | RepoListenerInvocation, 21 | SdmListener, 22 | } from "./Listener"; 23 | 24 | /** 25 | * Invokes when goals have been set 26 | */ 27 | export interface GoalsSetListenerInvocation extends RepoListenerInvocation { 28 | 29 | /** 30 | * The goals that were set 31 | */ 32 | goalSet: Goals | null; 33 | 34 | /** 35 | * The id of the goal set 36 | */ 37 | goalSetId: string; 38 | 39 | /** 40 | * The name of the goal set 41 | */ 42 | goalSetName: string; 43 | 44 | /** 45 | * The Push that the triggered scheduling of these goals 46 | */ 47 | push: PushFields.Fragment; 48 | } 49 | 50 | export type GoalsSetListener = SdmListener; 51 | -------------------------------------------------------------------------------- /lib/api/listener/IssueListenerInvocation.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as schema from "../../typings/types"; 18 | import { RepoListenerInvocation } from "./Listener"; 19 | 20 | /** 21 | * Superinterface for new and updated and closed issue invocations. 22 | */ 23 | export interface IssueListenerInvocation extends RepoListenerInvocation { 24 | 25 | // Relies on duck typing for compatibility 26 | 27 | issue: schema.OnIssueAction.Issue; 28 | } 29 | -------------------------------------------------------------------------------- /lib/api/listener/Listener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Function1 } from "lodash"; 18 | import { 19 | RepoContext, 20 | SdmContext, 21 | } from "../context/SdmContext"; 22 | 23 | export type ListenerInvocation = SdmContext; 24 | 25 | /** 26 | * Common parameters to an invocation of a listener to one of the 27 | * SDM's specific events. These are fired by our event handlers to allow 28 | * multiple, domain specific, listeners to be invoked. 29 | */ 30 | export type RepoListenerInvocation = RepoContext; 31 | 32 | export type RepoListener = 33 | Function1>; 34 | 35 | /** 36 | * Mapper from a ListenerInvocation to any result 37 | */ 38 | export type SdmListener = 39 | Function1>; 40 | -------------------------------------------------------------------------------- /lib/api/listener/NewIssueListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as schema from "../../typings/types"; 18 | import { IssueListenerInvocation } from "./IssueListenerInvocation"; 19 | import { SdmListener } from "./Listener"; 20 | 21 | export interface NewIssueListenerInvocation extends IssueListenerInvocation { 22 | 23 | issue: schema.OnIssueAction.Issue; 24 | } 25 | 26 | export type NewIssueListener = SdmListener; 27 | -------------------------------------------------------------------------------- /lib/api/listener/ParametersInvocation.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { SdmContext } from "../context/SdmContext"; 18 | 19 | /** 20 | * Context for anything with parameters. All commands 21 | * have parameters, as do autofixes and auto inspections. 22 | */ 23 | export interface ParametersInvocation extends SdmContext { 24 | 25 | /** 26 | * Parameters, if any were supplied 27 | */ 28 | parameters?: PARAMS; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /lib/api/listener/PullRequestListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { OnPullRequest } from "../../typings/types"; 18 | import { SdmListener } from "./Listener"; 19 | import { ProjectListenerInvocation } from "./ProjectListener"; 20 | 21 | /** 22 | * Invocation for a pull request. The project will be as of the sha of the head 23 | * of the pull request 24 | */ 25 | export interface PullRequestListenerInvocation extends ProjectListenerInvocation { 26 | 27 | pullRequest: OnPullRequest.PullRequest; 28 | 29 | } 30 | 31 | export type PullRequestListener = SdmListener; 32 | -------------------------------------------------------------------------------- /lib/api/listener/PushImpactListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Project } from "@atomist/automation-client/lib/project/Project"; 18 | import { PushFields } from "../../typings/types"; 19 | import { PushListenerInvocation } from "./PushListener"; 20 | 21 | /** 22 | * Invocation object used by most listeners that react to code changes. 23 | * Provides fuller information about the impact of the push. 24 | */ 25 | export interface PushImpactListenerInvocation extends PushListenerInvocation { 26 | 27 | /** 28 | * Paths of the files changed in this push. 29 | * Undefined if it is unknown how many files have changed. 30 | */ 31 | filesChanged: string[] | undefined; 32 | 33 | /** 34 | * Head commit on push 35 | */ 36 | commit: PushFields.Commits; 37 | 38 | /** 39 | * Project of affected files. May be the same as project, if we can't tell 40 | * which files were affected. 41 | */ 42 | impactedSubProject: Project; 43 | } 44 | -------------------------------------------------------------------------------- /lib/api/listener/PushListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { OnPushToAnyBranch } from "../../typings/types"; 18 | import { SdmListener } from "./Listener"; 19 | import { ProjectListenerInvocation } from "./ProjectListener"; 20 | 21 | /** 22 | * Invocation for an event relating to a push on a project. 23 | * Many event listeners listen to this type of event. 24 | */ 25 | export interface PushListenerInvocation extends ProjectListenerInvocation { 26 | 27 | /** 28 | * Information about the push, including repo and commit 29 | */ 30 | readonly push: OnPushToAnyBranch.Push; 31 | 32 | } 33 | 34 | export type PushListener = SdmListener; 35 | -------------------------------------------------------------------------------- /lib/api/listener/RepoCreationListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as schema from "../../typings/types"; 18 | import { 19 | RepoListenerInvocation, 20 | SdmListener, 21 | } from "./Listener"; 22 | 23 | /** 24 | * Superinterface for all event invocations concerning a repo. 25 | * Note: addressChannels will not result in any output on this event 26 | * as any channel mapping will not have been set up. 27 | */ 28 | export interface RepoCreationListenerInvocation extends RepoListenerInvocation { 29 | 30 | repo: schema.OnRepoCreation.Repo; 31 | } 32 | 33 | /** 34 | * Respond to the creation of a new repo. 35 | * Note that it may not have code in it, so you may want to use 36 | * a PushListener! See SoftwareDeliveryMachine.addFirstPushListener 37 | */ 38 | export type RepoCreationListener = SdmListener; 39 | -------------------------------------------------------------------------------- /lib/api/listener/ReviewListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { ProjectReview } from "@atomist/automation-client/lib/operations/review/ReviewResult"; 18 | import { PushImpactResponse } from "../registration/PushImpactListenerRegistration"; 19 | import { SdmListener } from "./Listener"; 20 | import { PushListenerInvocation } from "./PushListener"; 21 | 22 | /** 23 | * Invocation on a completed review. 24 | */ 25 | export interface ReviewListenerInvocation extends PushListenerInvocation { 26 | 27 | /** 28 | * Consolidated review 29 | */ 30 | review: ProjectReview; 31 | } 32 | 33 | /** 34 | * Listener invoked when a review has been completed. 35 | * Listeners will be invoked even in the case of a clean review, 36 | * without errors or comments. 37 | */ 38 | export type ReviewListener = SdmListener; 39 | -------------------------------------------------------------------------------- /lib/api/listener/StartupListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Function1 } from "lodash"; 18 | import { AdminCommunicationContext } from "../context/AdminCommunicationContext"; 19 | 20 | /** 21 | * Invocation on SDM startup 22 | */ 23 | export type StartupListenerInvocation = AdminCommunicationContext; 24 | 25 | /** 26 | * Listener invoked on SDM startup 27 | */ 28 | export type StartupListener = Function1>; 29 | -------------------------------------------------------------------------------- /lib/api/listener/TagListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { OnTag } from "../../typings/types"; 18 | import { 19 | RepoListenerInvocation, 20 | SdmListener, 21 | } from "./Listener"; 22 | import Tag = OnTag.Tag; 23 | 24 | /** 25 | * Invocation when a tag has been created on a repo 26 | */ 27 | export interface TagListenerInvocation extends RepoListenerInvocation { 28 | 29 | tag: Tag; 30 | 31 | } 32 | 33 | export type TagListener = SdmListener; 34 | -------------------------------------------------------------------------------- /lib/api/listener/TriggeredListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Function1 } from "lodash"; 18 | import { AdminCommunicationContext } from "../context/AdminCommunicationContext"; 19 | 20 | /** 21 | * Invocation when trigger occurs 22 | */ 23 | export type TriggeredListenerInvocation = AdminCommunicationContext; 24 | 25 | /** 26 | * Listener invoked by a trigger 27 | */ 28 | export type TriggeredListener = Function1>; 29 | -------------------------------------------------------------------------------- /lib/api/listener/UpdatedIssueListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as schema from "../../typings/types"; 18 | import { IssueListenerInvocation } from "./IssueListenerInvocation"; 19 | import { SdmListener } from "./Listener"; 20 | 21 | /** 22 | * Invocation on an updated issue 23 | */ 24 | export interface UpdatedIssueListenerInvocation extends IssueListenerInvocation { 25 | 26 | issue: schema.OnIssueAction.Issue; 27 | } 28 | 29 | export type UpdatedIssueListener = SdmListener; 30 | -------------------------------------------------------------------------------- /lib/api/listener/UserJoiningChannelListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { RemoteRepoRef } from "@atomist/automation-client/lib/operations/common/RepoId"; 18 | import * as schema from "../../typings/types"; 19 | import { 20 | ListenerInvocation, 21 | SdmListener, 22 | } from "./Listener"; 23 | 24 | export interface UserJoiningChannelListenerInvocation extends ListenerInvocation { 25 | 26 | joinEvent: schema.OnUserJoiningChannel.UserJoinedChannel; 27 | 28 | /** 29 | * Any linked repo refs 30 | */ 31 | repos: RemoteRepoRef[]; 32 | } 33 | 34 | /** 35 | * Respond to a user joining a channel 36 | */ 37 | export type UserJoiningChannelListener = SdmListener; 38 | -------------------------------------------------------------------------------- /lib/api/machine/FunctionalUnit.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { HandleCommand } from "@atomist/automation-client/lib/HandleCommand"; 18 | import { HandleEvent } from "@atomist/automation-client/lib/HandleEvent"; 19 | import { Maker } from "@atomist/automation-client/lib/util/constructionUtils"; 20 | 21 | /** 22 | * Unit of functionality that can be added to an Atomist automation. 23 | */ 24 | export interface FunctionalUnit { 25 | 26 | readonly eventHandlers: Array>>; 27 | 28 | readonly commandHandlers: Array>; 29 | 30 | readonly ingesters: string[]; 31 | } 32 | -------------------------------------------------------------------------------- /lib/api/machine/MachineConfiguration.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Configuration } from "@atomist/automation-client/lib/configuration"; 18 | 19 | /** 20 | * Configuration for software delivery machines 21 | */ 22 | export interface MachineConfiguration { 23 | 24 | readonly name: string; 25 | 26 | /** 27 | * Automation client and machine configuration this machine will run in 28 | */ 29 | readonly configuration: Configuration & O; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /lib/api/machine/MachineConfigurer.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { SoftwareDeliveryMachine } from "./SoftwareDeliveryMachine"; 18 | 19 | /** 20 | * Configure the given SDM 21 | */ 22 | export type ConfigureMachine = (sdm: SoftwareDeliveryMachine) => void; 23 | 24 | /** 25 | * Extended by types that know how to configure an existing SDM. 26 | * The SDM's configuration will be valid and can be accessed in 27 | * the implementation of the configure method. 28 | */ 29 | export interface MachineConfigurer { 30 | 31 | /** 32 | * Function to configure the given SDM 33 | * @param sdm 34 | */ 35 | configure: ConfigureMachine; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /lib/api/machine/WellKnownGoals.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { AutoCodeInspection } from "../goal/common/AutoCodeInspection"; 18 | import { Autofix } from "../goal/common/Autofix"; 19 | import { PushImpact } from "../goal/common/PushImpact"; 20 | 21 | /** 22 | * Commonly used goals in an SDM that may be used in creating an ExtensionPack 23 | */ 24 | export interface WellKnownGoals { 25 | /** 26 | * pushImpactGoal to add push impact reactions to. 27 | */ 28 | pushImpactGoal?: PushImpact; 29 | 30 | /** 31 | * Inspect goal to add inspections to. 32 | * Review functionality won't work otherwise. 33 | */ 34 | inspectGoal?: AutoCodeInspection; 35 | 36 | /** 37 | * Autofix goal to add autofixes to. 38 | * Autofix functionality won't work otherwise. 39 | */ 40 | autofixGoal?: Autofix; 41 | } 42 | -------------------------------------------------------------------------------- /lib/api/mapping/PushMapping.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { 18 | goals, 19 | Goals, 20 | } from "../goal/Goals"; 21 | import { PushListenerInvocation } from "../listener/PushListener"; 22 | import { Mapping } from "./Mapping"; 23 | 24 | /** 25 | * Constant to indicate we should never match. 26 | * @type {any} 27 | */ 28 | export const DoNotSetAnyGoals: Goals = goals("no goals"); 29 | 30 | /** 31 | * Should be used in additive goal setting when no more goals should be scheduled. 32 | */ 33 | export const DoNotSetAnyGoalsAndLock: Goals = DoNotSetAnyGoals.andLock(); 34 | 35 | /** 36 | * Mapper from push to value, id it can be resolved. 37 | * This is a central interface used throughout the SDM. 38 | */ 39 | export interface PushMapping extends Mapping { 40 | 41 | } 42 | -------------------------------------------------------------------------------- /lib/api/mapping/support/PredicateMappingCostAnalyzer.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { PredicateMapping } from "../PredicateMapping"; 18 | 19 | /** 20 | * Classification of expected PredicateMapping cost 21 | */ 22 | export enum ExpectedPredicateMappingCost { 23 | cheap = "cheap", 24 | expensive = "expensive", 25 | unknown = "unknown", 26 | } 27 | 28 | /** 29 | * Function that can classify PredicateMappings by expected cost to evaluate 30 | */ 31 | export type PredicateMappingCostAnalyzer = (pm: PredicateMapping) => ExpectedPredicateMappingCost; 32 | -------------------------------------------------------------------------------- /lib/api/mapping/support/PredicateMappingTerm.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { 18 | isMapping, 19 | Mapper, 20 | } from "../Mapping"; 21 | import { PredicateMapping } from "../PredicateMapping"; 22 | 23 | /** 24 | * Predicate that can be used in predicate DSL. 25 | * Can be a PredicateMapping, a function or computed boolean 26 | */ 27 | export type PredicateMappingTerm = 28 | PredicateMapping | 29 | Mapper | 30 | (() => (boolean | Promise)); 31 | 32 | /** 33 | * Convert a PredicateMapping term to a PredicateMapping 34 | * @param {PredicateMappingTerm} p 35 | * @return {PredicateMapping} 36 | */ 37 | export function toPredicateMapping(p: PredicateMappingTerm): PredicateMapping { 38 | if (isMapping(p)) { 39 | return p; 40 | } 41 | return {name: p + "", mapping: p as any}; 42 | } 43 | -------------------------------------------------------------------------------- /lib/api/mapping/support/StaticPushMapping.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { PushMapping } from "../PushMapping"; 18 | import { PushTest } from "../PushTest"; 19 | 20 | /** 21 | * PushMapping that always returns the same value, guarded by a PushTest. 22 | * Return undefined if the PushTest doesn't match. 23 | */ 24 | export interface StaticPushMapping extends PushMapping { 25 | 26 | readonly pushTest: PushTest; 27 | 28 | /** 29 | * Value we always return 30 | */ 31 | readonly value: V; 32 | } 33 | -------------------------------------------------------------------------------- /lib/api/mapping/support/namedSeedRepo.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { 18 | pushTest, 19 | PushTest, 20 | } from "../PushTest"; 21 | 22 | /** 23 | * Is this a seed repo, based on the naming convention 24 | * that such repos have "-seed" in their name 25 | * @param {PushListenerInvocation} pi 26 | * @constructor 27 | */ 28 | export const NamedSeedRepo: PushTest = pushTest( 29 | "Named seed repo", 30 | async pi => pi.id.repo.includes("-seed")); 31 | -------------------------------------------------------------------------------- /lib/api/registration/AutofixRegistration.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { NoParameters } from "@atomist/automation-client/lib/SmartParameters"; 18 | import { CodeTransformOrTransforms } from "./CodeTransform"; 19 | import { PushSelector } from "./PushRegistration"; 20 | 21 | export interface AutofixRegistrationOptions { 22 | 23 | ignoreFailure: boolean; 24 | } 25 | 26 | /** 27 | * Register an autofix. This is a transform run on every commit that will make a 28 | * commit if necessary to the same branch. 29 | */ 30 | export interface AutofixRegistration

extends PushSelector { 31 | 32 | transform: CodeTransformOrTransforms

; 33 | 34 | options?: AutofixRegistrationOptions; 35 | 36 | /** 37 | * Parameters used for all transforms 38 | */ 39 | parametersInstance?: P; 40 | } 41 | -------------------------------------------------------------------------------- /lib/api/registration/CommandHandlerRegistration.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { NoParameters } from "@atomist/automation-client/lib/SmartParameters"; 18 | import { CommandListener } from "../listener/CommandListener"; 19 | import { CommandRegistration } from "./CommandRegistration"; 20 | 21 | /** 22 | * Type for registering a project edit, which can encapsulate changes 23 | * to projects. One of listener or createCommand function must be provided. 24 | */ 25 | export interface CommandHandlerRegistration extends CommandRegistration { 26 | 27 | /** 28 | * Callback executing the command 29 | */ 30 | listener: CommandListener; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /lib/api/registration/EventRegistrationManager.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { EventHandlerRegistration } from "../registration/EventHandlerRegistration"; 18 | 19 | /** 20 | * Manage event registrations. 21 | */ 22 | export interface EventRegistrationManager { 23 | 24 | /** 25 | * Add an event to this machine. 26 | * @param {EventHandlerRegistration} event 27 | * @returns {this} 28 | */ 29 | addEvent(event: EventHandlerRegistration): this; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /lib/api/registration/IngesterRegistration.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Type to register customer type ingesters. 3 | */ 4 | export interface IngesterRegistration { 5 | 6 | /** 7 | * Ingester GraphQL SDL 8 | * Note: use the ingester() method of automation-client to load the ingester graphql contents. 9 | */ 10 | ingester: string; 11 | } 12 | -------------------------------------------------------------------------------- /lib/api/registration/IngesterRegistrationManager.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { IngesterRegistration } from "../registration/IngesterRegistration"; 18 | 19 | /** 20 | * Manage ingester registrations. 21 | */ 22 | export interface IngesterRegistrationManager { 23 | 24 | /** 25 | * Add ingester to this machine. 26 | * @param {IngesterRegistration} ingester 27 | * @returns {this} 28 | */ 29 | addIngester(ingester: string | IngesterRegistration): this; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /lib/api/registration/ProjectOperationRegistration.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { CodeTransformOrTransforms } from "./CodeTransform"; 18 | import { CommandRegistration } from "./CommandRegistration"; 19 | 20 | /** 21 | * Superclass for all registrations of "project operations", 22 | * which can create or modify projects. Supply a transform function. 23 | */ 24 | export interface ProjectOperationRegistration extends CommandRegistration { 25 | 26 | /** 27 | * Function to transform the project 28 | */ 29 | transform: CodeTransformOrTransforms; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /lib/api/registration/PushAwareParametersInvocation.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { ProgressLog } from "../../spi/log/ProgressLog"; 18 | import { ParametersInvocation } from "../listener/ParametersInvocation"; 19 | import { PushImpactListenerInvocation } from "../listener/PushImpactListener"; 20 | 21 | /** 22 | * Code inspections or autofixes may be invoked in response to a push, 23 | * or just with Parameters 24 | */ 25 | export interface PushAwareParametersInvocation

extends ParametersInvocation

{ 26 | 27 | /** 28 | * The push invocation. Will be undefined if we are not invoked from a push. 29 | */ 30 | push?: PushImpactListenerInvocation; 31 | 32 | /** 33 | * Optional ProgressLog to log to 34 | */ 35 | progressLog?: ProgressLog; 36 | } 37 | -------------------------------------------------------------------------------- /lib/api/registration/PushRegistration.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { PushTest } from "../mapping/PushTest"; 18 | 19 | /** 20 | * Extended by any object that can react to a subset of pushes. 21 | */ 22 | export interface PushSelector { 23 | 24 | name: string; 25 | 26 | pushTest?: PushTest; 27 | } 28 | 29 | /** 30 | * Superclass for registering actions or listeners associated with a push 31 | */ 32 | export interface PushRegistration extends PushSelector { 33 | 34 | action: A; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /lib/api/registration/ReviewListenerRegistration.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { ReviewListener } from "../listener/ReviewListener"; 18 | 19 | /** 20 | * Register a listener that can respond to reviews 21 | */ 22 | export interface ReviewListenerRegistration { 23 | 24 | name: string; 25 | 26 | listener: ReviewListener; 27 | } 28 | -------------------------------------------------------------------------------- /lib/api/registration/ReviewerError.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as slack from "@atomist/slack-messages"; 18 | 19 | export class ReviewerError extends Error { 20 | constructor(public reviewerName: string, msg: string, public stderr: string) { 21 | super(msg); 22 | } 23 | } 24 | 25 | export function formatReviewerError(err: ReviewerError): slack.SlackMessage { 26 | // I'd like to include a reference to the commit here 27 | const attachment: slack.Attachment = { 28 | color: "#bd4024", 29 | fallback: err.message, 30 | text: err.message, 31 | title: err.reviewerName + " failed to run", 32 | }; 33 | 34 | return { attachments: [attachment]}; 35 | } 36 | -------------------------------------------------------------------------------- /lib/api/registration/ReviewerRegistration.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { ProjectReview } from "@atomist/automation-client/lib/operations/review/ReviewResult"; 18 | import { NoParameters } from "@atomist/automation-client/lib/SmartParameters"; 19 | import { AutoInspectRegistration } from "./AutoInspectRegistration"; 20 | 21 | /** 22 | * Register a reviewer. This can return structured data based on a project. 23 | */ 24 | export interface ReviewerRegistration 25 | extends AutoInspectRegistration { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /lib/api/registration/ServiceRegistration.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { RepoContext } from "../context/SdmContext"; 18 | import { SdmGoalEvent } from "../goal/SdmGoalEvent"; 19 | 20 | /** 21 | * Key under which services can be found in goal data. 22 | */ 23 | export const ServiceRegistrationGoalDataKey = "@atomist/sdm/service"; 24 | 25 | /** 26 | * Register additional services for a goal. 27 | * This can be used to add additional containers into k8s jobs to use during goal execution. 28 | */ 29 | export interface ServiceRegistration { 30 | name: string; 31 | service: (goalEvent: SdmGoalEvent, repo: RepoContext) => Promise<{ type: string, spec: T } | undefined>; 32 | } 33 | -------------------------------------------------------------------------------- /lib/api/registration/TriggeredListenerRegistration.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { TriggeredListener } from "../listener/TriggeredListener"; 18 | 19 | /** 20 | * Register a TriggeredListener 21 | */ 22 | export interface TriggeredListenerRegistration { 23 | 24 | /** 25 | * Trigger can be a cron expression as string and/or a interval in milliseconds 26 | */ 27 | trigger: { 28 | cron?: string; 29 | interval?: number; 30 | }; 31 | 32 | /** 33 | * Listener to invoke when the trigger fires 34 | */ 35 | listener: TriggeredListener; 36 | } 37 | -------------------------------------------------------------------------------- /lib/core/delivery/build/local/projectIdentifier.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Project } from "@atomist/automation-client/lib/project/Project"; 18 | 19 | export interface ProjectIdentification { 20 | name: string; 21 | version: string; 22 | } 23 | 24 | /** 25 | * Return identification of this project or undefined if it can't be identified 26 | * @ModuleExport 27 | */ 28 | export type ProjectIdentifier = (p: Project) => Promise; 29 | -------------------------------------------------------------------------------- /lib/core/delivery/goals/support/validateGoal.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { automationClientInstance } from "@atomist/automation-client/lib/globals"; 18 | import { SdmGoalEvent } from "../../../../api/goal/SdmGoalEvent"; 19 | 20 | export function shouldHandle(sdmGoal: SdmGoalEvent, 21 | registration: string = automationClientInstance().configuration.name): boolean { 22 | const provenance = sdmGoal.registration; 23 | return provenance === registration || registration.startsWith(`${provenance}-job`); 24 | } 25 | 26 | export function shouldFulfill(sdmGoal: SdmGoalEvent, 27 | registration: string = automationClientInstance().configuration.name): boolean { 28 | const provenance = sdmGoal.fulfillment.registration; 29 | return provenance === registration || registration.startsWith(`${provenance}-job`); 30 | } 31 | -------------------------------------------------------------------------------- /lib/core/goal/container/encrypt.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { loadUserConfiguration } from "@atomist/automation-client/lib/configuration"; 18 | import * as crypto from "crypto"; 19 | 20 | async function encrypt(data: string): Promise { 21 | const cfg = loadUserConfiguration(); 22 | const encryptionCfp = cfg.sdm.encryption; 23 | if (!encryptionCfp) { 24 | throw new Error("Encryption configuration missing to encrypt secret"); 25 | } 26 | const e = crypto.publicEncrypt(encryptionCfp.publicKey, Buffer.from(data, "utf8")); 27 | // tslint:disable-next-line:no-console 28 | console.log(e.toString("base64")); 29 | } 30 | // tslint:disable-next-line:no-floating-promises 31 | encrypt(process.argv[2]); 32 | -------------------------------------------------------------------------------- /lib/core/ingesters/sdmDeployEnablement.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export const DeployEnablementRootType = "SdmDeployEnablement"; 18 | 19 | export interface SdmDeployEnablement { 20 | state: "requested" | "disabled"; 21 | owner: string; 22 | repo: string; 23 | providerId: string; 24 | } 25 | -------------------------------------------------------------------------------- /lib/core/ingesters/sdmVersionIngester.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export interface SdmVersion { 18 | sha: string; 19 | branch: string; 20 | repo: { 21 | name: string; 22 | owner: string; 23 | providerId: string; 24 | }; 25 | version: string; 26 | } 27 | -------------------------------------------------------------------------------- /lib/core/machine/InvokeSdmStartupListenersAutomationEventListener.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { AutomationEventListenerSupport } from "@atomist/automation-client/lib/server/AutomationEventListener"; 18 | import { AbstractSoftwareDeliveryMachine } from "../../api-helper/machine/AbstractSoftwareDeliveryMachine"; 19 | import { SoftwareDeliveryMachine } from "../../api/machine/SoftwareDeliveryMachine"; 20 | 21 | /** 22 | * AutomationEventListener that notifies the SDM StartupListeners that this SDM has been 23 | * successfully started up 24 | */ 25 | export class InvokeSdmStartupListenersAutomationEventListener extends AutomationEventListenerSupport { 26 | 27 | constructor(private readonly sdm: SoftwareDeliveryMachine) { 28 | super(); 29 | } 30 | 31 | public startupSuccessful(): Promise { 32 | if ((this.sdm as AbstractSoftwareDeliveryMachine).notifyStartupListeners) { 33 | return (this.sdm as AbstractSoftwareDeliveryMachine).notifyStartupListeners(); 34 | } 35 | return Promise.resolve(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/core/machine/modes.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { PushTest } from "../../api/mapping/PushTest"; 18 | 19 | /** 20 | * Is this SDM in local mode? 21 | * Invoked on client startup. 22 | */ 23 | export function isInLocalMode(): boolean { 24 | return process.env.ATOMIST_MODE === "local"; 25 | } 26 | 27 | /** 28 | * Is this SDM running in local mode? 29 | */ 30 | export const IsInLocalMode: PushTest = { 31 | name: "IsInLocalMode", 32 | mapping: async () => isInLocalMode(), 33 | }; 34 | 35 | /** 36 | * Is this SDM running as a GitHub action? 37 | * Invoked on client startup. 38 | */ 39 | export function isGitHubAction(): boolean { 40 | return !!process.env.GITHUB_WORKFLOW && !!process.env.GITHUB_ACTION && !!process.env.GITHUB_WORKSPACE; 41 | } 42 | 43 | /** 44 | * Is this SDM running as a GitHub action? 45 | */ 46 | export const IsGitHubAction: PushTest = { 47 | name: "IsGitHubAction", 48 | mapping: async () => isGitHubAction(), 49 | }; 50 | -------------------------------------------------------------------------------- /lib/core/mapping/pushtest/toPublicRepo.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { isGitHubRepoRef } from "@atomist/automation-client/lib/operations/common/GitHubRepoRef"; 18 | import { 19 | pushTest, 20 | PushTest, 21 | } from "../../../api/mapping/PushTest"; 22 | import { isPublicRepo } from "../../util/github/ghub"; 23 | 24 | /** 25 | * Match only pushes on a public repo 26 | * @param {PushListenerInvocation} p 27 | * @return {Promise} 28 | * @constructor 29 | */ 30 | export const ToPublicRepo: PushTest = pushTest("To public repo", async p => 31 | // Ask GitHub if the repo is public as we do not have this information in our model 32 | isGitHubRepoRef(p.id) && isPublicRepo(p.credentials, p.id), 33 | ); 34 | -------------------------------------------------------------------------------- /lib/core/signing/atomist-public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsSYx6eesfz8YrKBAKpsr 3 | 7T3xbQtmNbk6nQTLKvpHDnijcf3Sjn/4UPsxrqOEKz3nbRfeXBLCBW1iD3ftOTHa 4 | xxnu8Q3wvxfgGx0PQo8pqTB/eJi56F4GgBjH1mwgoKDTYriKIggNdkPILlfRKz3k 5 | YKYfAsSKgM8hzT3WLE+UQp4msWff/0/ZLRm1uBUquijPir7ZmhAQjfILdR7Hv/Y2 6 | DDA500/eT7rNCOroi0zAPSLcSenS1BFfA8eCaz01H6BfAuA38YZPYJaRN4ZkAGvj 7 | RFUy7o27f87itTK7kx2vrap69YDukuPsxytfSa9QYFFaqqs2Wa1jd+KYULuPSwEn 8 | gwIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /lib/core/util/github/gitHubProvider.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { HandlerContext } from "@atomist/automation-client/lib/HandlerContext"; 18 | import { ScmProvider } from "../../../typings/types"; 19 | 20 | export const GitHubDotComProviderId = "zjlmxjzwhurspem"; 21 | 22 | export async function fetchProvider(context: HandlerContext, providerId: string): Promise { 23 | const results = await context.graphClient.query( 24 | { name: "ScmProvider", variables: { providerId } }); 25 | 26 | if (!results || !results.SCMProvider || results.SCMProvider.length === 0) { 27 | throw new Error("Provider not found: " + providerId); 28 | } 29 | return results.SCMProvider[0]; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /lib/core/util/github/tagRepo.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { isGitHubRepoRef } from "@atomist/automation-client/lib/operations/common/GitHubRepoRef"; 18 | import { Tagger } from "@atomist/automation-client/lib/operations/tagger/Tagger"; 19 | import { PushListener } from "../../../api/listener/PushListener"; 20 | import { publishTags } from "../../repo/publishTags"; 21 | 22 | /** 23 | * Tag the repo using the given tagger 24 | * @param {Tagger} tagger 25 | * @ModuleExport 26 | */ 27 | export function tagRepo(tagger: Tagger): PushListener { 28 | return async pInv => 29 | isGitHubRepoRef(pInv.id) ? 30 | publishTags(tagger, pInv.id, pInv.credentials, pInv.addressChannels, pInv.context) : 31 | true; 32 | } 33 | -------------------------------------------------------------------------------- /lib/core/util/misc/array.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export function toArray(value: T | T[]): T[] { 18 | if (!!value) { 19 | if (Array.isArray(value)) { 20 | return value; 21 | } else { 22 | return [value]; 23 | } 24 | } else { 25 | return undefined; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/core/util/misc/time.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export function formatDuration(duration: number, format: string = "d[d] h[h] m[m] s[s]"): string { 18 | const moment = require("moment"); 19 | // The following require is needed to initialize the format function 20 | const momentDurationFormatSetup = require("moment-duration-format"); 21 | momentDurationFormatSetup(moment); 22 | 23 | return moment.duration(duration, "millisecond").format(format, { trim: "both"}); 24 | } 25 | -------------------------------------------------------------------------------- /lib/graphql/fragment/CoreCommitFields.graphql: -------------------------------------------------------------------------------- 1 | fragment CoreCommitFields on Commit { 2 | url 3 | sha 4 | message 5 | timestamp 6 | committer { 7 | person { 8 | ...PersonFields 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/graphql/fragment/CoreRepoFieldsAndChannels.graphql: -------------------------------------------------------------------------------- 1 | fragment CoreRepoFieldsAndChannels on Repo { 2 | id 3 | url 4 | owner 5 | name 6 | org { 7 | id 8 | owner 9 | ownerType 10 | provider { 11 | providerId 12 | providerType 13 | apiUrl 14 | url 15 | } 16 | } 17 | channels { 18 | team { 19 | id 20 | } 21 | name 22 | id 23 | channelId 24 | } 25 | defaultBranch 26 | } 27 | -------------------------------------------------------------------------------- /lib/graphql/fragment/PersonFields.graphql: -------------------------------------------------------------------------------- 1 | fragment PersonFields on Person { 2 | forename 3 | surname 4 | name 5 | emails { 6 | address 7 | } 8 | gitHubId { 9 | login 10 | } 11 | chatId { 12 | screenName 13 | chatTeam { 14 | id 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/graphql/fragment/PushFields.graphql: -------------------------------------------------------------------------------- 1 | fragment PushFields on Push { 2 | id 3 | timestamp 4 | branch 5 | before { 6 | url 7 | sha 8 | message 9 | committer { 10 | login 11 | person { 12 | ...PersonFields 13 | } 14 | } 15 | } 16 | after @required { 17 | url 18 | sha 19 | message 20 | author { 21 | login 22 | name 23 | emails { 24 | address 25 | } 26 | person { 27 | ...PersonFields 28 | } 29 | } 30 | committer { 31 | login 32 | name 33 | emails { 34 | address 35 | } 36 | person { 37 | ...PersonFields 38 | } 39 | } 40 | image { 41 | image 42 | imageName 43 | } 44 | images { 45 | image 46 | imageName 47 | } 48 | tags { 49 | name 50 | description 51 | timestamp 52 | release { 53 | name 54 | timestamp 55 | } 56 | } 57 | } 58 | repo { 59 | ...CoreRepoFieldsAndChannels 60 | } 61 | commits { 62 | url 63 | sha 64 | timestamp 65 | message 66 | author { 67 | login 68 | name 69 | person { 70 | ...PersonFields 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /lib/graphql/fragment/ScmProviderFields.graphql: -------------------------------------------------------------------------------- 1 | fragment ScmProviderFields on SCMProvider { 2 | apiUrl 3 | credential { 4 | secret 5 | } 6 | providerId 7 | providerType 8 | url 9 | } 10 | -------------------------------------------------------------------------------- /lib/graphql/fragment/SdmGoalFields.graphql: -------------------------------------------------------------------------------- 1 | fragment SdmGoalFields on SdmGoal { 2 | environment 3 | uniqueName 4 | name 5 | sha 6 | branch 7 | fulfillment { 8 | method 9 | registration 10 | name 11 | } 12 | description 13 | url 14 | externalUrl 15 | externalUrls { 16 | label 17 | url 18 | } 19 | state 20 | phase 21 | externalKey 22 | goalSet 23 | registration 24 | goalSetId 25 | ts 26 | error 27 | retryFeasible 28 | preConditions { 29 | environment 30 | uniqueName 31 | name 32 | } 33 | approval { 34 | correlationId 35 | registration 36 | name 37 | version 38 | ts 39 | userId 40 | channelId 41 | } 42 | approvalRequired 43 | preApproval { 44 | correlationId 45 | registration 46 | name 47 | version 48 | ts 49 | userId 50 | channelId 51 | } 52 | preApprovalRequired 53 | provenance { 54 | correlationId 55 | registration 56 | name 57 | version 58 | ts 59 | userId 60 | channelId 61 | } 62 | descriptions { 63 | canceled 64 | completed 65 | failed 66 | inProcess 67 | planned 68 | requested 69 | stopped 70 | skipped 71 | waitingForApproval 72 | waitingForPreApproval 73 | } 74 | parameters 75 | data 76 | push { 77 | ...PushFields 78 | } 79 | version 80 | signature 81 | } 82 | -------------------------------------------------------------------------------- /lib/graphql/fragment/SdmGoalRepo.graphql: -------------------------------------------------------------------------------- 1 | fragment SdmGoalRepo on SdmGoal { 2 | repo { 3 | name 4 | owner 5 | providerId 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/graphql/fragment/SdmGoalSetFields.graphql: -------------------------------------------------------------------------------- 1 | fragment SdmGoalSetFields on SdmGoalSet { 2 | sha 3 | branch 4 | goalSet 5 | goalSetId 6 | goals { 7 | name 8 | uniqueName 9 | } 10 | provenance { 11 | channelId 12 | correlationId 13 | name 14 | registration 15 | ts 16 | userId 17 | version 18 | } 19 | repo { 20 | name 21 | owner 22 | providerId 23 | } 24 | state 25 | tags { 26 | name 27 | value 28 | } 29 | ts 30 | } 31 | -------------------------------------------------------------------------------- /lib/graphql/mutation/CreateJob.graphql: -------------------------------------------------------------------------------- 1 | mutation CreateJob( 2 | $data: String! 3 | $name: String! 4 | $description: String! 5 | $owner: String! 6 | $concurrentTasks: Int 7 | $tasks: [AtmJobTaskInput!]! 8 | ) { 9 | createAtmJob( 10 | jobInput: { 11 | data: $data 12 | name: $name 13 | description: $description 14 | owner: $owner 15 | jobTasks: $tasks 16 | maxRunningTasks: $concurrentTasks 17 | initialState: preparing 18 | } 19 | ) { 20 | id 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/graphql/mutation/DeleteResourceProvider.graphql: -------------------------------------------------------------------------------- 1 | mutation DeleteResourceProvider($id: ID!) { 2 | deleteResourceProvider(id: $id) 3 | } 4 | -------------------------------------------------------------------------------- /lib/graphql/mutation/DeleteTeamConfiguration.graphql: -------------------------------------------------------------------------------- 1 | mutation DeleteTeamConfiguration($namespace: String!, $name: String!) { 2 | deleteTeamConfiguration(namespace: $namespace, name: $name) { 3 | name 4 | namespace 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /lib/graphql/mutation/SetJobTaskState.graphql: -------------------------------------------------------------------------------- 1 | mutation SetJobTaskState($id: ID!, $state: AtmJobTaskStateInput!) { 2 | setAtmJobTaskState(id: $id, jobTaskState: $state) { 3 | id 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/graphql/mutation/SetResourceProviderState.graphql: -------------------------------------------------------------------------------- 1 | mutation SetResourceProviderState( 2 | $id: ID! 3 | $state: ResourceProviderStateName! 4 | $error: String! 5 | ) { 6 | setResourceProviderState( 7 | id: $id 8 | providerState: { state: $state, error: $error } 9 | ) { 10 | id 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/graphql/mutation/SetTeamConfiguration.graphql: -------------------------------------------------------------------------------- 1 | mutation SetTeamConfiguration( 2 | $namespace: String! 3 | $name: String! 4 | $value: String! 5 | $ttl: Int 6 | ) { 7 | setTeamConfiguration( 8 | namespace: $namespace 9 | name: $name 10 | value: $value 11 | ttlSecs: $ttl 12 | ) { 13 | name 14 | namespace 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/graphql/mutation/UpdateGoal.graphql: -------------------------------------------------------------------------------- 1 | mutation UpdateSdmGoal($goal: CustomSdmGoalInput!) { 2 | ingestCustomSdmGoal(value: $goal) 3 | } 4 | -------------------------------------------------------------------------------- /lib/graphql/mutation/UpdateGoalSet.graphql: -------------------------------------------------------------------------------- 1 | mutation UpdateSdmGoalSet($goalSet: CustomSdmGoalSetInput!) { 2 | ingestCustomSdmGoalSet(value: $goalSet) 3 | } 4 | -------------------------------------------------------------------------------- /lib/graphql/mutation/UpdateSdmVersion.graphql: -------------------------------------------------------------------------------- 1 | mutation UpdateSdmVersion($version: CustomSdmVersionInput!) { 2 | ingestCustomSdmVersion(value: $version) 3 | } 4 | -------------------------------------------------------------------------------- /lib/graphql/mutation/addTasks.graphql: -------------------------------------------------------------------------------- 1 | mutation AddJobTasks($id: String!, $tasks: [AtmJobTaskInput!]!) { 2 | addAtmJobTasks(jobId: $id, jobTasks: $tasks) { 3 | id 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/graphql/mutation/resumeJob.graphql: -------------------------------------------------------------------------------- 1 | mutation ResumeJob($id: String!) { 2 | resumeAtmJob(jobId: $id) { 3 | id 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/graphql/query/BinaryRepositoryProvider.graphql: -------------------------------------------------------------------------------- 1 | query BinaryRepositoryProvider($name: String, $type: BinaryRepositoryType) { 2 | BinaryRepositoryProvider(name: $name, type: $type) { 3 | url 4 | name 5 | state { 6 | error 7 | name 8 | } 9 | credential { 10 | owner { 11 | login 12 | } 13 | id 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/graphql/query/BranchForName.graphql: -------------------------------------------------------------------------------- 1 | query BranchForName($repo: String!, $owner: String!, $branch: String!) { 2 | Branch(name: $branch) { 3 | id 4 | repo(name: $repo, owner: $owner) @required { 5 | id 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /lib/graphql/query/BuildUrlBySha.graphql: -------------------------------------------------------------------------------- 1 | query BuildUrlBySha($sha: String!) { 2 | Commit(sha: $sha) { 3 | builds { 4 | status 5 | buildUrl 6 | timestamp 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/graphql/query/CanceledSdmGoal.graphql: -------------------------------------------------------------------------------- 1 | query CanceledSdmGoal($goalSetId: String!, $uniqueName: String!) { 2 | SdmGoal( 3 | goalSetId: [$goalSetId] 4 | uniqueName: [$uniqueName] 5 | state: [canceled] 6 | _showHistory: true 7 | ) { 8 | id 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/graphql/query/CommitForSdmGoal.graphql: -------------------------------------------------------------------------------- 1 | query CommitForSdmGoal( 2 | $sha: String! 3 | $repo: String! 4 | $owner: String! 5 | $branch: String! 6 | ) { 7 | Commit(sha: $sha) { 8 | sha 9 | message 10 | statuses { 11 | context 12 | description 13 | state 14 | targetUrl 15 | } 16 | repo(name: $repo, owner: $owner) @required { 17 | ...CoreRepoFieldsAndChannels 18 | } 19 | pushes(branch: $branch) { 20 | ...PushFields 21 | } 22 | image { 23 | image 24 | imageName 25 | } 26 | images { 27 | image 28 | imageName 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/graphql/query/DockerRegistryProvider.graphql: -------------------------------------------------------------------------------- 1 | query DockerRegistryProvider($name: String) { 2 | DockerRegistryProvider(name: $name) { 3 | url 4 | name 5 | state { 6 | error 7 | name 8 | } 9 | credential { 10 | owner { 11 | login 12 | } 13 | id 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/graphql/query/DockerRegistryProviderAll.graphql: -------------------------------------------------------------------------------- 1 | query DockerRegistryProviderAll { 2 | DockerRegistryProvider { 3 | url 4 | name 5 | credential { 6 | id 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/graphql/query/GenericResourceProvider.graphql: -------------------------------------------------------------------------------- 1 | query GenericResourceProvider($name: String, $type: String!) { 2 | GenericResourceProvider(name: $name, type: $type) { 3 | url 4 | name 5 | credential { 6 | id 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/graphql/query/GitHubAppInstallationByOwner.graphql: -------------------------------------------------------------------------------- 1 | query GitHubAppInstallationByOwner($name: String) { 2 | GitHubAppInstallation(owner: $name) { 3 | token { 4 | secret 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/graphql/query/GitHubAppResourceProvider.graphql: -------------------------------------------------------------------------------- 1 | query GitHubAppResourceProvider { 2 | GitHubAppResourceProvider { 3 | id 4 | providerId 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /lib/graphql/query/GitHubLogin.graphql: -------------------------------------------------------------------------------- 1 | query GitHubLogin($userId: String!, $owner: String!, $providerId: String!) { 2 | Team { 3 | chatTeams { 4 | members(screenName: $userId) @required { 5 | person @required { 6 | gitHubId { 7 | login 8 | } 9 | } 10 | } 11 | } 12 | orgs(owner: $owner) @required { 13 | provider(providerId: $providerId) @required { 14 | apiUrl 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/graphql/query/InProcessSdmGoalSets.graphql: -------------------------------------------------------------------------------- 1 | query InProcessSdmGoalSets( 2 | $fetch: Int! 3 | $registration: [String!] 4 | $offset: Int! 5 | ) { 6 | SdmGoalSet( 7 | _orderBy: "ts" 8 | _ordering: asc 9 | _first: $fetch 10 | _offset: $offset 11 | state: [pre_approved, requested, approved, planned, in_process] 12 | ) { 13 | sha 14 | branch 15 | goalSet 16 | goalSetId 17 | goals { 18 | name 19 | uniqueName 20 | } 21 | provenance(registration: $registration) @required { 22 | channelId 23 | correlationId 24 | name 25 | registration 26 | ts 27 | userId 28 | version 29 | } 30 | repo { 31 | name 32 | owner 33 | providerId 34 | } 35 | state 36 | tags { 37 | name 38 | value 39 | } 40 | ts 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/graphql/query/LastEndpoint.graphql: -------------------------------------------------------------------------------- 1 | query LastEndpoint( 2 | $name: String! 3 | $owner: String! 4 | $branch: String! 5 | $statusContext: String! 6 | ) { 7 | Repo(owner: $owner, name: $name) { 8 | branches(name: $branch) { 9 | commit @required { 10 | sha 11 | statuses(context: $statusContext) { 12 | context 13 | description 14 | state 15 | targetUrl 16 | } 17 | pushes(first: 1, orderBy: [timestamp_desc]) { 18 | id 19 | } 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/graphql/query/Password.graphql: -------------------------------------------------------------------------------- 1 | query Password($id: ID!) { 2 | Password(id: $id) { 3 | owner { 4 | login 5 | } 6 | secret 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /lib/graphql/query/PersonByChatId.graphql: -------------------------------------------------------------------------------- 1 | query PersonByChatId($screenName: String!) { 2 | ChatId(screenName: $screenName) { 3 | userId 4 | screenName 5 | person @required { 6 | ...PersonFields 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/graphql/query/PersonQuery.graphql: -------------------------------------------------------------------------------- 1 | # deprecated, use PersonByChatId 2 | query PersonQuery($screenName: String!) { 3 | ChatId(screenName: $screenName) { 4 | userId 5 | screenName 6 | person @required { 7 | ...PersonFields 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/graphql/query/PullRequestForSha.graphql: -------------------------------------------------------------------------------- 1 | query PullRequestForSha($owner: String!, $repo: String!, $sha: String!) { 2 | PullRequest { 3 | name 4 | title 5 | body 6 | id 7 | number 8 | author { 9 | person { 10 | chatId { 11 | screenName 12 | } 13 | } 14 | } 15 | repo(owner: $owner, name: $repo) @required { 16 | ...CoreRepoFieldsAndChannels 17 | } 18 | head(sha: $sha) @required { 19 | message 20 | } 21 | base { 22 | sha 23 | message 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/graphql/query/PullRequestsForBranch.graphql: -------------------------------------------------------------------------------- 1 | query PullRequestsForBranch($owner: String!, $repo: String!, $branch: String!) { 2 | Repo(owner: $owner, name: $repo) { 3 | branches(name: $branch) { 4 | name 5 | pullRequests { 6 | state 7 | } 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/graphql/query/PushForCommit.graphql: -------------------------------------------------------------------------------- 1 | query PushForCommit( 2 | $sha: String! 3 | $repo: String! 4 | $owner: String! 5 | $providerId: String! 6 | $branch: String! 7 | ) { 8 | Commit(sha: $sha) { 9 | pushes(branch: $branch) { 10 | ...PushFields 11 | } 12 | repo(owner: $owner, name: $repo) @required { 13 | org @required { 14 | provider(providerId: $providerId) @required { 15 | providerId 16 | } 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/graphql/query/PushForSdmGoal.graphql: -------------------------------------------------------------------------------- 1 | query PushForSdmGoal( 2 | $owner: String! 3 | $repo: String! 4 | $providerId: String! 5 | $branch: String! 6 | $sha: String! 7 | ) { 8 | Commit(sha: $sha) { 9 | pushes(branch: $branch) { 10 | id 11 | timestamp 12 | branch 13 | before { 14 | sha 15 | message 16 | committer { 17 | login 18 | person { 19 | ...PersonFields 20 | } 21 | } 22 | } 23 | after(sha: $sha) { 24 | sha 25 | message 26 | committer { 27 | login 28 | person { 29 | ...PersonFields 30 | } 31 | } 32 | } 33 | commits { 34 | sha 35 | timestamp 36 | message 37 | author { 38 | login 39 | name 40 | } 41 | } 42 | repo(owner: $owner, name: $repo) @required { 43 | owner 44 | name 45 | org { 46 | owner 47 | ownerType 48 | provider(providerId: $providerId) @required { 49 | providerId 50 | providerType 51 | apiUrl 52 | url 53 | } 54 | } 55 | channels { 56 | team { 57 | id 58 | } 59 | name 60 | id 61 | } 62 | defaultBranch 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/graphql/query/RepoBranchTips.graphql: -------------------------------------------------------------------------------- 1 | query RepoBranchTips($name: String!, $owner: String!) { 2 | Repo(name: $name, owner: $owner) { 3 | owner 4 | org { 5 | provider { 6 | providerId 7 | } 8 | } 9 | defaultBranch 10 | branches { 11 | name 12 | commit { 13 | sha 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/graphql/query/RepoScmProvider.graphql: -------------------------------------------------------------------------------- 1 | query RepoScmProvider($repo: String!, $owner: String!) { 2 | Repo(name: $repo, owner: $owner) { 3 | branches { 4 | name 5 | } 6 | defaultBranch 7 | name 8 | org { 9 | owner 10 | ownerType 11 | scmProvider { 12 | ...ScmProviderFields 13 | } 14 | } 15 | owner 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/graphql/query/ReposInTeam.graphql: -------------------------------------------------------------------------------- 1 | query ReposInTeam($offset: Int!, $size: Int!) { 2 | ChatTeam { 3 | orgs { 4 | repo(first: $size, offset: $offset) { 5 | name 6 | owner 7 | org { 8 | provider { 9 | providerType 10 | apiUrl 11 | } 12 | } 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/graphql/query/RepositoryByOwnerAndName.graphql: -------------------------------------------------------------------------------- 1 | query RepositoryByOwnerAndName($owner: String, $name: String) { 2 | Repo(owner: $owner, name: $name) { 3 | id 4 | name 5 | owner 6 | org { 7 | provider { 8 | providerId 9 | providerType 10 | apiUrl 11 | url 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/graphql/query/RepositoryMappedChannels.graphql: -------------------------------------------------------------------------------- 1 | query RepositoryMappedChannels($id: String!) { 2 | ChatChannel(channelId: $id) { 3 | repos { 4 | id 5 | name 6 | owner 7 | org { 8 | provider { 9 | providerId 10 | providerType 11 | apiUrl 12 | url 13 | } 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/graphql/query/ResourceUser.graphql: -------------------------------------------------------------------------------- 1 | query ResourceUser($id: String!) { 2 | ChatId(userId: $id) { 3 | person { 4 | gitHubId { 5 | login 6 | credential { 7 | secret 8 | scopes 9 | } 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/graphql/query/ScmProvider.graphql: -------------------------------------------------------------------------------- 1 | query ScmProvider($providerId: String!) { 2 | SCMProvider(providerId: $providerId) { 3 | providerType 4 | url 5 | providerId 6 | apiUrl 7 | credential { 8 | secret 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/graphql/query/ScmProviderByType.graphql: -------------------------------------------------------------------------------- 1 | query ScmProviderByType($providerType: ProviderType!) { 2 | SCMProvider(providerType: $providerType) { 3 | providerId 4 | apiUrl 5 | credential { 6 | secret 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/graphql/query/ScmProviders.graphql: -------------------------------------------------------------------------------- 1 | query ScmProviders { 2 | SCMProvider { 3 | ...ScmProviderFields 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/graphql/query/SdmGoalByGoalSetIdAndUniqueName.graphql: -------------------------------------------------------------------------------- 1 | query SdmGoalsByGoalSetIdAndUniqueName( 2 | $goalSetId: [String!] 3 | $uniqueName: [String] 4 | ) { 5 | SdmGoal(goalSetId: $goalSetId, uniqueName: $uniqueName) { 6 | ...SdmGoalFields 7 | ...SdmGoalRepo 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/graphql/query/SdmGoalSetForId.graphql: -------------------------------------------------------------------------------- 1 | query SdmGoalSetForId($goalSetId: [String!]) { 2 | SdmGoalSet(goalSetId: $goalSetId) { 3 | ...SdmGoalSetFields 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/graphql/query/SdmGoalsForCommit.graphql: -------------------------------------------------------------------------------- 1 | query SdmGoalsForCommit( 2 | $sha: String! 3 | $branch: String 4 | $repo: String! 5 | $owner: String! 6 | $providerId: String! 7 | $goalSetId: String 8 | $qty: Int! 9 | $offset: Int! 10 | ) { 11 | SdmGoal( 12 | sha: [$sha] 13 | branch: [$branch] 14 | goalSetId: [$goalSetId] 15 | _first: $qty 16 | _offset: $offset 17 | _orderBy: "ts" 18 | _ordering: asc 19 | _showHistory: true 20 | ) { 21 | id 22 | repo(name: [$repo], owner: [$owner], providerId: [$providerId]) @required { 23 | name 24 | owner 25 | providerId 26 | } 27 | ...SdmGoalFields 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/graphql/query/SdmPreferenceByKey.graphql: -------------------------------------------------------------------------------- 1 | query SdmPreferenceByKey($key: [String!]) { 2 | SdmPreference(key: $key) { 3 | key 4 | value 5 | ttl 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/graphql/query/SdmVersionForCommit.graphql: -------------------------------------------------------------------------------- 1 | query SdmVersionForCommit( 2 | $sha: [String!] 3 | $branch: [String!] 4 | $name: [String!] 5 | $owner: [String!] 6 | $providerId: [String!] 7 | ) { 8 | SdmVersion(sha: $sha, branch: $branch, _orderBy: "version") { 9 | repo(name: $name, owner: $owner, providerId: $providerId) { 10 | name 11 | owner 12 | providerId 13 | } 14 | version 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/graphql/query/TeamConfiguratoinByNamespace.graphql: -------------------------------------------------------------------------------- 1 | query TeamConfigurationByNamespace($namespace: String!) { 2 | TeamConfiguration(namespace: $namespace) { 3 | name 4 | namespace 5 | value 6 | ttlSecs 7 | createdAt 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/graphql/query/WhatIsRunning.graphql: -------------------------------------------------------------------------------- 1 | query WhatIsRunning($domain: String) { 2 | Application(state: "started", domain: $domain) { 3 | domain 4 | commits { 5 | sha 6 | repo { 7 | owner 8 | name 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnAnyApprovedSdmGoal.graphql: -------------------------------------------------------------------------------- 1 | subscription OnAnyApprovedSdmGoal($registration: [String]) { 2 | SdmGoal(state: [approved, pre_approved], registration: $registration) { 3 | ...SdmGoalFields 4 | ...SdmGoalRepo 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnAnyCompletedSdmGoal.graphql: -------------------------------------------------------------------------------- 1 | subscription OnAnyCompletedSdmGoal($registration: [String]) { 2 | SdmGoal( 3 | state: [ 4 | in_process 5 | failure 6 | success 7 | stopped 8 | canceled 9 | waiting_for_pre_approval 10 | waiting_for_approval 11 | ] 12 | registration: $registration 13 | ) { 14 | ...SdmGoalWithGoalsFields 15 | ...SdmGoalRepo 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnAnyFailedSdmGoal.graphql: -------------------------------------------------------------------------------- 1 | subscription OnAnyFailedSdmGoal($registration: [String]) { 2 | SdmGoal(state: [failure, stopped, canceled], registration: $registration) { 3 | ...SdmGoalWithGoalsFields 4 | ...SdmGoalRepo 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnAnyJobTask.graphql: -------------------------------------------------------------------------------- 1 | subscription OnAnyJobTask($registration: String) { 2 | AtmJobTask(owner: $registration, state: created) { 3 | id 4 | data 5 | name 6 | job { 7 | id 8 | data 9 | } 10 | state 11 | message 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnAnyRequestedSdmGoal.graphql: -------------------------------------------------------------------------------- 1 | subscription OnAnyRequestedSdmGoal { 2 | SdmGoal(state: [requested]) { 3 | id 4 | ...SdmGoalFields 5 | ...SdmGoalRepo 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnAnySdmGoalSet.graphql: -------------------------------------------------------------------------------- 1 | subscription OnAnySdmGoalSet($registration: [String!]) { 2 | SdmGoalSet { 3 | sha 4 | branch 5 | goalSet 6 | goalSetId 7 | goals { 8 | name 9 | uniqueName 10 | } 11 | provenance(registration: $registration) @required { 12 | channelId 13 | correlationId 14 | name 15 | registration 16 | ts 17 | userId 18 | version 19 | } 20 | repo { 21 | name 22 | owner 23 | providerId 24 | } 25 | state 26 | tags { 27 | name 28 | value 29 | } 30 | ts 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnAnySuccessfulSdmGoal.graphql: -------------------------------------------------------------------------------- 1 | subscription OnAnySuccessfulSdmGoal($registration: [String]) { 2 | SdmGoal(state: [success], registration: $registration) { 3 | ...SdmGoalWithGoalsFields 4 | ...SdmGoalRepo 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnBuildComplete.graphql: -------------------------------------------------------------------------------- 1 | subscription OnBuildComplete { 2 | Build { 3 | buildId 4 | buildUrl 5 | compareUrl 6 | name 7 | status 8 | jobId 9 | startedAt 10 | timestamp 11 | push { 12 | ...PushFields 13 | } 14 | commit { 15 | sha 16 | message 17 | timestamp 18 | repo { 19 | ...CoreRepoFieldsAndChannels 20 | } 21 | statuses { 22 | context 23 | description 24 | state 25 | targetUrl 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnBuildCompleteForDryRun.graphql: -------------------------------------------------------------------------------- 1 | subscription OnBuildCompleteForDryRun { 2 | Build { 3 | buildId 4 | buildUrl 5 | compareUrl 6 | name 7 | status 8 | commit { 9 | sha 10 | message 11 | repo { 12 | ...CoreRepoFieldsAndChannels 13 | } 14 | pushes { 15 | branch 16 | } 17 | statuses { 18 | context 19 | description 20 | state 21 | targetUrl 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnChannelLink.graphql: -------------------------------------------------------------------------------- 1 | subscription OnChannelLink { 2 | ChannelLink { 3 | repo { 4 | ...CoreRepoFieldsAndChannels 5 | } 6 | channel { 7 | team { 8 | id 9 | } 10 | name 11 | id 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnClosedIssue.graphql: -------------------------------------------------------------------------------- 1 | subscription OnClosedIssue { 2 | Issue(state: closed) { 3 | number 4 | title 5 | body 6 | openedBy { 7 | login 8 | person { 9 | ...PersonFields 10 | } 11 | } 12 | closedBy { 13 | login 14 | person { 15 | ...PersonFields 16 | } 17 | } 18 | createdAt 19 | updatedAt 20 | repo { 21 | ...CoreRepoFieldsAndChannels 22 | } 23 | assignees { 24 | login 25 | person { 26 | ...PersonFields 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnFirstPushToRepo.graphql: -------------------------------------------------------------------------------- 1 | subscription OnFirstPushToRepo { 2 | Push { 3 | ...PushFields 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnIssueAction.graphql: -------------------------------------------------------------------------------- 1 | subscription OnIssueAction { 2 | Issue { 3 | number 4 | title 5 | state 6 | body 7 | openedBy { 8 | login 9 | person { 10 | ...PersonFields 11 | } 12 | } 13 | createdAt 14 | updatedAt 15 | repo { 16 | ...CoreRepoFieldsAndChannels 17 | } 18 | assignees { 19 | login 20 | person { 21 | ...PersonFields 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnNewIssue.graphql: -------------------------------------------------------------------------------- 1 | # deprecated, use OnIssueAction 2 | subscription OnNewIssue { 3 | Issue { 4 | number 5 | title 6 | state 7 | body 8 | openedBy { 9 | login 10 | person { 11 | ...PersonFields 12 | } 13 | } 14 | createdAt 15 | updatedAt 16 | repo { 17 | ...CoreRepoFieldsAndChannels 18 | } 19 | assignees { 20 | login 21 | person { 22 | ...PersonFields 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnPullRequest.graphql: -------------------------------------------------------------------------------- 1 | subscription OnPullRequest { 2 | PullRequest { 3 | branch { 4 | name 5 | } 6 | title 7 | number 8 | body 9 | id 10 | base { 11 | sha 12 | message 13 | } 14 | action 15 | createdAt 16 | updatedAt 17 | mergeStatus 18 | author { 19 | login 20 | person { 21 | name 22 | chatId { 23 | screenName 24 | } 25 | } 26 | } 27 | head { 28 | sha 29 | message 30 | committer { 31 | login 32 | person { 33 | name 34 | chatId { 35 | screenName 36 | } 37 | } 38 | } 39 | pushes { 40 | before { 41 | sha 42 | message 43 | } 44 | commits { 45 | sha 46 | message 47 | } 48 | branch 49 | id 50 | repo { 51 | ...CoreRepoFieldsAndChannels 52 | } 53 | } 54 | } 55 | repo { 56 | ...CoreRepoFieldsAndChannels 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnPushToAnyBranch.graphql: -------------------------------------------------------------------------------- 1 | subscription OnPushToAnyBranch { 2 | Push { 3 | ...PushFields 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnRepoCreation.graphql: -------------------------------------------------------------------------------- 1 | subscription OnRepoCreation { 2 | Repo { 3 | owner 4 | name 5 | id 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnRepoOnboarded.graphql: -------------------------------------------------------------------------------- 1 | subscription OnRepoOnboarded { 2 | RepoOnboarded { 3 | repo { 4 | ...CoreRepoFieldsAndChannels 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnSpecificCanceledSdmGoal.graphql: -------------------------------------------------------------------------------- 1 | subscription OnSpecificCanceledSdmGoal( 2 | $goalSetId: String! 3 | $uniqueName: String! 4 | ) { 5 | SdmGoal( 6 | goalSetId: [$goalSetId] 7 | uniqueName: [$uniqueName] 8 | state: [canceled] 9 | ) { 10 | id 11 | uniqueName 12 | name 13 | state 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnSuccessStatus.graphql: -------------------------------------------------------------------------------- 1 | subscription OnSuccessStatus($context: String!) { 2 | Status(state: success, context: $context) { 3 | commit { 4 | sha 5 | message 6 | statuses { 7 | context 8 | description 9 | state 10 | } 11 | repo { 12 | ...CoreRepoFieldsAndChannels 13 | } 14 | pushes { 15 | branch 16 | } 17 | } 18 | state 19 | targetUrl 20 | context 21 | description 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnTag.graphql: -------------------------------------------------------------------------------- 1 | subscription OnTag { 2 | Tag { 3 | id 4 | name 5 | description 6 | timestamp 7 | release { 8 | name 9 | id 10 | timestamp 11 | } 12 | commit { 13 | sha 14 | message 15 | repo { 16 | ...CoreRepoFieldsAndChannels 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/graphql/subscription/OnUserJoiningChannel.graphql: -------------------------------------------------------------------------------- 1 | subscription OnUserJoiningChannel { 2 | UserJoinedChannel { 3 | user @required { 4 | screenName 5 | person @required { 6 | ...PersonFields 7 | } 8 | } 9 | channel { 10 | name 11 | repos { 12 | ...CoreRepoFieldsAndChannels 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/pack/aws/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export { S3CacheConfiguration, S3GoalCacheArchiveStore } from "./cache"; 18 | -------------------------------------------------------------------------------- /lib/pack/docker/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export { HasDockerfile } from "./support/dockerPushTests"; 18 | export { DockerImageNameCreator, executeDockerBuild, DefaultDockerImageNameCreator } from "./build/executeDockerBuild"; 19 | export { DockerBuild, DockerOptions, DockerRegistry } from "./build/DockerBuild"; 20 | export { DockerProgressReporter, DockerProgressTests } from "./build/DockerProgressReporter"; 21 | export { DockerFileParser } from "./parse/DockerFileParser"; 22 | -------------------------------------------------------------------------------- /lib/pack/docker/support/dockerPushTests.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { predicatePushTest, PredicatePushTest } from "../../../api/mapping/PushTest"; 18 | import { hasFile } from "../../../api/mapping/support/commonPushTests"; 19 | 20 | /** 21 | * Does this project have a Dockerfile 22 | */ 23 | export const HasDockerfile: PredicatePushTest = predicatePushTest("Has Dockerfile", hasFile("Dockerfile").predicate); 24 | -------------------------------------------------------------------------------- /lib/pack/github-goal-status/github.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { metadata } from "../../api-helper/misc/extensionPack"; 18 | import { ExtensionPack } from "../../api/machine/ExtensionPack"; 19 | import { isGitHubAction, isInLocalMode } from "../../core/machine/modes"; 20 | import { createPendingGitHubStatusOnGoalSet, setGitHubStatusOnGoalCompletion } from "./statusSetters"; 21 | 22 | /** 23 | * Manage a GitHub status per SDM 24 | */ 25 | export function githubGoalStatusSupport(): ExtensionPack { 26 | return { 27 | ...metadata("github-goal-status"), 28 | configure: sdm => { 29 | if (!isGitHubAction() && !isInLocalMode()) { 30 | sdm.addGoalsSetListener(createPendingGitHubStatusOnGoalSet(sdm)); 31 | sdm.addGoalCompletionListener(setGitHubStatusOnGoalCompletion(sdm)); 32 | } 33 | }, 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /lib/pack/github-goal-status/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export { githubGoalStatusSupport } from "./github"; 18 | -------------------------------------------------------------------------------- /lib/pack/goal-state/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export { goalStateSupport } from "./goalState"; 18 | -------------------------------------------------------------------------------- /lib/pack/info/exposeInfo.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { metadata } from "../../api-helper/misc/extensionPack"; 18 | import { ExtensionPack } from "../../api/machine/ExtensionPack"; 19 | import { selfDescribeCommand } from "./SelfDescribe"; 20 | 21 | /** 22 | * Expose information about this machine 23 | */ 24 | export function infoSupport(): ExtensionPack { 25 | return { 26 | ...metadata("info"), 27 | configure: sdm => { 28 | sdm.addCommand(selfDescribeCommand(sdm)); 29 | }, 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /lib/pack/info/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export { infoSupport } from "./exposeInfo"; 18 | -------------------------------------------------------------------------------- /lib/pack/job/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export { invokeCommand } from "./invokeCommand"; 18 | export { jobSupport } from "./job"; 19 | -------------------------------------------------------------------------------- /lib/pack/job/job.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { metadata } from "../../api-helper/misc/extensionPack"; 18 | import { ExtensionPack } from "../../api/machine/ExtensionPack"; 19 | import { executeTask } from "./executeTask"; 20 | 21 | /** 22 | * Extension pack installing job execution support into 23 | * the SDM 24 | * 25 | * This extension pack is installed by default. 26 | */ 27 | export function jobSupport(): ExtensionPack { 28 | return { 29 | ...metadata("job"), 30 | configure: sdm => { 31 | sdm.addEvent(executeTask(sdm)); 32 | }, 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /lib/pack/jvm/java/query/javaPathExpressions.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Entire package declaration, of form 'package com.foo.bar;' 19 | * @type {string} 20 | */ 21 | export const JavaPackage = "//packageDeclaration"; 22 | 23 | export const JavaImports = "//importDeclaration"; 24 | 25 | /** 26 | * Return path expression to full annotation node, without breaking down further 27 | * @param {string} name 28 | * @return {string} 29 | */ 30 | export function annotationsOnJavaClass(name: string): string { 31 | return `//typeDeclaration[/classDeclaration//Identifier[@value='${name}']]//annotation`; 32 | } 33 | 34 | export function javaClassDeclarationWithName(name: string): string { 35 | return `//typeDeclaration[//classDeclaration[//Identifier[@value='${name}']]]`; 36 | } 37 | -------------------------------------------------------------------------------- /lib/pack/jvm/maven/mavenCommand.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Project } from "@atomist/automation-client/lib/project/Project"; 18 | import * as os from "os"; 19 | 20 | export async function determineMavenCommand(p: Project): Promise { 21 | if (os.platform() === "win32") { 22 | if (process.env.JAVA_HOME && (await p.hasFile("mvnw.cmd"))) { 23 | return "mvnw"; 24 | } else { 25 | return "mvn"; 26 | } 27 | } else if (await p.hasFile("mvnw")) { 28 | // Some times people end up storing the mvnw script in Git without executable flag; fix it 29 | await p.makeExecutable("mvnw"); 30 | return "./mvnw"; 31 | } else { 32 | return "mvn"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/pack/jvm/util/BoundedElement.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { MatchResult } from "@atomist/automation-client/lib/tree/ast/FileHits"; 18 | 19 | /** 20 | * Part of a file we can work around 21 | */ 22 | export interface BoundedElement { 23 | /** 24 | * Value of whole element 25 | */ 26 | value: string; 27 | 28 | /** 29 | * Offset within the file 30 | */ 31 | offset: number; 32 | 33 | /** 34 | * Save point to insert after this element 35 | */ 36 | insertAfter: number; 37 | } 38 | 39 | export function toBoundedElement(m: MatchResult): BoundedElement { 40 | return { 41 | value: m.$value, 42 | offset: m.$offset, 43 | insertAfter: m.$offset + m.$value.length, 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /lib/pack/k8s/kubernetes/patch.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { KubernetesApplication } from "./request"; 18 | 19 | /** Return type from [[patchHeaders]]. */ 20 | export interface K8sHeaders { 21 | headers: { 22 | [name: string]: string, 23 | }; 24 | } 25 | 26 | /** 27 | * Provide Content-Type header for patch operations. Valid values for 28 | * the Content-Type header when using PATCH are 29 | * "application/json-patch+json", "application/merge-patch+json", and 30 | * "application/strategic-merge-patch+json". See 31 | * https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/ 32 | * for details. 33 | */ 34 | export function patchHeaders(app: Pick): K8sHeaders { 35 | const contentType = (app?.patchStrategy) ? app.patchStrategy : "application/strategic-merge-patch+json"; 36 | return { 37 | headers: { 38 | "Content-Type": contentType, 39 | }, 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /lib/pack/k8s/scheduler/goalScheduling.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { metadata } from "../../../api-helper/misc/extensionPack"; 18 | import { ExtensionPack } from "../../../api/machine/ExtensionPack"; 19 | import { 20 | isConfiguredInEnv, 21 | KubernetesGoalScheduler, 22 | } from "./KubernetesGoalScheduler"; 23 | 24 | /** 25 | * Extension pack to schedule goals as k8s jobs when marked as isolated = true. 26 | */ 27 | export function k8sGoalSchedulingSupport(): ExtensionPack { 28 | return { 29 | ...metadata("k8s-goal-scheduling"), 30 | configure: sdm => { 31 | if (!process.env.ATOMIST_ISOLATED_GOAL && isConfiguredInEnv("kubernetes", "kubernetes-all")) { 32 | sdm.configuration.sdm.goalScheduler = [new KubernetesGoalScheduler()]; 33 | } 34 | }, 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /lib/pack/k8s/support/name.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Return the name with any leading '@' removed. 19 | */ 20 | export function cleanName(n: string): string { 21 | return n.replace(/^@/, ""); 22 | } 23 | -------------------------------------------------------------------------------- /lib/pack/k8s/support/namespace.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** Default Kubernetes namespace. */ 18 | export const K8sDefaultNamespace = "default"; 19 | 20 | /** In-pod location of Kubernetes namespace file. */ 21 | export const K8sNamespaceFile = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"; 22 | -------------------------------------------------------------------------------- /lib/pack/k8s/support/retry.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { 18 | doWithRetry, 19 | RetryOptions, 20 | } from "@atomist/automation-client/lib/util/retry"; 21 | import { k8sErrMsg } from "./error"; 22 | 23 | /** 24 | * Extract Kubernetes errors for doWithRetry. 25 | */ 26 | export async function logRetry(f: () => Promise, desc: string, options?: RetryOptions): Promise { 27 | return doWithRetry(async () => { 28 | let r: T; 29 | try { 30 | r = await f(); 31 | } catch (e) { 32 | if (!(e instanceof Error)) { 33 | const err = new Error(k8sErrMsg(e)); 34 | Object.keys(e).forEach(k => (err as any)[k] = e[k]); 35 | throw err; 36 | } 37 | throw e; 38 | } 39 | return r; 40 | }, desc, options); 41 | } 42 | -------------------------------------------------------------------------------- /lib/pack/k8s/sync/clone.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { CloneOptions } from "@atomist/automation-client/lib/spi/clone/DirectoryManager"; 18 | 19 | export const defaultCloneOptions: CloneOptions = { 20 | alwaysDeep: false, 21 | depth: 1, 22 | detachHead: false, 23 | keep: false, 24 | }; 25 | -------------------------------------------------------------------------------- /lib/pack/k8s/sync/previousSpecVersion.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { execPromise } from "@atomist/automation-client/lib/util/child_process"; 18 | 19 | /** 20 | * Use the Git CLI to fetch the previous version of the spec. If the 21 | * previous does not exist or an error occurs fetching it, an empty 22 | * string is returned. 23 | * 24 | * @param baseDir Project repository base directory 25 | * @param specPath Path to spec file relative to `baseDir` 26 | */ 27 | export async function previousSpecVersion(baseDir: string, specPath: string, sha: string): Promise { 28 | try { 29 | const showResult = await execPromise("git", ["show", `${sha}~1:${specPath}`], { cwd: baseDir }); 30 | return showResult.stdout; 31 | } catch (e) { 32 | return ""; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/pack/k8s/sync/tag.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { 18 | Configuration, 19 | configurationValue, 20 | } from "@atomist/automation-client/lib/configuration"; 21 | 22 | /** 23 | * Unique tag to include in sync commits made by this SDM. 24 | * 25 | * @param config the SDM configuration 26 | * @return unique commit tag string 27 | */ 28 | export function commitTag(config?: Configuration): string { 29 | const name = (config && config.name) ? config.name : configurationValue("name", "@atomist/sdm-pack-k8s"); 30 | return `[atomist:sync-commit=${name}]`; 31 | } 32 | -------------------------------------------------------------------------------- /lib/pack/node/autofix/addBuildScript.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Project } from "@atomist/automation-client/lib/project/Project"; 18 | import { doWithJson } from "@atomist/automation-client/lib/project/util/jsonUtils"; 19 | import * as _ from "lodash"; 20 | import { AutofixRegistration } from "../../../api/registration/AutofixRegistration"; 21 | import { IsNode } from "../pushtest/nodePushTests"; 22 | 23 | export const AddBuildScript: AutofixRegistration = { 24 | name: "Make sure there is a build script", 25 | pushTest: IsNode, 26 | transform: addBuildScriptTransform, 27 | }; 28 | 29 | export async function addBuildScriptTransform(p: Project): Promise { 30 | return doWithJson(p, "package.json", packageJson => { 31 | if (_.get(packageJson, "scripts.build")) { 32 | return packageJson; 33 | } 34 | // todo: what would work on both linuxy and windows? 35 | return _.merge(packageJson, { scripts: { build: "echo 'The build goes here'" } }); 36 | }); 37 | } 38 | -------------------------------------------------------------------------------- /lib/pack/node/autofix/packageJsonFormat.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { AutofixRegistration } from "../../../api/registration/AutofixRegistration"; 18 | import { IsNode } from "../pushtest/nodePushTests"; 19 | 20 | export const PackageJsonFormatingAutofix: AutofixRegistration = { 21 | name: "Package JSON format", 22 | pushTest: IsNode, 23 | transform: async p => { 24 | const pjFile = await p.getFile("package.json"); 25 | const pj = JSON.parse(await pjFile.getContent()); 26 | await pjFile.setContent(JSON.stringify(pj, undefined, 2) + "\n"); 27 | return p; 28 | }, 29 | }; 30 | -------------------------------------------------------------------------------- /lib/pack/node/autofix/packageLockUrlRewriteAutofix.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { hasFile } from "../../../api/mapping/support/commonPushTests"; 18 | import { AutofixRegistration } from "../../../api/registration/AutofixRegistration"; 19 | 20 | const PackageLock = "package-lock.json"; 21 | 22 | /** 23 | * Autofix to replace http registry links with https ones. 24 | * 25 | * Apparently the issue is fixed in npm but we are still seeing http link every once in a while: 26 | * https://npm.community/t/some-packages-have-dist-tarball-as-http-and-not-https/285 27 | */ 28 | export const PackageLockUrlRewriteAutofix: AutofixRegistration = { 29 | name: "NPM package lock", 30 | pushTest: hasFile(PackageLock), 31 | transform: async p => { 32 | const packageLock = await p.getFile(PackageLock); 33 | const packageLockContent = (await packageLock.getContent()).replace(/http:/g, "https:"); 34 | await packageLock.setContent(packageLockContent); 35 | return p; 36 | }, 37 | }; 38 | -------------------------------------------------------------------------------- /lib/pack/node/autofix/typescript/tslintAutofix.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { spawnAutofix } from "../../../../api-helper/code/autofix/spawnAutofix"; 18 | import { hasFile } from "../../../../api/mapping/support/commonPushTests"; 19 | import { allSatisfied } from "../../../../api/mapping/support/pushTestUtils"; 20 | import { AutofixRegistration } from "../../../../api/registration/AutofixRegistration"; 21 | import { DevelopmentEnvOptions } from "../../npm/spawn"; 22 | import { IsNode } from "../../pushtest/nodePushTests"; 23 | import { IsTypeScript } from "../../pushtest/tsPushTests"; 24 | 25 | export const TslintAutofix: AutofixRegistration = spawnAutofix( 26 | "tslint", 27 | allSatisfied(IsTypeScript, IsNode, hasFile("tslint.json")), 28 | { ignoreFailure: true }, 29 | { command: "npm", args: ["run", "--if-present", "lint:fix", "--", "--force"], options: DevelopmentEnvOptions }, 30 | ); 31 | -------------------------------------------------------------------------------- /lib/pack/node/build/nodeOptions.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { LogSuppressor } from "../../../api-helper/log/logInterpreters"; 18 | import { IsNode } from "../pushtest/nodePushTests"; 19 | import { NpmProgressReporter } from "./npmProgressReporter"; 20 | 21 | export const NodeDefaultOptions = { 22 | pushTest: IsNode, 23 | logInterpreter: LogSuppressor, 24 | progressReporter: NpmProgressReporter, 25 | }; 26 | -------------------------------------------------------------------------------- /lib/pack/node/build/nodeProjectIdentifier.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { ProjectIdentifier } from "../../../core/delivery/build/local/projectIdentifier"; 18 | 19 | export const NodeProjectIdentifier: ProjectIdentifier = async p => { 20 | const pkg = await p.getFile("package.json"); 21 | if (!pkg) { 22 | return undefined; 23 | } 24 | const parsed = JSON.parse(await pkg.getContent()); 25 | return { name: parsed.name, version: parsed.version }; 26 | }; 27 | -------------------------------------------------------------------------------- /lib/pack/node/npm/spawn.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { GitProject } from "@atomist/automation-client/lib/project/git/GitProject"; 18 | import { SpawnLogOptions } from "../../../api-helper/misc/child_process"; 19 | import { ProgressLog } from "../../../spi/log/ProgressLog"; 20 | 21 | /** 22 | * Options to use when running node commands like npm run compile that 23 | * require dev dependencies to be installed 24 | */ 25 | export const DevelopmentEnvOptions: Partial = { 26 | env: { 27 | ...process.env, 28 | NODE_ENV: "development", 29 | }, 30 | }; 31 | 32 | /** 33 | * Generate appropriate options for [[spawnLog]] for project and progress log. 34 | */ 35 | export function npmSpawnLogOptions(p: GitProject, log: ProgressLog): SpawnLogOptions { 36 | return { 37 | cwd: p.baseDir, 38 | ...DevelopmentEnvOptions, 39 | log, 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /lib/pack/node/pushtest/tsPushTests.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { fileExists } from "@atomist/automation-client/lib/project/util/projectUtils"; 18 | import { PushListenerInvocation } from "../../../api/listener/PushListener"; 19 | import { pushTest, PushTest } from "../../../api/mapping/PushTest"; 20 | 21 | /** 22 | * Does the project contain TypeScript code? 23 | */ 24 | export const IsTypeScript: PushTest = pushTest("Is TypeScript", async (pi: PushListenerInvocation) => 25 | fileExists(pi.project, "**/*.ts", () => true), 26 | ); 27 | -------------------------------------------------------------------------------- /lib/pack/node/typings/spdx-license-list.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | declare module "spdx-license-list" { 18 | interface LicenseInfo { 19 | name: string; 20 | url: string; 21 | osiApproved: boolean; 22 | } 23 | const L: Record; 24 | export = L; 25 | } 26 | -------------------------------------------------------------------------------- /lib/pack/notification/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export { notificationSupport } from "./notification"; 18 | -------------------------------------------------------------------------------- /lib/pack/universal-generator/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export { UniversalTransform, universalGeneratorSupport, UniversalGeneratorSupportOptions } from "./generatorSupport"; 18 | export { universalGenerator } from "./generator"; 19 | export { assertUniversalGenerator } from "./test/assertGenerator"; 20 | -------------------------------------------------------------------------------- /lib/pack/version/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export { 18 | FileVersioner, 19 | FileVersionerRegistration, 20 | FileVersionIncrementer, 21 | FileVersionIncrementerRegistration, 22 | HasVersionFile, 23 | } from "./file"; 24 | export { GitHubPushTest, GitHubReleaseCreator, GitHubReleaseRegistration } from "./github"; 25 | export { 26 | IncrementVersion, 27 | IncrementVersionRegistration, 28 | VersionIncrementer, 29 | VersionIncrementerArguments, 30 | } from "./increment"; 31 | export { IsReleaseCommit, Release, ReleaseRegistration, ReleaseCreator, ReleaseCreatorArguments } from "./release"; 32 | export { VersionSupport } from "./version"; 33 | -------------------------------------------------------------------------------- /lib/pack/version/version.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { metadata } from "../../api-helper/misc/extensionPack"; 18 | import { ExtensionPack } from "../../api/machine/ExtensionPack"; 19 | 20 | /** 21 | * Currently this extension pack does not alter the SDM. 22 | */ 23 | export const VersionSupport: ExtensionPack = { 24 | ...metadata(), 25 | configure: sdm => { 26 | return sdm; 27 | }, 28 | }; 29 | -------------------------------------------------------------------------------- /lib/spi/issue/IssueCreationOptions.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { IssueRouter } from "./IssueRouter"; 18 | 19 | /** 20 | * Options for anything that can raise issues. 21 | */ 22 | export interface IssueCreationOptions { 23 | 24 | issueRouter: IssueRouter; 25 | } 26 | -------------------------------------------------------------------------------- /lib/spi/issue/IssueRouter.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { ProjectOperationCredentials } from "@atomist/automation-client/lib/operations/common/ProjectOperationCredentials"; 18 | import { RemoteRepoRef } from "@atomist/automation-client/lib/operations/common/RepoId"; 19 | import { Issue } from "@atomist/automation-client/lib/util/gitHub"; 20 | 21 | /** 22 | * Implemented by types that can raise issues 23 | */ 24 | export interface IssueRouter { 25 | 26 | /** 27 | * Raise an issue with the given routing strategy. 28 | * @param {ProjectOperationCredentials} credentials 29 | * @param {RemoteRepoRef} id 30 | * @param {Issue} issue 31 | * @return {Promise} 32 | */ 33 | raiseIssue(credentials: ProjectOperationCredentials, 34 | id: RemoteRepoRef, 35 | issue: Issue): Promise; 36 | } 37 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | *.json 2 | -------------------------------------------------------------------------------- /test/api-helper/log/LoggingProgressLog.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as assert from "assert"; 18 | import { LoggingProgressLog } from "../../../lib/api-helper/log/LoggingProgressLog"; 19 | 20 | describe("The logging progress logger", () => { 21 | 22 | it("remembers the log accurately", () => { 23 | const progressLog = new LoggingProgressLog("hi", "debug"); 24 | const input = [`I am some stuff 25 | that might get written to the log 26 | and so on 27 | `, "and so on and so on\n"]; 28 | input.forEach(line => progressLog.write(line)); 29 | 30 | assert.strictEqual(progressLog.log, input.join("")); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /test/api-helper/misc/extensionPack.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as assert from "power-assert"; 18 | import { metadata } from "../../../lib/api-helper/misc/extensionPack"; 19 | 20 | describe("extensionPack", () => { 21 | 22 | it("should correctly read metadata from package.json", () => { 23 | const epm = metadata("test"); 24 | assert.equal(epm.name, "@atomist/sdm:test"); 25 | assert.equal(epm.vendor, "Atomist"); 26 | assert.equal(epm.tags.length, 5); 27 | }); 28 | 29 | }); 30 | -------------------------------------------------------------------------------- /test/api/goal/GoalNameGenerator.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as assert from "power-assert"; 18 | import { Autofix } from "../../../lib/api/goal/common/Autofix"; 19 | 20 | describe("GoalNameGenerator", () => { 21 | 22 | describe("SourceLocalGoalNameGenerator", () => { 23 | 24 | it("should correctly generate a goal name", () => { 25 | const goal = new Autofix(); 26 | const name = goal.definition.uniqueName; 27 | assert(name.startsWith("autofix")); 28 | assert(name.includes("GoalNameGenerator.test.")); 29 | }); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /test/api/mapping/support/pushRule.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2019 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { GitHubRepoRef } from "@atomist/automation-client/lib/operations/common/GitHubRepoRef"; 18 | import * as assert from "power-assert"; 19 | import { PushRule } from "../../../../lib/api/mapping/support/PushRule"; 20 | import { TruePushTest } from "./pushTestUtils.test"; 21 | 22 | describe("PushRule", () => { 23 | 24 | it("should set literal value", async () => { 25 | const pr = new PushRule(TruePushTest, [], "reason"); 26 | pr.set("frogs"); 27 | assert.equal(await pr.mapping({ 28 | push: { id: new Date().getTime() + "_"}, 29 | id: new GitHubRepoRef("a", "b"), 30 | } as any), "frogs"); 31 | }); 32 | 33 | }); 34 | -------------------------------------------------------------------------------- /test/api/registration/transformCompatibility.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2018 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as assert from "assert"; 18 | import { 19 | CodeTransform, 20 | ExplicitCodeTransform, 21 | } from "../../../lib/api/registration/CodeTransform"; 22 | 23 | describe("ExplicitTransform", () => { 24 | 25 | it("should be compatible with CodeTransform", () => { 26 | const ext: ExplicitCodeTransform = async (p, ci, params) => ({ target: p, success: true, edited: false}); 27 | const tr: CodeTransform = ext; 28 | assert(!!tr); 29 | }); 30 | 31 | }); 32 | -------------------------------------------------------------------------------- /test/core/goal/container/util.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export const containerTestImage = "alpine:3.9.4"; 18 | -------------------------------------------------------------------------------- /test/core/preferences/InMemoryPreferenceStore.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { PreferenceScope } from "../../../lib/api/context/preferenceStore"; 18 | import { InMemoryPreferenceStore } from "../../../lib/core/preferences/InMemoryPreferenceStore"; 19 | import { assertPreferences } from "./preferences"; 20 | 21 | describe("InMemoryPreferenceStore", () => { 22 | 23 | it("should correctly handle preferences", async () => { 24 | const prefs = new InMemoryPreferenceStore({ configuration: { name: "my-sdm" } } as any); 25 | await assertPreferences(prefs); 26 | }).timeout(5000); 27 | 28 | it("should correctly handle scoped preferences", async () => { 29 | const prefs = new InMemoryPreferenceStore({ configuration: { name: "my-sdm" } } as any); 30 | await assertPreferences(prefs, PreferenceScope.Sdm); 31 | }).timeout(5000); 32 | 33 | }); 34 | -------------------------------------------------------------------------------- /test/core/signing/es512-private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PRIVATE KEY----- 2 | MIHbAgEBBEFK4i3aUZSLPKdaG/o6sxmXb+3iBf7Suve19/f5Zgo6EeKlFm6eLIzA 3 | xS8cJi7Z5bV0xyLLWj9eFUJGQn5+KO49gKAHBgUrgQQAI6GBiQOBhgAEANHJNVHm 4 | fpIsp/wyKbnm/B3av2OhVRNGlNgcxS1yQ3NpPkB6PHRbg3bO4FhJzrjCsH3iAjuM 5 | pt+CfjZBdH/ma2juAdGu3/1KunkZda8eTzqQF/reDFBMVnWkFRyZh/+lfjjqwuHd 6 | /50+b8Ek87ghsaTM2am8u2u2wplgoatHxWq/Jgij 7 | -----END EC PRIVATE KEY----- 8 | -------------------------------------------------------------------------------- /test/core/signing/es512-public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQA0ck1UeZ+kiyn/DIpueb8Hdq/Y6FV 3 | E0aU2BzFLXJDc2k+QHo8dFuDds7gWEnOuMKwfeICO4ym34J+NkF0f+ZraO4B0a7f 4 | /Uq6eRl1rx5POpAX+t4MUExWdaQVHJmH/6V+OOrC4d3/nT5vwSTzuCGxpMzZqby7 5 | a7bCmWChq0fFar8mCKM= 6 | -----END PUBLIC KEY----- 7 | -------------------------------------------------------------------------------- /test/core/signing/sdm-test-public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3SA7ZtXsyqz38Bolt3jU 3 | f23HpfDc3dFa+LSH26wuvFhPoGtrC/DE5LaXw+6rC0lWuDRtn455Q3fYllqL9BhB 4 | K+IhSSxoLofJZiTs5NjWbnqdw2tdjE/VeJ/RuJX7Rp03SNi5a4Bl5UtHkGNGqvoB 5 | xcKQ7ZQxwIQybL14mOG2Lg0N6x2tCRuchSJlhIXpn5oIG2yoah/QLal2m/WergHe 6 | eNa0Bou1QRXKQoMdzLXTc55lEr1IbqV3bdndKEiAevD9HsASZ1+7TSKzPYARZWsb 7 | LyKhJXdoMwm5gwK3B6b1E7myJWCrUHIEJakl0IgK8K7vawi588pQUzw9UAZtc106 8 | 0wIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /test/core/util/slack/diffRendering.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as assert from "power-assert"; 18 | import { renderCommitMessage } from "../../../../lib/core/util/slack/diffRendering"; 19 | 20 | describe("commit rendering", () => { 21 | 22 | it("can render a commit", () => { 23 | 24 | const text = renderCommitMessage({ owner: "somewhere", name: "over" }, { 25 | sha: "blue", 26 | message: "a stripe, it's pretty", 27 | author: { login: "Dorothy" }, 28 | }); 29 | 30 | assert(text.includes("a stripe")); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /test/pack/k8s/kubernetes/clients.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as assert from "power-assert"; 18 | import { makeNoOpApiClients } from "../../../../lib/pack/k8s/kubernetes/clients"; 19 | 20 | describe("pack/k8s/kubernetes/clients", () => { 21 | describe("makeNoOpApiClients", () => { 22 | it("should make the no-op clients", () => { 23 | const c = makeNoOpApiClients(); 24 | assert(c); 25 | assert(c.core); 26 | assert(c.apps); 27 | assert(c.net); 28 | assert(c.rbac); 29 | }); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /test/pack/k8s/kubernetes/rbac.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as assert from "power-assert"; 18 | import { upsertRbac } from "../../../../lib/pack/k8s/kubernetes/rbac"; 19 | import { KubernetesResourceRequest } from "../../../../lib/pack/k8s/kubernetes/request"; 20 | 21 | describe("pack/k8s/kubernetes/rbac", () => { 22 | 23 | describe("upsertRbac", () => { 24 | 25 | it("should return nothing", async () => { 26 | const r: KubernetesResourceRequest = {} as any; 27 | const v = await upsertRbac(r); 28 | assert.deepStrictEqual(v, {}); 29 | }); 30 | 31 | }); 32 | 33 | }); 34 | -------------------------------------------------------------------------------- /test/pack/k8s/support/name.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as assert from "power-assert"; 18 | import { cleanName } from "../../../../lib/pack/k8s/support/name"; 19 | 20 | describe("pack/k8s/support/name", () => { 21 | 22 | describe("cleanName", () => { 23 | 24 | it("should remove the leading '@'", () => { 25 | const n = cleanName("@atomist/k8s-sdm"); 26 | assert(n === "atomist/k8s-sdm"); 27 | }); 28 | 29 | it("should leave a clean name alone", () => { 30 | const c = "atomist/k8s-sdm_somewhere@else"; 31 | const n = cleanName(c); 32 | assert(n === c); 33 | }); 34 | 35 | }); 36 | 37 | }); 38 | -------------------------------------------------------------------------------- /test/pack/node/build/gitBranchToNpmTag.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2020 Atomist, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as assert from "power-assert"; 18 | import { gitBranchToNpmTag } from "../../../../lib/pack/node/build/executePublish"; 19 | 20 | describe("git branch to npm tag", () => { 21 | it("prefixes it with branch", () => { 22 | const input = "hello"; 23 | const result = gitBranchToNpmTag(input); 24 | assert.equal(result, "branch-" + input); 25 | }); 26 | 27 | it("replaces slash with something", () => { 28 | const input = "hello/branch"; 29 | const result = gitBranchToNpmTag(input); 30 | assert(!result.includes("/")); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "newLine": "LF", 4 | "target": "ES2017", 5 | "module": "CommonJS", 6 | "moduleResolution": "Node", 7 | "jsx": "React", 8 | "declaration": true, 9 | "declarationMap": true, 10 | "sourceMap": true, 11 | "lib": [ 12 | "DOM", 13 | "ES2017", 14 | "DOM.Iterable", 15 | "ScriptHost", 16 | "esnext.asynciterable" 17 | ], 18 | "strict": false, 19 | "forceConsistentCasingInFileNames": true, 20 | "noImplicitReturns": true, 21 | "noUnusedLocals": true, 22 | "experimentalDecorators": true, 23 | "emitDecoratorMetadata": true 24 | }, 25 | "include": ["index.ts", "bin/*.ts", "lib/**/*.ts", "test/**/*.ts"], 26 | "exclude": [".#*"], 27 | "compileOnSave": true, 28 | "buildOnSave": false, 29 | "atom": { 30 | "rewriteTsconfig": false 31 | } 32 | } 33 | --------------------------------------------------------------------------------