From 494804fc1c03a6bf51ed7be4b81437a38e5fc39c Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sun, 27 Nov 2022 18:39:40 +0000 Subject: [PATCH] fix: move `std-env` out of app runtime --- nuxt.config.ts | 2 ++ server/shared.ts | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index ea3b0ace..af7efcf4 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,4 +1,5 @@ import Inspect from 'vite-plugin-inspect' +import { isCI } from 'std-env' export default defineNuxtConfig({ ssr: false, @@ -43,6 +44,7 @@ export default defineNuxtConfig({ }, }, runtimeConfig: { + env: isCI ? 'deployed' : 'local', deployUrl: process.env.PULL_REQUEST === 'true' ? process.env.DEPLOY_PRIME_URL : '', cloudflare: { accountId: '', diff --git a/server/shared.ts b/server/shared.ts index 6258b219..5eb997cf 100644 --- a/server/shared.ts +++ b/server/shared.ts @@ -2,7 +2,6 @@ import _fs from 'unstorage/drivers/fs' // @ts-expect-error unstorage needs to provide backwards-compatible subpath types import _kv from 'unstorage/drivers/cloudflare-kv-http' -import { isCI } from 'std-env' import { parseURL } from 'ufo' import { $fetch } from 'ohmyfetch' @@ -13,9 +12,9 @@ import cached from './cache-driver' import type { AppInfo } from '~/types' import { APP_NAME } from '~/constants' -const runtimeConfig = useRuntimeConfig() -export const HOST_URL = runtimeConfig.deployUrl - || (process.dev || !isCI ? 'http://localhost:5314' : 'https://elk.zone') +const config = useRuntimeConfig() +export const HOST_URL = config.deployUrl + || (config.env === 'local' ? 'http://localhost:5314' : 'https://elk.zone') export const HOST_DOMAIN = parseURL(HOST_URL).host! const fs = _fs as typeof import('unstorage/dist/drivers/fs')['default'] @@ -23,7 +22,7 @@ const kv = _kv as typeof import('unstorage/dist/drivers/cloudflare-kv-http')['de const storage = useStorage() as Storage -if (process.dev || !isCI) { +if (config.env === 'local') { storage.mount('servers', fs({ base: 'node_modules/.cache/servers' })) } else {