From fc834bbb7414baff97899145c023cb3e7d55a05d Mon Sep 17 00:00:00 2001 From: LynithDev <61880709+LynithDev@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:25:46 +0100 Subject: [PATCH] chore: Remove CurseForge API key from env variables and put it in the constants file --- .github/workflows/release.yml | 1 - .template.env | 3 - apps/frontend/tsconfig.json | 40 ----- apps/frontend/tsconfig.node.json | 10 -- apps/frontend/uno.config.ts | 139 ------------------ apps/frontend/vitest.config.ts | 3 - packages/core/build.rs | 40 ----- .../src/api/package/content/curseforge.rs | 3 +- packages/core/src/constants.rs | 4 +- 9 files changed, 3 insertions(+), 240 deletions(-) delete mode 100644 .template.env delete mode 100644 apps/frontend/tsconfig.json delete mode 100644 apps/frontend/tsconfig.node.json delete mode 100644 apps/frontend/uno.config.ts delete mode 100644 apps/frontend/vitest.config.ts delete mode 100644 packages/core/build.rs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9108d678..ab90fbc8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,6 @@ jobs: - uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} with: tagName: onelauncher-__VERSION__ releaseName: OneLauncher __VERSION__ diff --git a/.template.env b/.template.env deleted file mode 100644 index 434d6c54..00000000 --- a/.template.env +++ /dev/null @@ -1,3 +0,0 @@ -#! Use single quotes due to special characters and dotenvy being weird - -CURSEFORGE_API_KEY = '' diff --git a/apps/frontend/tsconfig.json b/apps/frontend/tsconfig.json deleted file mode 100644 index 6fe2122e..00000000 --- a/apps/frontend/tsconfig.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "target": "ESNext", - "jsx": "preserve", - "jsxImportSource": "solid-js", - "lib": ["ESNext", "DOM", "DOM.Iterable"], - "useDefineForClassFields": true, - "rootDir": ".", - "module": "ESNext", - "moduleResolution": "Bundler", - "paths": { - "~*": ["./src/*"] - }, - - "resolveJsonModule": true, - "types": [ - "vitest/globals", - "@testing-library/jest-dom", - "vite-plugin-solid-svg/types" - ], - "allowImportingTsExtensions": true, - "strict": true, - "noFallthroughCasesInSwitch": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noEmit": true, - "sourceMap": false, - "esModuleInterop": true, - "isolatedModules": true, - "verbatimModuleSyntax": true, - "skipLibCheck": true - }, - "references": [{ "path": "./tsconfig.node.json" }], - "include": [ - "./src/**/*.ts", - "./src/**/*.d.ts", - "./src/**/*.tsx" - ] -} diff --git a/apps/frontend/tsconfig.node.json b/apps/frontend/tsconfig.node.json deleted file mode 100644 index 4a2ccc4f..00000000 --- a/apps/frontend/tsconfig.node.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true, - "skipLibCheck": true - }, - "include": ["vite.config.ts"] -} diff --git a/apps/frontend/uno.config.ts b/apps/frontend/uno.config.ts deleted file mode 100644 index fd7a9442..00000000 --- a/apps/frontend/uno.config.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { - defineConfig, - presetAttributify, - presetIcons, - presetUno, - transformerDirectives, - transformerVariantGroup, -} from 'unocss'; - -export default defineConfig({ - rules: [], - shortcuts: {}, - presets: [ - presetUno(), - presetIcons(), - ], - transformers: [ - transformerVariantGroup(), - transformerDirectives(), - ], - theme: { - fontFamily: { - sans: 'Poppins', - }, - - borderRadius: { - md: '0.438rem', // 7px - }, - - fontSize: { - // Based off 16px - 'xs': '0.688rem', - 'sm': '0.75rem', - 'md': '0.875rem', - 'lg': '1rem', - '2lg': '1.125rem', - 'xl': '1.25rem', - 'xxl': '1.5rem', - '2xl': '2rem', - '3xl': '2.5rem', - '4xl': '3rem', - }, - - colors: { - white: 'rgba(var(--clr-white), )', - black: 'rgba(var(--clr-black), )', - - border: 'rgba(var(--clr-border), )', - - fg: { - primary: { - DEFAULT: 'rgba(var(--clr-fg-primary), )', - hover: 'rgba(var(--clr-fg-primary-hover), )', - pressed: 'rgba(var(--clr-fg-primary-pressed), )', - disabled: 'rgba(var(--clr-fg-primary-disabled))', - }, - secondary: { - DEFAULT: 'rgba(var(--clr-fg-secondary), )', - hover: 'rgba(var(--clr-fg-secondary-hover), )', - pressed: 'rgba(var(--clr-fg-secondary-pressed), )', - disabled: 'rgba(var(--clr-fg-secondary-disabled))', - }, - }, - - brand: { - DEFAULT: 'rgba(var(--clr-brand), )', - hover: 'rgba(var(--clr-brand-hover), )', - pressed: 'rgba(var(--clr-brand-pressed), )', - disabled: 'rgba(var(--clr-brand-disabled))', - }, - - onbrand: { - DEFAULT: 'rgba(var(--clr-onbrand), )', - hover: 'rgba(var(--clr-onbrand-hover), )', - pressed: 'rgba(var(--clr-onbrand-pressed), )', - disabled: 'rgba(var(--clr-onbrand-disabled))', - }, - - danger: { - DEFAULT: 'rgba(var(--clr-danger), )', - hover: 'rgba(var(--clr-danger-hover), )', - pressed: 'rgba(var(--clr-danger-pressed), )', - disabled: 'rgba(var(--clr-danger-disabled))', - }, - - success: { - DEFAULT: 'rgba(var(--clr-success), )', - hover: 'rgba(var(--clr-success-hover), )', - pressed: 'rgba(var(--clr-success-pressed), )', - disabled: 'rgba(var(--clr-success-disabled))', - }, - - component: { - bg: { - DEFAULT: 'rgba(var(--clr-component-bg), )', - hover: 'rgba(var(--clr-component-bg-hover), )', - pressed: 'rgba(var(--clr-component-bg-pressed), )', - disabled: 'rgba(var(--clr-component-bg-disabled))', - }, - }, - - code: { - info: 'rgba(var(--clr-code-info), )', - warn: 'rgba(var(--clr-code-warn), )', - error: 'rgba(var(--clr-code-error), )', - debug: 'rgba(var(--clr-code-debug), )', - trace: 'rgba(var(--clr-code-trace), )', - }, - - link: { - DEFAULT: 'rgba(var(--clr-link), )', - hover: 'rgba(var(--clr-link-hover), )', - pressed: 'rgba(var(--clr-link-pressed), )', - disabled: 'rgba(var(--clr-link-disabled))', - }, - - page: { - DEFAULT: 'rgba(var(--clr-page), )', - elevated: 'rgba(var(--clr-page-elevated), )', - pressed: 'rgba(var(--clr-page-pressed), )', - }, - - secondary: 'rgba(var(--clr-secondary), )', - }, - extend: { - height: { - 15: '60px', - }, - - strokeWidth: { - 3: '3', - }, - - backgroundColor: { - transparent: 'transparent', - }, - }, - }, -}); diff --git a/apps/frontend/vitest.config.ts b/apps/frontend/vitest.config.ts deleted file mode 100644 index ae577334..00000000 --- a/apps/frontend/vitest.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import shared from '../../shared.config'; - -export default shared`frontend`.vitest; diff --git a/packages/core/build.rs b/packages/core/build.rs deleted file mode 100644 index e7d1fb00..00000000 --- a/packages/core/build.rs +++ /dev/null @@ -1,40 +0,0 @@ -use std::path::PathBuf; - -fn main() { - let paths = vec![get_root_workspace().join(".env"), PathBuf::from(".env")]; - - for path in paths { - if path.exists() { - load_from_path(path); - } - } -} - -fn get_root_workspace() -> PathBuf { - let output: Vec = std::process::Command::new(env!("CARGO")) - .arg("locate-project") - .arg("--workspace") - .arg("--message-format=plain") - .output() - .unwrap() - .stdout; - - let root_workspace = String::from_utf8(output).unwrap(); - let mut root_workspace = PathBuf::from(root_workspace.trim()); - - if root_workspace.is_file() { - root_workspace.pop(); - } - - root_workspace -} - -fn load_from_path(path: PathBuf) { - let vars = dotenvy::EnvLoader::with_path(path) - .load() - .expect("failed to find .env file"); - - for (key, value) in vars { - println!("cargo:rustc-env={key}={value}"); - } -} diff --git a/packages/core/src/api/package/content/curseforge.rs b/packages/core/src/api/package/content/curseforge.rs index 1af63ffc..ceba5833 100644 --- a/packages/core/src/api/package/content/curseforge.rs +++ b/packages/core/src/api/package/content/curseforge.rs @@ -450,8 +450,7 @@ pub async fn fetch_advanced( json_body: Option, ) -> Result { // TODO: Get the API key from settings, fallback to constant, and error if missing - let key = crate::constants::CURSEFORGE_API_KEY - .ok_or(anyhow::anyhow!("missing curseforge api key"))?; + let key = crate::constants::CURSEFORGE_API_KEY; let mut headers = headers.unwrap_or(HashMap::<&str, &str>::new()); headers.insert("x-api-key", key); diff --git a/packages/core/src/constants.rs b/packages/core/src/constants.rs index f29e33b7..89cf5921 100644 --- a/packages/core/src/constants.rs +++ b/packages/core/src/constants.rs @@ -38,8 +38,8 @@ pub const MODRINTH_API_URL: &str = "https://api.modrinth.com/v2"; pub const MODRINTH_V3_API_URL: &str = "https://api.modrinth.com/v3"; /// The Curseforge API base url. pub const CURSEFORGE_API_URL: &str = "https://api.curseforge.com"; -/// The Curseforge API key. This is a secret and should not be shared. -pub const CURSEFORGE_API_KEY: Option<&'static str> = option_env!("CURSEFORGE_API_KEY"); +/// The Curseforge API key. Reserved for use in OneLauncher projects only. Do not use in other projects without permission from the OneLauncher team. +pub const CURSEFORGE_API_KEY: &str = "$2a$10$6utA1UNSmFPrE/Lh7b7ndeeGmiOkjKNY8kpFB0fsmE/d42ZAfFgCe"; /// The Minecraft game ID on Curseforge. pub const CURSEFORGE_GAME_ID: u32 = 432; /// Our metadata API base url.