Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}, ...toArray(options.taggers) || []);
const aspects = [...toArray(options.aspects || []), ...scoringAspects, tagAspect]
.map(aspect => makeVirtualProjectAware(aspect, options.virtualProjectFinder));
// Default the two display methods with some sensible defaults
aspects.forEach(a => {
if (!a.toDisplayableFingerprint) {
a.toDisplayableFingerprint = fp => JSON.stringify(fp.data);
}
if (!a.toDisplayableFingerprintName) {
a.toDisplayableFingerprintName = fn => fn;
}
});
return {
...metadata(),
configure: sdm => {
const cfg = sdm.configuration;
const analysisTracking = new AnalysisTracker();
if (isInLocalMode()) {
// If we're in local mode, expose analyzer commands and
// HTTP endpoints
const analyzer = createAnalyzer(
aspects,
options.virtualProjectFinder || exports.DefaultVirtualProjectFinder);
sdm.addCommand(analyzeGitHubByQueryCommandRegistration(analyzer, analysisTracking));
sdm.addCommand(analyzeGitHubOrganizationCommandRegistration(analyzer, analysisTracking));
sdm.addCommand(analyzeLocalCommandRegistration(analyzer, analysisTracking));
} else {
// Add command to calculate fingerprints as part of the initial onboarding
export function infoSupport(): ExtensionPack {
return {
...metadata("info"),
configure: sdm => {
sdm.addCommand(selfDescribeCommand(sdm));
},
};
}
export function universalGeneratorSupport(options: UniversalGeneratorSupportOptions): ExtensionPack {
return {
...metadata(),
configure: sdm => {
toArray(options.generators)
.map(g => universalGenerator(sdm, g, toArray(options.transformsAndParameters || [])))
.forEach(g => sdm.addGeneratorCommand(g));
},
};
}
export function notificationSupport(options: NotificationOptions = {}): ExtensionPack {
return {
...metadata("notification"),
configure: sdm => {
const updateGoalCommand = updateGoalStateCommand();
updateGoalCommand.name = `${updateGoalCommand.name}ForNotifications`;
sdm.addCommand(updateGoalCommand);
const optsToUse: NotificationOptions = {
destination: defaultDestinationFactory,
notification: defaultNotificationFactory(updateGoalCommand),
...options,
};
sdm.addGoalCompletionListener(notifyGoalCompletionListener(optsToUse));
},
};
}
export function goalStateSupport(options?: GoalStateOptions): ExtensionPack {
return {
...metadata("goal-state"),
configure: sdm => {
if (isInLocalMode()) {
logger.warn("Setting goal state is not available in local mode.");
logger.warn("Resetting goals does not work in local mode. Use `atomist trigger post-commit` instead.");
} else {
sdm.addCommand(setGoalStateCommand(sdm));
sdm.addCommand(resetGoalsCommand(sdm));
sdm.addCommand(cancelGoalSetsCommand(sdm));
sdm.addCommand(listPendingGoalSetsCommand(sdm));
if ((cluster.isMaster || !_.get(sdm.configuration, "cluster.enabled")) &&
!process.env.ATOMIST_ISOLATED_GOAL &&
!!options && !!options.cancellation && !!options.cancellation.enabled) {
logger.debug(`Timeout based goal cancellation enabled for this SDM`);
sdm.addTriggeredListener({
trigger: { interval: 1000 * 30 },
export function deploymentFreeze(dsm: DeploymentStatusManager): ExtensionPack {
return {
...metadata("deployment-freeze"),
configure: sdm => {
sdm.addCommand(
freezeCommand(dsm))
.addCommand(unfreezeCommand(dsm));
sdm.addGoalImplementation("ExplainDeploymentFreezeGoal",
ExplainDeploymentFreezeGoal,
executeSendMessageToSlack("*Attention*: Not deploying as deployment is currently frozen :no_entry:"));
},
};
}
export function springSupport(options: SpringSupportOptions): ExtensionPack {
return {
...metadata(),
configure: sdm => {
sdm
.addCodeTransformCommand(AddMavenDependency)
.addCodeTransformCommand(AddSpringBootStarter)
.addCodeTransformCommand(addSpringBootActuator())
.addCodeTransformCommand(ApplySecuredWebAppGuide)
.addCodeTransformCommand(tryToUpgradeSpringBootVersion(options))
.addFirstPushListener(
tagRepo(unifiedTagger(
springBootTagger,
gradleTagger,
mavenTagger,
),
),
);
if (!!options.inspectGoal) {
if (options.secureWeb === undefined) {
options.secureWeb = !isInLocalMode();
}
const aboutTheApi = api(resultStore, aspectRegistry, options.secureWeb);
if (!isInLocalMode() && !options.exposeWeb) {
return {
routesToSuggestOnStartup: aboutTheApi.routesToSuggestOnStartup,
customizers: [aboutTheApi.customizer],
};
}
const aboutStaticPages = addWebAppRoutes(aspectRegistry, resultStore, analysisTracking, configuration.http.client.factory,
options.instanceMetadata || metadata());
return {
routesToSuggestOnStartup:
[...aboutStaticPages.routesToSuggestOnStartup,
...aboutTheApi.routesToSuggestOnStartup],
customizers: [aboutStaticPages.customizer, aboutTheApi.customizer],
};
}