feat(stage-pocket,stage-web,stage-shared): add isEnvTruthy for safer env var checks
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
"@proj-airi/pipelines-audio": "workspace:^",
|
||||
"@proj-airi/server-sdk": "workspace:^",
|
||||
"@proj-airi/stage-layouts": "workspace:^",
|
||||
"@proj-airi/stage-shared": "workspace:^",
|
||||
"@proj-airi/stage-ui": "workspace:^",
|
||||
"@proj-airi/stage-ui-three": "workspace:^",
|
||||
"@proj-airi/stage-ui-three-performance-runtime": "workspace:^",
|
||||
|
||||
@@ -5,6 +5,7 @@ import Tres from '@tresjs/core'
|
||||
import NProgress from 'nprogress'
|
||||
|
||||
import { autoAnimatePlugin } from '@formkit/auto-animate/vue'
|
||||
import { isEnvTruthy } from '@proj-airi/stage-shared'
|
||||
import { MotionPlugin } from '@vueuse/motion'
|
||||
import { createPinia } from 'pinia'
|
||||
import { setupLayouts } from 'virtual:generated-layouts'
|
||||
@@ -17,8 +18,6 @@ import App from './App.vue'
|
||||
import { i18n } from './modules/i18n'
|
||||
|
||||
import './modules/posthog'
|
||||
|
||||
// eslint-disable-next-line perfectionist/sort-imports
|
||||
import '@proj-airi/font-cjkfonts-allseto/index.css'
|
||||
import '@proj-airi/font-xiaolai/index.css'
|
||||
import '@unocss/reset/tailwind.css'
|
||||
@@ -33,7 +32,7 @@ const pinia = createPinia()
|
||||
const routeRecords = setupLayouts(routes as RouteRecordRaw[])
|
||||
|
||||
let router: Router
|
||||
if (import.meta.env.VITE_APP_TARGET_HUGGINGFACE_SPACE)
|
||||
if (isEnvTruthy(import.meta.env.VITE_APP_TARGET_HUGGINGFACE_SPACE))
|
||||
router = createRouter({ routes: routeRecords, history: createWebHashHistory() })
|
||||
else
|
||||
router = createRouter({ routes: routeRecords, history: createWebHistory() })
|
||||
|
||||
@@ -18,6 +18,7 @@ import VueDevTools from 'vite-plugin-vue-devtools'
|
||||
import Layouts from 'vite-plugin-vue-layouts'
|
||||
import VueMacros from 'vue-macros/vite'
|
||||
|
||||
import { isEnvTruthy } from '@proj-airi/stage-shared'
|
||||
import { Download } from '@proj-airi/unplugin-fetch/vite'
|
||||
import { DownloadLive2DSDK } from '@proj-airi/unplugin-live2d-sdk/vite'
|
||||
import { templateCompilerOptions } from '@tresjs/core'
|
||||
@@ -88,7 +89,7 @@ export default defineConfig({
|
||||
},
|
||||
|
||||
plugins: [
|
||||
.../^1|true|yes$/i.test(process.env.VITE_SKIP_MKCERT ?? '') ? [] : [mkcert()],
|
||||
...isEnvTruthy(process.env.VITE_SKIP_MKCERT ?? '') ? [] : [mkcert()],
|
||||
|
||||
Info(),
|
||||
|
||||
@@ -145,7 +146,7 @@ export default defineConfig({
|
||||
Download('https://dist.ayaka.moe/vrm-models/VRoid-Hub/AvatarSample-A/AvatarSample_A.vrm', 'AvatarSample_A.vrm', 'vrm/models/AvatarSample-A', { parentDir: stageUIAssetsRoot, cacheDir: sharedCacheDir }),
|
||||
Download('https://dist.ayaka.moe/vrm-models/VRoid-Hub/AvatarSample-B/AvatarSample_B.vrm', 'AvatarSample_B.vrm', 'vrm/models/AvatarSample-B', { parentDir: stageUIAssetsRoot, cacheDir: sharedCacheDir }),
|
||||
|
||||
.../^1|true|yes$/i.test(process.env.VITE_CAP_SYNC_IOS_AFTER_BUILD ?? '')
|
||||
...isEnvTruthy(process.env.VITE_CAP_SYNC_IOS_AFTER_BUILD ?? '')
|
||||
? [{
|
||||
name: 'proj-airi:capacitor-sync',
|
||||
closeBundle: {
|
||||
|
||||
@@ -5,6 +5,7 @@ import Tres from '@tresjs/core'
|
||||
import NProgress from 'nprogress'
|
||||
|
||||
import { autoAnimatePlugin } from '@formkit/auto-animate/vue'
|
||||
import { isEnvTruthy } from '@proj-airi/stage-shared'
|
||||
import { MotionPlugin } from '@vueuse/motion'
|
||||
import { createPinia } from 'pinia'
|
||||
import { setupLayouts } from 'virtual:generated-layouts'
|
||||
@@ -17,8 +18,6 @@ import App from './App.vue'
|
||||
import { i18n } from './modules/i18n'
|
||||
|
||||
import './modules/posthog'
|
||||
|
||||
// eslint-disable-next-line perfectionist/sort-imports
|
||||
import '@proj-airi/font-cjkfonts-allseto/index.css'
|
||||
import '@proj-airi/font-xiaolai/index.css'
|
||||
import '@unocss/reset/tailwind.css'
|
||||
@@ -33,7 +32,7 @@ const pinia = createPinia()
|
||||
const routeRecords = setupLayouts(routes as RouteRecordRaw[])
|
||||
|
||||
let router: Router
|
||||
if (import.meta.env.VITE_APP_TARGET_HUGGINGFACE_SPACE)
|
||||
if (isEnvTruthy(import.meta.env.VITE_APP_TARGET_HUGGINGFACE_SPACE))
|
||||
router = createRouter({ routes: routeRecords, history: createWebHashHistory() })
|
||||
else
|
||||
router = createRouter({ routes: routeRecords, history: createWebHistory() })
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { isEnvTruthy } from '@proj-airi/stage-shared'
|
||||
import { ToasterPWAUpdateReady } from '@proj-airi/stage-ui/components'
|
||||
import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
|
||||
import { nanoid } from 'nanoid'
|
||||
@@ -14,7 +15,7 @@ export const usePWAStore = defineStore('pwa', () => {
|
||||
if (import.meta.env.SSR) {
|
||||
return
|
||||
}
|
||||
if (import.meta.env.VITE_APP_TARGET_HUGGINGFACE_SPACE) {
|
||||
if (isEnvTruthy(import.meta.env.VITE_APP_TARGET_HUGGINGFACE_SPACE)) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Returns true if the provided environment variable represents a truthy value.
|
||||
*
|
||||
* Truthy values: `true`, `t`, `yes`, `y`, `on`, `1`
|
||||
*/
|
||||
export function isEnvTruthy(value: string | undefined | null): boolean {
|
||||
if (value == null)
|
||||
return false
|
||||
return /^(?:1|true|t|yes|y|on)$/i.test(value.trim())
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './env-vars'
|
||||
export * from './environment'
|
||||
export * from './export-csv'
|
||||
export * from './perf/tracer'
|
||||
|
||||
Generated
+3
@@ -568,6 +568,9 @@ importers:
|
||||
'@proj-airi/stage-layouts':
|
||||
specifier: workspace:^
|
||||
version: link:../../packages/stage-layouts
|
||||
'@proj-airi/stage-shared':
|
||||
specifier: workspace:^
|
||||
version: link:../../packages/stage-shared
|
||||
'@proj-airi/stage-ui':
|
||||
specifier: workspace:^
|
||||
version: link:../../packages/stage-ui
|
||||
|
||||
Reference in New Issue
Block a user