@sentry/wizard 4.8.0 → 4.9.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/CHANGELOG.md +8 -0
  2. package/dist/e2e-tests/tests/angular-17.test.js +41 -41
  3. package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
  4. package/dist/e2e-tests/tests/angular-19.test.js +39 -39
  5. package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
  6. package/dist/e2e-tests/tests/expo.test.js +10 -2
  7. package/dist/e2e-tests/tests/expo.test.js.map +1 -1
  8. package/dist/e2e-tests/tests/react-native.test.js +38 -3
  9. package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
  10. package/dist/e2e-tests/utils/index.js +14 -6
  11. package/dist/e2e-tests/utils/index.js.map +1 -1
  12. package/dist/lib/Helper/SentryCli.d.ts +0 -11
  13. package/dist/lib/Helper/SentryCli.js +0 -52
  14. package/dist/lib/Helper/SentryCli.js.map +1 -1
  15. package/dist/src/android/templates.js +2 -0
  16. package/dist/src/android/templates.js.map +1 -1
  17. package/dist/src/angular/angular-wizard.js +1 -1
  18. package/dist/src/angular/angular-wizard.js.map +1 -1
  19. package/dist/src/angular/sdk-setup.d.ts +1 -1
  20. package/dist/src/angular/sdk-setup.js +3 -3
  21. package/dist/src/angular/sdk-setup.js.map +1 -1
  22. package/dist/src/apple/code-tools.d.ts +4 -2
  23. package/dist/src/apple/code-tools.js +21 -11
  24. package/dist/src/apple/code-tools.js.map +1 -1
  25. package/dist/src/apple/inject-code-snippet.js +5 -3
  26. package/dist/src/apple/inject-code-snippet.js.map +1 -1
  27. package/dist/src/apple/macos-system-helper.d.ts +5 -0
  28. package/dist/src/apple/macos-system-helper.js +86 -0
  29. package/dist/src/apple/macos-system-helper.js.map +1 -0
  30. package/dist/src/apple/templates.js +10 -0
  31. package/dist/src/apple/templates.js.map +1 -1
  32. package/dist/src/apple/xcode-manager.d.ts +237 -11
  33. package/dist/src/apple/xcode-manager.js +736 -65
  34. package/dist/src/apple/xcode-manager.js.map +1 -1
  35. package/dist/src/apple/xcode-project-object-with-id.d.ts +5 -0
  36. package/dist/src/apple/xcode-project-object-with-id.js +3 -0
  37. package/dist/src/apple/xcode-project-object-with-id.js.map +1 -0
  38. package/dist/src/flutter/templates.js +7 -1
  39. package/dist/src/flutter/templates.js.map +1 -1
  40. package/dist/src/nextjs/nextjs-wizard.js +1 -3
  41. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  42. package/dist/src/nuxt/nuxt-wizard.js +1 -3
  43. package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
  44. package/dist/src/react-native/expo-env-file.js +5 -0
  45. package/dist/src/react-native/expo-env-file.js.map +1 -1
  46. package/dist/src/react-native/expo-metro.js +18 -5
  47. package/dist/src/react-native/expo-metro.js.map +1 -1
  48. package/dist/src/react-native/expo.js +6 -0
  49. package/dist/src/react-native/expo.js.map +1 -1
  50. package/dist/src/react-native/glob.js +14 -4
  51. package/dist/src/react-native/glob.js.map +1 -1
  52. package/dist/src/react-native/gradle.js +14 -4
  53. package/dist/src/react-native/gradle.js.map +1 -1
  54. package/dist/src/react-native/javascript.d.ts +9 -4
  55. package/dist/src/react-native/javascript.js +44 -22
  56. package/dist/src/react-native/javascript.js.map +1 -1
  57. package/dist/src/react-native/metro.d.ts +1 -1
  58. package/dist/src/react-native/metro.js +30 -4
  59. package/dist/src/react-native/metro.js.map +1 -1
  60. package/dist/src/react-native/react-native-wizard.d.ts +4 -0
  61. package/dist/src/react-native/react-native-wizard.js +32 -4
  62. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  63. package/dist/src/react-native/xcode.js +24 -9
  64. package/dist/src/react-native/xcode.js.map +1 -1
  65. package/dist/src/remix/remix-wizard.js +1 -3
  66. package/dist/src/remix/remix-wizard.js.map +1 -1
  67. package/dist/src/sveltekit/sveltekit-wizard.js +1 -3
  68. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  69. package/dist/src/utils/clack/index.d.ts +2 -12
  70. package/dist/src/utils/clack/index.js +8 -47
  71. package/dist/src/utils/clack/index.js.map +1 -1
  72. package/dist/src/utils/git.d.ts +11 -0
  73. package/dist/src/utils/git.js +69 -0
  74. package/dist/src/utils/git.js.map +1 -0
  75. package/dist/src/utils/sentrycli-utils.js +13 -4
  76. package/dist/src/utils/sentrycli-utils.js.map +1 -1
  77. package/dist/src/version.d.ts +1 -1
  78. package/dist/src/version.js +1 -1
  79. package/dist/src/version.js.map +1 -1
  80. package/dist/test/apple/code-tools.test.js +54 -35
  81. package/dist/test/apple/code-tools.test.js.map +1 -1
  82. package/dist/test/apple/configure-sentry-cli.test.d.ts +1 -0
  83. package/dist/test/apple/configure-sentry-cli.test.js +131 -0
  84. package/dist/test/apple/configure-sentry-cli.test.js.map +1 -0
  85. package/dist/test/apple/macos-system-helper-mocked.test.d.ts +1 -0
  86. package/dist/test/apple/macos-system-helper-mocked.test.js +46 -0
  87. package/dist/test/apple/macos-system-helper-mocked.test.js.map +1 -0
  88. package/dist/test/apple/macos-system-helper.test.d.ts +1 -0
  89. package/dist/test/apple/macos-system-helper.test.js +88 -0
  90. package/dist/test/apple/macos-system-helper.test.js.map +1 -0
  91. package/dist/test/apple/templates.test.js +10 -0
  92. package/dist/test/apple/templates.test.js.map +1 -1
  93. package/dist/test/apple/xcode-manager.test.js +745 -379
  94. package/dist/test/apple/xcode-manager.test.js.map +1 -1
  95. package/dist/test/flutter/templates.test.js +9 -0
  96. package/dist/test/flutter/templates.test.js.map +1 -1
  97. package/dist/test/react-native/javascript.test.js +119 -0
  98. package/dist/test/react-native/javascript.test.js.map +1 -1
  99. package/dist/test/utils/git.test.d.ts +1 -0
  100. package/dist/test/utils/git.test.js +70 -0
  101. package/dist/test/utils/git.test.js.map +1 -0
  102. package/package.json +1 -1
@@ -0,0 +1,5 @@
1
+ export declare class MacOSSystemHelpers {
2
+ static findSDKRootDirectoryPath(): string | undefined;
3
+ static findDeveloperDirectoryPath(): string | undefined;
4
+ static readXcodeBuildSettings(projectPath: string): Record<string, string> | undefined;
5
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MacOSSystemHelpers = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const debug_1 = require("../utils/debug");
6
+ class MacOSSystemHelpers {
7
+ static findSDKRootDirectoryPath() {
8
+ try {
9
+ // Some Candidates:
10
+ // - /Applications/Xcode-16.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
11
+ // - /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
12
+ const sdkPath = (0, child_process_1.execSync)('xcrun --show-sdk-path', {
13
+ encoding: 'utf8',
14
+ }).trim();
15
+ return sdkPath;
16
+ }
17
+ catch (error) {
18
+ (0, debug_1.debug)(`Failed to find SDK root directory path: ${error}`);
19
+ return undefined;
20
+ }
21
+ }
22
+ static findDeveloperDirectoryPath() {
23
+ try {
24
+ // Some Candidates:
25
+ // - /Applications/Xcode.app/Contents/Developer
26
+ // - /Applications/Xcode-16.3.0.app/Contents/Developer
27
+ const developerPath = (0, child_process_1.execSync)('xcode-select --print-path', {
28
+ encoding: 'utf8',
29
+ }).trim();
30
+ return developerPath;
31
+ }
32
+ catch (error) {
33
+ (0, debug_1.debug)(`Failed to find developer directory path: ${error}`);
34
+ return undefined;
35
+ }
36
+ }
37
+ static readXcodeBuildSettings(projectPath) {
38
+ try {
39
+ // The child_process.execSync() method is generally identical to exec with the exception that the method will not return until the child process has fully closed.
40
+ // When a timeout has been encountered and killSignal is sent, the method won't return until the process has completely exited.
41
+ // If the child process intercepts and handles the SIGTERMsignal and doesn't exit, the parent process will wait until the child process has exited.
42
+ //
43
+ // If the process times out or has a non-zero exit code, this method will throw.
44
+ // The Error object will contain the entire result from spawnSync.
45
+ //
46
+ // IMPORTANT:
47
+ // Never pass unsanitized user input to this function.
48
+ // Any input containing shell metacharacters may be used to trigger arbitrary command execution.
49
+ const output = (0, child_process_1.execSync)([
50
+ `xcodebuild`,
51
+ `-project`,
52
+ projectPath.replace(/\\/g, '\\\\').replace(/"/g, '\\"'),
53
+ `-showBuildSettings`,
54
+ ]
55
+ .map((arg) => `"${arg.trim()}"`)
56
+ .join(' '), {
57
+ encoding: 'utf8',
58
+ }).trim();
59
+ // --- Example Output: ---
60
+ // Command line invocation:
61
+ // /Applications/Xcode-16.3.0.app/Contents/Developer/usr/bin/xcodebuild -project ./fixtures/test-applications/apple/project-with-synchronized-folders/Project.xcodeproj -showBuildSettings
62
+ //
63
+ // Build settings for action build and target Project:
64
+ // ACTION = build
65
+ // ALLOW_BUILD_REQUEST_OVERRIDES = NO
66
+ // ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES
67
+ // ALTERNATE_GROUP = staff
68
+ // ...
69
+ const lines = output.split('\n');
70
+ const settings = {};
71
+ lines.forEach((line) => {
72
+ const match = line.match(/^\s*(\w+)\s+=\s+(.*)$/);
73
+ if (match) {
74
+ settings[match[1]] = match[2];
75
+ }
76
+ });
77
+ return settings;
78
+ }
79
+ catch (error) {
80
+ (0, debug_1.debug)(`Failed to read Xcode build settings: ${error}`);
81
+ return undefined;
82
+ }
83
+ }
84
+ }
85
+ exports.MacOSSystemHelpers = MacOSSystemHelpers;
86
+ //# sourceMappingURL=macos-system-helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"macos-system-helper.js","sourceRoot":"","sources":["../../../src/apple/macos-system-helper.ts"],"names":[],"mappings":";;;AAAA,iDAAyC;AACzC,0CAAuC;AAEvC,MAAa,kBAAkB;IAC7B,MAAM,CAAC,wBAAwB;QAC7B,IAAI;YACF,mBAAmB;YACnB,0GAA0G;YAC1G,wDAAwD;YACxD,MAAM,OAAO,GAAG,IAAA,wBAAQ,EAAC,uBAAuB,EAAE;gBAChD,QAAQ,EAAE,MAAM;aACjB,CAAC,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,OAAO,CAAC;SAChB;QAAC,OAAO,KAAK,EAAE;YACd,IAAA,aAAK,EAAC,2CAA2C,KAAe,EAAE,CAAC,CAAC;YACpE,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;IAED,MAAM,CAAC,0BAA0B;QAC/B,IAAI;YACF,mBAAmB;YACnB,+CAA+C;YAC/C,sDAAsD;YACtD,MAAM,aAAa,GAAG,IAAA,wBAAQ,EAAC,2BAA2B,EAAE;gBAC1D,QAAQ,EAAE,MAAM;aACjB,CAAC,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,aAAa,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACd,IAAA,aAAK,EAAC,4CAA4C,KAAe,EAAE,CAAC,CAAC;YACrE,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;IAED,MAAM,CAAC,sBAAsB,CAC3B,WAAmB;QAEnB,IAAI;YACF,kKAAkK;YAClK,+HAA+H;YAC/H,mJAAmJ;YACnJ,EAAE;YACF,gFAAgF;YAChF,kEAAkE;YAClE,EAAE;YACF,aAAa;YACb,2DAA2D;YAC3D,qGAAqG;YACrG,MAAM,MAAM,GAAG,IAAA,wBAAQ,EACrB;gBACE,YAAY;gBACZ,UAAU;gBACV,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;gBACvD,oBAAoB;aACrB;iBACE,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC;iBAC/B,IAAI,CAAC,GAAG,CAAC,EACZ;gBACE,QAAQ,EAAE,MAAM;aACjB,CACF,CAAC,IAAI,EAAE,CAAC;YACT,0BAA0B;YAC1B,2BAA2B;YAC3B,0LAA0L;YAC1L,EAAE;YACF,sDAAsD;YACtD,qBAAqB;YACrB,yCAAyC;YACzC,iDAAiD;YACjD,8BAA8B;YAC9B,UAAU;YACV,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM,QAAQ,GAA2B,EAAE,CAAC;YAC5C,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACrB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;gBAClD,IAAI,KAAK,EAAE;oBACT,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;iBAC/B;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;SACjB;QAAC,OAAO,KAAK,EAAE;YACd,IAAA,aAAK,EAAC,wCAAwC,KAAe,EAAE,CAAC,CAAC;YACjE,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;CACF;AAnFD,gDAmFC","sourcesContent":["import { execSync } from 'child_process';\nimport { debug } from '../utils/debug';\n\nexport class MacOSSystemHelpers {\n static findSDKRootDirectoryPath(): string | undefined {\n try {\n // Some Candidates:\n // - /Applications/Xcode-16.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk\n // - /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk\n const sdkPath = execSync('xcrun --show-sdk-path', {\n encoding: 'utf8',\n }).trim();\n return sdkPath;\n } catch (error) {\n debug(`Failed to find SDK root directory path: ${error as string}`);\n return undefined;\n }\n }\n\n static findDeveloperDirectoryPath(): string | undefined {\n try {\n // Some Candidates:\n // - /Applications/Xcode.app/Contents/Developer\n // - /Applications/Xcode-16.3.0.app/Contents/Developer\n const developerPath = execSync('xcode-select --print-path', {\n encoding: 'utf8',\n }).trim();\n return developerPath;\n } catch (error) {\n debug(`Failed to find developer directory path: ${error as string}`);\n return undefined;\n }\n }\n\n static readXcodeBuildSettings(\n projectPath: string,\n ): Record<string, string> | undefined {\n try {\n // The child_process.execSync() method is generally identical to exec with the exception that the method will not return until the child process has fully closed.\n // When a timeout has been encountered and killSignal is sent, the method won't return until the process has completely exited.\n // If the child process intercepts and handles the SIGTERMsignal and doesn't exit, the parent process will wait until the child process has exited.\n //\n // If the process times out or has a non-zero exit code, this method will throw.\n // The Error object will contain the entire result from spawnSync.\n //\n // IMPORTANT:\n // Never pass unsanitized user input to this function.\n // Any input containing shell metacharacters may be used to trigger arbitrary command execution.\n const output = execSync(\n [\n `xcodebuild`,\n `-project`,\n projectPath.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"'),\n `-showBuildSettings`,\n ]\n .map((arg) => `\"${arg.trim()}\"`)\n .join(' '),\n {\n encoding: 'utf8',\n },\n ).trim();\n // --- Example Output: ---\n // Command line invocation:\n // /Applications/Xcode-16.3.0.app/Contents/Developer/usr/bin/xcodebuild -project ./fixtures/test-applications/apple/project-with-synchronized-folders/Project.xcodeproj -showBuildSettings\n //\n // Build settings for action build and target Project:\n // ACTION = build\n // ALLOW_BUILD_REQUEST_OVERRIDES = NO\n // ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES\n // ALTERNATE_GROUP = staff\n // ...\n const lines = output.split('\\n');\n const settings: Record<string, string> = {};\n lines.forEach((line) => {\n const match = line.match(/^\\s*(\\w+)\\s+=\\s+(.*)$/);\n if (match) {\n settings[match[1]] = match[2];\n }\n });\n\n return settings;\n } catch (error) {\n debug(`Failed to read Xcode build settings: ${error as string}`);\n return undefined;\n }\n }\n}\n"]}
@@ -14,6 +14,11 @@ function getSwiftSnippet(dsn) {
14
14
  return ` SentrySDK.start { options in
15
15
  options.dsn = "${dsn}"
16
16
  options.debug = true // Enabled debug when first installing is always helpful
17
+
18
+ // Adds IP for users.
19
+ // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/
20
+ options.sendDefaultPii = true
21
+
17
22
  // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
18
23
  // We recommend adjusting this value in production.
19
24
  options.tracesSampleRate = 1.0
@@ -36,6 +41,11 @@ function getObjcSnippet(dsn) {
36
41
  return ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {
37
42
  options.dsn = @"${dsn}";
38
43
  options.debug = YES; // Enabled debug when first installing is always helpful
44
+
45
+ // Adds IP for users.
46
+ // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/
47
+ options.sendDefaultPii = YES;
48
+
39
49
  // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
40
50
  // We recommend adjusting this value in production.
41
51
  options.tracesSampleRate = @1.0;
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC,uFAAuF;QACzF,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe,+DAA+D,OAAO,4BAA4B,WAAW,4CAC3N,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC,2OAA2O,CAAC;AAC9O,CAAC;AAbD,oDAaC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO;6BACoB,GAAG;;;;;;;;;;;;;;;;;iEAiBiC,CAAC;AAClE,CAAC;AApBD,0CAoBC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO;0BACiB,GAAG;;;;;;;;;;;;;;;;;2DAiB8B,CAAC;AAC5D,CAAC;AApBD,wCAoBC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? '\\\\nif [[ \"$(uname -m)\" == arm64 ]]; then\\\\nexport PATH=\"/opt/homebrew/bin:$PATH\"\\\\nfi'\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\\\\nif which sentry-cli >/dev/null; then\\\\nexport SENTRY_ORG=${orgSlug}\\\\nexport SENTRY_PROJECT=${projectSlug}\\\\nERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\\\\nif [ ! $? -eq 0 ]; then\\\\necho \"warning: sentry-cli - $ERROR\"\\\\nfi\\\\nelse\\\\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\\\\nfi\\\\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string): string {\n return ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n options.debug = true // Enabled debug when first installing is always helpful\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n}\n\nexport function getObjcSnippet(dsn: string): string {\n return ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n options.debug = YES; // Enabled debug when first installing is always helpful\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return ` sentry_cli(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC,uFAAuF;QACzF,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe,+DAA+D,OAAO,4BAA4B,WAAW,4CAC3N,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC,2OAA2O,CAAC;AAC9O,CAAC;AAbD,oDAaC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO;6BACoB,GAAG;;;;;;;;;;;;;;;;;;;;;;iEAsBiC,CAAC;AAClE,CAAC;AAzBD,0CAyBC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO;0BACiB,GAAG;;;;;;;;;;;;;;;;;;;;;;2DAsB8B,CAAC;AAC5D,CAAC;AAzBD,wCAyBC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? '\\\\nif [[ \"$(uname -m)\" == arm64 ]]; then\\\\nexport PATH=\"/opt/homebrew/bin:$PATH\"\\\\nfi'\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\\\\nif which sentry-cli >/dev/null; then\\\\nexport SENTRY_ORG=${orgSlug}\\\\nexport SENTRY_PROJECT=${projectSlug}\\\\nERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\\\\nif [ ! $? -eq 0 ]; then\\\\necho \"warning: sentry-cli - $ERROR\"\\\\nfi\\\\nelse\\\\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\\\\nfi\\\\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string): string {\n return ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n options.debug = true // Enabled debug when first installing is always helpful\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = true\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n}\n\nexport function getObjcSnippet(dsn: string): string {\n return ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n options.debug = YES; // Enabled debug when first installing is always helpful\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = YES;\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return ` sentry_cli(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
@@ -1,14 +1,24 @@
1
1
  import type { SentryProjectData } from '../utils/types';
2
- import { type PBXGroup, type PBXObjects, type Project } from 'xcode';
3
- interface ProjectFile {
4
- key: string;
5
- path: string;
6
- }
2
+ import { PBXSourcesBuildPhase, type PBXNativeTarget, type PBXObjects, type Project } from 'xcode';
3
+ import { XcodeProjectObjectWithId } from './xcode-project-object-with-id';
7
4
  export declare class XcodeProject {
8
- projectPath: string;
5
+ /**
6
+ * The directory where the Xcode project is located.
7
+ */
8
+ baseDir: string;
9
+ /**
10
+ * The path to the `<PROJECT>.xcodeproj` directory.
11
+ */
12
+ xcodeprojPath: string;
13
+ /**
14
+ * The path to the `project.pbxproj` file.
15
+ */
16
+ pbxprojPath: string;
17
+ /**
18
+ * The Xcode project object.
19
+ */
9
20
  project: Project;
10
21
  objects: PBXObjects;
11
- files: ProjectFile[] | undefined;
12
22
  /**
13
23
  * Creates a new XcodeProject instance, a wrapper around the Xcode project file `<PROJECT>.xcodeproj/project.pbxproj`.
14
24
  *
@@ -17,8 +27,224 @@ export declare class XcodeProject {
17
27
  constructor(projectPath: string);
18
28
  getAllTargets(): string[];
19
29
  updateXcodeProject(sentryProject: SentryProjectData, target: string, addSPMReference: boolean, uploadSource?: boolean): void;
20
- filesForTarget(target: string): string[] | undefined;
21
- projectFiles(): ProjectFile[];
22
- buildGroup(group: PBXGroup, path?: string): ProjectFile[];
30
+ /**
31
+ * Retrieves all source files associated with a specific target in the Xcode project.
32
+ * This is used to find files where we can inject Sentry initialization code.
33
+ *
34
+ * @param targetName - The name of the target to get files for
35
+ * @returns An array of absolute file paths for the target's source files, or undefined if target not found
36
+ */
37
+ getSourceFilesForTarget(targetName: string): string[] | undefined;
38
+ /**
39
+ * Finds a native target by name.
40
+ *
41
+ * @param targetName - The name of the target to find
42
+ * @returns The native target, or undefined if the target is not found
43
+ */
44
+ private findNativeTargetByName;
45
+ /**
46
+ * Finds the source build phase in a target.
47
+ *
48
+ * @param target - The target to find the source build phase in
49
+ * @returns The source build phase, or undefined if the target is not found or has no source build phase
50
+ */
51
+ findSourceBuildPhaseInTarget(target: PBXNativeTarget): XcodeProjectObjectWithId<PBXSourcesBuildPhase> | undefined;
52
+ /**
53
+ * Finds all files in the source build phase of a target.
54
+ *
55
+ * @param nativeTarget - The target to find the files in
56
+ * @returns The files in the source build phase of the target, or an empty array if the target is not found or has no source build phase
57
+ */
58
+ findFilesInSourceBuildPhase(nativeTarget: XcodeProjectObjectWithId<PBXNativeTarget>): string[];
59
+ /**
60
+ * Resolves the absolute path of a file reference.
61
+ *
62
+ * @param fileRef - The file reference to resolve the path of
63
+ * @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path
64
+ */
65
+ private resolveAbsolutePathOfFileReference;
66
+ /**
67
+ * Resolves the absolute path of a file reference relative to the parent group.
68
+ *
69
+ * @param fileRef - The file reference to resolve the path of
70
+ * @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path
71
+ */
72
+ private resolveAbsoluteFilePathRelativeToGroup;
73
+ /**
74
+ * Resolves the absolute path of a file reference relative to the built products directory.
75
+ *
76
+ * @param buildFile - The file reference to resolve the path of
77
+ * @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path
78
+ */
79
+ private resolveAbsoluteFilePathRelativeToBuiltProductsDir;
80
+ /**
81
+ * Resolves the absolute path of a file reference relative to the source root.
82
+ *
83
+ * The source root is the directory where the `.xcodeproj` file is located.
84
+ *
85
+ * @param buildFile - The file reference to resolve the path of
86
+ * @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path
87
+ */
88
+ private resolveAbsoluteFilePathRelativeToSourceRoot;
89
+ /**
90
+ * Resolves the absolute path of a file reference relative to the SDK root.
91
+ *
92
+ * @param buildFile - The file reference to resolve the path of
93
+ * @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path
94
+ */
95
+ private resolveAbsoluteFilePathRelativeToSdkRoot;
96
+ /**
97
+ * Resolves the absolute path of a file reference relative to the developer directory.
98
+ *
99
+ * @param buildFile - The file reference to resolve the path of
100
+ * @returns The absolute path of the file reference, or undefined if the file reference is not found or has no path
101
+ */
102
+ private resolveAbsoluteFilePathRelativeToDeveloperDir;
103
+ /**
104
+ * Resolves the absolute path of a group.
105
+ *
106
+ * @param group - The group to resolve the path of
107
+ * @returns The absolute path of the group, or undefined if the group is not found or has no path
108
+ */
109
+ private resolveAbsolutePathOfGroup;
110
+ /**
111
+ * Resolves the path of a group relative to the parent group.
112
+ *
113
+ * @param group - The group to resolve the path of
114
+ * @returns The path of the group relative to the parent group, or undefined if the group is not found or has no path
115
+ */
116
+ private resolvePathOfGroupRelativeToGroup;
117
+ /**
118
+ * Resolves the path of a group relative to the source root.
119
+ *
120
+ * The source root is the directory where the `.xcodeproj` file is located.
121
+ *
122
+ * @param group - The group to resolve the path of
123
+ * @returns The path of the group relative to the source root, or undefined if the group is not found or has no path
124
+ */
125
+ private resolvePathOfGroupRelativeToSourceRoot;
126
+ /**
127
+ * Resolves the path of a group relative to the built products directory.
128
+ *
129
+ * @param group - The group to resolve the path of
130
+ * @returns The path of the group relative to the built products directory, or undefined if the group is not found or has no path
131
+ */
132
+ private resolvePathOfGroupRelativeToBuiltProductsDir;
133
+ /**
134
+ * Resolves the path of a group relative to the SDK root.
135
+ *
136
+ * The SDK root is the directory where the SDK is installed.
137
+ *
138
+ * @param group - The group to resolve the path of
139
+ * @returns The path of the group relative to the SDK root, or undefined if the group is not found or has no path
140
+ */
141
+ private resolvePathOfGroupRelativeToSdkRoot;
142
+ /**
143
+ * Resolves the path of a group relative to the developer directory.
144
+ *
145
+ * The developer directory is the directory where the Xcode command line tools are installed.
146
+ *
147
+ * @param group - The group to resolve the path of
148
+ * @returns The path of the group relative to the developer directory, or undefined if the group is not found or has no path
149
+ */
150
+ private resolvePathOfGroupRelativeToDeveloperDir;
151
+ /**
152
+ * Resolves the absolute path of a group.
153
+ *
154
+ * @param group - The group to resolve the path of
155
+ * @returns The absolute path of the group, or undefined if the group is not found or has no path
156
+ */
157
+ private resolveAbsolutePathOfSynchronizedRootGroup;
158
+ /**
159
+ * Resolves the path of a group relative to the parent group.
160
+ *
161
+ * @param group - The group to resolve the path of
162
+ * @returns The path of the group relative to the parent group, or undefined if the group is not found or has no path
163
+ */
164
+ private resolvePathOfSynchronizedRootGroupRelativeToGroup;
165
+ /**
166
+ * Resolves the path of a group relative to the source root.
167
+ *
168
+ * The source root is the directory where the `.xcodeproj` file is located.
169
+ *
170
+ * @param group - The group to resolve the path of
171
+ * @returns The path of the group relative to the source root, or undefined if the group is not found or has no path
172
+ */
173
+ private resolvePathOfSynchronizedRootGroupRelativeToSourceRoot;
174
+ /**
175
+ * Resolves the path of a group relative to the built products directory.
176
+ *
177
+ * @param group - The group to resolve the path of
178
+ * @returns The path of the group relative to the built products directory, or undefined if the group is not found or has no path
179
+ */
180
+ private resolvePathOfSynchronizedRootGroupRelativeToBuiltProductsDir;
181
+ /**
182
+ * Resolves the path of a group relative to the SDK root.
183
+ *
184
+ * The SDK root is the directory where the SDK is installed.
185
+ *
186
+ * @param group - The group to resolve the path of
187
+ * @returns The path of the group relative to the SDK root, or undefined if the group is not found or has no path
188
+ */
189
+ private resolvePathOfSynchronizedRootGroupRelativeToSdkRoot;
190
+ /**
191
+ * Resolves the path of a group relative to the developer directory.
192
+ *
193
+ * The developer directory is the directory where the Xcode command line tools are installed.
194
+ *
195
+ * @param group - The group to resolve the path of
196
+ * @returns The path of the group relative to the developer directory, or undefined if the group is not found or has no path
197
+ */
198
+ private resolvePathOfSynchronizedRootGroupRelativeToDeveloperDir;
199
+ /**
200
+ * Finds all files in the synchronized root groups of a target.
201
+ *
202
+ * @param nativeTarget - The target to find the files in
203
+ * @returns The files in the synchronized root groups of the target, or an empty array if the target is not found or has no synchronized root groups
204
+ */
205
+ findFilesInSynchronizedRootGroups(nativeTarget: XcodeProjectObjectWithId<PBXNativeTarget>): string[];
206
+ private getFilesInSynchronizedRootGroup;
207
+ /**
208
+ * Returns all files in a directory tree.
209
+ *
210
+ * @param dirPath - The path of the directory to get the files in
211
+ * @returns All files in the directory tree, or an empty array if the directory does not exist
212
+ */
213
+ private getAbsoluteFilePathsInDirectoryTree;
214
+ private filterFilesByExceptionSets;
215
+ /**
216
+ * Returns all groups that are PBXGroup.
217
+ *
218
+ * This is a helper method to avoid having to map and filter the groups manually.
219
+ *
220
+ * @returns All groups that are PBXGroup, excluding comments and non-object values.
221
+ */
222
+ private get groups();
223
+ /**
224
+ * Finds the parent group of a child group or file reference.
225
+ *
226
+ * @param childId - The ID of the child group or file reference
227
+ * @returns The parent group of the child group or file reference, or undefined if the child group or file reference is not found or has no parent group
228
+ */
229
+ private findParentGroupByChildId;
230
+ /**
231
+ * Checks if a group is the main group of any project.
232
+ *
233
+ * @param groupId - The ID of the group to check
234
+ * @returns True if the group is the main group, false otherwise
235
+ */
236
+ private isMainGroup;
237
+ private getExceptionSetsForGroup;
238
+ /**
239
+ * The path to the build products directory for the project.
240
+ *
241
+ * This is cached to avoid having to read the build settings from Xcode for each call to `getBuildProductsDirectoryPath`.
242
+ */
243
+ private buildProductsDir;
244
+ /**
245
+ * Returns the path to the build products directory for the project.
246
+ *
247
+ * @returns The path to the build products directory for the project, or undefined if the path is not found
248
+ */
249
+ private getBuildProductsDirectoryPath;
23
250
  }
24
- export {};