From 401e65f4d2bbe5b4b40729b8e8f2cc7e1b4e9f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Tue, 2 Apr 2019 10:21:54 +0800 Subject: [PATCH] use netlify functions (#3882) * use netlify functions * rm .gitignore key * fix build error * use new folder * change config * add redirects * add redirects * add router * remobe "/" * remove code * add tag * remove babel loader * rm firebase config * remove babel --- .eslintignore | 2 +- .firebaserc | 5 --- .gitignore | 4 +-- README.md | 2 +- README.ru-RU.md | 2 +- README.tr-TR.md | 3 +- README.zh-CN.md | 2 +- firebase.json | 13 ------- functions/index.js | 10 ------ functions/package.json | 23 ------------ lambda/api.js | 11 ++++++ {functions => lambda/mock}/matchMock.js | 11 +++--- netlify.toml | 7 ++-- package.json | 47 +++++++++++++------------ scripts/generateMock.js | 2 +- tsconfig.json | 2 +- 16 files changed, 56 insertions(+), 90 deletions(-) delete mode 100644 .firebaserc delete mode 100644 firebase.json delete mode 100644 functions/index.js delete mode 100644 functions/package.json create mode 100644 lambda/api.js rename {functions => lambda/mock}/matchMock.js (90%) diff --git a/.eslintignore b/.eslintignore index 43ab7824..1cd605b1 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,3 @@ -/functions/mock/** +/lambda/mock/** /scripts /config \ No newline at end of file diff --git a/.firebaserc b/.firebaserc deleted file mode 100644 index e3a9a50c..00000000 --- a/.firebaserc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "projects": { - "default": "antd-pro" - } -} diff --git a/.gitignore b/.gitignore index 28592158..253591b5 100644 --- a/.gitignore +++ b/.gitignore @@ -25,8 +25,8 @@ package-lock.json # visual studio code .history *.log - -functions/mock +functions/* +lambda/mock/index.js .temp/** # umi diff --git a/README.md b/README.md index 06029c2e..c6da6474 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ An out-of-box UI solution for enterprise applications as a React boilerplate. [![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design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VzZSB4bGluazpocmVmPSIjczQiIHg9IjI0NyIgeT0iMjEwIi8%2BDQo8L2c%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzOSIgeD0iNDk0Ii8%2BDQo8L2c%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzMTgiIHg9Ijk4OCIvPg0KPHVzZSB4bGluazpocmVmPSIjczkiIHg9IjE5NzYiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3M1IiB4PSIyNDcwIi8%2BDQo8L2c%2BDQo8L3N2Zz4%3D)](https://gitter.im/ant-design/pro-english?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Join the chat at https://gitter.im/ant-design/ant-design-pro](https://img.shields.io/gitter/room/ant-design/ant-design-pro.svg?style=flat-square&logoWidth=20&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjkwMCIgaGVpZ2h0PSI2MDAiIHZpZXdCb3g9IjAgMCAzMCAyMCI%2BDQo8ZGVmcz4NCjxwYXRoIGlkPSJzIiBkPSJNMCwtMSAwLjU4Nzc4NSwwLjgwOTAxNyAtMC45NTEwNTcsLTAuMzA5MDE3SDAuOTUxMDU3TC0wLjU4Nzc4NSwwLjgwOTAxN3oiIGZpbGw9IiNmZmRlMDAiLz4NCjwvZGVmcz4NCjxyZWN0IHdpZHRoPSIzMCIgaGVpZ2h0PSIyMCIgZmlsbD0iI2RlMjkxMCIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNSw1KSBzY2FsZSgzKSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsMikgcm90YXRlKDIzLjAzNjI0MykiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3MiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEyLDQpIHJvdGF0ZSg0NS44Njk4OTgpIi8%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxMiw3KSByb3RhdGUoNjkuOTQ1Mzk2KSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsOSkgcm90YXRlKDIwLjY1OTgwOCkiLz4NCjwvc3ZnPg%3D%3D)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) - +[![Netlify Status](https://api.netlify.com/api/v1/badges/b68e9850-a529-4364-9d3b-d70aade560f9/deploy-status)](https://app.netlify.com/sites/ant-design-pro/deploys) ![](https://user-images.githubusercontent.com/8186664/44953195-581e3d80-aec4-11e8-8dcb-54b9db38ec11.png) diff --git a/README.ru-RU.md b/README.ru-RU.md index 9ebefff6..f820dfba 100644 --- a/README.ru-RU.md +++ b/README.ru-RU.md @@ -12,7 +12,7 @@ UI-решение "из коробки" для корпоративных при [![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro?type=dev) [![Gitter](https://img.shields.io/gitter/room/ant-design/pro-english.svg?style=flat-square&logoWidth=20&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjEyMzUiIGhlaWdodD0iNjUwIiB2aWV3Qm94PSIwIDAgNzQxMCAzOTAwIj4NCjxyZWN0IHdpZHRoPSI3NDEwIiBoZWlnaHQ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](https://img.shields.io/gitter/room/ant-design/ant-design-pro.svg?style=flat-square&logoWidth=20&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjkwMCIgaGVpZ2h0PSI2MDAiIHZpZXdCb3g9IjAgMCAzMCAyMCI%2BDQo8ZGVmcz4NCjxwYXRoIGlkPSJzIiBkPSJNMCwtMSAwLjU4Nzc4NSwwLjgwOTAxNyAtMC45NTEwNTcsLTAuMzA5MDE3SDAuOTUxMDU3TC0wLjU4Nzc4NSwwLjgwOTAxN3oiIGZpbGw9IiNmZmRlMDAiLz4NCjwvZGVmcz4NCjxyZWN0IHdpZHRoPSIzMCIgaGVpZ2h0PSIyMCIgZmlsbD0iI2RlMjkxMCIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNSw1KSBzY2FsZSgzKSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsMikgcm90YXRlKDIzLjAzNjI0MykiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3MiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEyLDQpIHJvdGF0ZSg0NS44Njk4OTgpIi8%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxMiw3KSByb3RhdGUoNjkuOTQ1Mzk2KSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsOSkgcm90YXRlKDIwLjY1OTgwOCkiLz4NCjwvc3ZnPg%3D%3D)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) - +[![Netlify Status](https://api.netlify.com/api/v1/badges/b68e9850-a529-4364-9d3b-d70aade560f9/deploy-status)](https://app.netlify.com/sites/ant-design-pro/deploys) ![](https://user-images.githubusercontent.com/8186664/44953195-581e3d80-aec4-11e8-8dcb-54b9db38ec11.png) diff --git a/README.tr-TR.md b/README.tr-TR.md index 8d894293..8470cb79 100644 --- a/README.tr-TR.md +++ b/README.tr-TR.md @@ -12,8 +12,7 @@ React ile kurumsal uygulamalar için taslak olarak geliştirilmiş kullanıma ha [![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro?type=dev) [![Gitter](https://img.shields.io/gitter/room/ant-design/pro-english.svg)](https://gitter.im/ant-design/pro-english?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)(🇺🇸) [![Gitter](https://img.shields.io/gitter/room/ant-design/ant-design-pro.svg?style=flat-square)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)(🇨🇳) - - +[![Netlify Status](https://api.netlify.com/api/v1/badges/b68e9850-a529-4364-9d3b-d70aade560f9/deploy-status)](https://app.netlify.com/sites/ant-design-pro/deploys) ![](https://user-images.githubusercontent.com/8186664/44953195-581e3d80-aec4-11e8-8dcb-54b9db38ec11.png) diff --git a/README.zh-CN.md b/README.zh-CN.md index a4186f30..b4b3b722 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -11,7 +11,7 @@ [![Dependencies](https://img.shields.io/david/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro) [![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro?type=dev) [![Join the chat at https://gitter.im/ant-design/ant-design-pro](https://img.shields.io/gitter/room/ant-design/ant-design-pro.svg?style=flat-square&logoWidth=20&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjkwMCIgaGVpZ2h0PSI2MDAiIHZpZXdCb3g9IjAgMCAzMCAyMCI%2BDQo8ZGVmcz4NCjxwYXRoIGlkPSJzIiBkPSJNMCwtMSAwLjU4Nzc4NSwwLjgwOTAxNyAtMC45NTEwNTcsLTAuMzA5MDE3SDAuOTUxMDU3TC0wLjU4Nzc4NSwwLjgwOTAxN3oiIGZpbGw9IiNmZmRlMDAiLz4NCjwvZGVmcz4NCjxyZWN0IHdpZHRoPSIzMCIgaGVpZ2h0PSIyMCIgZmlsbD0iI2RlMjkxMCIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNSw1KSBzY2FsZSgzKSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsMikgcm90YXRlKDIzLjAzNjI0MykiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3MiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEyLDQpIHJvdGF0ZSg0NS44Njk4OTgpIi8%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxMiw3KSByb3RhdGUoNjkuOTQ1Mzk2KSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsOSkgcm90YXRlKDIwLjY1OTgwOCkiLz4NCjwvc3ZnPg%3D%3D)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) - +[![Netlify Status](https://api.netlify.com/api/v1/badges/b68e9850-a529-4364-9d3b-d70aade560f9/deploy-status)](https://app.netlify.com/sites/ant-design-pro/deploys) ![](https://user-images.githubusercontent.com/8186664/44953195-581e3d80-aec4-11e8-8dcb-54b9db38ec11.png) diff --git a/firebase.json b/firebase.json deleted file mode 100644 index a00223d4..00000000 --- a/firebase.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "hosting": { - "public": "dist", - "rewrites": [ - { "source": "/api/**", "function": "api" }, - { - "source": "**", - "destination": "/index.html" - } - ], - "ignore": ["firebase.json", "**/.*", "**/node_modules/**"] - } -} diff --git a/functions/index.js b/functions/index.js deleted file mode 100644 index 609b51ca..00000000 --- a/functions/index.js +++ /dev/null @@ -1,10 +0,0 @@ -// [START functionsimport] -const functions = require('firebase-functions'); -const express = require('express'); - -const matchMock = require('./matchMock'); - -const app = express(); - -app.use(matchMock); -exports.api = functions.https.onRequest(app); diff --git a/functions/package.json b/functions/package.json deleted file mode 100644 index fe77db2a..00000000 --- a/functions/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "functions", - "description": "Cloud Functions for Firebase", - "scripts": { - "serve": "firebase serve --only functions", - "shell": "firebase functions:shell", - "start": "npm run shell", - "deploy": "npm run mock && firebase deploy --only functions", - "logs": "firebase functions:log", - "mock": "node ../scripts/generateMock.js" - }, - "dependencies": { - "@babel/runtime": "^7.0.0", - "body-parser": "^1.18.3", - "express": "^4.16.4", - "firebase-admin": "^6.4.0", - "firebase-functions": "^2.1.0", - "mockjs": "^1.0.1-beta3", - "moment": "^2.22.2", - "path-to-regexp": "^3.0.0" - }, - "private": true -} diff --git a/lambda/api.js b/lambda/api.js new file mode 100644 index 00000000..e0c147a6 --- /dev/null +++ b/lambda/api.js @@ -0,0 +1,11 @@ +// [START functions import] +const express = require('express'); +const serverLess = require('serverless-http'); + +const matchMock = require('./mock/matchMock'); + +const app = express(); + +app.use(matchMock); + +exports.handler = serverLess(app); diff --git a/functions/matchMock.js b/lambda/mock/matchMock.js similarity index 90% rename from functions/matchMock.js rename to lambda/mock/matchMock.js index 924573a5..94027802 100644 --- a/functions/matchMock.js +++ b/lambda/mock/matchMock.js @@ -1,7 +1,7 @@ const pathToRegexp = require('path-to-regexp'); const bodyParser = require('body-parser'); -const mockFile = require('./mock/index'); +const mockFile = require('./index'); const BODY_PARSED_METHODS = ['post', 'put', 'patch']; @@ -10,13 +10,14 @@ function parseKey(key) { let method = 'get'; let path = key; if (key.indexOf(' ') > -1) { - const splited = key.split(' '); - method = splited[0].toLowerCase(); - path = splited[1]; // eslint-disable-line + const spliced = key.split(' '); + method = spliced[0].toLowerCase(); + path = spliced[1]; // eslint-disable-line } + const routerBasePath = process.env.NODE_ENV === 'dev' ? `${path}` : `/.netlify/functions${path}`; return { method, - path, + path: routerBasePath, }; } diff --git a/netlify.toml b/netlify.toml index 18b22e9d..9d3438c4 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,12 +1,15 @@ +[build] + functions = "./functions" + [[redirects]] from = "/api/*" - to = "https://us-central1-antd-pro.cloudfunctions.net/api/api/:splat" + to = "/.netlify/functions/api/:splat" status = 200 force = true [redirects.headers] X-From = "Netlify" X-Api-Key = "some-api-key-string" - + [[redirects]] from = "/*" to = "/index.html" diff --git a/package.json b/package.json index 239197bf..af94ef99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ant-design-pro", - "version": "2.3.0", + "version": "2.3.1", "private": true, "description": "An out-of-box UI solution for enterprise applications", "scripts": { @@ -13,6 +13,9 @@ "docker:dev": "docker-compose -f ./docker/docker-compose.dev.yml up", "docker:push": "npm run docker-hub:build && npm run docker:tag && docker push antdesign/ant-design-pro", "docker:tag": "docker tag ant-design-pro antdesign/ant-design-pro", + "functions:build": "npm run generateMock && netlify-lambda build ./lambda", + "functions:run": "npm run generateMock && cross-env NODE_ENV=dev netlify-lambda serve ./lambda", + "generateMock": "node ./scripts/generateMock", "lint": "eslint --ext .js src mock tests && npm run lint:style && npm run lint:prettier", "lint-staged": "lint-staged", "lint-staged:js": "eslint --ext .js", @@ -20,8 +23,6 @@ "lint:prettier": "check-prettier lint", "lint:style": "stylelint 'src/**/*.less' --syntax less", "prettier": "node ./scripts/prettier.js", - "presite": "cd functions && npm install", - "site": "npm run presite && cross-env APP_TYPE=site npm run build && firebase deploy && npm run docker:push", "start": "cross-env APP_TYPE=site umi dev", "start:no-mock": "cross-env MOCK=none umi dev", "test": "umi test", @@ -30,20 +31,39 @@ "tslint": "npm run tslint:fix", "tslint:fix": "tslint --fix 'src/**/*.ts*'" }, + "husky": { + "hooks": { + "pre-commit": "npm run lint-staged" + } + }, + "lint-staged": { + "**/*.less": "stylelint --syntax less", + "**/*.{js,jsx}": "npm run lint-staged:js", + "**/*.{js,ts,tsx,json,jsx,less}": [ + "node ./scripts/lint-prettier.js", + "git add" + ] + }, + "browserslist": [ + "> 1%", + "last 2 versions", + "not ie <= 10" + ], "dependencies": { "@antv/data-set": "^0.10.1", - "@babel/runtime": "^7.3.1", "antd": "^3.13.0", "bizcharts": "^3.4.3", "bizcharts-plugin-slider": "^2.1.1-beta.1", "classnames": "^2.2.6", "dva": "^2.4.1", "enquire-js": "^0.2.1", + "express": "^4.16.4", "gg-editor": "^2.0.2", "lodash": "^4.17.11", "lodash-decorators": "^6.0.1", "memoize-one": "^5.0.0", "moment": "^2.24.0", + "netlify-lambda": "^1.4.3", "numeral": "^2.0.6", "nzh": "^1.0.4", "omit.js": "^1.0.0", @@ -58,6 +78,7 @@ "react-dom": "^16.7.0", "react-fittext": "^1.0.0", "react-media": "^1.9.2", + "serverless-http": "^1.9.1", "umi": "^2.4.4", "umi-plugin-react": "^1.7.2", "umi-request": "^1.0.5" @@ -110,24 +131,6 @@ "engines": { "node": ">=8.0.0" }, - "husky": { - "hooks": { - "pre-commit": "npm run lint-staged" - } - }, - "lint-staged": { - "**/*.less": "stylelint --syntax less", - "**/*.{js,jsx}": "npm run lint-staged:js", - "**/*.{js,ts,tsx,json,jsx,less}": [ - "node ./scripts/lint-prettier.js", - "git add" - ] - }, - "browserslist": [ - "> 1%", - "last 2 versions", - "not ie <= 10" - ], "checkFiles": [ "src/**/*.js*", "src/**/*.ts*", diff --git a/scripts/generateMock.js b/scripts/generateMock.js index 54c7d6d6..e8600caf 100644 --- a/scripts/generateMock.js +++ b/scripts/generateMock.js @@ -1,3 +1,3 @@ const generateMock = require('merge-umi-mock-data'); const path = require('path'); -generateMock(path.join(__dirname, '../mock'), path.join(__dirname, '../functions/mock/index.js')); +generateMock(path.join(__dirname, '../mock'), path.join(__dirname, '../lambda/mock/index.js')); diff --git a/tsconfig.json b/tsconfig.json index 5be30831..5c261011 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "jsx": "react", "allowSyntheticDefaultImports": true, "moduleResolution": "node", - "rootDirs": ["/src", "/test", "/mock","./typings"], + "rootDirs": ["/src", "/test", "/mock", "./typings"], "forceConsistentCasingInFileNames": true, "noImplicitReturns": true, "suppressImplicitAnyIndexErrors": true, -- GitLab