react-native-update-cli 2.10.0 → 2.10.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 +47 -497
- package/README.zh-CN.md +52 -500
- package/cli.json +2 -16
- package/lib/api.js +1 -1
- package/lib/app.d.ts +7 -6
- package/lib/app.js +23 -22
- package/lib/exports.d.ts +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +14 -62
- package/lib/locales/en.d.ts +1 -0
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.d.ts +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/module-manager.d.ts +1 -5
- package/lib/module-manager.js +2 -30
- package/lib/modules/app-module.js +1 -249
- package/lib/modules/bundle-module.js +1 -173
- package/lib/modules/package-module.js +1 -2
- package/lib/modules/user-module.js +1 -399
- package/lib/modules/version-module.js +1 -2
- package/lib/package.d.ts +1 -2
- package/lib/package.js +6 -6
- package/lib/provider.d.ts +1 -4
- package/lib/provider.js +2 -21
- package/lib/types.d.ts +0 -20
- package/lib/user.d.ts +1 -1
- package/lib/user.js +1 -1
- package/lib/utils/app-info-parser/aab.js +1 -1
- package/lib/utils/app-info-parser/resource-finder.js +5 -5
- package/lib/utils/app-info-parser/utils.js +3 -2
- package/lib/utils/check-lockfile.js +1 -1
- package/lib/utils/dep-versions.js +2 -2
- package/lib/utils/http-helper.js +2 -2
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/versions.d.ts +1 -0
- package/lib/versions.js +19 -14
- package/package.json +1 -1
- package/src/api.ts +1 -1
- package/src/app.ts +39 -40
- package/src/exports.ts +0 -2
- package/src/index.ts +16 -81
- package/src/locales/en.ts +1 -0
- package/src/locales/zh.ts +1 -0
- package/src/module-manager.ts +1 -41
- package/src/modules/app-module.ts +1 -271
- package/src/modules/bundle-module.ts +1 -206
- package/src/modules/package-module.ts +0 -3
- package/src/modules/user-module.ts +1 -459
- package/src/modules/version-module.ts +0 -1
- package/src/package.ts +5 -7
- package/src/provider.ts +4 -25
- package/src/types.ts +0 -32
- package/src/user.ts +1 -1
- package/src/utils/app-info-parser/aab.ts +1 -1
- package/src/utils/app-info-parser/resource-finder.ts +5 -5
- package/src/utils/app-info-parser/utils.ts +2 -2
- package/src/utils/check-lockfile.ts +1 -1
- package/src/utils/dep-versions.ts +2 -2
- package/src/utils/http-helper.ts +2 -2
- package/src/utils/index.ts +1 -1
- package/src/versions.ts +24 -14
- package/lib/workflow-runner.d.ts +0 -2
- package/lib/workflow-runner.js +0 -25
- package/src/workflow-runner.ts +0 -24
|
@@ -1,465 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { CLIModule, CommandContext } from '../types';
|
|
3
|
-
import { userCommands } from '../user';
|
|
4
|
-
import {
|
|
5
|
-
getBooleanOption,
|
|
6
|
-
getOptionalStringOption,
|
|
7
|
-
toObjectState,
|
|
8
|
-
} from '../utils/options';
|
|
9
|
-
|
|
10
|
-
type AuthCheckState = {
|
|
11
|
-
hasToken?: boolean;
|
|
12
|
-
validated?: boolean;
|
|
13
|
-
[key: string]: unknown;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type LoginFlowState = {
|
|
17
|
-
alreadyLoggedIn?: boolean;
|
|
18
|
-
loginSuccess?: boolean;
|
|
19
|
-
validationSuccess?: boolean;
|
|
20
|
-
loginError?: string;
|
|
21
|
-
[key: string]: unknown;
|
|
22
|
-
};
|
|
1
|
+
import type { CLIModule } from '../types';
|
|
23
2
|
|
|
24
3
|
export const userModule: CLIModule = {
|
|
25
4
|
name: 'user',
|
|
26
5
|
version: '1.0.0',
|
|
27
|
-
|
|
28
6
|
commands: [],
|
|
29
|
-
|
|
30
|
-
workflows: [
|
|
31
|
-
{
|
|
32
|
-
name: 'auth-check',
|
|
33
|
-
description: 'Check authentication status and user information',
|
|
34
|
-
options: {
|
|
35
|
-
autoLogin: {
|
|
36
|
-
default: false,
|
|
37
|
-
description: 'Automatically login if not authenticated',
|
|
38
|
-
},
|
|
39
|
-
showDetails: {
|
|
40
|
-
default: true,
|
|
41
|
-
description: 'Show detailed user information',
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
steps: [
|
|
45
|
-
{
|
|
46
|
-
name: 'load-session',
|
|
47
|
-
description: 'Load existing session from local storage',
|
|
48
|
-
execute: async (context: CommandContext) => {
|
|
49
|
-
console.log('Loading session from local storage...');
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
await loadSession();
|
|
53
|
-
const session = getSession();
|
|
54
|
-
|
|
55
|
-
if (session?.token) {
|
|
56
|
-
console.log('✓ Session found in local storage');
|
|
57
|
-
return {
|
|
58
|
-
sessionLoaded: true,
|
|
59
|
-
hasToken: true,
|
|
60
|
-
session,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
console.log('✗ No valid session found in local storage');
|
|
64
|
-
return {
|
|
65
|
-
sessionLoaded: true,
|
|
66
|
-
hasToken: false,
|
|
67
|
-
session: null,
|
|
68
|
-
};
|
|
69
|
-
} catch (error) {
|
|
70
|
-
console.log(
|
|
71
|
-
'✗ Failed to load session:',
|
|
72
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
73
|
-
);
|
|
74
|
-
return {
|
|
75
|
-
sessionLoaded: false,
|
|
76
|
-
hasToken: false,
|
|
77
|
-
session: null,
|
|
78
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: 'validate-session',
|
|
85
|
-
description: 'Validate session by calling API',
|
|
86
|
-
execute: async (
|
|
87
|
-
context: CommandContext,
|
|
88
|
-
previousResult?: unknown,
|
|
89
|
-
) => {
|
|
90
|
-
const state = toObjectState<AuthCheckState>(previousResult, {});
|
|
91
|
-
if (!state.hasToken) {
|
|
92
|
-
console.log('No token available, skipping validation');
|
|
93
|
-
return {
|
|
94
|
-
...state,
|
|
95
|
-
validated: false,
|
|
96
|
-
reason: 'No token available',
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
console.log('Validating session with server...');
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
await userCommands.me();
|
|
104
|
-
console.log('✓ Session is valid');
|
|
105
|
-
return {
|
|
106
|
-
...state,
|
|
107
|
-
validated: true,
|
|
108
|
-
reason: 'Session validated successfully',
|
|
109
|
-
};
|
|
110
|
-
} catch (error) {
|
|
111
|
-
console.log(
|
|
112
|
-
'✗ Session validation failed:',
|
|
113
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
114
|
-
);
|
|
115
|
-
return {
|
|
116
|
-
...state,
|
|
117
|
-
validated: false,
|
|
118
|
-
reason:
|
|
119
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
name: 'get-user-info',
|
|
126
|
-
description: 'Get current user information',
|
|
127
|
-
execute: async (
|
|
128
|
-
context: CommandContext,
|
|
129
|
-
previousResult?: unknown,
|
|
130
|
-
) => {
|
|
131
|
-
const state = toObjectState<AuthCheckState>(previousResult, {});
|
|
132
|
-
if (!state.validated) {
|
|
133
|
-
console.log('Session not valid, cannot get user info');
|
|
134
|
-
return {
|
|
135
|
-
...state,
|
|
136
|
-
userInfo: null,
|
|
137
|
-
reason: 'Session not valid',
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
console.log('Getting user information...');
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
const { get } = await import('../api');
|
|
145
|
-
const userInfo = (await get('/user/me')) as Record<
|
|
146
|
-
string,
|
|
147
|
-
unknown
|
|
148
|
-
>;
|
|
149
|
-
|
|
150
|
-
console.log('✓ User information retrieved successfully');
|
|
151
|
-
|
|
152
|
-
const showDetails = getBooleanOption(
|
|
153
|
-
context.options,
|
|
154
|
-
'showDetails',
|
|
155
|
-
true,
|
|
156
|
-
);
|
|
157
|
-
if (showDetails) {
|
|
158
|
-
console.log('\n=== User Information ===');
|
|
159
|
-
for (const [key, value] of Object.entries(userInfo)) {
|
|
160
|
-
if (key !== 'ok') {
|
|
161
|
-
console.log(`${key}: ${value}`);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
console.log('========================\n');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return {
|
|
168
|
-
...state,
|
|
169
|
-
userInfo,
|
|
170
|
-
reason: 'User info retrieved successfully',
|
|
171
|
-
};
|
|
172
|
-
} catch (error) {
|
|
173
|
-
console.log(
|
|
174
|
-
'✗ Failed to get user info:',
|
|
175
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
176
|
-
);
|
|
177
|
-
return {
|
|
178
|
-
...state,
|
|
179
|
-
userInfo: null,
|
|
180
|
-
reason:
|
|
181
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
name: 'handle-auth-failure',
|
|
188
|
-
description: 'Handle authentication failure',
|
|
189
|
-
execute: async (
|
|
190
|
-
context: CommandContext,
|
|
191
|
-
previousResult?: unknown,
|
|
192
|
-
) => {
|
|
193
|
-
const state = toObjectState<AuthCheckState>(previousResult, {});
|
|
194
|
-
if (state.validated) {
|
|
195
|
-
console.log('✓ Authentication check completed successfully');
|
|
196
|
-
return {
|
|
197
|
-
...state,
|
|
198
|
-
authCheckComplete: true,
|
|
199
|
-
status: 'authenticated',
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
console.log('✗ Authentication check failed');
|
|
204
|
-
|
|
205
|
-
const autoLogin = getBooleanOption(
|
|
206
|
-
context.options,
|
|
207
|
-
'autoLogin',
|
|
208
|
-
false,
|
|
209
|
-
);
|
|
210
|
-
if (autoLogin) {
|
|
211
|
-
console.log('Attempting automatic login...');
|
|
212
|
-
try {
|
|
213
|
-
await userCommands.login({ args: [] });
|
|
214
|
-
console.log('✓ Automatic login successful');
|
|
215
|
-
return {
|
|
216
|
-
...state,
|
|
217
|
-
authCheckComplete: true,
|
|
218
|
-
status: 'auto-logged-in',
|
|
219
|
-
autoLoginSuccess: true,
|
|
220
|
-
};
|
|
221
|
-
} catch (error) {
|
|
222
|
-
console.log(
|
|
223
|
-
'✗ Automatic login failed:',
|
|
224
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
225
|
-
);
|
|
226
|
-
return {
|
|
227
|
-
...state,
|
|
228
|
-
authCheckComplete: true,
|
|
229
|
-
status: 'failed',
|
|
230
|
-
autoLoginSuccess: false,
|
|
231
|
-
autoLoginError:
|
|
232
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
} else {
|
|
236
|
-
console.log('Please run login command to authenticate');
|
|
237
|
-
return {
|
|
238
|
-
...state,
|
|
239
|
-
authCheckComplete: true,
|
|
240
|
-
status: 'unauthenticated',
|
|
241
|
-
suggestion: 'Run login command to authenticate',
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
],
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
name: 'login-flow',
|
|
250
|
-
description: 'Complete login flow with validation',
|
|
251
|
-
options: {
|
|
252
|
-
email: { hasValue: true, description: 'User email' },
|
|
253
|
-
password: { hasValue: true, description: 'User password' },
|
|
254
|
-
validateAfterLogin: {
|
|
255
|
-
default: true,
|
|
256
|
-
description: 'Validate session after login',
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
steps: [
|
|
260
|
-
{
|
|
261
|
-
name: 'check-existing-session',
|
|
262
|
-
description: 'Check if user is already logged in',
|
|
263
|
-
execute: async (context: CommandContext) => {
|
|
264
|
-
console.log('Checking existing session...');
|
|
265
|
-
|
|
266
|
-
try {
|
|
267
|
-
await loadSession();
|
|
268
|
-
const session = getSession();
|
|
269
|
-
|
|
270
|
-
if (session?.token) {
|
|
271
|
-
try {
|
|
272
|
-
await userCommands.me();
|
|
273
|
-
console.log('✓ User is already logged in');
|
|
274
|
-
return {
|
|
275
|
-
alreadyLoggedIn: true,
|
|
276
|
-
session: session,
|
|
277
|
-
status: 'authenticated',
|
|
278
|
-
};
|
|
279
|
-
} catch (error) {
|
|
280
|
-
console.log(
|
|
281
|
-
'✗ Existing session is invalid, proceeding with login',
|
|
282
|
-
);
|
|
283
|
-
return {
|
|
284
|
-
alreadyLoggedIn: false,
|
|
285
|
-
session: null,
|
|
286
|
-
status: 'session-expired',
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
} else {
|
|
290
|
-
console.log('No existing session found');
|
|
291
|
-
return {
|
|
292
|
-
alreadyLoggedIn: false,
|
|
293
|
-
session: null,
|
|
294
|
-
status: 'no-session',
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
} catch (error) {
|
|
298
|
-
console.log(
|
|
299
|
-
'Error checking existing session:',
|
|
300
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
301
|
-
);
|
|
302
|
-
return {
|
|
303
|
-
alreadyLoggedIn: false,
|
|
304
|
-
session: null,
|
|
305
|
-
status: 'error',
|
|
306
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
name: 'perform-login',
|
|
313
|
-
description: 'Perform user login',
|
|
314
|
-
execute: async (
|
|
315
|
-
context: CommandContext,
|
|
316
|
-
previousResult?: unknown,
|
|
317
|
-
) => {
|
|
318
|
-
const state = toObjectState<LoginFlowState>(previousResult, {});
|
|
319
|
-
if (state.alreadyLoggedIn) {
|
|
320
|
-
console.log('Skipping login - user already authenticated');
|
|
321
|
-
return {
|
|
322
|
-
...state,
|
|
323
|
-
loginPerformed: false,
|
|
324
|
-
loginSuccess: true,
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
console.log('Performing login...');
|
|
329
|
-
|
|
330
|
-
try {
|
|
331
|
-
const loginArgs: string[] = [];
|
|
332
|
-
const email = getOptionalStringOption(context.options, 'email');
|
|
333
|
-
if (email) {
|
|
334
|
-
loginArgs.push(email);
|
|
335
|
-
}
|
|
336
|
-
const password = getOptionalStringOption(
|
|
337
|
-
context.options,
|
|
338
|
-
'password',
|
|
339
|
-
);
|
|
340
|
-
if (password) {
|
|
341
|
-
loginArgs.push(password);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
await userCommands.login({ args: loginArgs });
|
|
345
|
-
console.log('✓ Login successful');
|
|
346
|
-
|
|
347
|
-
return {
|
|
348
|
-
...state,
|
|
349
|
-
loginPerformed: true,
|
|
350
|
-
loginSuccess: true,
|
|
351
|
-
};
|
|
352
|
-
} catch (error) {
|
|
353
|
-
console.log(
|
|
354
|
-
'✗ Login failed:',
|
|
355
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
356
|
-
);
|
|
357
|
-
return {
|
|
358
|
-
...state,
|
|
359
|
-
loginPerformed: true,
|
|
360
|
-
loginSuccess: false,
|
|
361
|
-
loginError:
|
|
362
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
name: 'validate-login',
|
|
369
|
-
description: 'Validate login by getting user info',
|
|
370
|
-
execute: async (
|
|
371
|
-
context: CommandContext,
|
|
372
|
-
previousResult?: unknown,
|
|
373
|
-
) => {
|
|
374
|
-
const state = toObjectState<LoginFlowState>(previousResult, {});
|
|
375
|
-
if (!state.loginSuccess && !state.alreadyLoggedIn) {
|
|
376
|
-
console.log('Login failed, skipping validation');
|
|
377
|
-
return {
|
|
378
|
-
...state,
|
|
379
|
-
validationPerformed: false,
|
|
380
|
-
validationSuccess: false,
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
const validateAfterLogin = getBooleanOption(
|
|
385
|
-
context.options,
|
|
386
|
-
'validateAfterLogin',
|
|
387
|
-
true,
|
|
388
|
-
);
|
|
389
|
-
if (!validateAfterLogin) {
|
|
390
|
-
console.log('Skipping validation as requested');
|
|
391
|
-
return {
|
|
392
|
-
...state,
|
|
393
|
-
validationPerformed: false,
|
|
394
|
-
validationSuccess: true,
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
console.log('Validating login by getting user information...');
|
|
399
|
-
|
|
400
|
-
try {
|
|
401
|
-
const userInfo = await userCommands.me();
|
|
402
|
-
console.log('✓ Login validation successful');
|
|
403
|
-
|
|
404
|
-
return {
|
|
405
|
-
...state,
|
|
406
|
-
validationPerformed: true,
|
|
407
|
-
validationSuccess: true,
|
|
408
|
-
userInfo,
|
|
409
|
-
};
|
|
410
|
-
} catch (error) {
|
|
411
|
-
console.log(
|
|
412
|
-
'✗ Login validation failed:',
|
|
413
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
414
|
-
);
|
|
415
|
-
return {
|
|
416
|
-
...state,
|
|
417
|
-
validationPerformed: true,
|
|
418
|
-
validationSuccess: false,
|
|
419
|
-
validationError:
|
|
420
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
},
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
name: 'login-summary',
|
|
427
|
-
description: 'Provide login flow summary',
|
|
428
|
-
execute: async (
|
|
429
|
-
context: CommandContext,
|
|
430
|
-
previousResult?: unknown,
|
|
431
|
-
) => {
|
|
432
|
-
const state = toObjectState<LoginFlowState>(previousResult, {});
|
|
433
|
-
console.log('\n=== Login Flow Summary ===');
|
|
434
|
-
|
|
435
|
-
if (state.alreadyLoggedIn) {
|
|
436
|
-
console.log('Status: Already logged in');
|
|
437
|
-
console.log('Session: Valid');
|
|
438
|
-
} else if (state.loginSuccess) {
|
|
439
|
-
console.log('Status: Login successful');
|
|
440
|
-
if (state.validationSuccess) {
|
|
441
|
-
console.log('Validation: Passed');
|
|
442
|
-
} else {
|
|
443
|
-
console.log('Validation: Failed');
|
|
444
|
-
}
|
|
445
|
-
} else {
|
|
446
|
-
console.log('Status: Login failed');
|
|
447
|
-
console.log('Error:', state.loginError || 'Unknown error');
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
console.log('==========================\n');
|
|
451
|
-
|
|
452
|
-
return {
|
|
453
|
-
...state,
|
|
454
|
-
flowComplete: true,
|
|
455
|
-
finalStatus:
|
|
456
|
-
state.alreadyLoggedIn || state.loginSuccess
|
|
457
|
-
? 'success'
|
|
458
|
-
: 'failed',
|
|
459
|
-
};
|
|
460
|
-
},
|
|
461
|
-
},
|
|
462
|
-
],
|
|
463
|
-
},
|
|
464
|
-
],
|
|
465
7
|
};
|
package/src/package.ts
CHANGED
|
@@ -59,7 +59,7 @@ function ensureFileByExt(
|
|
|
59
59
|
extension: NativeUploadConfig['extension'] | '.aab',
|
|
60
60
|
usageKey: string,
|
|
61
61
|
): string {
|
|
62
|
-
if (!filePath
|
|
62
|
+
if (!filePath?.endsWith(extension)) {
|
|
63
63
|
throw new Error(t(usageKey));
|
|
64
64
|
}
|
|
65
65
|
return filePath;
|
|
@@ -274,28 +274,28 @@ export const packageCommands = {
|
|
|
274
274
|
},
|
|
275
275
|
parseApp: async ({ args }: { args: string[] }) => {
|
|
276
276
|
const fn = args[0];
|
|
277
|
-
if (!fn
|
|
277
|
+
if (!fn?.endsWith('.app')) {
|
|
278
278
|
throw new Error(t('usageParseApp'));
|
|
279
279
|
}
|
|
280
280
|
console.log(await getAppInfo(fn));
|
|
281
281
|
},
|
|
282
282
|
parseIpa: async ({ args }: { args: string[] }) => {
|
|
283
283
|
const fn = args[0];
|
|
284
|
-
if (!fn
|
|
284
|
+
if (!fn?.endsWith('.ipa')) {
|
|
285
285
|
throw new Error(t('usageParseIpa'));
|
|
286
286
|
}
|
|
287
287
|
console.log(await getIpaInfo(fn));
|
|
288
288
|
},
|
|
289
289
|
parseApk: async ({ args }: { args: string[] }) => {
|
|
290
290
|
const fn = args[0];
|
|
291
|
-
if (!fn
|
|
291
|
+
if (!fn?.endsWith('.apk')) {
|
|
292
292
|
throw new Error(t('usageParseApk'));
|
|
293
293
|
}
|
|
294
294
|
console.log(await getApkInfo(fn));
|
|
295
295
|
},
|
|
296
296
|
parseAab: async ({ args }: { args: string[] }) => {
|
|
297
297
|
const fn = args[0];
|
|
298
|
-
if (!fn
|
|
298
|
+
if (!fn?.endsWith('.aab')) {
|
|
299
299
|
throw new Error(t('usageParseAab'));
|
|
300
300
|
}
|
|
301
301
|
console.log(await getAabInfo(fn));
|
|
@@ -333,10 +333,8 @@ export const packageCommands = {
|
|
|
333
333
|
await listPackage(String(appId));
|
|
334
334
|
},
|
|
335
335
|
deletePackage: async ({
|
|
336
|
-
args,
|
|
337
336
|
options,
|
|
338
337
|
}: {
|
|
339
|
-
args: string[];
|
|
340
338
|
options: {
|
|
341
339
|
appId?: string;
|
|
342
340
|
packageId?: string;
|
package/src/provider.ts
CHANGED
|
@@ -5,7 +5,6 @@ import type {
|
|
|
5
5
|
CLIProvider,
|
|
6
6
|
CommandContext,
|
|
7
7
|
CommandResult,
|
|
8
|
-
CustomWorkflow,
|
|
9
8
|
Platform,
|
|
10
9
|
PublishOptions,
|
|
11
10
|
Session,
|
|
@@ -13,10 +12,11 @@ import type {
|
|
|
13
12
|
Version,
|
|
14
13
|
} from './types';
|
|
15
14
|
import { runAsCommandResult } from './utils/command-result';
|
|
16
|
-
|
|
15
|
+
|
|
16
|
+
const DEFAULT_BUNDLE_OUTPUT =
|
|
17
|
+
'$' + '{tempDir}/output/$' + '{platform}.$' + '{time}.ppk';
|
|
17
18
|
|
|
18
19
|
export class CLIProviderImpl implements CLIProvider {
|
|
19
|
-
private workflows: Map<string, CustomWorkflow> = new Map();
|
|
20
20
|
private session?: Session;
|
|
21
21
|
private sessionInitPromise?: Promise<void>;
|
|
22
22
|
|
|
@@ -83,7 +83,7 @@ export class CLIProviderImpl implements CLIProvider {
|
|
|
83
83
|
platform: options.platform,
|
|
84
84
|
bundleName: options.bundleName || 'index.bundlejs',
|
|
85
85
|
entryFile: options.entryFile || 'index.js',
|
|
86
|
-
output: options.output ||
|
|
86
|
+
output: options.output || DEFAULT_BUNDLE_OUTPUT,
|
|
87
87
|
sourcemap: options.sourcemap || false,
|
|
88
88
|
taro: options.taro || false,
|
|
89
89
|
expo: options.expo || false,
|
|
@@ -238,27 +238,6 @@ export class CLIProviderImpl implements CLIProvider {
|
|
|
238
238
|
return this.session;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
registerWorkflow(workflow: CustomWorkflow): void {
|
|
242
|
-
this.workflows.set(workflow.name, workflow);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
async executeWorkflow(
|
|
246
|
-
workflowName: string,
|
|
247
|
-
context: CommandContext,
|
|
248
|
-
): Promise<CommandResult> {
|
|
249
|
-
return this.runDataCommand(async () => {
|
|
250
|
-
const workflow = this.workflows.get(workflowName);
|
|
251
|
-
if (!workflow) {
|
|
252
|
-
throw new Error(`Workflow '${workflowName}' not found`);
|
|
253
|
-
}
|
|
254
|
-
const result = await runWorkflow(workflowName, workflow, context);
|
|
255
|
-
return {
|
|
256
|
-
message: `Workflow '${workflowName}' completed successfully`,
|
|
257
|
-
result,
|
|
258
|
-
};
|
|
259
|
-
}, `Workflow '${workflowName}' failed`);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
241
|
async listPackages(appId?: string): Promise<CommandResult> {
|
|
263
242
|
return this.runDataCommand(async () => {
|
|
264
243
|
const { listPackage } = await import('./package');
|
package/src/types.ts
CHANGED
|
@@ -92,31 +92,6 @@ export interface UploadOptions {
|
|
|
92
92
|
version?: string;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
export interface WorkflowStep {
|
|
96
|
-
name: string;
|
|
97
|
-
description?: string;
|
|
98
|
-
execute: (
|
|
99
|
-
context: CommandContext,
|
|
100
|
-
previousResult?: unknown,
|
|
101
|
-
) => Promise<unknown>;
|
|
102
|
-
condition?: (context: CommandContext) => boolean;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface CustomWorkflow {
|
|
106
|
-
name: string;
|
|
107
|
-
description?: string;
|
|
108
|
-
steps: WorkflowStep[];
|
|
109
|
-
validate?: (context: CommandContext) => boolean;
|
|
110
|
-
options?: Record<
|
|
111
|
-
string,
|
|
112
|
-
{
|
|
113
|
-
hasValue?: boolean;
|
|
114
|
-
default?: unknown;
|
|
115
|
-
description?: string;
|
|
116
|
-
}
|
|
117
|
-
>;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
95
|
export interface CLIProvider {
|
|
121
96
|
bundle: (options: BundleOptions) => Promise<CommandResult>;
|
|
122
97
|
publish: (options: PublishOptions) => Promise<CommandResult>;
|
|
@@ -137,19 +112,12 @@ export interface CLIProvider {
|
|
|
137
112
|
|
|
138
113
|
getPlatform: (platform?: Platform) => Promise<Platform>;
|
|
139
114
|
loadSession: () => Promise<Session>;
|
|
140
|
-
|
|
141
|
-
registerWorkflow: (workflow: CustomWorkflow) => void;
|
|
142
|
-
executeWorkflow: (
|
|
143
|
-
workflowName: string,
|
|
144
|
-
context: CommandContext,
|
|
145
|
-
) => Promise<CommandResult>;
|
|
146
115
|
}
|
|
147
116
|
|
|
148
117
|
export interface CLIModule {
|
|
149
118
|
name: string;
|
|
150
119
|
version: string;
|
|
151
120
|
commands?: CommandDefinition[];
|
|
152
|
-
workflows?: CustomWorkflow[];
|
|
153
121
|
init?: (provider: CLIProvider) => void;
|
|
154
122
|
cleanup?: () => void;
|
|
155
123
|
}
|
package/src/user.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const userCommands = {
|
|
|
20
20
|
await saveSession();
|
|
21
21
|
console.log(t('welcomeMessage', { name: info.name }));
|
|
22
22
|
},
|
|
23
|
-
logout: async (
|
|
23
|
+
logout: async (_context: CommandContext) => {
|
|
24
24
|
await closeSession();
|
|
25
25
|
console.log(t('loggedOut'));
|
|
26
26
|
},
|
|
@@ -88,7 +88,7 @@ export class AabParser extends Zip {
|
|
|
88
88
|
'--overwrite',
|
|
89
89
|
...modulesArgs,
|
|
90
90
|
]);
|
|
91
|
-
} catch (
|
|
91
|
+
} catch (_e) {
|
|
92
92
|
// Fallback to npx node-bundletool if bundletool is not in PATH
|
|
93
93
|
// We use -y to avoid interactive prompt for installation
|
|
94
94
|
if (await needsNpxDownload()) {
|
|
@@ -74,14 +74,14 @@ export class ResourceFinder {
|
|
|
74
74
|
while (true) {
|
|
75
75
|
let pos = 0;
|
|
76
76
|
let t = 0;
|
|
77
|
-
let
|
|
77
|
+
let _hs = 0;
|
|
78
78
|
let s = 0;
|
|
79
79
|
try {
|
|
80
80
|
pos = bb.offset;
|
|
81
81
|
t = bb.readShort();
|
|
82
|
-
|
|
82
|
+
_hs = bb.readShort();
|
|
83
83
|
s = bb.readInt();
|
|
84
|
-
} catch (
|
|
84
|
+
} catch (_e) {
|
|
85
85
|
break;
|
|
86
86
|
}
|
|
87
87
|
if (t === RES_STRING_POOL_TYPE) {
|
|
@@ -231,7 +231,7 @@ export class ResourceFinder {
|
|
|
231
231
|
if (!bb.remaining()) {
|
|
232
232
|
break;
|
|
233
233
|
}
|
|
234
|
-
} catch (
|
|
234
|
+
} catch (_e) {
|
|
235
235
|
break;
|
|
236
236
|
}
|
|
237
237
|
}
|
|
@@ -288,7 +288,7 @@ export class ResourceFinder {
|
|
|
288
288
|
entrySize = bb.readShort();
|
|
289
289
|
entryFlag = bb.readShort();
|
|
290
290
|
entryKey = bb.readInt();
|
|
291
|
-
} catch (
|
|
291
|
+
} catch (_e) {
|
|
292
292
|
break;
|
|
293
293
|
}
|
|
294
294
|
|