@xfe-repo/web-app 1.6.2 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -1
- package/client.d.ts +1 -0
- package/deploy/.drone.yml +12 -5
- package/deploy/Dockerfile +14 -6
- package/deploy/helm/templates/deployment.yaml +5 -18
- package/deploy/helm/templates/svc.yaml +1 -1
- package/dist/cli.js +275 -413
- package/dist/cli.mjs +273 -267
- package/dist/config.d.mts +20 -6
- package/dist/config.d.ts +20 -6
- package/dist/config.js +83 -297
- package/dist/config.mjs +69 -2
- package/dist/framework.d.mts +10 -0
- package/dist/framework.d.ts +10 -0
- package/dist/framework.js +174 -0
- package/dist/framework.mjs +137 -0
- package/dist/react-router-config.d.mts +11 -0
- package/dist/react-router-config.d.ts +11 -0
- package/dist/react-router-config.js +66 -0
- package/dist/react-router-config.mjs +35 -0
- package/dist/root.d.mts +17 -0
- package/dist/root.d.ts +17 -0
- package/dist/root.js +61 -0
- package/dist/root.mjs +34 -0
- package/dist/serve.d.mts +10 -0
- package/dist/serve.d.ts +10 -0
- package/dist/serve.js +71 -0
- package/dist/serve.mjs +36 -0
- package/dist/vite.d.mts +9 -0
- package/dist/vite.d.ts +9 -0
- package/dist/vite.js +135 -0
- package/dist/vite.mjs +100 -0
- package/package.json +22 -71
- package/tsconfig.json +4 -1
- package/config/env.js +0 -104
- package/config/getHttpsConfig.js +0 -66
- package/config/jest/babelTransform.js +0 -29
- package/config/jest/cssTransform.js +0 -14
- package/config/jest/fileTransform.js +0 -40
- package/config/modules.js +0 -133
- package/config/paths.js +0 -65
- package/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
- package/config/webpack/webpack.config.js +0 -724
- package/config/webpack/webpackDevServer.config.js +0 -122
- package/deploy/nginx.conf +0 -62
- package/dist/chunk-75BJNL7E.mjs +0 -239
- package/scripts/build.js +0 -217
- package/scripts/dev.js +0 -162
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware')
|
|
5
|
-
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware')
|
|
6
|
-
const ignoredFiles = require('react-dev-utils/ignoredFiles')
|
|
7
|
-
const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware')
|
|
8
|
-
const paths = require('../paths')
|
|
9
|
-
const getHttpsConfig = require('../getHttpsConfig')
|
|
10
|
-
|
|
11
|
-
const host = process.env.HOST || '0.0.0.0'
|
|
12
|
-
const sockHost = process.env.WDS_SOCKET_HOST
|
|
13
|
-
const sockPath = process.env.WDS_SOCKET_PATH // default: '/ws'
|
|
14
|
-
const sockPort = process.env.WDS_SOCKET_PORT
|
|
15
|
-
|
|
16
|
-
module.exports = function (proxy, allowedHost) {
|
|
17
|
-
const disableFirewall = !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true'
|
|
18
|
-
return {
|
|
19
|
-
// WebpackDevServer 2.4.3 introduced a security fix that prevents remote
|
|
20
|
-
// websites from potentially accessing local content through DNS rebinding:
|
|
21
|
-
// https://github.com/webpack/webpack-dev-server/issues/887
|
|
22
|
-
// https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
|
|
23
|
-
// However, it made several existing use cases such as development in cloud
|
|
24
|
-
// environment or subdomains in development significantly more complicated:
|
|
25
|
-
// https://github.com/facebook/create-react-app/issues/2271
|
|
26
|
-
// https://github.com/facebook/create-react-app/issues/2233
|
|
27
|
-
// While we're investigating better solutions, for now we will take a
|
|
28
|
-
// compromise. Since our WDS configuration only serves files in the `public`
|
|
29
|
-
// folder we won't consider accessing them a vulnerability. However, if you
|
|
30
|
-
// use the `proxy` feature, it gets more dangerous because it can expose
|
|
31
|
-
// remote code execution vulnerabilities in backends like Django and Rails.
|
|
32
|
-
// So we will disable the host check normally, but enable it if you have
|
|
33
|
-
// specified the `proxy` setting. Finally, we let you override it if you
|
|
34
|
-
// really know what you're doing with a special environment variable.
|
|
35
|
-
// Note: ["localhost", ".localhost"] will support subdomains - but we might
|
|
36
|
-
// want to allow setting the allowedHosts manually for more complex setups
|
|
37
|
-
allowedHosts: disableFirewall ? 'all' : [allowedHost],
|
|
38
|
-
headers: {
|
|
39
|
-
'Access-Control-Allow-Origin': '*',
|
|
40
|
-
'Access-Control-Allow-Methods': '*',
|
|
41
|
-
'Access-Control-Allow-Headers': '*',
|
|
42
|
-
},
|
|
43
|
-
// Enable gzip compression of generated files.
|
|
44
|
-
compress: true,
|
|
45
|
-
static: {
|
|
46
|
-
// By default WebpackDevServer serves physical files from current directory
|
|
47
|
-
// in addition to all the virtual build products that it serves from memory.
|
|
48
|
-
// This is confusing because those files won’t automatically be available in
|
|
49
|
-
// production build folder unless we copy them. However, copying the whole
|
|
50
|
-
// project directory is dangerous because we may expose sensitive files.
|
|
51
|
-
// Instead, we establish a convention that only files in `public` directory
|
|
52
|
-
// get served. Our build script will copy `public` into the `build` folder.
|
|
53
|
-
// In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
|
|
54
|
-
// <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
|
|
55
|
-
// In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
|
|
56
|
-
// Note that we only recommend to use `public` folder as an escape hatch
|
|
57
|
-
// for files like `favicon.ico`, `manifest.json`, and libraries that are
|
|
58
|
-
// for some reason broken when imported through webpack. If you just want to
|
|
59
|
-
// use an image, put it in `src` and `import` it from JavaScript instead.
|
|
60
|
-
directory: paths.appPublic,
|
|
61
|
-
publicPath: [paths.publicUrlOrPath],
|
|
62
|
-
// By default files from `contentBase` will not trigger a page reload.
|
|
63
|
-
watch: {
|
|
64
|
-
// Reportedly, this avoids CPU overload on some systems.
|
|
65
|
-
// https://github.com/facebook/create-react-app/issues/293
|
|
66
|
-
// src/node_modules is not ignored to support absolute imports
|
|
67
|
-
// https://github.com/facebook/create-react-app/issues/1065
|
|
68
|
-
ignored: ignoredFiles(paths.appSrc),
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
client: {
|
|
72
|
-
webSocketURL: {
|
|
73
|
-
// Enable custom sockjs pathname for websocket connection to hot reloading server.
|
|
74
|
-
// Enable custom sockjs hostname, pathname and port for websocket connection
|
|
75
|
-
// to hot reloading server.
|
|
76
|
-
hostname: sockHost,
|
|
77
|
-
pathname: sockPath,
|
|
78
|
-
port: sockPort,
|
|
79
|
-
},
|
|
80
|
-
overlay: {
|
|
81
|
-
errors: true,
|
|
82
|
-
warnings: false,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
devMiddleware: {
|
|
86
|
-
// It is important to tell WebpackDevServer to use the same "publicPath" path as
|
|
87
|
-
// we specified in the webpack config. When homepage is '.', default to serving
|
|
88
|
-
// from the root.
|
|
89
|
-
// remove last slash so user can land on `/test` instead of `/test/`
|
|
90
|
-
publicPath: paths.publicUrlOrPath.slice(0, -1),
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
https: getHttpsConfig(),
|
|
94
|
-
host,
|
|
95
|
-
historyApiFallback: {
|
|
96
|
-
// Paths with dots should still use the history fallback.
|
|
97
|
-
// See https://github.com/facebook/create-react-app/issues/387.
|
|
98
|
-
disableDotRule: true,
|
|
99
|
-
index: paths.publicUrlOrPath,
|
|
100
|
-
},
|
|
101
|
-
// `proxy` is run between `before` and `after` `webpack-dev-server` hooks
|
|
102
|
-
proxy,
|
|
103
|
-
// modify 改进devServer的报错问题
|
|
104
|
-
setupMiddlewares: (middlewares, devServer) => {
|
|
105
|
-
if (!devServer) {
|
|
106
|
-
throw new Error('webpack-dev-server is not defined')
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (fs.existsSync(paths.proxySetup)) {
|
|
110
|
-
require(paths.proxySetup)(devServer.app)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
middlewares.push(
|
|
114
|
-
evalSourceMapMiddleware(devServer),
|
|
115
|
-
redirectServedPath(paths.publicUrlOrPath),
|
|
116
|
-
noopServiceWorkerMiddleware(paths.publicUrlOrPath)
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
return middlewares
|
|
120
|
-
},
|
|
121
|
-
}
|
|
122
|
-
}
|
package/deploy/nginx.conf
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
server {
|
|
2
|
-
listen 80;
|
|
3
|
-
listen [::]:80;
|
|
4
|
-
|
|
5
|
-
server_name -;
|
|
6
|
-
root /code/www/deploy/webroot/app/current;
|
|
7
|
-
|
|
8
|
-
gzip on;
|
|
9
|
-
gzip_vary on;
|
|
10
|
-
gzip_proxied any;
|
|
11
|
-
gzip_comp_level 5;
|
|
12
|
-
gzip_min_length 1024;
|
|
13
|
-
gzip_types text/plain text/css text/javascript application/javascript application/json application/xml text/xml image/svg+xml;
|
|
14
|
-
|
|
15
|
-
set $apiEnv test;
|
|
16
|
-
|
|
17
|
-
if ( $host ~* ^(?<hostPrefix>[^.]+)?\.?(?<subDomain>.*?)\.?(?<domain>[^.]+)\.(?<ltd>[a-zA-Z]+)$ ) {
|
|
18
|
-
set $apiEnv $hostPrefix;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if ( $hostPrefix !~* (test|beta|stage) ) {
|
|
22
|
-
set $apiEnv prod;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
set $file /index.html;
|
|
26
|
-
|
|
27
|
-
# 屏蔽掉map文件
|
|
28
|
-
location ~ .*\.map {
|
|
29
|
-
return 404;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
location /check-update {
|
|
33
|
-
add_header Cache-Control no-cache always;
|
|
34
|
-
|
|
35
|
-
try_files /release =404;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
# 仅带内容 hash 的资源使用长期缓存
|
|
39
|
-
location ~* "\.[0-9a-f]{8,}(\.chunk)?\.[^./]+$" {
|
|
40
|
-
rewrite ^/v[0-9]+(/(static|js|css)/.*)$ $1 break;
|
|
41
|
-
try_files $uri =404;
|
|
42
|
-
|
|
43
|
-
add_header 'Access-Control-Allow-Origin' '*';
|
|
44
|
-
add_header Cache-Control "public, max-age=31536000, immutable";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
# 兼容 /v数字/ 前缀下的构建资源
|
|
48
|
-
location ~ ^/v[0-9]+/(static|js|css)/ {
|
|
49
|
-
rewrite ^/v[0-9]+(/.*)$ $1 break;
|
|
50
|
-
add_header Cache-Control no-cache always;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
location / {
|
|
54
|
-
try_files $uri $file;
|
|
55
|
-
|
|
56
|
-
# 兼容微前端 允许跨域
|
|
57
|
-
add_header 'Access-Control-Allow-Origin' '*';
|
|
58
|
-
|
|
59
|
-
add_header Cache-Control no-cache always;
|
|
60
|
-
add_header Set-Cookie "apiEnv=${apiEnv}; Max-Age=2626560; Path=/;";
|
|
61
|
-
}
|
|
62
|
-
}
|
package/dist/chunk-75BJNL7E.mjs
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
-
try {
|
|
3
|
-
var info = gen[key](arg);
|
|
4
|
-
var value = info.value;
|
|
5
|
-
} catch (error) {
|
|
6
|
-
reject(error);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (info.done) {
|
|
10
|
-
resolve(value);
|
|
11
|
-
} else {
|
|
12
|
-
Promise.resolve(value).then(_next, _throw);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function _async_to_generator(fn) {
|
|
16
|
-
return function() {
|
|
17
|
-
var self = this, args = arguments;
|
|
18
|
-
return new Promise(function(resolve, reject) {
|
|
19
|
-
var gen = fn.apply(self, args);
|
|
20
|
-
function _next(value) {
|
|
21
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
-
}
|
|
23
|
-
function _throw(err) {
|
|
24
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
-
}
|
|
26
|
-
_next(undefined);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function _ts_generator(thisArg, body) {
|
|
31
|
-
var f, y, t, _ = {
|
|
32
|
-
label: 0,
|
|
33
|
-
sent: function() {
|
|
34
|
-
if (t[0] & 1) throw t[1];
|
|
35
|
-
return t[1];
|
|
36
|
-
},
|
|
37
|
-
trys: [],
|
|
38
|
-
ops: []
|
|
39
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
40
|
-
return d(g, "next", {
|
|
41
|
-
value: verb(0)
|
|
42
|
-
}), d(g, "throw", {
|
|
43
|
-
value: verb(1)
|
|
44
|
-
}), d(g, "return", {
|
|
45
|
-
value: verb(2)
|
|
46
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
47
|
-
value: function() {
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
}), g;
|
|
51
|
-
function verb(n) {
|
|
52
|
-
return function(v) {
|
|
53
|
-
return step([
|
|
54
|
-
n,
|
|
55
|
-
v
|
|
56
|
-
]);
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function step(op) {
|
|
60
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
61
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
62
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
63
|
-
if (y = 0, t) op = [
|
|
64
|
-
op[0] & 2,
|
|
65
|
-
t.value
|
|
66
|
-
];
|
|
67
|
-
switch(op[0]){
|
|
68
|
-
case 0:
|
|
69
|
-
case 1:
|
|
70
|
-
t = op;
|
|
71
|
-
break;
|
|
72
|
-
case 4:
|
|
73
|
-
_.label++;
|
|
74
|
-
return {
|
|
75
|
-
value: op[1],
|
|
76
|
-
done: false
|
|
77
|
-
};
|
|
78
|
-
case 5:
|
|
79
|
-
_.label++;
|
|
80
|
-
y = op[1];
|
|
81
|
-
op = [
|
|
82
|
-
0
|
|
83
|
-
];
|
|
84
|
-
continue;
|
|
85
|
-
case 7:
|
|
86
|
-
op = _.ops.pop();
|
|
87
|
-
_.trys.pop();
|
|
88
|
-
continue;
|
|
89
|
-
default:
|
|
90
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
91
|
-
_ = 0;
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
95
|
-
_.label = op[1];
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
99
|
-
_.label = t[1];
|
|
100
|
-
t = op;
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
if (t && _.label < t[2]) {
|
|
104
|
-
_.label = t[2];
|
|
105
|
-
_.ops.push(op);
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
if (t[2]) _.ops.pop();
|
|
109
|
-
_.trys.pop();
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
op = body.call(thisArg, _);
|
|
113
|
-
} catch (e) {
|
|
114
|
-
op = [
|
|
115
|
-
6,
|
|
116
|
-
e
|
|
117
|
-
];
|
|
118
|
-
y = 0;
|
|
119
|
-
} finally{
|
|
120
|
-
f = t = 0;
|
|
121
|
-
}
|
|
122
|
-
if (op[0] & 5) throw op[1];
|
|
123
|
-
return {
|
|
124
|
-
value: op[0] ? op[1] : void 0,
|
|
125
|
-
done: true
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
// src/config.ts
|
|
130
|
-
import path from "path";
|
|
131
|
-
import fs from "fs";
|
|
132
|
-
import yaml from "yaml";
|
|
133
|
-
var loadXfeConfig = function loadXfeConfig() {
|
|
134
|
-
var xfeConfigPath = "./xfe.json";
|
|
135
|
-
if (!fs.existsSync(xfeConfigPath)) {
|
|
136
|
-
throw new Error("xfe.json \u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5728\u9879\u76EE\u6839\u76EE\u5F55\u4E0B\u521B\u5EFA\u8BE5\u6587\u4EF6\u3002");
|
|
137
|
-
}
|
|
138
|
-
var xfeConfigContent = fs.readFileSync(xfeConfigPath, "utf8");
|
|
139
|
-
return JSON.parse(xfeConfigContent);
|
|
140
|
-
};
|
|
141
|
-
var configDeploy = function configDeploy() {
|
|
142
|
-
var xfeConfig = loadXfeConfig();
|
|
143
|
-
if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.deploy)) return;
|
|
144
|
-
var droneConfigFilePath = path.resolve(__dirname, "../deploy/.drone.yml");
|
|
145
|
-
fs.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
|
|
146
|
-
var valuesYamlFilePath = path.resolve(__dirname, "../deploy/helm/values.yaml");
|
|
147
|
-
var valuesYamlFile = fs.readFileSync(valuesYamlFilePath, "utf8");
|
|
148
|
-
var valuesYaml = yaml.parse(valuesYamlFile);
|
|
149
|
-
if (!valuesYaml.virtualService) valuesYaml.virtualService = {};
|
|
150
|
-
if (!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = {
|
|
151
|
-
test: [],
|
|
152
|
-
stage: [],
|
|
153
|
-
prod: []
|
|
154
|
-
};
|
|
155
|
-
var _xfeConfig_deploy = xfeConfig.deploy, _xfeConfig_deploy_virtualServiceEnabled = _xfeConfig_deploy.virtualServiceEnabled, virtualServiceEnabled = _xfeConfig_deploy_virtualServiceEnabled === void 0 ? true : _xfeConfig_deploy_virtualServiceEnabled, _xfeConfig_deploy_hostsProd = _xfeConfig_deploy.hostsProd, hostsProd = _xfeConfig_deploy_hostsProd === void 0 ? [] : _xfeConfig_deploy_hostsProd, _xfeConfig_deploy_hostsStage = _xfeConfig_deploy.hostsStage, hostsStage = _xfeConfig_deploy_hostsStage === void 0 ? [] : _xfeConfig_deploy_hostsStage, _xfeConfig_deploy_hostsTest = _xfeConfig_deploy.hostsTest, hostsTest = _xfeConfig_deploy_hostsTest === void 0 ? [] : _xfeConfig_deploy_hostsTest, _xfeConfig_deploy_gateways = _xfeConfig_deploy.gateways, gateways = _xfeConfig_deploy_gateways === void 0 ? [
|
|
156
|
-
"common-gateway-eshetang"
|
|
157
|
-
] : _xfeConfig_deploy_gateways;
|
|
158
|
-
var _xfeConfig_deploy1 = xfeConfig.deploy, _xfeConfig_deploy_targetK8s = _xfeConfig_deploy1.targetK8s, targetK8s = _xfeConfig_deploy_targetK8s === void 0 ? "saas" : _xfeConfig_deploy_targetK8s, _xfeConfig_deploy_targetNamespace = _xfeConfig_deploy1.targetNamespace, targetNamespace = _xfeConfig_deploy_targetNamespace === void 0 ? "" : _xfeConfig_deploy_targetNamespace;
|
|
159
|
-
valuesYaml.virtualService.enabled = virtualServiceEnabled;
|
|
160
|
-
valuesYaml.virtualService.gateways = gateways;
|
|
161
|
-
valuesYaml.virtualService.hosts.prod = hostsProd;
|
|
162
|
-
valuesYaml.virtualService.hosts.stage = hostsStage;
|
|
163
|
-
valuesYaml.virtualService.hosts.test = hostsTest;
|
|
164
|
-
valuesYaml.targetK8s = targetK8s;
|
|
165
|
-
valuesYaml.namespace = targetNamespace;
|
|
166
|
-
var valuesYamlStr = yaml.stringify(valuesYaml, {
|
|
167
|
-
defaultStringType: "QUOTE_SINGLE",
|
|
168
|
-
defaultKeyType: "PLAIN"
|
|
169
|
-
});
|
|
170
|
-
fs.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
171
|
-
};
|
|
172
|
-
var getJwtEnv = function getJwtEnv() {
|
|
173
|
-
return _async_to_generator(function() {
|
|
174
|
-
var xfeConfig, _xfeConfig_jwt, _xfeConfig_jwt_aud, aud, jwkRes, JwkResponseJson, err, _, _1, _2, _ref, keyId, privateKeyPkcs8;
|
|
175
|
-
return _ts_generator(this, function(_state) {
|
|
176
|
-
switch(_state.label){
|
|
177
|
-
case 0:
|
|
178
|
-
xfeConfig = loadXfeConfig();
|
|
179
|
-
if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.jwt)) throw new Error("xfe.json \u4E2D\u672A\u914D\u7F6E jwt \u4FE1\u606F\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E\u6587\u4EF6\u3002");
|
|
180
|
-
_xfeConfig_jwt = xfeConfig.jwt, _xfeConfig_jwt_aud = _xfeConfig_jwt.aud, aud = _xfeConfig_jwt_aud === void 0 ? "" : _xfeConfig_jwt_aud;
|
|
181
|
-
if (!aud) throw new Error("xfe.json \u4E2D\u7684 jwt \u914D\u7F6E\u4E0D\u5B8C\u6574\uFF0C\u8BF7\u786E\u4FDD\u5305\u542B aud \u5B57\u6BB5\u3002");
|
|
182
|
-
return [
|
|
183
|
-
4,
|
|
184
|
-
fetch("https://app.eshetang.com/jwk?appId=".concat(aud))
|
|
185
|
-
];
|
|
186
|
-
case 1:
|
|
187
|
-
jwkRes = _state.sent();
|
|
188
|
-
if (!jwkRes.ok) {
|
|
189
|
-
throw new Error("远程获取密钥失败: ".concat(jwkRes.status, " ").concat(jwkRes.statusText));
|
|
190
|
-
}
|
|
191
|
-
_state.label = 2;
|
|
192
|
-
case 2:
|
|
193
|
-
_state.trys.push([
|
|
194
|
-
2,
|
|
195
|
-
4,
|
|
196
|
-
,
|
|
197
|
-
6
|
|
198
|
-
]);
|
|
199
|
-
return [
|
|
200
|
-
4,
|
|
201
|
-
jwkRes.json()
|
|
202
|
-
];
|
|
203
|
-
case 3:
|
|
204
|
-
JwkResponseJson = _state.sent();
|
|
205
|
-
return [
|
|
206
|
-
3,
|
|
207
|
-
6
|
|
208
|
-
];
|
|
209
|
-
case 4:
|
|
210
|
-
err = _state.sent();
|
|
211
|
-
_ = Error.bind;
|
|
212
|
-
_2 = (_1 = "远程获取密钥失败,响应解析错误: ".concat(err.message, ", response text: ")).concat;
|
|
213
|
-
return [
|
|
214
|
-
4,
|
|
215
|
-
jwkRes.text()
|
|
216
|
-
];
|
|
217
|
-
case 5:
|
|
218
|
-
throw new (_.apply(Error, [
|
|
219
|
-
void 0,
|
|
220
|
-
_2.apply(_1, [
|
|
221
|
-
_state.sent()
|
|
222
|
-
])
|
|
223
|
-
]));
|
|
224
|
-
case 6:
|
|
225
|
-
_ref = (JwkResponseJson === null || JwkResponseJson === void 0 ? void 0 : JwkResponseJson.data) || {}, keyId = _ref.keyId, privateKeyPkcs8 = _ref.privateKeyPkcs8;
|
|
226
|
-
if (!keyId || !privateKeyPkcs8) throw new Error("未获取到项目签名密钥, 请检查aud是否正确: ".concat(aud));
|
|
227
|
-
return [
|
|
228
|
-
2,
|
|
229
|
-
{
|
|
230
|
-
XFE_JWT_AUD: aud,
|
|
231
|
-
XFE_JWT_KEY_ID: keyId,
|
|
232
|
-
XFE_JWT_PRIVATE_KEY: privateKeyPkcs8
|
|
233
|
-
}
|
|
234
|
-
];
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
})();
|
|
238
|
-
};
|
|
239
|
-
export { loadXfeConfig, configDeploy, getJwtEnv };
|
package/scripts/build.js
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// Do this as the first thing so that any code reading it knows the right env.
|
|
4
|
-
process.env.BABEL_ENV = "production";
|
|
5
|
-
process.env.NODE_ENV = "production";
|
|
6
|
-
|
|
7
|
-
// Makes the script crash on unhandled rejections instead of silently
|
|
8
|
-
// ignoring them. In the future, promise rejections that are not handled will
|
|
9
|
-
// terminate the Node.js process with a non-zero exit code.
|
|
10
|
-
process.on("unhandledRejection", (err) => {
|
|
11
|
-
throw err;
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// Ensure environment variables are read.
|
|
15
|
-
require("../config/env");
|
|
16
|
-
|
|
17
|
-
const path = require("path");
|
|
18
|
-
const chalk = require("react-dev-utils/chalk");
|
|
19
|
-
const fs = require("fs-extra");
|
|
20
|
-
const bfj = require("bfj");
|
|
21
|
-
const webpack = require("webpack");
|
|
22
|
-
const configFactory = require("../config/webpack/webpack.config");
|
|
23
|
-
const paths = require("../config/paths");
|
|
24
|
-
const checkRequiredFiles = require("react-dev-utils/checkRequiredFiles");
|
|
25
|
-
const formatWebpackMessages = require("react-dev-utils/formatWebpackMessages");
|
|
26
|
-
const printHostingInstructions = require("react-dev-utils/printHostingInstructions");
|
|
27
|
-
const FileSizeReporter = require("react-dev-utils/FileSizeReporter");
|
|
28
|
-
const printBuildError = require("react-dev-utils/printBuildError");
|
|
29
|
-
|
|
30
|
-
const measureFileSizesBeforeBuild =
|
|
31
|
-
FileSizeReporter.measureFileSizesBeforeBuild;
|
|
32
|
-
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
|
33
|
-
const useYarn = fs.existsSync(paths.yarnLockFile);
|
|
34
|
-
|
|
35
|
-
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
36
|
-
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
37
|
-
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
38
|
-
|
|
39
|
-
const isInteractive = process.stdout.isTTY;
|
|
40
|
-
|
|
41
|
-
// Warn and crash if required files are missing
|
|
42
|
-
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const argv = process.argv.slice(2);
|
|
47
|
-
const writeStatsJson = argv.indexOf("--stats") !== -1;
|
|
48
|
-
|
|
49
|
-
// Generate configuration
|
|
50
|
-
const config = configFactory("production");
|
|
51
|
-
|
|
52
|
-
// We require that you explicitly set browsers and do not fall back to
|
|
53
|
-
// browserslist defaults.
|
|
54
|
-
const { checkBrowsers } = require("react-dev-utils/browsersHelper");
|
|
55
|
-
checkBrowsers(paths.appPath, isInteractive)
|
|
56
|
-
.then(() => {
|
|
57
|
-
// First, read the current file sizes in build directory.
|
|
58
|
-
// This lets us display how much they changed later.
|
|
59
|
-
return measureFileSizesBeforeBuild(paths.appBuild);
|
|
60
|
-
})
|
|
61
|
-
.then((previousFileSizes) => {
|
|
62
|
-
// Remove all content but keep the directory so that
|
|
63
|
-
// if you're in it, you don't end up in Trash
|
|
64
|
-
fs.emptyDirSync(paths.appBuild);
|
|
65
|
-
// Merge with the public folder
|
|
66
|
-
copyPublicFolder();
|
|
67
|
-
// Start the webpack build
|
|
68
|
-
return build(previousFileSizes);
|
|
69
|
-
})
|
|
70
|
-
.then(
|
|
71
|
-
({ stats, previousFileSizes, warnings }) => {
|
|
72
|
-
if (warnings.length) {
|
|
73
|
-
console.log(chalk.yellow("Compiled with warnings.\n"));
|
|
74
|
-
console.log(warnings.join("\n\n"));
|
|
75
|
-
console.log(
|
|
76
|
-
"\nSearch for the " +
|
|
77
|
-
chalk.underline(chalk.yellow("keywords")) +
|
|
78
|
-
" to learn more about each warning."
|
|
79
|
-
);
|
|
80
|
-
console.log(
|
|
81
|
-
"To ignore, add " +
|
|
82
|
-
chalk.cyan("// eslint-disable-next-line") +
|
|
83
|
-
" to the line before.\n"
|
|
84
|
-
);
|
|
85
|
-
} else {
|
|
86
|
-
console.log(chalk.green("Compiled successfully.\n"));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
console.log("File sizes after gzip:\n");
|
|
90
|
-
printFileSizesAfterBuild(
|
|
91
|
-
stats,
|
|
92
|
-
previousFileSizes,
|
|
93
|
-
paths.appBuild,
|
|
94
|
-
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
|
95
|
-
WARN_AFTER_CHUNK_GZIP_SIZE
|
|
96
|
-
);
|
|
97
|
-
console.log();
|
|
98
|
-
|
|
99
|
-
const appPackage = require(paths.appPackageJson);
|
|
100
|
-
const publicUrl = paths.publicUrlOrPath;
|
|
101
|
-
const publicPath = config.output.publicPath;
|
|
102
|
-
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
|
103
|
-
printHostingInstructions(
|
|
104
|
-
appPackage,
|
|
105
|
-
publicUrl,
|
|
106
|
-
publicPath,
|
|
107
|
-
buildFolder,
|
|
108
|
-
useYarn
|
|
109
|
-
);
|
|
110
|
-
},
|
|
111
|
-
(err) => {
|
|
112
|
-
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === "true";
|
|
113
|
-
if (tscCompileOnError) {
|
|
114
|
-
console.log(
|
|
115
|
-
chalk.yellow(
|
|
116
|
-
"Compiled with the following type errors (you may want to check these before deploying your app):\n"
|
|
117
|
-
)
|
|
118
|
-
);
|
|
119
|
-
printBuildError(err);
|
|
120
|
-
} else {
|
|
121
|
-
console.log(chalk.red("Failed to compile.\n"));
|
|
122
|
-
printBuildError(err);
|
|
123
|
-
process.exit(1);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
)
|
|
127
|
-
.catch((err) => {
|
|
128
|
-
if (err && err.message) {
|
|
129
|
-
console.log(err.message);
|
|
130
|
-
}
|
|
131
|
-
process.exit(1);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
// Create the production build and print the deployment instructions.
|
|
135
|
-
function build(previousFileSizes) {
|
|
136
|
-
console.log("Creating an optimized production build...");
|
|
137
|
-
|
|
138
|
-
const compiler = webpack(config);
|
|
139
|
-
return new Promise((resolve, reject) => {
|
|
140
|
-
compiler.run((err, stats) => {
|
|
141
|
-
let messages;
|
|
142
|
-
if (err) {
|
|
143
|
-
if (!err.message) {
|
|
144
|
-
return reject(err);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
let errMessage = err.message;
|
|
148
|
-
|
|
149
|
-
// Add additional information for postcss errors
|
|
150
|
-
if (Object.prototype.hasOwnProperty.call(err, "postcssNode")) {
|
|
151
|
-
errMessage +=
|
|
152
|
-
"\nCompileError: Begins at CSS selector " +
|
|
153
|
-
err["postcssNode"].selector;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
messages = formatWebpackMessages({
|
|
157
|
-
errors: [errMessage],
|
|
158
|
-
warnings: [],
|
|
159
|
-
});
|
|
160
|
-
} else {
|
|
161
|
-
messages = formatWebpackMessages(
|
|
162
|
-
stats.toJson({ all: false, warnings: true, errors: true })
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
if (messages.errors.length) {
|
|
166
|
-
// Only keep the first error. Others are often indicative
|
|
167
|
-
// of the same problem, but confuse the reader with noise.
|
|
168
|
-
if (messages.errors.length > 1) {
|
|
169
|
-
messages.errors.length = 1;
|
|
170
|
-
}
|
|
171
|
-
return reject(new Error(messages.errors.join("\n\n")));
|
|
172
|
-
}
|
|
173
|
-
if (
|
|
174
|
-
process.env.CI &&
|
|
175
|
-
(typeof process.env.CI !== "string" ||
|
|
176
|
-
process.env.CI.toLowerCase() !== "false") &&
|
|
177
|
-
messages.warnings.length
|
|
178
|
-
) {
|
|
179
|
-
// Ignore sourcemap warnings in CI builds. See #8227 for more info.
|
|
180
|
-
const filteredWarnings = messages.warnings.filter(
|
|
181
|
-
(w) => !/Failed to parse source map/.test(w)
|
|
182
|
-
);
|
|
183
|
-
if (filteredWarnings.length) {
|
|
184
|
-
console.log(
|
|
185
|
-
chalk.yellow(
|
|
186
|
-
"\nTreating warnings as errors because process.env.CI = true.\n" +
|
|
187
|
-
"Most CI servers set it automatically.\n"
|
|
188
|
-
)
|
|
189
|
-
);
|
|
190
|
-
return reject(new Error(filteredWarnings.join("\n\n")));
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const resolveArgs = {
|
|
195
|
-
stats,
|
|
196
|
-
previousFileSizes,
|
|
197
|
-
warnings: messages.warnings,
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
if (writeStatsJson) {
|
|
201
|
-
return bfj
|
|
202
|
-
.write(paths.appBuild + "/bundle-stats.json", stats.toJson())
|
|
203
|
-
.then(() => resolve(resolveArgs))
|
|
204
|
-
.catch((error) => reject(new Error(error)));
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return resolve(resolveArgs);
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function copyPublicFolder() {
|
|
213
|
-
fs.copySync(paths.appPublic, paths.appBuild, {
|
|
214
|
-
dereference: true,
|
|
215
|
-
filter: (file) => file !== paths.appHtml,
|
|
216
|
-
});
|
|
217
|
-
}
|