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