@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
package/dist/config.js
CHANGED
|
@@ -1,320 +1,106 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3
|
-
try {
|
|
4
|
-
var info = gen[key](arg);
|
|
5
|
-
var value = info.value;
|
|
6
|
-
} catch (error) {
|
|
7
|
-
reject(error);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
if (info.done) {
|
|
11
|
-
resolve(value);
|
|
12
|
-
} else {
|
|
13
|
-
Promise.resolve(value).then(_next, _throw);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function _async_to_generator(fn) {
|
|
17
|
-
return function() {
|
|
18
|
-
var self = this, args = arguments;
|
|
19
|
-
return new Promise(function(resolve, reject) {
|
|
20
|
-
var gen = fn.apply(self, args);
|
|
21
|
-
function _next(value) {
|
|
22
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
23
|
-
}
|
|
24
|
-
function _throw(err) {
|
|
25
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
26
|
-
}
|
|
27
|
-
_next(undefined);
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function _type_of(obj) {
|
|
32
|
-
"@swc/helpers - typeof";
|
|
33
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
34
|
-
}
|
|
35
|
-
function _ts_generator(thisArg, body) {
|
|
36
|
-
var f, y, t, _ = {
|
|
37
|
-
label: 0,
|
|
38
|
-
sent: function() {
|
|
39
|
-
if (t[0] & 1) throw t[1];
|
|
40
|
-
return t[1];
|
|
41
|
-
},
|
|
42
|
-
trys: [],
|
|
43
|
-
ops: []
|
|
44
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
45
|
-
return d(g, "next", {
|
|
46
|
-
value: verb(0)
|
|
47
|
-
}), d(g, "throw", {
|
|
48
|
-
value: verb(1)
|
|
49
|
-
}), d(g, "return", {
|
|
50
|
-
value: verb(2)
|
|
51
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
52
|
-
value: function() {
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
}), g;
|
|
56
|
-
function verb(n) {
|
|
57
|
-
return function(v) {
|
|
58
|
-
return step([
|
|
59
|
-
n,
|
|
60
|
-
v
|
|
61
|
-
]);
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function step(op) {
|
|
65
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
66
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
67
|
-
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;
|
|
68
|
-
if (y = 0, t) op = [
|
|
69
|
-
op[0] & 2,
|
|
70
|
-
t.value
|
|
71
|
-
];
|
|
72
|
-
switch(op[0]){
|
|
73
|
-
case 0:
|
|
74
|
-
case 1:
|
|
75
|
-
t = op;
|
|
76
|
-
break;
|
|
77
|
-
case 4:
|
|
78
|
-
_.label++;
|
|
79
|
-
return {
|
|
80
|
-
value: op[1],
|
|
81
|
-
done: false
|
|
82
|
-
};
|
|
83
|
-
case 5:
|
|
84
|
-
_.label++;
|
|
85
|
-
y = op[1];
|
|
86
|
-
op = [
|
|
87
|
-
0
|
|
88
|
-
];
|
|
89
|
-
continue;
|
|
90
|
-
case 7:
|
|
91
|
-
op = _.ops.pop();
|
|
92
|
-
_.trys.pop();
|
|
93
|
-
continue;
|
|
94
|
-
default:
|
|
95
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
96
|
-
_ = 0;
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
100
|
-
_.label = op[1];
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
104
|
-
_.label = t[1];
|
|
105
|
-
t = op;
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
if (t && _.label < t[2]) {
|
|
109
|
-
_.label = t[2];
|
|
110
|
-
_.ops.push(op);
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
if (t[2]) _.ops.pop();
|
|
114
|
-
_.trys.pop();
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
op = body.call(thisArg, _);
|
|
118
|
-
} catch (e) {
|
|
119
|
-
op = [
|
|
120
|
-
6,
|
|
121
|
-
e
|
|
122
|
-
];
|
|
123
|
-
y = 0;
|
|
124
|
-
} finally{
|
|
125
|
-
f = t = 0;
|
|
126
|
-
}
|
|
127
|
-
if (op[0] & 5) throw op[1];
|
|
128
|
-
return {
|
|
129
|
-
value: op[0] ? op[1] : void 0,
|
|
130
|
-
done: true
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
2
|
var __create = Object.create;
|
|
135
3
|
var __defProp = Object.defineProperty;
|
|
136
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
137
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
138
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
139
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
140
|
-
var __export =
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
enumerable: true
|
|
144
|
-
});
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
145
11
|
};
|
|
146
|
-
var __copyProps =
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
get: function get() {
|
|
154
|
-
return from[key];
|
|
155
|
-
},
|
|
156
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
157
|
-
});
|
|
158
|
-
};
|
|
159
|
-
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
160
|
-
} catch (err) {
|
|
161
|
-
_didIteratorError = true;
|
|
162
|
-
_iteratorError = err;
|
|
163
|
-
} finally{
|
|
164
|
-
try {
|
|
165
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
166
|
-
_iterator.return();
|
|
167
|
-
}
|
|
168
|
-
} finally{
|
|
169
|
-
if (_didIteratorError) {
|
|
170
|
-
throw _iteratorError;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return to;
|
|
176
|
-
};
|
|
177
|
-
var __toESM = function __toESM(mod, isNodeMode, target) {
|
|
178
|
-
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
179
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
180
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
181
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
182
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
183
|
-
value: mod,
|
|
184
|
-
enumerable: true
|
|
185
|
-
}) : target, mod);
|
|
186
|
-
};
|
|
187
|
-
var __toCommonJS = function __toCommonJS(mod) {
|
|
188
|
-
return __copyProps(__defProp({}, "__esModule", {
|
|
189
|
-
value: true
|
|
190
|
-
}), mod);
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
191
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
192
30
|
// src/config.ts
|
|
193
31
|
var config_exports = {};
|
|
194
32
|
__export(config_exports, {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
getJwtEnv: function getJwtEnv1() {
|
|
199
|
-
return getJwtEnv;
|
|
200
|
-
},
|
|
201
|
-
loadXfeConfig: function loadXfeConfig1() {
|
|
202
|
-
return loadXfeConfig;
|
|
203
|
-
}
|
|
33
|
+
configDeploy: () => configDeploy,
|
|
34
|
+
getJwtEnv: () => getJwtEnv,
|
|
35
|
+
loadXfeConfig: () => loadXfeConfig
|
|
204
36
|
});
|
|
205
37
|
module.exports = __toCommonJS(config_exports);
|
|
206
38
|
var import_path = __toESM(require("path"));
|
|
207
39
|
var import_fs = __toESM(require("fs"));
|
|
208
40
|
var import_yaml = __toESM(require("yaml"));
|
|
209
|
-
var loadXfeConfig =
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
41
|
+
var loadXfeConfig = (root = process.cwd()) => {
|
|
42
|
+
const xfeConfigPath = import_path.default.join(root, "xfe.json");
|
|
43
|
+
if (!import_fs.default.existsSync(xfeConfigPath)) {
|
|
44
|
+
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");
|
|
45
|
+
}
|
|
46
|
+
const xfeConfigContent = import_fs.default.readFileSync(xfeConfigPath, "utf8");
|
|
47
|
+
const config = JSON.parse(xfeConfigContent);
|
|
48
|
+
const renderMode = config.webapp?.renderMode;
|
|
49
|
+
if (renderMode !== void 0 && renderMode !== "client" && renderMode !== "server") {
|
|
50
|
+
throw new Error("xfe.json.webapp.renderMode \u53EA\u80FD\u4E3A client \u6216 server");
|
|
51
|
+
}
|
|
52
|
+
return config;
|
|
216
53
|
};
|
|
217
|
-
var configDeploy =
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
defaultKeyType: "PLAIN"
|
|
245
|
-
});
|
|
246
|
-
import_fs.default.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
54
|
+
var configDeploy = () => {
|
|
55
|
+
const xfeConfig = loadXfeConfig();
|
|
56
|
+
if (!xfeConfig?.deploy) return;
|
|
57
|
+
const droneConfigFilePath = import_path.default.resolve(__dirname, "../deploy/.drone.yml");
|
|
58
|
+
import_fs.default.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
|
|
59
|
+
const valuesYamlFilePath = import_path.default.resolve(__dirname, "../deploy/helm/values.yaml");
|
|
60
|
+
const valuesYamlFile = import_fs.default.readFileSync(valuesYamlFilePath, "utf8");
|
|
61
|
+
const valuesYaml = import_yaml.default.parse(valuesYamlFile);
|
|
62
|
+
if (!valuesYaml.virtualService) valuesYaml.virtualService = {};
|
|
63
|
+
if (!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = { test: [], stage: [], prod: [] };
|
|
64
|
+
const {
|
|
65
|
+
virtualServiceEnabled = true,
|
|
66
|
+
hostsProd = [],
|
|
67
|
+
hostsStage = [],
|
|
68
|
+
hostsTest = [],
|
|
69
|
+
gateways = ["common-gateway-eshetang"]
|
|
70
|
+
} = xfeConfig.deploy;
|
|
71
|
+
const { targetK8s = "saas", targetNamespace = "" } = xfeConfig.deploy;
|
|
72
|
+
valuesYaml.virtualService.enabled = virtualServiceEnabled;
|
|
73
|
+
valuesYaml.virtualService.gateways = gateways;
|
|
74
|
+
valuesYaml.virtualService.hosts.prod = hostsProd;
|
|
75
|
+
valuesYaml.virtualService.hosts.stage = hostsStage;
|
|
76
|
+
valuesYaml.virtualService.hosts.test = hostsTest;
|
|
77
|
+
valuesYaml.targetK8s = targetK8s;
|
|
78
|
+
valuesYaml.namespace = targetNamespace;
|
|
79
|
+
const valuesYamlStr = import_yaml.default.stringify(valuesYaml, { defaultStringType: "QUOTE_SINGLE", defaultKeyType: "PLAIN" });
|
|
80
|
+
import_fs.default.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
247
81
|
};
|
|
248
|
-
var getJwtEnv =
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
_state.label = 2;
|
|
268
|
-
case 2:
|
|
269
|
-
_state.trys.push([
|
|
270
|
-
2,
|
|
271
|
-
4,
|
|
272
|
-
,
|
|
273
|
-
6
|
|
274
|
-
]);
|
|
275
|
-
return [
|
|
276
|
-
4,
|
|
277
|
-
jwkRes.json()
|
|
278
|
-
];
|
|
279
|
-
case 3:
|
|
280
|
-
JwkResponseJson = _state.sent();
|
|
281
|
-
return [
|
|
282
|
-
3,
|
|
283
|
-
6
|
|
284
|
-
];
|
|
285
|
-
case 4:
|
|
286
|
-
err = _state.sent();
|
|
287
|
-
_ = Error.bind;
|
|
288
|
-
_2 = (_1 = "远程获取密钥失败,响应解析错误: ".concat(err.message, ", response text: ")).concat;
|
|
289
|
-
return [
|
|
290
|
-
4,
|
|
291
|
-
jwkRes.text()
|
|
292
|
-
];
|
|
293
|
-
case 5:
|
|
294
|
-
throw new (_.apply(Error, [
|
|
295
|
-
void 0,
|
|
296
|
-
_2.apply(_1, [
|
|
297
|
-
_state.sent()
|
|
298
|
-
])
|
|
299
|
-
]));
|
|
300
|
-
case 6:
|
|
301
|
-
_ref = (JwkResponseJson === null || JwkResponseJson === void 0 ? void 0 : JwkResponseJson.data) || {}, keyId = _ref.keyId, privateKeyPkcs8 = _ref.privateKeyPkcs8;
|
|
302
|
-
if (!keyId || !privateKeyPkcs8) throw new Error("未获取到项目签名密钥, 请检查aud是否正确: ".concat(aud));
|
|
303
|
-
return [
|
|
304
|
-
2,
|
|
305
|
-
{
|
|
306
|
-
XFE_JWT_AUD: aud,
|
|
307
|
-
XFE_JWT_KEY_ID: keyId,
|
|
308
|
-
XFE_JWT_PRIVATE_KEY: privateKeyPkcs8
|
|
309
|
-
}
|
|
310
|
-
];
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
})();
|
|
82
|
+
var getJwtEnv = async () => {
|
|
83
|
+
const xfeConfig = loadXfeConfig();
|
|
84
|
+
if (!xfeConfig?.jwt) return {};
|
|
85
|
+
const { aud = "" } = xfeConfig.jwt;
|
|
86
|
+
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");
|
|
87
|
+
const jwkRes = await fetch(`https://app.eshetang.com/jwk?appId=${aud}`);
|
|
88
|
+
if (!jwkRes.ok) {
|
|
89
|
+
throw new Error(`\u8FDC\u7A0B\u83B7\u53D6\u5BC6\u94A5\u5931\u8D25: ${jwkRes.status} ${jwkRes.statusText}`);
|
|
90
|
+
}
|
|
91
|
+
let JwkResponseJson;
|
|
92
|
+
try {
|
|
93
|
+
JwkResponseJson = await jwkRes.json();
|
|
94
|
+
} catch (err) {
|
|
95
|
+
throw new Error(`\u8FDC\u7A0B\u83B7\u53D6\u5BC6\u94A5\u5931\u8D25\uFF0C\u54CD\u5E94\u89E3\u6790\u9519\u8BEF: ${err.message}, response text: ${await jwkRes.text()}`);
|
|
96
|
+
}
|
|
97
|
+
const { keyId, privateKeyPkcs8 } = JwkResponseJson?.data || {};
|
|
98
|
+
if (!keyId || !privateKeyPkcs8) throw new Error(`\u672A\u83B7\u53D6\u5230\u9879\u76EE\u7B7E\u540D\u5BC6\u94A5, \u8BF7\u68C0\u67E5aud\u662F\u5426\u6B63\u786E: ${aud}`);
|
|
99
|
+
return { XFE_JWT_AUD: aud, XFE_JWT_KEY_ID: keyId, XFE_JWT_PRIVATE_KEY: privateKeyPkcs8 };
|
|
314
100
|
};
|
|
315
101
|
// Annotate the CommonJS export names for ESM import in node:
|
|
316
102
|
0 && (module.exports = {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
103
|
+
configDeploy,
|
|
104
|
+
getJwtEnv,
|
|
105
|
+
loadXfeConfig
|
|
320
106
|
});
|
package/dist/config.mjs
CHANGED
|
@@ -1,2 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/config.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import yaml from "yaml";
|
|
5
|
+
var loadXfeConfig = (root = process.cwd()) => {
|
|
6
|
+
const xfeConfigPath = path.join(root, "xfe.json");
|
|
7
|
+
if (!fs.existsSync(xfeConfigPath)) {
|
|
8
|
+
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");
|
|
9
|
+
}
|
|
10
|
+
const xfeConfigContent = fs.readFileSync(xfeConfigPath, "utf8");
|
|
11
|
+
const config = JSON.parse(xfeConfigContent);
|
|
12
|
+
const renderMode = config.webapp?.renderMode;
|
|
13
|
+
if (renderMode !== void 0 && renderMode !== "client" && renderMode !== "server") {
|
|
14
|
+
throw new Error("xfe.json.webapp.renderMode \u53EA\u80FD\u4E3A client \u6216 server");
|
|
15
|
+
}
|
|
16
|
+
return config;
|
|
17
|
+
};
|
|
18
|
+
var configDeploy = () => {
|
|
19
|
+
const xfeConfig = loadXfeConfig();
|
|
20
|
+
if (!xfeConfig?.deploy) return;
|
|
21
|
+
const droneConfigFilePath = path.resolve(__dirname, "../deploy/.drone.yml");
|
|
22
|
+
fs.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
|
|
23
|
+
const valuesYamlFilePath = path.resolve(__dirname, "../deploy/helm/values.yaml");
|
|
24
|
+
const valuesYamlFile = fs.readFileSync(valuesYamlFilePath, "utf8");
|
|
25
|
+
const valuesYaml = yaml.parse(valuesYamlFile);
|
|
26
|
+
if (!valuesYaml.virtualService) valuesYaml.virtualService = {};
|
|
27
|
+
if (!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = { test: [], stage: [], prod: [] };
|
|
28
|
+
const {
|
|
29
|
+
virtualServiceEnabled = true,
|
|
30
|
+
hostsProd = [],
|
|
31
|
+
hostsStage = [],
|
|
32
|
+
hostsTest = [],
|
|
33
|
+
gateways = ["common-gateway-eshetang"]
|
|
34
|
+
} = xfeConfig.deploy;
|
|
35
|
+
const { targetK8s = "saas", targetNamespace = "" } = xfeConfig.deploy;
|
|
36
|
+
valuesYaml.virtualService.enabled = virtualServiceEnabled;
|
|
37
|
+
valuesYaml.virtualService.gateways = gateways;
|
|
38
|
+
valuesYaml.virtualService.hosts.prod = hostsProd;
|
|
39
|
+
valuesYaml.virtualService.hosts.stage = hostsStage;
|
|
40
|
+
valuesYaml.virtualService.hosts.test = hostsTest;
|
|
41
|
+
valuesYaml.targetK8s = targetK8s;
|
|
42
|
+
valuesYaml.namespace = targetNamespace;
|
|
43
|
+
const valuesYamlStr = yaml.stringify(valuesYaml, { defaultStringType: "QUOTE_SINGLE", defaultKeyType: "PLAIN" });
|
|
44
|
+
fs.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
45
|
+
};
|
|
46
|
+
var getJwtEnv = async () => {
|
|
47
|
+
const xfeConfig = loadXfeConfig();
|
|
48
|
+
if (!xfeConfig?.jwt) return {};
|
|
49
|
+
const { aud = "" } = xfeConfig.jwt;
|
|
50
|
+
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");
|
|
51
|
+
const jwkRes = await fetch(`https://app.eshetang.com/jwk?appId=${aud}`);
|
|
52
|
+
if (!jwkRes.ok) {
|
|
53
|
+
throw new Error(`\u8FDC\u7A0B\u83B7\u53D6\u5BC6\u94A5\u5931\u8D25: ${jwkRes.status} ${jwkRes.statusText}`);
|
|
54
|
+
}
|
|
55
|
+
let JwkResponseJson;
|
|
56
|
+
try {
|
|
57
|
+
JwkResponseJson = await jwkRes.json();
|
|
58
|
+
} catch (err) {
|
|
59
|
+
throw new Error(`\u8FDC\u7A0B\u83B7\u53D6\u5BC6\u94A5\u5931\u8D25\uFF0C\u54CD\u5E94\u89E3\u6790\u9519\u8BEF: ${err.message}, response text: ${await jwkRes.text()}`);
|
|
60
|
+
}
|
|
61
|
+
const { keyId, privateKeyPkcs8 } = JwkResponseJson?.data || {};
|
|
62
|
+
if (!keyId || !privateKeyPkcs8) throw new Error(`\u672A\u83B7\u53D6\u5230\u9879\u76EE\u7B7E\u540D\u5BC6\u94A5, \u8BF7\u68C0\u67E5aud\u662F\u5426\u6B63\u786E: ${aud}`);
|
|
63
|
+
return { XFE_JWT_AUD: aud, XFE_JWT_KEY_ID: keyId, XFE_JWT_PRIVATE_KEY: privateKeyPkcs8 };
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
configDeploy,
|
|
67
|
+
getJwtEnv,
|
|
68
|
+
loadXfeConfig
|
|
69
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type FrameworkPaths = {
|
|
2
|
+
appDirectory: string;
|
|
3
|
+
rootDirectory: string;
|
|
4
|
+
viteConfig: string;
|
|
5
|
+
typeScriptConfig: string;
|
|
6
|
+
};
|
|
7
|
+
declare const getFrameworkRoot: (projectRoot: string) => string;
|
|
8
|
+
declare const prepareFramework: (projectRoot?: string) => FrameworkPaths;
|
|
9
|
+
|
|
10
|
+
export { type FrameworkPaths, getFrameworkRoot, prepareFramework };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type FrameworkPaths = {
|
|
2
|
+
appDirectory: string;
|
|
3
|
+
rootDirectory: string;
|
|
4
|
+
viteConfig: string;
|
|
5
|
+
typeScriptConfig: string;
|
|
6
|
+
};
|
|
7
|
+
declare const getFrameworkRoot: (projectRoot: string) => string;
|
|
8
|
+
declare const prepareFramework: (projectRoot?: string) => FrameworkPaths;
|
|
9
|
+
|
|
10
|
+
export { type FrameworkPaths, getFrameworkRoot, prepareFramework };
|