@sentry/wizard 6.0.0 → 6.1.1

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 (67) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/e2e-tests/tests/angular-17.test.js +6 -0
  3. package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
  4. package/dist/e2e-tests/tests/angular-19.test.js +7 -1
  5. package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
  6. package/dist/e2e-tests/tests/nextjs-14.test.js +5 -1
  7. package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
  8. package/dist/e2e-tests/tests/nextjs-15.test.js +5 -1
  9. package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
  10. package/dist/e2e-tests/tests/nuxt-3.test.js +9 -1
  11. package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
  12. package/dist/e2e-tests/tests/nuxt-4.test.js +9 -1
  13. package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
  14. package/dist/e2e-tests/tests/remix.test.js +8 -2
  15. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  16. package/dist/e2e-tests/tests/sveltekit.test.js +15 -3
  17. package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
  18. package/dist/src/angular/angular-wizard.js +6 -1
  19. package/dist/src/angular/angular-wizard.js.map +1 -1
  20. package/dist/src/angular/codemods/main.d.ts +4 -1
  21. package/dist/src/angular/codemods/main.js +3 -0
  22. package/dist/src/angular/codemods/main.js.map +1 -1
  23. package/dist/src/angular/sdk-setup.d.ts +1 -0
  24. package/dist/src/angular/sdk-setup.js.map +1 -1
  25. package/dist/src/apple/templates.js +17 -2
  26. package/dist/src/apple/templates.js.map +1 -1
  27. package/dist/src/apple/xcode-manager.d.ts +23 -0
  28. package/dist/src/apple/xcode-manager.js +140 -40
  29. package/dist/src/apple/xcode-manager.js.map +1 -1
  30. package/dist/src/nextjs/nextjs-wizard.js +6 -1
  31. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  32. package/dist/src/nextjs/templates.d.ts +3 -0
  33. package/dist/src/nextjs/templates.js +15 -2
  34. package/dist/src/nextjs/templates.js.map +1 -1
  35. package/dist/src/nuxt/sdk-setup.js +5 -0
  36. package/dist/src/nuxt/sdk-setup.js.map +1 -1
  37. package/dist/src/nuxt/templates.d.ts +1 -0
  38. package/dist/src/nuxt/templates.js +3 -2
  39. package/dist/src/nuxt/templates.js.map +1 -1
  40. package/dist/src/remix/remix-wizard.js +5 -0
  41. package/dist/src/remix/remix-wizard.js.map +1 -1
  42. package/dist/src/remix/sdk-setup.d.ts +5 -0
  43. package/dist/src/remix/sdk-setup.js +4 -0
  44. package/dist/src/remix/sdk-setup.js.map +1 -1
  45. package/dist/src/sveltekit/sdk-setup.js +11 -0
  46. package/dist/src/sveltekit/sdk-setup.js.map +1 -1
  47. package/dist/src/sveltekit/templates.d.ts +2 -0
  48. package/dist/src/sveltekit/templates.js +10 -0
  49. package/dist/src/sveltekit/templates.js.map +1 -1
  50. package/dist/src/version.d.ts +1 -1
  51. package/dist/src/version.js +1 -1
  52. package/dist/src/version.js.map +1 -1
  53. package/dist/test/apple/templates.test.js +36 -34
  54. package/dist/test/apple/templates.test.js.map +1 -1
  55. package/dist/test/apple/xcode-manager.test.js +418 -0
  56. package/dist/test/apple/xcode-manager.test.js.map +1 -1
  57. package/dist/test/nextjs/templates.test.js +119 -0
  58. package/dist/test/nextjs/templates.test.js.map +1 -1
  59. package/dist/test/nuxt/templates.test.js +119 -0
  60. package/dist/test/nuxt/templates.test.js.map +1 -1
  61. package/dist/test/remix/client-entry.test.js +56 -0
  62. package/dist/test/remix/client-entry.test.js.map +1 -1
  63. package/dist/test/remix/server-instrumentation.test.js +37 -1
  64. package/dist/test/remix/server-instrumentation.test.js.map +1 -1
  65. package/dist/test/sveltekit/templates.test.js +67 -0
  66. package/dist/test/sveltekit/templates.test.js.map +1 -1
  67. package/package.json +1 -1
@@ -396,6 +396,27 @@ const projectData = {
396
396
  productName: 'Sentry',
397
397
  });
398
398
  });
399
+ (0, vitest_1.it)('should initialize packageProductDependencies if not present', () => {
400
+ // -- Arrange --
401
+ // Ensure the target exists but has no packageProductDependencies initially
402
+ const targetKey = 'D4E604CC2D50CEEC00CAB00F';
403
+ const target = xcodeProject.objects.PBXNativeTarget?.[targetKey];
404
+ if (target) {
405
+ // Remove packageProductDependencies to test initialization
406
+ delete target.packageProductDependencies;
407
+ }
408
+ // -- Act --
409
+ xcodeProject.updateXcodeProject(projectData, 'Project', addSPMReference);
410
+ // -- Assert --
411
+ const updatedTarget = xcodeProject.objects.PBXNativeTarget?.[targetKey];
412
+ (0, vitest_1.expect)(updatedTarget.packageProductDependencies).toBeDefined();
413
+ (0, vitest_1.expect)(updatedTarget.packageProductDependencies).toEqual([
414
+ vitest_1.expect.objectContaining({
415
+ value: vitest_1.expect.any(String),
416
+ comment: 'Sentry',
417
+ }),
418
+ ]);
419
+ });
399
420
  });
400
421
  });
401
422
  (0, vitest_1.describe)('getSourceFilesForTarget', () => {
@@ -1213,6 +1234,403 @@ const projectData = {
1213
1234
  });
1214
1235
  });
1215
1236
  });
1237
+ (0, vitest_1.describe)('addUploadSymbolsScript', () => {
1238
+ let sourceProjectPath;
1239
+ let tempProjectPath;
1240
+ let xcodeProject;
1241
+ (0, vitest_1.beforeEach)(() => {
1242
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'add-upload-symbols-script'));
1243
+ sourceProjectPath = singleTargetProjectPath;
1244
+ tempProjectPath = path.resolve(tempDir, 'project.pbxproj');
1245
+ fs.copyFileSync(sourceProjectPath, tempProjectPath);
1246
+ xcodeProject = new xcode_manager_1.XcodeProject(tempProjectPath);
1247
+ });
1248
+ (0, vitest_1.describe)('when target is not found', () => {
1249
+ (0, vitest_1.it)('should return early', () => {
1250
+ // -- Act --
1251
+ xcodeProject.addUploadSymbolsScript({
1252
+ sentryProject: projectData,
1253
+ targetName: 'NonExistentTarget',
1254
+ uploadSource: true,
1255
+ });
1256
+ // -- Assert --
1257
+ // Verify that no shell script build phases were added
1258
+ (0, vitest_1.expect)(xcodeProject.objects.PBXShellScriptBuildPhase).toBeUndefined();
1259
+ });
1260
+ });
1261
+ (0, vitest_1.describe)('when target has existing Sentry build phase', () => {
1262
+ (0, vitest_1.beforeEach)(() => {
1263
+ // Set up a target with an existing Sentry build phase
1264
+ xcodeProject.objects.PBXNativeTarget = {
1265
+ 'target-key': {
1266
+ isa: 'PBXNativeTarget',
1267
+ name: 'TestTarget',
1268
+ buildPhases: [
1269
+ {
1270
+ value: 'existing-sentry-phase',
1271
+ comment: 'Upload Debug Symbols to Sentry',
1272
+ },
1273
+ ],
1274
+ },
1275
+ };
1276
+ xcodeProject.objects.PBXShellScriptBuildPhase = {
1277
+ 'existing-sentry-phase': {
1278
+ isa: 'PBXShellScriptBuildPhase',
1279
+ shellScript: '"echo sentry-cli upload-dsym"',
1280
+ buildActionMask: 2147483647,
1281
+ files: [],
1282
+ inputPaths: [],
1283
+ outputPaths: [],
1284
+ runOnlyForDeploymentPostprocessing: 0,
1285
+ shellPath: '/bin/sh',
1286
+ },
1287
+ };
1288
+ });
1289
+ (0, vitest_1.it)('should update existing build phase instead of adding new one', () => {
1290
+ // -- Act --
1291
+ xcodeProject.addUploadSymbolsScript({
1292
+ sentryProject: projectData,
1293
+ targetName: 'TestTarget',
1294
+ uploadSource: true,
1295
+ });
1296
+ // -- Assert --
1297
+ // Should still have only one build phase (the updated one)
1298
+ const buildPhases = Object.keys(xcodeProject.objects.PBXShellScriptBuildPhase || {});
1299
+ (0, vitest_1.expect)(buildPhases.filter((key) => !key.endsWith('_comment'))).toHaveLength(1);
1300
+ // The existing phase should be updated with new script content
1301
+ const updatedPhase = xcodeProject.objects.PBXShellScriptBuildPhase?.['existing-sentry-phase'];
1302
+ (0, vitest_1.expect)(updatedPhase).toBeDefined();
1303
+ (0, vitest_1.expect)(updatedPhase?.shellScript).toContain('sentry-cli');
1304
+ });
1305
+ });
1306
+ (0, vitest_1.describe)('orphaned build phase cleanup', () => {
1307
+ (0, vitest_1.beforeEach)(() => {
1308
+ // Set up targets with orphaned build phase references
1309
+ xcodeProject.objects.PBXNativeTarget = {
1310
+ 'target-1': {
1311
+ isa: 'PBXNativeTarget',
1312
+ name: 'Target1',
1313
+ buildPhases: [
1314
+ {
1315
+ value: 'orphaned-phase-1',
1316
+ comment: 'Upload Debug Symbols to Sentry',
1317
+ },
1318
+ {
1319
+ value: 'valid-phase',
1320
+ comment: 'Sources',
1321
+ },
1322
+ ],
1323
+ },
1324
+ 'target-2': {
1325
+ isa: 'PBXNativeTarget',
1326
+ name: 'Target2',
1327
+ buildPhases: [
1328
+ {
1329
+ value: 'orphaned-phase-2',
1330
+ comment: 'Upload Debug Symbols to Sentry',
1331
+ },
1332
+ ],
1333
+ },
1334
+ };
1335
+ // PBXShellScriptBuildPhase doesn't have the orphaned phases
1336
+ xcodeProject.objects.PBXShellScriptBuildPhase = {
1337
+ 'valid-phase': {
1338
+ isa: 'PBXShellScriptBuildPhase',
1339
+ shellScript: '"echo valid"',
1340
+ buildActionMask: 2147483647,
1341
+ files: [],
1342
+ inputPaths: [],
1343
+ outputPaths: [],
1344
+ runOnlyForDeploymentPostprocessing: 0,
1345
+ shellPath: '/bin/sh',
1346
+ },
1347
+ };
1348
+ });
1349
+ (0, vitest_1.it)('should remove orphaned build phase references from all targets', () => {
1350
+ // -- Act --
1351
+ xcodeProject.addUploadSymbolsScript({
1352
+ sentryProject: projectData,
1353
+ targetName: 'Target1',
1354
+ uploadSource: true,
1355
+ });
1356
+ // -- Assert --
1357
+ const target1 = xcodeProject.objects.PBXNativeTarget?.['target-1'];
1358
+ const target2 = xcodeProject.objects.PBXNativeTarget?.['target-2'];
1359
+ // Target1 should only have the valid phase left, plus the new Sentry phase
1360
+ (0, vitest_1.expect)(target1?.buildPhases).not.toEqual(vitest_1.expect.arrayContaining([
1361
+ vitest_1.expect.objectContaining({ value: 'orphaned-phase-1' }),
1362
+ ]));
1363
+ (0, vitest_1.expect)(target1?.buildPhases).toEqual(vitest_1.expect.arrayContaining([
1364
+ vitest_1.expect.objectContaining({ value: 'valid-phase' }),
1365
+ ]));
1366
+ // Target2 should have orphaned phase removed and be empty
1367
+ (0, vitest_1.expect)(target2?.buildPhases).not.toEqual(vitest_1.expect.arrayContaining([
1368
+ vitest_1.expect.objectContaining({ value: 'orphaned-phase-2' }),
1369
+ ]));
1370
+ });
1371
+ });
1372
+ });
1373
+ (0, vitest_1.describe)('addUploadSymbolsScript edge cases', () => {
1374
+ let xcodeProject;
1375
+ (0, vitest_1.beforeEach)(() => {
1376
+ xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
1377
+ });
1378
+ (0, vitest_1.describe)('when target is not found', () => {
1379
+ (0, vitest_1.it)('should handle gracefully without throwing', () => {
1380
+ // -- Act & Assert --
1381
+ (0, vitest_1.expect)(() => {
1382
+ xcodeProject.addUploadSymbolsScript({
1383
+ sentryProject: projectData,
1384
+ targetName: 'NonExistentTarget',
1385
+ uploadSource: true,
1386
+ });
1387
+ }).not.toThrow();
1388
+ });
1389
+ });
1390
+ });
1391
+ (0, vitest_1.describe)('addScriptBuildPhase method coverage', () => {
1392
+ let sourceProjectPath;
1393
+ let tempProjectPath;
1394
+ let xcodeProject;
1395
+ (0, vitest_1.beforeEach)(() => {
1396
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'add-script-build-phase'));
1397
+ sourceProjectPath = singleTargetProjectPath;
1398
+ tempProjectPath = path.resolve(tempDir, 'project.pbxproj');
1399
+ fs.copyFileSync(sourceProjectPath, tempProjectPath);
1400
+ xcodeProject = new xcode_manager_1.XcodeProject(tempProjectPath);
1401
+ });
1402
+ (0, vitest_1.describe)('when PBXShellScriptBuildPhase does not exist initially', () => {
1403
+ (0, vitest_1.it)('should initialize PBXShellScriptBuildPhase and add build phase', () => {
1404
+ // -- Arrange --
1405
+ // Set PBXShellScriptBuildPhase to empty to test initialization path
1406
+ delete xcodeProject.objects.PBXShellScriptBuildPhase;
1407
+ const targetKey = 'D4E604CC2D50CEEC00CAB00F';
1408
+ // -- Act --
1409
+ const buildPhaseId = xcodeProject.addScriptBuildPhase(targetKey, 'Test Script', 'echo "test"', ['input.txt']);
1410
+ // -- Assert --
1411
+ (0, vitest_1.expect)(xcodeProject.objects.PBXShellScriptBuildPhase).toBeDefined();
1412
+ (0, vitest_1.expect)(buildPhaseId).toMatch(/^[A-F0-9]{24}$/i);
1413
+ const buildPhase = xcodeProject.objects.PBXShellScriptBuildPhase?.[buildPhaseId];
1414
+ (0, vitest_1.expect)(buildPhase).toBeDefined();
1415
+ (0, vitest_1.expect)(typeof buildPhase).not.toBe('string');
1416
+ });
1417
+ });
1418
+ (0, vitest_1.describe)('when target does not exist', () => {
1419
+ (0, vitest_1.it)('should still create build phase but not add to target', () => {
1420
+ // -- Arrange --
1421
+ const invalidTargetKey = 'INVALID_TARGET_KEY';
1422
+ // -- Act --
1423
+ const buildPhaseId = xcodeProject.addScriptBuildPhase(invalidTargetKey, 'Test Script', 'echo "test"', []);
1424
+ // -- Assert --
1425
+ (0, vitest_1.expect)(buildPhaseId).toMatch(/^[A-F0-9]{24}$/i);
1426
+ // Build phase should be created in PBXShellScriptBuildPhase
1427
+ const buildPhase = xcodeProject.objects.PBXShellScriptBuildPhase?.[buildPhaseId];
1428
+ (0, vitest_1.expect)(buildPhase).toBeDefined();
1429
+ // But target should not have the build phase added since target doesn't exist
1430
+ const target = xcodeProject.objects.PBXNativeTarget?.[invalidTargetKey];
1431
+ (0, vitest_1.expect)(target).toBeUndefined();
1432
+ });
1433
+ });
1434
+ (0, vitest_1.describe)('when target has no buildPhases array', () => {
1435
+ (0, vitest_1.it)('should not add build phase to target but should create build phase object', () => {
1436
+ // -- Arrange --
1437
+ const targetKey = 'D4E604CC2D50CEEC00CAB00F';
1438
+ const target = xcodeProject.objects.PBXNativeTarget?.[targetKey];
1439
+ if (target && typeof target !== 'string') {
1440
+ // Remove buildPhases to test the undefined case
1441
+ const targetWithoutBuildPhases = target;
1442
+ delete targetWithoutBuildPhases.buildPhases;
1443
+ }
1444
+ // -- Act --
1445
+ const buildPhaseId = xcodeProject.addScriptBuildPhase(targetKey, 'Test Script', 'echo "test"', []);
1446
+ // -- Assert --
1447
+ (0, vitest_1.expect)(buildPhaseId).toMatch(/^[A-F0-9]{24}$/i);
1448
+ // Build phase should be created
1449
+ const buildPhase = xcodeProject.objects.PBXShellScriptBuildPhase?.[buildPhaseId];
1450
+ (0, vitest_1.expect)(buildPhase).toBeDefined();
1451
+ // Target should exist but buildPhases should still be undefined
1452
+ const updatedTarget = xcodeProject.objects.PBXNativeTarget?.[targetKey];
1453
+ (0, vitest_1.expect)(updatedTarget).toBeDefined();
1454
+ (0, vitest_1.expect)(updatedTarget?.buildPhases).toBeUndefined();
1455
+ });
1456
+ });
1457
+ });
1458
+ (0, vitest_1.describe)('updateScriptBuildPhase method coverage', () => {
1459
+ let sourceProjectPath;
1460
+ let tempProjectPath;
1461
+ let xcodeProject;
1462
+ (0, vitest_1.beforeEach)(() => {
1463
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'update-script-build-phase'));
1464
+ sourceProjectPath = singleTargetProjectPath;
1465
+ tempProjectPath = path.resolve(tempDir, 'project.pbxproj');
1466
+ fs.copyFileSync(sourceProjectPath, tempProjectPath);
1467
+ xcodeProject = new xcode_manager_1.XcodeProject(tempProjectPath);
1468
+ });
1469
+ (0, vitest_1.describe)('when build phase does not exist', () => {
1470
+ (0, vitest_1.it)('should debug and return early', () => {
1471
+ // -- Act & Assert --
1472
+ (0, vitest_1.expect)(() => {
1473
+ xcodeProject.updateScriptBuildPhase('NONEXISTENT_BUILD_PHASE', 'echo "updated"', ['input.txt']);
1474
+ }).not.toThrow();
1475
+ });
1476
+ });
1477
+ (0, vitest_1.describe)('when build phase is a string comment', () => {
1478
+ (0, vitest_1.it)('should debug and return early', () => {
1479
+ // -- Arrange --
1480
+ xcodeProject.objects.PBXShellScriptBuildPhase = {
1481
+ 'test-id': 'This is a comment string',
1482
+ };
1483
+ // -- Act & Assert --
1484
+ (0, vitest_1.expect)(() => {
1485
+ xcodeProject.updateScriptBuildPhase('test-id', 'echo "updated"', [
1486
+ 'input.txt',
1487
+ ]);
1488
+ }).not.toThrow();
1489
+ });
1490
+ });
1491
+ (0, vitest_1.describe)('when build phase exists and is valid', () => {
1492
+ (0, vitest_1.it)('should update the build phase successfully', () => {
1493
+ // -- Arrange --
1494
+ const buildPhaseId = 'test-build-phase-id';
1495
+ xcodeProject.objects.PBXShellScriptBuildPhase = {
1496
+ [buildPhaseId]: {
1497
+ isa: 'PBXShellScriptBuildPhase',
1498
+ shellScript: '"echo \\"old script\\""',
1499
+ inputPaths: ['old-input.txt'],
1500
+ shellPath: '/bin/sh',
1501
+ buildActionMask: 2147483647,
1502
+ files: [],
1503
+ outputPaths: [],
1504
+ runOnlyForDeploymentPostprocessing: 0,
1505
+ },
1506
+ };
1507
+ // -- Act --
1508
+ xcodeProject.updateScriptBuildPhase(buildPhaseId, 'echo "new script"', ['new-input.txt']);
1509
+ // -- Assert --
1510
+ const buildPhase = xcodeProject.objects.PBXShellScriptBuildPhase?.[buildPhaseId];
1511
+ (0, vitest_1.expect)(buildPhase).toBeDefined();
1512
+ (0, vitest_1.expect)(buildPhase?.shellScript).toBe('"echo \\"new script\\""');
1513
+ (0, vitest_1.expect)(buildPhase?.inputPaths).toEqual(['new-input.txt']);
1514
+ (0, vitest_1.expect)(buildPhase?.shellPath).toBe('/bin/sh');
1515
+ });
1516
+ });
1517
+ });
1518
+ (0, vitest_1.describe)('addUploadSymbolsScript method comprehensive coverage', () => {
1519
+ let sourceProjectPath;
1520
+ let tempProjectPath;
1521
+ let xcodeProject;
1522
+ (0, vitest_1.beforeEach)(() => {
1523
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'add-upload-symbols-comprehensive'));
1524
+ sourceProjectPath = singleTargetProjectPath;
1525
+ tempProjectPath = path.resolve(tempDir, 'project.pbxproj');
1526
+ fs.copyFileSync(sourceProjectPath, tempProjectPath);
1527
+ xcodeProject = new xcode_manager_1.XcodeProject(tempProjectPath);
1528
+ });
1529
+ (0, vitest_1.describe)('when PBXShellScriptBuildPhase does not exist initially', () => {
1530
+ (0, vitest_1.it)('should initialize PBXShellScriptBuildPhase and add new build phase', () => {
1531
+ // -- Arrange --
1532
+ delete xcodeProject.objects.PBXShellScriptBuildPhase;
1533
+ // -- Act --
1534
+ xcodeProject.addUploadSymbolsScript({
1535
+ sentryProject: projectData,
1536
+ targetName: 'Project',
1537
+ uploadSource: true,
1538
+ });
1539
+ // -- Assert --
1540
+ (0, vitest_1.expect)(xcodeProject.objects.PBXShellScriptBuildPhase).toBeDefined();
1541
+ // Should have created a new build phase
1542
+ const buildPhases = Object.keys(xcodeProject.objects.PBXShellScriptBuildPhase || {});
1543
+ const actualBuildPhases = buildPhases.filter((key) => !key.endsWith('_comment'));
1544
+ (0, vitest_1.expect)(actualBuildPhases.length).toBeGreaterThan(0);
1545
+ });
1546
+ });
1547
+ (0, vitest_1.describe)('when target has buildPhases but no existing Sentry script', () => {
1548
+ (0, vitest_1.it)('should iterate through buildPhases and add new script', () => {
1549
+ // -- Arrange --
1550
+ // Ensure target has buildPhases but none contain sentry-cli
1551
+ const targetKey = 'D4E604CC2D50CEEC00CAB00F';
1552
+ const target = xcodeProject.objects.PBXNativeTarget?.[targetKey];
1553
+ if (target && typeof target !== 'string') {
1554
+ target.buildPhases = [
1555
+ { value: 'some-other-phase', comment: 'Sources' },
1556
+ { value: 'another-phase', comment: 'Frameworks' },
1557
+ ];
1558
+ }
1559
+ // Ensure PBXShellScriptBuildPhase exists but without sentry-cli scripts
1560
+ xcodeProject.objects.PBXShellScriptBuildPhase = {
1561
+ 'some-other-phase': {
1562
+ isa: 'PBXShellScriptBuildPhase',
1563
+ shellScript: '"echo \\"other script\\""',
1564
+ buildActionMask: 2147483647,
1565
+ files: [],
1566
+ inputPaths: [],
1567
+ outputPaths: [],
1568
+ runOnlyForDeploymentPostprocessing: 0,
1569
+ shellPath: '/bin/sh',
1570
+ },
1571
+ 'another-phase': {
1572
+ isa: 'PBXShellScriptBuildPhase',
1573
+ shellScript: '"echo \\"another script\\""',
1574
+ buildActionMask: 2147483647,
1575
+ files: [],
1576
+ inputPaths: [],
1577
+ outputPaths: [],
1578
+ runOnlyForDeploymentPostprocessing: 0,
1579
+ shellPath: '/bin/sh',
1580
+ },
1581
+ };
1582
+ // -- Act --
1583
+ xcodeProject.addUploadSymbolsScript({
1584
+ sentryProject: projectData,
1585
+ targetName: 'Project',
1586
+ uploadSource: true,
1587
+ });
1588
+ // -- Assert --
1589
+ // Should have added a new Sentry build phase (calls addScriptBuildPhase path)
1590
+ const buildPhases = Object.keys(xcodeProject.objects.PBXShellScriptBuildPhase || {});
1591
+ const actualBuildPhases = buildPhases.filter((key) => !key.endsWith('_comment'));
1592
+ (0, vitest_1.expect)(actualBuildPhases.length).toBeGreaterThan(2); // Should have more than the original 2
1593
+ // Find the new Sentry script
1594
+ const sentryPhase = actualBuildPhases.find((phaseId) => {
1595
+ const phase = xcodeProject.objects.PBXShellScriptBuildPhase?.[phaseId];
1596
+ return (phase &&
1597
+ typeof phase !== 'string' &&
1598
+ phase.shellScript?.includes('sentry-cli'));
1599
+ });
1600
+ (0, vitest_1.expect)(sentryPhase).toBeDefined();
1601
+ });
1602
+ });
1603
+ (0, vitest_1.describe)('when target has no buildPhases', () => {
1604
+ (0, vitest_1.it)('should skip the buildPhases iteration and add new script', () => {
1605
+ // -- Arrange --
1606
+ const targetKey = 'D4E604CC2D50CEEC00CAB00F';
1607
+ const target = xcodeProject.objects.PBXNativeTarget?.[targetKey];
1608
+ if (target && typeof target !== 'string') {
1609
+ // Set buildPhases to undefined to test the skip path
1610
+ target.buildPhases = undefined;
1611
+ }
1612
+ // -- Act --
1613
+ xcodeProject.addUploadSymbolsScript({
1614
+ sentryProject: projectData,
1615
+ targetName: 'Project',
1616
+ uploadSource: true,
1617
+ });
1618
+ // -- Assert --
1619
+ // Should have added a new Sentry build phase via the else branch (addScriptBuildPhase)
1620
+ const buildPhases = Object.keys(xcodeProject.objects.PBXShellScriptBuildPhase || {});
1621
+ const actualBuildPhases = buildPhases.filter((key) => !key.endsWith('_comment'));
1622
+ (0, vitest_1.expect)(actualBuildPhases.length).toBeGreaterThan(0);
1623
+ // Find the new Sentry script
1624
+ const sentryPhase = actualBuildPhases.find((phaseId) => {
1625
+ const phase = xcodeProject.objects.PBXShellScriptBuildPhase?.[phaseId];
1626
+ return (phase &&
1627
+ typeof phase !== 'string' &&
1628
+ phase.shellScript?.includes('sentry-cli'));
1629
+ });
1630
+ (0, vitest_1.expect)(sentryPhase).toBeDefined();
1631
+ });
1632
+ });
1633
+ });
1216
1634
  });
1217
1635
  });
1218
1636
  //# sourceMappingURL=xcode-manager.test.js.map