@xfe-repo/mini-app 1.6.5 → 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/dist/cli.mjs CHANGED
@@ -1,355 +1,62 @@
1
- function _array_like_to_array(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
5
- }
6
- function _array_with_holes(arr) {
7
- if (Array.isArray(arr)) return arr;
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
- }
38
- function _define_property(obj, key, value) {
39
- if (key in obj) {
40
- Object.defineProperty(obj, key, {
41
- value: value,
42
- enumerable: true,
43
- configurable: true,
44
- writable: true
45
- });
46
- } else {
47
- obj[key] = value;
48
- }
49
- return obj;
50
- }
51
- function _iterable_to_array_limit(arr, i) {
52
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
53
- if (_i == null) return;
54
- var _arr = [];
55
- var _n = true;
56
- var _d = false;
57
- var _s, _e;
58
- try {
59
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
60
- _arr.push(_s.value);
61
- if (i && _arr.length === i) break;
62
- }
63
- } catch (err) {
64
- _d = true;
65
- _e = err;
66
- } finally{
67
- try {
68
- if (!_n && _i["return"] != null) _i["return"]();
69
- } finally{
70
- if (_d) throw _e;
71
- }
72
- }
73
- return _arr;
74
- }
75
- function _non_iterable_rest() {
76
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
77
- }
78
- function _object_spread(target) {
79
- for(var i = 1; i < arguments.length; i++){
80
- var source = arguments[i] != null ? arguments[i] : {};
81
- var ownKeys = Object.keys(source);
82
- if (typeof Object.getOwnPropertySymbols === "function") {
83
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
84
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
85
- }));
86
- }
87
- ownKeys.forEach(function(key) {
88
- _define_property(target, key, source[key]);
89
- });
90
- }
91
- return target;
92
- }
93
- function ownKeys(object, enumerableOnly) {
94
- var keys = Object.keys(object);
95
- if (Object.getOwnPropertySymbols) {
96
- var symbols = Object.getOwnPropertySymbols(object);
97
- if (enumerableOnly) {
98
- symbols = symbols.filter(function(sym) {
99
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
100
- });
101
- }
102
- keys.push.apply(keys, symbols);
103
- }
104
- return keys;
105
- }
106
- function _object_spread_props(target, source) {
107
- source = source != null ? source : {};
108
- if (Object.getOwnPropertyDescriptors) {
109
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
110
- } else {
111
- ownKeys(Object(source)).forEach(function(key) {
112
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
113
- });
114
- }
115
- return target;
116
- }
117
- function _object_without_properties(source, excluded) {
118
- if (source == null) return {};
119
- var target = {}, sourceKeys, key, i;
120
- if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
121
- sourceKeys = Reflect.ownKeys(Object(source));
122
- for(i = 0; i < sourceKeys.length; i++){
123
- key = sourceKeys[i];
124
- if (excluded.indexOf(key) >= 0) continue;
125
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
126
- target[key] = source[key];
127
- }
128
- return target;
129
- }
130
- target = _object_without_properties_loose(source, excluded);
131
- if (Object.getOwnPropertySymbols) {
132
- sourceKeys = Object.getOwnPropertySymbols(source);
133
- for(i = 0; i < sourceKeys.length; i++){
134
- key = sourceKeys[i];
135
- if (excluded.indexOf(key) >= 0) continue;
136
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
137
- target[key] = source[key];
138
- }
139
- }
140
- return target;
141
- }
142
- function _object_without_properties_loose(source, excluded) {
143
- if (source == null) return {};
144
- var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
145
- for(i = 0; i < sourceKeys.length; i++){
146
- key = sourceKeys[i];
147
- if (excluded.indexOf(key) >= 0) continue;
148
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
149
- target[key] = source[key];
150
- }
151
- return target;
152
- }
153
- function _sliced_to_array(arr, i) {
154
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
155
- }
156
- function _unsupported_iterable_to_array(o, minLen) {
157
- if (!o) return;
158
- if (typeof o === "string") return _array_like_to_array(o, minLen);
159
- var n = Object.prototype.toString.call(o).slice(8, -1);
160
- if (n === "Object" && o.constructor) n = o.constructor.name;
161
- if (n === "Map" || n === "Set") return Array.from(n);
162
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
163
- }
164
- function _ts_generator(thisArg, body) {
165
- var f, y, t, _ = {
166
- label: 0,
167
- sent: function() {
168
- if (t[0] & 1) throw t[1];
169
- return t[1];
170
- },
171
- trys: [],
172
- ops: []
173
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
174
- return d(g, "next", {
175
- value: verb(0)
176
- }), d(g, "throw", {
177
- value: verb(1)
178
- }), d(g, "return", {
179
- value: verb(2)
180
- }), typeof Symbol === "function" && d(g, Symbol.iterator, {
181
- value: function() {
182
- return this;
183
- }
184
- }), g;
185
- function verb(n) {
186
- return function(v) {
187
- return step([
188
- n,
189
- v
190
- ]);
191
- };
192
- }
193
- function step(op) {
194
- if (f) throw new TypeError("Generator is already executing.");
195
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
196
- 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;
197
- if (y = 0, t) op = [
198
- op[0] & 2,
199
- t.value
200
- ];
201
- switch(op[0]){
202
- case 0:
203
- case 1:
204
- t = op;
205
- break;
206
- case 4:
207
- _.label++;
208
- return {
209
- value: op[1],
210
- done: false
211
- };
212
- case 5:
213
- _.label++;
214
- y = op[1];
215
- op = [
216
- 0
217
- ];
218
- continue;
219
- case 7:
220
- op = _.ops.pop();
221
- _.trys.pop();
222
- continue;
223
- default:
224
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
225
- _ = 0;
226
- continue;
227
- }
228
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
229
- _.label = op[1];
230
- break;
231
- }
232
- if (op[0] === 6 && _.label < t[1]) {
233
- _.label = t[1];
234
- t = op;
235
- break;
236
- }
237
- if (t && _.label < t[2]) {
238
- _.label = t[2];
239
- _.ops.push(op);
240
- break;
241
- }
242
- if (t[2]) _.ops.pop();
243
- _.trys.pop();
244
- continue;
245
- }
246
- op = body.call(thisArg, _);
247
- } catch (e) {
248
- op = [
249
- 6,
250
- e
251
- ];
252
- y = 0;
253
- } finally{
254
- f = t = 0;
255
- }
256
- if (op[0] & 5) throw op[1];
257
- return {
258
- value: op[0] ? op[1] : void 0,
259
- done: true
260
- };
261
- }
262
- }
263
- import { configDeploy, getJwtEnv } from "./chunk-75BJNL7E.mjs";
264
- import { uploadMini } from "./chunk-4JD7C4FF.mjs";
265
- import { previewMini } from "./chunk-MLSNG3O7.mjs";
1
+ import {
2
+ configDeploy,
3
+ getJwtEnv
4
+ } from "./chunk-MSNDQMQN.mjs";
5
+ import {
6
+ uploadMini
7
+ } from "./chunk-4JD7C4FF.mjs";
8
+ import {
9
+ previewMini
10
+ } from "./chunk-MLSNG3O7.mjs";
11
+ import {
12
+ __require
13
+ } from "./chunk-Y6FXYEAI.mjs";
14
+
266
15
  // src/cli.ts
267
16
  import minimist from "minimist";
268
17
  import path from "path";
269
- import { execSync } from "child_process";
18
+ import { execFileSync } from "child_process";
270
19
  var argv = minimist(process.argv.slice(2));
271
- var commands = argv._, args = _object_without_properties(argv, [
272
- "_"
273
- ]);
274
- var _commands = _sliced_to_array(commands, 1), command = _commands[0];
20
+ var { _: commands, ...args } = argv;
21
+ var [command] = commands;
275
22
  var appPackageRoot = path.resolve(__dirname, "../");
276
23
  var appProjectRoot = process.cwd();
277
- var env = _object_spread_props(_object_spread({}, process.env), {
278
- APP_PROJECT_ROOT: appProjectRoot
279
- });
280
- var argsString = Object.entries(args).map(function(param) {
281
- var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
282
- return "--".concat(key, "=").concat(value);
283
- }).join(" ");
284
- function main() {
285
- return _async_to_generator(function() {
286
- var jwtEnv, jwtEnv1, v, version, d, desc, P, progress, v1, version1, p, previewPath, d1, desc1, s, scene, P1, progress1;
287
- return _ts_generator(this, function(_state) {
288
- switch(_state.label){
289
- case 0:
290
- if (!(command === "dev")) return [
291
- 3,
292
- 2
293
- ];
294
- return [
295
- 4,
296
- getJwtEnv()
297
- ];
298
- case 1:
299
- jwtEnv = _state.sent();
300
- execSync("taro build --watch ".concat(argsString), {
301
- stdio: "inherit",
302
- cwd: appPackageRoot,
303
- env: _object_spread({}, env, jwtEnv)
304
- });
305
- return [
306
- 3,
307
- 5
308
- ];
309
- case 2:
310
- if (!(command === "build")) return [
311
- 3,
312
- 4
313
- ];
314
- return [
315
- 4,
316
- getJwtEnv()
317
- ];
318
- case 3:
319
- jwtEnv1 = _state.sent();
320
- execSync("taro build ".concat(argsString), {
321
- stdio: "inherit",
322
- cwd: appPackageRoot,
323
- env: _object_spread({}, env, jwtEnv1)
324
- });
325
- return [
326
- 3,
327
- 5
328
- ];
329
- case 4:
330
- if (command === "config") {
331
- configDeploy();
332
- } else if (command === "upload") {
333
- v = argv.v, version = argv.version, d = argv.d, desc = argv.desc, P = argv.P, progress = argv.progress;
334
- void uploadMini(v || version, d || desc, P || progress).catch(console.error).finally(function() {
335
- return process.exit(0);
336
- });
337
- } else if (command === "preview") {
338
- 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;
339
- void previewMini(v1 || version1, p || previewPath, d1 || desc1, s || scene, P1 || progress1).finally(function() {
340
- return process.exit(0);
341
- });
342
- }
343
- _state.label = 5;
344
- case 5:
345
- return [
346
- 2
347
- ];
348
- }
349
- });
350
- })();
351
- }
352
- main().catch(function(err) {
353
- console.error("XFE Mini CLI \u6267\u884C\u51FA\u9519:", err);
354
- process.exit(1);
24
+ var env = { ...process.env, APP_PROJECT_ROOT: appProjectRoot };
25
+ var taroBin = __require.resolve("@tarojs/cli/bin/taro");
26
+ var taroArgs = Object.entries(args).map(([key, value]) => `--${key}=${value}`);
27
+ async function main() {
28
+ if (command === "dev") {
29
+ const jwtEnv = await getJwtEnv();
30
+ execFileSync(process.execPath, [taroBin, "build", "--watch", ...taroArgs], {
31
+ stdio: "inherit",
32
+ cwd: appPackageRoot,
33
+ env: { ...env, ...jwtEnv }
34
+ });
35
+ } else if (command === "build") {
36
+ const jwtEnv = await getJwtEnv();
37
+ execFileSync(process.execPath, [taroBin, "build", ...taroArgs], {
38
+ stdio: "inherit",
39
+ cwd: appPackageRoot,
40
+ env: { ...env, ...jwtEnv }
41
+ });
42
+ } else if (command === "config") {
43
+ const { configWorkspace, printDeployment } = await import("./workspace-7FXUJJOQ.mjs");
44
+ if (argv.workspace)
45
+ return configWorkspace({
46
+ workspaceRoot: path.resolve(argv.workspace),
47
+ frameworkRoot: appPackageRoot
48
+ });
49
+ configDeploy();
50
+ if (argv.json) printDeployment(appPackageRoot);
51
+ } else if (command === "upload") {
52
+ const { v, version, d, desc, P, progress } = argv;
53
+ await uploadMini(v || version, d || desc, P || progress);
54
+ } else if (command === "preview") {
55
+ const { v, version, p, path: previewPath, d, desc, s, scene, P, progress } = argv;
56
+ await previewMini(v || version, p || previewPath, d || desc, s || scene, P || progress);
57
+ }
58
+ }
59
+ main().catch((err) => {
60
+ console.error("XFE Mini CLI \u6267\u884C\u51FA\u9519:", err);
61
+ process.exit(1);
355
62
  });
package/dist/config.d.mts CHANGED
@@ -1,9 +1,10 @@
1
1
  declare const loadXfeConfig: () => Record<string, any>;
2
+ /** 使用与 Web 一致的项目部署目录和 Helm values 契约。 */
2
3
  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
- }>;
4
+ /**
5
+ * 仅在项目声明了旧 BFF JWT 时获取签名密钥。
6
+ * 直连新 API 的小程序不需要这组构建时凭据。
7
+ */
8
+ declare const getJwtEnv: () => Promise<Record<string, string>>;
8
9
 
9
10
  export { configDeploy, getJwtEnv, loadXfeConfig };
package/dist/config.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  declare const loadXfeConfig: () => Record<string, any>;
2
+ /** 使用与 Web 一致的项目部署目录和 Helm values 契约。 */
2
3
  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
- }>;
4
+ /**
5
+ * 仅在项目声明了旧 BFF JWT 时获取签名密钥。
6
+ * 直连新 API 的小程序不需要这组构建时凭据。
7
+ */
8
+ declare const getJwtEnv: () => Promise<Record<string, string>>;
8
9
 
9
10
  export { configDeploy, getJwtEnv, loadXfeConfig };