From e4885510d68ae07187f3f747664c304626bc6ddc Mon Sep 17 00:00:00 2001 From: dexter21767 Date: Thu, 19 Dec 2024 14:40:03 +0100 Subject: [PATCH] better support for non netlify deployments --- .env.example | 5 +++++ README.md | 2 +- build.js | 2 +- config.js | 11 ++++++++--- lib/discord.js | 2 +- lib/graphql.js | 2 +- package-lock.json | 22 +++++++++++++++++++++- package.json | 3 ++- 8 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8efbab2 --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +TOKEN="github Token" +DISCORD_WEBHOOK="discord webhook" +REPO="stremio-addons-list" +REPO_AUTHOR="danamag" +DOMAIN="stremio-addons.com" \ No newline at end of file diff --git a/README.md b/README.md index 47f82fb..0e9101d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > [!NOTE] > Due to recent abuse of this repository (malicious addons, spam) by a user called [vancengvn](https://github.com/Vance-ng-vn) we were forced to implement a moderation system. New addon submissions now need explicit approval from a contributor to be published - unless you are on the [trusted publishers](./trusted_publishers.json) list. Please contact a moderator on Discord or Reddit if your addon hasn't been approved after 7 days. -To see the great list of Stremio Addons go to [the website](https://stremio-addons.netlify.app/). +To see the great list of Stremio Addons go to [the website](https://stremio-addons.com/). To submit a new addon to the list, use [this link](https://github.com/danamag/stremio-addons-list/issues/new?assignees=&labels=pending+approval&template=submit-addon.yaml&title=Addon+Name). diff --git a/build.js b/build.js index 6be765a..009498e 100644 --- a/build.js +++ b/build.js @@ -208,7 +208,7 @@ getCached().then(cached => { }, 1) queue.drain = () => { - if (process.env.DISCORD_WEBHOOK && newAddons.length) + if (config.DISCORD_WEBHOOK && newAddons.length) sendDiscordMessage(newAddons) console.log('copying resources (styles, js, images)') fs.readdirSync('./resources').forEach(file => { diff --git a/config.js b/config.js index 16486ee..4d957d1 100644 --- a/config.js +++ b/config.js @@ -1,8 +1,13 @@ +require('dotenv').config() + module.exports = { + // env vars + "DISCORD_WEBHOOK": process.env.DISCORD_WEBHOOK, + "GITHUB_TOKEN": process.env.TOKEN, // for repo: danamag/stremio-addons-list - "repository": "stremio-addons-list", - "author": "danamag", - "netlify-domain": "stremio-addons.netlify.app", + "repository": process.env.REPO || "stremio-addons-list", + "author": process.env.REPO_AUTHOR || "danamag", + "netlify-domain": process.env.DOMAIN || "stremio-addons.com", "page-title": "Stremio Community Addons List", // images are located in ./resources/ "meta-favicon": "stremio_community_logo.png", diff --git a/lib/discord.js b/lib/discord.js index 084a3b3..2ee8dc3 100644 --- a/lib/discord.js +++ b/lib/discord.js @@ -41,7 +41,7 @@ const sendDiscordMessage = (addons) => { const needleOpts = Object.assign({}, config.needle) needleOpts.json = true console.log(`sending discord message about ${addons.length} new addons`) - needle.post(process.env.DISCORD_WEBHOOK, payload, needleOpts, (err, resp, body) => { + needle.post(config.DISCORD_WEBHOOK, payload, needleOpts, (err, resp, body) => { if (!err) console.log(`sent discord message about ${addons.length} new addons`) else { diff --git a/lib/graphql.js b/lib/graphql.js index 2b9bf1c..240a8c7 100644 --- a/lib/graphql.js +++ b/lib/graphql.js @@ -4,7 +4,7 @@ const config = require('../config') const request = graphql.defaults({ headers: { - authorization: `token ${process.env.TOKEN}`, + authorization: `token ${config.GITHUB_TOKEN}`, }, }) diff --git a/package-lock.json b/package-lock.json index dc46832..8bcfc5b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,14 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@octokit/graphql": "4.5.2", + "@octokit/graphql": "^4.5.2", "async.queue": "0.5.2", + "dotenv": "^16.4.7", "needle": "3.1.0", "slug": "8.2.2" + }, + "engines": { + "node": "16.18.0" } }, "node_modules/@octokit/endpoint": { @@ -148,6 +152,17 @@ "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" }, + "node_modules/dotenv": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", @@ -399,6 +414,11 @@ "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" }, + "dotenv": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==" + }, "iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", diff --git a/package.json b/package.json index 8722985..c08406b 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,9 @@ }, "dependencies": { "@octokit/graphql": "^4.5.2", - "needle": "3.1.0", "async.queue": "0.5.2", + "dotenv": "^16.4.7", + "needle": "3.1.0", "slug": "8.2.2" }, "engines": {