new build

This commit is contained in:
Michael Shick 2023-05-04 17:32:54 -04:00
parent 4a541a260f
commit 73ffb32342
No known key found for this signature in database
GPG key ID: ADF5BC9704BB4A61
4 changed files with 3888 additions and 1216 deletions

5011
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -22,14 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getInputs = void 0;
const core = __importStar(require("@actions/core"));
const github = __importStar(require("@actions/github"));
const promises_1 = __importDefault(require("node:fs/promises"));
const util_1 = require("./util");
async function getInputs() {
var _a, _b;
const messageIdInput = core.getInput('message-id', { required: false });
@ -45,12 +42,12 @@ async function getInputs() {
const allowRepeats = core.getInput('allow-repeats', { required: true }) === 'true';
const refreshMessagePosition = core.getInput('refresh-message-position', { required: false }) === 'true';
const updateOnly = core.getInput('update-only', { required: false }) === 'true';
if (messageInput && messagePath) {
if (messageInput && messagePath.length) {
throw new Error('must specify only one, message or message-path');
}
let message;
if (messagePath) {
message = await promises_1.default.readFile(messagePath, { encoding: 'utf8' });
if (messagePath.length) {
message = await (0, util_1.getMessageFromPaths)(messagePath);
}
else {
message = messageInput;
@ -76,16 +73,16 @@ async function getInputs() {
}
const { payload } = github.context;
return {
refreshMessagePosition,
allowRepeats,
commitSha: github.context.sha,
issue: issue ? Number(issue) : (_a = payload.issue) === null || _a === void 0 ? void 0 : _a.number,
message,
messageId: `<!-- ${messageId} -->`,
proxyUrl,
pullRequestNumber: (_b = payload.pull_request) === null || _b === void 0 ? void 0 : _b.number,
refreshMessagePosition,
repoToken,
status,
issue: issue ? Number(issue) : (_a = payload.issue) === null || _a === void 0 ? void 0 : _a.number,
pullRequestNumber: (_b = payload.pull_request) === null || _b === void 0 ? void 0 : _b.number,
commitSha: github.context.sha,
owner: repoOwner || payload.repo.owner,
repo: repoName || payload.repo.repo,
updateOnly: updateOnly,

68
lib/util.js Normal file
View file

@ -0,0 +1,68 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.findFiles = exports.getMessageFromPaths = void 0;
const core = __importStar(require("@actions/core"));
const glob = __importStar(require("@actions/glob"));
const promises_1 = __importDefault(require("node:fs/promises"));
async function getMessageFromPaths(searchPath) {
let message = '';
const files = await findFiles(searchPath);
for (const [index, path] of files.entries()) {
if (index > 0) {
message += '\n';
}
message += await promises_1.default.readFile(path, { encoding: 'utf8' });
}
return message;
}
exports.getMessageFromPaths = getMessageFromPaths;
function getDefaultGlobOptions() {
return {
followSymbolicLinks: true,
implicitDescendants: true,
omitBrokenSymbolicLinks: true,
};
}
async function findFiles(searchPath, globOptions) {
const searchResults = [];
const globber = await glob.create(searchPath, globOptions || getDefaultGlobOptions());
const rawSearchResults = await globber.glob();
for (const searchResult of rawSearchResults) {
const fileStats = await promises_1.default.stat(searchResult);
if (!fileStats.isDirectory()) {
core.debug(`File: ${searchResult} was found using the provided searchPath`);
searchResults.push(searchResult);
}
else {
core.debug(`Removing ${searchResult} from rawSearchResults because it is a directory`);
}
}
return searchResults;
}
exports.findFiles = findFiles;