react-native-update-cli 2.10.1 → 2.11.0
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 +1 -1
- package/lib/app.js +42 -45
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +70 -0
- package/lib/bundle-runner.d.ts +1 -0
- package/lib/bundle-runner.js +46 -10
- package/lib/exports.d.ts +2 -9
- package/lib/exports.js +0 -31
- package/lib/index.d.ts +1 -5
- package/lib/index.js +12 -128
- 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/package.d.ts +1 -2
- package/lib/package.js +50 -10
- package/lib/provider.d.ts +1 -4
- package/lib/provider.js +6 -25
- package/lib/types.d.ts +0 -37
- package/lib/user.d.ts +1 -1
- package/lib/user.js +1 -1
- package/lib/utils/app-info-parser/aab.js +46 -5
- 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 +0 -1
- package/lib/utils/index.js +0 -13
- package/lib/utils/plugin-config.js +42 -6
- package/lib/versions.d.ts +1 -0
- package/lib/versions.js +19 -16
- package/package.json +8 -10
- package/src/api.ts +1 -1
- package/src/app.ts +40 -40
- package/src/bin.ts +86 -0
- package/src/bundle-runner.ts +70 -12
- package/src/exports.ts +1 -12
- package/src/index.ts +1 -159
- package/src/locales/en.ts +1 -0
- package/src/locales/zh.ts +1 -0
- package/src/package.ts +6 -10
- package/src/provider.ts +10 -29
- package/src/types.ts +0 -54
- package/src/user.ts +1 -1
- package/src/utils/app-info-parser/aab.ts +2 -2
- 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 -12
- package/src/utils/plugin-config.ts +1 -1
- package/src/versions.ts +25 -17
- package/lib/module-manager.d.ts +0 -20
- package/lib/module-manager.js +0 -118
- package/lib/modules/app-module.d.ts +0 -2
- package/lib/modules/app-module.js +0 -263
- package/lib/modules/bundle-module.d.ts +0 -2
- package/lib/modules/bundle-module.js +0 -187
- package/lib/modules/index.d.ts +0 -6
- package/lib/modules/index.js +0 -42
- package/lib/modules/package-module.d.ts +0 -2
- package/lib/modules/package-module.js +0 -16
- package/lib/modules/user-module.d.ts +0 -2
- package/lib/modules/user-module.js +0 -413
- package/lib/modules/version-module.d.ts +0 -2
- package/lib/modules/version-module.js +0 -16
- package/lib/workflow-runner.d.ts +0 -2
- package/lib/workflow-runner.js +0 -25
- package/src/module-manager.ts +0 -145
- package/src/modules/app-module.ts +0 -277
- package/src/modules/bundle-module.ts +0 -212
- package/src/modules/index.ts +0 -19
- package/src/modules/package-module.ts +0 -10
- package/src/modules/user-module.ts +0 -465
- package/src/modules/version-module.ts +0 -8
- package/src/workflow-runner.ts +0 -24
|
@@ -1,413 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "userModule", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return userModule;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _api = require("../api");
|
|
12
|
-
const _user = require("../user");
|
|
13
|
-
const _options = require("../utils/options");
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
15
|
-
if (typeof WeakMap !== "function") return null;
|
|
16
|
-
var cacheBabelInterop = new WeakMap();
|
|
17
|
-
var cacheNodeInterop = new WeakMap();
|
|
18
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
19
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
20
|
-
})(nodeInterop);
|
|
21
|
-
}
|
|
22
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
23
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
24
|
-
return obj;
|
|
25
|
-
}
|
|
26
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
27
|
-
return {
|
|
28
|
-
default: obj
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
32
|
-
if (cache && cache.has(obj)) {
|
|
33
|
-
return cache.get(obj);
|
|
34
|
-
}
|
|
35
|
-
var newObj = {
|
|
36
|
-
__proto__: null
|
|
37
|
-
};
|
|
38
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
39
|
-
for(var key in obj){
|
|
40
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
41
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
42
|
-
if (desc && (desc.get || desc.set)) {
|
|
43
|
-
Object.defineProperty(newObj, key, desc);
|
|
44
|
-
} else {
|
|
45
|
-
newObj[key] = obj[key];
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
newObj.default = obj;
|
|
50
|
-
if (cache) {
|
|
51
|
-
cache.set(obj, newObj);
|
|
52
|
-
}
|
|
53
|
-
return newObj;
|
|
54
|
-
}
|
|
55
|
-
const userModule = {
|
|
56
|
-
name: 'user',
|
|
57
|
-
version: '1.0.0',
|
|
58
|
-
commands: [],
|
|
59
|
-
workflows: [
|
|
60
|
-
{
|
|
61
|
-
name: 'auth-check',
|
|
62
|
-
description: 'Check authentication status and user information',
|
|
63
|
-
options: {
|
|
64
|
-
autoLogin: {
|
|
65
|
-
default: false,
|
|
66
|
-
description: 'Automatically login if not authenticated'
|
|
67
|
-
},
|
|
68
|
-
showDetails: {
|
|
69
|
-
default: true,
|
|
70
|
-
description: 'Show detailed user information'
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
steps: [
|
|
74
|
-
{
|
|
75
|
-
name: 'load-session',
|
|
76
|
-
description: 'Load existing session from local storage',
|
|
77
|
-
execute: async (context)=>{
|
|
78
|
-
console.log('Loading session from local storage...');
|
|
79
|
-
try {
|
|
80
|
-
await (0, _api.loadSession)();
|
|
81
|
-
const session = (0, _api.getSession)();
|
|
82
|
-
if (session == null ? void 0 : session.token) {
|
|
83
|
-
console.log('✓ Session found in local storage');
|
|
84
|
-
return {
|
|
85
|
-
sessionLoaded: true,
|
|
86
|
-
hasToken: true,
|
|
87
|
-
session
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
console.log('✗ No valid session found in local storage');
|
|
91
|
-
return {
|
|
92
|
-
sessionLoaded: true,
|
|
93
|
-
hasToken: false,
|
|
94
|
-
session: null
|
|
95
|
-
};
|
|
96
|
-
} catch (error) {
|
|
97
|
-
console.log('✗ Failed to load session:', error instanceof Error ? error.message : 'Unknown error');
|
|
98
|
-
return {
|
|
99
|
-
sessionLoaded: false,
|
|
100
|
-
hasToken: false,
|
|
101
|
-
session: null,
|
|
102
|
-
error: error instanceof Error ? error.message : 'Unknown error'
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: 'validate-session',
|
|
109
|
-
description: 'Validate session by calling API',
|
|
110
|
-
execute: async (context, previousResult)=>{
|
|
111
|
-
const state = (0, _options.toObjectState)(previousResult, {});
|
|
112
|
-
if (!state.hasToken) {
|
|
113
|
-
console.log('No token available, skipping validation');
|
|
114
|
-
return {
|
|
115
|
-
...state,
|
|
116
|
-
validated: false,
|
|
117
|
-
reason: 'No token available'
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
console.log('Validating session with server...');
|
|
121
|
-
try {
|
|
122
|
-
await _user.userCommands.me();
|
|
123
|
-
console.log('✓ Session is valid');
|
|
124
|
-
return {
|
|
125
|
-
...state,
|
|
126
|
-
validated: true,
|
|
127
|
-
reason: 'Session validated successfully'
|
|
128
|
-
};
|
|
129
|
-
} catch (error) {
|
|
130
|
-
console.log('✗ Session validation failed:', error instanceof Error ? error.message : 'Unknown error');
|
|
131
|
-
return {
|
|
132
|
-
...state,
|
|
133
|
-
validated: false,
|
|
134
|
-
reason: error instanceof Error ? error.message : 'Unknown error'
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: 'get-user-info',
|
|
141
|
-
description: 'Get current user information',
|
|
142
|
-
execute: async (context, previousResult)=>{
|
|
143
|
-
const state = (0, _options.toObjectState)(previousResult, {});
|
|
144
|
-
if (!state.validated) {
|
|
145
|
-
console.log('Session not valid, cannot get user info');
|
|
146
|
-
return {
|
|
147
|
-
...state,
|
|
148
|
-
userInfo: null,
|
|
149
|
-
reason: 'Session not valid'
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
console.log('Getting user information...');
|
|
153
|
-
try {
|
|
154
|
-
const { get } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("../api")));
|
|
155
|
-
const userInfo = await get('/user/me');
|
|
156
|
-
console.log('✓ User information retrieved successfully');
|
|
157
|
-
const showDetails = (0, _options.getBooleanOption)(context.options, 'showDetails', true);
|
|
158
|
-
if (showDetails) {
|
|
159
|
-
console.log('\n=== User Information ===');
|
|
160
|
-
for (const [key, value] of Object.entries(userInfo)){
|
|
161
|
-
if (key !== 'ok') {
|
|
162
|
-
console.log(`${key}: ${value}`);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
console.log('========================\n');
|
|
166
|
-
}
|
|
167
|
-
return {
|
|
168
|
-
...state,
|
|
169
|
-
userInfo,
|
|
170
|
-
reason: 'User info retrieved successfully'
|
|
171
|
-
};
|
|
172
|
-
} catch (error) {
|
|
173
|
-
console.log('✗ Failed to get user info:', error instanceof Error ? error.message : 'Unknown error');
|
|
174
|
-
return {
|
|
175
|
-
...state,
|
|
176
|
-
userInfo: null,
|
|
177
|
-
reason: error instanceof Error ? error.message : 'Unknown error'
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
name: 'handle-auth-failure',
|
|
184
|
-
description: 'Handle authentication failure',
|
|
185
|
-
execute: async (context, previousResult)=>{
|
|
186
|
-
const state = (0, _options.toObjectState)(previousResult, {});
|
|
187
|
-
if (state.validated) {
|
|
188
|
-
console.log('✓ Authentication check completed successfully');
|
|
189
|
-
return {
|
|
190
|
-
...state,
|
|
191
|
-
authCheckComplete: true,
|
|
192
|
-
status: 'authenticated'
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
console.log('✗ Authentication check failed');
|
|
196
|
-
const autoLogin = (0, _options.getBooleanOption)(context.options, 'autoLogin', false);
|
|
197
|
-
if (autoLogin) {
|
|
198
|
-
console.log('Attempting automatic login...');
|
|
199
|
-
try {
|
|
200
|
-
await _user.userCommands.login({
|
|
201
|
-
args: []
|
|
202
|
-
});
|
|
203
|
-
console.log('✓ Automatic login successful');
|
|
204
|
-
return {
|
|
205
|
-
...state,
|
|
206
|
-
authCheckComplete: true,
|
|
207
|
-
status: 'auto-logged-in',
|
|
208
|
-
autoLoginSuccess: true
|
|
209
|
-
};
|
|
210
|
-
} catch (error) {
|
|
211
|
-
console.log('✗ Automatic login failed:', error instanceof Error ? error.message : 'Unknown error');
|
|
212
|
-
return {
|
|
213
|
-
...state,
|
|
214
|
-
authCheckComplete: true,
|
|
215
|
-
status: 'failed',
|
|
216
|
-
autoLoginSuccess: false,
|
|
217
|
-
autoLoginError: error instanceof Error ? error.message : 'Unknown error'
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
} else {
|
|
221
|
-
console.log('Please run login command to authenticate');
|
|
222
|
-
return {
|
|
223
|
-
...state,
|
|
224
|
-
authCheckComplete: true,
|
|
225
|
-
status: 'unauthenticated',
|
|
226
|
-
suggestion: 'Run login command to authenticate'
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
]
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
name: 'login-flow',
|
|
235
|
-
description: 'Complete login flow with validation',
|
|
236
|
-
options: {
|
|
237
|
-
email: {
|
|
238
|
-
hasValue: true,
|
|
239
|
-
description: 'User email'
|
|
240
|
-
},
|
|
241
|
-
password: {
|
|
242
|
-
hasValue: true,
|
|
243
|
-
description: 'User password'
|
|
244
|
-
},
|
|
245
|
-
validateAfterLogin: {
|
|
246
|
-
default: true,
|
|
247
|
-
description: 'Validate session after login'
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
steps: [
|
|
251
|
-
{
|
|
252
|
-
name: 'check-existing-session',
|
|
253
|
-
description: 'Check if user is already logged in',
|
|
254
|
-
execute: async (context)=>{
|
|
255
|
-
console.log('Checking existing session...');
|
|
256
|
-
try {
|
|
257
|
-
await (0, _api.loadSession)();
|
|
258
|
-
const session = (0, _api.getSession)();
|
|
259
|
-
if (session == null ? void 0 : session.token) {
|
|
260
|
-
try {
|
|
261
|
-
await _user.userCommands.me();
|
|
262
|
-
console.log('✓ User is already logged in');
|
|
263
|
-
return {
|
|
264
|
-
alreadyLoggedIn: true,
|
|
265
|
-
session: session,
|
|
266
|
-
status: 'authenticated'
|
|
267
|
-
};
|
|
268
|
-
} catch (error) {
|
|
269
|
-
console.log('✗ Existing session is invalid, proceeding with login');
|
|
270
|
-
return {
|
|
271
|
-
alreadyLoggedIn: false,
|
|
272
|
-
session: null,
|
|
273
|
-
status: 'session-expired'
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
} else {
|
|
277
|
-
console.log('No existing session found');
|
|
278
|
-
return {
|
|
279
|
-
alreadyLoggedIn: false,
|
|
280
|
-
session: null,
|
|
281
|
-
status: 'no-session'
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
} catch (error) {
|
|
285
|
-
console.log('Error checking existing session:', error instanceof Error ? error.message : 'Unknown error');
|
|
286
|
-
return {
|
|
287
|
-
alreadyLoggedIn: false,
|
|
288
|
-
session: null,
|
|
289
|
-
status: 'error',
|
|
290
|
-
error: error instanceof Error ? error.message : 'Unknown error'
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
name: 'perform-login',
|
|
297
|
-
description: 'Perform user login',
|
|
298
|
-
execute: async (context, previousResult)=>{
|
|
299
|
-
const state = (0, _options.toObjectState)(previousResult, {});
|
|
300
|
-
if (state.alreadyLoggedIn) {
|
|
301
|
-
console.log('Skipping login - user already authenticated');
|
|
302
|
-
return {
|
|
303
|
-
...state,
|
|
304
|
-
loginPerformed: false,
|
|
305
|
-
loginSuccess: true
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
console.log('Performing login...');
|
|
309
|
-
try {
|
|
310
|
-
const loginArgs = [];
|
|
311
|
-
const email = (0, _options.getOptionalStringOption)(context.options, 'email');
|
|
312
|
-
if (email) {
|
|
313
|
-
loginArgs.push(email);
|
|
314
|
-
}
|
|
315
|
-
const password = (0, _options.getOptionalStringOption)(context.options, 'password');
|
|
316
|
-
if (password) {
|
|
317
|
-
loginArgs.push(password);
|
|
318
|
-
}
|
|
319
|
-
await _user.userCommands.login({
|
|
320
|
-
args: loginArgs
|
|
321
|
-
});
|
|
322
|
-
console.log('✓ Login successful');
|
|
323
|
-
return {
|
|
324
|
-
...state,
|
|
325
|
-
loginPerformed: true,
|
|
326
|
-
loginSuccess: true
|
|
327
|
-
};
|
|
328
|
-
} catch (error) {
|
|
329
|
-
console.log('✗ Login failed:', error instanceof Error ? error.message : 'Unknown error');
|
|
330
|
-
return {
|
|
331
|
-
...state,
|
|
332
|
-
loginPerformed: true,
|
|
333
|
-
loginSuccess: false,
|
|
334
|
-
loginError: error instanceof Error ? error.message : 'Unknown error'
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
name: 'validate-login',
|
|
341
|
-
description: 'Validate login by getting user info',
|
|
342
|
-
execute: async (context, previousResult)=>{
|
|
343
|
-
const state = (0, _options.toObjectState)(previousResult, {});
|
|
344
|
-
if (!state.loginSuccess && !state.alreadyLoggedIn) {
|
|
345
|
-
console.log('Login failed, skipping validation');
|
|
346
|
-
return {
|
|
347
|
-
...state,
|
|
348
|
-
validationPerformed: false,
|
|
349
|
-
validationSuccess: false
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
const validateAfterLogin = (0, _options.getBooleanOption)(context.options, 'validateAfterLogin', true);
|
|
353
|
-
if (!validateAfterLogin) {
|
|
354
|
-
console.log('Skipping validation as requested');
|
|
355
|
-
return {
|
|
356
|
-
...state,
|
|
357
|
-
validationPerformed: false,
|
|
358
|
-
validationSuccess: true
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
console.log('Validating login by getting user information...');
|
|
362
|
-
try {
|
|
363
|
-
const userInfo = await _user.userCommands.me();
|
|
364
|
-
console.log('✓ Login validation successful');
|
|
365
|
-
return {
|
|
366
|
-
...state,
|
|
367
|
-
validationPerformed: true,
|
|
368
|
-
validationSuccess: true,
|
|
369
|
-
userInfo
|
|
370
|
-
};
|
|
371
|
-
} catch (error) {
|
|
372
|
-
console.log('✗ Login validation failed:', error instanceof Error ? error.message : 'Unknown error');
|
|
373
|
-
return {
|
|
374
|
-
...state,
|
|
375
|
-
validationPerformed: true,
|
|
376
|
-
validationSuccess: false,
|
|
377
|
-
validationError: error instanceof Error ? error.message : 'Unknown error'
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
name: 'login-summary',
|
|
384
|
-
description: 'Provide login flow summary',
|
|
385
|
-
execute: async (context, previousResult)=>{
|
|
386
|
-
const state = (0, _options.toObjectState)(previousResult, {});
|
|
387
|
-
console.log('\n=== Login Flow Summary ===');
|
|
388
|
-
if (state.alreadyLoggedIn) {
|
|
389
|
-
console.log('Status: Already logged in');
|
|
390
|
-
console.log('Session: Valid');
|
|
391
|
-
} else if (state.loginSuccess) {
|
|
392
|
-
console.log('Status: Login successful');
|
|
393
|
-
if (state.validationSuccess) {
|
|
394
|
-
console.log('Validation: Passed');
|
|
395
|
-
} else {
|
|
396
|
-
console.log('Validation: Failed');
|
|
397
|
-
}
|
|
398
|
-
} else {
|
|
399
|
-
console.log('Status: Login failed');
|
|
400
|
-
console.log('Error:', state.loginError || 'Unknown error');
|
|
401
|
-
}
|
|
402
|
-
console.log('==========================\n');
|
|
403
|
-
return {
|
|
404
|
-
...state,
|
|
405
|
-
flowComplete: true,
|
|
406
|
-
finalStatus: state.alreadyLoggedIn || state.loginSuccess ? 'success' : 'failed'
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
]
|
|
411
|
-
}
|
|
412
|
-
]
|
|
413
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "versionModule", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return versionModule;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const versionModule = {
|
|
12
|
-
name: 'version',
|
|
13
|
-
version: '1.0.0',
|
|
14
|
-
commands: [],
|
|
15
|
-
workflows: []
|
|
16
|
-
};
|
package/lib/workflow-runner.d.ts
DELETED
package/lib/workflow-runner.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "runWorkflow", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return runWorkflow;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
async function runWorkflow(workflowName, workflow, context) {
|
|
12
|
-
if (workflow.validate && !workflow.validate(context)) {
|
|
13
|
-
throw new Error(`Workflow '${workflowName}' validation failed`);
|
|
14
|
-
}
|
|
15
|
-
let previousResult;
|
|
16
|
-
for (const step of workflow.steps){
|
|
17
|
-
if (step.condition && !step.condition(context)) {
|
|
18
|
-
console.log(`Skipping step '${step.name}' due to condition`);
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
console.log(`Executing step '${step.name}'`);
|
|
22
|
-
previousResult = await step.execute(context, previousResult);
|
|
23
|
-
}
|
|
24
|
-
return previousResult;
|
|
25
|
-
}
|
package/src/module-manager.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { CLIProviderImpl } from './provider';
|
|
2
|
-
import type {
|
|
3
|
-
CLIModule,
|
|
4
|
-
CLIProvider,
|
|
5
|
-
CommandContext,
|
|
6
|
-
CommandDefinition,
|
|
7
|
-
CommandResult,
|
|
8
|
-
CustomWorkflow,
|
|
9
|
-
} from './types';
|
|
10
|
-
|
|
11
|
-
export class ModuleManager {
|
|
12
|
-
private modules: Map<string, CLIModule> = new Map();
|
|
13
|
-
private provider: CLIProvider;
|
|
14
|
-
private commands: Map<string, CommandDefinition> = new Map();
|
|
15
|
-
private workflows: Map<string, CustomWorkflow> = new Map();
|
|
16
|
-
|
|
17
|
-
constructor() {
|
|
18
|
-
this.provider = new CLIProviderImpl();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
registerModule(module: CLIModule): void {
|
|
22
|
-
if (this.modules.has(module.name)) {
|
|
23
|
-
throw new Error(`Module '${module.name}' is already registered`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
this.modules.set(module.name, module);
|
|
27
|
-
|
|
28
|
-
if (module.commands) {
|
|
29
|
-
for (const command of module.commands) {
|
|
30
|
-
this.registerCommand(command);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (module.workflows) {
|
|
35
|
-
for (const workflow of module.workflows) {
|
|
36
|
-
this.registerWorkflow(workflow);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (module.init) {
|
|
41
|
-
module.init(this.provider);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
unregisterModule(moduleName: string): void {
|
|
46
|
-
const module = this.modules.get(moduleName);
|
|
47
|
-
if (!module) {
|
|
48
|
-
throw new Error(`Module '${moduleName}' is not registered`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (module.commands) {
|
|
52
|
-
for (const command of module.commands) {
|
|
53
|
-
this.commands.delete(command.name);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (module.workflows) {
|
|
58
|
-
for (const workflow of module.workflows) {
|
|
59
|
-
this.workflows.delete(workflow.name);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (module.cleanup) {
|
|
64
|
-
module.cleanup();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
this.modules.delete(moduleName);
|
|
68
|
-
console.log(`Module '${moduleName}' unregistered successfully`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
registerCommand(command: CommandDefinition): void {
|
|
72
|
-
if (this.commands.has(command.name)) {
|
|
73
|
-
throw new Error(`Command '${command.name}' is already registered`);
|
|
74
|
-
}
|
|
75
|
-
this.commands.set(command.name, command);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
registerWorkflow(workflow: CustomWorkflow): void {
|
|
79
|
-
if (this.workflows.has(workflow.name)) {
|
|
80
|
-
throw new Error(`Workflow '${workflow.name}' is already registered`);
|
|
81
|
-
}
|
|
82
|
-
this.workflows.set(workflow.name, workflow);
|
|
83
|
-
this.provider.registerWorkflow(workflow);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async executeCommand(
|
|
87
|
-
commandName: string,
|
|
88
|
-
context: CommandContext,
|
|
89
|
-
): Promise<CommandResult> {
|
|
90
|
-
const command = this.commands.get(commandName);
|
|
91
|
-
if (!command) {
|
|
92
|
-
throw new Error(`Command '${commandName}' not found`);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return await command.handler(context);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async executeWorkflow(
|
|
99
|
-
workflowName: string,
|
|
100
|
-
context: CommandContext,
|
|
101
|
-
): Promise<CommandResult> {
|
|
102
|
-
return await this.provider.executeWorkflow(workflowName, context);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
getProvider(): CLIProvider {
|
|
106
|
-
return this.provider;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
listCommands(): CommandDefinition[] {
|
|
110
|
-
return Array.from(this.commands.values());
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
listWorkflows(): CustomWorkflow[] {
|
|
114
|
-
return Array.from(this.workflows.values());
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
listModules(): CLIModule[] {
|
|
118
|
-
return Array.from(this.modules.values());
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
listAll(): void {
|
|
122
|
-
console.log('\n=== Registered Commands ===');
|
|
123
|
-
for (const command of this.commands.values()) {
|
|
124
|
-
console.log(
|
|
125
|
-
` ${command.name}: ${command.description || 'No description'}`,
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
console.log('\n=== Registered Workflows ===');
|
|
130
|
-
for (const workflow of this.workflows.values()) {
|
|
131
|
-
console.log(
|
|
132
|
-
` ${workflow.name}: ${workflow.description || 'No description'}`,
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
console.log('\n=== Registered Modules ===');
|
|
137
|
-
for (const module of this.modules.values()) {
|
|
138
|
-
console.log(
|
|
139
|
-
` ${module.name} (v${module.version}): ${module.commands?.length || 0} commands, ${module.workflows?.length || 0} workflows`,
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export const moduleManager = new ModuleManager();
|