diff --git a/.github/actions/ci/node/curse-distributable.js b/.github/actions/ci/node/curse-distributable.js new file mode 100644 index 0000000000..4ae03a68dc --- /dev/null +++ b/.github/actions/ci/node/curse-distributable.js @@ -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': ``, +} + +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(', ')}`); + } + }); diff --git a/.github/actions/ci/node/package-lock.json b/.github/actions/ci/node/package-lock.json index 68efc2e67e..8554329bb6 100644 --- a/.github/actions/ci/node/package-lock.json +++ b/.github/actions/ci/node/package-lock.json @@ -1,15 +1,24 @@ { "name": "node", - "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "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", @@ -24,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", @@ -217,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", @@ -233,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", @@ -247,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", @@ -406,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" } } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e7cca3a7a..110bd35421 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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