chore: Remove CurseForge API key from env variables and put it in the constants file

This commit is contained in:
LynithDev 2024-11-28 16:25:46 +01:00
parent cbc7ae8465
commit fc834bbb74
9 changed files with 3 additions and 240 deletions

View file

@ -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__

View file

@ -1,3 +0,0 @@
#! Use single quotes due to special characters and dotenvy being weird
CURSEFORGE_API_KEY = ''

View file

@ -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"
]
}

View file

@ -1,10 +0,0 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": ["vite.config.ts"]
}

View file

@ -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), <alpha-value>)',
black: 'rgba(var(--clr-black), <alpha-value>)',
border: 'rgba(var(--clr-border), <alpha-value>)',
fg: {
primary: {
DEFAULT: 'rgba(var(--clr-fg-primary), <alpha-value>)',
hover: 'rgba(var(--clr-fg-primary-hover), <alpha-value>)',
pressed: 'rgba(var(--clr-fg-primary-pressed), <alpha-value>)',
disabled: 'rgba(var(--clr-fg-primary-disabled))',
},
secondary: {
DEFAULT: 'rgba(var(--clr-fg-secondary), <alpha-value>)',
hover: 'rgba(var(--clr-fg-secondary-hover), <alpha-value>)',
pressed: 'rgba(var(--clr-fg-secondary-pressed), <alpha-value>)',
disabled: 'rgba(var(--clr-fg-secondary-disabled))',
},
},
brand: {
DEFAULT: 'rgba(var(--clr-brand), <alpha-value>)',
hover: 'rgba(var(--clr-brand-hover), <alpha-value>)',
pressed: 'rgba(var(--clr-brand-pressed), <alpha-value>)',
disabled: 'rgba(var(--clr-brand-disabled))',
},
onbrand: {
DEFAULT: 'rgba(var(--clr-onbrand), <alpha-value>)',
hover: 'rgba(var(--clr-onbrand-hover), <alpha-value>)',
pressed: 'rgba(var(--clr-onbrand-pressed), <alpha-value>)',
disabled: 'rgba(var(--clr-onbrand-disabled))',
},
danger: {
DEFAULT: 'rgba(var(--clr-danger), <alpha-value>)',
hover: 'rgba(var(--clr-danger-hover), <alpha-value>)',
pressed: 'rgba(var(--clr-danger-pressed), <alpha-value>)',
disabled: 'rgba(var(--clr-danger-disabled))',
},
success: {
DEFAULT: 'rgba(var(--clr-success), <alpha-value>)',
hover: 'rgba(var(--clr-success-hover), <alpha-value>)',
pressed: 'rgba(var(--clr-success-pressed), <alpha-value>)',
disabled: 'rgba(var(--clr-success-disabled))',
},
component: {
bg: {
DEFAULT: 'rgba(var(--clr-component-bg), <alpha-value>)',
hover: 'rgba(var(--clr-component-bg-hover), <alpha-value>)',
pressed: 'rgba(var(--clr-component-bg-pressed), <alpha-value>)',
disabled: 'rgba(var(--clr-component-bg-disabled))',
},
},
code: {
info: 'rgba(var(--clr-code-info), <alpha-value>)',
warn: 'rgba(var(--clr-code-warn), <alpha-value>)',
error: 'rgba(var(--clr-code-error), <alpha-value>)',
debug: 'rgba(var(--clr-code-debug), <alpha-value>)',
trace: 'rgba(var(--clr-code-trace), <alpha-value>)',
},
link: {
DEFAULT: 'rgba(var(--clr-link), <alpha-value>)',
hover: 'rgba(var(--clr-link-hover), <alpha-value>)',
pressed: 'rgba(var(--clr-link-pressed), <alpha-value>)',
disabled: 'rgba(var(--clr-link-disabled))',
},
page: {
DEFAULT: 'rgba(var(--clr-page), <alpha-value>)',
elevated: 'rgba(var(--clr-page-elevated), <alpha-value>)',
pressed: 'rgba(var(--clr-page-pressed), <alpha-value>)',
},
secondary: 'rgba(var(--clr-secondary), <alpha-value>)',
},
extend: {
height: {
15: '60px',
},
strokeWidth: {
3: '3',
},
backgroundColor: {
transparent: 'transparent',
},
},
},
});

View file

@ -1,3 +0,0 @@
import shared from '../../shared.config';
export default shared`frontend`.vitest;

View file

@ -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<u8> = 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}");
}
}

View file

@ -450,8 +450,7 @@ pub async fn fetch_advanced<F: FnOnce(&mut Url)>(
json_body: Option<serde_json::Value>,
) -> Result<Bytes> {
// 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);

View file

@ -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.