From 883f0ed5802e0461e60b2755a4ebf90f23e7e2f4 Mon Sep 17 00:00:00 2001 From: Web4 Date: Fri, 13 Dec 2024 09:36:36 -0800 Subject: [PATCH] Delete scripts directory --- scripts/.gitignore | 1 - scripts/delete-deployment-preview.sh | 34 ---------- scripts/fetch-prompts.mjs | 98 ---------------------------- scripts/init-proxy.sh | 6 -- scripts/proxychains.template.conf | 12 ---- scripts/setup.sh | 68 ------------------- 6 files changed, 219 deletions(-) delete mode 100644 scripts/.gitignore delete mode 100755 scripts/delete-deployment-preview.sh delete mode 100644 scripts/fetch-prompts.mjs delete mode 100644 scripts/init-proxy.sh delete mode 100644 scripts/proxychains.template.conf delete mode 100644 scripts/setup.sh diff --git a/scripts/.gitignore b/scripts/.gitignore deleted file mode 100644 index 80fe56c37..000000000 --- a/scripts/.gitignore +++ /dev/null @@ -1 +0,0 @@ -proxychains.conf diff --git a/scripts/delete-deployment-preview.sh b/scripts/delete-deployment-preview.sh deleted file mode 100755 index 4f2bb3495..000000000 --- a/scripts/delete-deployment-preview.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# Set the pipefail option. -set -o pipefail - -# Get the Vercel API endpoints. -GET_DEPLOYMENTS_ENDPOINT="https://api.vercel.com/v6/deployments" -DELETE_DEPLOYMENTS_ENDPOINT="https://api.vercel.com/v13/deployments" - -# Create a list of deployments. -deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID&teamId=$VERCEL_ORG_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") -#deployments=$(curl -s -X GET "$GET_DEPLOYMENTS_ENDPOINT/?projectId=$VERCEL_PROJECT_ID" -H "Authorization: Bearer $VERCEL_TOKEN ") - -# Filter the deployments list by meta.base_hash === meta tag. -filtered_deployments=$(echo -E $deployments | jq --arg META_TAG "$META_TAG" '[.deployments[] | select(.meta.base_hash | type == "string" and contains($META_TAG)) | .uid] | join(",")') -filtered_deployments="${filtered_deployments//\"/}" # Remove double quotes - -# Clears the values from filtered_deployments -IFS=',' read -ra values <<<"$filtered_deployments" - -echo "META_TAG ${META_TAG}" -echo "Filtered deployments ${filtered_deployments}" - -# Iterate over the filtered deployments list. -for uid in "${values[@]}"; do - echo "Deleting ${uid}" - - delete_url="${DELETE_DEPLOYMENTS_ENDPOINT}/${uid}?teamId=${VERCEL_ORG_ID}" - echo $delete_url - - # Make DELETE a request to the /v13/deployments/{id} endpoint. - curl -X DELETE $delete_url -H "Authorization: Bearer $VERCEL_TOKEN" - - echo "Deleted!" -done diff --git a/scripts/fetch-prompts.mjs b/scripts/fetch-prompts.mjs deleted file mode 100644 index 4107f60a9..000000000 --- a/scripts/fetch-prompts.mjs +++ /dev/null @@ -1,98 +0,0 @@ -import fetch from "node-fetch"; -import fs from "fs/promises"; - -const RAW_FILE_URL = "https://raw.githubusercontent.com/"; -const MIRRORF_FILE_URL = "http://raw.fgit.ml/"; - -const RAW_CN_URL = "PlexPt/awesome-chatgpt-prompts-zh/main/prompts-zh.json"; -const CN_URL = MIRRORF_FILE_URL + RAW_CN_URL; -const RAW_TW_URL = "PlexPt/awesome-chatgpt-prompts-zh/main/prompts-zh-TW.json"; -const TW_URL = MIRRORF_FILE_URL + RAW_TW_URL; -const RAW_EN_URL = "f/awesome-chatgpt-prompts/main/prompts.csv"; -const EN_URL = MIRRORF_FILE_URL + RAW_EN_URL; -const FILE = "./public/prompts.json"; - -const ignoreWords = ["涩涩", "魅魔", "澀澀"]; - -const timeoutPromise = (timeout) => { - return new Promise((resolve, reject) => { - setTimeout(() => { - reject(new Error("Request timeout")); - }, timeout); - }); -}; - -async function fetchCN() { - console.log("[Fetch] fetching cn prompts..."); - try { - const response = await Promise.race([fetch(CN_URL), timeoutPromise(5000)]); - const raw = await response.json(); - return raw - .map((v) => [v.act, v.prompt]) - .filter( - (v) => - v[0] && - v[1] && - ignoreWords.every((w) => !v[0].includes(w) && !v[1].includes(w)), - ); - } catch (error) { - console.error("[Fetch] failed to fetch cn prompts", error); - return []; - } -} - -async function fetchTW() { - console.log("[Fetch] fetching tw prompts..."); - try { - const response = await Promise.race([fetch(TW_URL), timeoutPromise(5000)]); - const raw = await response.json(); - return raw - .map((v) => [v.act, v.prompt]) - .filter( - (v) => - v[0] && - v[1] && - ignoreWords.every((w) => !v[0].includes(w) && !v[1].includes(w)), - ); - } catch (error) { - console.error("[Fetch] failed to fetch tw prompts", error); - return []; - } -} - -async function fetchEN() { - console.log("[Fetch] fetching en prompts..."); - try { - // const raw = await (await fetch(EN_URL)).text(); - const response = await Promise.race([fetch(EN_URL), timeoutPromise(5000)]); - const raw = await response.text(); - return raw - .split("\n") - .slice(1) - .map((v) => - v - .split('","') - .map((v) => v.replace(/^"|"$/g, "").replaceAll('""', '"')) - .filter((v) => v[0] && v[1]), - ); - } catch (error) { - console.error("[Fetch] failed to fetch en prompts", error); - return []; - } -} - -async function main() { - Promise.all([fetchCN(), fetchTW(), fetchEN()]) - .then(([cn, tw, en]) => { - fs.writeFile(FILE, JSON.stringify({ cn, tw, en })); - }) - .catch((e) => { - console.error("[Fetch] failed to fetch prompts"); - fs.writeFile(FILE, JSON.stringify({ cn: [], tw: [], en: [] })); - }) - .finally(() => { - console.log("[Fetch] saved to " + FILE); - }); -} - -main(); diff --git a/scripts/init-proxy.sh b/scripts/init-proxy.sh deleted file mode 100644 index 32e55921a..000000000 --- a/scripts/init-proxy.sh +++ /dev/null @@ -1,6 +0,0 @@ -dir="$(dirname "$0")" -config=$dir/proxychains.conf -host_ip=$(grep nameserver /etc/resolv.conf | sed 's/nameserver //') -echo "proxying to $host_ip" -cp $dir/proxychains.template.conf $config -sed -i "\$s/.*/http $host_ip 7890/" $config diff --git a/scripts/proxychains.template.conf b/scripts/proxychains.template.conf deleted file mode 100644 index e78b96a68..000000000 --- a/scripts/proxychains.template.conf +++ /dev/null @@ -1,12 +0,0 @@ -strict_chain -proxy_dns - -remote_dns_subnet 224 - -tcp_read_time_out 15000 -tcp_connect_time_out 8000 - -localnet 127.0.0.0/255.0.0.0 - -[ProxyList] -socks4 127.0.0.1 9050 diff --git a/scripts/setup.sh b/scripts/setup.sh deleted file mode 100644 index 50488f963..000000000 --- a/scripts/setup.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash - -# Check if running on a supported system -case "$(uname -s)" in - Linux) - if [[ -f "/etc/lsb-release" ]]; then - . /etc/lsb-release - if [[ "$DISTRIB_ID" != "Ubuntu" ]]; then - echo "This script only works on Ubuntu, not $DISTRIB_ID." - exit 1 - fi - else - if [[ !"$(cat /etc/*-release | grep '^ID=')" =~ ^(ID=\"ubuntu\")|(ID=\"centos\")|(ID=\"arch\")|(ID=\"debian\")$ ]]; then - echo "Unsupported Linux distribution." - exit 1 - fi - fi - ;; - Darwin) - echo "Running on MacOS." - ;; - *) - echo "Unsupported operating system." - exit 1 - ;; -esac - -# Check if needed dependencies are installed and install if necessary -if ! command -v node >/dev/null || ! command -v git >/dev/null || ! command -v yarn >/dev/null; then - case "$(uname -s)" in - Linux) - if [[ "$(cat /etc/*-release | grep '^ID=')" = "ID=ubuntu" ]]; then - sudo apt-get update - sudo apt-get -y install nodejs git yarn - elif [[ "$(cat /etc/*-release | grep '^ID=')" = "ID=debian" ]]; then - sudo apt-get update - sudo apt-get -y install nodejs git yarn - elif [[ "$(cat /etc/*-release | grep '^ID=')" = "ID=centos" ]]; then - sudo yum -y install epel-release - sudo yum -y install nodejs git yarn - elif [[ "$(cat /etc/*-release | grep '^ID=')" = "ID=arch" ]]; then - sudo pacman -Syu -y - sudo pacman -S -y nodejs git yarn - else - echo "Unsupported Linux distribution" - exit 1 - fi - ;; - Darwin) - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - brew install node git yarn - ;; - esac -fi - -# Clone the repository and install dependencies -git clone https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web -cd ChatGPT-Next-Web -yarn install - -# Prompt user for environment variables -read -p "Enter OPENAI_API_KEY: " OPENAI_API_KEY -read -p "Enter CODE: " CODE -read -p "Enter PORT: " PORT - -# Build and run the project using the environment variables -OPENAI_API_KEY=$OPENAI_API_KEY CODE=$CODE PORT=$PORT yarn build -OPENAI_API_KEY=$OPENAI_API_KEY CODE=$CODE PORT=$PORT yarn start