Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Custom dev ui port(load env from .env) #2702

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"bootstrap": "npx cross-env lerna bootstrap && lerna link",
"start:ui": "cd packages/neuron-ui && yarn run start",
"start:wallet": "cd packages/neuron-wallet && yarn run start:debug",
"start": "concurrently \"cross-env BROWSER=none yarn run start:ui\" \"wait-on http://127.0.0.1:3000 && yarn run start:wallet\"",
"start": "zx scripts/start.mjs",
"clean": "lerna run --stream clean",
"prebuild": "yarn clean",
"build": "lerna run --stream build",
Expand Down Expand Up @@ -56,7 +56,8 @@
"prettier": "2.8.7",
"ts-jest": "27.1.5",
"typescript": "5.0.4",
"wait-on": "6.0.1"
"wait-on": "6.0.1",
"zx": "^7.2.2"
Keith-CY marked this conversation as resolved.
Show resolved Hide resolved
},
"dependencies": {},
"resolutions": {
Expand Down
3 changes: 2 additions & 1 deletion packages/neuron-wallet/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ const fileBase = (() => {
return 'dev/'
})()

const port = process.env.PORT || 3000
const env = {
app,
isDevMode,
isTestMode,
fileBasePath: path.resolve(app.getPath('userData'), fileBase),
mainURL: isDevMode ? 'http://localhost:3000' : `file://${path.join(__dirname, '../dist/neuron-ui/index.html')}`,
mainURL: isDevMode ? `http://localhost:${port}` : `file://${path.join(__dirname, '../dist/neuron-ui/index.html')}`,
}

export default env
10 changes: 10 additions & 0 deletions scripts/start.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env zx

import dotenv from 'dotenv'
import path from 'path'
dotenv.config({ path: path.join(__dirname, '..', 'packages', 'neuron-wallet', '.env.development.local')})
FrankFang marked this conversation as resolved.
Show resolved Hide resolved
await Promise.all([
$`cross-env BROWSER=none PORT=${process.env.PORT} yarn run start:ui`,
$`wait-on http://127.0.0.1:${process.env.PORT} && yarn run start:wallet`
])
console.log('bye')
Loading