@xfe-repo/web-app 1.6.4 → 2.0.0-beta.2
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 +118 -1
- package/client.d.ts +1 -0
- package/deploy/.drone.yml +13 -4
- package/deploy/Dockerfile +15 -6
- package/deploy/helm/templates/deployment.yaml +5 -18
- package/deploy/helm/templates/svc.yaml +1 -1
- package/dist/cli.js +577 -416
- package/dist/cli.mjs +562 -256
- package/dist/config.d.mts +30 -6
- package/dist/config.d.ts +30 -6
- package/dist/config.js +142 -298
- package/dist/config.mjs +124 -2
- package/dist/framework.d.mts +10 -0
- package/dist/framework.d.ts +10 -0
- package/dist/framework.js +220 -0
- package/dist/framework.mjs +182 -0
- package/dist/node-dev.d.mts +2 -0
- package/dist/node-dev.d.ts +2 -0
- package/dist/node-dev.js +358 -0
- package/dist/node-dev.mjs +332 -0
- package/dist/node.d.mts +27 -0
- package/dist/node.d.ts +27 -0
- package/dist/node.js +381 -0
- package/dist/node.mjs +343 -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 +111 -0
- package/dist/react-router-config.mjs +77 -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 +10 -0
- package/dist/vite.d.ts +10 -0
- package/dist/vite.js +182 -0
- package/dist/vite.mjs +146 -0
- package/package.json +27 -72
- 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 -737
- 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.d.mts
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type WebAppConfig = {
|
|
2
|
+
basename?: string;
|
|
3
|
+
/** 相对于项目根目录的输出路径,默认 dist;旧项目可显式设置 build。 */
|
|
4
|
+
buildDirectory?: string;
|
|
5
|
+
host?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
/** 渲染方式由 XFE 转换为底层框架配置;省略时兼容已有服务端应用。 */
|
|
8
|
+
renderMode?: 'client' | 'server';
|
|
9
|
+
/** 项目内默认导出 Node 工厂的源码入口;省略时保留原有 SPA / SSR 启动。 */
|
|
10
|
+
serverEntry?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
lang?: string;
|
|
13
|
+
themeColor?: string;
|
|
14
|
+
};
|
|
15
|
+
type XfeConfig = Record<string, any> & {
|
|
16
|
+
webapp?: WebAppConfig;
|
|
17
|
+
};
|
|
18
|
+
type JwtEnv = {
|
|
19
|
+
XFE_JWT_AUD: string;
|
|
5
20
|
XFE_JWT_KEY_ID: string;
|
|
6
21
|
XFE_JWT_PRIVATE_KEY: string;
|
|
7
|
-
}
|
|
22
|
+
};
|
|
23
|
+
/** 读取业务配置,并在构建或启动前拒绝无效的渲染方式和输出路径。 */
|
|
24
|
+
declare const loadXfeConfig: (root?: string) => XfeConfig;
|
|
25
|
+
/** 返回构建和启动共用的绝对路径,防止清空项目根目录或框架输入目录。 */
|
|
26
|
+
declare const getBuildDirectory: (projectRoot: string, webapp?: WebAppConfig) => string;
|
|
27
|
+
/** 生产仅校验入口约定而不读取源码,构建阶段由编译器检查文件存在。 */
|
|
28
|
+
declare const getServerEntry: (projectRoot: string, webapp?: WebAppConfig) => string | undefined;
|
|
29
|
+
/** 将输出目录传给 Docker 构建,并沿用现有的集群、域名与 Helm 配置。 */
|
|
30
|
+
declare const configDeploy: () => void;
|
|
31
|
+
declare const getJwtEnv: () => Promise<Partial<JwtEnv>>;
|
|
8
32
|
|
|
9
|
-
export { configDeploy, getJwtEnv, loadXfeConfig };
|
|
33
|
+
export { type JwtEnv, type WebAppConfig, type XfeConfig, configDeploy, getBuildDirectory, getJwtEnv, getServerEntry, loadXfeConfig };
|
package/dist/config.d.ts
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type WebAppConfig = {
|
|
2
|
+
basename?: string;
|
|
3
|
+
/** 相对于项目根目录的输出路径,默认 dist;旧项目可显式设置 build。 */
|
|
4
|
+
buildDirectory?: string;
|
|
5
|
+
host?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
/** 渲染方式由 XFE 转换为底层框架配置;省略时兼容已有服务端应用。 */
|
|
8
|
+
renderMode?: 'client' | 'server';
|
|
9
|
+
/** 项目内默认导出 Node 工厂的源码入口;省略时保留原有 SPA / SSR 启动。 */
|
|
10
|
+
serverEntry?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
lang?: string;
|
|
13
|
+
themeColor?: string;
|
|
14
|
+
};
|
|
15
|
+
type XfeConfig = Record<string, any> & {
|
|
16
|
+
webapp?: WebAppConfig;
|
|
17
|
+
};
|
|
18
|
+
type JwtEnv = {
|
|
19
|
+
XFE_JWT_AUD: string;
|
|
5
20
|
XFE_JWT_KEY_ID: string;
|
|
6
21
|
XFE_JWT_PRIVATE_KEY: string;
|
|
7
|
-
}
|
|
22
|
+
};
|
|
23
|
+
/** 读取业务配置,并在构建或启动前拒绝无效的渲染方式和输出路径。 */
|
|
24
|
+
declare const loadXfeConfig: (root?: string) => XfeConfig;
|
|
25
|
+
/** 返回构建和启动共用的绝对路径,防止清空项目根目录或框架输入目录。 */
|
|
26
|
+
declare const getBuildDirectory: (projectRoot: string, webapp?: WebAppConfig) => string;
|
|
27
|
+
/** 生产仅校验入口约定而不读取源码,构建阶段由编译器检查文件存在。 */
|
|
28
|
+
declare const getServerEntry: (projectRoot: string, webapp?: WebAppConfig) => string | undefined;
|
|
29
|
+
/** 将输出目录传给 Docker 构建,并沿用现有的集群、域名与 Helm 配置。 */
|
|
30
|
+
declare const configDeploy: () => void;
|
|
31
|
+
declare const getJwtEnv: () => Promise<Partial<JwtEnv>>;
|
|
8
32
|
|
|
9
|
-
export { configDeploy, getJwtEnv, loadXfeConfig };
|
|
33
|
+
export { type JwtEnv, type WebAppConfig, type XfeConfig, configDeploy, getBuildDirectory, getJwtEnv, getServerEntry, loadXfeConfig };
|
package/dist/config.js
CHANGED
|
@@ -1,320 +1,164 @@
|
|
|
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
|
-
});
|
|
145
|
-
};
|
|
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);
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
186
11
|
};
|
|
187
|
-
var
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
},
|
|
201
|
-
loadXfeConfig: function loadXfeConfig1() {
|
|
202
|
-
return loadXfeConfig;
|
|
203
|
-
}
|
|
33
|
+
configDeploy: () => configDeploy,
|
|
34
|
+
getBuildDirectory: () => getBuildDirectory,
|
|
35
|
+
getJwtEnv: () => getJwtEnv,
|
|
36
|
+
getServerEntry: () => getServerEntry,
|
|
37
|
+
loadXfeConfig: () => loadXfeConfig
|
|
204
38
|
});
|
|
205
39
|
module.exports = __toCommonJS(config_exports);
|
|
206
|
-
var
|
|
207
|
-
var
|
|
40
|
+
var import_node_fs = __toESM(require("fs"));
|
|
41
|
+
var import_node_path = __toESM(require("path"));
|
|
42
|
+
var import_node_url = require("url");
|
|
208
43
|
var import_yaml = __toESM(require("yaml"));
|
|
209
|
-
var
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
44
|
+
var import_meta = {};
|
|
45
|
+
var DEFAULT_BUILD_DIRECTORY = "dist";
|
|
46
|
+
var BUILD_DIRECTORY_ARGUMENT = "XFE_BUILD_DIRECTORY";
|
|
47
|
+
var protectedDirectories = /* @__PURE__ */ new Set(["src", "types", "public", "node_modules", ".git"]);
|
|
48
|
+
var configDirectory = typeof __dirname === "string" ? __dirname : import_node_path.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
49
|
+
var loadXfeConfig = (root = process.cwd()) => {
|
|
50
|
+
const xfeConfigPath = import_node_path.default.join(root, "xfe.json");
|
|
51
|
+
if (!import_node_fs.default.existsSync(xfeConfigPath)) {
|
|
52
|
+
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");
|
|
53
|
+
}
|
|
54
|
+
const xfeConfigContent = import_node_fs.default.readFileSync(xfeConfigPath, "utf8");
|
|
55
|
+
const config = JSON.parse(xfeConfigContent);
|
|
56
|
+
const renderMode = config.webapp?.renderMode;
|
|
57
|
+
if (renderMode !== void 0 && renderMode !== "client" && renderMode !== "server") {
|
|
58
|
+
throw new Error("xfe.json.webapp.renderMode \u53EA\u80FD\u4E3A client \u6216 server");
|
|
59
|
+
}
|
|
60
|
+
getBuildDirectory(root, config.webapp);
|
|
61
|
+
getServerEntry(root, config.webapp);
|
|
62
|
+
return config;
|
|
63
|
+
};
|
|
64
|
+
var getBuildDirectory = (projectRoot, webapp = {}) => {
|
|
65
|
+
const configured = webapp?.buildDirectory === void 0 ? DEFAULT_BUILD_DIRECTORY : webapp.buildDirectory;
|
|
66
|
+
if (typeof configured !== "string" || !configured.trim() || /[\0\r\n]/.test(configured)) {
|
|
67
|
+
throw new Error("xfe.json.webapp.buildDirectory \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u5355\u884C\u5B57\u7B26\u4E32");
|
|
68
|
+
}
|
|
69
|
+
const directory = configured.trim().replaceAll("\\", "/");
|
|
70
|
+
const root = import_node_path.default.resolve(projectRoot);
|
|
71
|
+
const output = import_node_path.default.resolve(root, directory);
|
|
72
|
+
const relative = import_node_path.default.relative(root, output);
|
|
73
|
+
const [firstDirectory = ""] = relative.split(import_node_path.default.sep);
|
|
74
|
+
const escapesProject = import_node_path.default.isAbsolute(directory) || Boolean(import_node_path.default.win32.parse(directory).root) || firstDirectory === "..";
|
|
75
|
+
const overwritesInput = !relative || protectedDirectories.has(firstDirectory.toLowerCase());
|
|
76
|
+
if (escapesProject || overwritesInput) {
|
|
77
|
+
throw new Error("xfe.json.webapp.buildDirectory \u5FC5\u987B\u662F\u9879\u76EE\u5185\u72EC\u7ACB\u7684\u8F93\u51FA\u76EE\u5F55\uFF0C\u4E0D\u80FD\u8986\u76D6\u9879\u76EE\u3001\u6E90\u7801\u6216\u4F9D\u8D56");
|
|
78
|
+
}
|
|
79
|
+
let currentDirectory = root;
|
|
80
|
+
for (const segment of relative.split(import_node_path.default.sep)) {
|
|
81
|
+
currentDirectory = import_node_path.default.join(currentDirectory, segment);
|
|
82
|
+
if (import_node_fs.default.lstatSync(currentDirectory, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
83
|
+
throw new Error("xfe.json.webapp.buildDirectory \u4E0D\u80FD\u7ECF\u8FC7\u7B26\u53F7\u94FE\u63A5\uFF0C\u4EE5\u514D\u6E05\u7406\u5176\u4ED6\u76EE\u5F55");
|
|
213
84
|
}
|
|
214
|
-
|
|
215
|
-
|
|
85
|
+
}
|
|
86
|
+
return output;
|
|
87
|
+
};
|
|
88
|
+
var getServerEntry = (projectRoot, webapp = {}) => {
|
|
89
|
+
const entry = webapp?.serverEntry;
|
|
90
|
+
if (entry === void 0) return;
|
|
91
|
+
if (typeof entry !== "string" || !entry.trim() || /[\0\r\n]/.test(entry)) {
|
|
92
|
+
throw new Error("xfe.json.webapp.serverEntry \u5FC5\u987B\u662F\u9879\u76EE\u5185\u7684 TypeScript / JavaScript \u76F8\u5BF9\u8DEF\u5F84");
|
|
93
|
+
}
|
|
94
|
+
const normalized = entry.trim().replaceAll("\\", "/");
|
|
95
|
+
const absolute = import_node_path.default.resolve(projectRoot, normalized);
|
|
96
|
+
const relative = import_node_path.default.relative(import_node_path.default.resolve(projectRoot), absolute);
|
|
97
|
+
const outside = Boolean(import_node_path.default.win32.parse(normalized).root) || relative.split(import_node_path.default.sep)[0] === "..";
|
|
98
|
+
if (outside || !/\.(?:[jt]sx?|m[jt]s)$/.test(relative)) {
|
|
99
|
+
throw new Error("xfe.json.webapp.serverEntry \u5FC5\u987B\u662F\u9879\u76EE\u5185\u7684 TypeScript / JavaScript \u76F8\u5BF9\u8DEF\u5F84");
|
|
100
|
+
}
|
|
101
|
+
return absolute;
|
|
216
102
|
};
|
|
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
|
-
|
|
245
|
-
|
|
246
|
-
|
|
103
|
+
var configDeploy = () => {
|
|
104
|
+
const xfeConfig = loadXfeConfig();
|
|
105
|
+
if (!xfeConfig?.deploy) return;
|
|
106
|
+
const projectRoot = process.cwd();
|
|
107
|
+
const buildDirectory = import_node_path.default.relative(projectRoot, getBuildDirectory(projectRoot, xfeConfig.webapp)).replaceAll(import_node_path.default.sep, "/");
|
|
108
|
+
const droneConfigFilePath = import_node_path.default.resolve(configDirectory, "../deploy/.drone.yml");
|
|
109
|
+
const droneTarget = import_node_path.default.resolve(projectRoot, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
|
|
110
|
+
const defaultArgument = JSON.stringify(`${BUILD_DIRECTORY_ARGUMENT}=${DEFAULT_BUILD_DIRECTORY}`);
|
|
111
|
+
const configuredArgument = JSON.stringify(`${BUILD_DIRECTORY_ARGUMENT}=${buildDirectory}`);
|
|
112
|
+
const droneConfig = import_node_fs.default.readFileSync(droneConfigFilePath, "utf8").replace(defaultArgument, configuredArgument);
|
|
113
|
+
import_node_fs.default.mkdirSync(import_node_path.default.dirname(droneTarget), { recursive: true });
|
|
114
|
+
import_node_fs.default.writeFileSync(droneTarget, droneConfig);
|
|
115
|
+
const valuesYamlFilePath = import_node_path.default.resolve(configDirectory, "../deploy/helm/values.yaml");
|
|
116
|
+
const valuesYamlFile = import_node_fs.default.readFileSync(valuesYamlFilePath, "utf8");
|
|
117
|
+
const valuesYaml = import_yaml.default.parse(valuesYamlFile);
|
|
118
|
+
if (!valuesYaml.virtualService) valuesYaml.virtualService = {};
|
|
119
|
+
if (!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = { test: [], stage: [], prod: [] };
|
|
120
|
+
const {
|
|
121
|
+
virtualServiceEnabled = true,
|
|
122
|
+
hostsProd = [],
|
|
123
|
+
hostsStage = [],
|
|
124
|
+
hostsTest = [],
|
|
125
|
+
gateways = ["common-gateway-eshetang"]
|
|
126
|
+
} = xfeConfig.deploy;
|
|
127
|
+
const { targetK8s = "saas", targetNamespace = "" } = xfeConfig.deploy;
|
|
128
|
+
valuesYaml.virtualService.enabled = virtualServiceEnabled;
|
|
129
|
+
valuesYaml.virtualService.gateways = gateways;
|
|
130
|
+
valuesYaml.virtualService.hosts.prod = hostsProd;
|
|
131
|
+
valuesYaml.virtualService.hosts.stage = hostsStage;
|
|
132
|
+
valuesYaml.virtualService.hosts.test = hostsTest;
|
|
133
|
+
valuesYaml.targetK8s = targetK8s;
|
|
134
|
+
valuesYaml.namespace = targetNamespace;
|
|
135
|
+
const valuesYamlStr = import_yaml.default.stringify(valuesYaml, { defaultStringType: "QUOTE_SINGLE", defaultKeyType: "PLAIN" });
|
|
136
|
+
import_node_fs.default.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
247
137
|
};
|
|
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
|
-
})();
|
|
138
|
+
var getJwtEnv = async () => {
|
|
139
|
+
const xfeConfig = loadXfeConfig();
|
|
140
|
+
if (!xfeConfig?.jwt) return {};
|
|
141
|
+
const { aud = "" } = xfeConfig.jwt;
|
|
142
|
+
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");
|
|
143
|
+
const jwkRes = await fetch(`https://app.eshetang.com/jwk?appId=${aud}`);
|
|
144
|
+
if (!jwkRes.ok) {
|
|
145
|
+
throw new Error(`\u8FDC\u7A0B\u83B7\u53D6\u5BC6\u94A5\u5931\u8D25: ${jwkRes.status} ${jwkRes.statusText}`);
|
|
146
|
+
}
|
|
147
|
+
let JwkResponseJson;
|
|
148
|
+
try {
|
|
149
|
+
JwkResponseJson = await jwkRes.json();
|
|
150
|
+
} catch (err) {
|
|
151
|
+
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()}`);
|
|
152
|
+
}
|
|
153
|
+
const { keyId, privateKeyPkcs8 } = JwkResponseJson?.data || {};
|
|
154
|
+
if (!keyId || !privateKeyPkcs8) throw new Error(`\u672A\u83B7\u53D6\u5230\u9879\u76EE\u7B7E\u540D\u5BC6\u94A5, \u8BF7\u68C0\u67E5aud\u662F\u5426\u6B63\u786E: ${aud}`);
|
|
155
|
+
return { XFE_JWT_AUD: aud, XFE_JWT_KEY_ID: keyId, XFE_JWT_PRIVATE_KEY: privateKeyPkcs8 };
|
|
314
156
|
};
|
|
315
157
|
// Annotate the CommonJS export names for ESM import in node:
|
|
316
158
|
0 && (module.exports = {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
159
|
+
configDeploy,
|
|
160
|
+
getBuildDirectory,
|
|
161
|
+
getJwtEnv,
|
|
162
|
+
getServerEntry,
|
|
163
|
+
loadXfeConfig
|
|
320
164
|
});
|