Skip to content

Commit

Permalink
⚡️ Upgrade to next.js
Browse files Browse the repository at this point in the history
  • Loading branch information
wei committed Oct 22, 2020
1 parent 13fa9fb commit f19e805
Show file tree
Hide file tree
Showing 56 changed files with 2,578 additions and 8,924 deletions.
11 changes: 11 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": ["next/babel"],
"plugins": [
[
"relay",
{
"artifactDirectory": "./src/components/__generated__"
}
]
]
}
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
GITHUB_TOKEN=
HOST=github-socialify.netlify.app
HOST=github-socialify.git.ci
SCREENSHOT_ENDPOINT=https://screenshotter.git.ci/screenshot
12 changes: 2 additions & 10 deletions .eslintrc.json → .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,14 @@
"node": true
},
"extends": [
"react-app",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:jest/recommended",
"prettier-standard"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
"project": "./tsconfig.json"
},
"plugins": ["react", "@typescript-eslint", "react-hooks", "prettier"],
"rules": {
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.env
/.next
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
__generated__/
package.json
build/
.next/
3 changes: 0 additions & 3 deletions config-overrides.js

This file was deleted.

14 changes: 14 additions & 0 deletions config/jest/cssTransform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'

// This is a custom Jest transformer turning style imports into empty objects.
// http://facebook.github.io/jest/docs/en/webpack.html

module.exports = {
process() {
return 'module.exports = {};'
},
getCacheKey() {
// The output is always the same.
return 'cssTransform'
}
}
40 changes: 40 additions & 0 deletions config/jest/fileTransform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict'

const path = require('path')
const camelcase = require('camelcase')

// This is a custom Jest transformer turning file imports into filenames.
// http://facebook.github.io/jest/docs/en/webpack.html

module.exports = {
process(src, filename) {
const assetFilename = JSON.stringify(path.basename(filename))

if (filename.match(/\.svg$/)) {
// Based on how SVGR generates a component name:
// https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
const pascalCaseFilename = camelcase(path.parse(filename).name, {
pascalCase: true
})
const componentName = `Svg${pascalCaseFilename}`
return `const React = require('react');
module.exports = {
__esModule: true,
default: ${assetFilename},
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
return {
$$typeof: Symbol.for('react.element'),
type: 'svg',
ref: ref,
key: null,
props: Object.assign({}, props, {
children: ${assetFilename}
})
};
}),
};`
}

return `module.exports = ${assetFilename};`
}
}
File renamed without changes.
26 changes: 0 additions & 26 deletions functions/graphql.js

This file was deleted.

50 changes: 0 additions & 50 deletions functions/image.js

This file was deleted.

44 changes: 0 additions & 44 deletions netlify.toml

This file was deleted.

2 changes: 2 additions & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
19 changes: 19 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
target: process.env.NETLIFY ? 'experimental-serverless-trace' : 'server',
async rewrites() {
return [
{
source: '/:owner/:name/png',
destination: '/api/image'
},
{
source: '/:owner/:name/jpg',
destination: '/api/image'
},
{
source: '/graphql',
destination: '/api/graphql'
}
]
}
}
66 changes: 47 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
{
"name": "Socialify",
"name": "socialify",
"version": "1.0.0",
"description": "Socialify your project. Share with the world!",
"author": "@CryogenicPlanet, @wei",
"license": "MIT",
"repository": "https://github.com/wei/socialify.git",
"scripts": {
"dev": "netlify dev",
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject",
"dev": "next dev -p ${PORT-3000}",
"debug": "NODE_OPTIONS='--inspect' next",
"build": "next build",
"test": "jest",
"test:watch": "jest --watch",
"start": "node server.js",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "yarn lint --fix",
"prettier": "prettier --check .",
"prettier:fix": "prettier --write .",
"relay": "relay-compiler --language typescript --extensions ts tsx"
},
"dependencies": {
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"@types/react-relay": "^7.0.11",
"antd": "^4.6.5",
"copee": "^1.0.6",
"hero-patterns": "^2.1.0",
"next": "^9.5.4",
"node-fetch": "^2.6.1",
"query-string": "^6.13.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-relay": "^10.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
"relay-runtime": "^10.0.1",
"typescript": "~3.7.2",
"use-debounce": "^5.0.1"
Expand All @@ -41,21 +36,31 @@
"@types/enzyme": "^3.10.7",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/enzyme-to-json": "^1.5.4",
"@types/jest": "^24.0.0",
"@types/lodash": "^4.14.161",
"@types/node": "^12.0.0",
"@types/node-fetch": "^2.5.7",
"@types/react": "^16.9.0",
"@types/react-relay": "^7.0.11",
"@types/react-router-dom": "^5.1.5",
"@types/relay-runtime": "^10.0.4",
"@typescript-eslint/eslint-plugin": "^4.2.0",
"@typescript-eslint/parser": "^4.2.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.5.2",
"babel-plugin-relay": "^10.0.1",
"customize-cra": "^1.0.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"enzyme-to-json": "^3.6.1",
"eslint": "^7.10.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-prettier-standard": "^3.0.1",
"eslint-config-react-app": "^5.2.1",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^24.0.2",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-promise": "^4.2.1",
Expand All @@ -65,10 +70,10 @@
"graphql": "^15.3.0",
"graphql-compiler": "^1.7.0",
"husky": "^4.3.0",
"netlify-cli": "^2.64.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.5.2",
"prettier": "^2.1.2",
"prettier-config-standard": "^1.0.1",
"react-app-rewired": "^2.1.6",
"relay-compiler": "^10.0.1",
"relay-compiler-language-typescript": "^13.0.1",
"relay-config": "^10.0.1"
Expand All @@ -86,16 +91,39 @@
]
},
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFilesAfterEnv": [
"<rootDir>src/setupTests.ts"
"<rootDir>/config/jest/setupTests.ts"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"moduleNameMapper": {
"\\.(css|less)$": "identity-obj-proxy"
},
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
},
"husky": {
"hooks": {
"pre-commit": "yarn prettier && yarn lint && CI=true yarn test"
"pre-commit": "yarn prettier && yarn lint && yarn test"
}
}
}
}
Loading

0 comments on commit f19e805

Please sign in to comment.