How to use the @atomist/automation-client.Parameters 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 / src / software-delivery-machine / commands / editors / support / RequestedCommitParameters.ts View on Github external
* Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { Parameter, Parameters } from "@atomist/automation-client";
import { GitBranchRegExp } from "@atomist/automation-client/operations/common/params/gitHubPatterns";
import { BranchCommit, EditMode, PullRequest } from "@atomist/automation-client/operations/edit/editModes";

/**
 * Allow user to specify a branch (with default master).
 * Set 'newBranch' to true to create a unique new branch.
 */
@Parameters()
export class RequestedCommitParameters {

    @Parameter({
            required: false,
            description: "Branch to use. Default is 'master'.",
            ...GitBranchRegExp,
        },
    )
    private readonly branch = "master";

    // TODO should really be a boolean, investigate client issue
    @Parameter({required: false, pattern: /(true|false)/})
    private readonly newBranch: string = "false";

    @Parameter({required: false})
    // tslint gets the following variable declaration wrong, producing a compile error
github atomist / sdm / src / software-delivery-machine / commands / editors / spring / tryToUpgradeSpringBootVersion.ts View on Github external
*
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { HandleCommand, Parameter, Parameters } from "@atomist/automation-client";
import { setSpringBootVersionEditor } from "@atomist/spring-automation/commands/editor/spring/setSpringBootVersionEditor";
import { UnleashPhilParameters } from "@atomist/spring-automation/commands/editor/spring/unleashPhil";
import { CurrentSpringBootVersion } from "@atomist/spring-automation/commands/reviewer/spring/SpringBootVersionReviewer";
import { EditModeSuggestion } from "../../../../common/command/editor/EditModeSuggestion";
import { dryRunEditor } from "../../../../common/command/generator/dry-run/dryRunEditor";

@Parameters()
export class UpgradeSpringBootParameters implements EditModeSuggestion {

    @Parameter({
        displayName: "Desired Spring Boot version",
        description: "The desired Spring Boot version across these repos",
        pattern: /^.+$/,
        validInput: "Semantic version",
        required: false,
    })
    // TODO this should be in a  object goals
    public desiredBootVersion: string = CurrentSpringBootVersion;

    private readonly guid = "" + new Date().getTime();

    get desiredBranchName() {
        return `boot-upgrade-${this.desiredBootVersion}-${this.guid}`;
github atomist / sdm-core / lib / handlers / commands / ShowBuildLog.ts View on Github external
Secrets,
    Success,
} from "@atomist/automation-client";
import {
    AddressChannels,
    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 => {
github atomist / sdm-core / lib / handlers / common / ConfigurationBasedBasicCredentialsResolver.ts View on Github external
* limitations under the License.
 */

import {
    configurationValue,
    HandlerContext,
    Parameters,
    ProjectOperationCredentials,
    RemoteRepoRef,
} from "@atomist/automation-client";
import { CredentialsResolver } from "@atomist/sdm";

/**
 * Resolves to single credentials from the configuration
 */
@Parameters()
export class ConfigurationBasedBasicCredentialsResolver implements CredentialsResolver {

    constructor(private readonly paths: { username: string, password: string } = {
        username: "sdm.git.user",
        password: "sdm.git.password",
    }) { }

    public eventHandlerCredentials(context: HandlerContext): ProjectOperationCredentials {
        return this.credentialsFromConfiguration();
    }

    public commandHandlerCredentials(context: HandlerContext, id: RemoteRepoRef): ProjectOperationCredentials {
        return this.credentialsFromConfiguration();
    }

    private credentialsFromConfiguration(): ProjectOperationCredentials & { username: string, password: string} {
github atomist / sdm-core / lib / pack / goal-state / resetGoals.ts View on Github external
slackWarningMessage,
    SoftwareDeliveryMachine,
    toRepoTargetingParametersMaker,
} 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,
github atomist / sdm-core / lib / handlers / commands / SetDeployEnablement.ts View on Github external
Parameters,
    Success,
    Value,
} from "@atomist/automation-client";
import {
    CommandHandlerRegistration,
    CommandListenerInvocation,
    slackSuccessMessage,
} from "@atomist/sdm";
import { bold } from "@atomist/slack-messages";
import {
    DeployEnablementRootType,
    SdmDeployEnablement,
} from "../../ingesters/sdmDeployEnablement";

@Parameters()
export class SetDeployEnablementParameters {

    @Parameter({ required: false, displayable: false })
    public msgId?: string;

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

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

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

    @Value("name")
    public name: string;
github atomist / sdm-core / lib / handlers / commands / disposeCommand.ts View on Github external
success,
    Success,
} from "@atomist/automation-client";
import { HandleCommand } from "@atomist/automation-client/lib/HandleCommand";
import { commandHandlerFrom } from "@atomist/automation-client/lib/onCommand";
import {
    chooseAndSetGoals,
    ChooseAndSetGoalsRules,
} from "@atomist/sdm";
import {
    fetchBranchTips,
    fetchPushForCommit,
    tipOfBranch,
} from "../../util/graph/queryCommits";

@Parameters()
export class DisposeParameters {

    @Secret(Secrets.UserToken)
    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;
github atomist / sdm / src / software-delivery-machine / commands / editors / demo / affirmationEditor.ts View on Github external
* Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { HandleCommand, Parameter, Parameters } from "@atomist/automation-client";
import { SimpleProjectEditor } from "@atomist/automation-client/operations/edit/projectEditor";
import { doWithFiles } from "@atomist/automation-client/project/util/projectUtils";
import { editorCommand } from "../../../../common/command/editor/editorCommand";
import { RequestedCommitParameters } from "../support/RequestedCommitParameters";

export const AffirmationEditorName = "affirmation";

@Parameters()
export class AffirmationParameters extends RequestedCommitParameters {

    constructor(message: string) {
        super(message);
    }

    @Parameter({required: false, pattern: /.*/})
    public readonly customAffirmation: string;
}

/**
 * Function returning a command handler around the appendAffirmationToReadMe
 * editor
 * @type {HandleCommand}
 */
export const affirmationEditor: HandleCommand = editorCommand(
github atomist / sdm / src / software-delivery-machine / commands / editors / support / OptionalBranchParameters.ts View on Github external
* you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import { Parameter, Parameters } from "@atomist/automation-client";

@Parameters()
export class OptionalBranchParameters {

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

}
github atomist / sdm / src / software-delivery-machine / commands / editors / license / addHeader.ts View on Github external
import { HandleCommand, HandlerContext, logger, Parameter, Parameters } from "@atomist/automation-client";
import { GitProject } from "@atomist/automation-client/project/git/GitProject";
import { Project } from "@atomist/automation-client/project/Project";
import { doWithFiles } from "@atomist/automation-client/project/util/projectUtils";
import { editorCommand } from "../../../../common/command/editor/editorCommand";
import { CFamilyLanguageSourceFiles } from "../GlobPatterns";
import { RequestedCommitParameters } from "../support/RequestedCommitParameters";

/**
 * Default glob pattern matches all C family languages
 */
@Parameters()
export class AddHeaderParameters extends RequestedCommitParameters {

    @Parameter({required: false})
    public glob: string = CFamilyLanguageSourceFiles;

    @Parameter({required: false})
    public license: "apache" = "apache";

    @Parameter({required: false})
    public readonly successEmoji = ":carousel_horse:";

    constructor() {
        super("Add missing license headers");
    }

    get header(): string {