UNPKG

@atomist/sdm-pack-aspect

Version:

an Atomist SDM Extension Pack for visualizing drift across an organization

116 lines 5.11 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 spiderCall_1 = require("./spiderCall"); const AnalyzeCommandParameterDefinitions = { workspaceId: { description: "Atomist workspace ID to save analysis in. Defaults to 'local'", defaultValue: "local", required: false, }, update: { type: "boolean", description: "Overwrite existing analyses? (default is no)", required: false, }, }; const AnalyzeGitHubCommandParametersDefinition = Object.assign({}, AnalyzeCommandParameterDefinitions, { source: { description: "find repositories on GitHub. Please specify at least 'owner' or 'query'", defaultValue: "GitHub", displayable: false, required: false, pattern: /GitHub/, validInput: "'GitHub'", }, owner: { description: "GitHub owner of repositories to analyze", required: true, }, query: { description: "A GitHub search query to choose repositories", required: true, }, search: { description: "To narrow which repositories within an owner, provide a substring to look for in the repo name", required: false, }, cloneUnder: { description: "A local directory to clone repositories in", required: false, } }); const AnalyzeLocalCommandParametersDefinition = Object.assign({}, AnalyzeCommandParameterDefinitions, { source: { description: "find repositories on the local filesystem", defaultValue: "local", displayable: false, required: false, pattern: /local/, validInput: "'local'", }, localDirectory: { description: "absolute path to find repositories in", required: true, } }); function analyzeFromGitHub(analyzer) { return (d) => __awaiter(this, void 0, void 0, function* () { const { owner, query } = d.parameters; if (!owner && !query) { yield d.addressChannels("Please provide either 'owner' or 'query'"); return { code: 1 }; } const spiderAppOptions = d.parameters; automation_client_1.logger.info("analyze github invoked with " + JSON.stringify(spiderAppOptions)); const result = yield spiderCall_1.spider(spiderAppOptions, analyzer); yield d.addressChannels(`Analysis result: ` + JSON.stringify(result, undefined, 2)); return { code: 0 }; }); } function analyzeGitHubCommandRegistration(analyzer) { return { name: "analyzeRepositoriesFromGitHub", intent: ["analyze github repositories"], description: "choose repositories to analyze, by owner or query", parameters: AnalyzeGitHubCommandParametersDefinition, listener: analyzeFromGitHub(analyzer), }; } exports.analyzeGitHubCommandRegistration = analyzeGitHubCommandRegistration; function analyzeFromLocal(analyzer) { return (d) => __awaiter(this, void 0, void 0, function* () { const spiderAppOptions = d.parameters; automation_client_1.logger.info("analyze local invoked with " + JSON.stringify(spiderAppOptions)); const result = yield spiderCall_1.spider(spiderAppOptions, analyzer); yield d.addressChannels(`Analysis result: ` + JSON.stringify(result, undefined, 2)); return { code: 0 }; }); } function analyzeLocalCommandRegistration(analyzer) { return { name: "analyzeRepositoriesFromLocalFilesystem", intent: ["analyze local repositories"], description: "choose repositories to analyze, by parent directory", parameters: AnalyzeLocalCommandParametersDefinition, listener: analyzeFromLocal(analyzer), }; } exports.analyzeLocalCommandRegistration = analyzeLocalCommandRegistration; //# sourceMappingURL=analyzeCommand.js.map