UNPKG

2.79 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright © 2018 Atomist, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18 return new (P || (P = Promise))(function (resolve, reject) {
19 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
22 step((generator = generator.apply(thisArg, _arguments || [])).next());
23 });
24};
25Object.defineProperty(exports, "__esModule", { value: true });
26const RolarProgressLog_1 = require("./RolarProgressLog");
27/**
28 * Persistent Rolar log that displays in the Dashboard
29 */
30class DashboardDisplayProgressLog {
31 constructor(rolarBaseUrl, bufferSize, flushInterval, context, sdmGoal) {
32 this.context = context;
33 this.sdmGoal = sdmGoal;
34 this.rolarProgressLog =
35 new RolarProgressLog_1.RolarProgressLog(rolarBaseUrl, constructLogPath(context, sdmGoal), bufferSize, flushInterval);
36 }
37 get name() {
38 return this.rolarProgressLog.name;
39 }
40 get url() {
41 const path = constructLogPath(this.context, this.sdmGoal);
42 return `https://app.atomist.com/workspace/${path[0]}/logs/${path.slice(1).join("/")}`;
43 }
44 isAvailable() {
45 return __awaiter(this, void 0, void 0, function* () {
46 return this.rolarProgressLog.isAvailable();
47 });
48 }
49 write(what) {
50 this.rolarProgressLog.write(what);
51 }
52 flush() {
53 return this.rolarProgressLog.flush();
54 }
55 close() {
56 return this.rolarProgressLog.close();
57 }
58}
59exports.DashboardDisplayProgressLog = DashboardDisplayProgressLog;
60function constructLogPath(context, sdmGoal) {
61 return [
62 context.teamId,
63 sdmGoal.repo.owner,
64 sdmGoal.repo.name,
65 sdmGoal.sha,
66 sdmGoal.environment,
67 sdmGoal.name,
68 sdmGoal.goalSetId,
69 context.correlationId,
70 ];
71}
72exports.constructLogPath = constructLogPath;
73//# sourceMappingURL=DashboardDisplayProgressLog.js.map
\No newline at end of file