Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List mods that have opted out of curseforge 3rd party downloads #4870

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/actions/ci/node/curse-distributable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const fs = require('fs');
const axios = require('axios');
const https = require('https');
const clc = require('cli-color');

const axiosThrottle = require('axios-request-throttle');
axiosThrottle.use(axios, { requestsPerSecond: 4 });

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': `<api key>`,
}

minecraftinstance.installedAddons.forEach(addon => {
requests.push(axios.get(`https://api.curseforge.com/v1/mods/${addon.addonID}`)
.then(response => {
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.data.name, color(allowed));

if(response.data.data.allowModDistribution === false) no_3rd_party_downloads.push(response.data.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} mods would like to get paid for their work: ${no_3rd_party_downloads.join(', ')}`);
}
});
50 changes: 49 additions & 1 deletion .github/actions/ci/node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .github/actions/ci/node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"dependencies": {
"axios": "^0.27.2",
"axios-request-throttle": "^1.0.0",
"cli-color": "^2.0.2"
}
}
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,14 @@ jobs:
with:
name: compiled (${{ matrix.repo }})
path: ./KubeJS/forge/build/libs/kubejs-forge-1605.3.19-build.9999.jar
# job
curseforge:
runs-on: ubuntu-latest
timeout-minutes: 2.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