Skip to content

Commit 43a9a3f

Browse files
authored
Merge pull request #8 from geekdada/dev
2 parents ad95f18 + f31bc32 commit 43a9a3f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3548
-1643
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest]
17-
node-version: [12]
17+
node-version: [14]
1818

1919
steps:
2020
- uses: actions/checkout@v1
@@ -40,7 +40,7 @@ jobs:
4040
4141
- name: test, report coverage
4242
run: |
43-
yarn test
43+
yarn verify-translation
4444
yarn test:coverage
4545
4646
- uses: codecov/codecov-action@v1

.github/workflows/release.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [ubuntu-latest]
14-
node-version: [12]
14+
node-version: [14]
1515

1616
steps:
1717
- uses: actions/checkout@v1
@@ -32,15 +32,9 @@ jobs:
3232
${{ runner.OS }}-
3333
3434
- name: yarn install, build, bundle
35-
env:
36-
REACT_APP_SHOW_AD: true
37-
REACT_APP_HASH_ROUTER: true
3835
run: |
3936
yarn install
40-
CI=false yarn build
41-
sed -i 's/"\/home"/"\/#home"/g' build/manifest.json
42-
sed -i 's/<script src=\"https:\/\/polyfill.alicdn.com\/modern\/polyfill.min.js\" crossorigin=\"anonymous\"><\/script>//g' build/index.html
43-
tar -czf build.tar.gz ./build
37+
CI=false yarn build:release
4438
4539
- name: Upload Release Asset
4640
id: upload-release-asset

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
# production
1414
/build
15+
/build.tar.gz
16+
/yasd.tar.gz
1517

1618
# misc
1719
.DS_Store

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12
1+
14

README.md

+9-19
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
</a>
55
</p>
66

7-
# Yet Another Surge Dashboard
8-
9-
> STILL IN ALPHA
7+
# Surge Web Dashboard (formerly YASD)
108

119
![Github Actions][github-actions-image]
1210
[![Test coverage][codecov-image]][codecov-url]
@@ -23,36 +21,28 @@
2321

2422
[中文](/README_zh-CN.md) | [English](/README.md)
2523

26-
## What is YASD?
24+
## What is Surge Web Dashboard?
25+
26+
We are happy to announce Surge Web Dashboard (formerly YASD) has joined Surge! This project will remain open-source and active.
2727

28-
Starts from Surge iOS 4.4.0 and Surge Mac 4.0.0, you may use [HTTP API](https://manual.nssurge.com/others/http-api.html) to control Surge. YASD provides a way to interact with Surge's HTTP API, enabling you to control Surge from another device or outside your house.
28+
Starting from Surge iOS 4.4.0 and Surge Mac 4.0.0, Surge added support for [HTTP API](https://manual.nssurge.com/others/http-api.html), which makes it possible to control Surge from a browser.
2929

30-
YASD isn't in its final shape, so please be patient if you find anything you aren't happy with 😎.
30+
You can use Surge Web Dashboard to control policies, inspect requests and more from another device!
3131

3232
## How-to
3333

34-
Right now, Surge doesn't support HTTPS API endpoints, so it's almost impossible to use HTTPS. If you find a way to proxy the HTTP API with HTTPS, you will be able to take advantages of many useful features such as the PWA.
34+
Surge has Surge Web Dashboard built in now, you can turn it on in advance settings (it may require a subscription to activate built-in Surge Web Dashboard).
3535

36-
We provide both HTTP and HTTPS website:
36+
We also provide standalone version, so you can manage all Surge instances at one place (it may require a subscription to activate HTTP API).
3737

3838
- [HTTP](http://yasd.nerdynerd.org)
3939
- [HTTPS](https://yasd.royli.dev)
4040

4141
You can also find the full bundle in [releases](https://github.com/geekdada/yasd/releases) and deploy yourself.
4242

43-
## Known issues
44-
45-
- Error handling isn't ideal, try reloading if anything snaps.
46-
- i18n hasn't been implemented yet (0%), my apology to those who can't read Chinese or English.
47-
4843
## Roadmap
4944

50-
- [x] Better PWA support
51-
- [ ] i18n
52-
- [x] Manage and inspect requests
53-
- [x] Write and debug scripts
54-
- [ ] Manage DHCP devices
55-
- [ ] Full unit and e2e tests
45+
See [Roadmap](https://github.com/geekdada/yasd/projects/1)
5646

5747
## License
5848

README_zh-CN.md

+34-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# YASD - Yet Another Surge Dashboard
1+
<p align="center">
2+
<a href="https://github.com/geekdada/yasd">
3+
<img width="300" src="public/github-banner.png" alt="logo">
4+
</a>
5+
</p>
26

3-
> STILL IN ALPHA
7+
# Surge Web Dashboard (前身为 YASD)
48

59
![Github Actions][github-actions-image]
610
[![Test coverage][codecov-image]][codecov-url]
@@ -17,4 +21,31 @@
1721

1822
[中文](/README_zh-CN.md) | [English](/README.md)
1923

20-
还未编撰
24+
## 什么是 Surge Web Dashboard?
25+
26+
我们很高兴地宣布 Surge Web Dashboard(前身为 YASD)已加入 Surge!这个项目将保持开源和活跃开发维护。
27+
28+
从 Surge i0S 4.4.0 和Surge Mac 4.0.0 开始,Surge 增加了对 [HTTP API](https://manual.nssurge.com/others/http-api.html) 的支持,这使得从浏览器控制 Surge 成为可能。
29+
30+
您可以使用 Surge Web Dashboard 从另一台设备上控制策略、检查请求等!
31+
32+
## 如何使用本项目
33+
34+
新版本的 Surge 已经内建 Surge Web Dashboard, 又可以在高级设置中将其打开。
35+
36+
内建的 Surge Web Dashboard 可能需要您拥有一个有效中的订阅才能开启,但是使用公开的独立版本(见后)则不受此限制。
37+
38+
公开的独立版本地址如下。你可以通过这个版本的 Surge Web Dashboard 管理多个 Surge 实例。
39+
40+
- [HTTP](http://yasd.nerdynerd.org)
41+
- [HTTPS](https://yasd.royli.dev)
42+
43+
你也可以在 [releases](https://github.com/geekdada/yasd/releases) 找到完整应用包自主部署。
44+
45+
## 路线图
46+
47+
[路线图](https://github.com/geekdada/yasd/projects/1)
48+
49+
## License
50+
51+
[MIT](https://github.com/geekdada/yasd/blob/master/LICENSE)

package.json

+22-7
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@
55
"license": "MIT",
66
"scripts": {
77
"start": "craco start",
8-
"build": "NODE_ENV=production craco build",
8+
"build": "zx scripts/build.mjs release-vercel",
9+
"build:release": "zx scripts/build.mjs release-ci",
10+
"build:surge": "zx scripts/build.mjs surge",
911
"test": "craco test --watchAll=false",
1012
"test:watch": "craco test",
1113
"test:coverage": "craco test --coverage --runInBand --watchAll=false",
12-
"test:lint": "eslint . --ext .js,.jsx,.ts,.tsx",
14+
"test:lint": "eslint . --ext .mjs,.js,.jsx,.ts,.tsx",
1315
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
1416
"pub": "np --no-publish",
1517
"version": "npm run changelog && git add .",
1618
"snyk-protect": "snyk protect",
17-
"prepare": "npm run snyk-protect && husky install"
19+
"prepare": "npm run snyk-protect && husky install",
20+
"verify-translation": "zx scripts/verify-translations.mjs"
1821
},
1922
"dependencies": {
2023
"@commitlint/cli": "^12.0.1",
@@ -38,10 +41,11 @@
3841
"@types/chart.js": "^2.9.27",
3942
"@types/enzyme": "^3.10.7",
4043
"@types/enzyme-adapter-react-16": "^1.0.6",
44+
"@types/fs-extra": "^9.0.11",
4145
"@types/jest": "^26.0.15",
4246
"@types/loadable__component": "^5.13.0",
4347
"@types/lodash-es": "^4.17.3",
44-
"@types/node": "^12.0.0",
48+
"@types/node": "^14.0.0",
4549
"@types/react": "^17.0.3",
4650
"@types/react-collapse": "^5.0.0",
4751
"@types/react-dom": "^17.0.3",
@@ -53,6 +57,7 @@
5357
"@typescript-eslint/eslint-plugin": "^4.5.0",
5458
"@typescript-eslint/parser": "^4.5.0",
5559
"autoprefixer": "^9.8.6",
60+
"await-to-js": "^3.0.0",
5661
"axios": "^0.21.0",
5762
"bluebird": "^3.7.2",
5863
"bytes": "^3.1.0",
@@ -70,8 +75,14 @@
7075
"eslint-plugin-prettier": "^3.3.1",
7176
"eslint-plugin-react": "^7.21.5",
7277
"eslint-plugin-react-hooks": "^4.2.0",
78+
"fs-extra": "^10.0.0",
7379
"husky": "^5.2.0",
80+
"i18next": "^20.3.1",
81+
"i18next-chained-backend": "^3.0.2",
82+
"i18next-http-backend": "^1.2.6",
83+
"i18next-resources-to-backend": "^1.0.0",
7484
"identity-obj-proxy": "^3.0.0",
85+
"is-ip": "^3.1.0",
7586
"lint-staged": "^10.4.0",
7687
"lodash-es": "^4.17.15",
7788
"modern-normalize": "^1.0.0",
@@ -88,12 +99,15 @@
8899
"react-collapse": "^5.0.1",
89100
"react-dom": "^17.0.1",
90101
"react-ga": "^3.1.2",
102+
"react-hook-form": "^7.8.4",
103+
"react-i18next": "^11.10.0",
91104
"react-router-dom": "^5.2.0",
92105
"react-scripts": "4.0.3",
93106
"react-scroll-to": "^3.0.0-beta.6",
94107
"react-tabs": "^3.1.1",
95108
"react-toastify": "^7.0.3",
96109
"react-virtualized": "^9.22.2",
110+
"rimraf": "^3.0.2",
97111
"semver": "^7.3.2",
98112
"smoothscroll-polyfill": "^0.4.4",
99113
"snyk": "^1.511.0",
@@ -104,7 +118,8 @@
104118
"twin.macro": "^1.11.1",
105119
"typescript": "^4.0.3",
106120
"use-is-in-viewport": "^1.0.9",
107-
"uuid": "^8.3.0"
121+
"uuid": "^8.3.0",
122+
"zx": "^1.11.0"
108123
},
109124
"browserslist": {
110125
"production": [
@@ -127,10 +142,10 @@
127142
}
128143
},
129144
"lint-staged": {
130-
"*.{js,jsx,ts,tsx}": "eslint --ext .js,.jsx,.ts,.tsx"
145+
"*.{js,jsx,ts,tsx}": "eslint --ext .mjs,.js,.jsx,.ts,.tsx"
131146
},
132147
"engines": {
133-
"node": ">=12.0.0"
148+
"node": "^14"
134149
},
135150
"snyk": true
136151
}

public/apple-touch-icon-120x120.png

3.18 KB
Loading

public/apple-touch-icon-152x152.png

212 Bytes
Loading

public/apple-touch-icon-180x180.png

-2.88 KB
Loading

public/favicon.ico

-9.86 KB
Binary file not shown.

public/github-banner.png

-31.4 KB
Loading

public/icon-circle@512w.png

-19.5 KB
Loading

public/icon-square@192w.png

-167 Bytes
Loading

public/icon-square@512w.png

-23.4 KB
Loading

public/index.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
<meta name="theme-color" content="#f6f9fb" />
77
<meta
88
name="description"
9-
content="Yet Another Surge Dashboard"
9+
content="Surge Web Dashboard"
1010
/>
1111
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
1212
<link rel="apple-touch-icon" href="%PUBLIC_URL%/apple-touch-icon-120x120.png" sizes="120x120">
1313
<link rel="apple-touch-icon" href="%PUBLIC_URL%/apple-touch-icon-152x152.png" sizes="152x152">
1414
<link rel="apple-touch-icon" href="%PUBLIC_URL%/apple-touch-icon-180x180.png" sizes="180x180">
1515
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
16-
<script src="https://polyfill.alicdn.com/modern/polyfill.min.js" crossorigin="anonymous"></script>
17-
<title>YASD - Yet Another Surge Dashboard</title>
16+
<meta name="apple-mobile-web-app-capable" content="yes">
17+
<meta name="apple-mobile-web-app-status-bar-style" content="dark-content">
18+
<meta name="format-detection" content="telephone=no">
19+
<title>Surge Web Dashboard</title>
1820
</head>
1921
<body>
2022
<noscript>You need to enable JavaScript to run this app.</noscript>

scripts/build.mjs

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/* global $ */
2+
3+
import fs from 'fs-extra'
4+
5+
await (async () => {
6+
const { argv } = process
7+
const target = argv[3]
8+
const validTargets = ['release-vercel', 'release-ci', 'surge']
9+
10+
if (!validTargets.includes(target)) {
11+
throw new Error('Invalid build target.')
12+
}
13+
14+
await $`yarn verify-translation`
15+
await clean()
16+
console.info('🚧 Build artifact')
17+
18+
switch (target) {
19+
case 'release-vercel':
20+
process.env.NODE_ENV = 'production'
21+
process.env.REACT_APP_USE_SW = 'true'
22+
await $`craco build`
23+
24+
break
25+
26+
case 'release-ci':
27+
process.env.NODE_ENV = 'production'
28+
process.env.REACT_APP_SHOW_AD = 'true'
29+
process.env.REACT_APP_HASH_ROUTER = 'true'
30+
process.env.REACT_APP_USE_SW = 'true'
31+
process.env.PUBLIC_URL = getUrlPathPrefix()
32+
await $`craco build`
33+
await changeManifest({
34+
start_url: `${getUrlPathPrefix()}/#/home`,
35+
})
36+
await bundleArtifact()
37+
38+
break
39+
40+
case 'surge':
41+
process.env.NODE_ENV = 'production'
42+
process.env.REACT_APP_HASH_ROUTER = 'true'
43+
process.env.REACT_APP_RUN_IN_SURGE = 'true'
44+
process.env.REACT_APP_URL_PATH_PREFIX = '/web'
45+
process.env.PUBLIC_URL = getUrlPathPrefix()
46+
await $`craco build`
47+
await changeManifest({
48+
short_name: 'Dashboard',
49+
name: 'Surge Web Dashboard',
50+
start_url: `${getUrlPathPrefix()}/index.html#/home`,
51+
})
52+
await bundleArtifact()
53+
await $`mv ./build.tar.gz ./yasd.tar.gz`
54+
55+
break
56+
57+
default:
58+
process.env.NODE_ENV = 'production'
59+
process.env.REACT_APP_USE_SW = 'true'
60+
process.env.PUBLIC_URL = getUrlPathPrefix()
61+
await $`craco build`
62+
63+
if ('REACT_APP_HASH_ROUTER' in process.env) {
64+
await changeManifest({
65+
start_url: `${getUrlPathPrefix()}/#/home`,
66+
})
67+
}
68+
}
69+
})()
70+
71+
async function changeManifest(obj = {}) {
72+
const manifest = await fs.readJson('build/manifest.json')
73+
74+
await fs.writeJSON(
75+
'build/manifest.json',
76+
{
77+
...manifest,
78+
...obj,
79+
},
80+
{ spaces: 2 },
81+
)
82+
}
83+
84+
async function bundleArtifact() {
85+
await $`(cd ./build; tar -czf ../build.tar.gz ./)`
86+
}
87+
88+
async function clean() {
89+
console.info('🧹 Clean up')
90+
await $`rimraf ./build`
91+
await $`rimraf ./*.tar.gz`
92+
}
93+
94+
function getUrlPathPrefix() {
95+
return 'REACT_APP_URL_PATH_PREFIX' in process.env
96+
? process.env.REACT_APP_URL_PATH_PREFIX
97+
: ''
98+
}

0 commit comments

Comments
 (0)