Skip to content

Commit 4e10fd5

Browse files
authored
chore: add dev staging env configuration and package scripts (#665)
1 parent 5cb8d88 commit 4e10fd5

9 files changed

Lines changed: 37 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ build/
1515
# misc
1616
.DS_Store
1717
.env.local
18+
.env.*.local
1819
.env.development.local
1920
.env.test.local
2021
.env.production.local

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"clean:modules:trash": "find . -name \"node_modules\" -type d -prune -exec trash {} +",
1212
"regen": "rm -rf pnpm-lock.yaml && pnpm clean:modules && corepack use pnpm@latest",
1313
"dev": "pnpm --filter widget-playground-vite dev",
14+
"dev:dev": "pnpm --filter widget-playground-vite dev:dev",
15+
"dev:staging": "pnpm --filter widget-playground-vite dev:staging",
1416
"dev:next": "pnpm --filter widget-playground-next dev",
1517
"release": "pnpm release:version && pnpm release:build && pnpm standard-version -a -s",
1618
"release:alpha": "pnpm release:version --preid alpha && pnpm release:build && pnpm standard-version -a -s --prerelease alpha --skip.changelog",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
VITE_EVM_WALLET_CONNECT=5432e3507d41270bee46b7b85bbc2ef8
2+
VITE_API_URL=https://li.quest/v1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
VITE_API_URL=https://develop.li.quest/v1
2+
# Set VITE_API_KEY in .env.dev.local (git-ignored)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
VITE_API_URL=https://staging.li.quest/v1
2+
# Set VITE_API_KEY in .env.staging.local (git-ignored)

packages/widget-playground-vite/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"scripts": {
66
"analyze": "source-map-explorer 'dist/assets/*.js' --no-border-checks",
77
"dev": "vite",
8+
"dev:dev": "vite --mode dev",
9+
"dev:staging": "vite --mode staging",
810
"build": "tsc && vite build",
911
"clean": "rm -rf dist tsconfig.tsbuildinfo",
1012
"preview": "vite preview",

packages/widget-playground-vite/src/App.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,14 @@ if (!import.meta.env.VITE_EVM_WALLET_CONNECT) {
4848
'VITE_EVM_WALLET_CONNECT is require in your .env.local file for external wallet management'
4949
)
5050
}
51+
52+
if (
53+
import.meta.env.MODE !== 'development' &&
54+
import.meta.env.MODE !== 'production' &&
55+
!import.meta.env.VITE_API_KEY
56+
) {
57+
throw new Error(
58+
`VITE_API_KEY is required when running in "${import.meta.env.MODE}" mode. ` +
59+
`Please set it in your .env.${import.meta.env.MODE}.local file.`
60+
)
61+
}

packages/widget-playground/src/defaultWidgetConfig.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export const widgetBaseConfig: WidgetConfig = {
5353
// },
5454
// },
5555
integrator: 'li.fi-playground',
56+
...(import.meta.env.VITE_API_KEY && {
57+
apiKey: import.meta.env.VITE_API_KEY,
58+
}),
5659
// fee: 0.01,
5760
// feeConfig: {
5861
// name: 'DApp fee',
@@ -74,7 +77,7 @@ export const widgetBaseConfig: WidgetConfig = {
7477
// usePartialWalletManagement: true,
7578
// },
7679
sdkConfig: {
77-
apiUrl: 'https://li.quest/v1',
80+
apiUrl: import.meta.env.VITE_API_URL || 'https://li.quest/v1',
7881
preloadChains: false,
7982
rpcUrls: {
8083
[ChainId.SOL]: [
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
declare global {
2+
interface ImportMetaEnv {
3+
readonly VITE_API_URL?: string
4+
readonly VITE_API_KEY?: string
5+
}
6+
7+
interface ImportMeta {
8+
readonly env: ImportMetaEnv
9+
}
10+
}
11+
12+
export {}

0 commit comments

Comments
 (0)