From 51abe86d3f67fffcc6ecee59b68b4a5cce54202b Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Fri, 20 May 2022 12:36:33 +0200 Subject: [PATCH 1/3] Throw a warning for mods that opted out --- .github/actions/ci/node/.gitignore | 1 + .../actions/ci/node/curse-distributable.js | 39 ++ .github/actions/ci/node/package-lock.json | 423 ++++++++++++++++++ .github/actions/ci/node/package.json | 6 + .github/workflows/ci.yml | 10 + 5 files changed, 479 insertions(+) create mode 100644 .github/actions/ci/node/.gitignore create mode 100644 .github/actions/ci/node/curse-distributable.js create mode 100644 .github/actions/ci/node/package-lock.json create mode 100644 .github/actions/ci/node/package.json diff --git a/.github/actions/ci/node/.gitignore b/.github/actions/ci/node/.gitignore new file mode 100644 index 0000000000..2ccbe4656c --- /dev/null +++ b/.github/actions/ci/node/.gitignore @@ -0,0 +1 @@ +/node_modules/ diff --git a/.github/actions/ci/node/curse-distributable.js b/.github/actions/ci/node/curse-distributable.js new file mode 100644 index 0000000000..f90fd294bd --- /dev/null +++ b/.github/actions/ci/node/curse-distributable.js @@ -0,0 +1,39 @@ +const fs = require('fs'); +const axios = require('axios'); +const https = require('https'); +const clc = require('cli-color'); + +const minecraftinstance = JSON.parse(fs.readFileSync('minecraftinstance.json')); + +https.globalAgent.maxSockets = 5; // concurrent api requests + +const no_3rd_party_downloads = []; + +const requests = []; + +minecraftinstance.installedAddons.forEach(addon => { + requests.push(axios.get(`https://auto.xmdhs.top/curse/api/v2/addon/${addon.addonID}`) + .then(response => { + const allowed = String(response.data.allowModDistribution); + + let color = clc.yellow; + if(allowed === 'true') color = clc.green; + if(allowed === 'false') color = clc.red; + + console.log(response.data.name, color(allowed)); + + if(response.data.allowModDistribution === false) no_3rd_party_downloads.push(response.data.name); + }) + .catch(error => { + console.log(error.response.status); + console.log(addon); + })); +}); + +Promise.all(requests) + .then(() => { + console.log(no_3rd_party_downloads); + if (no_3rd_party_downloads.length > 0) { + console.log(`::warning::${no_3rd_party_downloads.length} have opted out of distribution: ${no_3rd_party_downloads.join(', ')}`); + } + }); diff --git a/.github/actions/ci/node/package-lock.json b/.github/actions/ci/node/package-lock.json new file mode 100644 index 0000000000..98d0ceeed0 --- /dev/null +++ b/.github/actions/ci/node/package-lock.json @@ -0,0 +1,423 @@ +{ + "name": "node", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "axios": "^0.27.2", + "cli-color": "^2.0.2" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/cli-color": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.2.tgz", + "integrity": "sha512-g4JYjrTW9MGtCziFNjkqp3IMpGhnJyeB0lOtRPjQkYhXzKYr6tYnXKyEVnMzITxhpbahsEW9KsxOYIDKwcsIBw==", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.59", + "es6-iterator": "^2.0.3", + "memoizee": "^0.4.15", + "timers-ext": "^0.1.7" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "dependencies": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/es5-ext": { + "version": "0.10.61", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.61.tgz", + "integrity": "sha512-yFhIqQAzu2Ca2I4SE2Au3rxVfmohU9Y7wqGR+s7+H7krk26NXhIRAZDgqd6xqjCEFUomDEA3/Bo/7fKmIkW1kA==", + "hasInstallScript": true, + "dependencies": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "node_modules/es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "dependencies": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "node_modules/es6-weak-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.1" + } + }, + "node_modules/event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", + "dependencies": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, + "node_modules/ext": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.6.0.tgz", + "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==", + "dependencies": { + "type": "^2.5.0" + } + }, + "node_modules/ext/node_modules/type": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/type/-/type-2.6.0.tgz", + "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==" + }, + "node_modules/follow-redirects": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz", + "integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/is-promise": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==" + }, + "node_modules/lru-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", + "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", + "dependencies": { + "es5-ext": "~0.10.2" + } + }, + "node_modules/memoizee": { + "version": "0.4.15", + "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", + "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.53", + "es6-weak-map": "^2.0.3", + "event-emitter": "^0.3.5", + "is-promise": "^2.2.2", + "lru-queue": "^0.1.0", + "next-tick": "^1.1.0", + "timers-ext": "^0.1.7" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, + "node_modules/timers-ext": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", + "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==", + "dependencies": { + "es5-ext": "~0.10.46", + "next-tick": "1" + } + }, + "node_modules/type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + } + }, + "dependencies": { + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "requires": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "cli-color": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.2.tgz", + "integrity": "sha512-g4JYjrTW9MGtCziFNjkqp3IMpGhnJyeB0lOtRPjQkYhXzKYr6tYnXKyEVnMzITxhpbahsEW9KsxOYIDKwcsIBw==", + "requires": { + "d": "^1.0.1", + "es5-ext": "^0.10.59", + "es6-iterator": "^2.0.3", + "memoizee": "^0.4.15", + "timers-ext": "^0.1.7" + } + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "requires": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "es5-ext": { + "version": "0.10.61", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.61.tgz", + "integrity": "sha512-yFhIqQAzu2Ca2I4SE2Au3rxVfmohU9Y7wqGR+s7+H7krk26NXhIRAZDgqd6xqjCEFUomDEA3/Bo/7fKmIkW1kA==", + "requires": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "requires": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "requires": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "es6-weak-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", + "requires": { + "d": "1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.1" + } + }, + "event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", + "requires": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, + "ext": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.6.0.tgz", + "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==", + "requires": { + "type": "^2.5.0" + }, + "dependencies": { + "type": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/type/-/type-2.6.0.tgz", + "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==" + } + } + }, + "follow-redirects": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz", + "integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==" + }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, + "is-promise": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==" + }, + "lru-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", + "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", + "requires": { + "es5-ext": "~0.10.2" + } + }, + "memoizee": { + "version": "0.4.15", + "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", + "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", + "requires": { + "d": "^1.0.1", + "es5-ext": "^0.10.53", + "es6-weak-map": "^2.0.3", + "event-emitter": "^0.3.5", + "is-promise": "^2.2.2", + "lru-queue": "^0.1.0", + "next-tick": "^1.1.0", + "timers-ext": "^0.1.7" + } + }, + "mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" + }, + "mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "requires": { + "mime-db": "1.52.0" + } + }, + "next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, + "timers-ext": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", + "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==", + "requires": { + "es5-ext": "~0.10.46", + "next-tick": "1" + } + }, + "type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + } + } +} diff --git a/.github/actions/ci/node/package.json b/.github/actions/ci/node/package.json new file mode 100644 index 0000000000..98cbb420c2 --- /dev/null +++ b/.github/actions/ci/node/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "axios": "^0.27.2", + "cli-color": "^2.0.2" + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5420c06d7..40cc4ab51c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,3 +65,13 @@ jobs: - uses: actions/setup-node@v3 - run: node .github/actions/ci/kubejs-todo-remove.js + curseforge: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + + - run: npm install + working-directory: .github/actions/ci/node/ + - run: node .github/actions/ci/node/curse-distributable.js From fcba817ed037c950fbbb0ebfb318962bb12a674f Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Fri, 20 May 2022 12:54:51 +0200 Subject: [PATCH 2/3] Finetune --- .github/actions/ci/node/curse-distributable.js | 2 +- .github/workflows/ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/ci/node/curse-distributable.js b/.github/actions/ci/node/curse-distributable.js index f90fd294bd..1a8aa981db 100644 --- a/.github/actions/ci/node/curse-distributable.js +++ b/.github/actions/ci/node/curse-distributable.js @@ -34,6 +34,6 @@ Promise.all(requests) .then(() => { console.log(no_3rd_party_downloads); if (no_3rd_party_downloads.length > 0) { - console.log(`::warning::${no_3rd_party_downloads.length} have opted out of distribution: ${no_3rd_party_downloads.join(', ')}`); + console.log(`::warning::${no_3rd_party_downloads.length} mods have opted out of distribution: ${no_3rd_party_downloads.join(', ')}`); } }); diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40cc4ab51c..585326fce7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: - run: node .github/actions/ci/kubejs-todo-remove.js curseforge: runs-on: ubuntu-latest - timeout-minutes: 5 + timeout-minutes: 2.5 steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 From 7df02abc4e4327cb44e60fd3de113d8486eed520 Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Thu, 9 Jun 2022 19:20:34 +0200 Subject: [PATCH 3/3] Update to use the official curseforge api An official api key has yet to be obtained. --- .../actions/ci/node/curse-distributable.js | 20 +++++--- .github/actions/ci/node/package-lock.json | 49 +++++++++++++++++++ .github/actions/ci/node/package.json | 1 + 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/.github/actions/ci/node/curse-distributable.js b/.github/actions/ci/node/curse-distributable.js index 1a8aa981db..4ae03a68dc 100644 --- a/.github/actions/ci/node/curse-distributable.js +++ b/.github/actions/ci/node/curse-distributable.js @@ -3,26 +3,32 @@ const axios = require('axios'); const https = require('https'); const clc = require('cli-color'); -const minecraftinstance = JSON.parse(fs.readFileSync('minecraftinstance.json')); +const axiosThrottle = require('axios-request-throttle'); +axiosThrottle.use(axios, { requestsPerSecond: 4 }); -https.globalAgent.maxSockets = 5; // concurrent api requests +const minecraftinstance = JSON.parse(fs.readFileSync('minecraftinstance.json')); const no_3rd_party_downloads = []; const requests = []; +axios.defaults.headers.common = { + 'Accept': 'application/json', + 'x-api-key': ``, +} + minecraftinstance.installedAddons.forEach(addon => { - requests.push(axios.get(`https://auto.xmdhs.top/curse/api/v2/addon/${addon.addonID}`) + requests.push(axios.get(`https://api.curseforge.com/v1/mods/${addon.addonID}`) .then(response => { - const allowed = String(response.data.allowModDistribution); + const allowed = String(response.data.data.allowModDistribution); let color = clc.yellow; if(allowed === 'true') color = clc.green; if(allowed === 'false') color = clc.red; - console.log(response.data.name, color(allowed)); + console.log(response.data.data.name, color(allowed)); - if(response.data.allowModDistribution === false) no_3rd_party_downloads.push(response.data.name); + if(response.data.data.allowModDistribution === false) no_3rd_party_downloads.push(response.data.data.name); }) .catch(error => { console.log(error.response.status); @@ -34,6 +40,6 @@ Promise.all(requests) .then(() => { console.log(no_3rd_party_downloads); if (no_3rd_party_downloads.length > 0) { - console.log(`::warning::${no_3rd_party_downloads.length} mods have opted out of distribution: ${no_3rd_party_downloads.join(', ')}`); + console.log(`::warning::${no_3rd_party_downloads.length} mods would like to get paid for their work: ${no_3rd_party_downloads.join(', ')}`); } }); diff --git a/.github/actions/ci/node/package-lock.json b/.github/actions/ci/node/package-lock.json index 98d0ceeed0..a07fe39466 100644 --- a/.github/actions/ci/node/package-lock.json +++ b/.github/actions/ci/node/package-lock.json @@ -6,9 +6,19 @@ "": { "dependencies": { "axios": "^0.27.2", + "axios-request-throttle": "^1.0.0", "cli-color": "^2.0.2" } }, + "node_modules/@types/axios": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@types/axios/-/axios-0.14.0.tgz", + "integrity": "sha512-KqQnQbdYE54D7oa/UmYVMZKq7CO4l8DEENzOKc4aBRwxCXSlJXGz83flFx5L7AWrOQnmuN3kVsRdt+GZPPjiVQ==", + "deprecated": "This is a stub types definition for axios (https://github.com/mzabriskie/axios). axios provides its own type definitions, so you don't need @types/axios installed!", + "dependencies": { + "axios": "*" + } + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -23,6 +33,18 @@ "form-data": "^4.0.0" } }, + "node_modules/axios-request-throttle": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/axios-request-throttle/-/axios-request-throttle-1.0.0.tgz", + "integrity": "sha512-NYh7kZkgSJZyIohqrvQEzr4uygqbxXb769kbphkwgYNAJm5eDg33mqHLA2pwHKC1uqbTfNpmjmzWdUdo+ptBWg==", + "dependencies": { + "@types/axios": "^0.14.0", + "promise-throttle": "^1.1.2" + }, + "peerDependencies": { + "axios": "*" + } + }, "node_modules/cli-color": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.2.tgz", @@ -216,6 +238,11 @@ "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" }, + "node_modules/promise-throttle": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/promise-throttle/-/promise-throttle-1.1.2.tgz", + "integrity": "sha512-dij7vjyXNewuuN/gyr+TX2KRjw48mbV5FEtgyXaIoJjGYAKT0au23/voNvy9eS4UNJjx2KUdEcO5Yyfc1h7vWQ==" + }, "node_modules/timers-ext": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", @@ -232,6 +259,14 @@ } }, "dependencies": { + "@types/axios": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@types/axios/-/axios-0.14.0.tgz", + "integrity": "sha512-KqQnQbdYE54D7oa/UmYVMZKq7CO4l8DEENzOKc4aBRwxCXSlJXGz83flFx5L7AWrOQnmuN3kVsRdt+GZPPjiVQ==", + "requires": { + "axios": "*" + } + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -246,6 +281,15 @@ "form-data": "^4.0.0" } }, + "axios-request-throttle": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/axios-request-throttle/-/axios-request-throttle-1.0.0.tgz", + "integrity": "sha512-NYh7kZkgSJZyIohqrvQEzr4uygqbxXb769kbphkwgYNAJm5eDg33mqHLA2pwHKC1uqbTfNpmjmzWdUdo+ptBWg==", + "requires": { + "@types/axios": "^0.14.0", + "promise-throttle": "^1.1.2" + } + }, "cli-color": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.2.tgz", @@ -405,6 +449,11 @@ "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" }, + "promise-throttle": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/promise-throttle/-/promise-throttle-1.1.2.tgz", + "integrity": "sha512-dij7vjyXNewuuN/gyr+TX2KRjw48mbV5FEtgyXaIoJjGYAKT0au23/voNvy9eS4UNJjx2KUdEcO5Yyfc1h7vWQ==" + }, "timers-ext": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", diff --git a/.github/actions/ci/node/package.json b/.github/actions/ci/node/package.json index 98cbb420c2..5949f2304d 100644 --- a/.github/actions/ci/node/package.json +++ b/.github/actions/ci/node/package.json @@ -1,6 +1,7 @@ { "dependencies": { "axios": "^0.27.2", + "axios-request-throttle": "^1.0.0", "cli-color": "^2.0.2" } }