@xfe-repo/mini-app 0.1.13 → 0.1.16
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/config/index.ts +15 -4
- package/dist/chunk-TFIAHV2G.mjs +238 -0
- package/dist/cli.js +153 -27
- package/dist/cli.mjs +199 -24
- package/dist/config.d.mts +8 -2
- package/dist/config.d.ts +8 -2
- package/dist/config.js +214 -7
- package/dist/config.mjs +2 -2
- package/package.json +3 -3
- package/dist/chunk-EQD7HO6T.mjs +0 -39
package/config/index.ts
CHANGED
|
@@ -51,14 +51,23 @@ export default defineConfig<'webpack5'>(async (merge) => {
|
|
|
51
51
|
ignoreOrder: true,
|
|
52
52
|
},
|
|
53
53
|
postcss: {
|
|
54
|
+
// 尺寸单位转换配置
|
|
54
55
|
pxtransform: {
|
|
55
56
|
enable: true,
|
|
56
57
|
config: {}
|
|
57
58
|
},
|
|
59
|
+
// css引用本地资源内联配置
|
|
60
|
+
url: {
|
|
61
|
+
enable: true,
|
|
62
|
+
config: {
|
|
63
|
+
limit: 10240,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
// 开启 css modules 功能
|
|
58
67
|
cssModules: {
|
|
59
|
-
enable: true,
|
|
68
|
+
enable: true,
|
|
60
69
|
config: {
|
|
61
|
-
namingPattern: 'module',
|
|
70
|
+
namingPattern: 'module',
|
|
62
71
|
generateScopedName: '[name]__[local]___[hash:base64:5]'
|
|
63
72
|
}
|
|
64
73
|
}
|
|
@@ -83,14 +92,16 @@ export default defineConfig<'webpack5'>(async (merge) => {
|
|
|
83
92
|
chunkFilename: 'css/[name].[chunkhash].css'
|
|
84
93
|
},
|
|
85
94
|
postcss: {
|
|
95
|
+
// 自动添加浏览器前缀
|
|
86
96
|
autoprefixer: {
|
|
87
97
|
enable: true,
|
|
88
98
|
config: {}
|
|
89
99
|
},
|
|
100
|
+
// 开启 css modules 功能
|
|
90
101
|
cssModules: {
|
|
91
|
-
enable: true,
|
|
102
|
+
enable: true,
|
|
92
103
|
config: {
|
|
93
|
-
namingPattern: 'module',
|
|
104
|
+
namingPattern: 'module',
|
|
94
105
|
generateScopedName: '[name]__[local]___[hash:base64:5]'
|
|
95
106
|
}
|
|
96
107
|
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
// src/config.ts
|
|
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 _ts_generator(thisArg, body) {
|
|
32
|
+
var f, y, t, g, _ = {
|
|
33
|
+
label: 0,
|
|
34
|
+
sent: function() {
|
|
35
|
+
if (t[0] & 1) throw t[1];
|
|
36
|
+
return t[1];
|
|
37
|
+
},
|
|
38
|
+
trys: [],
|
|
39
|
+
ops: []
|
|
40
|
+
};
|
|
41
|
+
return g = {
|
|
42
|
+
next: verb(0),
|
|
43
|
+
"throw": verb(1),
|
|
44
|
+
"return": verb(2)
|
|
45
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
46
|
+
return this;
|
|
47
|
+
}), g;
|
|
48
|
+
function verb(n) {
|
|
49
|
+
return function(v) {
|
|
50
|
+
return step([
|
|
51
|
+
n,
|
|
52
|
+
v
|
|
53
|
+
]);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function step(op) {
|
|
57
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
+
while(_)try {
|
|
59
|
+
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;
|
|
60
|
+
if (y = 0, t) op = [
|
|
61
|
+
op[0] & 2,
|
|
62
|
+
t.value
|
|
63
|
+
];
|
|
64
|
+
switch(op[0]){
|
|
65
|
+
case 0:
|
|
66
|
+
case 1:
|
|
67
|
+
t = op;
|
|
68
|
+
break;
|
|
69
|
+
case 4:
|
|
70
|
+
_.label++;
|
|
71
|
+
return {
|
|
72
|
+
value: op[1],
|
|
73
|
+
done: false
|
|
74
|
+
};
|
|
75
|
+
case 5:
|
|
76
|
+
_.label++;
|
|
77
|
+
y = op[1];
|
|
78
|
+
op = [
|
|
79
|
+
0
|
|
80
|
+
];
|
|
81
|
+
continue;
|
|
82
|
+
case 7:
|
|
83
|
+
op = _.ops.pop();
|
|
84
|
+
_.trys.pop();
|
|
85
|
+
continue;
|
|
86
|
+
default:
|
|
87
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
88
|
+
_ = 0;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
92
|
+
_.label = op[1];
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
96
|
+
_.label = t[1];
|
|
97
|
+
t = op;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (t && _.label < t[2]) {
|
|
101
|
+
_.label = t[2];
|
|
102
|
+
_.ops.push(op);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
if (t[2]) _.ops.pop();
|
|
106
|
+
_.trys.pop();
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
op = body.call(thisArg, _);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
op = [
|
|
112
|
+
6,
|
|
113
|
+
e
|
|
114
|
+
];
|
|
115
|
+
y = 0;
|
|
116
|
+
} finally{
|
|
117
|
+
f = t = 0;
|
|
118
|
+
}
|
|
119
|
+
if (op[0] & 5) throw op[1];
|
|
120
|
+
return {
|
|
121
|
+
value: op[0] ? op[1] : void 0,
|
|
122
|
+
done: true
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
import path from "path";
|
|
127
|
+
import fs from "fs";
|
|
128
|
+
import yaml from "yaml";
|
|
129
|
+
var loadXfeConfig = function() {
|
|
130
|
+
var xfeConfigPath = "./xfe.json";
|
|
131
|
+
if (!fs.existsSync(xfeConfigPath)) {
|
|
132
|
+
throw new Error("xfe.json 配置文件不存在,请在项目根目录下创建该文件。");
|
|
133
|
+
}
|
|
134
|
+
var xfeConfigContent = fs.readFileSync(xfeConfigPath, "utf8");
|
|
135
|
+
return JSON.parse(xfeConfigContent);
|
|
136
|
+
};
|
|
137
|
+
var configDeploy = function() {
|
|
138
|
+
var xfeConfig = loadXfeConfig();
|
|
139
|
+
if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.deploy)) return;
|
|
140
|
+
var droneConfigFilePath = path.resolve(__dirname, "../deploy/.drone.yml");
|
|
141
|
+
fs.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
|
|
142
|
+
var valuesYamlFilePath = path.resolve(__dirname, "../deploy/helm/values.yaml");
|
|
143
|
+
var valuesYamlFile = fs.readFileSync(valuesYamlFilePath, "utf8");
|
|
144
|
+
var valuesYaml = yaml.parse(valuesYamlFile);
|
|
145
|
+
if (!valuesYaml.virtualService) valuesYaml.virtualService = {};
|
|
146
|
+
if (!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = {
|
|
147
|
+
test: [],
|
|
148
|
+
stage: [],
|
|
149
|
+
prod: []
|
|
150
|
+
};
|
|
151
|
+
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 ? [
|
|
152
|
+
"common-gateway-eshetang"
|
|
153
|
+
] : _xfeConfig_deploy_gateways;
|
|
154
|
+
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;
|
|
155
|
+
valuesYaml.virtualService.enabled = virtualServiceEnabled;
|
|
156
|
+
valuesYaml.virtualService.gateways = gateways;
|
|
157
|
+
valuesYaml.virtualService.hosts.prod = hostsProd;
|
|
158
|
+
valuesYaml.virtualService.hosts.stage = hostsStage;
|
|
159
|
+
valuesYaml.virtualService.hosts.test = hostsTest;
|
|
160
|
+
valuesYaml.targetK8s = targetK8s;
|
|
161
|
+
valuesYaml.namespace = targetNamespace;
|
|
162
|
+
var valuesYamlStr = yaml.stringify(valuesYaml, {
|
|
163
|
+
defaultStringType: "QUOTE_SINGLE",
|
|
164
|
+
defaultKeyType: "PLAIN"
|
|
165
|
+
});
|
|
166
|
+
fs.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
167
|
+
};
|
|
168
|
+
var getJwtEnv = function() {
|
|
169
|
+
var _ref = _async_to_generator(function() {
|
|
170
|
+
var xfeConfig, _xfeConfig_jwt, _xfeConfig_jwt_aud, aud, jwkRes, JwkResponseJson, err, _, _1, _2, _ref, keyId, privateKeyPkcs8;
|
|
171
|
+
return _ts_generator(this, function(_state) {
|
|
172
|
+
switch(_state.label){
|
|
173
|
+
case 0:
|
|
174
|
+
xfeConfig = loadXfeConfig();
|
|
175
|
+
if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.jwt)) throw new Error("xfe.json 中未配置 jwt 信息,请检查配置文件。");
|
|
176
|
+
_xfeConfig_jwt = xfeConfig.jwt, _xfeConfig_jwt_aud = _xfeConfig_jwt.aud, aud = _xfeConfig_jwt_aud === void 0 ? "" : _xfeConfig_jwt_aud;
|
|
177
|
+
if (!aud) throw new Error("xfe.json 中的 jwt 配置不完整,请确保包含 aud 字段。");
|
|
178
|
+
return [
|
|
179
|
+
4,
|
|
180
|
+
fetch("https://app.eshetang.com/jwk?appId=".concat(aud))
|
|
181
|
+
];
|
|
182
|
+
case 1:
|
|
183
|
+
jwkRes = _state.sent();
|
|
184
|
+
if (!jwkRes.ok) {
|
|
185
|
+
throw new Error("远程获取密钥失败: ".concat(jwkRes.status, " ").concat(jwkRes.statusText));
|
|
186
|
+
}
|
|
187
|
+
_state.label = 2;
|
|
188
|
+
case 2:
|
|
189
|
+
_state.trys.push([
|
|
190
|
+
2,
|
|
191
|
+
4,
|
|
192
|
+
,
|
|
193
|
+
6
|
|
194
|
+
]);
|
|
195
|
+
return [
|
|
196
|
+
4,
|
|
197
|
+
jwkRes.json()
|
|
198
|
+
];
|
|
199
|
+
case 3:
|
|
200
|
+
JwkResponseJson = _state.sent();
|
|
201
|
+
return [
|
|
202
|
+
3,
|
|
203
|
+
6
|
|
204
|
+
];
|
|
205
|
+
case 4:
|
|
206
|
+
err = _state.sent();
|
|
207
|
+
_ = Error.bind;
|
|
208
|
+
_2 = (_1 = "远程获取密钥失败,响应解析错误: ".concat(err.message, ", response text: ")).concat;
|
|
209
|
+
return [
|
|
210
|
+
4,
|
|
211
|
+
jwkRes.text()
|
|
212
|
+
];
|
|
213
|
+
case 5:
|
|
214
|
+
throw new (_.apply(Error, [
|
|
215
|
+
void 0,
|
|
216
|
+
_2.apply(_1, [
|
|
217
|
+
_state.sent()
|
|
218
|
+
])
|
|
219
|
+
]));
|
|
220
|
+
case 6:
|
|
221
|
+
_ref = (JwkResponseJson === null || JwkResponseJson === void 0 ? void 0 : JwkResponseJson.data) || {}, keyId = _ref.keyId, privateKeyPkcs8 = _ref.privateKeyPkcs8;
|
|
222
|
+
if (!keyId || !privateKeyPkcs8) throw new Error("未获取到项目签名密钥, 请检查aud是否正确: ".concat(aud));
|
|
223
|
+
return [
|
|
224
|
+
2,
|
|
225
|
+
{
|
|
226
|
+
XFE_JWT_AUD: aud,
|
|
227
|
+
XFE_JWT_KEY_ID: keyId,
|
|
228
|
+
XFE_JWT_PRIVATE_KEY: privateKeyPkcs8
|
|
229
|
+
}
|
|
230
|
+
];
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
return function getJwtEnv() {
|
|
235
|
+
return _ref.apply(this, arguments);
|
|
236
|
+
};
|
|
237
|
+
}();
|
|
238
|
+
export { loadXfeConfig, configDeploy, getJwtEnv };
|
package/dist/cli.js
CHANGED
|
@@ -303,8 +303,16 @@ var import_child_process = require("child_process");
|
|
|
303
303
|
var import_path = __toESM(require("path"));
|
|
304
304
|
var import_fs = __toESM(require("fs"));
|
|
305
305
|
var import_yaml = __toESM(require("yaml"));
|
|
306
|
+
var loadXfeConfig = function() {
|
|
307
|
+
var xfeConfigPath = "./xfe.json";
|
|
308
|
+
if (!import_fs.default.existsSync(xfeConfigPath)) {
|
|
309
|
+
throw new Error("xfe.json 配置文件不存在,请在项目根目录下创建该文件。");
|
|
310
|
+
}
|
|
311
|
+
var xfeConfigContent = import_fs.default.readFileSync(xfeConfigPath, "utf8");
|
|
312
|
+
return JSON.parse(xfeConfigContent);
|
|
313
|
+
};
|
|
306
314
|
var configDeploy = function() {
|
|
307
|
-
var xfeConfig =
|
|
315
|
+
var xfeConfig = loadXfeConfig();
|
|
308
316
|
if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.deploy)) return;
|
|
309
317
|
var droneConfigFilePath = import_path.default.resolve(__dirname, "../deploy/.drone.yml");
|
|
310
318
|
import_fs.default.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
|
|
@@ -334,9 +342,76 @@ var configDeploy = function() {
|
|
|
334
342
|
});
|
|
335
343
|
import_fs.default.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
336
344
|
};
|
|
337
|
-
var
|
|
338
|
-
|
|
339
|
-
|
|
345
|
+
var getJwtEnv = function() {
|
|
346
|
+
var _ref = _async_to_generator(function() {
|
|
347
|
+
var xfeConfig, _xfeConfig_jwt, _xfeConfig_jwt_aud, aud, jwkRes, JwkResponseJson, err, _, _1, _2, _ref, keyId, privateKeyPkcs8;
|
|
348
|
+
return _ts_generator(this, function(_state) {
|
|
349
|
+
switch(_state.label){
|
|
350
|
+
case 0:
|
|
351
|
+
xfeConfig = loadXfeConfig();
|
|
352
|
+
if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.jwt)) throw new Error("xfe.json 中未配置 jwt 信息,请检查配置文件。");
|
|
353
|
+
_xfeConfig_jwt = xfeConfig.jwt, _xfeConfig_jwt_aud = _xfeConfig_jwt.aud, aud = _xfeConfig_jwt_aud === void 0 ? "" : _xfeConfig_jwt_aud;
|
|
354
|
+
if (!aud) throw new Error("xfe.json 中的 jwt 配置不完整,请确保包含 aud 字段。");
|
|
355
|
+
return [
|
|
356
|
+
4,
|
|
357
|
+
fetch("https://app.eshetang.com/jwk?appId=".concat(aud))
|
|
358
|
+
];
|
|
359
|
+
case 1:
|
|
360
|
+
jwkRes = _state.sent();
|
|
361
|
+
if (!jwkRes.ok) {
|
|
362
|
+
throw new Error("远程获取密钥失败: ".concat(jwkRes.status, " ").concat(jwkRes.statusText));
|
|
363
|
+
}
|
|
364
|
+
_state.label = 2;
|
|
365
|
+
case 2:
|
|
366
|
+
_state.trys.push([
|
|
367
|
+
2,
|
|
368
|
+
4,
|
|
369
|
+
,
|
|
370
|
+
6
|
|
371
|
+
]);
|
|
372
|
+
return [
|
|
373
|
+
4,
|
|
374
|
+
jwkRes.json()
|
|
375
|
+
];
|
|
376
|
+
case 3:
|
|
377
|
+
JwkResponseJson = _state.sent();
|
|
378
|
+
return [
|
|
379
|
+
3,
|
|
380
|
+
6
|
|
381
|
+
];
|
|
382
|
+
case 4:
|
|
383
|
+
err = _state.sent();
|
|
384
|
+
_ = Error.bind;
|
|
385
|
+
_2 = (_1 = "远程获取密钥失败,响应解析错误: ".concat(err.message, ", response text: ")).concat;
|
|
386
|
+
return [
|
|
387
|
+
4,
|
|
388
|
+
jwkRes.text()
|
|
389
|
+
];
|
|
390
|
+
case 5:
|
|
391
|
+
throw new (_.apply(Error, [
|
|
392
|
+
void 0,
|
|
393
|
+
_2.apply(_1, [
|
|
394
|
+
_state.sent()
|
|
395
|
+
])
|
|
396
|
+
]));
|
|
397
|
+
case 6:
|
|
398
|
+
_ref = (JwkResponseJson === null || JwkResponseJson === void 0 ? void 0 : JwkResponseJson.data) || {}, keyId = _ref.keyId, privateKeyPkcs8 = _ref.privateKeyPkcs8;
|
|
399
|
+
if (!keyId || !privateKeyPkcs8) throw new Error("未获取到项目签名密钥, 请检查aud是否正确: ".concat(aud));
|
|
400
|
+
return [
|
|
401
|
+
2,
|
|
402
|
+
{
|
|
403
|
+
XFE_JWT_AUD: aud,
|
|
404
|
+
XFE_JWT_KEY_ID: keyId,
|
|
405
|
+
XFE_JWT_PRIVATE_KEY: privateKeyPkcs8
|
|
406
|
+
}
|
|
407
|
+
];
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
return function getJwtEnv() {
|
|
412
|
+
return _ref.apply(this, arguments);
|
|
413
|
+
};
|
|
414
|
+
}();
|
|
340
415
|
// src/upload.ts
|
|
341
416
|
var import_miniprogram_ci2 = require("miniprogram-ci");
|
|
342
417
|
// src/preview.ts
|
|
@@ -487,28 +562,79 @@ var argsString = Object.entries(args).map(function(param) {
|
|
|
487
562
|
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
488
563
|
return "--".concat(key, "=").concat(value);
|
|
489
564
|
}).join(" ");
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
565
|
+
function main() {
|
|
566
|
+
return _main.apply(this, arguments);
|
|
567
|
+
}
|
|
568
|
+
function _main() {
|
|
569
|
+
_main = _async_to_generator(function() {
|
|
570
|
+
var jwtEnv, jwtEnv1, v, version, d, desc, P, progress, v1, version1, p, previewPath, d1, desc1, s, scene, P1, progress1;
|
|
571
|
+
return _ts_generator(this, function(_state) {
|
|
572
|
+
switch(_state.label){
|
|
573
|
+
case 0:
|
|
574
|
+
if (!(command === "dev")) return [
|
|
575
|
+
3,
|
|
576
|
+
2
|
|
577
|
+
];
|
|
578
|
+
return [
|
|
579
|
+
4,
|
|
580
|
+
getJwtEnv()
|
|
581
|
+
];
|
|
582
|
+
case 1:
|
|
583
|
+
jwtEnv = _state.sent();
|
|
584
|
+
(0, import_child_process.execSync)("taro build --watch ".concat(argsString), {
|
|
585
|
+
stdio: "inherit",
|
|
586
|
+
cwd: appPackageRoot,
|
|
587
|
+
env: _object_spread({}, env, jwtEnv)
|
|
588
|
+
});
|
|
589
|
+
return [
|
|
590
|
+
3,
|
|
591
|
+
5
|
|
592
|
+
];
|
|
593
|
+
case 2:
|
|
594
|
+
if (!(command === "build")) return [
|
|
595
|
+
3,
|
|
596
|
+
4
|
|
597
|
+
];
|
|
598
|
+
return [
|
|
599
|
+
4,
|
|
600
|
+
getJwtEnv()
|
|
601
|
+
];
|
|
602
|
+
case 3:
|
|
603
|
+
jwtEnv1 = _state.sent();
|
|
604
|
+
(0, import_child_process.execSync)("taro build ".concat(argsString), {
|
|
605
|
+
stdio: "inherit",
|
|
606
|
+
cwd: appPackageRoot,
|
|
607
|
+
env: _object_spread({}, env, jwtEnv1)
|
|
608
|
+
});
|
|
609
|
+
return [
|
|
610
|
+
3,
|
|
611
|
+
5
|
|
612
|
+
];
|
|
613
|
+
case 4:
|
|
614
|
+
if (command === "config") {
|
|
615
|
+
configDeploy();
|
|
616
|
+
} else if (command === "upload") {
|
|
617
|
+
v = argv.v, version = argv.version, d = argv.d, desc = argv.desc, P = argv.P, progress = argv.progress;
|
|
618
|
+
void uploadMini(v || version, d || desc, P || progress).catch(console.error).finally(function() {
|
|
619
|
+
return process.exit(0);
|
|
620
|
+
});
|
|
621
|
+
} else if (command === "preview") {
|
|
622
|
+
v1 = argv.v, version1 = argv.version, p = argv.p, previewPath = argv.path, d1 = argv.d, desc1 = argv.desc, s = argv.s, scene = argv.scene, P1 = argv.P, progress1 = argv.progress;
|
|
623
|
+
void previewMini(v1 || version1, p || previewPath, d1 || desc1, s || scene, P1 || progress1).finally(function() {
|
|
624
|
+
return process.exit(0);
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
_state.label = 5;
|
|
628
|
+
case 5:
|
|
629
|
+
return [
|
|
630
|
+
2
|
|
631
|
+
];
|
|
632
|
+
}
|
|
633
|
+
});
|
|
513
634
|
});
|
|
635
|
+
return _main.apply(this, arguments);
|
|
514
636
|
}
|
|
637
|
+
main().catch(function(err) {
|
|
638
|
+
console.error("XFE Mini CLI 执行出错:", err);
|
|
639
|
+
process.exit(1);
|
|
640
|
+
});
|
package/dist/cli.mjs
CHANGED
|
@@ -6,6 +6,35 @@ function _array_like_to_array(arr, len) {
|
|
|
6
6
|
function _array_with_holes(arr) {
|
|
7
7
|
if (Array.isArray(arr)) return arr;
|
|
8
8
|
}
|
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
+
try {
|
|
11
|
+
var info = gen[key](arg);
|
|
12
|
+
var value = info.value;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
reject(error);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (info.done) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
} else {
|
|
20
|
+
Promise.resolve(value).then(_next, _throw);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function _async_to_generator(fn) {
|
|
24
|
+
return function() {
|
|
25
|
+
var self = this, args = arguments;
|
|
26
|
+
return new Promise(function(resolve, reject) {
|
|
27
|
+
var gen = fn.apply(self, args);
|
|
28
|
+
function _next(value) {
|
|
29
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
30
|
+
}
|
|
31
|
+
function _throw(err) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
+
}
|
|
34
|
+
_next(undefined);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
9
38
|
function _define_property(obj, key, value) {
|
|
10
39
|
if (key in obj) {
|
|
11
40
|
Object.defineProperty(obj, key, {
|
|
@@ -123,7 +152,102 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
123
152
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
124
153
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
125
154
|
}
|
|
126
|
-
|
|
155
|
+
function _ts_generator(thisArg, body) {
|
|
156
|
+
var f, y, t, g, _ = {
|
|
157
|
+
label: 0,
|
|
158
|
+
sent: function() {
|
|
159
|
+
if (t[0] & 1) throw t[1];
|
|
160
|
+
return t[1];
|
|
161
|
+
},
|
|
162
|
+
trys: [],
|
|
163
|
+
ops: []
|
|
164
|
+
};
|
|
165
|
+
return g = {
|
|
166
|
+
next: verb(0),
|
|
167
|
+
"throw": verb(1),
|
|
168
|
+
"return": verb(2)
|
|
169
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
170
|
+
return this;
|
|
171
|
+
}), g;
|
|
172
|
+
function verb(n) {
|
|
173
|
+
return function(v) {
|
|
174
|
+
return step([
|
|
175
|
+
n,
|
|
176
|
+
v
|
|
177
|
+
]);
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function step(op) {
|
|
181
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
182
|
+
while(_)try {
|
|
183
|
+
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;
|
|
184
|
+
if (y = 0, t) op = [
|
|
185
|
+
op[0] & 2,
|
|
186
|
+
t.value
|
|
187
|
+
];
|
|
188
|
+
switch(op[0]){
|
|
189
|
+
case 0:
|
|
190
|
+
case 1:
|
|
191
|
+
t = op;
|
|
192
|
+
break;
|
|
193
|
+
case 4:
|
|
194
|
+
_.label++;
|
|
195
|
+
return {
|
|
196
|
+
value: op[1],
|
|
197
|
+
done: false
|
|
198
|
+
};
|
|
199
|
+
case 5:
|
|
200
|
+
_.label++;
|
|
201
|
+
y = op[1];
|
|
202
|
+
op = [
|
|
203
|
+
0
|
|
204
|
+
];
|
|
205
|
+
continue;
|
|
206
|
+
case 7:
|
|
207
|
+
op = _.ops.pop();
|
|
208
|
+
_.trys.pop();
|
|
209
|
+
continue;
|
|
210
|
+
default:
|
|
211
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
212
|
+
_ = 0;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
216
|
+
_.label = op[1];
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
220
|
+
_.label = t[1];
|
|
221
|
+
t = op;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
if (t && _.label < t[2]) {
|
|
225
|
+
_.label = t[2];
|
|
226
|
+
_.ops.push(op);
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
if (t[2]) _.ops.pop();
|
|
230
|
+
_.trys.pop();
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
op = body.call(thisArg, _);
|
|
234
|
+
} catch (e) {
|
|
235
|
+
op = [
|
|
236
|
+
6,
|
|
237
|
+
e
|
|
238
|
+
];
|
|
239
|
+
y = 0;
|
|
240
|
+
} finally{
|
|
241
|
+
f = t = 0;
|
|
242
|
+
}
|
|
243
|
+
if (op[0] & 5) throw op[1];
|
|
244
|
+
return {
|
|
245
|
+
value: op[0] ? op[1] : void 0,
|
|
246
|
+
done: true
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
import { configDeploy, getJwtEnv } from "./chunk-TFIAHV2G.mjs";
|
|
127
251
|
import { uploadMini } from "./chunk-4JD7C4FF.mjs";
|
|
128
252
|
import { previewMini } from "./chunk-MLSNG3O7.mjs";
|
|
129
253
|
// src/cli.ts
|
|
@@ -144,28 +268,79 @@ var argsString = Object.entries(args).map(function(param) {
|
|
|
144
268
|
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
145
269
|
return "--".concat(key, "=").concat(value);
|
|
146
270
|
}).join(" ");
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
271
|
+
function main() {
|
|
272
|
+
return _main.apply(this, arguments);
|
|
273
|
+
}
|
|
274
|
+
function _main() {
|
|
275
|
+
_main = _async_to_generator(function() {
|
|
276
|
+
var jwtEnv, jwtEnv1, v, version, d, desc, P, progress, v1, version1, p, previewPath, d1, desc1, s, scene, P1, progress1;
|
|
277
|
+
return _ts_generator(this, function(_state) {
|
|
278
|
+
switch(_state.label){
|
|
279
|
+
case 0:
|
|
280
|
+
if (!(command === "dev")) return [
|
|
281
|
+
3,
|
|
282
|
+
2
|
|
283
|
+
];
|
|
284
|
+
return [
|
|
285
|
+
4,
|
|
286
|
+
getJwtEnv()
|
|
287
|
+
];
|
|
288
|
+
case 1:
|
|
289
|
+
jwtEnv = _state.sent();
|
|
290
|
+
execSync("taro build --watch ".concat(argsString), {
|
|
291
|
+
stdio: "inherit",
|
|
292
|
+
cwd: appPackageRoot,
|
|
293
|
+
env: _object_spread({}, env, jwtEnv)
|
|
294
|
+
});
|
|
295
|
+
return [
|
|
296
|
+
3,
|
|
297
|
+
5
|
|
298
|
+
];
|
|
299
|
+
case 2:
|
|
300
|
+
if (!(command === "build")) return [
|
|
301
|
+
3,
|
|
302
|
+
4
|
|
303
|
+
];
|
|
304
|
+
return [
|
|
305
|
+
4,
|
|
306
|
+
getJwtEnv()
|
|
307
|
+
];
|
|
308
|
+
case 3:
|
|
309
|
+
jwtEnv1 = _state.sent();
|
|
310
|
+
execSync("taro build ".concat(argsString), {
|
|
311
|
+
stdio: "inherit",
|
|
312
|
+
cwd: appPackageRoot,
|
|
313
|
+
env: _object_spread({}, env, jwtEnv1)
|
|
314
|
+
});
|
|
315
|
+
return [
|
|
316
|
+
3,
|
|
317
|
+
5
|
|
318
|
+
];
|
|
319
|
+
case 4:
|
|
320
|
+
if (command === "config") {
|
|
321
|
+
configDeploy();
|
|
322
|
+
} else if (command === "upload") {
|
|
323
|
+
v = argv.v, version = argv.version, d = argv.d, desc = argv.desc, P = argv.P, progress = argv.progress;
|
|
324
|
+
void uploadMini(v || version, d || desc, P || progress).catch(console.error).finally(function() {
|
|
325
|
+
return process.exit(0);
|
|
326
|
+
});
|
|
327
|
+
} else if (command === "preview") {
|
|
328
|
+
v1 = argv.v, version1 = argv.version, p = argv.p, previewPath = argv.path, d1 = argv.d, desc1 = argv.desc, s = argv.s, scene = argv.scene, P1 = argv.P, progress1 = argv.progress;
|
|
329
|
+
void previewMini(v1 || version1, p || previewPath, d1 || desc1, s || scene, P1 || progress1).finally(function() {
|
|
330
|
+
return process.exit(0);
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
_state.label = 5;
|
|
334
|
+
case 5:
|
|
335
|
+
return [
|
|
336
|
+
2
|
|
337
|
+
];
|
|
338
|
+
}
|
|
339
|
+
});
|
|
170
340
|
});
|
|
341
|
+
return _main.apply(this, arguments);
|
|
171
342
|
}
|
|
343
|
+
main().catch(function(err) {
|
|
344
|
+
console.error("XFE Mini CLI 执行出错:", err);
|
|
345
|
+
process.exit(1);
|
|
346
|
+
});
|
package/dist/config.d.mts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
declare const loadXfeConfig: () => Record<string, any>;
|
|
2
|
+
declare const configDeploy: () => void;
|
|
3
|
+
declare const getJwtEnv: () => Promise<{
|
|
4
|
+
XFE_JWT_AUD: any;
|
|
5
|
+
XFE_JWT_KEY_ID: string;
|
|
6
|
+
XFE_JWT_PRIVATE_KEY: string;
|
|
7
|
+
}>;
|
|
2
8
|
|
|
3
|
-
export {
|
|
9
|
+
export { configDeploy, getJwtEnv, loadXfeConfig };
|
package/dist/config.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
declare const loadXfeConfig: () => Record<string, any>;
|
|
2
|
+
declare const configDeploy: () => void;
|
|
3
|
+
declare const getJwtEnv: () => Promise<{
|
|
4
|
+
XFE_JWT_AUD: any;
|
|
5
|
+
XFE_JWT_KEY_ID: string;
|
|
6
|
+
XFE_JWT_PRIVATE_KEY: string;
|
|
7
|
+
}>;
|
|
2
8
|
|
|
3
|
-
export {
|
|
9
|
+
export { configDeploy, getJwtEnv, loadXfeConfig };
|
package/dist/config.js
CHANGED
|
@@ -1,4 +1,128 @@
|
|
|
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 _ts_generator(thisArg, body) {
|
|
32
|
+
var f, y, t, g, _ = {
|
|
33
|
+
label: 0,
|
|
34
|
+
sent: function() {
|
|
35
|
+
if (t[0] & 1) throw t[1];
|
|
36
|
+
return t[1];
|
|
37
|
+
},
|
|
38
|
+
trys: [],
|
|
39
|
+
ops: []
|
|
40
|
+
};
|
|
41
|
+
return g = {
|
|
42
|
+
next: verb(0),
|
|
43
|
+
"throw": verb(1),
|
|
44
|
+
"return": verb(2)
|
|
45
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
46
|
+
return this;
|
|
47
|
+
}), g;
|
|
48
|
+
function verb(n) {
|
|
49
|
+
return function(v) {
|
|
50
|
+
return step([
|
|
51
|
+
n,
|
|
52
|
+
v
|
|
53
|
+
]);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function step(op) {
|
|
57
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
+
while(_)try {
|
|
59
|
+
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;
|
|
60
|
+
if (y = 0, t) op = [
|
|
61
|
+
op[0] & 2,
|
|
62
|
+
t.value
|
|
63
|
+
];
|
|
64
|
+
switch(op[0]){
|
|
65
|
+
case 0:
|
|
66
|
+
case 1:
|
|
67
|
+
t = op;
|
|
68
|
+
break;
|
|
69
|
+
case 4:
|
|
70
|
+
_.label++;
|
|
71
|
+
return {
|
|
72
|
+
value: op[1],
|
|
73
|
+
done: false
|
|
74
|
+
};
|
|
75
|
+
case 5:
|
|
76
|
+
_.label++;
|
|
77
|
+
y = op[1];
|
|
78
|
+
op = [
|
|
79
|
+
0
|
|
80
|
+
];
|
|
81
|
+
continue;
|
|
82
|
+
case 7:
|
|
83
|
+
op = _.ops.pop();
|
|
84
|
+
_.trys.pop();
|
|
85
|
+
continue;
|
|
86
|
+
default:
|
|
87
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
88
|
+
_ = 0;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
92
|
+
_.label = op[1];
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
96
|
+
_.label = t[1];
|
|
97
|
+
t = op;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (t && _.label < t[2]) {
|
|
101
|
+
_.label = t[2];
|
|
102
|
+
_.ops.push(op);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
if (t[2]) _.ops.pop();
|
|
106
|
+
_.trys.pop();
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
op = body.call(thisArg, _);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
op = [
|
|
112
|
+
6,
|
|
113
|
+
e
|
|
114
|
+
];
|
|
115
|
+
y = 0;
|
|
116
|
+
} finally{
|
|
117
|
+
f = t = 0;
|
|
118
|
+
}
|
|
119
|
+
if (op[0] & 5) throw op[1];
|
|
120
|
+
return {
|
|
121
|
+
value: op[0] ? op[1] : void 0,
|
|
122
|
+
done: true
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
2
126
|
var __create = Object.create;
|
|
3
127
|
var __defProp = Object.defineProperty;
|
|
4
128
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -60,16 +184,30 @@ var __toCommonJS = function(mod) {
|
|
|
60
184
|
// src/config.ts
|
|
61
185
|
var config_exports = {};
|
|
62
186
|
__export(config_exports, {
|
|
63
|
-
|
|
64
|
-
return
|
|
187
|
+
configDeploy: function() {
|
|
188
|
+
return configDeploy;
|
|
189
|
+
},
|
|
190
|
+
getJwtEnv: function() {
|
|
191
|
+
return getJwtEnv;
|
|
192
|
+
},
|
|
193
|
+
loadXfeConfig: function() {
|
|
194
|
+
return loadXfeConfig;
|
|
65
195
|
}
|
|
66
196
|
});
|
|
67
197
|
module.exports = __toCommonJS(config_exports);
|
|
68
198
|
var import_path = __toESM(require("path"));
|
|
69
199
|
var import_fs = __toESM(require("fs"));
|
|
70
200
|
var import_yaml = __toESM(require("yaml"));
|
|
201
|
+
var loadXfeConfig = function() {
|
|
202
|
+
var xfeConfigPath = "./xfe.json";
|
|
203
|
+
if (!import_fs.default.existsSync(xfeConfigPath)) {
|
|
204
|
+
throw new Error("xfe.json 配置文件不存在,请在项目根目录下创建该文件。");
|
|
205
|
+
}
|
|
206
|
+
var xfeConfigContent = import_fs.default.readFileSync(xfeConfigPath, "utf8");
|
|
207
|
+
return JSON.parse(xfeConfigContent);
|
|
208
|
+
};
|
|
71
209
|
var configDeploy = function() {
|
|
72
|
-
var xfeConfig =
|
|
210
|
+
var xfeConfig = loadXfeConfig();
|
|
73
211
|
if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.deploy)) return;
|
|
74
212
|
var droneConfigFilePath = import_path.default.resolve(__dirname, "../deploy/.drone.yml");
|
|
75
213
|
import_fs.default.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
|
|
@@ -99,10 +237,79 @@ var configDeploy = function() {
|
|
|
99
237
|
});
|
|
100
238
|
import_fs.default.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
101
239
|
};
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
|
|
240
|
+
var getJwtEnv = function() {
|
|
241
|
+
var _ref = _async_to_generator(function() {
|
|
242
|
+
var xfeConfig, _xfeConfig_jwt, _xfeConfig_jwt_aud, aud, jwkRes, JwkResponseJson, err, _, _1, _2, _ref, keyId, privateKeyPkcs8;
|
|
243
|
+
return _ts_generator(this, function(_state) {
|
|
244
|
+
switch(_state.label){
|
|
245
|
+
case 0:
|
|
246
|
+
xfeConfig = loadXfeConfig();
|
|
247
|
+
if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.jwt)) throw new Error("xfe.json 中未配置 jwt 信息,请检查配置文件。");
|
|
248
|
+
_xfeConfig_jwt = xfeConfig.jwt, _xfeConfig_jwt_aud = _xfeConfig_jwt.aud, aud = _xfeConfig_jwt_aud === void 0 ? "" : _xfeConfig_jwt_aud;
|
|
249
|
+
if (!aud) throw new Error("xfe.json 中的 jwt 配置不完整,请确保包含 aud 字段。");
|
|
250
|
+
return [
|
|
251
|
+
4,
|
|
252
|
+
fetch("https://app.eshetang.com/jwk?appId=".concat(aud))
|
|
253
|
+
];
|
|
254
|
+
case 1:
|
|
255
|
+
jwkRes = _state.sent();
|
|
256
|
+
if (!jwkRes.ok) {
|
|
257
|
+
throw new Error("远程获取密钥失败: ".concat(jwkRes.status, " ").concat(jwkRes.statusText));
|
|
258
|
+
}
|
|
259
|
+
_state.label = 2;
|
|
260
|
+
case 2:
|
|
261
|
+
_state.trys.push([
|
|
262
|
+
2,
|
|
263
|
+
4,
|
|
264
|
+
,
|
|
265
|
+
6
|
|
266
|
+
]);
|
|
267
|
+
return [
|
|
268
|
+
4,
|
|
269
|
+
jwkRes.json()
|
|
270
|
+
];
|
|
271
|
+
case 3:
|
|
272
|
+
JwkResponseJson = _state.sent();
|
|
273
|
+
return [
|
|
274
|
+
3,
|
|
275
|
+
6
|
|
276
|
+
];
|
|
277
|
+
case 4:
|
|
278
|
+
err = _state.sent();
|
|
279
|
+
_ = Error.bind;
|
|
280
|
+
_2 = (_1 = "远程获取密钥失败,响应解析错误: ".concat(err.message, ", response text: ")).concat;
|
|
281
|
+
return [
|
|
282
|
+
4,
|
|
283
|
+
jwkRes.text()
|
|
284
|
+
];
|
|
285
|
+
case 5:
|
|
286
|
+
throw new (_.apply(Error, [
|
|
287
|
+
void 0,
|
|
288
|
+
_2.apply(_1, [
|
|
289
|
+
_state.sent()
|
|
290
|
+
])
|
|
291
|
+
]));
|
|
292
|
+
case 6:
|
|
293
|
+
_ref = (JwkResponseJson === null || JwkResponseJson === void 0 ? void 0 : JwkResponseJson.data) || {}, keyId = _ref.keyId, privateKeyPkcs8 = _ref.privateKeyPkcs8;
|
|
294
|
+
if (!keyId || !privateKeyPkcs8) throw new Error("未获取到项目签名密钥, 请检查aud是否正确: ".concat(aud));
|
|
295
|
+
return [
|
|
296
|
+
2,
|
|
297
|
+
{
|
|
298
|
+
XFE_JWT_AUD: aud,
|
|
299
|
+
XFE_JWT_KEY_ID: keyId,
|
|
300
|
+
XFE_JWT_PRIVATE_KEY: privateKeyPkcs8
|
|
301
|
+
}
|
|
302
|
+
];
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
return function getJwtEnv() {
|
|
307
|
+
return _ref.apply(this, arguments);
|
|
308
|
+
};
|
|
309
|
+
}();
|
|
105
310
|
// Annotate the CommonJS export names for ESM import in node:
|
|
106
311
|
0 && (module.exports = {
|
|
107
|
-
|
|
312
|
+
configDeploy: configDeploy,
|
|
313
|
+
getJwtEnv: getJwtEnv,
|
|
314
|
+
loadXfeConfig: loadXfeConfig
|
|
108
315
|
});
|
package/dist/config.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { configDeploy, getJwtEnv, loadXfeConfig } from "./chunk-TFIAHV2G.mjs";
|
|
2
|
+
export { configDeploy, getJwtEnv, loadXfeConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfe-repo/mini-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"bin": {
|
|
5
5
|
"xfe-mini": "./bin/index.js"
|
|
6
6
|
},
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"typescript": "5.5.4",
|
|
52
52
|
"webpack": "5.91.0",
|
|
53
53
|
"yaml": "^2.3.4",
|
|
54
|
-
"@xfe-repo/
|
|
55
|
-
"@xfe-repo/
|
|
54
|
+
"@xfe-repo/routes-define-webpack-plugin": "0.0.3",
|
|
55
|
+
"@xfe-repo/typescript-config": "0.0.6"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"react": "18.2.0",
|
package/dist/chunk-EQD7HO6T.mjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// src/config.ts
|
|
2
|
-
import path from "path";
|
|
3
|
-
import fs from "fs";
|
|
4
|
-
import yaml from "yaml";
|
|
5
|
-
var configDeploy = function() {
|
|
6
|
-
var xfeConfig = JSON.parse(fs.readFileSync("./xfe.json", "utf8"));
|
|
7
|
-
if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.deploy)) return;
|
|
8
|
-
var droneConfigFilePath = path.resolve(__dirname, "../deploy/.drone.yml");
|
|
9
|
-
fs.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
|
|
10
|
-
var valuesYamlFilePath = path.resolve(__dirname, "../deploy/helm/values.yaml");
|
|
11
|
-
var valuesYamlFile = fs.readFileSync(valuesYamlFilePath, "utf8");
|
|
12
|
-
var valuesYaml = yaml.parse(valuesYamlFile);
|
|
13
|
-
if (!valuesYaml.virtualService) valuesYaml.virtualService = {};
|
|
14
|
-
if (!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = {
|
|
15
|
-
test: [],
|
|
16
|
-
stage: [],
|
|
17
|
-
prod: []
|
|
18
|
-
};
|
|
19
|
-
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 ? [
|
|
20
|
-
"common-gateway-eshetang"
|
|
21
|
-
] : _xfeConfig_deploy_gateways;
|
|
22
|
-
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;
|
|
23
|
-
valuesYaml.virtualService.enabled = virtualServiceEnabled;
|
|
24
|
-
valuesYaml.virtualService.gateways = gateways;
|
|
25
|
-
valuesYaml.virtualService.hosts.prod = hostsProd;
|
|
26
|
-
valuesYaml.virtualService.hosts.stage = hostsStage;
|
|
27
|
-
valuesYaml.virtualService.hosts.test = hostsTest;
|
|
28
|
-
valuesYaml.targetK8s = targetK8s;
|
|
29
|
-
valuesYaml.namespace = targetNamespace;
|
|
30
|
-
var valuesYamlStr = yaml.stringify(valuesYaml, {
|
|
31
|
-
defaultStringType: "QUOTE_SINGLE",
|
|
32
|
-
defaultKeyType: "PLAIN"
|
|
33
|
-
});
|
|
34
|
-
fs.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
35
|
-
};
|
|
36
|
-
var config = function() {
|
|
37
|
-
configDeploy();
|
|
38
|
-
};
|
|
39
|
-
export { config };
|