@xfe-repo/web-app 1.6.3 → 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.
Files changed (48) hide show
  1. package/README.md +60 -1
  2. package/client.d.ts +1 -0
  3. package/deploy/.drone.yml +11 -4
  4. package/deploy/Dockerfile +14 -6
  5. package/deploy/helm/templates/deployment.yaml +5 -18
  6. package/deploy/helm/templates/svc.yaml +1 -1
  7. package/dist/cli.js +275 -413
  8. package/dist/cli.mjs +273 -267
  9. package/dist/config.d.mts +20 -6
  10. package/dist/config.d.ts +20 -6
  11. package/dist/config.js +83 -297
  12. package/dist/config.mjs +69 -2
  13. package/dist/framework.d.mts +10 -0
  14. package/dist/framework.d.ts +10 -0
  15. package/dist/framework.js +174 -0
  16. package/dist/framework.mjs +137 -0
  17. package/dist/react-router-config.d.mts +11 -0
  18. package/dist/react-router-config.d.ts +11 -0
  19. package/dist/react-router-config.js +66 -0
  20. package/dist/react-router-config.mjs +35 -0
  21. package/dist/root.d.mts +17 -0
  22. package/dist/root.d.ts +17 -0
  23. package/dist/root.js +61 -0
  24. package/dist/root.mjs +34 -0
  25. package/dist/serve.d.mts +10 -0
  26. package/dist/serve.d.ts +10 -0
  27. package/dist/serve.js +71 -0
  28. package/dist/serve.mjs +36 -0
  29. package/dist/vite.d.mts +9 -0
  30. package/dist/vite.d.ts +9 -0
  31. package/dist/vite.js +135 -0
  32. package/dist/vite.mjs +100 -0
  33. package/package.json +22 -71
  34. package/tsconfig.json +4 -1
  35. package/config/env.js +0 -104
  36. package/config/getHttpsConfig.js +0 -66
  37. package/config/jest/babelTransform.js +0 -29
  38. package/config/jest/cssTransform.js +0 -14
  39. package/config/jest/fileTransform.js +0 -40
  40. package/config/modules.js +0 -133
  41. package/config/paths.js +0 -65
  42. package/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
  43. package/config/webpack/webpack.config.js +0 -737
  44. package/config/webpack/webpackDevServer.config.js +0 -122
  45. package/deploy/nginx.conf +0 -62
  46. package/dist/chunk-75BJNL7E.mjs +0 -239
  47. package/scripts/build.js +0 -217
  48. 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 = function __export(target, all) {
141
- for(var name in all)__defProp(target, name, {
142
- get: all[name],
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 = function __copyProps(to, from, except, desc) {
147
- if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
148
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
149
- try {
150
- var _loop = function() {
151
- var key = _step.value;
152
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
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
- configDeploy: function configDeploy1() {
196
- return configDeploy;
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 = function loadXfeConfig() {
210
- var xfeConfigPath = "./xfe.json";
211
- if (!import_fs.default.existsSync(xfeConfigPath)) {
212
- 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");
213
- }
214
- var xfeConfigContent = import_fs.default.readFileSync(xfeConfigPath, "utf8");
215
- return JSON.parse(xfeConfigContent);
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 = function configDeploy() {
218
- var xfeConfig = loadXfeConfig();
219
- if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.deploy)) return;
220
- var droneConfigFilePath = import_path.default.resolve(__dirname, "../deploy/.drone.yml");
221
- import_fs.default.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
222
- var valuesYamlFilePath = import_path.default.resolve(__dirname, "../deploy/helm/values.yaml");
223
- var valuesYamlFile = import_fs.default.readFileSync(valuesYamlFilePath, "utf8");
224
- var valuesYaml = import_yaml.default.parse(valuesYamlFile);
225
- if (!valuesYaml.virtualService) valuesYaml.virtualService = {};
226
- if (!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = {
227
- test: [],
228
- stage: [],
229
- prod: []
230
- };
231
- 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 ? [
232
- "common-gateway-eshetang"
233
- ] : _xfeConfig_deploy_gateways;
234
- 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;
235
- valuesYaml.virtualService.enabled = virtualServiceEnabled;
236
- valuesYaml.virtualService.gateways = gateways;
237
- valuesYaml.virtualService.hosts.prod = hostsProd;
238
- valuesYaml.virtualService.hosts.stage = hostsStage;
239
- valuesYaml.virtualService.hosts.test = hostsTest;
240
- valuesYaml.targetK8s = targetK8s;
241
- valuesYaml.namespace = targetNamespace;
242
- var valuesYamlStr = import_yaml.default.stringify(valuesYaml, {
243
- defaultStringType: "QUOTE_SINGLE",
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 = function getJwtEnv() {
249
- return _async_to_generator(function() {
250
- var xfeConfig, _xfeConfig_jwt, _xfeConfig_jwt_aud, aud, jwkRes, JwkResponseJson, err, _, _1, _2, _ref, keyId, privateKeyPkcs8;
251
- return _ts_generator(this, function(_state) {
252
- switch(_state.label){
253
- case 0:
254
- xfeConfig = loadXfeConfig();
255
- 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");
256
- _xfeConfig_jwt = xfeConfig.jwt, _xfeConfig_jwt_aud = _xfeConfig_jwt.aud, aud = _xfeConfig_jwt_aud === void 0 ? "" : _xfeConfig_jwt_aud;
257
- 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");
258
- return [
259
- 4,
260
- fetch("https://app.eshetang.com/jwk?appId=".concat(aud))
261
- ];
262
- case 1:
263
- jwkRes = _state.sent();
264
- if (!jwkRes.ok) {
265
- throw new Error("远程获取密钥失败: ".concat(jwkRes.status, " ").concat(jwkRes.statusText));
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
- configDeploy: configDeploy,
318
- getJwtEnv: getJwtEnv,
319
- loadXfeConfig: loadXfeConfig
103
+ configDeploy,
104
+ getJwtEnv,
105
+ loadXfeConfig
320
106
  });
package/dist/config.mjs CHANGED
@@ -1,2 +1,69 @@
1
- import { configDeploy, getJwtEnv, loadXfeConfig } from "./chunk-75BJNL7E.mjs";
2
- export { configDeploy, getJwtEnv, loadXfeConfig };
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 };