refactor: configure preview status with runtime config

zio/stable
Daniel Roe 2022-12-06 21:09:47 +00:00
parent 83d313c47b
commit 08d629ea78
No known key found for this signature in database
GPG Key ID: 22D5008E4F5D9B55
4 changed files with 8 additions and 8 deletions

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
const sub = process.dev ? 'dev' : window.location.hostname.includes('deploy-preview') ? 'preview' : 'alpha' const sub = process.dev ? 'dev' : useRuntimeConfig().public.env === 'staging' ? 'preview' : 'alpha'
</script> </script>
<template> <template>

View File

@ -1,9 +1,9 @@
import { APP_NAME, STORAGE_KEY_LANG } from '~/constants' import { APP_NAME, STORAGE_KEY_LANG } from '~/constants'
const isDev = process.dev
const isPreview = window.location.hostname.includes('deploy-preview')
export function setupPageHeader() { export function setupPageHeader() {
const isDev = process.dev
const isPreview = useRuntimeConfig().public.env === 'staging'
const i18n = useI18n() const i18n = useI18n()
useHeadFixed({ useHeadFixed({

View File

@ -48,7 +48,6 @@ export default defineNuxtConfig({
}, },
}, },
runtimeConfig: { runtimeConfig: {
env: isCI ? 'deployed' : 'local',
deployUrl: !isCI deployUrl: !isCI
? 'http://localhost:5314' ? 'http://localhost:5314'
: process.env.PULL_REQUEST === 'true' : process.env.PULL_REQUEST === 'true'
@ -60,6 +59,7 @@ export default defineNuxtConfig({
apiToken: '', apiToken: '',
}, },
public: { public: {
env: isCI ? process.env.PULL_REQUEST === 'true' ? 'production' : 'staging' : 'local',
translateApi: '', translateApi: '',
// Masto uses Mastodon version checks to see what features are enabled. // Masto uses Mastodon version checks to see what features are enabled.
// Mastodon alternatives like GoToSocial will always fail these checks, so // Mastodon alternatives like GoToSocial will always fail these checks, so
@ -67,7 +67,7 @@ export default defineNuxtConfig({
disableVersionCheck: false, disableVersionCheck: false,
}, },
storage: { storage: {
driver: 'cloudflare', driver: isCI ? 'cloudflare' : 'fs',
fsBase: 'node_modules/.cache/servers', fsBase: 'node_modules/.cache/servers',
}, },
}, },

View File

@ -21,7 +21,7 @@ const kv = _kv as typeof import('unstorage/dist/drivers/cloudflare-kv-http')['de
const storage = useStorage() as Storage const storage = useStorage() as Storage
if (config.env === 'local' || config.storage.driver === 'fs') { if (config.storage.driver === 'fs') {
storage.mount('servers', fs({ base: config.storage.fsBase })) storage.mount('servers', fs({ base: config.storage.fsBase }))
} }
else { else {
@ -40,7 +40,7 @@ async function fetchAppInfo(server: string) {
const app: AppInfo = await $fetch(`https://${server}/api/v1/apps`, { const app: AppInfo = await $fetch(`https://${server}/api/v1/apps`, {
method: 'POST', method: 'POST',
body: { body: {
client_name: APP_NAME + (config.env === 'local' ? ' (dev)' : ''), client_name: APP_NAME + (config.public.env === 'local' ? ' (dev)' : ''),
website: 'https://elk.zone', website: 'https://elk.zone',
redirect_uris: getRedirectURI(server), redirect_uris: getRedirectURI(server),
scopes: 'read write follow push', scopes: 'read write follow push',