This commit is contained in:
Kir_Antipov 2022-07-05 21:10:15 +03:00
parent 8709f9c0d1
commit 9342207fee
4 changed files with 817 additions and 148 deletions

325
action.yml Normal file
View file

@ -0,0 +1,325 @@
name: Publish Minecraft Mods
description: GitHub Action that helps you publish your Minecraft mods
author: Kir-Antipov
branding:
color: orange
icon: upload
inputs:
modrinth-id:
description: The ID of the Modrinth project to upload to
required: false
default: ${undefined}
modrinth-featured:
description: Indicates whether the version should be featured on Modrinth or not
required: false
default: ${undefined}
modrinth-unfeature-mode:
description: Determines the way automatic unfeaturing of older Modrinth versions works
required: false
default: ${undefined}
modrinth-token:
description: A valid token for the Modrinth API
required: false
default: ${undefined}
curseforge-id:
description: The ID of the CurseForge project to upload to
required: false
default: ${undefined}
curseforge-token:
description: A valid token for the CurseForge API
required: false
default: ${undefined}
github-tag:
description: The tag name of the release to upload assets to
required: false
default: ${undefined}
github-generate-changelog:
description: Indicates whether to automatically generate the changelog for this
release. If changelog is specified, it will be pre-pended to the
automatically generated notes. Unused if the GitHub Release already exists
required: false
default: ${undefined}
github-draft:
description: true to create a draft (unpublished) release, false to create a
published one. Unused if the GitHub Release already exists
required: false
default: ${undefined}
github-prerelease:
description: true to identify the release as a prerelease, false to identify the
release as a full release. Unused if the GitHub Release already exists
required: false
default: ${undefined}
github-commitish:
description: Specifies the commitish value that determines where the Git tag is
created from. Can be any branch or commit SHA. Unused if the Git tag
already exists
required: false
default: ${undefined}
github-discussion:
description: If specified, a discussion of the specified category is created and
linked to the release. Unused if the GitHub Release already exists
required: false
default: ${undefined}
github-token:
description: A valid token for the GitHub API
required: false
default: ${undefined}
files:
description: A glob of the files to upload
required: false
default: ${undefined}
files-primary:
description: A glob of the primary files to upload
required: false
default: ${undefined}
files-secondary:
description: A glob of the secondary files to upload
required: false
default: ${undefined}
name:
description: The name of the version
required: false
default: ${undefined}
version:
description: The version number
required: false
default: ${undefined}
version-type:
description: The type of the release - alpha, beta, or release
required: false
default: ${undefined}
changelog:
description: The changelog for this version
required: false
default: ${undefined}
changelog-file:
description: A glob of the changelog file
required: false
default: ${undefined}
loaders:
description: A list of supported mod loaders
required: false
default: ${undefined}
game-versions:
description: A list of supported Minecraft versions
required: false
default: ${undefined}
dependencies:
description: A list of dependencies
required: false
default: ${undefined}
version-resolver:
description: Determines the way automatic game-versions resolvement works
required: false
default: ${undefined}
java:
description: A list of supported Java versions
required: false
default: ${undefined}
retry-attempts:
description: The maximum number of attempts to publish assets
default: 2
required: false
retry-delay:
description: Time delay between attempts to publish assets (in milliseconds)
default: 10000
required: false
fail-mode:
description: Determines how errors that occur during mod publishing process are handled
required: false
default: ${undefined}
modrinth-files:
description: A glob of the files to upload
required: false
default: ${undefined}
modrinth-files-primary:
description: A glob of the primary files to upload
required: false
default: ${undefined}
modrinth-files-secondary:
description: A glob of the secondary files to upload
required: false
default: ${undefined}
modrinth-name:
description: The name of the version
required: false
default: ${undefined}
modrinth-version:
description: The version number
required: false
default: ${undefined}
modrinth-version-type:
description: The type of the release - alpha, beta, or release
required: false
default: ${undefined}
modrinth-changelog:
description: The changelog for this version
required: false
default: ${undefined}
modrinth-changelog-file:
description: A glob of the changelog file
required: false
default: ${undefined}
modrinth-loaders:
description: A list of supported mod loaders
required: false
default: ${undefined}
modrinth-game-versions:
description: A list of supported Minecraft versions
required: false
default: ${undefined}
modrinth-dependencies:
description: A list of dependencies
required: false
default: ${undefined}
modrinth-version-resolver:
description: Determines the way automatic game-versions resolvement works
required: false
default: ${undefined}
modrinth-java:
description: A list of supported Java versions
required: false
default: ${undefined}
modrinth-retry-attempts:
description: The maximum number of attempts to publish assets
default: 2
required: false
modrinth-retry-delay:
description: Time delay between attempts to publish assets (in milliseconds)
default: 10000
required: false
modrinth-fail-mode:
description: Determines how errors that occur during mod publishing process are handled
required: false
default: ${undefined}
curseforge-files:
description: A glob of the files to upload
required: false
default: ${undefined}
curseforge-files-primary:
description: A glob of the primary files to upload
required: false
default: ${undefined}
curseforge-files-secondary:
description: A glob of the secondary files to upload
required: false
default: ${undefined}
curseforge-name:
description: The name of the version
required: false
default: ${undefined}
curseforge-version:
description: The version number
required: false
default: ${undefined}
curseforge-version-type:
description: The type of the release - alpha, beta, or release
required: false
default: ${undefined}
curseforge-changelog:
description: The changelog for this version
required: false
default: ${undefined}
curseforge-changelog-file:
description: A glob of the changelog file
required: false
default: ${undefined}
curseforge-loaders:
description: A list of supported mod loaders
required: false
default: ${undefined}
curseforge-game-versions:
description: A list of supported Minecraft versions
required: false
default: ${undefined}
curseforge-dependencies:
description: A list of dependencies
required: false
default: ${undefined}
curseforge-version-resolver:
description: Determines the way automatic game-versions resolvement works
required: false
default: ${undefined}
curseforge-java:
description: A list of supported Java versions
required: false
default: ${undefined}
curseforge-retry-attempts:
description: The maximum number of attempts to publish assets
default: 2
required: false
curseforge-retry-delay:
description: Time delay between attempts to publish assets (in milliseconds)
default: 10000
required: false
curseforge-fail-mode:
description: Determines how errors that occur during mod publishing process are handled
required: false
default: ${undefined}
github-files:
description: A glob of the files to upload
required: false
default: ${undefined}
github-files-primary:
description: A glob of the primary files to upload
required: false
default: ${undefined}
github-files-secondary:
description: A glob of the secondary files to upload
required: false
default: ${undefined}
github-name:
description: The name of the version
required: false
default: ${undefined}
github-version:
description: The version number
required: false
default: ${undefined}
github-version-type:
description: The type of the release - alpha, beta, or release
required: false
default: ${undefined}
github-changelog:
description: The changelog for this version
required: false
default: ${undefined}
github-changelog-file:
description: A glob of the changelog file
required: false
default: ${undefined}
github-loaders:
description: A list of supported mod loaders
required: false
default: ${undefined}
github-game-versions:
description: A list of supported Minecraft versions
required: false
default: ${undefined}
github-dependencies:
description: A list of dependencies
required: false
default: ${undefined}
github-version-resolver:
description: Determines the way automatic game-versions resolvement works
required: false
default: ${undefined}
github-java:
description: A list of supported Java versions
required: false
default: ${undefined}
github-retry-attempts:
description: The maximum number of attempts to publish assets
default: 2
required: false
github-retry-delay:
description: Time delay between attempts to publish assets (in milliseconds)
default: 10000
required: false
github-fail-mode:
description: Determines how errors that occur during mod publishing process are handled
required: false
default: ${undefined}
runs:
using: node12
main: dist/index.js

586
dist/index.js vendored
View file

@ -22426,23 +22426,23 @@ function wrappy (fn, cb) {
/***/ }), /***/ }),
/***/ 4067: /***/ 1991:
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
"use strict"; "use strict";
// ESM COMPAT FLAG // ESM COMPAT FLAG
__nccwpck_require__.r(__webpack_exports__); __nccwpck_require__.r(__webpack_exports__);
// EXTERNAL MODULE: ./node_modules/fast-glob/out/index.js
var out = __nccwpck_require__(3664);
var out_default = /*#__PURE__*/__nccwpck_require__.n(out);
// EXTERNAL MODULE: external "fs" // EXTERNAL MODULE: external "fs"
var external_fs_ = __nccwpck_require__(7147); var external_fs_ = __nccwpck_require__(7147);
var external_fs_default = /*#__PURE__*/__nccwpck_require__.n(external_fs_); var external_fs_default = /*#__PURE__*/__nccwpck_require__.n(external_fs_);
// EXTERNAL MODULE: external "path" // EXTERNAL MODULE: external "path"
var external_path_ = __nccwpck_require__(1017); var external_path_ = __nccwpck_require__(1017);
var external_path_default = /*#__PURE__*/__nccwpck_require__.n(external_path_); var external_path_default = /*#__PURE__*/__nccwpck_require__.n(external_path_);
;// CONCATENATED MODULE: ./src/utils/file.ts // EXTERNAL MODULE: ./node_modules/fast-glob/out/index.js
var out = __nccwpck_require__(3664);
var out_default = /*#__PURE__*/__nccwpck_require__.n(out);
;// CONCATENATED MODULE: ./src/utils/io/file.ts
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
@ -22454,6 +22454,11 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
}; };
const gradleOutputSelector = {
primary: "build/libs/!(*-@(dev|sources)).jar",
secondary: "build/libs/*-@(dev|sources).jar"
};
class File { class File {
constructor(filePath) { constructor(filePath) {
this.name = external_path_default().basename(filePath); this.name = external_path_default().basename(filePath);
@ -22480,58 +22485,41 @@ class File {
equals(file) { equals(file) {
return file instanceof File && file.path === this.path; return file instanceof File && file.path === this.path;
} }
} static getFiles(files) {
return __awaiter(this, void 0, void 0, function* () {
;// CONCATENATED MODULE: ./src/utils/file-utils.ts if (!files || typeof files !== "string" && !files.primary && !files.secondary) {
var file_utils_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { return [];
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } }
return new (P || (P = Promise))(function (resolve, reject) { if (typeof files === "string") {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } return (yield out_default()(files)).map(x => new File(x));
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } let results = [];
step((generator = generator.apply(thisArg, _arguments || [])).next()); if (files.primary) {
}); results = (yield out_default()(files.primary)).map(x => new File(x));
}; }
if (files.secondary) {
results = results.concat((yield out_default()(files.secondary)).map(x => new File(x)));
const gradleOutputSelector = { }
primary: "build/libs/!(*-@(dev|sources)).jar", return results.filter((x, i, self) => self.findIndex(y => x.equals(y)) === i);
secondary: "build/libs/*-@(dev|sources).jar" });
}; }
function getRequiredFiles(files) { static getRequiredFiles(files) {
return file_utils_awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const foundFiles = yield getFiles(files); const foundFiles = yield File.getFiles(files);
if (foundFiles && foundFiles.length) { if (foundFiles && foundFiles.length) {
return foundFiles; return foundFiles;
} }
throw new Error(`Specified files ('${typeof files === "string" ? files : [files.primary, files.secondary].filter(x => x).join(", ")}') were not found`); throw new Error(`Specified files ('${typeof files === "string" ? files : [files.primary, files.secondary].filter(x => x).join(", ")}') were not found`);
}); });
} }
function getFiles(files) {
return file_utils_awaiter(this, void 0, void 0, function* () {
if (!files || typeof files !== "string" && !files.primary && !files.secondary) {
return [];
}
if (typeof files === "string") {
return (yield out_default()(files)).map(x => new File(x));
}
let results = [];
if (files.primary) {
results = (yield out_default()(files.primary)).map(x => new File(x));
}
if (files.secondary) {
results = results.concat((yield out_default()(files.secondary)).map(x => new File(x)));
}
return results.filter((x, i, self) => self.findIndex(y => x.equals(y)) === i);
});
} }
;// CONCATENATED MODULE: ./src/publishing/publisher-target.ts ;// CONCATENATED MODULE: ./src/publishing/publisher-target.ts
var PublisherTarget; var PublisherTarget;
(function (PublisherTarget) { (function (PublisherTarget) {
PublisherTarget[PublisherTarget["GitHub"] = 0] = "GitHub"; PublisherTarget[PublisherTarget["CurseForge"] = 0] = "CurseForge";
PublisherTarget[PublisherTarget["Modrinth"] = 1] = "Modrinth"; PublisherTarget[PublisherTarget["Modrinth"] = 1] = "Modrinth";
PublisherTarget[PublisherTarget["CurseForge"] = 2] = "CurseForge"; PublisherTarget[PublisherTarget["GitHub"] = 2] = "GitHub";
})(PublisherTarget || (PublisherTarget = {})); })(PublisherTarget || (PublisherTarget = {}));
(function (PublisherTarget) { (function (PublisherTarget) {
function getValues() { function getValues() {
@ -22550,7 +22538,7 @@ var github = __nccwpck_require__(5438);
// EXTERNAL MODULE: ./node_modules/node-fetch/lib/index.js // EXTERNAL MODULE: ./node_modules/node-fetch/lib/index.js
var lib = __nccwpck_require__(467); var lib = __nccwpck_require__(467);
var lib_default = /*#__PURE__*/__nccwpck_require__.n(lib); var lib_default = /*#__PURE__*/__nccwpck_require__.n(lib);
;// CONCATENATED MODULE: ./src/utils/version.ts ;// CONCATENATED MODULE: ./src/utils/versioning/version.ts
class Version { class Version {
constructor(major, minor, build) { constructor(major, minor, build) {
if (typeof major === "string") { if (typeof major === "string") {
@ -22568,10 +22556,14 @@ class Version {
} }
return typeof version === "string" && this.equals(new Version(version)); return typeof version === "string" && this.equals(new Version(version));
} }
static fromName(name) {
const match = name.match(/[a-z]{0,2}\d+\.\d+.*/i);
return match ? match[0] : name;
}
} }
;// CONCATENATED MODULE: ./src/utils/minecraft-utils.ts ;// CONCATENATED MODULE: ./src/utils/minecraft/index.ts
var minecraft_utils_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { var minecraft_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@ -22608,7 +22600,7 @@ class MinecraftVersion {
} }
let cachedVersionsById = null; let cachedVersionsById = null;
function getVersionMap() { function getVersionMap() {
return minecraft_utils_awaiter(this, void 0, void 0, function* () { return minecraft_awaiter(this, void 0, void 0, function* () {
if (!cachedVersionsById) { if (!cachedVersionsById) {
cachedVersionsById = yield loadVersions(); cachedVersionsById = yield loadVersions();
} }
@ -22616,7 +22608,7 @@ function getVersionMap() {
}); });
} }
function loadVersions() { function loadVersions() {
return minecraft_utils_awaiter(this, void 0, void 0, function* () { return minecraft_awaiter(this, void 0, void 0, function* () {
const response = yield (yield lib_default()("https://launchermeta.mojang.com/mc/game/version_manifest.json")).json(); const response = yield (yield lib_default()("https://launchermeta.mojang.com/mc/game/version_manifest.json")).json();
const versionsById = new Map(); const versionsById = new Map();
for (let i = 0; i < response.versions.length; ++i) { for (let i = 0; i < response.versions.length; ++i) {
@ -22644,17 +22636,17 @@ function getNearestReleaseVersionName(versions, start) {
return null; return null;
} }
function getVersions() { function getVersions() {
return minecraft_utils_awaiter(this, void 0, void 0, function* () { return minecraft_awaiter(this, void 0, void 0, function* () {
return [...(yield getVersionMap()).values()]; return [...(yield getVersionMap()).values()];
}); });
} }
function getVersionById(id) { function getVersionById(id) {
return minecraft_utils_awaiter(this, void 0, void 0, function* () { return minecraft_awaiter(this, void 0, void 0, function* () {
return (yield getVersionMap()).get(id.trim()) || null; return (yield getVersionMap()).get(id.trim()) || null;
}); });
} }
function findVersionByName(name, snapshot) { function findVersionByName(name, snapshot) {
return minecraft_utils_awaiter(this, void 0, void 0, function* () { return minecraft_awaiter(this, void 0, void 0, function* () {
const versionMap = yield getVersionMap(); const versionMap = yield getVersionMap();
snapshot !== null && snapshot !== void 0 ? snapshot : (snapshot = isSnapshot(name)); snapshot !== null && snapshot !== void 0 ? snapshot : (snapshot = isSnapshot(name));
const foundVersion = versionMap.get(name); const foundVersion = versionMap.get(name);
@ -22692,12 +22684,12 @@ function parseVersionName(version) {
return versionCandidates.filter(x => x.startsWith("1."))[0] || null; return versionCandidates.filter(x => x.startsWith("1."))[0] || null;
} }
function getLatestRelease() { function getLatestRelease() {
return minecraft_utils_awaiter(this, void 0, void 0, function* () { return minecraft_awaiter(this, void 0, void 0, function* () {
return (yield getVersions()).find(x => x.isRelease) || null; return (yield getVersions()).find(x => x.isRelease) || null;
}); });
} }
function getCompatibleBuilds(build) { function getCompatibleBuilds(build) {
return minecraft_utils_awaiter(this, void 0, void 0, function* () { return minecraft_awaiter(this, void 0, void 0, function* () {
if (!(build instanceof Version)) { if (!(build instanceof Version)) {
build = new Version(build); build = new Version(build);
} }
@ -22721,7 +22713,7 @@ function getCompatibleBuilds(build) {
var core = __nccwpck_require__(2186); var core = __nccwpck_require__(2186);
;// CONCATENATED MODULE: external "console" ;// CONCATENATED MODULE: external "console"
const external_console_namespaceObject = require("console"); const external_console_namespaceObject = require("console");
;// CONCATENATED MODULE: ./src/utils/logger-utils.ts ;// CONCATENATED MODULE: ./src/utils/logging/logger.ts
function getDefaultLogger() { function getDefaultLogger() {
@ -22765,7 +22757,7 @@ class Publisher {
} }
} }
;// CONCATENATED MODULE: ./src/utils/game-version-resolver.ts ;// CONCATENATED MODULE: ./src/utils/versioning/game-version-resolver.ts
var game_version_resolver_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { var game_version_resolver_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
@ -22789,7 +22781,7 @@ class GameVersionResolver {
} }
} }
;// CONCATENATED MODULE: ./src/utils/minecraft-version-resolver.ts ;// CONCATENATED MODULE: ./src/utils/minecraft/minecraft-version-resolver.ts
class MinecraftVersionResolver extends GameVersionResolver { class MinecraftVersionResolver extends GameVersionResolver {
@ -23007,6 +22999,13 @@ function getDependenciesByKind(config, kind) {
} }
return dependencies; return dependencies;
} }
function getLoaders(config) {
var _a, _b, _c, _d;
if ((_b = (_a = config[package_namespaceObject.u2]) === null || _a === void 0 ? void 0 : _a.quilt) !== null && _b !== void 0 ? _b : (_d = (_c = config.custom) === null || _c === void 0 ? void 0 : _c[package_namespaceObject.u2]) === null || _d === void 0 ? void 0 : _d.quilt) {
return ["fabric", "quilt"];
}
return ["fabric"];
}
class FabricModMetadata extends ModConfig { class FabricModMetadata extends ModConfig {
constructor(config) { constructor(config) {
var _a, _b, _c; var _a, _b, _c;
@ -23014,7 +23013,7 @@ class FabricModMetadata extends ModConfig {
this.id = String((_a = this.config.id) !== null && _a !== void 0 ? _a : ""); this.id = String((_a = this.config.id) !== null && _a !== void 0 ? _a : "");
this.name = String((_b = this.config.name) !== null && _b !== void 0 ? _b : this.id); this.name = String((_b = this.config.name) !== null && _b !== void 0 ? _b : this.id);
this.version = String((_c = this.config.version) !== null && _c !== void 0 ? _c : "*"); this.version = String((_c = this.config.version) !== null && _c !== void 0 ? _c : "*");
this.loaders = ["fabric"]; this.loaders = getLoaders(this.config);
this.dependencies = dependency_kind.getValues().flatMap(x => getDependenciesByKind(this.config, x)); this.dependencies = dependency_kind.getValues().flatMap(x => getDependenciesByKind(this.config, x));
} }
getProjectId(project) { getProjectId(project) {
@ -23236,28 +23235,28 @@ var ModMetadataReader;
})(ModMetadataReader || (ModMetadataReader = {})); })(ModMetadataReader || (ModMetadataReader = {}));
/* harmony default export */ const mod_metadata_reader = (ModMetadataReader); /* harmony default export */ const mod_metadata_reader = (ModMetadataReader);
;// CONCATENATED MODULE: ./src/utils/version-utils.ts ;// CONCATENATED MODULE: ./src/utils/versioning/version-type.ts
var VersionType; var VersionType;
(function (VersionType) { (function (VersionType) {
VersionType["Alpha"] = "alpha"; VersionType["Alpha"] = "alpha";
VersionType["Beta"] = "beta"; VersionType["Beta"] = "beta";
VersionType["Release"] = "release"; VersionType["Release"] = "release";
})(VersionType || (VersionType = {})); })(VersionType || (VersionType = {}));
function parseVersionFromName(name) { (function (VersionType) {
const match = name.match(/[a-z]{0,2}\d+\.\d+.*/i); function fromName(name) {
return match ? match[0] : name; if (name.match(/[+-_]alpha/i)) {
} return VersionType.Alpha;
function parseVersionTypeFromName(name) { }
if (name.match(/[+-_]alpha/i)) { else if (name.match(/[+-_]beta/i)) {
return VersionType.Alpha; return VersionType.Beta;
}
else {
return VersionType.Release;
}
} }
else if (name.match(/[+-_]beta/i)) { VersionType.fromName = fromName;
return VersionType.Beta; })(VersionType || (VersionType = {}));
} /* harmony default export */ const version_type = (VersionType);
else {
return VersionType.Release;
}
}
;// CONCATENATED MODULE: ./src/publishing/mod-publisher.ts ;// CONCATENATED MODULE: ./src/publishing/mod-publisher.ts
var mod_publisher_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { var mod_publisher_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
@ -23280,6 +23279,7 @@ var mod_publisher_awaiter = (undefined && undefined.__awaiter) || function (this
function processMultilineInput(input, splitter) { function processMultilineInput(input, splitter) {
if (!input) { if (!input) {
return []; return [];
@ -23300,7 +23300,7 @@ function processDependenciesInput(input, inputSplitter, entrySplitter) {
} }
function readChangelog(changelogPath) { function readChangelog(changelogPath) {
return mod_publisher_awaiter(this, void 0, void 0, function* () { return mod_publisher_awaiter(this, void 0, void 0, function* () {
const file = (yield getFiles(changelogPath))[0]; const file = (yield File.getFiles(changelogPath))[0];
if (!file) { if (!file) {
throw new Error("Changelog file was not found"); throw new Error("Changelog file was not found");
} }
@ -23318,7 +23318,7 @@ class ModPublisher extends Publisher {
return true; return true;
} }
publish(files, options) { publish(files, options) {
var _a, _b; var _a;
return mod_publisher_awaiter(this, void 0, void 0, function* () { return mod_publisher_awaiter(this, void 0, void 0, function* () {
this.validateOptions(options); this.validateOptions(options);
const releaseInfo = github.context.payload.release; const releaseInfo = github.context.payload.release;
@ -23335,13 +23335,13 @@ class ModPublisher extends Publisher {
throw new Error(`Project id is required to publish your assets to ${publisher_target.toString(this.target)}`); throw new Error(`Project id is required to publish your assets to ${publisher_target.toString(this.target)}`);
} }
const filename = external_path_default().parse(files[0].path).name; const filename = external_path_default().parse(files[0].path).name;
const version = (typeof options.version === "string" && options.version) || (releaseInfo === null || releaseInfo === void 0 ? void 0 : releaseInfo.tag_name) || (metadata === null || metadata === void 0 ? void 0 : metadata.version) || parseVersionFromName(filename); const version = (typeof options.version === "string" && options.version) || (releaseInfo === null || releaseInfo === void 0 ? void 0 : releaseInfo.tag_name) || (metadata === null || metadata === void 0 ? void 0 : metadata.version) || Version.fromName(filename);
const versionType = ((_a = options.versionType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || parseVersionTypeFromName((metadata === null || metadata === void 0 ? void 0 : metadata.version) || filename); const versionType = ((_a = options.versionType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || version_type.fromName((metadata === null || metadata === void 0 ? void 0 : metadata.version) || filename);
const name = typeof options.name === "string" ? options.name : ((releaseInfo === null || releaseInfo === void 0 ? void 0 : releaseInfo.name) || version); const name = typeof options.name === "string" ? options.name : ((releaseInfo === null || releaseInfo === void 0 ? void 0 : releaseInfo.name) || version);
const changelog = typeof options.changelog === "string" const changelog = typeof options.changelog === "string"
? options.changelog ? options.changelog
: ((_b = options.changelog) === null || _b === void 0 ? void 0 : _b.file) : typeof options.changelogFile === "string"
? yield readChangelog(options.changelog.file) ? yield readChangelog(options.changelogFile)
: (releaseInfo === null || releaseInfo === void 0 ? void 0 : releaseInfo.body) || ""; : (releaseInfo === null || releaseInfo === void 0 ? void 0 : releaseInfo.body) || "";
const loaders = processMultilineInput(options.loaders, /\s+/); const loaders = processMultilineInput(options.loaders, /\s+/);
if (!loaders.length && this.requiresModLoaders) { if (!loaders.length && this.requiresModLoaders) {
@ -23377,7 +23377,7 @@ class ModPublisher extends Publisher {
;// CONCATENATED MODULE: external "process" ;// CONCATENATED MODULE: external "process"
const external_process_namespaceObject = require("process"); const external_process_namespaceObject = require("process");
var external_process_default = /*#__PURE__*/__nccwpck_require__.n(external_process_namespaceObject); var external_process_default = /*#__PURE__*/__nccwpck_require__.n(external_process_namespaceObject);
;// CONCATENATED MODULE: ./src/utils/input-utils.ts ;// CONCATENATED MODULE: ./src/utils/actions/input.ts
const undefinedValue = "${undefined}"; const undefinedValue = "${undefined}";
function getInputAsObject() { function getInputAsObject() {
@ -23530,19 +23530,32 @@ class GitHubPublisher extends ModPublisher {
return github_publisher_awaiter(this, void 0, void 0, function* () { return github_publisher_awaiter(this, void 0, void 0, function* () {
const repo = github.context.repo; const repo = github.context.repo;
const octokit = github.getOctokit(token); const octokit = github.getOctokit(token);
const environmentTag = getEnvironmentTag();
let tag = mapStringInput(options.tag, null); let tag = mapStringInput(options.tag, null);
let releaseId = tag ? yield this.getReleaseIdByTag(tag, token) : (_a = github.context.payload.release) === null || _a === void 0 ? void 0 : _a.id; let releaseId = 0;
if (tag) {
releaseId = yield this.getReleaseIdByTag(tag, token);
}
else if ((_a = github.context.payload.release) === null || _a === void 0 ? void 0 : _a.id) {
releaseId = (_b = github.context.payload.release) === null || _b === void 0 ? void 0 : _b.id;
}
else if (environmentTag) {
releaseId = yield this.getReleaseIdByTag(environmentTag, token);
}
else if (version) {
releaseId = yield this.getReleaseIdByTag(version, token);
}
const generated = !releaseId; const generated = !releaseId;
if (!releaseId && (tag !== null && tag !== void 0 ? tag : (tag = (_b = getEnvironmentTag()) !== null && _b !== void 0 ? _b : version))) { if (!releaseId && (tag !== null && tag !== void 0 ? tag : (tag = environmentTag !== null && environmentTag !== void 0 ? environmentTag : version))) {
const generateChangelog = mapBooleanInput(options.generateChangelog, !changelog); const generateChangelog = mapBooleanInput(options.generateChangelog, !changelog);
const draft = mapBooleanInput(options.draft, false); const draft = mapBooleanInput(options.draft, false);
const prerelease = mapBooleanInput(options.prerelease, channel !== VersionType.Release); const prerelease = mapBooleanInput(options.prerelease, channel !== version_type.Release);
const commitish = mapStringInput(options.commitish, null); const commitish = mapStringInput(options.commitish, null);
const discussion = mapStringInput(options.discussion, null); const discussion = mapStringInput(options.discussion, null);
releaseId = yield this.createRelease(tag, name, changelog, generateChangelog, draft, prerelease, commitish, discussion, token); releaseId = yield this.createRelease(tag, name, changelog, generateChangelog, draft, prerelease, commitish, discussion, token);
} }
if (!releaseId) { if (!releaseId) {
throw new Error(`Cannot find or create release #${options.tag || releaseId}`); throw new Error(`Cannot find or create release ${tag}`);
} }
const existingAssets = generated ? [] : (yield octokit.rest.repos.listReleaseAssets(Object.assign(Object.assign({}, repo), { release_id: releaseId }))).data; const existingAssets = generated ? [] : (yield octokit.rest.repos.listReleaseAssets(Object.assign(Object.assign({}, repo), { release_id: releaseId }))).data;
for (const file of files) { for (const file of files) {
@ -23614,8 +23627,8 @@ class SoftError extends Error {
} }
} }
;// CONCATENATED MODULE: ./src/utils/modrinth-utils.ts ;// CONCATENATED MODULE: ./src/utils/modrinth/index.ts
var modrinth_utils_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { var modrinth_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@ -23649,7 +23662,7 @@ function createVersion(modId, data, files, token) {
function getProject(idOrSlug) { function getProject(idOrSlug) {
return processResponse(lib_default()(`${baseUrl}/project/${idOrSlug}`), { 404: () => null }); return processResponse(lib_default()(`${baseUrl}/project/${idOrSlug}`), { 404: () => null });
} }
function modrinth_utils_getVersions(idOrSlug, loaders, gameVersions, featured, token) { function modrinth_getVersions(idOrSlug, loaders, gameVersions, featured, token) {
const urlParams = new external_url_.URLSearchParams(); const urlParams = new external_url_.URLSearchParams();
if (loaders) { if (loaders) {
urlParams.append("loaders", JSON.stringify(loaders)); urlParams.append("loaders", JSON.stringify(loaders));
@ -23666,7 +23679,7 @@ function modrinth_utils_getVersions(idOrSlug, loaders, gameVersions, featured, t
return processResponse(response, { 404: () => [] }); return processResponse(response, { 404: () => [] });
} }
function modifyVersion(id, version, token) { function modifyVersion(id, version, token) {
return modrinth_utils_awaiter(this, void 0, void 0, function* () { return modrinth_awaiter(this, void 0, void 0, function* () {
const response = yield lib_default()(`${baseUrl}/version/${id}`, { const response = yield lib_default()(`${baseUrl}/version/${id}`, {
method: "PATCH", method: "PATCH",
headers: { headers: {
@ -23679,7 +23692,7 @@ function modifyVersion(id, version, token) {
}); });
} }
function processResponse(response, mappers, errorFactory) { function processResponse(response, mappers, errorFactory) {
return modrinth_utils_awaiter(this, void 0, void 0, function* () { return modrinth_awaiter(this, void 0, void 0, function* () {
response = yield response; response = yield response;
if (response.ok) { if (response.ok) {
return yield response.json(); return yield response.json();
@ -23697,16 +23710,117 @@ function processResponse(response, mappers, errorFactory) {
} }
catch (_a) { } catch (_a) { }
errorText = `${response.status} (${errorText})`; errorText = `${response.status} (${errorText})`;
const isServerError = response.status >= 500; const isSoftError = response.status === 429 || response.status >= 500;
if (errorFactory) { if (errorFactory) {
throw errorFactory(isServerError, errorText, response); throw errorFactory(isSoftError, errorText, response);
} }
else { else {
throw new SoftError(isServerError, errorText); throw new SoftError(isSoftError, errorText);
} }
}); });
} }
;// CONCATENATED MODULE: ./src/utils/diagnostics/stopwatch.ts
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Stopwatch_initialDate, _Stopwatch_isRunning, _Stopwatch_elapsedMilliseconds, _Stopwatch_onStart, _Stopwatch_onStop;
class Stopwatch {
constructor(onStart, onStop) {
_Stopwatch_initialDate.set(this, 0);
_Stopwatch_isRunning.set(this, false);
_Stopwatch_elapsedMilliseconds.set(this, 0);
_Stopwatch_onStart.set(this, null);
_Stopwatch_onStop.set(this, null);
__classPrivateFieldSet(this, _Stopwatch_onStart, onStart, "f");
__classPrivateFieldSet(this, _Stopwatch_onStop, onStop, "f");
}
get elapsedMilliseconds() {
return __classPrivateFieldGet(this, _Stopwatch_isRunning, "f")
? (__classPrivateFieldGet(this, _Stopwatch_elapsedMilliseconds, "f") + new Date().valueOf() - __classPrivateFieldGet(this, _Stopwatch_initialDate, "f"))
: __classPrivateFieldGet(this, _Stopwatch_elapsedMilliseconds, "f");
}
get isRunning() {
return __classPrivateFieldGet(this, _Stopwatch_isRunning, "f");
}
start() {
var _a;
if (!__classPrivateFieldGet(this, _Stopwatch_isRunning, "f")) {
const currentDate = new Date();
__classPrivateFieldSet(this, _Stopwatch_initialDate, currentDate.valueOf(), "f");
__classPrivateFieldSet(this, _Stopwatch_isRunning, true, "f");
(_a = __classPrivateFieldGet(this, _Stopwatch_onStart, "f")) === null || _a === void 0 ? void 0 : _a.call(this, currentDate, this);
return true;
}
return false;
}
stop() {
var _a;
if (__classPrivateFieldGet(this, _Stopwatch_isRunning, "f")) {
const currentDate = new Date();
__classPrivateFieldSet(this, _Stopwatch_elapsedMilliseconds, __classPrivateFieldGet(this, _Stopwatch_elapsedMilliseconds, "f") + (currentDate.valueOf() - __classPrivateFieldGet(this, _Stopwatch_initialDate, "f")), "f");
__classPrivateFieldSet(this, _Stopwatch_isRunning, false, "f");
(_a = __classPrivateFieldGet(this, _Stopwatch_onStop, "f")) === null || _a === void 0 ? void 0 : _a.call(this, __classPrivateFieldGet(this, _Stopwatch_elapsedMilliseconds, "f"), currentDate, this);
return true;
}
return false;
}
reset() {
this.stop();
__classPrivateFieldSet(this, _Stopwatch_elapsedMilliseconds, 0, "f");
}
restart() {
this.reset();
this.start();
}
static startNew(onStart, onStop) {
const stopwatch = new Stopwatch(onStart, onStop);
stopwatch.start();
return stopwatch;
}
}
_Stopwatch_initialDate = new WeakMap(), _Stopwatch_isRunning = new WeakMap(), _Stopwatch_elapsedMilliseconds = new WeakMap(), _Stopwatch_onStart = new WeakMap(), _Stopwatch_onStop = new WeakMap();
;// CONCATENATED MODULE: ./src/utils/logging/logging-stopwatch.ts
function toCallback(func) {
if (typeof func === "string") {
return (() => func);
}
return func;
}
function loggingCallbackToVoidCallback(logger, func) {
if (!func) {
return func;
}
return (...args) => {
const msg = func(...args);
if (typeof msg === "string") {
logger === null || logger === void 0 ? void 0 : logger.info(msg);
}
};
}
// eslint-disable-next-line
// @ts-ignore: ts2417
class LoggingStopwatch extends Stopwatch {
constructor(logger, onStart, onStop) {
super(loggingCallbackToVoidCallback(logger, toCallback(onStart)), loggingCallbackToVoidCallback(logger, toCallback(onStop)));
}
static startNew(logger, onStart, onStop) {
const stopwatch = new LoggingStopwatch(logger, onStart, onStop);
stopwatch.start();
return stopwatch;
}
}
;// CONCATENATED MODULE: ./src/publishing/modrinth/modrinth-publisher.ts ;// CONCATENATED MODULE: ./src/publishing/modrinth/modrinth-publisher.ts
var modrinth_publisher_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { var modrinth_publisher_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@ -23722,6 +23836,7 @@ var modrinth_publisher_awaiter = (undefined && undefined.__awaiter) || function
var UnfeatureMode; var UnfeatureMode;
(function (UnfeatureMode) { (function (UnfeatureMode) {
UnfeatureMode[UnfeatureMode["None"] = 0] = "None"; UnfeatureMode[UnfeatureMode["None"] = 0] = "None";
@ -23742,7 +23857,7 @@ const modrinthDependencyKinds = new Map([
[dependency_kind.Depends, "required"], [dependency_kind.Depends, "required"],
[dependency_kind.Recommends, "optional"], [dependency_kind.Recommends, "optional"],
[dependency_kind.Suggests, "optional"], [dependency_kind.Suggests, "optional"],
[dependency_kind.Includes, "optional"], [dependency_kind.Includes, "embedded"],
[dependency_kind.Breaks, "incompatible"], [dependency_kind.Breaks, "incompatible"],
]); ]);
class ModrinthPublisher extends ModPublisher { class ModrinthPublisher extends ModPublisher {
@ -23781,12 +23896,11 @@ class ModrinthPublisher extends ModPublisher {
} }
unfeatureOlderVersions(id, token, unfeatureMode, loaders, gameVersions) { unfeatureOlderVersions(id, token, unfeatureMode, loaders, gameVersions) {
return modrinth_publisher_awaiter(this, void 0, void 0, function* () { return modrinth_publisher_awaiter(this, void 0, void 0, function* () {
this.logger.info("Unfeaturing older Modrinth versions..."); const unfeaturedVersions = new Array();
const start = new Date(); const stopwatch = LoggingStopwatch.startNew(this.logger, "📝 Unfeaturing older Modrinth versions...", ms => `✅ Successfully unfeatured: ${unfeaturedVersions.join(", ")} (in ${ms} ms)`);
const unfeaturedVersions = [];
const versionSubset = hasFlag(unfeatureMode, UnfeatureMode.VersionSubset); const versionSubset = hasFlag(unfeatureMode, UnfeatureMode.VersionSubset);
const loaderSubset = hasFlag(unfeatureMode, UnfeatureMode.LoaderSubset); const loaderSubset = hasFlag(unfeatureMode, UnfeatureMode.LoaderSubset);
const olderVersions = yield modrinth_utils_getVersions(id, hasFlag(unfeatureMode, UnfeatureMode.LoaderAny) ? null : loaders, hasFlag(unfeatureMode, UnfeatureMode.VersionAny) ? null : gameVersions, true, token); const olderVersions = yield modrinth_getVersions(id, hasFlag(unfeatureMode, UnfeatureMode.LoaderAny) ? null : loaders, hasFlag(unfeatureMode, UnfeatureMode.VersionAny) ? null : gameVersions, true, token);
for (const olderVersion of olderVersions) { for (const olderVersion of olderVersions) {
if (loaderSubset && !olderVersion.loaders.every(x => loaders.includes(x))) { if (loaderSubset && !olderVersion.loaders.every(x => loaders.includes(x))) {
continue; continue;
@ -23798,22 +23912,21 @@ class ModrinthPublisher extends ModPublisher {
unfeaturedVersions.push(olderVersion.id); unfeaturedVersions.push(olderVersion.id);
} }
else { else {
this.logger.warn(`Cannot unfeature version ${olderVersion.id}`); this.logger.warn(`⚠️ Cannot unfeature version ${olderVersion.id}`);
} }
} }
if (unfeaturedVersions.length) { if (unfeaturedVersions.length) {
const end = new Date(); stopwatch.stop();
this.logger.info(`Successfully unfeatured versions ${unfeaturedVersions.join(", ")} (in ${end.getTime() - start.getTime()} ms)`);
} }
else { else {
this.logger.info("No versions to unfeature were found"); this.logger.info("No versions to unfeature were found");
} }
}); });
} }
} }
;// CONCATENATED MODULE: ./src/utils/curseforge-utils.ts ;// CONCATENATED MODULE: ./src/utils/curseforge/index.ts
var curseforge_utils_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { var curseforge_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@ -23826,7 +23939,7 @@ var curseforge_utils_awaiter = (undefined && undefined.__awaiter) || function (t
const curseforge_utils_baseUrl = "https://minecraft.curseforge.com/api"; const curseforge_baseUrl = "https://minecraft.curseforge.com/api";
class CurseForgeUploadError extends SoftError { class CurseForgeUploadError extends SoftError {
constructor(soft, message, info) { constructor(soft, message, info) {
super(soft, message); super(soft, message);
@ -23834,11 +23947,11 @@ class CurseForgeUploadError extends SoftError {
} }
} }
function fetchJsonArray(url) { function fetchJsonArray(url) {
return curseforge_utils_awaiter(this, void 0, void 0, function* () { return curseforge_awaiter(this, void 0, void 0, function* () {
const response = yield lib_default()(url); const response = yield lib_default()(url);
if (!response.ok) { if (!response.ok) {
const isServerError = response.status >= 500; const isSoft = response.status === 429 || response.status >= 500;
throw new SoftError(isServerError, `${response.status} (${response.statusText})`); throw new SoftError(isSoft, `${response.status} (${response.statusText})`);
} }
let array; let array;
try { try {
@ -23855,7 +23968,7 @@ function fetchJsonArray(url) {
} }
let cachedCurseForgeVersions = null; let cachedCurseForgeVersions = null;
function getCurseForgeVersions(token) { function getCurseForgeVersions(token) {
return curseforge_utils_awaiter(this, void 0, void 0, function* () { return curseforge_awaiter(this, void 0, void 0, function* () {
if (!cachedCurseForgeVersions) { if (!cachedCurseForgeVersions) {
cachedCurseForgeVersions = yield loadCurseForgeVersions(token); cachedCurseForgeVersions = yield loadCurseForgeVersions(token);
} }
@ -23863,12 +23976,12 @@ function getCurseForgeVersions(token) {
}); });
} }
function loadCurseForgeVersions(token) { function loadCurseForgeVersions(token) {
return curseforge_utils_awaiter(this, void 0, void 0, function* () { return curseforge_awaiter(this, void 0, void 0, function* () {
const versionTypes = yield fetchJsonArray(`${curseforge_utils_baseUrl}/game/version-types?token=${token}`); const versionTypes = yield fetchJsonArray(`${curseforge_baseUrl}/game/version-types?token=${token}`);
const javaVersionTypes = versionTypes.filter(x => x.slug.startsWith("java")).map(x => x.id); const javaVersionTypes = versionTypes.filter(x => x.slug.startsWith("java")).map(x => x.id);
const minecraftVersionTypes = versionTypes.filter(x => x.slug.startsWith("minecraft")).map(x => x.id); const minecraftVersionTypes = versionTypes.filter(x => x.slug.startsWith("minecraft")).map(x => x.id);
const loaderVersionTypes = versionTypes.filter(x => x.slug.startsWith("modloader")).map(x => x.id); const loaderVersionTypes = versionTypes.filter(x => x.slug.startsWith("modloader")).map(x => x.id);
const versions = yield fetchJsonArray(`${curseforge_utils_baseUrl}/game/versions?token=${token}`); const versions = yield fetchJsonArray(`${curseforge_baseUrl}/game/versions?token=${token}`);
return versions.reduce((container, version) => { return versions.reduce((container, version) => {
if (javaVersionTypes.includes(version.gameVersionTypeID)) { if (javaVersionTypes.includes(version.gameVersionTypeID)) {
container.java.push(version); container.java.push(version);
@ -23884,7 +23997,7 @@ function loadCurseForgeVersions(token) {
}); });
} }
function unifyGameVersion(gameVersion) { function unifyGameVersion(gameVersion) {
return curseforge_utils_awaiter(this, void 0, void 0, function* () { return curseforge_awaiter(this, void 0, void 0, function* () {
gameVersion = gameVersion.trim(); gameVersion = gameVersion.trim();
const minecraftVersion = yield findVersionByName(gameVersion); const minecraftVersion = yield findVersionByName(gameVersion);
if (minecraftVersion) { if (minecraftVersion) {
@ -23902,7 +24015,7 @@ function unifyJava(java) {
return java; return java;
} }
function addVersionIntersectionToSet(curseForgeVersions, versions, unify, comparer, intersection) { function addVersionIntersectionToSet(curseForgeVersions, versions, unify, comparer, intersection) {
return curseforge_utils_awaiter(this, void 0, void 0, function* () { return curseforge_awaiter(this, void 0, void 0, function* () {
for (const version of versions) { for (const version of versions) {
const unifiedVersion = yield unify(version); const unifiedVersion = yield unify(version);
const curseForgeVersion = curseForgeVersions.find(x => comparer(x, unifiedVersion)); const curseForgeVersion = curseForgeVersions.find(x => comparer(x, unifiedVersion));
@ -23913,7 +24026,7 @@ function addVersionIntersectionToSet(curseForgeVersions, versions, unify, compar
}); });
} }
function convertToCurseForgeVersions(gameVersions, loaders, java, token) { function convertToCurseForgeVersions(gameVersions, loaders, java, token) {
return curseforge_utils_awaiter(this, void 0, void 0, function* () { return curseforge_awaiter(this, void 0, void 0, function* () {
const versions = new Set(); const versions = new Set();
const curseForgeVersions = yield getCurseForgeVersions(token); const curseForgeVersions = yield getCurseForgeVersions(token);
yield addVersionIntersectionToSet(curseForgeVersions.gameVersions, gameVersions, unifyGameVersion, (cfv, v) => cfv.name === v, versions); yield addVersionIntersectionToSet(curseForgeVersions.gameVersions, gameVersions, unifyGameVersion, (cfv, v) => cfv.name === v, versions);
@ -23924,7 +24037,7 @@ function convertToCurseForgeVersions(gameVersions, loaders, java, token) {
} }
function uploadFile(id, data, file, token) { function uploadFile(id, data, file, token) {
var _a; var _a;
return curseforge_utils_awaiter(this, void 0, void 0, function* () { return curseforge_awaiter(this, void 0, void 0, function* () {
if (Array.isArray((_a = data.relations) === null || _a === void 0 ? void 0 : _a.projects) && (!data.relations.projects.length || data.parentFileID)) { if (Array.isArray((_a = data.relations) === null || _a === void 0 ? void 0 : _a.projects) && (!data.relations.projects.length || data.parentFileID)) {
delete data.relations; delete data.relations;
} }
@ -23934,7 +24047,7 @@ function uploadFile(id, data, file, token) {
const form = new (form_data_default())(); const form = new (form_data_default())();
form.append("file", file.getStream(), file.name); form.append("file", file.getStream(), file.name);
form.append("metadata", JSON.stringify(data)); form.append("metadata", JSON.stringify(data));
const response = yield lib_default()(`${curseforge_utils_baseUrl}/projects/${id}/upload-file?token=${token}`, { const response = yield lib_default()(`${curseforge_baseUrl}/projects/${id}/upload-file?token=${token}`, {
method: "POST", method: "POST",
headers: form.getHeaders(), headers: form.getHeaders(),
body: form body: form
@ -23947,8 +24060,8 @@ function uploadFile(id, data, file, token) {
errorText += `, ${JSON.stringify(info)}`; errorText += `, ${JSON.stringify(info)}`;
} }
catch (_b) { } catch (_b) { }
const isServerError = response.status >= 500; const isSoftError = response.status === 429 || response.status >= 500;
throw new CurseForgeUploadError(isServerError, `Failed to upload file: ${response.status} (${errorText})`, info); throw new CurseForgeUploadError(isSoftError, `Failed to upload file: ${response.status} (${errorText})`, info);
} }
return (yield response.json()).id; return (yield response.json()).id;
}); });
@ -24058,8 +24171,8 @@ function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));
} }
;// CONCATENATED MODULE: ./src/utils/function-utils.ts ;// CONCATENATED MODULE: ./src/utils/retry.ts
var function_utils_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { var retry_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@ -24070,7 +24183,7 @@ var function_utils_awaiter = (undefined && undefined.__awaiter) || function (thi
}; };
function retry({ func, delay = 0, maxAttempts = -1, softErrorPredicate, errorCallback }) { function retry({ func, delay = 0, maxAttempts = -1, softErrorPredicate, errorCallback }) {
return function_utils_awaiter(this, void 0, void 0, function* () { return retry_awaiter(this, void 0, void 0, function* () {
let attempts = 0; let attempts = 0;
while (true) { while (true) {
try { try {
@ -24090,6 +24203,159 @@ function retry({ func, delay = 0, maxAttempts = -1, softErrorPredicate, errorCal
}); });
} }
;// CONCATENATED MODULE: ./node_modules/indent-string/index.js
function indentString(string, count = 1, options = {}) {
const {
indent = ' ',
includeEmptyLines = false
} = options;
if (typeof string !== 'string') {
throw new TypeError(
`Expected \`input\` to be a \`string\`, got \`${typeof string}\``
);
}
if (typeof count !== 'number') {
throw new TypeError(
`Expected \`count\` to be a \`number\`, got \`${typeof count}\``
);
}
if (count < 0) {
throw new RangeError(
`Expected \`count\` to be at least 0, got \`${count}\``
);
}
if (typeof indent !== 'string') {
throw new TypeError(
`Expected \`options.indent\` to be a \`string\`, got \`${typeof indent}\``
);
}
if (count === 0) {
return string;
}
const regex = includeEmptyLines ? /^/gm : /^(?!\s*$)/gm;
return string.replace(regex, indent.repeat(count));
}
// EXTERNAL MODULE: external "os"
var external_os_ = __nccwpck_require__(2037);
;// CONCATENATED MODULE: ./node_modules/clean-stack/node_modules/escape-string-regexp/index.js
function escapeStringRegexp(string) {
if (typeof string !== 'string') {
throw new TypeError('Expected a string');
}
// Escape characters with special meaning either inside or outside character sets.
// Use a simple backslash escape when its always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns stricter grammar.
return string
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
.replace(/-/g, '\\x2d');
}
;// CONCATENATED MODULE: ./node_modules/clean-stack/index.js
const extractPathRegex = /\s+at.*[(\s](.*)\)?/;
const pathRegex = /^(?:(?:(?:node|node:[\w/]+|(?:(?:node:)?internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)(?:\.js)?:\d+:\d+)|native)/;
const homeDir = typeof external_os_.homedir === 'undefined' ? '' : external_os_.homedir().replace(/\\/g, '/');
function cleanStack(stack, {pretty = false, basePath} = {}) {
const basePathRegex = basePath && new RegExp(`(at | \\()${escapeStringRegexp(basePath.replace(/\\/g, '/'))}`, 'g');
if (typeof stack !== 'string') {
return undefined;
}
return stack.replace(/\\/g, '/')
.split('\n')
.filter(line => {
const pathMatches = line.match(extractPathRegex);
if (pathMatches === null || !pathMatches[1]) {
return true;
}
const match = pathMatches[1];
// Electron
if (
match.includes('.app/Contents/Resources/electron.asar') ||
match.includes('.app/Contents/Resources/default_app.asar') ||
match.includes('node_modules/electron/dist/resources/electron.asar') ||
match.includes('node_modules/electron/dist/resources/default_app.asar')
) {
return false;
}
return !pathRegex.test(match);
})
.filter(line => line.trim() !== '')
.map(line => {
if (basePathRegex) {
line = line.replace(basePathRegex, '$1');
}
if (pretty) {
line = line.replace(extractPathRegex, (m, p1) => m.replace(p1, p1.replace(homeDir, '~')));
}
return line;
})
.join('\n');
}
;// CONCATENATED MODULE: ./node_modules/aggregate-error/index.js
const cleanInternalStack = stack => stack.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, '');
class AggregateError extends Error {
#errors;
name = 'AggregateError';
constructor(errors) {
if (!Array.isArray(errors)) {
throw new TypeError(`Expected input to be an Array, got ${typeof errors}`);
}
errors = errors.map(error => {
if (error instanceof Error) {
return error;
}
if (error !== null && typeof error === 'object') {
// Handle plain error objects with message property and/or possibly other metadata
return Object.assign(new Error(error.message), error);
}
return new Error(error);
});
let message = errors
.map(error => {
// The `stack` property is not standardized, so we can't assume it exists
return typeof error.stack === 'string' && error.stack.length > 0 ? cleanInternalStack(cleanStack(error.stack)) : String(error);
})
.join('\n');
message = '\n' + indentString(message, 4);
super(message);
this.#errors = errors;
}
get errors() {
return this.#errors.slice();
}
}
;// CONCATENATED MODULE: ./src/index.ts ;// CONCATENATED MODULE: ./src/index.ts
var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@ -24106,13 +24372,21 @@ var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argu
var FailMode;
(function (FailMode) {
FailMode[FailMode["Fail"] = 0] = "Fail";
FailMode[FailMode["Warn"] = 1] = "Warn";
FailMode[FailMode["Skip"] = 2] = "Skip";
})(FailMode || (FailMode = {}));
function main() { function main() {
var _a, _b;
return src_awaiter(this, void 0, void 0, function* () { return src_awaiter(this, void 0, void 0, function* () {
const commonOptions = getInputAsObject(); const commonOptions = getInputAsObject();
const publisherFactory = new PublisherFactory(); const publisherFactory = new PublisherFactory();
const logger = getDefaultLogger(); const logger = getDefaultLogger();
const publishedTo = new Array(); const publishedTo = new Array();
const errors = new Array();
for (const target of publisher_target.getValues()) { for (const target of publisher_target.getValues()) {
const targetName = publisher_target.toString(target); const targetName = publisher_target.toString(target);
const publisherOptions = commonOptions[targetName.toLowerCase()]; const publisherOptions = commonOptions[targetName.toLowerCase()];
@ -24120,35 +24394,53 @@ function main() {
continue; continue;
} }
const options = Object.assign(Object.assign({}, commonOptions), publisherOptions); const options = Object.assign(Object.assign({}, commonOptions), publisherOptions);
const fileSelector = options.files && (typeof (options.files) === "string" || options.files.primary) ? options.files : gradleOutputSelector; const fileSelector = typeof options.filesPrimary === "string" ? { primary: options.filesPrimary, secondary: typeof options.filesSecondary === "string" ? options.filesSecondary : gradleOutputSelector.secondary } : typeof options.files === "string" ? options.files : gradleOutputSelector;
const files = yield getRequiredFiles(fileSelector); const files = yield File.getRequiredFiles(fileSelector);
const retryAttempts = mapNumberInput((_a = options.retry) === null || _a === void 0 ? void 0 : _a["attempts"]); const retryAttempts = mapNumberInput(options.retryAttempts);
const retryDelay = mapNumberInput((_b = options.retry) === null || _b === void 0 ? void 0 : _b["delay"]); const retryDelay = mapNumberInput(options.retryDelay);
const failMode = mapEnumInput(options.failMode, FailMode, FailMode.Fail);
const publisher = publisherFactory.create(target, logger); const publisher = publisherFactory.create(target, logger);
logger.info(`Publishing assets to ${targetName}...`); const func = {
const start = new Date();
yield retry({
func: () => publisher.publish(files, options), func: () => publisher.publish(files, options),
maxAttempts: retryAttempts, maxAttempts: retryAttempts,
delay: retryDelay, delay: retryDelay,
errorCallback: e => { errorCallback: (e) => {
logger.error(`${e}`); logger.error(e);
logger.info(`Retrying to publish assets to ${targetName} in ${retryDelay} ms...`); logger.info(`🔂 Retrying to publish assets to ${targetName} in ${retryDelay} ms...`);
} }
}); };
const end = new Date(); const stopwatch = LoggingStopwatch.startNew(logger, `📤 Publishing assets to ${targetName}...`, ms => `✅ Successfully published assets to ${targetName} (in ${ms} ms)`);
logger.info(`Successfully published assets to ${targetName} (in ${end.getTime() - start.getTime()} ms)`); try {
yield retry(func);
}
catch (e) {
switch (failMode) {
case FailMode.Warn:
logger.warn(e);
continue;
case FailMode.Skip:
logger.warn(`☢️ An error occurred while uploading assets to ${targetName}`);
errors.push(e);
continue;
default:
throw e;
}
}
stopwatch.stop();
publishedTo.push(targetName); publishedTo.push(targetName);
} }
if (publishedTo.length) { if (publishedTo.length) {
logger.info(`Your assets have been successfully published to: ${publishedTo.join(", ")}`); logger.info(`🎉 Your assets have been successfully published to: ${publishedTo.join(", ")}`);
} }
else { else if (!errors.length) {
logger.warn("You didn't specify any targets, your assets have not been published"); logger.warn("🗿 You didn't specify any targets, your assets have not been published");
}
if (errors.length) {
throw new AggregateError(errors);
} }
}); });
} }
main().catch(error => getDefaultLogger().fatal(error instanceof Error ? `${error}` : `Something went horribly wrong: ${error}`)); main().catch(error => getDefaultLogger().fatal(error instanceof Error ? error : `💀 Something went horribly wrong: ${error}`));
/***/ }), /***/ }),
@ -24371,7 +24663,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
/******/ // startup /******/ // startup
/******/ // Load entry module and return exports /******/ // Load entry module and return exports
/******/ // This entry module doesn't tell about it's top-level declarations so it can't be inlined /******/ // This entry module doesn't tell about it's top-level declarations so it can't be inlined
/******/ var __webpack_exports__ = __nccwpck_require__(4067); /******/ var __webpack_exports__ = __nccwpck_require__(1991);
/******/ module.exports = __webpack_exports__; /******/ module.exports = __webpack_exports__;
/******/ /******/
/******/ })() /******/ })()

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

52
dist/license.txt vendored
View file

@ -304,6 +304,19 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
aggregate-error
MIT
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
asynckit asynckit
MIT MIT
The MIT License (MIT) The MIT License (MIT)
@ -559,6 +572,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
clean-stack
MIT
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
combined-stream combined-stream
MIT MIT
Copyright (c) 2011 Debuggable Limited <felix@debuggable.com> Copyright (c) 2011 Debuggable Limited <felix@debuggable.com>
@ -624,6 +650,19 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
escape-string-regexp
MIT
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
fast-glob fast-glob
MIT MIT
The MIT License (MIT) The MIT License (MIT)
@ -733,6 +772,19 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
indent-string
MIT
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
is-extglob is-extglob
MIT MIT
The MIT License (MIT) The MIT License (MIT)