UNPKG

@atomist/atomist-sdm

Version:

Atomist SDM to deliver our own projects

74 lines 3.73 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"); function isNamed(...names) { return sdm_1.pushTest(`Project name is one of these '${names.join(", ")}'`, (pci) => __awaiter(this, void 0, void 0, function* () { if (names.includes(pci.project.name)) { automation_client_1.logger.info("True: Project %s (in repo %s) in my list of names, which is %s", pci.project.name, pci.id.repo, names); return true; } else { automation_client_1.logger.info("False: Project %s (in repo %s) is not in my list of names, which is %s", pci.project.name, pci.id.repo, names); return false; } })); } exports.isNamed = isNamed; function nameMatches(...regexps) { const res = regexps.map(r => r.toString()).join(", "); return sdm_1.pushTest(`Project name matches one of these regular expressions '${res}'`, (pci) => __awaiter(this, void 0, void 0, function* () { if (regexps.some(r => r.test(pci.project.name))) { automation_client_1.logger.info("True: Project %s (in repo %s) matches a regular expression, one of %s", pci.project.name, pci.id.repo, res); return true; } else { automation_client_1.logger.info("False: Project %s (in repo %s) does not match any regular expression, none of %s", pci.project.name, pci.id.repo, res); return false; } })); } exports.nameMatches = nameMatches; function isOrgNamed(...names) { return sdm_1.pushTest(`Org name is one of these '${names.join(", ")}'`, (pci) => __awaiter(this, void 0, void 0, function* () { if (names.includes(pci.push.repo.owner)) { automation_client_1.logger.info("True: Org %s (in repo %s) in my list of names, which is %s", pci.push.repo.owner, pci.id.repo, names); return true; } else { automation_client_1.logger.info("False: Org %s (in repo %s) is not in my list of names, which is %s", pci.push.repo.owner, pci.id.repo, names); return false; } })); } exports.isOrgNamed = isOrgNamed; function isTeam(...teams) { return sdm_1.pushTest(`Atomist team is one of these '${teams.join(", ")}'`, (pci) => __awaiter(this, void 0, void 0, function* () { return teams.includes(pci.context.workspaceId); })); } exports.isTeam = isTeam; //# sourceMappingURL=identityPushTests.js.map