Skip to content

Commit ace7815

Browse files
committed
refactor: 迁移使用 gastby & auto format
1 parent 035d2a0 commit ace7815

Some content is hidden

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

54 files changed

+1006
-1170
lines changed

.eslintrc.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ module.exports = {
22
env: {
33
browser: true,
44
commonjs: true,
5-
es6: true
5+
es6: true,
66
},
7-
extends: "eslint:recommended",
7+
extends: 'eslint:recommended',
88
parserOptions: {
99
ecmaFeatures: {
1010
experimentalObjectRestSpread: true,
11-
jsx: true
11+
jsx: true,
1212
},
13-
sourceType: "module"
13+
sourceType: 'module',
1414
},
15-
plugins: ["react"],
15+
plugins: ['react'],
1616
rules: {
17-
"linebreak-style": ["error", "unix"],
18-
quotes: ["error", "single"],
19-
semi: ["error", "always"],
20-
"no-unused-vars": "off" // 关闭规则
21-
}
17+
'linebreak-style': ['error', 'unix'],
18+
quotes: ['error', 'single'],
19+
semi: ['error', 'always'],
20+
'no-unused-vars': 'off', // 关闭规则
21+
},
2222
};

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ package-lock.json
1717

1818
# vscode editor
1919
.vscode
20+
21+
22+
# gatsby
23+
.cache
24+
public

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.cache
2+
package.json
3+
package-lock.json
4+
public

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"arrowParens": "avoid",
3+
"singleQuote": true,
4+
"semi": true
5+
}

devServer.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

gatsby-config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
pathPrefix: '/resume',
3+
siteMetadata: {
4+
title: 'Resume Generator',
5+
githubUrl: 'https://github.com/visiky/resume.git',
6+
author: 'visiky',
7+
contact: 'https://github.com/visiky',
8+
},
9+
flags: {
10+
DEV_SSR: false,
11+
},
12+
plugins: [
13+
{
14+
resolve: 'gatsby-plugin-less',
15+
options: {
16+
strictMath: true,
17+
},
18+
},
19+
// this (optional) plugin enables Progressive Web App + Offline functionality
20+
// To learn more, visit: https://gatsby.dev/offline
21+
// `gatsby-plugin-offline`,
22+
],
23+
};

gatsby-node.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const path = require('path');
2+
3+
exports.onCreateWebpackConfig = ({ actions, loaders, stage, getConfig }) => {
4+
const config = getConfig();
5+
6+
if (config.resolve) {
7+
config.resolve.alias = {
8+
...config.resolve.alias,
9+
'@': path.resolve(__dirname, 'src'),
10+
};
11+
} else {
12+
config.resolve = {
13+
alias: { '@': path.resolve(__dirname, 'src') },
14+
};
15+
}
16+
17+
// This will completely replace the webpack config with the modified object.
18+
actions.replaceWebpackConfig(config);
19+
20+
if (stage === 'build-html' || stage === 'develop-html') {
21+
actions.setWebpackConfig({
22+
module: {
23+
rules: [
24+
{
25+
test: /bad-module/,
26+
use: loaders.null(),
27+
},
28+
],
29+
},
30+
});
31+
}
32+
};

package.json

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,59 +5,38 @@
55
"dependencies": {
66
"antd": "^2.9.3",
77
"material-ui": "^0.17.4",
8-
"react": "^15.4.2",
9-
"react-dom": "^15.4.2",
8+
"react": "^17.0.1",
9+
"react-dom": "^17.0.1",
1010
"react-event-listener": "^0.4.5",
1111
"redux": "^3.6.0"
1212
},
1313
"devDependencies": {
14-
"@babel/cli": "^7.13.10",
15-
"@babel/core": "^7.13.13",
16-
"@babel/plugin-proposal-class-properties": "^7.13.0",
17-
"@babel/preset-env": "^7.13.12",
18-
"@babel/preset-react": "^7.0.0",
19-
"@babel/preset-typescript": "^7.13.0",
2014
"@types/material-ui": "^0.21.8",
2115
"@types/react": "^17.0.3",
22-
"@types/react-dom": "^17.0.3",
2316
"@types/react-redux": "^7.1.16",
24-
"@types/react-tap-event-plugin": "^0.0.30",
25-
"babel-loader": "^8.2.2",
2617
"babel-plugin-import": "^1.13.3",
27-
"copy-webpack-plugin": "^4.0.1",
28-
"cross-env": "^2.0.1",
29-
"css-loader": "^0.28.11",
30-
"eslint": "^7.23.0",
31-
"eslint-config-airbnb": "^18.2.1",
32-
"eslint-plugin-react": "^7.23.1",
33-
"html-webpack-plugin": "^4.5.2",
34-
"less": "^3.7.1",
35-
"less-loader": "^4.1.0",
18+
"gatsby": "^2.26.1",
19+
"gatsby-plugin-less": "^5.2.0",
20+
"less": "^4.1.0",
3621
"open-browser-webpack-plugin": "0.0.5",
37-
"postcss-import": "^14.0.0",
38-
"postcss-loader": "^3.0.0",
22+
"prettier": "2.2.1",
3923
"prop-types": "^15.5.8",
4024
"react-hot-loader": "^4.13.0",
4125
"react-redux": "^5.0.4",
42-
"react-tap-event-plugin": "^2.0.1",
4326
"redux-devtools-extension": "^2.13.0",
4427
"redux-form": "^6.6.3",
4528
"rimraf": "^2.5.4",
46-
"style-loader": "^2.0.0",
4729
"ts-loader": "^8.0.18",
48-
"typescript": "^4.2.3",
49-
"url-loader": "^4.1.1",
50-
"webpack": "^4.43.0",
51-
"webpack-cli": "^4.5.0",
52-
"webpack-dev-server": "^3.11.2"
30+
"typescript": "^4.2.3"
5331
},
5432
"scripts": {
55-
"start": "node devServer.js",
56-
"clean": "rimraf dist",
57-
"eslint": "eslint --ext *.js src"
33+
"start": "gatsby develop",
34+
"build": "gatsby build",
35+
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
36+
"clean": "gatsby clean",
37+
"deploy": "npm run clean && gatsby build --prefix-paths && gh-pages -d public"
5838
},
5939
"description": "This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).",
60-
"main": "devServer.js",
6140
"repository": {
6241
"type": "git",
6342
"url": "[email protected]:visiky/resume.git"
@@ -71,4 +50,4 @@
7150
"url": "https://github.com/visiky/resume/issues"
7251
},
7352
"homepage": "https://github.com/visiky/resume#readme"
74-
}
53+
}

src/actions/index.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
import { ActionTypes } from 'constants/actionTypes'
1+
import { ActionTypes } from '../constants/actionTypes';
22

33
/**
44
* actionCreator
55
* @param {*} payload
66
* @return {object} action
77
*/
88

9-
export const setStyleColor = (color) => ({
9+
export const setStyleColor = color => ({
1010
type: 'SET_STYLE_COLOR',
1111
color,
12-
})
12+
});
1313

14-
export const setTemplate = (templateId) => ({
14+
export const setTemplate = templateId => ({
1515
type: 'SET_TEMPLATE',
1616
templateId,
17-
})
17+
});
1818

19-
export const setBasicInfo = (basicInfo) => ({
19+
export const setBasicInfo = basicInfo => ({
2020
type: ActionTypes.SET_BASIC_INFO,
2121
basicInfo,
22-
})
22+
});
2323

24-
export const setExperience = (experiences) => ({
24+
export const setExperience = experiences => ({
2525
type: ActionTypes.SET_EXPERIENCE,
2626
experiences,
27-
})
27+
});
2828

29-
export const setSkill = (skills) => ({
29+
export const setSkill = skills => ({
3030
type: ActionTypes.SET_SKILL,
3131
skills,
32-
})
32+
});
3333

34-
export const setAppraisal = (appraisals) => ({
34+
export const setAppraisal = appraisals => ({
3535
type: ActionTypes.SET_APPRAISAL,
3636
appraisals,
37-
})
37+
});
3838

3939
// export const clearBasicInfo = (basicInfo) => ({
4040
// type: ActionTypes.CLEAR_SET_BASIC_INFO,
4141
// basicInfo
4242
// });
4343

44-
export const deleteInfo = (payload) => ({
44+
export const deleteInfo = payload => ({
4545
type: 'DELETE_INFO',
4646
payload,
47-
})
47+
});
4848

4949
// export const clearAppraisal = (appraisal) => ({
5050
// type: ActionTypes.CLEAR_SET_APPRAISAL,
@@ -54,63 +54,63 @@ export const deleteInfo = (payload) => ({
5454
/**
5555
* @params {object} - 要进行调整的信息
5656
*/
57-
export const adjustInfo = (payload) => ({
57+
export const adjustInfo = payload => ({
5858
type: 'ADJUST_INFO',
5959
payload,
60-
})
60+
});
6161

62-
export const newSet = (actionType) => {
62+
export const newSet = actionType => {
6363
switch (actionType) {
6464
case 'SET_SKILL':
6565
return {
6666
type: 'SET_NEW_SKILL',
6767
skills: {},
68-
}
68+
};
6969
case 'SET_EXPERIENCE':
7070
return {
7171
type: 'SET_NEW_EXPERIENCE',
7272
experiences: {},
73-
}
73+
};
7474
case 'SET_APPRAISAL':
7575
return {
7676
type: 'SET_NEW_APPRAISAL',
7777
appraisals: '',
78-
}
78+
};
7979
default:
80-
break
80+
break;
8181
}
82-
}
82+
};
8383

84-
export const clearSet = (payload) => {
84+
export const clearSet = payload => {
8585
const actionType = payload.actionType,
86-
content = payload.content
86+
content = payload.content;
8787
switch (actionType) {
8888
case 'SET_BASIC_INFO':
8989
return {
9090
type: ActionTypes.SET_BASIC_INFO,
9191
basicInfo: content,
92-
}
92+
};
9393
case 'SET_SKILL':
9494
return {
9595
type: ActionTypes.SET_SKILL,
9696
skills: content,
97-
}
97+
};
9898
case 'SET_EXPERIENCE':
9999
return {
100100
type: ActionTypes.SET_EXPERIENCE,
101101
experiences: content,
102-
}
102+
};
103103
case 'SET_APPRAISAL':
104104
return {
105105
type: ActionTypes.SET_APPRAISAL,
106106
appraisals: content,
107-
}
107+
};
108108
default:
109-
break
109+
break;
110110
}
111-
}
111+
};
112112

113113
export const setFormSchema = (index = 0) => ({
114114
type: 'SET_FORM_SCHEMA',
115115
index,
116-
})
116+
});
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import React, { Component } from 'react'
2-
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'
1+
import React, { Component } from 'react';
2+
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
33

4-
import FullWidthSection from './containers/FullWidthSection'
4+
import FullWidthSection from '../containers/FullWidthSection';
55

66
class App extends Component {
77
render() {
88
return (
99
<MuiThemeProvider>
1010
<FullWidthSection />
1111
</MuiThemeProvider>
12-
)
12+
);
1313
}
1414
}
1515

16-
export default App
16+
export default App;

0 commit comments

Comments
 (0)