1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.default = void 0;
|
5 |
|
6 | var _fsExtra = require("fs-extra");
|
7 |
|
8 | var _os = require("os");
|
9 |
|
10 | var _path = require("path");
|
11 |
|
12 | var _chalk = _interopRequireDefault(require("chalk"));
|
13 |
|
14 | var _utils = require("./utils");
|
15 |
|
16 | var _utils2 = require("../utils");
|
17 |
|
18 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19 |
|
20 | (0, _fsExtra.ensureDirSync)((0, _path.join)((0, _os.tmpdir)(), "gd-scripts", "fixtures"));
|
21 | const repos = ["https://github.com/GabrielDuarteM/youtube-autoclose-ads.git", "https://github.com/GabrielDuarteM/copy-paste-component.git", "https://github.com/GabrielDuarteM/copy-paste-component-vscode.git", "https://github.com/GabrielDuarteM/pipe-now.git"];
|
22 | const statuses = [];
|
23 |
|
24 | const runFuncOnEveryRepo = async (func, message, currStep, totalSteps, afterFunc) => {
|
25 | for (let i = 0; i < repos.length; i++) {
|
26 | const repo = repos[i];
|
27 | const repoName = (0, _utils.getRepoName)(repo);
|
28 | (0, _utils2.logMessage)(`[${repoName} | ${i + 1}/${repos.length} | Step ${currStep}/${totalSteps}] ${message}`);
|
29 | const result = await func(repo);
|
30 |
|
31 | if (afterFunc) {
|
32 | afterFunc(result);
|
33 | }
|
34 | }
|
35 | };
|
36 |
|
37 | const logStatus = (repoName, status, spaceLength) => {
|
38 | console.log(`${repoName}${" ".repeat(spaceLength)}${status === 0 ? _chalk.default.green("SUCCESS") : _chalk.default.red("ERROR")}`);
|
39 | };
|
40 |
|
41 | const test = async () => {
|
42 | const totalSteps = 3;
|
43 | let currStep = 0;
|
44 | await runFuncOnEveryRepo(_utils.cloneOrPull, "Cloning repo", currStep += 1, totalSteps);
|
45 | await runFuncOnEveryRepo(_utils.runYarnAddGdScripts, "Installing the new version of gd-scripts", currStep += 1, totalSteps);
|
46 | await runFuncOnEveryRepo(_utils.runYarnCi, "Running CI Script", currStep += 1, totalSteps, result => {
|
47 | statuses.push(result.status);
|
48 | });
|
49 | const results = statuses.reduce((acc, item, index) => [...acc, {
|
50 | repoName: (0, _utils.getRepoName)(repos[index]),
|
51 | status: item
|
52 | }], []);
|
53 | const longestNameLength = results.reduce((acc, item) => acc >= item.repoName.length ? acc : item.repoName.length, 0);
|
54 | console.log(`\n${_chalk.default.cyan("TEST RESULTS:")}`);
|
55 | console.log();
|
56 | results.forEach(result => {
|
57 | logStatus(result.repoName, result.status, longestNameLength - result.repoName.length + 2);
|
58 | });
|
59 | console.log();
|
60 | const finalStatus = statuses.some(x => x === 1) ? 1 : 0;
|
61 | process.exit(finalStatus);
|
62 | };
|
63 |
|
64 | var _default = test;
|
65 | exports.default = _default;
|
66 |
|
\ | No newline at end of file |