How to use the @atomist/slack-messages.codeLine function in @atomist/slack-messages

To help you get started, we’ve selected a few @atomist/slack-messages 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 / pack / info / SelfDescribe.ts View on Github external
return async cli => {
        const pj = require(path.join(appRoot.path, "package.json"));
        const clientPj = require(path.join(appRoot.path, "node_modules", "@atomist", "automation-client", "package.json"));
        const sdmPj = require(path.join(appRoot.path, "node_modules", "@atomist", "sdm", "package.json"));
        const sdmCorePj = require(path.join(appRoot.path, "node_modules", "@atomist", "sdm-core", "package.json"));
        const gitInfo = info(automationClientInstance().automations.automations);

        const msg: SlackMessage = {
            attachments: [{
                author_name: pj.author && pj.author.name ? pj.author.name : pj.author,
                title: sdm.name,
                title_link: pj.homepage,
                fallback: sdm.name,
                text: `${pj.description}
Version: ${codeLine(sdm.configuration.version)} - License: ${codeLine(pj.license)}`,
            }, {
                author_name: "Details",
                fallback: "Details",
                text: `Sha: ${codeLine(gitInfo.git && gitInfo.git.sha ? gitInfo.git.sha.slice(0, 7) : "n/a")}
Repository: ${codeLine(gitInfo.git && gitInfo.git.repository ? gitInfo.git.repository : "n/a")}
Policy: ${codeLine(sdm.configuration.policy)}
Environment: ${codeLine(sdm.configuration.environment)}
Cluster: ${codeLine(sdm.configuration.cluster.enabled ? "enabled" : "disabled")}`,
            }, {
                author_name: "Dependencies",
                fallback: "Dependencies",
                text: `${codeLine(`${clientPj.name}:${clientPj.version}`)}
${codeLine(`${sdmPj.name}:${sdmPj.version}`)}
${codeLine(`${sdmCorePj.name}:${sdmCorePj.version}`)}`,
            }, {
                author_name: "Extension Packs",
github atomist / sdm / lib / api-helper / listener / executeAutofixes.ts View on Github external
${appliedAutofixes.map(af => ` * ${codeLine(af.name)}`).join("\n")}
github atomist / sdm-core / lib / pack / notification / notification.ts View on Github external
})],
                });
                break;
            case SdmGoalState.stopped:
                state = "has stopped";
                suffix = "Stopped";
                msg = slackInfoMessage("", "");
                break;
            default:
                return undefined;
        }

        const author = `Goal ${suffix}`;
        const commitMsg = truncateCommitMessage(completedGoal.push.after.message);
        const text = `Goal ${italic(completedGoal.url ? url(completedGoal.url, completedGoal.name) : completedGoal.name)} on ${
            url(completedGoal.push.after.url, codeLine(completedGoal.sha.slice(0, 7)))} ${italic(commitMsg)} of ${
            bold(`${url(completedGoal.push.repo.url, `${completedGoal.repo.owner}/${completedGoal.repo.name}/${
                completedGoal.branch}`)}`)} ${state}.`;
        const channels: CoreRepoFieldsAndChannels.Channels[] = _.get(completedGoal, "push.repo.channels") || [];
        const channelLink = channels.filter(c => !!c.channelId).map(c => channel(c.channelId)).join(" \u00B7 ");
        const link =
            `https://app.atomist.com/workspace/${context.workspaceId}/goalset/${completedGoal.goalSetId}`;

        msg.attachments[0] = {
            ...msg.attachments[0],
            author_name: author,
            text,
            footer: `${slackFooter()} \u00B7 ${url(link, completedGoal.goalSetId.slice(0, 7))} \u00B7 ${channelLink}`,
        };

        return { message: msg, options: { id: msgId } };
    };
github atomist / sdm-core / lib / pack / info / SelfDescribe.ts View on Github external
const sdmPj = require(path.join(appRoot.path, "node_modules", "@atomist", "sdm", "package.json"));
        const sdmCorePj = require(path.join(appRoot.path, "node_modules", "@atomist", "sdm-core", "package.json"));
        const gitInfo = info(automationClientInstance().automations.automations);

        const msg: SlackMessage = {
            attachments: [{
                author_name: pj.author && pj.author.name ? pj.author.name : pj.author,
                title: sdm.name,
                title_link: pj.homepage,
                fallback: sdm.name,
                text: `${pj.description}
Version: ${codeLine(sdm.configuration.version)} - License: ${codeLine(pj.license)}`,
            }, {
                author_name: "Details",
                fallback: "Details",
                text: `Sha: ${codeLine(gitInfo.git && gitInfo.git.sha ? gitInfo.git.sha.slice(0, 7) : "n/a")}
Repository: ${codeLine(gitInfo.git && gitInfo.git.repository ? gitInfo.git.repository : "n/a")}
Policy: ${codeLine(sdm.configuration.policy)}
Environment: ${codeLine(sdm.configuration.environment)}
Cluster: ${codeLine(sdm.configuration.cluster.enabled ? "enabled" : "disabled")}`,
            }, {
                author_name: "Dependencies",
                fallback: "Dependencies",
                text: `${codeLine(`${clientPj.name}:${clientPj.version}`)}
${codeLine(`${sdmPj.name}:${sdmPj.version}`)}
${codeLine(`${sdmCorePj.name}:${sdmCorePj.version}`)}`,
            }, {
                author_name: "Extension Packs",
                fallback: "Extension Packs",
                text: [...sdm.extensionPacks]
                    .sort((e1, e2) => e1.name.localeCompare(e2.name))
                    .map(e => `${codeLine(`${e.name}:${e.version}`)} ${e.vendor}`).join("\n"),
github atomist / sdm-core / lib / pack / info / SelfDescribe.ts View on Github external
const msg: SlackMessage = {
            attachments: [{
                author_name: pj.author && pj.author.name ? pj.author.name : pj.author,
                title: sdm.name,
                title_link: pj.homepage,
                fallback: sdm.name,
                text: `${pj.description}
Version: ${codeLine(sdm.configuration.version)} - License: ${codeLine(pj.license)}`,
            }, {
                author_name: "Details",
                fallback: "Details",
                text: `Sha: ${codeLine(gitInfo.git && gitInfo.git.sha ? gitInfo.git.sha.slice(0, 7) : "n/a")}
Repository: ${codeLine(gitInfo.git && gitInfo.git.repository ? gitInfo.git.repository : "n/a")}
Policy: ${codeLine(sdm.configuration.policy)}
Environment: ${codeLine(sdm.configuration.environment)}
Cluster: ${codeLine(sdm.configuration.cluster.enabled ? "enabled" : "disabled")}`,
            }, {
                author_name: "Dependencies",
                fallback: "Dependencies",
                text: `${codeLine(`${clientPj.name}:${clientPj.version}`)}
${codeLine(`${sdmPj.name}:${sdmPj.version}`)}
${codeLine(`${sdmCorePj.name}:${sdmCorePj.version}`)}`,
            }, {
                author_name: "Extension Packs",
                fallback: "Extension Packs",
                text: [...sdm.extensionPacks]
                    .sort((e1, e2) => e1.name.localeCompare(e2.name))
                    .map(e => `${codeLine(`${e.name}:${e.version}`)} ${e.vendor}`).join("\n"),
            }, {
                author_name: "Events",
                fallback: "Events",
                text: automationClientInstance().automations.automations.events
github atomist / sdm-core / lib / pack / goal-state / cancelGoals.ts View on Github external
listener: async ci => {
            const id = ci.parameters.msgId || guid();
            let offset = 0;
            let pgs = await pendingGoalSets(ci.context, sdm.configuration.name, offset);
            const attachments: Attachment[] = [];
            while (pgs.length > 0) {
                for (const pg of pgs) {
                    attachments.push({
                        text: `Pending goal set ${italic(pg.goalSet)} ${codeLine(pg.goalSetId.slice(0, 7))} on ${
                            codeLine(pg.sha.slice(0, 7))} of ${bold(`${pg.repo.owner}/${pg.repo.name}/${pg.branch}`)} is ${italic(pg.state)}`,
                        fallback: pg.goalSet,
                        actions: [
                            buttonForCommand({ text: "Cancel" }, cancelGoalSetsCommand(sdm).name, {
                                goalSetId: pg.goalSetId,
                                msgId: id,
                            }),
                        ],
                    });
                }
                offset = offset + pgs.length;
                pgs = await pendingGoalSets(ci.context, sdm.configuration.name, offset);
            }

            const update: Action = buttonForCommand(
                { text: "Refresh" },
github atomist / sdm-core / lib / internal / delivery / build / local / projectVersioner.ts View on Github external
repo: {
                    owner: goalEvent.repo.owner,
                    name: goalEvent.repo.name,
                    providerId: goalEvent.repo.providerId,
                },
            };
            await context.graphClient.mutate({
                name: "UpdateSdmVersion",
                variables: {
                    version: sdmVersion,
                },
                options: MutationNoCacheOptions,
            });
            return {
                ...Success,
                description: `Versioned ${codeLine(version)}`,
            };
        });
    };
github atomist / sdm / lib / api-helper / command / transform / codeTransformWrapping.ts View on Github external
return async ci => {
        const target = ci.parameters.targets;
        if (!target || !target.repoRef || !target.repoRef.owner || !target.repoRef.repo) {
            await ci.context.messageClient.respond(
                slackErrorMessage(
                    "Code Transform",
                    `Can only invoke Code Transform ${italic(ci.commandName)} against a single repository. ` +
                    `Please specify ${codeLine("targets.owner")} and ${codeLine("targets.repo")} parameters.`,
                    ci.context));
            return Success;
        }

        const id = ci.ids[0];

        return sdm.configuration.sdm.projectLoader.doWithProject({
            credentials: ci.credentials,
            id,
            readOnly: true,
            context: ci.context,
            cloneOptions: {
                alwaysDeep: false,
            },
        }, async p => {
github atomist / sdm-core / lib / pack / info / SelfDescribe.ts View on Github external
const gitInfo = info(automationClientInstance().automations.automations);

        const msg: SlackMessage = {
            attachments: [{
                author_name: pj.author && pj.author.name ? pj.author.name : pj.author,
                title: sdm.name,
                title_link: pj.homepage,
                fallback: sdm.name,
                text: `${pj.description}
Version: ${codeLine(sdm.configuration.version)} - License: ${codeLine(pj.license)}`,
            }, {
                author_name: "Details",
                fallback: "Details",
                text: `Sha: ${codeLine(gitInfo.git && gitInfo.git.sha ? gitInfo.git.sha.slice(0, 7) : "n/a")}
Repository: ${codeLine(gitInfo.git && gitInfo.git.repository ? gitInfo.git.repository : "n/a")}
Policy: ${codeLine(sdm.configuration.policy)}
Environment: ${codeLine(sdm.configuration.environment)}
Cluster: ${codeLine(sdm.configuration.cluster.enabled ? "enabled" : "disabled")}`,
            }, {
                author_name: "Dependencies",
                fallback: "Dependencies",
                text: `${codeLine(`${clientPj.name}:${clientPj.version}`)}
${codeLine(`${sdmPj.name}:${sdmPj.version}`)}
${codeLine(`${sdmCorePj.name}:${sdmCorePj.version}`)}`,
            }, {
                author_name: "Extension Packs",
                fallback: "Extension Packs",
                text: [...sdm.extensionPacks]
                    .sort((e1, e2) => e1.name.localeCompare(e2.name))
                    .map(e => `${codeLine(`${e.name}:${e.version}`)} ${e.vendor}`).join("\n"),
            }, {
                author_name: "Events",