How to use the @atomist/automation-client.MappedParameter function in @atomist/automation-client

To help you get started, we’ve selected a few @atomist/automation-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atomist / sdm-core / lib / handlers / commands / ShowBuildLog.ts View on Github external
CommandHandlerRegistration,
    CommandListener,
    LogInterpretation,
} from "@atomist/sdm";
import * as _ from "lodash";
import { BuildUrlBySha } from "../../typings/types";
import { tipOfDefaultBranch } from "../../util/github/ghub";
import { DefaultRepoRefResolver } from "../common/DefaultRepoRefResolver";
import { displayBuildLogFailure } from "../events/delivery/build/SetStatusOnBuildComplete";

@Parameters()
export class DisplayBuildLogParameters {
    @Secret(Secrets.UserToken)
    public githubToken: string;

    @MappedParameter(MappedParameters.GitHubOwner)
    public owner: string;

    @MappedParameter(MappedParameters.GitHubRepository)
    public repo: string;

    @Parameter({ required: false })
    public sha?: string;
}

function displayBuildLogForCommit(interpreter?: LogInterpretation): CommandListener {
    return async cli => {

        const sha = cli.parameters.sha ? cli.parameters.sha :
            await tipOfDefaultBranch(cli.parameters.githubToken,
                new GitHubRepoRef(cli.parameters.owner, cli.parameters.repo)); // TODO: use fetchDefaultBranchTip
github atomist / sdm / src / software-delivery-machine / blueprint / deploy / deployToProd.ts View on Github external
import { GitHubRepoRef } from "@atomist/automation-client/operations/common/GitHubRepoRef";
import { Fingerprint } from "@atomist/automation-client/project/fingerprint/Fingerprint";
import { addressSlackUsers } from "@atomist/automation-client/spi/message/MessageClient";
import * as slack from "@atomist/slack-messages/SlackMessages";
import { BuildContext } from "../../../common/phases/gitHubContext";
import { ProductionDeployPhases } from "../../../handlers/events/delivery/phases/productionDeployPhases";
import { listStatuses, Status } from "../../../util/github/ghub";
import { sendFingerprint } from "../../../util/webhook/sendFingerprint";

@CommandHandler("Promote to production", "promote to production")
export class DeployToProd implements HandleCommand {

    @Secret(Secrets.userToken(["repo", "user:email", "read:user"]))
    private githubToken: string;

    @MappedParameter(MappedParameters.SlackUserName)
    private slackUserName: string;

    @Parameter()
    private owner: string;

    @Parameter()
    private repo: string;

    @Parameter()
    private sha: string;

    // update this message
    @Parameter({required: false})
    private messageId: string;

    // in these channels
github atomist / sdm / src / handlers / commands / deleteRepository.ts View on Github external
success,
    Success,
} from "@atomist/automation-client";
import { Parameters } from "@atomist/automation-client/decorators";
import { commandHandlerFrom } from "@atomist/automation-client/onCommand";
import { GitHubRepoRef } from "@atomist/automation-client/operations/common/GitHubRepoRef";
import { deleteRepository } from "../../util/github/ghub";
import { fetchProvider } from "../../util/github/gitHubProvider";

@Parameters()
export class DeleteRepositoryParameters {

    @Secret(Secrets.userToken("delete_repo"))
    public githubToken: string;

    @MappedParameter(MappedParameters.GitHubOwner)
    public owner: string;

    @MappedParameter(MappedParameters.GitHubRepository)
    public repo: string;

    @MappedParameter(MappedParameters.GitHubRepositoryProvider)
    public providerId: string;

    @Parameter({required: true})
    public areYouSure: string;
}

export const DeleteRepositoryCommandName = "DeleteRepository";

export function deleteRepositoryCommand(): HandleCommand {
    return commandHandlerFrom(deleteRepositoryPlease(),
github atomist / sdm / lib / api / command / target / GitlabRepoTargets.ts View on Github external
} from "@atomist/automation-client";
import { FallbackParams } from "@atomist/automation-client/lib/operations/common/params/FallbackParams";
import { TargetsParams } from "@atomist/automation-client/lib/operations/common/params/TargetsParams";
import { RepoTargets } from "../../machine/RepoTargets";

/**
 * Targets for working with BitBucket repo(s).
 * Allows use of regex.
 */
@Parameters()
export class GitlabRepoTargets extends TargetsParams implements FallbackParams, RepoTargets {

    @MappedParameter(MappedParameters.GitHubApiUrl, false)
    public apiUrl: string;

    @MappedParameter(MappedParameters.GitHubUrl, false)
    public url: string;

    @MappedParameter(MappedParameters.GitHubOwner, false)
    public owner: string;

    @MappedParameter(MappedParameters.GitHubRepository, false)
    public repo: string;

    @Parameter({ description: "Ref", ...validationPatterns.GitShaRegExp, required: false })
    public sha: string;

    @Parameter({ description: "Branch Defaults to 'master'", ...validationPatterns.GitBranchRegExp, required: false })
    public branch: string = "master";

    @Parameter({ description: "regex", required: false })
    public repos: string;
github atomist / sdm / src / software-delivery-machine / blueprint / deploy / presentPromotionInformation.ts View on Github external
const message: slack.SlackMessage = {
        attachments: currentlyRunning,
    };
    return inv.context.messageClient.send(message, inv.messageDestination, {id: messageId});
}

@Parameters()
export class PromotionParameters {
    @Secret(Secrets.UserToken)
    public githubToken;

    @MappedParameter(MappedParameters.GitHubOwner)
    public owner;

    @MappedParameter(MappedParameters.GitHubRepository)
    public repo;

    @Parameter({required: false})
    public sha;

    @MappedParameter(MappedParameters.SlackChannel)
    public channel;
}

export const offerPromotionCommand: Maker> = () =>
    commandHandlerFrom(async (context: HandlerContext, params: PromotionParameters) => {
            const inv: VerifiedDeploymentInvocation = {
                id: new GitHubRepoRef(params.owner, params.repo, params.sha || await
                    tipOfDefaultBranch(params.githubToken, new GitHubRepoRef(params.owner, params.repo))),
                status: {targetUrl: undefined},
                credentials: {token: params.githubToken},
github atomist / sdm-core / lib / pack / goal-state / resetGoals.ts View on Github external
} from "@atomist/sdm";
import {
    bold,
    codeLine,
    italic,
} from "@atomist/slack-messages";
import {
    fetchBranchTips,
    fetchPushForCommit,
    tipOfBranch,
} from "../../util/graph/queryCommits";

@Parameters()
export class ResetGoalsParameters {

    @MappedParameter(MappedParameters.GitHubRepositoryProvider)
    public providerId: string;

    @Value("name")
    public name: string;

    @Value("version")
    public version: string;

}

export function resetGoalsCommand(
    sdm: SoftwareDeliveryMachine,
    repoTargets: Maker = GitHubRepoTargets,
): CommandHandlerRegistration {

    return {