test-genie-mcp 2.0.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.
Files changed (102) hide show
  1. package/README.md +219 -0
  2. package/dist/analyzers/astAnalyzer.d.ts +108 -0
  3. package/dist/analyzers/astAnalyzer.d.ts.map +1 -0
  4. package/dist/analyzers/astAnalyzer.js +800 -0
  5. package/dist/analyzers/astAnalyzer.js.map +1 -0
  6. package/dist/analyzers/performanceAnalyzer.d.ts +90 -0
  7. package/dist/analyzers/performanceAnalyzer.d.ts.map +1 -0
  8. package/dist/analyzers/performanceAnalyzer.js +647 -0
  9. package/dist/analyzers/performanceAnalyzer.js.map +1 -0
  10. package/dist/index.d.ts +3 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +683 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/platforms/android/index.d.ts +90 -0
  15. package/dist/platforms/android/index.d.ts.map +1 -0
  16. package/dist/platforms/android/index.js +519 -0
  17. package/dist/platforms/android/index.js.map +1 -0
  18. package/dist/platforms/flutter/index.d.ts +105 -0
  19. package/dist/platforms/flutter/index.d.ts.map +1 -0
  20. package/dist/platforms/flutter/index.js +533 -0
  21. package/dist/platforms/flutter/index.js.map +1 -0
  22. package/dist/platforms/ios/index.d.ts +79 -0
  23. package/dist/platforms/ios/index.d.ts.map +1 -0
  24. package/dist/platforms/ios/index.js +393 -0
  25. package/dist/platforms/ios/index.js.map +1 -0
  26. package/dist/platforms/react-native/index.d.ts +160 -0
  27. package/dist/platforms/react-native/index.d.ts.map +1 -0
  28. package/dist/platforms/react-native/index.js +602 -0
  29. package/dist/platforms/react-native/index.js.map +1 -0
  30. package/dist/platforms/web/index.d.ts +177 -0
  31. package/dist/platforms/web/index.d.ts.map +1 -0
  32. package/dist/platforms/web/index.js +637 -0
  33. package/dist/platforms/web/index.js.map +1 -0
  34. package/dist/storage/index.d.ts +35 -0
  35. package/dist/storage/index.d.ts.map +1 -0
  36. package/dist/storage/index.js +351 -0
  37. package/dist/storage/index.js.map +1 -0
  38. package/dist/tools/analysis/analyzeAppStructure.d.ts +9 -0
  39. package/dist/tools/analysis/analyzeAppStructure.d.ts.map +1 -0
  40. package/dist/tools/analysis/analyzeAppStructure.js +289 -0
  41. package/dist/tools/analysis/analyzeAppStructure.js.map +1 -0
  42. package/dist/tools/analysis/createTestPlan.d.ts +21 -0
  43. package/dist/tools/analysis/createTestPlan.d.ts.map +1 -0
  44. package/dist/tools/analysis/createTestPlan.js +214 -0
  45. package/dist/tools/analysis/createTestPlan.js.map +1 -0
  46. package/dist/tools/analysis/generateScenarios.d.ts +21 -0
  47. package/dist/tools/analysis/generateScenarios.d.ts.map +1 -0
  48. package/dist/tools/analysis/generateScenarios.js +567 -0
  49. package/dist/tools/analysis/generateScenarios.js.map +1 -0
  50. package/dist/tools/automation/cicdIntegration.d.ts +41 -0
  51. package/dist/tools/automation/cicdIntegration.d.ts.map +1 -0
  52. package/dist/tools/automation/cicdIntegration.js +825 -0
  53. package/dist/tools/automation/cicdIntegration.js.map +1 -0
  54. package/dist/tools/automation/generateReport.d.ts +16 -0
  55. package/dist/tools/automation/generateReport.d.ts.map +1 -0
  56. package/dist/tools/automation/generateReport.js +406 -0
  57. package/dist/tools/automation/generateReport.js.map +1 -0
  58. package/dist/tools/automation/runFullAutomation.d.ts +25 -0
  59. package/dist/tools/automation/runFullAutomation.d.ts.map +1 -0
  60. package/dist/tools/automation/runFullAutomation.js +296 -0
  61. package/dist/tools/automation/runFullAutomation.js.map +1 -0
  62. package/dist/tools/detection/detectLogicErrors.d.ts +18 -0
  63. package/dist/tools/detection/detectLogicErrors.d.ts.map +1 -0
  64. package/dist/tools/detection/detectLogicErrors.js +470 -0
  65. package/dist/tools/detection/detectLogicErrors.js.map +1 -0
  66. package/dist/tools/detection/detectMemoryLeaks.d.ts +23 -0
  67. package/dist/tools/detection/detectMemoryLeaks.d.ts.map +1 -0
  68. package/dist/tools/detection/detectMemoryLeaks.js +453 -0
  69. package/dist/tools/detection/detectMemoryLeaks.js.map +1 -0
  70. package/dist/tools/execution/runScenarioTest.d.ts +34 -0
  71. package/dist/tools/execution/runScenarioTest.d.ts.map +1 -0
  72. package/dist/tools/execution/runScenarioTest.js +334 -0
  73. package/dist/tools/execution/runScenarioTest.js.map +1 -0
  74. package/dist/tools/execution/runSimulation.d.ts +17 -0
  75. package/dist/tools/execution/runSimulation.d.ts.map +1 -0
  76. package/dist/tools/execution/runSimulation.js +250 -0
  77. package/dist/tools/execution/runSimulation.js.map +1 -0
  78. package/dist/tools/execution/runStressTest.d.ts +52 -0
  79. package/dist/tools/execution/runStressTest.d.ts.map +1 -0
  80. package/dist/tools/execution/runStressTest.js +176 -0
  81. package/dist/tools/execution/runStressTest.js.map +1 -0
  82. package/dist/tools/fixing/applyFix.d.ts +44 -0
  83. package/dist/tools/fixing/applyFix.d.ts.map +1 -0
  84. package/dist/tools/fixing/applyFix.js +399 -0
  85. package/dist/tools/fixing/applyFix.js.map +1 -0
  86. package/dist/tools/fixing/confirmFix.d.ts +31 -0
  87. package/dist/tools/fixing/confirmFix.d.ts.map +1 -0
  88. package/dist/tools/fixing/confirmFix.js +136 -0
  89. package/dist/tools/fixing/confirmFix.js.map +1 -0
  90. package/dist/tools/fixing/suggestFixes.d.ts +23 -0
  91. package/dist/tools/fixing/suggestFixes.d.ts.map +1 -0
  92. package/dist/tools/fixing/suggestFixes.js +349 -0
  93. package/dist/tools/fixing/suggestFixes.js.map +1 -0
  94. package/dist/types.d.ts +322 -0
  95. package/dist/types.d.ts.map +1 -0
  96. package/dist/types.js +6 -0
  97. package/dist/types.js.map +1 -0
  98. package/dist/utils/codeParser.d.ts +12 -0
  99. package/dist/utils/codeParser.d.ts.map +1 -0
  100. package/dist/utils/codeParser.js +487 -0
  101. package/dist/utils/codeParser.js.map +1 -0
  102. package/package.json +68 -0
@@ -0,0 +1,825 @@
1
+ "use strict";
2
+ // ============================================
3
+ // CI/CD Integration Tool
4
+ // GitHub Actions, Jenkins, GitLab CI
5
+ // ============================================
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.generateGitHubActions = generateGitHubActions;
41
+ exports.generateJenkinsfile = generateJenkinsfile;
42
+ exports.generateGitLabCI = generateGitLabCI;
43
+ exports.generateCICDConfig = generateCICDConfig;
44
+ exports.writeCICDConfig = writeCICDConfig;
45
+ const fs = __importStar(require("fs"));
46
+ const path = __importStar(require("path"));
47
+ // ============================================
48
+ // GitHub Actions
49
+ // ============================================
50
+ function generateGitHubActions(config) {
51
+ const { platform, options = {} } = config;
52
+ const { testCommand = 'npm test', buildCommand = 'npm run build', cacheEnabled = true, parallelTests = false, branches = ['main', 'develop'], } = options;
53
+ let workflow = '';
54
+ switch (platform) {
55
+ case 'ios':
56
+ workflow = generateIOSGitHubActions(testCommand, buildCommand, branches, cacheEnabled);
57
+ break;
58
+ case 'android':
59
+ workflow = generateAndroidGitHubActions(testCommand, buildCommand, branches, cacheEnabled);
60
+ break;
61
+ case 'flutter':
62
+ workflow = generateFlutterGitHubActions(testCommand, buildCommand, branches, cacheEnabled);
63
+ break;
64
+ case 'react-native':
65
+ workflow = generateReactNativeGitHubActions(testCommand, buildCommand, branches, cacheEnabled);
66
+ break;
67
+ case 'web':
68
+ default:
69
+ workflow = generateWebGitHubActions(testCommand, buildCommand, branches, cacheEnabled, parallelTests);
70
+ break;
71
+ }
72
+ return {
73
+ provider: 'github-actions',
74
+ filePath: '.github/workflows/test-genie.yml',
75
+ content: workflow,
76
+ };
77
+ }
78
+ function generateIOSGitHubActions(testCommand, buildCommand, branches, cacheEnabled) {
79
+ return `name: iOS Test Genie
80
+
81
+ on:
82
+ push:
83
+ branches: [${branches.map(b => `'${b}'`).join(', ')}]
84
+ pull_request:
85
+ branches: [${branches.map(b => `'${b}'`).join(', ')}]
86
+
87
+ concurrency:
88
+ group: \${{ github.workflow }}-\${{ github.ref }}
89
+ cancel-in-progress: true
90
+
91
+ jobs:
92
+ test:
93
+ runs-on: macos-14
94
+
95
+ steps:
96
+ - uses: actions/checkout@v4
97
+
98
+ - name: Select Xcode
99
+ run: sudo xcode-select -s /Applications/Xcode_15.2.app
100
+
101
+ ${cacheEnabled ? `- name: Cache CocoaPods
102
+ uses: actions/cache@v4
103
+ with:
104
+ path: Pods
105
+ key: \${{ runner.os }}-pods-\${{ hashFiles('**/Podfile.lock') }}
106
+ restore-keys: |
107
+ \${{ runner.os }}-pods-` : ''}
108
+
109
+ - name: Install CocoaPods
110
+ run: |
111
+ gem install cocoapods
112
+ pod install --repo-update
113
+
114
+ - name: Run Tests
115
+ run: |
116
+ set -o pipefail
117
+ xcodebuild test \\
118
+ -workspace *.xcworkspace \\
119
+ -scheme "YourScheme" \\
120
+ -destination 'platform=iOS Simulator,name=iPhone 15' \\
121
+ -resultBundlePath TestResults.xcresult | xcpretty
122
+
123
+ - name: Upload Test Results
124
+ uses: actions/upload-artifact@v4
125
+ if: always()
126
+ with:
127
+ name: test-results
128
+ path: TestResults.xcresult
129
+
130
+ - name: Run Test Genie Analysis
131
+ if: always()
132
+ run: npx test-genie-mcp analyze --project . --platform ios
133
+
134
+ build:
135
+ runs-on: macos-14
136
+ needs: test
137
+
138
+ steps:
139
+ - uses: actions/checkout@v4
140
+
141
+ - name: Build
142
+ run: ${buildCommand}
143
+ `;
144
+ }
145
+ function generateAndroidGitHubActions(testCommand, buildCommand, branches, cacheEnabled) {
146
+ return `name: Android Test Genie
147
+
148
+ on:
149
+ push:
150
+ branches: [${branches.map(b => `'${b}'`).join(', ')}]
151
+ pull_request:
152
+ branches: [${branches.map(b => `'${b}'`).join(', ')}]
153
+
154
+ concurrency:
155
+ group: \${{ github.workflow }}-\${{ github.ref }}
156
+ cancel-in-progress: true
157
+
158
+ jobs:
159
+ test:
160
+ runs-on: ubuntu-latest
161
+
162
+ steps:
163
+ - uses: actions/checkout@v4
164
+
165
+ - name: Set up JDK 17
166
+ uses: actions/setup-java@v4
167
+ with:
168
+ java-version: '17'
169
+ distribution: 'temurin'
170
+
171
+ ${cacheEnabled ? `- name: Cache Gradle
172
+ uses: actions/cache@v4
173
+ with:
174
+ path: |
175
+ ~/.gradle/caches
176
+ ~/.gradle/wrapper
177
+ key: \${{ runner.os }}-gradle-\${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
178
+ restore-keys: |
179
+ \${{ runner.os }}-gradle-` : ''}
180
+
181
+ - name: Run Unit Tests
182
+ run: ./gradlew testDebugUnitTest --stacktrace
183
+
184
+ - name: Run Instrumented Tests
185
+ uses: reactivecircus/android-emulator-runner@v2
186
+ with:
187
+ api-level: 29
188
+ script: ./gradlew connectedDebugAndroidTest
189
+
190
+ - name: Upload Test Results
191
+ uses: actions/upload-artifact@v4
192
+ if: always()
193
+ with:
194
+ name: test-results
195
+ path: |
196
+ **/build/reports/tests/
197
+ **/build/reports/androidTests/
198
+
199
+ - name: Run Test Genie Analysis
200
+ if: always()
201
+ run: npx test-genie-mcp analyze --project . --platform android
202
+
203
+ build:
204
+ runs-on: ubuntu-latest
205
+ needs: test
206
+
207
+ steps:
208
+ - uses: actions/checkout@v4
209
+
210
+ - name: Set up JDK 17
211
+ uses: actions/setup-java@v4
212
+ with:
213
+ java-version: '17'
214
+ distribution: 'temurin'
215
+
216
+ - name: Build APK
217
+ run: ./gradlew assembleRelease
218
+
219
+ - name: Upload APK
220
+ uses: actions/upload-artifact@v4
221
+ with:
222
+ name: app-release
223
+ path: app/build/outputs/apk/release/*.apk
224
+ `;
225
+ }
226
+ function generateFlutterGitHubActions(testCommand, buildCommand, branches, cacheEnabled) {
227
+ return `name: Flutter Test Genie
228
+
229
+ on:
230
+ push:
231
+ branches: [${branches.map(b => `'${b}'`).join(', ')}]
232
+ pull_request:
233
+ branches: [${branches.map(b => `'${b}'`).join(', ')}]
234
+
235
+ concurrency:
236
+ group: \${{ github.workflow }}-\${{ github.ref }}
237
+ cancel-in-progress: true
238
+
239
+ jobs:
240
+ test:
241
+ runs-on: ubuntu-latest
242
+
243
+ steps:
244
+ - uses: actions/checkout@v4
245
+
246
+ - name: Setup Flutter
247
+ uses: subosito/flutter-action@v2
248
+ with:
249
+ flutter-version: '3.16.x'
250
+ channel: 'stable'
251
+ cache: ${cacheEnabled}
252
+
253
+ - name: Install dependencies
254
+ run: flutter pub get
255
+
256
+ - name: Analyze code
257
+ run: flutter analyze
258
+
259
+ - name: Run tests with coverage
260
+ run: flutter test --coverage
261
+
262
+ - name: Upload coverage
263
+ uses: codecov/codecov-action@v3
264
+ with:
265
+ files: coverage/lcov.info
266
+
267
+ - name: Run Test Genie Analysis
268
+ if: always()
269
+ run: npx test-genie-mcp analyze --project . --platform flutter
270
+
271
+ build-android:
272
+ runs-on: ubuntu-latest
273
+ needs: test
274
+
275
+ steps:
276
+ - uses: actions/checkout@v4
277
+
278
+ - name: Setup Flutter
279
+ uses: subosito/flutter-action@v2
280
+ with:
281
+ flutter-version: '3.16.x'
282
+ channel: 'stable'
283
+ cache: true
284
+
285
+ - name: Build APK
286
+ run: flutter build apk --release
287
+
288
+ - name: Upload APK
289
+ uses: actions/upload-artifact@v4
290
+ with:
291
+ name: app-release
292
+ path: build/app/outputs/flutter-apk/app-release.apk
293
+
294
+ build-ios:
295
+ runs-on: macos-14
296
+ needs: test
297
+
298
+ steps:
299
+ - uses: actions/checkout@v4
300
+
301
+ - name: Setup Flutter
302
+ uses: subosito/flutter-action@v2
303
+ with:
304
+ flutter-version: '3.16.x'
305
+ channel: 'stable'
306
+ cache: true
307
+
308
+ - name: Build iOS
309
+ run: flutter build ios --release --no-codesign
310
+ `;
311
+ }
312
+ function generateReactNativeGitHubActions(testCommand, buildCommand, branches, cacheEnabled) {
313
+ return `name: React Native Test Genie
314
+
315
+ on:
316
+ push:
317
+ branches: [${branches.map(b => `'${b}'`).join(', ')}]
318
+ pull_request:
319
+ branches: [${branches.map(b => `'${b}'`).join(', ')}]
320
+
321
+ concurrency:
322
+ group: \${{ github.workflow }}-\${{ github.ref }}
323
+ cancel-in-progress: true
324
+
325
+ jobs:
326
+ test:
327
+ runs-on: ubuntu-latest
328
+
329
+ steps:
330
+ - uses: actions/checkout@v4
331
+
332
+ - name: Setup Node.js
333
+ uses: actions/setup-node@v4
334
+ with:
335
+ node-version: '20'
336
+ ${cacheEnabled ? `cache: 'npm'` : ''}
337
+
338
+ - name: Install dependencies
339
+ run: npm ci
340
+
341
+ - name: Run linter
342
+ run: npm run lint
343
+
344
+ - name: Run tests
345
+ run: ${testCommand}
346
+
347
+ - name: Upload coverage
348
+ uses: codecov/codecov-action@v3
349
+
350
+ - name: Run Test Genie Analysis
351
+ if: always()
352
+ run: npx test-genie-mcp analyze --project . --platform react-native
353
+
354
+ build-android:
355
+ runs-on: ubuntu-latest
356
+ needs: test
357
+
358
+ steps:
359
+ - uses: actions/checkout@v4
360
+
361
+ - name: Setup Node.js
362
+ uses: actions/setup-node@v4
363
+ with:
364
+ node-version: '20'
365
+ cache: 'npm'
366
+
367
+ - name: Setup JDK
368
+ uses: actions/setup-java@v4
369
+ with:
370
+ java-version: '17'
371
+ distribution: 'temurin'
372
+
373
+ - name: Install dependencies
374
+ run: npm ci
375
+
376
+ - name: Build Android
377
+ run: cd android && ./gradlew assembleRelease
378
+
379
+ - name: Upload APK
380
+ uses: actions/upload-artifact@v4
381
+ with:
382
+ name: app-release
383
+ path: android/app/build/outputs/apk/release/*.apk
384
+
385
+ build-ios:
386
+ runs-on: macos-14
387
+ needs: test
388
+
389
+ steps:
390
+ - uses: actions/checkout@v4
391
+
392
+ - name: Setup Node.js
393
+ uses: actions/setup-node@v4
394
+ with:
395
+ node-version: '20'
396
+ cache: 'npm'
397
+
398
+ - name: Install dependencies
399
+ run: npm ci
400
+
401
+ - name: Install CocoaPods
402
+ run: cd ios && pod install
403
+
404
+ - name: Build iOS
405
+ run: npx react-native run-ios --configuration Release
406
+
407
+ e2e-test:
408
+ runs-on: macos-14
409
+ needs: [build-android, build-ios]
410
+
411
+ steps:
412
+ - uses: actions/checkout@v4
413
+
414
+ - name: Setup Node.js
415
+ uses: actions/setup-node@v4
416
+ with:
417
+ node-version: '20'
418
+ cache: 'npm'
419
+
420
+ - name: Install dependencies
421
+ run: npm ci
422
+
423
+ - name: Detox build
424
+ run: npx detox build -c ios.sim.release
425
+
426
+ - name: Detox test
427
+ run: npx detox test -c ios.sim.release --cleanup
428
+ `;
429
+ }
430
+ function generateWebGitHubActions(testCommand, buildCommand, branches, cacheEnabled, parallelTests) {
431
+ return `name: Web Test Genie
432
+
433
+ on:
434
+ push:
435
+ branches: [${branches.map(b => `'${b}'`).join(', ')}]
436
+ pull_request:
437
+ branches: [${branches.map(b => `'${b}'`).join(', ')}]
438
+
439
+ concurrency:
440
+ group: \${{ github.workflow }}-\${{ github.ref }}
441
+ cancel-in-progress: true
442
+
443
+ jobs:
444
+ test:
445
+ runs-on: ubuntu-latest
446
+ ${parallelTests ? `
447
+ strategy:
448
+ matrix:
449
+ shard: [1, 2, 3, 4]
450
+ ` : ''}
451
+
452
+ steps:
453
+ - uses: actions/checkout@v4
454
+
455
+ - name: Setup Node.js
456
+ uses: actions/setup-node@v4
457
+ with:
458
+ node-version: '20'
459
+ ${cacheEnabled ? `cache: 'npm'` : ''}
460
+
461
+ - name: Install dependencies
462
+ run: npm ci
463
+
464
+ - name: Run linter
465
+ run: npm run lint
466
+
467
+ - name: Run type check
468
+ run: npm run type-check
469
+
470
+ - name: Run tests
471
+ run: ${testCommand}${parallelTests ? ' -- --shard=${{ matrix.shard }}/4' : ''}
472
+
473
+ - name: Upload coverage
474
+ uses: codecov/codecov-action@v3
475
+
476
+ - name: Run Test Genie Analysis
477
+ if: always()
478
+ run: npx test-genie-mcp analyze --project . --platform web
479
+
480
+ e2e:
481
+ runs-on: ubuntu-latest
482
+ needs: test
483
+
484
+ steps:
485
+ - uses: actions/checkout@v4
486
+
487
+ - name: Setup Node.js
488
+ uses: actions/setup-node@v4
489
+ with:
490
+ node-version: '20'
491
+ cache: 'npm'
492
+
493
+ - name: Install dependencies
494
+ run: npm ci
495
+
496
+ - name: Install Playwright browsers
497
+ run: npx playwright install --with-deps
498
+
499
+ - name: Run Playwright tests
500
+ run: npx playwright test
501
+
502
+ - name: Upload Playwright report
503
+ uses: actions/upload-artifact@v4
504
+ if: always()
505
+ with:
506
+ name: playwright-report
507
+ path: playwright-report/
508
+
509
+ build:
510
+ runs-on: ubuntu-latest
511
+ needs: [test, e2e]
512
+
513
+ steps:
514
+ - uses: actions/checkout@v4
515
+
516
+ - name: Setup Node.js
517
+ uses: actions/setup-node@v4
518
+ with:
519
+ node-version: '20'
520
+ cache: 'npm'
521
+
522
+ - name: Install dependencies
523
+ run: npm ci
524
+
525
+ - name: Build
526
+ run: ${buildCommand}
527
+
528
+ - name: Upload build artifacts
529
+ uses: actions/upload-artifact@v4
530
+ with:
531
+ name: build
532
+ path: dist/
533
+ `;
534
+ }
535
+ // ============================================
536
+ // Jenkins
537
+ // ============================================
538
+ function generateJenkinsfile(config) {
539
+ const { platform, options = {} } = config;
540
+ const { testCommand = 'npm test', buildCommand = 'npm run build', notifyOnFailure = true, } = options;
541
+ const content = `pipeline {
542
+ agent any
543
+
544
+ environment {
545
+ NODE_VERSION = '20'
546
+ ${platform === 'android' ? "ANDROID_SDK_ROOT = '/opt/android-sdk'" : ''}
547
+ ${platform === 'ios' ? "DEVELOPER_DIR = '/Applications/Xcode.app/Contents/Developer'" : ''}
548
+ }
549
+
550
+ options {
551
+ timeout(time: 30, unit: 'MINUTES')
552
+ disableConcurrentBuilds()
553
+ }
554
+
555
+ stages {
556
+ stage('Checkout') {
557
+ steps {
558
+ checkout scm
559
+ }
560
+ }
561
+
562
+ stage('Install Dependencies') {
563
+ steps {
564
+ ${platform === 'flutter' ? `
565
+ sh 'flutter pub get'
566
+ ` : platform === 'ios' ? `
567
+ sh 'pod install'
568
+ ` : `
569
+ sh 'npm ci'
570
+ `}
571
+ }
572
+ }
573
+
574
+ stage('Lint') {
575
+ steps {
576
+ ${platform === 'flutter' ? `
577
+ sh 'flutter analyze'
578
+ ` : `
579
+ sh 'npm run lint'
580
+ `}
581
+ }
582
+ }
583
+
584
+ stage('Test') {
585
+ steps {
586
+ ${platform === 'flutter' ? `
587
+ sh 'flutter test --coverage'
588
+ ` : platform === 'ios' ? `
589
+ sh '''
590
+ xcodebuild test \\
591
+ -workspace *.xcworkspace \\
592
+ -scheme "YourScheme" \\
593
+ -destination 'platform=iOS Simulator,name=iPhone 15' \\
594
+ | xcpretty
595
+ '''
596
+ ` : platform === 'android' ? `
597
+ sh './gradlew testDebugUnitTest'
598
+ ` : `
599
+ sh '${testCommand}'
600
+ `}
601
+ }
602
+ post {
603
+ always {
604
+ ${platform === 'flutter' || platform === 'web' || platform === 'react-native' ? `
605
+ publishHTML([
606
+ allowMissing: true,
607
+ alwaysLinkToLastBuild: true,
608
+ keepAll: true,
609
+ reportDir: 'coverage',
610
+ reportFiles: 'index.html',
611
+ reportName: 'Coverage Report'
612
+ ])
613
+ ` : `
614
+ junit '**/test-results/**/*.xml'
615
+ `}
616
+ }
617
+ }
618
+ }
619
+
620
+ stage('Test Genie Analysis') {
621
+ steps {
622
+ sh 'npx test-genie-mcp analyze --project . --platform ${platform}'
623
+ }
624
+ }
625
+
626
+ stage('Build') {
627
+ steps {
628
+ ${platform === 'flutter' ? `
629
+ sh 'flutter build apk --release'
630
+ ` : platform === 'ios' ? `
631
+ sh '''
632
+ xcodebuild archive \\
633
+ -workspace *.xcworkspace \\
634
+ -scheme "YourScheme" \\
635
+ -archivePath build/App.xcarchive
636
+ '''
637
+ ` : platform === 'android' ? `
638
+ sh './gradlew assembleRelease'
639
+ ` : `
640
+ sh '${buildCommand}'
641
+ `}
642
+ }
643
+ }
644
+ }
645
+
646
+ post {
647
+ ${notifyOnFailure ? `
648
+ failure {
649
+ emailext(
650
+ subject: "Build Failed: \${env.JOB_NAME} [\${env.BUILD_NUMBER}]",
651
+ body: "Check console output at \${env.BUILD_URL}",
652
+ recipientProviders: [developers(), requestor()]
653
+ )
654
+ }
655
+ ` : ''}
656
+ always {
657
+ cleanWs()
658
+ }
659
+ }
660
+ }
661
+ `;
662
+ return {
663
+ provider: 'jenkins',
664
+ filePath: 'Jenkinsfile',
665
+ content,
666
+ };
667
+ }
668
+ // ============================================
669
+ // GitLab CI
670
+ // ============================================
671
+ function generateGitLabCI(config) {
672
+ const { platform, options = {} } = config;
673
+ const { testCommand = 'npm test', buildCommand = 'npm run build', cacheEnabled = true, } = options;
674
+ const content = `stages:
675
+ - test
676
+ - analyze
677
+ - build
678
+ - deploy
679
+
680
+ variables:
681
+ ${platform === 'android' ? 'ANDROID_SDK_ROOT: "/opt/android-sdk"' : ''}
682
+ ${platform === 'flutter' ? 'FLUTTER_VERSION: "3.16.0"' : ''}
683
+
684
+ ${cacheEnabled ? `
685
+ cache:
686
+ key: \${CI_COMMIT_REF_SLUG}
687
+ paths:
688
+ ${platform === 'flutter' ? '- .pub-cache/' : platform === 'ios' ? '- Pods/' : '- node_modules/'}
689
+ ` : ''}
690
+
691
+ # Test Stage
692
+ test:
693
+ stage: test
694
+ ${platform === 'ios' ? 'tags: [macos]' : 'image: node:20'}
695
+ before_script:
696
+ ${platform === 'flutter' ? `
697
+ - git clone https://github.com/flutter/flutter.git -b stable
698
+ - export PATH="$PATH:$(pwd)/flutter/bin"
699
+ - flutter pub get
700
+ ` : platform === 'ios' ? `
701
+ - pod install
702
+ ` : `
703
+ - npm ci
704
+ `}
705
+ script:
706
+ ${platform === 'flutter' ? `
707
+ - flutter analyze
708
+ - flutter test --coverage
709
+ ` : platform === 'ios' ? `
710
+ - xcodebuild test -workspace *.xcworkspace -scheme "YourScheme" -destination 'platform=iOS Simulator,name=iPhone 15'
711
+ ` : platform === 'android' ? `
712
+ - ./gradlew testDebugUnitTest
713
+ ` : `
714
+ - npm run lint
715
+ - ${testCommand}
716
+ `}
717
+ artifacts:
718
+ reports:
719
+ ${platform === 'flutter' || platform === 'web' || platform === 'react-native' ? 'coverage_report:' : 'junit:'}
720
+ ${platform === 'flutter' ? 'coverage/lcov.info' : platform === 'web' || platform === 'react-native' ? 'coverage/lcov.info' : '**/test-results.xml'}
721
+ expire_in: 1 week
722
+
723
+ # Test Genie Analysis
724
+ analyze:
725
+ stage: analyze
726
+ image: node:20
727
+ script:
728
+ - npm ci
729
+ - npx test-genie-mcp analyze --project . --platform ${platform}
730
+ artifacts:
731
+ paths:
732
+ - .test-genie/reports/
733
+ expire_in: 1 week
734
+ allow_failure: true
735
+
736
+ # Build Stage
737
+ build:
738
+ stage: build
739
+ ${platform === 'ios' ? 'tags: [macos]' : 'image: node:20'}
740
+ before_script:
741
+ ${platform === 'flutter' ? `
742
+ - git clone https://github.com/flutter/flutter.git -b stable
743
+ - export PATH="$PATH:$(pwd)/flutter/bin"
744
+ - flutter pub get
745
+ ` : platform === 'ios' ? `
746
+ - pod install
747
+ ` : `
748
+ - npm ci
749
+ `}
750
+ script:
751
+ ${platform === 'flutter' ? `
752
+ - flutter build apk --release
753
+ ` : platform === 'ios' ? `
754
+ - xcodebuild archive -workspace *.xcworkspace -scheme "YourScheme" -archivePath build/App.xcarchive
755
+ ` : platform === 'android' ? `
756
+ - ./gradlew assembleRelease
757
+ ` : `
758
+ - ${buildCommand}
759
+ `}
760
+ artifacts:
761
+ paths:
762
+ ${platform === 'flutter' ? '- build/app/outputs/flutter-apk/' : platform === 'android' ? '- app/build/outputs/apk/' : '- dist/'}
763
+ expire_in: 1 week
764
+ only:
765
+ - main
766
+ - develop
767
+ `;
768
+ return {
769
+ provider: 'gitlab-ci',
770
+ filePath: '.gitlab-ci.yml',
771
+ content,
772
+ };
773
+ }
774
+ // ============================================
775
+ // Main Function
776
+ // ============================================
777
+ function generateCICDConfig(config) {
778
+ switch (config.provider) {
779
+ case 'github-actions':
780
+ return generateGitHubActions(config);
781
+ case 'jenkins':
782
+ return generateJenkinsfile(config);
783
+ case 'gitlab-ci':
784
+ return generateGitLabCI(config);
785
+ default:
786
+ return generateGitHubActions(config);
787
+ }
788
+ }
789
+ function writeCICDConfig(config) {
790
+ const generated = generateCICDConfig(config);
791
+ const files = [];
792
+ try {
793
+ const fullPath = path.join(config.projectPath, generated.filePath);
794
+ const dir = path.dirname(fullPath);
795
+ if (!fs.existsSync(dir)) {
796
+ fs.mkdirSync(dir, { recursive: true });
797
+ }
798
+ fs.writeFileSync(fullPath, generated.content);
799
+ files.push(fullPath);
800
+ // Write additional files if any
801
+ if (generated.additionalFiles) {
802
+ for (const file of generated.additionalFiles) {
803
+ const additionalPath = path.join(config.projectPath, file.path);
804
+ const additionalDir = path.dirname(additionalPath);
805
+ if (!fs.existsSync(additionalDir)) {
806
+ fs.mkdirSync(additionalDir, { recursive: true });
807
+ }
808
+ fs.writeFileSync(additionalPath, file.content);
809
+ files.push(additionalPath);
810
+ }
811
+ }
812
+ return { success: true, files };
813
+ }
814
+ catch (error) {
815
+ return { success: false, files };
816
+ }
817
+ }
818
+ exports.default = {
819
+ generateCICDConfig,
820
+ writeCICDConfig,
821
+ generateGitHubActions,
822
+ generateJenkinsfile,
823
+ generateGitLabCI,
824
+ };
825
+ //# sourceMappingURL=cicdIntegration.js.map