From b2a48861e7689a0daa476d40f21cf9656764e5cc Mon Sep 17 00:00:00 2001 From: niku <nvdpoel01@gmail.com> Date: Sat, 10 Jun 2023 19:54:00 +0200 Subject: [PATCH] Never dealing with this again --- .env.sample | 3 +++ .gitignore | 3 +++ babel.config.js | 25 ++++++++++++++++--------- components/login/index.tsx | 11 ++++++++--- package.json | 3 ++- yarn.lock | 12 ++++++++++++ 6 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..e5a33ba --- /dev/null +++ b/.env.sample @@ -0,0 +1,3 @@ +DEFAUL_PVE_URL= +DEFAUL_PVE_USER= +DEFAUL_PVE_PASSWORD= diff --git a/.gitignore b/.gitignore index ec8a36a..e003792 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ web-build/ # macOS .DS_Store + +# secrets +.env diff --git a/babel.config.js b/babel.config.js index 355556e..2917f44 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,11 +1,18 @@ module.exports = function (api) { - api.cache(true); - return { - presets: ["babel-preset-expo"], - plugins: [ - "@babel/plugin-proposal-export-namespace-from", - "react-native-reanimated/plugin", - require.resolve("expo-router/babel"), - ], - }; + api.cache(true); + return { + presets: ["babel-preset-expo"], + plugins: [ + "@babel/plugin-proposal-export-namespace-from", + "react-native-reanimated/plugin", + require.resolve("expo-router/babel"), + [ + "module:react-native-dotenv", + { + moduleName: "react-native-dotenv", + verbose: false, + }, + ], + ], + }; }; diff --git a/components/login/index.tsx b/components/login/index.tsx index 40a0702..60f3439 100644 --- a/components/login/index.tsx +++ b/components/login/index.tsx @@ -10,6 +10,11 @@ import React, { useState } from "react"; import tw from "twrnc"; import useAuthStore from "../../stores/useAuthStore"; import { useTicketMut } from "../../hooks/useTicket"; +import { + DEFAUL_PVE_URL, + DEFAUL_PVE_USER, + DEFAUL_PVE_PASSWORD, +} from "react-native-dotenv"; interface FormFieldProps extends TextInputProps { label: string; @@ -41,9 +46,9 @@ export function FormField({ } export default function Login() { - const [domain, setDomain] = useState("https://pve.holowaif.us:8006"); - const [username, setUsername] = useState("root@pam"); - const [password, setPassword] = useState("7eji5TXjVpme2ZPd6zMUwmrPkg2gQFJc"); + const [domain, setDomain] = useState(DEFAUL_PVE_URL ?? ""); + const [username, setUsername] = useState(DEFAUL_PVE_USER ?? ""); + const [password, setPassword] = useState(DEFAUL_PVE_PASSWORD ?? ""); const authStore = useAuthStore(); const ticketMut = useTicketMut({ diff --git a/package.json b/package.json index a98d337..1464303 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "devDependencies": { "@babel/core": "^7.19.3", "@babel/plugin-proposal-export-namespace-from": "^7.18.9", + "react-native-dotenv": "^3.4.8", "rome": "^11.0.0" }, "resolutions": { @@ -50,4 +51,4 @@ "name": "pvern", "version": "1.0.0", "private": true -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 8e17083..5ecb13a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3212,6 +3212,11 @@ dlv@^1.1.3: resolved "https://registry.yarnpkg.com/dlv/-/dlv-1.1.3.tgz#5c198a8a11453596e751494d49874bc7732f2e79" integrity sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA== +dotenv@^16.0.3: + version "16.1.4" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.1.4.tgz#67ac1a10cd9c25f5ba604e4e08bc77c0ebe0ca8c" + integrity sha512-m55RtE8AsPeJBpOIFKihEmqUcoVncQIwo7x9U8ZwLEZw9ZpXboz2c+rvog+jUaJvVrZ5kBOeYQBX5+8Aa/OZQw== + ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -6122,6 +6127,13 @@ react-native-codegen@^0.71.5: jscodeshift "^0.13.1" nullthrows "^1.1.1" +react-native-dotenv@^3.4.8: + version "3.4.8" + resolved "https://registry.yarnpkg.com/react-native-dotenv/-/react-native-dotenv-3.4.8.tgz#42284070a9994076cd700805c2dd28051c9e1432" + integrity sha512-fg9F8X/cG1kDTwRLgLz3t+AMbsULoFHbUVltdQarmrJ3kNllD1Zq7ZgY85bp8BnPwk0DnYQzKbooiLsUoKd10w== + dependencies: + dotenv "^16.0.3" + react-native-gesture-handler@~2.9.0: version "2.9.0" resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.9.0.tgz#2f63812e523c646f25b9ad660fc6f75948e51241"