Skip to content

Commit

Permalink
feat: Typescript! (#461)
Browse files Browse the repository at this point in the history
* feat: Typescript!

Signed-off-by: Frost Ming <me@frostming.com>

* chore: use node 16 as the base

Signed-off-by: Frost Ming <me@frostming.com>

* fix: remove use dependencies

Signed-off-by: Frost Ming <me@frostming.com>

---------

Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming authored Aug 3, 2023
1 parent c02d1da commit b3b8df7
Show file tree
Hide file tree
Showing 36 changed files with 639 additions and 539 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// eslint-disable-next-line no-undef
module.exports = {
parser: '@typescript-eslint/parser',
env: {
browser: true,
es2021: true,
Expand All @@ -24,5 +25,9 @@ module.exports = {
rules: {
'prettier/prettier': 'off',
'react/prop-types': 'off',
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
globals: {
NodeJS: true,
},
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ _site/
.idea

config.yaml
.venv/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN apt-get update \
&& pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/ \
&& pip3 install -r requirements.txt

FROM node:14 AS develop-node
FROM node:16 AS develop-node
WORKDIR /root/running_page
COPY ./package.json /root/running_page/package.json
COPY ./yarn.lock /root/running_page/yarn.lock
Expand Down
122 changes: 61 additions & 61 deletions README-CN.md

Large diffs are not rendered by default.

117 changes: 58 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,58 +24,57 @@ English | [简体中文](https://github.com/yihong0618/running_page/blob/master/
<details>
<summary>Running page runners</summary>

| Runner | page | App |
| ------------------------------------------------- | ---------------------------------------------- | --------- |
| [zhubao315](https://github.com/zhubao315) | <https://zhubao315.github.io/running> | Strava |
| [shaonianche](https://github.com/shaonianche) | <https://run.duanfei.org> | Strava |
| [yihong0618](https://github.com/yihong0618) | <https://yihong.run> | Nike |
| [superleeyom](https://github.com/superleeyom) | <https://running.leeyom.top> | Nike |
| [geekplux](https://github.com/geekplux) | <https://activities.geekplux.com> | Nike |
| [guanlan](https://github.com/guanlan) | <https://grun.vercel.app> | Strava |
| [tuzimoe](https://github.com/tuzimoe) | <https://run.tuzi.moe> | Nike |
| [ben_29](https://github.com/ben-29) | <https://running.ben29.xyz> | Strava |
| [kcllf](https://github.com/kcllf) | <https://running-tau.vercel.app> | Garmin-cn |
| [mq](https://github.com/MQ-0707) | <https://running-iota.vercel.app> | Keep |
| [zhaohongxuan](https://github.com/zhaohongxuan) | <https://zhaohongxuan.github.io/workouts> | Strava |
| [yvetterowe](https://github.com/yvetterowe) | <https://run.haoluo.io> | Strava |
| [love-exercise](https://github.com/KaiOrange) | <https://run.kai666666.top> | Keep |
| [zstone12](https://github.com/zstone12) | <https://running-page.zstone12.vercel.app> | Keep |
| [Lax](https://github.com/Lax) | <https://lax.github.io/running> | Keep |
| [lusuzi](https://github.com/lusuzi) | <https://running.lusuzi.vercel.app> | Nike |
| [wh1994](https://github.com/wh1994) | <https://run4life.fun> | Garmin |
| [liuyihui](https://github.com/YiHui-Liu) | <https://run.foolishfox.cn> | Keep |
| [sunyunxian](https://github.com/sunyunxian) | <https://sunyunxian.github.io/running_page> | Strava |
| [AhianZhang](https://github.com/AhianZhang) | <https://running.ahianzhang.com> | Nike |
| [L1cardo](https://github.com/L1cardo) | <https://run.licardo.cn> | Nike |
| [luckylele666](https://github.com/luckylele666) | <https://0000928.xyz> | Strava |
| [MFYDev](https://github.com/MFYDev) | <https://mfydev.run> | Garmin-cn |
| [Eished](https://github.com/eished) | <https://run.iknow.fun> | Keep |
| [Liuxin](https://github.com/liuxindtc) | <https://liuxin.run> | Nike |
| [loucx](https://github.com/loucx) | <https://loucx.github.io/running> | Nike |
| [winf42](https://github.com/winf42) | <https://winf42.github.io> | Garmin-cn |
| [sun0225SUN](https://github.com/sun0225SUN) | <https://run.sunguoqi.com> | Nike |
| [Zhan](https://www.zlog.in/about/) | <https://run.zlog.in> | Nike |
| [Dennis](https://run.domon.cn) | <https://run.domon.cn> | Garmin-cn |
| [hanpei](https://running.nexts.top) | <https://running.nexts.top> | Garmin-cn |
| [liugezhou](https://github.com/liugezhou) | <https://run.liugezhou.online> | Strava |
| [Jason Tan](https://github.com/Jason-cqtan) | <https://jason-cqtan.github.io/running_page> | Nike |
| [Conge](https://github.com/conge) | <https://conge.github.io/running_page> | Strava |
| [zHElEARN](https://github.com/zHElEARN) | <https://workouts.zhelearn.com> | Strava |
| [Ym9i](https://github.com/Ym9i) | <https://bobrun.vercel.app/> | Strava |
| [jianchengwang](https://github.com/jianchengwang) | <https://jianchengwang.github.io/running_page> | Suunto |
| [fxbin](https://github.com/fxbin) | <https://fxbin.github.io/sport-records/> | Keep |
| [shensl4499](https://github.com/shensl4499) | <https://waner.run> | codoon |
| [haowei93](https://github.com/haowei93) | <https://haowei93.github.io/> | gpx |
| [stevenash0822](https://github.com/stevenash0822) | <https://run.imangry.xyz/> | Strava |
| [Vint](https://github.com/VintLin) | <https://vinton.store/Running/> | Keep |
| [Muyids](https://github.com/muyids) | <https://muyids.github.io/running> | Garmin-cn |
| [Gao Hao](https://github.com/efish2002) | <https://efish2002.github.io/running_page/> | Garmin-cn |
| [Jinlei](https://github.com/iamjinlei0312) | <https://jinlei.run/> | AW-GPX |
| [RealTiny656](https://github.com/tiny656) | <https://tiny656.github.io/running_page/> | JoyRun |
| [EINDEX](https://github.com/eindex) | <https://workouts.eindex.me/> | Strava/Nike|
| [Melt](https://github.com/fpGHwd) | <https://running.autove.dev/> | Strava |
| [deepinwine](https://github.com/deepinwine) | <https://deepin.autove.dev/> | Garmin-cn |

| Runner | page | App |
| ------------------------------------------------- | ---------------------------------------------- | ----------- |
| [zhubao315](https://github.com/zhubao315) | <https://zhubao315.github.io/running> | Strava |
| [shaonianche](https://github.com/shaonianche) | <https://run.duanfei.org> | Strava |
| [yihong0618](https://github.com/yihong0618) | <https://yihong.run> | Nike |
| [superleeyom](https://github.com/superleeyom) | <https://running.leeyom.top> | Nike |
| [geekplux](https://github.com/geekplux) | <https://activities.geekplux.com> | Nike |
| [guanlan](https://github.com/guanlan) | <https://grun.vercel.app> | Strava |
| [tuzimoe](https://github.com/tuzimoe) | <https://run.tuzi.moe> | Nike |
| [ben_29](https://github.com/ben-29) | <https://running.ben29.xyz> | Strava |
| [kcllf](https://github.com/kcllf) | <https://running-tau.vercel.app> | Garmin-cn |
| [mq](https://github.com/MQ-0707) | <https://running-iota.vercel.app> | Keep |
| [zhaohongxuan](https://github.com/zhaohongxuan) | <https://zhaohongxuan.github.io/workouts> | Strava |
| [yvetterowe](https://github.com/yvetterowe) | <https://run.haoluo.io> | Strava |
| [love-exercise](https://github.com/KaiOrange) | <https://run.kai666666.top> | Keep |
| [zstone12](https://github.com/zstone12) | <https://running-page.zstone12.vercel.app> | Keep |
| [Lax](https://github.com/Lax) | <https://lax.github.io/running> | Keep |
| [lusuzi](https://github.com/lusuzi) | <https://running.lusuzi.vercel.app> | Nike |
| [wh1994](https://github.com/wh1994) | <https://run4life.fun> | Garmin |
| [liuyihui](https://github.com/YiHui-Liu) | <https://run.foolishfox.cn> | Keep |
| [sunyunxian](https://github.com/sunyunxian) | <https://sunyunxian.github.io/running_page> | Strava |
| [AhianZhang](https://github.com/AhianZhang) | <https://running.ahianzhang.com> | Nike |
| [L1cardo](https://github.com/L1cardo) | <https://run.licardo.cn> | Nike |
| [luckylele666](https://github.com/luckylele666) | <https://0000928.xyz> | Strava |
| [MFYDev](https://github.com/MFYDev) | <https://mfydev.run> | Garmin-cn |
| [Eished](https://github.com/eished) | <https://run.iknow.fun> | Keep |
| [Liuxin](https://github.com/liuxindtc) | <https://liuxin.run> | Nike |
| [loucx](https://github.com/loucx) | <https://loucx.github.io/running> | Nike |
| [winf42](https://github.com/winf42) | <https://winf42.github.io> | Garmin-cn |
| [sun0225SUN](https://github.com/sun0225SUN) | <https://run.sunguoqi.com> | Nike |
| [Zhan](https://www.zlog.in/about/) | <https://run.zlog.in> | Nike |
| [Dennis](https://run.domon.cn) | <https://run.domon.cn> | Garmin-cn |
| [hanpei](https://running.nexts.top) | <https://running.nexts.top> | Garmin-cn |
| [liugezhou](https://github.com/liugezhou) | <https://run.liugezhou.online> | Strava |
| [Jason Tan](https://github.com/Jason-cqtan) | <https://jason-cqtan.github.io/running_page> | Nike |
| [Conge](https://github.com/conge) | <https://conge.github.io/running_page> | Strava |
| [zHElEARN](https://github.com/zHElEARN) | <https://workouts.zhelearn.com> | Strava |
| [Ym9i](https://github.com/Ym9i) | <https://bobrun.vercel.app/> | Strava |
| [jianchengwang](https://github.com/jianchengwang) | <https://jianchengwang.github.io/running_page> | Suunto |
| [fxbin](https://github.com/fxbin) | <https://fxbin.github.io/sport-records/> | Keep |
| [shensl4499](https://github.com/shensl4499) | <https://waner.run> | codoon |
| [haowei93](https://github.com/haowei93) | <https://haowei93.github.io/> | gpx |
| [stevenash0822](https://github.com/stevenash0822) | <https://run.imangry.xyz/> | Strava |
| [Vint](https://github.com/VintLin) | <https://vinton.store/Running/> | Keep |
| [Muyids](https://github.com/muyids) | <https://muyids.github.io/running> | Garmin-cn |
| [Gao Hao](https://github.com/efish2002) | <https://efish2002.github.io/running_page/> | Garmin-cn |
| [Jinlei](https://github.com/iamjinlei0312) | <https://jinlei.run/> | AW-GPX |
| [RealTiny656](https://github.com/tiny656) | <https://tiny656.github.io/running_page/> | JoyRun |
| [EINDEX](https://github.com/eindex) | <https://workouts.eindex.me/> | Strava/Nike |
| [Melt](https://github.com/fpGHwd) | <https://running.autove.dev/> | Strava |
| [deepinwine](https://github.com/deepinwine) | <https://deepin.autove.dev/> | Garmin-cn |

</details>

Expand Down Expand Up @@ -198,19 +197,19 @@ const LINE_OPACITY = 0.4;
- privacy protection

setting flowing env:

```shell
IGNORE_START_END_RANGE = 200 # ignore distance for each polyline start and end.

IGNORE_RANGE = 200 # ignore meters for each point in below polyline.
IGNORE_POLYLINE = ktjrFoemeU~IorGq}DeB # a polyline include point you want to ignore.
IGNORE_RANGE = 200 # ignore meters for each point in below polyline.
IGNORE_POLYLINE = ktjrFoemeU~IorGq}DeB # a polyline include point you want to ignore.

# Do filter before saving to database, you will lose some data, but you can protect your privacy, when you using public repo. enable for set 1, disable via unset.
IGNORE_BEFORE_SAVING =
IGNORE_BEFORE_SAVING =
```

You can using [this](https://developers.google.com/maps/documentation/utilities/polylineutility), to making your `IGNORE_POLYLINE`.


## Download your running data and do not forget to [generate svg in `total` page](#total-data-analysis)

### GPX
Expand Down Expand Up @@ -413,7 +412,7 @@ curl -X POST https://www.strava.com/oauth/token \
7. Sync `Strava` data

> The first time you synchronize Strava data you need to change line 12 of the code False to True in strava_sync.py, and then change it to False after it finishes running.
If you only want to sync `type running` add args --only-run
> If you only want to sync `type running` add args --only-run
```python
python3(python) scripts/strava_sync.py ${client_id} ${client_secret} ${refresh_token}
Expand Down Expand Up @@ -545,7 +544,7 @@ if your garmin account region is **China**, you need to execute the command:
python3(python) scripts/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --is-cn
```

If you want to add Garmin Device during sync, you should add `--use_fake_garmin_device` argument, this will add a Garmin Device (Garmin Forerunner 245 by default, and you can change device in `garmin_device_adaptor.py`) in synced Garmin workout record, this is essential when you want to sync the workout record to other APP like Keep, JoyRun etc.
If you want to add Garmin Device during sync, you should add `--use_fake_garmin_device` argument, this will add a Garmin Device (Garmin Forerunner 245 by default, and you can change device in `garmin_device_adaptor.py`) in synced Garmin workout record, this is essential when you want to sync the workout record to other APP like Keep, JoyRun etc.

<img width="830" alt="image" src="https://github.com/yihong0618/running_page/assets/8613196/b5076942-3133-4c89-ad66-a828211667dc">

Expand Down Expand Up @@ -691,7 +690,7 @@ supported manufacturer:
- [ ] support the world map
- [ ] support multiple types, like hiking, biking~
- [ ] support for Zeep life

# Contribution

- Any Issues PR welcome.
Expand Down
13 changes: 9 additions & 4 deletions gatsby-config.js → gatsby-config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-undef */
// eslint-disable-next-line no-undef
module.exports = {
import type { GatsbyConfig } from 'gatsby';

const config: GatsbyConfig = {
pathPrefix: process.env.PATH_PREFIX || '/',
siteMetadata: {
siteTitle: 'Running Page',
Expand Down Expand Up @@ -45,7 +45,10 @@ module.exports = {
{
resolve: 'gatsby-alias-imports',
options: {
rootFolder: '.',
aliases: {
'@': 'src/',
'@assets': 'assets/',
},
},
},
{
Expand Down Expand Up @@ -81,3 +84,5 @@ module.exports = {
},
],
};

export default config;
14 changes: 8 additions & 6 deletions gatsby-node.js → gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// eslint-disable-next-line no-undef
exports.createSchemaCustomization = ({ actions }) => {
const { createTypes } = actions;
const typeDefs = `
import type { GatsbyNode } from 'gatsby';

export const createSchemaCustomization: GatsbyNode['createSchemaCustomization'] =
({ actions }) => {
const { createTypes } = actions;
const typeDefs = `
type ActivitiesJson implements Node @dontInfer {
id: String
distance: Float
Expand All @@ -18,5 +20,5 @@ exports.createSchemaCustomization = ({ actions }) => {
summary_polyline: String
}
`;
createTypes(typeDefs);
};
createTypes(typeDefs);
};
18 changes: 0 additions & 18 deletions jsconfig.json

This file was deleted.

25 changes: 10 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"@mapbox/mapbox-gl-language": "^1.0.0",
"@mapbox/polyline": "^1.1.1",
"@vercel/analytics": "^0.1.6",
"classnames": "^2.3.1",
"date-fns": "^2.28.0",
"gatsby": "^4.25.0",
"gatsby-alias-imports": "^1.0.6",
"gatsby-plugin-manifest": "^4.16.0",
Expand All @@ -20,6 +18,7 @@
"gatsby-source-filesystem": "^4.16.0",
"gatsby-transformer-json": "^4.16.0",
"gcoord": "^0.3.2",
"geojson": "^0.5.0",
"mapbox-gl": "^2.8.2",
"prop-types": "^15.8.1",
"react": "^17.0.2",
Expand All @@ -28,11 +27,8 @@
"react-map-gl": "^5.1.22",
"sass": "^1.52.3",
"sass-mq": "^6.0.0",
"styled-components": "^5.3.5",
"tachyons": "^4.12.0",
"tachyons-sass": "git+https://github.com/tachyons-css/tachyons-sass.git",
"viewport-mercator-project": "^7.0.4",
"webpack": "^5.73.0"
"tachyons-sass": "git+https://github.com/tachyons-css/tachyons-sass.git"
},
"license": "MIT",
"private": true,
Expand All @@ -45,9 +41,9 @@
"develop": "gatsby develop",
"serve": "gatsby serve",
"serve-prefix": "gatsby serve --prefix-paths",
"lint": "eslint --ext .js,.jsx src --fix",
"check": "npx prettier --write {*,src/**/*}.{js,jsx,scss,json,md,yaml}",
"ci": "yarn run check && yarn run build && yarn run test"
"lint": "eslint --ext .ts,.tsx src --fix",
"check": "prettier --write src/**/*.{scss,json,ts,tsx} *.{md,yaml,json,ts,js}",
"ci": "yarn run check && yarn run lint && yarn run build && yarn run test"
},
"engineStrict": true,
"browserslist": "defaults, not ie 11",
Expand All @@ -59,19 +55,18 @@
"url": "https://github.com/yihong0618/running_page"
},
"devDependencies": {
"@types/mapbox__polyline": "^1.0.2",
"@types/node": "^20.3.3",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@types/react-helmet": "^6.1.6",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"babel-eslint": "^10.1.0",
"eslint": "^8.17.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.2",
"graphql": "15.0.0",
"prettier": "2.8.8",
"react-is": "^18.2.0",
"react-server-dom-webpack": "^0.0.1",
"typescript": "^5.0.4"
"typescript": "^5.1.6"
},
"volta": {
"node": "18.16.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Link } from 'gatsby';
import React from 'react';
import useSiteMetadata from 'src/hooks/useSiteMetadata';
import useSiteMetadata from '@/hooks/useSiteMetadata';

const Header = () => {
const { logo, siteUrl, navLinks } = useSiteMetadata();
Expand Down
Loading

0 comments on commit b3b8df7

Please sign in to comment.