Add biome and initial format rules
This commit is contained in:
126
dist/index.js
vendored
126
dist/index.js
vendored
@@ -127,7 +127,7 @@ class Action {
|
||||
if (!releases) {
|
||||
throw new Error(`No releases found. Response: ${JSON.stringify(response)}`);
|
||||
}
|
||||
const draftRelease = releases.find(release => release.draft && release.tag_name == tag);
|
||||
const draftRelease = releases.find((release) => release.draft && release.tag_name == tag);
|
||||
return draftRelease?.id;
|
||||
}
|
||||
async createRelease() {
|
||||
@@ -321,14 +321,15 @@ class FileArtifactGlobber {
|
||||
}
|
||||
globArtifactString(artifact, contentType, errorsFailBuild) {
|
||||
const split = /[,\n]/;
|
||||
return artifact.split(split)
|
||||
.map(path => path.trimStart())
|
||||
.map(path => PathNormalizer_1.PathNormalizer.normalizePath(path))
|
||||
.map(path => FileArtifactGlobber.expandPath(path))
|
||||
.map(pattern => this.globPattern(pattern, errorsFailBuild))
|
||||
return artifact
|
||||
.split(split)
|
||||
.map((path) => path.trimStart())
|
||||
.map((path) => PathNormalizer_1.PathNormalizer.normalizePath(path))
|
||||
.map((path) => FileArtifactGlobber.expandPath(path))
|
||||
.map((pattern) => this.globPattern(pattern, errorsFailBuild))
|
||||
.map((globResult) => FileArtifactGlobber.validatePattern(errorsFailBuild, globResult[1], globResult[0]))
|
||||
.reduce((accumulated, current) => accumulated.concat(current))
|
||||
.map(path => new Artifact_1.Artifact(path, contentType));
|
||||
.map((path) => new Artifact_1.Artifact(path, contentType));
|
||||
}
|
||||
globPattern(pattern, errorsFailBuild) {
|
||||
const paths = this.globber.glob(pattern);
|
||||
@@ -525,7 +526,7 @@ class GithubArtifactUploader {
|
||||
async deleteUpdatedArtifacts(artifacts, releaseId) {
|
||||
const releaseAssets = await this.releases.listArtifactsForRelease(releaseId);
|
||||
const assetByName = {};
|
||||
releaseAssets.forEach(asset => {
|
||||
releaseAssets.forEach((asset) => {
|
||||
assetByName[asset.name] = asset;
|
||||
});
|
||||
for (const artifact of artifacts) {
|
||||
@@ -616,13 +617,13 @@ class GithubErrorDetail {
|
||||
toString() {
|
||||
const code = this.error.code;
|
||||
switch (code) {
|
||||
case 'missing':
|
||||
case "missing":
|
||||
return this.missingResourceMessage();
|
||||
case 'missing_field':
|
||||
case "missing_field":
|
||||
return this.missingFieldMessage();
|
||||
case 'invalid':
|
||||
case "invalid":
|
||||
return this.invalidFieldMessage();
|
||||
case 'already_exists':
|
||||
case "already_exists":
|
||||
return this.resourceAlreadyExists();
|
||||
default:
|
||||
return this.customErrorMessage();
|
||||
@@ -732,46 +733,45 @@ class CoreInputs {
|
||||
this.context = context;
|
||||
}
|
||||
get allowUpdates() {
|
||||
const allow = core.getInput('allowUpdates');
|
||||
return allow == 'true';
|
||||
const allow = core.getInput("allowUpdates");
|
||||
return allow == "true";
|
||||
}
|
||||
get artifacts() {
|
||||
let artifacts = core.getInput('artifacts');
|
||||
let artifacts = core.getInput("artifacts");
|
||||
if (!artifacts) {
|
||||
artifacts = core.getInput('artifact');
|
||||
artifacts = core.getInput("artifact");
|
||||
}
|
||||
if (artifacts) {
|
||||
let contentType = core.getInput('artifactContentType');
|
||||
let contentType = core.getInput("artifactContentType");
|
||||
if (!contentType) {
|
||||
contentType = 'raw';
|
||||
contentType = "raw";
|
||||
}
|
||||
return this.artifactGlobber
|
||||
.globArtifactString(artifacts, contentType, this.artifactErrorsFailBuild);
|
||||
return this.artifactGlobber.globArtifactString(artifacts, contentType, this.artifactErrorsFailBuild);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
get artifactErrorsFailBuild() {
|
||||
const allow = core.getInput('artifactErrorsFailBuild');
|
||||
return allow == 'true';
|
||||
const allow = core.getInput("artifactErrorsFailBuild");
|
||||
return allow == "true";
|
||||
}
|
||||
get body() {
|
||||
const body = core.getInput('body');
|
||||
const body = core.getInput("body");
|
||||
if (body) {
|
||||
return body;
|
||||
}
|
||||
const bodyFile = core.getInput('bodyFile');
|
||||
const bodyFile = core.getInput("bodyFile");
|
||||
if (bodyFile) {
|
||||
return this.stringFromFile(bodyFile);
|
||||
}
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
get createdDraft() {
|
||||
const draft = core.getInput('draft');
|
||||
return draft == 'true';
|
||||
const draft = core.getInput("draft");
|
||||
return draft == "true";
|
||||
}
|
||||
get createdPrerelease() {
|
||||
const preRelease = core.getInput('prerelease');
|
||||
return preRelease == 'true';
|
||||
const preRelease = core.getInput("prerelease");
|
||||
return preRelease == "true";
|
||||
}
|
||||
get createdReleaseBody() {
|
||||
if (CoreInputs.omitBody)
|
||||
@@ -779,7 +779,7 @@ class CoreInputs {
|
||||
return this.body;
|
||||
}
|
||||
static get omitBody() {
|
||||
return core.getInput('omitBody') == 'true';
|
||||
return core.getInput("omitBody") == "true";
|
||||
}
|
||||
get createdReleaseName() {
|
||||
if (CoreInputs.omitName)
|
||||
@@ -787,57 +787,57 @@ class CoreInputs {
|
||||
return this.name;
|
||||
}
|
||||
static get omitName() {
|
||||
return core.getInput('omitName') == 'true';
|
||||
return core.getInput("omitName") == "true";
|
||||
}
|
||||
get commit() {
|
||||
const commit = core.getInput('commit');
|
||||
const commit = core.getInput("commit");
|
||||
if (commit) {
|
||||
return commit;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
get discussionCategory() {
|
||||
const category = core.getInput('discussionCategory');
|
||||
const category = core.getInput("discussionCategory");
|
||||
if (category) {
|
||||
return category;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
get name() {
|
||||
const name = core.getInput('name');
|
||||
const name = core.getInput("name");
|
||||
if (name) {
|
||||
return name;
|
||||
}
|
||||
return this.tag;
|
||||
}
|
||||
get generateReleaseNotes() {
|
||||
const generate = core.getInput('generateReleaseNotes');
|
||||
return generate == 'true';
|
||||
const generate = core.getInput("generateReleaseNotes");
|
||||
return generate == "true";
|
||||
}
|
||||
get makeLatest() {
|
||||
let latest = core.getInput('makeLatest');
|
||||
let latest = core.getInput("makeLatest");
|
||||
if (latest == "true" || latest == "false" || latest == "legacy") {
|
||||
return latest;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
get owner() {
|
||||
let owner = core.getInput('owner');
|
||||
let owner = core.getInput("owner");
|
||||
if (owner) {
|
||||
return owner;
|
||||
}
|
||||
return this.context.repo.owner;
|
||||
}
|
||||
get removeArtifacts() {
|
||||
const removes = core.getInput('removeArtifacts');
|
||||
return removes == 'true';
|
||||
const removes = core.getInput("removeArtifacts");
|
||||
return removes == "true";
|
||||
}
|
||||
get replacesArtifacts() {
|
||||
const replaces = core.getInput('replacesArtifacts');
|
||||
return replaces == 'true';
|
||||
const replaces = core.getInput("replacesArtifacts");
|
||||
return replaces == "true";
|
||||
}
|
||||
get repo() {
|
||||
let repo = core.getInput('repo');
|
||||
let repo = core.getInput("repo");
|
||||
if (repo) {
|
||||
return repo;
|
||||
}
|
||||
@@ -847,7 +847,7 @@ class CoreInputs {
|
||||
return core.getBooleanInput("skipIfReleaseExists");
|
||||
}
|
||||
get tag() {
|
||||
const tag = core.getInput('tag');
|
||||
const tag = core.getInput("tag");
|
||||
if (tag) {
|
||||
return tag;
|
||||
}
|
||||
@@ -859,7 +859,7 @@ class CoreInputs {
|
||||
throw Error("No tag found in ref or input!");
|
||||
}
|
||||
get token() {
|
||||
return core.getInput('token', { required: true });
|
||||
return core.getInput("token", { required: true });
|
||||
}
|
||||
get updatedDraft() {
|
||||
if (CoreInputs.omitDraftDuringUpdate)
|
||||
@@ -867,7 +867,7 @@ class CoreInputs {
|
||||
return this.createdDraft;
|
||||
}
|
||||
static get omitDraftDuringUpdate() {
|
||||
return core.getInput('omitDraftDuringUpdate') == 'true';
|
||||
return core.getInput("omitDraftDuringUpdate") == "true";
|
||||
}
|
||||
get updatedPrerelease() {
|
||||
if (CoreInputs.omitPrereleaseDuringUpdate)
|
||||
@@ -875,7 +875,7 @@ class CoreInputs {
|
||||
return this.createdPrerelease;
|
||||
}
|
||||
static get omitPrereleaseDuringUpdate() {
|
||||
return core.getInput('omitPrereleaseDuringUpdate') == 'true';
|
||||
return core.getInput("omitPrereleaseDuringUpdate") == "true";
|
||||
}
|
||||
get updatedReleaseBody() {
|
||||
if (CoreInputs.omitBody || CoreInputs.omitBodyDuringUpdate)
|
||||
@@ -883,7 +883,7 @@ class CoreInputs {
|
||||
return this.body;
|
||||
}
|
||||
static get omitBodyDuringUpdate() {
|
||||
return core.getInput('omitBodyDuringUpdate') == 'true';
|
||||
return core.getInput("omitBodyDuringUpdate") == "true";
|
||||
}
|
||||
get updatedReleaseName() {
|
||||
if (CoreInputs.omitName || CoreInputs.omitNameDuringUpdate)
|
||||
@@ -891,13 +891,13 @@ class CoreInputs {
|
||||
return this.name;
|
||||
}
|
||||
get updateOnlyUnreleased() {
|
||||
return core.getInput('updateOnlyUnreleased') == 'true';
|
||||
return core.getInput("updateOnlyUnreleased") == "true";
|
||||
}
|
||||
static get omitNameDuringUpdate() {
|
||||
return core.getInput('omitNameDuringUpdate') == 'true';
|
||||
return core.getInput("omitNameDuringUpdate") == "true";
|
||||
}
|
||||
stringFromFile(path) {
|
||||
return (0, fs_1.readFileSync)(path, 'utf-8');
|
||||
return (0, fs_1.readFileSync)(path, "utf-8");
|
||||
}
|
||||
}
|
||||
exports.CoreInputs = CoreInputs;
|
||||
@@ -948,9 +948,9 @@ exports.CoreOutputs = void 0;
|
||||
const core = __importStar(__nccwpck_require__(1401));
|
||||
class CoreOutputs {
|
||||
applyReleaseData(releaseData) {
|
||||
core.setOutput('id', releaseData.id);
|
||||
core.setOutput('html_url', releaseData.html_url);
|
||||
core.setOutput('upload_url', releaseData.upload_url);
|
||||
core.setOutput("id", releaseData.id);
|
||||
core.setOutput("html_url", releaseData.html_url);
|
||||
core.setOutput("upload_url", releaseData.upload_url);
|
||||
}
|
||||
}
|
||||
exports.CoreOutputs = CoreOutputs;
|
||||
@@ -1032,34 +1032,34 @@ class GithubReleases {
|
||||
prerelease: prerelease,
|
||||
repo: this.inputs.repo,
|
||||
target_commitish: commitHash,
|
||||
tag_name: tag
|
||||
tag_name: tag,
|
||||
});
|
||||
}
|
||||
async deleteArtifact(assetId) {
|
||||
return this.git.rest.repos.deleteReleaseAsset({
|
||||
asset_id: assetId,
|
||||
owner: this.inputs.owner,
|
||||
repo: this.inputs.repo
|
||||
repo: this.inputs.repo,
|
||||
});
|
||||
}
|
||||
async getByTag(tag) {
|
||||
return this.git.rest.repos.getReleaseByTag({
|
||||
owner: this.inputs.owner,
|
||||
repo: this.inputs.repo,
|
||||
tag: tag
|
||||
tag: tag,
|
||||
});
|
||||
}
|
||||
async listArtifactsForRelease(releaseId) {
|
||||
return this.git.paginate(this.git.rest.repos.listReleaseAssets, {
|
||||
owner: this.inputs.owner,
|
||||
release_id: releaseId,
|
||||
repo: this.inputs.repo
|
||||
repo: this.inputs.repo,
|
||||
});
|
||||
}
|
||||
async listReleases() {
|
||||
return this.git.rest.repos.listReleases({
|
||||
owner: this.inputs.owner,
|
||||
repo: this.inputs.repo
|
||||
repo: this.inputs.repo,
|
||||
});
|
||||
}
|
||||
async update(id, tag, body, commitHash, discussionCategory, draft, makeLatest, name, prerelease) {
|
||||
@@ -1075,7 +1075,7 @@ class GithubReleases {
|
||||
prerelease: prerelease,
|
||||
repo: this.inputs.repo,
|
||||
target_commitish: commitHash,
|
||||
tag_name: tag
|
||||
tag_name: tag,
|
||||
});
|
||||
}
|
||||
async uploadArtifact(assetUrl, contentLength, contentType, file, name, releaseId) {
|
||||
@@ -1083,13 +1083,13 @@ class GithubReleases {
|
||||
url: assetUrl,
|
||||
headers: {
|
||||
"content-length": contentLength,
|
||||
"content-type": contentType
|
||||
"content-type": contentType,
|
||||
},
|
||||
data: file,
|
||||
name: name,
|
||||
owner: this.inputs.owner,
|
||||
release_id: releaseId,
|
||||
repo: this.inputs.repo
|
||||
repo: this.inputs.repo,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1159,7 +1159,7 @@ async function run() {
|
||||
}
|
||||
}
|
||||
function createAction() {
|
||||
const token = core.getInput('token');
|
||||
const token = core.getInput("token");
|
||||
const context = github.context;
|
||||
const git = github.getOctokit(token);
|
||||
const globber = new ArtifactGlobber_1.FileArtifactGlobber();
|
||||
|
||||
Reference in New Issue
Block a user