UNPKG

@atomist/atomist-sdm

Version:

Atomist SDM to deliver our own projects

108 lines (104 loc) 4.55 kB
"use strict"; /* * Copyright © 2019 Atomist, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * 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. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const automation_client_1 = require("@atomist/automation-client"); const sdm_1 = require("@atomist/sdm"); const changelog_1 = require("@atomist/sdm-pack-changelog/lib/changelog/changelog"); const _ = require("lodash"); const ChangelogRepos = [{ repo: "sdm", owner: "atomist", }, { repo: "sdm-core", owner: "atomist", }, { repo: "automation-client", owner: "atomist", }, { repo: "sdm-local", owner: "atomist", }, { repo: "cli", owner: "atomist", }, ]; exports.GenerateChangelog = { name: "generate-changelog", intent: "release changelog", description: "Generate a changelog across automation-client, sdm, sdm-core, sdm-local and cli projects", parameters: { token: { declarationType: sdm_1.DeclarationType.Secret, uri: automation_client_1.Secrets.userToken("repo") } }, listener: (ci) => __awaiter(this, void 0, void 0, function* () { // "added" | "changed" | "deprecated" | "removed" | "fixed" | "security"; const changelog = { added: [], changed: [], deprecated: [], removed: [], fixed: [], security: [], }; const versions = []; for (const repo of ChangelogRepos) { const rcl = yield getChangelog(repo.repo, repo.owner, { token: ci.parameters.token }); const entries = rcl.versions[1].parsed; // tslint:disable-next-line:max-line-length versions.push(`- [\`@${repo.owner}/${repo.repo}@${rcl.versions[1].version}\`](https://npmjs.com/package/@${repo.owner}/${repo.repo}) - [Source Code](https://github.com/${repo.owner}/${repo.repo}), [API Docs](https://${repo.owner}.github.io/${repo.repo}/), [OSS Licenses](https://github.com/${repo.owner}/${repo.repo}/blob/master/legal/THIRD_PARTY.md)`); _.forEach(entries, (v, k) => { if (k !== "_") { changelog[_.lowerFirst(k)].push(...v.map(e => `${e} \`@${repo.owner}/${repo.repo}@${rcl.versions[1].version}\``)); } }); } const content = []; content.push(`## Changelog Here is the combined changelog for the following released projects: ${versions.join("\n")} The format is based on [Keep a Changelog](http://keepachangelog.com/) and the projects adhere to [Semantic Versioning](http://semver.org/). `); _.forEach(changelog, (v, k) => { if (v && v.length > 0) { content.push(`### ${_.upperFirst(k)} ${v.join("\n")} `); } }); const msg = { fileName: "changelog.md", fileType: "markdown", content: content.join("\n"), title: "Combined Changelog", }; yield ci.context.messageClient.respond(msg); return automation_client_1.Success; }), }; function getChangelog(repo, owner, creds) { return __awaiter(this, void 0, void 0, function* () { const id = automation_client_1.GitHubRepoRef.from({ owner, repo, branch: "master" }); const gp = yield automation_client_1.GitCommandGitProject.cloned(creds, id); return changelog_1.readChangelog(gp); }); } //# sourceMappingURL=changelog.js.map