Refactor CLI/cleanup

pull/310/head
Frostebite 2021-12-25 19:55:20 +00:00
parent 079d526f16
commit bd731a540a
10 changed files with 39 additions and 16 deletions

35
dist/index.js vendored
View File

@ -381,12 +381,12 @@ exports.CLI = void 0;
const commander_ts_1 = __webpack_require__(40451); const commander_ts_1 = __webpack_require__(40451);
const __1 = __webpack_require__(41359); const __1 = __webpack_require__(41359);
const core = __importStar(__webpack_require__(42186)); const core = __importStar(__webpack_require__(42186));
const remote_client_1 = __webpack_require__(95575); const cloud_runner_client_1 = __webpack_require__(74462);
class CLI { class CLI {
static RunCli(options) { static RunCli(options) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (options.mode === 'remote-cli') { if (options.mode === 'remote-cli') {
yield remote_client_1.RemoteClient.Run(options); yield cloud_runner_client_1.RemoteClient.Run(options);
} }
else { else {
options.versioning = 'None'; options.versioning = 'None';
@ -430,7 +430,22 @@ exports.CLI = CLI;
/***/ }), /***/ }),
/***/ 95575: /***/ 52818:
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CloudRunnerClientStatics = void 0;
class CloudRunnerClientStatics {
}
exports.CloudRunnerClientStatics = CloudRunnerClientStatics;
CloudRunnerClientStatics.logPrefix = `Cloud-Runner-Client`;
/***/ }),
/***/ 74462:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) { /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict"; "use strict";
@ -447,7 +462,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RemoteClient = void 0; exports.RemoteClient = void 0;
const cloud_runner_state_1 = __webpack_require__(70912); const cloud_runner_state_1 = __webpack_require__(70912);
const setup_remote_repository_1 = __webpack_require__(62100); const setup_remote_repository_1 = __webpack_require__(40601);
class RemoteClient { class RemoteClient {
static Run(options) { static Run(options) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -466,7 +481,7 @@ exports.RemoteClient = RemoteClient;
/***/ }), /***/ }),
/***/ 91269: /***/ 21227:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) { /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict"; "use strict";
@ -512,7 +527,7 @@ exports.RemoteClientSystem = RemoteClientSystem;
/***/ }), /***/ }),
/***/ 62100: /***/ 40601:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) { /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict"; "use strict";
@ -535,7 +550,7 @@ const fs_1 = __importDefault(__webpack_require__(35747));
const path_1 = __importDefault(__webpack_require__(85622)); const path_1 = __importDefault(__webpack_require__(85622));
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855)); const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
const cloud_runner_state_1 = __webpack_require__(70912); const cloud_runner_state_1 = __webpack_require__(70912);
const remote_client_system_1 = __webpack_require__(91269); const remote_client_system_1 = __webpack_require__(21227);
class SetupRemoteRepository { class SetupRemoteRepository {
static run() { static run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -877,6 +892,7 @@ const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
const __1 = __webpack_require__(41359); const __1 = __webpack_require__(41359);
const fs_1 = __importDefault(__webpack_require__(35747)); const fs_1 = __importDefault(__webpack_require__(35747));
const cloud_runner_state_1 = __webpack_require__(70912); const cloud_runner_state_1 = __webpack_require__(70912);
const cloud_runner_client_statics_1 = __webpack_require__(52818);
class AWSBuildRunner { class AWSBuildRunner {
static runTask(taskDef, ECS, CF, environment, buildGuid, commands) { static runTask(taskDef, ECS, CF, environment, buildGuid, commands) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
@ -1008,7 +1024,7 @@ class AWSBuildRunner {
else if (message.includes('Rebuilding Library because the asset database could not be found!')) { else if (message.includes('Rebuilding Library because the asset database could not be found!')) {
core.warning('LIBRARY NOT FOUND!'); core.warning('LIBRARY NOT FOUND!');
} }
message = `[Cloud-Runner-Agent] ${message}`; message = `[${cloud_runner_client_statics_1.CloudRunnerClientStatics.logPrefix}] ${message}`;
if (cloud_runner_state_1.CloudRunnerState.buildParams.logToFile) { if (cloud_runner_state_1.CloudRunnerState.buildParams.logToFile) {
fs_1.default.appendFileSync(`${cloud_runner_state_1.CloudRunnerState.buildGuid}-outputfile.txt`, `${message}\r\n`); fs_1.default.appendFileSync(`${cloud_runner_state_1.CloudRunnerState.buildGuid}-outputfile.txt`, `${message}\r\n`);
} }
@ -1934,6 +1950,7 @@ const stream_1 = __webpack_require__(92413);
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855)); const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
const cloud_runner_state_1 = __webpack_require__(70912); const cloud_runner_state_1 = __webpack_require__(70912);
const fs_1 = __importDefault(__webpack_require__(35747)); const fs_1 = __importDefault(__webpack_require__(35747));
const cloud_runner_client_statics_1 = __webpack_require__(52818);
class KubernetesLogging { class KubernetesLogging {
static streamLogs(kubeConfig, kubeClient, jobName, podName, containerName, namespace, logCallback) { static streamLogs(kubeConfig, kubeClient, jobName, podName, containerName, namespace, logCallback) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -1943,7 +1960,7 @@ class KubernetesLogging {
stream._write = (chunk, encoding, next) => { stream._write = (chunk, encoding, next) => {
didStreamAnyLogs = true; didStreamAnyLogs = true;
let message = chunk.toString(); let message = chunk.toString();
message = `[Cloud-Runner-Agent] ${message}`; message = `[${cloud_runner_client_statics_1.CloudRunnerClientStatics.logPrefix}] ${message}`;
if (cloud_runner_state_1.CloudRunnerState.buildParams.logToFile) { if (cloud_runner_state_1.CloudRunnerState.buildParams.logToFile) {
fs_1.default.appendFileSync(`${cloud_runner_state_1.CloudRunnerState.buildGuid}-outputfile.txt`, `${message}\r\n`); fs_1.default.appendFileSync(`${cloud_runner_state_1.CloudRunnerState.buildGuid}-outputfile.txt`, `${message}\r\n`);
} }

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
import { Command } from 'commander-ts'; import { Command } from 'commander-ts';
import { BuildParameters, CloudRunner, ImageTag, Input } from '..'; import { BuildParameters, CloudRunner, ImageTag, Input } from '..';
import * as core from '@actions/core'; import * as core from '@actions/core';
import { RemoteClient } from './remote-client'; import { RemoteClient } from './cloud-runner-client';
export class CLI { export class CLI {
static async RunCli(options: any) { static async RunCli(options: any) {

View File

@ -0,0 +1,3 @@
export class CloudRunnerClientStatics {
public static readonly logPrefix = `Cloud-Runner-Client`;
}

View File

@ -7,6 +7,7 @@ import CloudRunnerLogger from '../services/cloud-runner-logger';
import { Input } from '../..'; import { Input } from '../..';
import fs from 'fs'; import fs from 'fs';
import { CloudRunnerState } from '../state/cloud-runner-state'; import { CloudRunnerState } from '../state/cloud-runner-state';
import { CloudRunnerClientStatics } from '../../cli/cloud-runner-client/cloud-runner-client-statics';
class AWSBuildRunner { class AWSBuildRunner {
static async runTask( static async runTask(
@ -178,7 +179,7 @@ class AWSBuildRunner {
} else if (message.includes('Rebuilding Library because the asset database could not be found!')) { } else if (message.includes('Rebuilding Library because the asset database could not be found!')) {
core.warning('LIBRARY NOT FOUND!'); core.warning('LIBRARY NOT FOUND!');
} }
message = `[Cloud-Runner-Agent] ${message}`; message = `[${CloudRunnerClientStatics.logPrefix}] ${message}`;
if (CloudRunnerState.buildParams.logToFile) { if (CloudRunnerState.buildParams.logToFile) {
fs.appendFileSync(`${CloudRunnerState.buildGuid}-outputfile.txt`, `${message}\r\n`); fs.appendFileSync(`${CloudRunnerState.buildGuid}-outputfile.txt`, `${message}\r\n`);
} }

View File

@ -3,6 +3,7 @@ import CloudRunner from './cloud-runner';
import Input from '../input'; import Input from '../input';
import fs from 'fs'; import fs from 'fs';
import { CloudRunnerState } from './state/cloud-runner-state'; import { CloudRunnerState } from './state/cloud-runner-state';
import { CloudRunnerClientStatics } from '../cli/cloud-runner-client/cloud-runner-client-statics';
describe('Cloud Runner', () => { describe('Cloud Runner', () => {
it('responds', () => {}); it('responds', () => {});
@ -35,9 +36,9 @@ describe('Cloud Runner', () => {
const inputKeys = Object.getOwnPropertyNames(Input); const inputKeys = Object.getOwnPropertyNames(Input);
for (const element of inputKeys) { for (const element of inputKeys) {
if (Input[element] !== undefined && typeof Input[element] != 'function') { if (Input[element] !== undefined && typeof Input[element] != 'function') {
expect(file.replace(/\s+/g, '').replace(new RegExp('\\[Cloud-Runner-Agent\\]', 'g'), '')).toContain( expect(
`${element}=${Input[element].toString().replace(/\s+/g, '')}`, file.replace(/\s+/g, '').replace(new RegExp(`\\[${CloudRunnerClientStatics.logPrefix}\\]`, 'g'), ''),
); ).toContain(`${element}=${Input[element].toString().replace(/\s+/g, '')}`);
} }
} }
} }

View File

@ -3,6 +3,7 @@ import { Writable } from 'stream';
import CloudRunnerLogger from '../services/cloud-runner-logger'; import CloudRunnerLogger from '../services/cloud-runner-logger';
import { CloudRunnerState } from '../state/cloud-runner-state'; import { CloudRunnerState } from '../state/cloud-runner-state';
import fs from 'fs'; import fs from 'fs';
import { CloudRunnerClientStatics } from '../../cli/cloud-runner-client/cloud-runner-client-statics';
class KubernetesLogging { class KubernetesLogging {
static async streamLogs( static async streamLogs(
kubeConfig: KubeConfig, kubeConfig: KubeConfig,
@ -19,7 +20,7 @@ class KubernetesLogging {
stream._write = (chunk, encoding, next) => { stream._write = (chunk, encoding, next) => {
didStreamAnyLogs = true; didStreamAnyLogs = true;
let message = chunk.toString(); let message = chunk.toString();
message = `[Cloud-Runner-Agent] ${message}`; message = `[${CloudRunnerClientStatics.logPrefix}] ${message}`;
if (CloudRunnerState.buildParams.logToFile) { if (CloudRunnerState.buildParams.logToFile) {
fs.appendFileSync(`${CloudRunnerState.buildGuid}-outputfile.txt`, `${message}\r\n`); fs.appendFileSync(`${CloudRunnerState.buildGuid}-outputfile.txt`, `${message}\r\n`);
} }