@@ -168,15 +168,16 @@ const core_1 = __nccwpck_require__(2186);
168168function getAndValidateArgs() {
169169 var _a, _b, _c, _d;
170170 const args = {
171- repoToken: core_1.getInput('repo-token', { required: true }),
172- directory: core_1.getInput('directory'),
173- tsConfigPath: core_1.getInput('ts-config-path'),
171+ repoToken: core_1.getInput('repo-token', { required: true, trimWhitespace: true }),
172+ directory: core_1.getInput('directory', { trimWhitespace: true } ),
173+ tsConfigPath: core_1.getInput('ts-config-path', { trimWhitespace: true, required: true } ),
174174 filesChanged: ((_a = core_1.getInput('files-changed')) !== null && _a !== void 0 ? _a : "").split(" "),
175175 filesAdded: ((_b = core_1.getInput('files-added')) !== null && _b !== void 0 ? _b : "").split(" "),
176176 filesDeleted: ((_c = core_1.getInput('files-deleted')) !== null && _c !== void 0 ? _c : "").split(" "),
177177 lineNumbers: (_d = JSON.parse(core_1.getInput('line-numbers'))) !== null && _d !== void 0 ? _d : [],
178- useCheck: core_1.getInput('use-check').trim() === 'true' ? true : false,
179- checkFailMode: core_1.getInput('check-fail-mode')
178+ useCheck: core_1.getBooleanInput('use-check'),
179+ checkFailMode: core_1.getInput('check-fail-mode'),
180+ debug: core_1.getBooleanInput('debug')
180181 };
181182 if (![
182183 "added" /* ON_ERRORS_ADDED_IN_PR */,
@@ -240,6 +241,7 @@ function getBodyComment({ errorsInProjectBefore, errorsInProjectAfter, errorsInM
240241 s += BLANK_LINE;
241242 }
242243 if (newErrorsInModifiedFiles.length > 0) {
244+ s += BLANK_LINE;
243245 s += `**${newErrorsInModifiedFiles.length} new errors added** \n`;
244246 s += `*Note : in some cases, new errors can be just same errors but with different locations*`;
245247 s += BLANK_LINE;
@@ -252,7 +254,7 @@ function getBodyComment({ errorsInProjectBefore, errorsInProjectAfter, errorsInM
252254 return s;
253255}
254256exports.getBodyComment = getBodyComment;
255- function getListOfErrors(title, errors, thresholdCollapse = 10 ) {
257+ function getListOfErrors(title, errors, thresholdCollapse = 5 ) {
256258 const shouldUseCollapsible = errors.length > thresholdCollapse;
257259 let s = ``;
258260 if (shouldUseCollapsible) {
@@ -274,7 +276,7 @@ function getListOfErrors(title, errors, thresholdCollapse = 10) {
274276 }
275277 return s;
276278}
277- function getNbOfErrorsByFile(title, errors, thresholdCollapse = 10 ) {
279+ function getNbOfErrorsByFile(title, errors, thresholdCollapse = 5 ) {
278280 const errorsByFile = [];
279281 errors.forEach(err => {
280282 const errByFileFound = errorsByFile.find(o => o.fileName === err.fileName);
@@ -299,7 +301,6 @@ function getNbOfErrorsByFile(title, errors, thresholdCollapse = 10) {
299301 s += BLANK_LINE;
300302 }
301303 else {
302- s += BLANK_LINE;
303304 s += `${title} \n`;
304305 s += BLANK_LINE;
305306 }
@@ -312,9 +313,6 @@ function getNbOfErrorsByFile(title, errors, thresholdCollapse = 10) {
312313 s += BLANK_LINE;
313314 s += `</details> \n`;
314315 }
315- else {
316- s += BLANK_LINE;
317- }
318316 return s;
319317}
320318
@@ -405,11 +403,14 @@ async function run() {
405403 tsconfigPath
406404 });
407405 const errorsPr = parseOutputTsc_1.parseOutputTsc(tscOutputCurrent);
408- if (errorsPr.length) {
409- core_1.info(`[current branch] ts errors : 10 first:\n ${JSON.stringify(errorsPr.slice(0, 10))}`);
410- }
411- else {
412- core_1.info(`[current branch] : no error detected`);
406+ core_1.info(`[current branch] : ${errorsPr.length} error(s) detected`);
407+ const ansiColorsCode = {
408+ magenta: '\u001b[35m',
409+ cyan: '\u001b[38;5;6m',
410+ red: '\u001b[38;2;255;0;0m'
411+ };
412+ if (args.debug) {
413+ core_1.info(`${ansiColorsCode.cyan}[current branch] all errors: \n${JSON.stringify(errorsPr)}`);
413414 }
414415 core_1.endGroup();
415416 // ***********************************************************************************************
@@ -426,7 +427,10 @@ async function run() {
426427 tsconfigPath
427428 });
428429 const errorsBaseBranch = parseOutputTsc_1.parseOutputTsc(tscOutputBase);
429- core_1.info(`[base branch] ts errors : 10 first : \n ${JSON.stringify(errorsBaseBranch.slice(0, 10))}`);
430+ core_1.info(`[base branch] : ${errorsBaseBranch.length} error(s) detected`);
431+ if (args.debug) {
432+ core_1.info(`${ansiColorsCode.cyan}[base branch] all errors: \n${JSON.stringify(errorsBaseBranch)}`);
433+ }
430434 core_1.endGroup();
431435 core_1.startGroup(`Comparing errors`);
432436 const resultCompareErrors = compareErrors_1.compareErrors({
@@ -437,13 +441,17 @@ async function run() {
437441 filesDeleted: args.filesDeleted,
438442 lineNumbers: args.lineNumbers
439443 });
440- core_1.info(`Contenu de resultCompareErrors : ${JSON.stringify(resultCompareErrors)}`);
444+ if (args.debug) {
445+ core_1.info(`${ansiColorsCode.cyan}Contenu de resultCompareErrors : ${JSON.stringify(resultCompareErrors)}`);
446+ }
441447 const errorsInModifiedFiles = errorsPr.filter(err => {
442448 return args.filesChanged.concat(args.filesAdded).includes(err.fileName);
443449 });
450+ core_1.info(`${errorsInModifiedFiles.length} errors in modified files`);
444451 const newErrorsInModifiedFiles = resultCompareErrors.errorsAdded.filter(err => {
445452 return args.filesChanged.concat(args.filesAdded).includes(err.fileName);
446453 });
454+ core_1.info(`${newErrorsInModifiedFiles.length} added errors in modified files`);
447455 core_1.endGroup();
448456 core_1.startGroup(`Creating comment`);
449457 const commentInfo = {
@@ -740,6 +748,7 @@ async function runTscCli({ workingDir, tsconfigPath, files }) {
740748 catch (error) {
741749 core_1.setFailed(error.message);
742750 }
751+ process.exitCode = 0;
743752 return {
744753 output: myOutput,
745754 error: myError
@@ -755,14 +764,27 @@ exports.runTscCli = runTscCli;
755764
756765"use strict";
757766
767+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
768+ if (k2 === undefined) k2 = k;
769+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
770+ }) : (function(o, m, k, k2) {
771+ if (k2 === undefined) k2 = k;
772+ o[k2] = m[k];
773+ }));
774+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
775+ Object.defineProperty(o, "default", { enumerable: true, value: v });
776+ }) : function(o, v) {
777+ o["default"] = v;
778+ });
758779var __importStar = (this && this.__importStar) || function (mod) {
759780 if (mod && mod.__esModule) return mod;
760781 var result = {};
761- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k] ;
762- result["default"] = mod;
782+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding( result, mod, k) ;
783+ __setModuleDefault( result, mod) ;
763784 return result;
764785};
765786Object.defineProperty(exports, "__esModule", ({ value: true }));
787+ exports.issue = exports.issueCommand = void 0;
766788const os = __importStar(__nccwpck_require__(2087));
767789const utils_1 = __nccwpck_require__(5278);
768790/**
@@ -841,6 +863,25 @@ function escapeProperty(s) {
841863
842864"use strict";
843865
866+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
867+ if (k2 === undefined) k2 = k;
868+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
869+ }) : (function(o, m, k, k2) {
870+ if (k2 === undefined) k2 = k;
871+ o[k2] = m[k];
872+ }));
873+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
874+ Object.defineProperty(o, "default", { enumerable: true, value: v });
875+ }) : function(o, v) {
876+ o["default"] = v;
877+ });
878+ var __importStar = (this && this.__importStar) || function (mod) {
879+ if (mod && mod.__esModule) return mod;
880+ var result = {};
881+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
882+ __setModuleDefault(result, mod);
883+ return result;
884+ };
844885var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
845886 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
846887 return new (P || (P = Promise))(function (resolve, reject) {
@@ -850,14 +891,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
850891 step((generator = generator.apply(thisArg, _arguments || [])).next());
851892 });
852893};
853- var __importStar = (this && this.__importStar) || function (mod) {
854- if (mod && mod.__esModule) return mod;
855- var result = {};
856- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
857- result["default"] = mod;
858- return result;
859- };
860894Object.defineProperty(exports, "__esModule", ({ value: true }));
895+ exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
861896const command_1 = __nccwpck_require__(7351);
862897const file_command_1 = __nccwpck_require__(717);
863898const utils_1 = __nccwpck_require__(5278);
@@ -924,7 +959,9 @@ function addPath(inputPath) {
924959}
925960exports.addPath = addPath;
926961/**
927- * Gets the value of an input. The value is also trimmed.
962+ * Gets the value of an input.
963+ * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
964+ * Returns an empty string if the value is not defined.
928965 *
929966 * @param name name of the input to get
930967 * @param options optional. See InputOptions.
@@ -935,9 +972,49 @@ function getInput(name, options) {
935972 if (options && options.required && !val) {
936973 throw new Error(`Input required and not supplied: ${name}`);
937974 }
975+ if (options && options.trimWhitespace === false) {
976+ return val;
977+ }
938978 return val.trim();
939979}
940980exports.getInput = getInput;
981+ /**
982+ * Gets the values of an multiline input. Each value is also trimmed.
983+ *
984+ * @param name name of the input to get
985+ * @param options optional. See InputOptions.
986+ * @returns string[]
987+ *
988+ */
989+ function getMultilineInput(name, options) {
990+ const inputs = getInput(name, options)
991+ .split('\n')
992+ .filter(x => x !== '');
993+ return inputs;
994+ }
995+ exports.getMultilineInput = getMultilineInput;
996+ /**
997+ * Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
998+ * Support boolean input list: `true | True | TRUE | false | False | FALSE` .
999+ * The return value is also in boolean type.
1000+ * ref: https://yaml.org/spec/1.2/spec.html#id2804923
1001+ *
1002+ * @param name name of the input to get
1003+ * @param options optional. See InputOptions.
1004+ * @returns boolean
1005+ */
1006+ function getBooleanInput(name, options) {
1007+ const trueValue = ['true', 'True', 'TRUE'];
1008+ const falseValue = ['false', 'False', 'FALSE'];
1009+ const val = getInput(name, options);
1010+ if (trueValue.includes(val))
1011+ return true;
1012+ if (falseValue.includes(val))
1013+ return false;
1014+ throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
1015+ `Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
1016+ }
1017+ exports.getBooleanInput = getBooleanInput;
9411018/**
9421019 * Sets the value of an output.
9431020 *
@@ -946,6 +1023,7 @@ exports.getInput = getInput;
9461023 */
9471024// eslint-disable-next-line @typescript-eslint/no-explicit-any
9481025function setOutput(name, value) {
1026+ process.stdout.write(os.EOL);
9491027 command_1.issueCommand('set-output', { name }, value);
9501028}
9511029exports.setOutput = setOutput;
@@ -1087,14 +1165,27 @@ exports.getState = getState;
10871165"use strict";
10881166
10891167// For internal use, subject to change.
1168+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1169+ if (k2 === undefined) k2 = k;
1170+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1171+ }) : (function(o, m, k, k2) {
1172+ if (k2 === undefined) k2 = k;
1173+ o[k2] = m[k];
1174+ }));
1175+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
1176+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1177+ }) : function(o, v) {
1178+ o["default"] = v;
1179+ });
10901180var __importStar = (this && this.__importStar) || function (mod) {
10911181 if (mod && mod.__esModule) return mod;
10921182 var result = {};
1093- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k] ;
1094- result["default"] = mod;
1183+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding( result, mod, k) ;
1184+ __setModuleDefault( result, mod) ;
10951185 return result;
10961186};
10971187Object.defineProperty(exports, "__esModule", ({ value: true }));
1188+ exports.issueCommand = void 0;
10981189// We use any as a valid input type
10991190/* eslint-disable @typescript-eslint/no-explicit-any */
11001191const fs = __importStar(__nccwpck_require__(5747));
@@ -1125,6 +1216,7 @@ exports.issueCommand = issueCommand;
11251216// We use any as a valid input type
11261217/* eslint-disable @typescript-eslint/no-explicit-any */
11271218Object.defineProperty(exports, "__esModule", ({ value: true }));
1219+ exports.toCommandValue = void 0;
11281220/**
11291221 * Sanitizes an input into a string so it can be passed into issueCommand safely
11301222 * @param input input to sanitize into a string
0 commit comments