@sentry/wizard 6.11.0 → 6.13.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 (245) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/bin.js +16 -1
  3. package/dist/bin.js.map +1 -1
  4. package/dist/e2e-tests/tests/angular-17.test.js +3 -4
  5. package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
  6. package/dist/e2e-tests/tests/angular-19.test.js +3 -4
  7. package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
  8. package/dist/e2e-tests/tests/cloudflare-worker.test.js +5 -0
  9. package/dist/e2e-tests/tests/cloudflare-worker.test.js.map +1 -1
  10. package/dist/e2e-tests/tests/flutter.test.js +60 -0
  11. package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
  12. package/dist/e2e-tests/tests/help-message.test.js +8 -3
  13. package/dist/e2e-tests/tests/help-message.test.js.map +1 -1
  14. package/dist/e2e-tests/tests/nuxt-3.test.js +12 -6
  15. package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
  16. package/dist/e2e-tests/tests/nuxt-4.test.js +12 -6
  17. package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
  18. package/dist/e2e-tests/tests/pnpm-workspace.test.js +8 -4
  19. package/dist/e2e-tests/tests/pnpm-workspace.test.js.map +1 -1
  20. package/dist/e2e-tests/tests/react-router-instrumentation-api.test.js +96 -0
  21. package/dist/e2e-tests/tests/react-router-instrumentation-api.test.js.map +1 -0
  22. package/dist/e2e-tests/tests/react-router.test.js +6 -7
  23. package/dist/e2e-tests/tests/react-router.test.js.map +1 -1
  24. package/dist/e2e-tests/tests/remix.test.js +2 -4
  25. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  26. package/dist/e2e-tests/tests/sveltekit-hooks.test.js +24 -8
  27. package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -1
  28. package/dist/e2e-tests/tests/sveltekit-tracing.test.js +8 -4
  29. package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -1
  30. package/dist/lib/Constants.d.ts +1 -0
  31. package/dist/lib/Constants.js +5 -0
  32. package/dist/lib/Constants.js.map +1 -1
  33. package/dist/lib/Steps/Integrations/Electron.js +2 -2
  34. package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
  35. package/dist/src/android/android-wizard.js +3 -0
  36. package/dist/src/android/android-wizard.js.map +1 -1
  37. package/dist/src/angular/codemods/main.d.ts +1 -1
  38. package/dist/src/angular/codemods/main.js +0 -1
  39. package/dist/src/angular/codemods/main.js.map +1 -1
  40. package/dist/src/apple/apple-wizard.js +2 -3
  41. package/dist/src/apple/apple-wizard.js.map +1 -1
  42. package/dist/src/apple/check-installed-cli.d.ts +1 -1
  43. package/dist/src/apple/check-installed-cli.js +13 -7
  44. package/dist/src/apple/check-installed-cli.js.map +1 -1
  45. package/dist/src/apple/code-tools.js +17 -3
  46. package/dist/src/apple/code-tools.js.map +1 -1
  47. package/dist/src/apple/configure-package-manager.js +18 -5
  48. package/dist/src/apple/configure-package-manager.js.map +1 -1
  49. package/dist/src/apple/configure-xcode-project.js +8 -1
  50. package/dist/src/apple/configure-xcode-project.js.map +1 -1
  51. package/dist/src/apple/lookup-xcode-project.d.ts +8 -5
  52. package/dist/src/apple/lookup-xcode-project.js +22 -17
  53. package/dist/src/apple/lookup-xcode-project.js.map +1 -1
  54. package/dist/src/apple/options.d.ts +5 -0
  55. package/dist/src/apple/options.js.map +1 -1
  56. package/dist/src/apple/sentry-swift-package.d.ts +4 -0
  57. package/dist/src/apple/sentry-swift-package.js +17 -0
  58. package/dist/src/apple/sentry-swift-package.js.map +1 -0
  59. package/dist/src/apple/snapshots/apple-snapshots-wizard.d.ts +2 -0
  60. package/dist/src/apple/snapshots/apple-snapshots-wizard.js +251 -0
  61. package/dist/src/apple/snapshots/apple-snapshots-wizard.js.map +1 -0
  62. package/dist/src/apple/snapshots/configure-snapshotpreviews-xcode-project.d.ts +13 -0
  63. package/dist/src/apple/snapshots/configure-snapshotpreviews-xcode-project.js +48 -0
  64. package/dist/src/apple/snapshots/configure-snapshotpreviews-xcode-project.js.map +1 -0
  65. package/dist/src/apple/snapshots/snapshot-test-file.d.ts +18 -0
  66. package/dist/src/apple/snapshots/snapshot-test-file.js +122 -0
  67. package/dist/src/apple/snapshots/snapshot-test-file.js.map +1 -0
  68. package/dist/src/apple/snapshots/snapshot-verification-scheme.d.ts +6 -0
  69. package/dist/src/apple/snapshots/snapshot-verification-scheme.js +147 -0
  70. package/dist/src/apple/snapshots/snapshot-verification-scheme.js.map +1 -0
  71. package/dist/src/apple/snapshots/snapshotpreviews-package.d.ts +4 -0
  72. package/dist/src/apple/snapshots/snapshotpreviews-package.js +8 -0
  73. package/dist/src/apple/snapshots/snapshotpreviews-package.js.map +1 -0
  74. package/dist/src/apple/snapshots/snapshots-cli-preflight.d.ts +23 -0
  75. package/dist/src/apple/snapshots/snapshots-cli-preflight.js +136 -0
  76. package/dist/src/apple/snapshots/snapshots-cli-preflight.js.map +1 -0
  77. package/dist/src/apple/xcode-manager.d.ts +59 -1
  78. package/dist/src/apple/xcode-manager.js +507 -106
  79. package/dist/src/apple/xcode-manager.js.map +1 -1
  80. package/dist/src/cloudflare/cloudflare-wizard.js +5 -0
  81. package/dist/src/cloudflare/cloudflare-wizard.js.map +1 -1
  82. package/dist/src/cloudflare/sdk-setup.d.ts +1 -0
  83. package/dist/src/cloudflare/sdk-setup.js.map +1 -1
  84. package/dist/src/cloudflare/templates.d.ts +1 -0
  85. package/dist/src/cloudflare/templates.js +7 -1
  86. package/dist/src/cloudflare/templates.js.map +1 -1
  87. package/dist/src/cloudflare/wrap-worker.d.ts +1 -0
  88. package/dist/src/cloudflare/wrap-worker.js +7 -0
  89. package/dist/src/cloudflare/wrap-worker.js.map +1 -1
  90. package/dist/src/flutter/flutter-wizard.js +3 -0
  91. package/dist/src/flutter/flutter-wizard.js.map +1 -1
  92. package/dist/src/nextjs/templates.js +12 -6
  93. package/dist/src/nextjs/templates.js.map +1 -1
  94. package/dist/src/nuxt/templates.js +12 -6
  95. package/dist/src/nuxt/templates.js.map +1 -1
  96. package/dist/src/react-native/expo.d.ts +6 -0
  97. package/dist/src/react-native/expo.js +27 -1
  98. package/dist/src/react-native/expo.js.map +1 -1
  99. package/dist/src/react-native/git.d.ts +5 -0
  100. package/dist/src/react-native/git.js +32 -1
  101. package/dist/src/react-native/git.js.map +1 -1
  102. package/dist/src/react-native/javascript.js +3 -1
  103. package/dist/src/react-native/javascript.js.map +1 -1
  104. package/dist/src/react-native/react-native-wizard.js +12 -6
  105. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  106. package/dist/src/react-router/codemods/client.entry.d.ts +1 -1
  107. package/dist/src/react-router/codemods/client.entry.js +124 -26
  108. package/dist/src/react-router/codemods/client.entry.js.map +1 -1
  109. package/dist/src/react-router/codemods/react-router-config.js +1 -1
  110. package/dist/src/react-router/codemods/react-router-config.js.map +1 -1
  111. package/dist/src/react-router/codemods/server-entry.d.ts +1 -1
  112. package/dist/src/react-router/codemods/server-entry.js +40 -4
  113. package/dist/src/react-router/codemods/server-entry.js.map +1 -1
  114. package/dist/src/react-router/codemods/vite.js +46 -1
  115. package/dist/src/react-router/codemods/vite.js.map +1 -1
  116. package/dist/src/react-router/react-router-wizard.js +62 -21
  117. package/dist/src/react-router/react-router-wizard.js.map +1 -1
  118. package/dist/src/react-router/sdk-setup.d.ts +5 -3
  119. package/dist/src/react-router/sdk-setup.js +44 -16
  120. package/dist/src/react-router/sdk-setup.js.map +1 -1
  121. package/dist/src/react-router/templates.d.ts +2 -4
  122. package/dist/src/react-router/templates.js +89 -87
  123. package/dist/src/react-router/templates.js.map +1 -1
  124. package/dist/src/remix/sdk-setup.js +1 -2
  125. package/dist/src/remix/sdk-setup.js.map +1 -1
  126. package/dist/src/run.d.ts +4 -1
  127. package/dist/src/run.js +13 -0
  128. package/dist/src/run.js.map +1 -1
  129. package/dist/src/sourcemaps/tools/remix.js +4 -4
  130. package/dist/src/sourcemaps/tools/remix.js.map +1 -1
  131. package/dist/src/sourcemaps/tools/vite.js +1 -1
  132. package/dist/src/sourcemaps/tools/vite.js.map +1 -1
  133. package/dist/src/sveltekit/sdk-setup/setup.js +17 -4
  134. package/dist/src/sveltekit/sdk-setup/setup.js.map +1 -1
  135. package/dist/src/sveltekit/sdk-setup/vite.js +1 -1
  136. package/dist/src/sveltekit/sdk-setup/vite.js.map +1 -1
  137. package/dist/src/sveltekit/templates.js +12 -6
  138. package/dist/src/sveltekit/templates.js.map +1 -1
  139. package/dist/src/utils/ast-utils.d.ts +10 -0
  140. package/dist/src/utils/ast-utils.js +19 -1
  141. package/dist/src/utils/ast-utils.js.map +1 -1
  142. package/dist/src/utils/clack/index.d.ts +2 -1
  143. package/dist/src/utils/clack/index.js +17 -6
  144. package/dist/src/utils/clack/index.js.map +1 -1
  145. package/dist/src/utils/files.d.ts +2 -0
  146. package/dist/src/utils/files.js +58 -0
  147. package/dist/src/utils/files.js.map +1 -0
  148. package/dist/src/utils/git.d.ts +3 -1
  149. package/dist/src/utils/git.js +2 -1
  150. package/dist/src/utils/git.js.map +1 -1
  151. package/dist/src/utils/line-endings.d.ts +1 -0
  152. package/dist/src/utils/line-endings.js +76 -0
  153. package/dist/src/utils/line-endings.js.map +1 -0
  154. package/dist/src/version.d.ts +1 -1
  155. package/dist/src/version.js +1 -1
  156. package/dist/src/version.js.map +1 -1
  157. package/dist/test/angular/angular-wizard.test.js +0 -5
  158. package/dist/test/angular/angular-wizard.test.js.map +1 -1
  159. package/dist/test/apple/code-tools.test.js +78 -0
  160. package/dist/test/apple/code-tools.test.js.map +1 -1
  161. package/dist/test/apple/configure-package-manager.test.d.ts +1 -0
  162. package/dist/test/apple/configure-package-manager.test.js +161 -0
  163. package/dist/test/apple/configure-package-manager.test.js.map +1 -0
  164. package/dist/test/apple/lookup-xcode-project.test.d.ts +1 -0
  165. package/dist/test/apple/lookup-xcode-project.test.js +167 -0
  166. package/dist/test/apple/lookup-xcode-project.test.js.map +1 -0
  167. package/dist/test/apple/snapshots/apple-snapshots-wizard.test.d.ts +1 -0
  168. package/dist/test/apple/snapshots/apple-snapshots-wizard.test.js +487 -0
  169. package/dist/test/apple/snapshots/apple-snapshots-wizard.test.js.map +1 -0
  170. package/dist/test/apple/snapshots/hosted-test-target-fixture.d.ts +24 -0
  171. package/dist/test/apple/snapshots/hosted-test-target-fixture.js +191 -0
  172. package/dist/test/apple/snapshots/hosted-test-target-fixture.js.map +1 -0
  173. package/dist/test/apple/snapshots/snapshot-test-file.test.d.ts +1 -0
  174. package/dist/test/apple/snapshots/snapshot-test-file.test.js +110 -0
  175. package/dist/test/apple/snapshots/snapshot-test-file.test.js.map +1 -0
  176. package/dist/test/apple/snapshots/snapshot-verification-scheme.test.d.ts +1 -0
  177. package/dist/test/apple/snapshots/snapshot-verification-scheme.test.js +146 -0
  178. package/dist/test/apple/snapshots/snapshot-verification-scheme.test.js.map +1 -0
  179. package/dist/test/apple/snapshots/snapshotpreviews-xcode-smoke.test.d.ts +1 -0
  180. package/dist/test/apple/snapshots/snapshotpreviews-xcode-smoke.test.js +186 -0
  181. package/dist/test/apple/snapshots/snapshotpreviews-xcode-smoke.test.js.map +1 -0
  182. package/dist/test/apple/snapshots/snapshots-cli-preflight.test.d.ts +1 -0
  183. package/dist/test/apple/snapshots/snapshots-cli-preflight.test.js +192 -0
  184. package/dist/test/apple/snapshots/snapshots-cli-preflight.test.js.map +1 -0
  185. package/dist/test/apple/snapshots/source-file-insertion.test.d.ts +1 -0
  186. package/dist/test/apple/snapshots/source-file-insertion.test.js +77 -0
  187. package/dist/test/apple/snapshots/source-file-insertion.test.js.map +1 -0
  188. package/dist/test/apple/xcode-manager.test.js +452 -43
  189. package/dist/test/apple/xcode-manager.test.js.map +1 -1
  190. package/dist/test/cloudflare/sdk-setup.test.js +20 -2
  191. package/dist/test/cloudflare/sdk-setup.test.js.map +1 -1
  192. package/dist/test/cloudflare/templates.test.js +54 -0
  193. package/dist/test/cloudflare/templates.test.js.map +1 -1
  194. package/dist/test/cloudflare/wrap-worker.test.js +74 -11
  195. package/dist/test/cloudflare/wrap-worker.test.js.map +1 -1
  196. package/dist/test/constants.test.d.ts +1 -0
  197. package/dist/test/constants.test.js +12 -0
  198. package/dist/test/constants.test.js.map +1 -0
  199. package/dist/test/nextjs/templates.test.js +66 -33
  200. package/dist/test/nextjs/templates.test.js.map +1 -1
  201. package/dist/test/nuxt/templates.test.js +66 -36
  202. package/dist/test/nuxt/templates.test.js.map +1 -1
  203. package/dist/test/react-native/expo.test.js +140 -0
  204. package/dist/test/react-native/expo.test.js.map +1 -1
  205. package/dist/test/react-native/git.test.d.ts +1 -0
  206. package/dist/test/react-native/git.test.js +160 -0
  207. package/dist/test/react-native/git.test.js.map +1 -0
  208. package/dist/test/react-router/codemods/client-entry.test.js +38 -5
  209. package/dist/test/react-router/codemods/client-entry.test.js.map +1 -1
  210. package/dist/test/react-router/codemods/server-entry.test.js +83 -0
  211. package/dist/test/react-router/codemods/server-entry.test.js.map +1 -1
  212. package/dist/test/react-router/codemods/vite.test.js +89 -0
  213. package/dist/test/react-router/codemods/vite.test.js.map +1 -1
  214. package/dist/test/react-router/sdk-setup.test.js +98 -6
  215. package/dist/test/react-router/sdk-setup.test.js.map +1 -1
  216. package/dist/test/react-router/templates.test.js +50 -38
  217. package/dist/test/react-router/templates.test.js.map +1 -1
  218. package/dist/test/remix/build-script.test.d.ts +1 -0
  219. package/dist/test/remix/build-script.test.js +124 -0
  220. package/dist/test/remix/build-script.test.js.map +1 -0
  221. package/dist/test/remix/client-entry.test.js +4 -10
  222. package/dist/test/remix/client-entry.test.js.map +1 -1
  223. package/dist/test/run.test.d.ts +1 -0
  224. package/dist/test/run.test.js +137 -0
  225. package/dist/test/run.test.js.map +1 -0
  226. package/dist/test/sourcemaps/tools/vite.test.js +12 -8
  227. package/dist/test/sourcemaps/tools/vite.test.js.map +1 -1
  228. package/dist/test/sveltekit/templates.test.js +78 -27
  229. package/dist/test/sveltekit/templates.test.js.map +1 -1
  230. package/dist/test/utils/ast-utils.test.js +22 -0
  231. package/dist/test/utils/ast-utils.test.js.map +1 -1
  232. package/dist/test/utils/clack/index.test.js +101 -0
  233. package/dist/test/utils/clack/index.test.js.map +1 -1
  234. package/dist/test/utils/git.test.js +10 -0
  235. package/dist/test/utils/git.test.js.map +1 -1
  236. package/dist/test/utils/line-endings.test.d.ts +1 -0
  237. package/dist/test/utils/line-endings.test.js +103 -0
  238. package/dist/test/utils/line-endings.test.js.map +1 -0
  239. package/package.json +2 -2
  240. package/dist/src/react-router/codemods/root.d.ts +0 -1
  241. package/dist/src/react-router/codemods/root.js +0 -171
  242. package/dist/src/react-router/codemods/root.js.map +0 -1
  243. package/dist/test/react-router/codemods/root.test.js +0 -178
  244. package/dist/test/react-router/codemods/root.test.js.map +0 -1
  245. /package/dist/{test/react-router/codemods/root.test.d.ts → e2e-tests/tests/react-router-instrumentation-api.test.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"apple-wizard.js","sourceRoot":"","sources":["../../../src/apple/apple-wizard.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,4CAA6C;AAC7C,0CAKwB;AACxB,0DAAwE;AACxE,+DAA0D;AAC1D,6DAAyD;AACzD,2EAAsE;AACtE,iEAA4D;AAC5D,uEAAkE;AAClE,+DAA0D;AAC1D,iEAA4D;AAE5D,kGAA0F;AAEnF,KAAK,UAAU,cAAc,CAClC,OAA2B;IAE3B,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,KAAK;QAClB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAC5C,CAAC;AACJ,CAAC;AAXD,wCAWC;AAED,KAAK,UAAU,4BAA4B,CACzC,OAA2B;IAE3B,+BAA+B;IAC/B,MAAM,UAAU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AM,CACP,2CAA2C;YAC5C,WAAW,EAAE,UAAU;SACxB;KACF,CAAC,CAAC;IAEH,0BAA0B;IAC1B,IAAA,uCAAiB,EAAC;QAChB,OAAO,EAAE,SAAS;QAClB,MAAM;QACN,GAAG,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM;QACvC,UAAU,EAAE,gBAAgB,CAAC,IAAI,IAAI,KAAK;KAC3C,CAAC,CAAC;IAEH,gCAAgC;IAChC,MAAM,IAAA,sCAAiB,EAAC;QACtB,UAAU;QACV,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;QAC1C,WAAW,EAAE,eAAe,CAAC,IAAI;KAClC,CAAC,CAAC;IAEH,iFAAiF;IACjF,MAAM,IAAA,wCAA2B,EAC/B,eAAe,CAAC,YAAY,CAAC,IAAI,EACjC,eAAe,CAAC,IAAI,CACrB,CAAC;IAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,gKAAgK,CACjK,CAAC;AACJ,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport { withTelemetry } from '../telemetry';\nimport {\n confirmContinueIfNoOrDirtyGitRepo,\n featureSelectionPrompt,\n getOrAskForProjectData,\n printWelcome,\n} from '../utils/clack';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport { checkInstalledCLI } from './check-installed-cli';\nimport { configureFastlane } from './configure-fastlane';\nimport { configurePackageManager } from './configure-package-manager';\nimport { configureSentryCLI } from './configure-sentry-cli';\nimport { configureXcodeProject } from './configure-xcode-project';\nimport { injectCodeSnippet } from './inject-code-snippet';\nimport { lookupXcodeProject } from './lookup-xcode-project';\nimport { AppleWizardOptions } from './options';\nimport { abortIfSpotlightNotSupported } from '../utils/abort-if-sportlight-not-supported';\n\nexport async function runAppleWizard(\n options: AppleWizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'ios',\n wizardOptions: options,\n },\n () => runAppleWizardWithTelementry(options),\n );\n}\n\nasync function runAppleWizardWithTelementry(\n options: AppleWizardOptions,\n): Promise<void> {\n // Define options with defaults\n const projectDir = options.projectDir ?? process.cwd();\n\n // Step - Welcome Message\n printWelcome({\n wizardName: 'Sentry Apple Wizard',\n promoCode: options.promoCode,\n });\n\n // Step - Git Status Check\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: projectDir,\n });\n\n // Step - Sentry CLI Check\n await checkInstalledCLI();\n\n // Step - Xcode Project Lookup\n // This step should be run before the Sentry Project and API Key step\n // because it can abort the wizard if no Xcode project is found.\n const { xcProject, target } = await lookupXcodeProject({\n projectDir,\n });\n\n // Step - Sentry Project and API Key\n const projectData = await getOrAskForProjectData(options, 'apple-ios');\n\n if (projectData.spotlight) {\n return abortIfSpotlightNotSupported('Apple/iOS');\n }\n\n const { selectedProject, authToken } = projectData;\n\n // Step - Sentry CLI Configuration Setup\n configureSentryCLI({\n projectDir,\n authToken: authToken,\n });\n\n // Step - Set up Package Manager\n const { shouldUseSPM } = await configurePackageManager({\n projectDir,\n });\n\n // Step - Configure Xcode Project\n configureXcodeProject({\n xcProject,\n project: selectedProject,\n target,\n shouldUseSPM,\n });\n\n // Step - Feature Selection\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'logs',\n prompt: `Do you want to enable ${chalk.bold(\n 'Logs',\n )} to send your application logs to Sentry?`,\n enabledHint: 'optional',\n },\n ]);\n\n // Step - Add Code Snippet\n injectCodeSnippet({\n project: xcProject,\n target,\n dsn: selectedProject.keys[0].dsn.public,\n enableLogs: selectedFeatures.logs ?? false,\n });\n\n // Step - Fastlane Configuration\n await configureFastlane({\n projectDir,\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n });\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n clack.log.success(\n 'Sentry was successfully added to your project! Run your project to send your first event to Sentry. Go to Sentry.io to see whether everything is working fine.',\n );\n}\n"]}
1
+ {"version":3,"file":"apple-wizard.js","sourceRoot":"","sources":["../../../src/apple/apple-wizard.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,4CAA6C;AAC7C,0CAKwB;AACxB,0DAAwE;AACxE,+DAA0D;AAC1D,6DAAyD;AACzD,2EAAsE;AACtE,iEAA4D;AAC5D,uEAAkE;AAClE,+DAA0D;AAC1D,iEAA+E;AAE/E,kGAA0F;AAEnF,KAAK,UAAU,cAAc,CAClC,OAA2B;IAE3B,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,KAAK;QAClB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAC5C,CAAC;AACJ,CAAC;AAXD,wCAWC;AAED,KAAK,UAAU,4BAA4B,CACzC,OAA2B;IAE3B,+BAA+B;IAC/B,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAEvD,yBAAyB;IACzB,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,qBAAqB;QACjC,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAC;IAEH,0BAA0B;IAC1B,MAAM,IAAA,yCAAiC,EAAC;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,GAAG,EAAE,UAAU;KAChB,CAAC,CAAC;IAEH,0BAA0B;IAC1B,MAAM,IAAA,uCAAiB,GAAE,CAAC;IAE1B,8BAA8B;IAC9B,qEAAqE;IACrE,gEAAgE;IAChE,MAAM,SAAS,GAAG,MAAM,IAAA,yCAAkB,EAAC,EAAE,UAAU,EAAE,CAAC,CAAC;IAC3D,MAAM,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iF;IACjF,MAAM,IAAA,wCAA2B,EAC/B,eAAe,CAAC,YAAY,CAAC,IAAI,EACjC,eAAe,CAAC,IAAI,CACrB,CAAC;IAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,gKAAgK,CACjK,CAAC;AACJ,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport { withTelemetry } from '../telemetry';\nimport {\n confirmContinueIfNoOrDirtyGitRepo,\n featureSelectionPrompt,\n getOrAskForProjectData,\n printWelcome,\n} from '../utils/clack';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport { checkInstalledCLI } from './check-installed-cli';\nimport { configureFastlane } from './configure-fastlane';\nimport { configurePackageManager } from './configure-package-manager';\nimport { configureSentryCLI } from './configure-sentry-cli';\nimport { configureXcodeProject } from './configure-xcode-project';\nimport { injectCodeSnippet } from './inject-code-snippet';\nimport { lookupXcodeProject, selectXcodeTarget } from './lookup-xcode-project';\nimport { AppleWizardOptions } from './options';\nimport { abortIfSpotlightNotSupported } from '../utils/abort-if-sportlight-not-supported';\n\nexport async function runAppleWizard(\n options: AppleWizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'ios',\n wizardOptions: options,\n },\n () => runAppleWizardWithTelementry(options),\n );\n}\n\nasync function runAppleWizardWithTelementry(\n options: AppleWizardOptions,\n): Promise<void> {\n // Define options with defaults\n const projectDir = options.projectDir ?? process.cwd();\n\n // Step - Welcome Message\n printWelcome({\n wizardName: 'Sentry Apple Wizard',\n promoCode: options.promoCode,\n });\n\n // Step - Git Status Check\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: projectDir,\n });\n\n // Step - Sentry CLI Check\n await checkInstalledCLI();\n\n // Step - Xcode Project Lookup\n // This step should be run before the Sentry Project and API Key step\n // because it can abort the wizard if no Xcode project is found.\n const xcProject = await lookupXcodeProject({ projectDir });\n const target = await selectXcodeTarget(xcProject);\n\n // Step - Sentry Project and API Key\n const projectData = await getOrAskForProjectData(options, 'apple-ios');\n\n if (projectData.spotlight) {\n return abortIfSpotlightNotSupported('Apple/iOS');\n }\n\n const { selectedProject, authToken } = projectData;\n\n // Step - Sentry CLI Configuration Setup\n configureSentryCLI({\n projectDir,\n authToken: authToken,\n });\n\n // Step - Set up Package Manager\n const { shouldUseSPM } = await configurePackageManager({\n projectDir,\n });\n\n // Step - Configure Xcode Project\n configureXcodeProject({\n xcProject,\n project: selectedProject,\n target,\n shouldUseSPM,\n });\n\n // Step - Feature Selection\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'logs',\n prompt: `Do you want to enable ${chalk.bold(\n 'Logs',\n )} to send your application logs to Sentry?`,\n enabledHint: 'optional',\n },\n ]);\n\n // Step - Add Code Snippet\n injectCodeSnippet({\n project: xcProject,\n target,\n dsn: selectedProject.keys[0].dsn.public,\n enableLogs: selectedFeatures.logs ?? false,\n });\n\n // Step - Fastlane Configuration\n await configureFastlane({\n projectDir,\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n });\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n clack.log.success(\n 'Sentry was successfully added to your project! Run your project to send your first event to Sentry. Go to Sentry.io to see whether everything is working fine.',\n );\n}\n"]}
@@ -1 +1 @@
1
- export declare function checkInstalledCLI(): Promise<void>;
1
+ export declare function checkInstalledCLI(declineWarning?: string, nonInteractive?: boolean): Promise<boolean>;
@@ -34,14 +34,20 @@ const telemetry_1 = require("../telemetry");
34
34
  const bash = __importStar(require("../utils/bash"));
35
35
  const clack_1 = require("../utils/clack");
36
36
  const debug_1 = require("../utils/debug");
37
- async function checkInstalledCLI() {
37
+ async function checkInstalledCLI(declineWarning = "Without sentry-cli, you won't be able to upload debug symbols to Sentry. You can install it later by following the instructions at https://docs.sentry.io/cli/", nonInteractive = false) {
38
38
  (0, debug_1.debug)(`Checking if sentry-cli is installed`);
39
39
  const hasCli = bash.hasSentryCLI();
40
40
  Sentry.setTag('has-cli', hasCli);
41
41
  if (hasCli) {
42
42
  // If the CLI is installed, we don't need to ask the user to install it and can exit early.
43
43
  (0, debug_1.debug)(`sentry-cli is installed`);
44
- return;
44
+ return true;
45
+ }
46
+ if (nonInteractive) {
47
+ (0, debug_1.debug)(`sentry-cli is not installed; skipping install prompt`);
48
+ prompts_1.default.log.warn(declineWarning);
49
+ Sentry.setTag('CLI-Installed', false);
50
+ return false;
45
51
  }
46
52
  (0, debug_1.debug)(`sentry-cli is not installed, asking user to install it`);
47
53
  const shouldInstallCLI = await (0, telemetry_1.traceStep)('Ask for SentryCLI', () => (0, clack_1.askToInstallSentryCLI)());
@@ -49,12 +55,12 @@ async function checkInstalledCLI() {
49
55
  (0, debug_1.debug)(`User agreed to install sentry-cli`);
50
56
  await bash.installSentryCLI();
51
57
  Sentry.setTag('CLI-Installed', true);
58
+ return true;
52
59
  }
53
- else {
54
- (0, debug_1.debug)(`User declined to install sentry-cli`);
55
- prompts_1.default.log.warn("Without sentry-cli, you won't be able to upload debug symbols to Sentry. You can install it later by following the instructions at https://docs.sentry.io/cli/");
56
- Sentry.setTag('CLI-Installed', false);
57
- }
60
+ (0, debug_1.debug)(`User declined to install sentry-cli`);
61
+ prompts_1.default.log.warn(declineWarning);
62
+ Sentry.setTag('CLI-Installed', false);
63
+ return false;
58
64
  }
59
65
  exports.checkInstalledCLI = checkInstalledCLI;
60
66
  //# sourceMappingURL=check-installed-cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"check-installed-cli.js","sourceRoot":"","sources":["../../../src/apple/check-installed-cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,4CAAyC;AACzC,oDAAsC;AACtC,0CAAuD;AACvD,0CAAuC;AAEhC,KAAK,UAAU,iBAAiB;IACrC,IAAA,aAAK,EAAC,qCAAqC,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IACnC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,MAAM,EAAE;QACV,2FAA2F;QAC3F,IAAA,aAAK,EAAC,yBAAyB,CAAC,CAAC;QACjC,OAAO;KACR;IAED,IAAA,aAAK,EAAC,wDAAwD,CAAC,CAAC;IAChE,MAAM,gBAAgB,GAAG,MAAM,IAAA,qBAAS,EAAC,mBAAmB,EAAE,GAAG,EAAE,CACjE,IAAA,6BAAqB,GAAE,CACxB,CAAC;IACF,IAAI,gBAAgB,EAAE;QACpB,IAAA,aAAK,EAAC,mCAAmC,CAAC,CAAC;QAC3C,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;KACtC;SAAM;QACL,IAAA,aAAK,EAAC,qCAAqC,CAAC,CAAC;QAC7C,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,gKAAgK,CACjK,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;KACvC;AACH,CAAC;AAzBD,8CAyBC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport { traceStep } from '../telemetry';\nimport * as bash from '../utils/bash';\nimport { askToInstallSentryCLI } from '../utils/clack';\nimport { debug } from '../utils/debug';\n\nexport async function checkInstalledCLI() {\n debug(`Checking if sentry-cli is installed`);\n const hasCli = bash.hasSentryCLI();\n Sentry.setTag('has-cli', hasCli);\n if (hasCli) {\n // If the CLI is installed, we don't need to ask the user to install it and can exit early.\n debug(`sentry-cli is installed`);\n return;\n }\n\n debug(`sentry-cli is not installed, asking user to install it`);\n const shouldInstallCLI = await traceStep('Ask for SentryCLI', () =>\n askToInstallSentryCLI(),\n );\n if (shouldInstallCLI) {\n debug(`User agreed to install sentry-cli`);\n await bash.installSentryCLI();\n Sentry.setTag('CLI-Installed', true);\n } else {\n debug(`User declined to install sentry-cli`);\n clack.log.warn(\n \"Without sentry-cli, you won't be able to upload debug symbols to Sentry. You can install it later by following the instructions at https://docs.sentry.io/cli/\",\n );\n Sentry.setTag('CLI-Installed', false);\n }\n}\n"]}
1
+ {"version":3,"file":"check-installed-cli.js","sourceRoot":"","sources":["../../../src/apple/check-installed-cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,4CAAyC;AACzC,oDAAsC;AACtC,0CAAuD;AACvD,0CAAuC;AAEhC,KAAK,UAAU,iBAAiB,CACrC,cAAc,GAAG,gKAAgK,EACjL,cAAc,GAAG,KAAK;IAEtB,IAAA,aAAK,EAAC,qCAAqC,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IACnC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,MAAM,EAAE;QACV,2FAA2F;QAC3F,IAAA,aAAK,EAAC,yBAAyB,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,cAAc,EAAE;QAClB,IAAA,aAAK,EAAC,sDAAsD,CAAC,CAAC;QAC9D,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;QACtC,OAAO,KAAK,CAAC;KACd;IAED,IAAA,aAAK,EAAC,wDAAwD,CAAC,CAAC;IAChE,MAAM,gBAAgB,GAAG,MAAM,IAAA,qBAAS,EAAC,mBAAmB,EAAE,GAAG,EAAE,CACjE,IAAA,6BAAqB,GAAE,CACxB,CAAC;IACF,IAAI,gBAAgB,EAAE;QACpB,IAAA,aAAK,EAAC,mCAAmC,CAAC,CAAC;QAC3C,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;KACb;IAED,IAAA,aAAK,EAAC,qCAAqC,CAAC,CAAC;IAC7C,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC/B,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC;AACf,CAAC;AAnCD,8CAmCC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport { traceStep } from '../telemetry';\nimport * as bash from '../utils/bash';\nimport { askToInstallSentryCLI } from '../utils/clack';\nimport { debug } from '../utils/debug';\n\nexport async function checkInstalledCLI(\n declineWarning = \"Without sentry-cli, you won't be able to upload debug symbols to Sentry. You can install it later by following the instructions at https://docs.sentry.io/cli/\",\n nonInteractive = false,\n): Promise<boolean> {\n debug(`Checking if sentry-cli is installed`);\n const hasCli = bash.hasSentryCLI();\n Sentry.setTag('has-cli', hasCli);\n if (hasCli) {\n // If the CLI is installed, we don't need to ask the user to install it and can exit early.\n debug(`sentry-cli is installed`);\n return true;\n }\n\n if (nonInteractive) {\n debug(`sentry-cli is not installed; skipping install prompt`);\n clack.log.warn(declineWarning);\n Sentry.setTag('CLI-Installed', false);\n return false;\n }\n\n debug(`sentry-cli is not installed, asking user to install it`);\n const shouldInstallCLI = await traceStep('Ask for SentryCLI', () =>\n askToInstallSentryCLI(),\n );\n if (shouldInstallCLI) {\n debug(`User agreed to install sentry-cli`);\n await bash.installSentryCLI();\n Sentry.setTag('CLI-Installed', true);\n return true;\n }\n\n debug(`User declined to install sentry-cli`);\n clack.log.warn(declineWarning);\n Sentry.setTag('CLI-Installed', false);\n return false;\n}\n"]}
@@ -34,6 +34,7 @@ const debug_1 = require("../utils/debug");
34
34
  const swiftAppLaunchRegex = /(func\s+application\s*\(\s*_\s+application:\s*[^,]+,\s*didFinishLaunchingWithOptions[^,]+:\s*[^)]+\s*\)\s+->\s+Bool\s+{)|func\s+applicationDidFinishLaunching\s*\(\s*_\s+aNotification:\s+Notification\s*\)\s*{/im;
35
35
  const objcAppLaunchRegex = /-\s*\(\s*BOOL\s*\)\s*application:\s*\(\s*UIApplication\s*\*\s*\)\s*application\s+didFinishLaunchingWithOptions:\s*\(\s*NSDictionary\s*\*\s*\)\s*launchOptions\s*{/im;
36
36
  const swiftUIRegex = /@main\s+struct[^:]+:\s*(SwiftUI\.)?App\s*{/im;
37
+ const swiftUIInitRegex = /\binit\s*\(\s*\)\s*\{/m;
37
38
  function isAppDelegateFile(filePath) {
38
39
  (0, debug_1.debug)('Checking if ' + filePath + ' is an AppDelegate file');
39
40
  const appLaunchRegex = filePath.toLowerCase().endsWith('.swift')
@@ -107,9 +108,22 @@ function addCodeSnippetToProject(files, dsn, enableLogs) {
107
108
  // This branch is not reached, because we already checked for SwiftUI in isAppDelegateFile
108
109
  return false;
109
110
  }
110
- //Is SwiftUI with no init
111
- match = swiftUIMatch;
112
- codeSnippet = ` init() {\n${codeSnippet} }`;
111
+ const afterStructContent = fileContent.slice(swiftUIMatch.index);
112
+ const bodyMatch = /var\s+body\s*:/m.exec(afterStructContent);
113
+ const searchRange = bodyMatch
114
+ ? afterStructContent.slice(0, bodyMatch.index)
115
+ : afterStructContent;
116
+ const initMatch = swiftUIInitRegex.exec(searchRange);
117
+ if (initMatch) {
118
+ match = {
119
+ index: swiftUIMatch.index + initMatch.index,
120
+ 0: initMatch[0],
121
+ };
122
+ }
123
+ else {
124
+ match = swiftUIMatch;
125
+ codeSnippet = ` init() {\n${codeSnippet} }`;
126
+ }
113
127
  }
114
128
  const insertIndex = match.index + match[0].length;
115
129
  let newFileContent = fileContent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ry/node';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as templates from './templates';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport { debug } from '../utils/debug';\n\nconst swiftAppLaunchRegex =\n /(func\\s+application\\s*\\(\\s*_\\s+application:\\s*[^,]+,\\s*didFinishLaunchingWithOptions[^,]+:\\s*[^)]+\\s*\\)\\s+->\\s+Bool\\s+{)|func\\s+applicationDidFinishLaunching\\s*\\(\\s*_\\s+aNotification:\\s+Notification\\s*\\)\\s*{/im;\nconst objcAppLaunchRegex =\n /-\\s*\\(\\s*BOOL\\s*\\)\\s*application:\\s*\\(\\s*UIApplication\\s*\\*\\s*\\)\\s*application\\s+didFinishLaunchingWithOptions:\\s*\\(\\s*NSDictionary\\s*\\*\\s*\\)\\s*launchOptions\\s*{/im;\nconst swiftUIRegex = /@main\\s+struct[^:]+:\\s*(SwiftUI\\.)?App\\s*{/im;\n\nfunction isAppDelegateFile(filePath: string): boolean {\n debug('Checking if ' + filePath + ' is an AppDelegate file');\n const appLaunchRegex = filePath.toLowerCase().endsWith('.swift')\n ? swiftAppLaunchRegex\n : objcAppLaunchRegex;\n\n const fileContent = fs.readFileSync(filePath, 'utf8');\n return appLaunchRegex.test(fileContent) || swiftUIRegex.test(fileContent);\n}\n\nfunction findAppDidFinishLaunchingWithOptionsInDirectory(\n dir: string,\n): string | null {\n debug('Searching for AppDelegate in directory: ' + dir);\n const files = fs.readdirSync(dir);\n const filePaths = files.map((f) => path.join(dir, f));\n return findAppDidFinishLaunchingWithOptions(filePaths);\n}\n\nfunction findAppDidFinishLaunchingWithOptions(files: string[]): string | null {\n debug(`Searching for AppDelegate in ${files.length} files`);\n\n // Iterate over subdirectories after iterating over files,\n // because the AppDelegate is usually in the top level\n const dirs: string[] = [];\n for (const filePath of files) {\n debug('Checking file: ' + filePath);\n if (\n filePath.endsWith('.swift') ||\n filePath.endsWith('.m') ||\n filePath.endsWith('.mm')\n ) {\n if (fs.existsSync(filePath) && isAppDelegateFile(filePath)) {\n debug('Found AppDelegate in ' + filePath);\n return filePath;\n }\n } else if (\n !path.basename(filePath).startsWith('.') &&\n !filePath.endsWith('.xcodeproj') &&\n !filePath.endsWith('.xcassets') &&\n fs.existsSync(filePath) &&\n fs.lstatSync(filePath).isDirectory()\n ) {\n dirs.push(filePath);\n }\n }\n\n for (const dr of dirs) {\n const result = findAppDidFinishLaunchingWithOptionsInDirectory(dr);\n if (result) {\n debug('Found AppDelegate in ' + dr);\n return result;\n }\n }\n return null;\n}\n\nexport function addCodeSnippetToProject(\n files: string[],\n dsn: string,\n enableLogs: boolean,\n): boolean {\n const appDelegate = findAppDidFinishLaunchingWithOptions(files);\n if (!appDelegate) {\n return false;\n }\n\n const fileContent = fs.readFileSync(appDelegate, 'utf8');\n const isSwift = appDelegate.toLowerCase().endsWith('.swift');\n const appLaunchRegex = isSwift ? swiftAppLaunchRegex : objcAppLaunchRegex;\n const importStatement = isSwift ? 'import Sentry\\n' : '@import Sentry;\\n';\n const checkForSentryInit = isSwift ? 'SentrySDK.start' : '[SentrySDK start';\n let codeSnippet = isSwift\n ? templates.getSwiftSnippet(dsn, enableLogs)\n : templates.getObjcSnippet(dsn, enableLogs);\n\n Sentry.setTag('code-language', isSwift ? 'swift' : 'objc');\n Sentry.setTag(\n 'ui-engine',\n swiftUIRegex.test(fileContent) ? 'swiftui' : 'uikit',\n );\n\n if (fileContent.includes(checkForSentryInit)) {\n //already initialized\n clack.log.info(\n 'Sentry is already initialized in your AppDelegate. Skipping adding the code snippet.',\n );\n return true;\n }\n\n let match = appLaunchRegex.exec(fileContent);\n if (!match) {\n const swiftUIMatch = swiftUIRegex.exec(fileContent);\n if (!swiftUIMatch) {\n // This branch is not reached, because we already checked for SwiftUI in isAppDelegateFile\n return false;\n }\n //Is SwiftUI with no init\n match = swiftUIMatch;\n codeSnippet = ` init() {\\n${codeSnippet} }`;\n }\n\n const insertIndex = match.index + match[0].length;\n let newFileContent =\n fileContent.slice(0, insertIndex) +\n '\\n' +\n codeSnippet +\n fileContent.slice(insertIndex);\n\n if (newFileContent.indexOf(importStatement) < 0) {\n const firstImport = /^[ \\t]*import +\\w+.*$/m.exec(newFileContent);\n if (firstImport) {\n const importIndex = firstImport.index + firstImport[0].length;\n newFileContent =\n newFileContent.slice(0, importIndex) +\n '\\n' +\n importStatement +\n newFileContent.slice(importIndex);\n } else {\n newFileContent = importStatement + newFileContent;\n }\n }\n\n fs.writeFileSync(appDelegate, newFileContent, 'utf8');\n\n clack.log.step('Added Sentry initialization code snippet to ' + appDelegate);\n return true;\n}\n\n/**\n * Exported for testing purposes, but should not be used in other modules.\n */\nexport let exportForTesting: {\n isAppDelegateFile: typeof isAppDelegateFile;\n findAppDidFinishLaunchingWithOptionsInDirectory: typeof findAppDidFinishLaunchingWithOptionsInDirectory;\n findAppDidFinishLaunchingWithOptions: typeof findAppDidFinishLaunchingWithOptions;\n};\nif (process.env.NODE_ENV === 'test') {\n exportForTesting = {\n isAppDelegateFile,\n findAppDidFinishLaunchingWithOptionsInDirectory,\n findAppDidFinishLaunchingWithOptions,\n };\n}\n"]}
1
+ {"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/apple/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,uCAAyB;AACzB,2CAA6B;AAC7B,uDAAyC;AACzC,+EAA+E;AAC/E,sDAAwC;AACxC,0CAAuC;AAEvC,MAAM,mBAAmB,GACvB,mNAAmN,CAAC;AACtN,MAAM,kBAAkB,GACtB,qKAAqK,CAAC;AACxK,MAAM,YAAY,GAAG,8CAA8C,CAAC;AACpE,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAElD,SAAS,iBAAiB,CAAC,QAAgB;IACzC,IAAA,aAAK,EAAC,cAAc,GAAG,QAAQ,GAAG,yBAAyB,CAAC,CAAC;IAC7D,MAAM,cAAc,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,C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';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as templates from './templates';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport { debug } from '../utils/debug';\n\nconst swiftAppLaunchRegex =\n /(func\\s+application\\s*\\(\\s*_\\s+application:\\s*[^,]+,\\s*didFinishLaunchingWithOptions[^,]+:\\s*[^)]+\\s*\\)\\s+->\\s+Bool\\s+{)|func\\s+applicationDidFinishLaunching\\s*\\(\\s*_\\s+aNotification:\\s+Notification\\s*\\)\\s*{/im;\nconst objcAppLaunchRegex =\n /-\\s*\\(\\s*BOOL\\s*\\)\\s*application:\\s*\\(\\s*UIApplication\\s*\\*\\s*\\)\\s*application\\s+didFinishLaunchingWithOptions:\\s*\\(\\s*NSDictionary\\s*\\*\\s*\\)\\s*launchOptions\\s*{/im;\nconst swiftUIRegex = /@main\\s+struct[^:]+:\\s*(SwiftUI\\.)?App\\s*{/im;\nconst swiftUIInitRegex = /\\binit\\s*\\(\\s*\\)\\s*\\{/m;\n\nfunction isAppDelegateFile(filePath: string): boolean {\n debug('Checking if ' + filePath + ' is an AppDelegate file');\n const appLaunchRegex = filePath.toLowerCase().endsWith('.swift')\n ? swiftAppLaunchRegex\n : objcAppLaunchRegex;\n\n const fileContent = fs.readFileSync(filePath, 'utf8');\n return appLaunchRegex.test(fileContent) || swiftUIRegex.test(fileContent);\n}\n\nfunction findAppDidFinishLaunchingWithOptionsInDirectory(\n dir: string,\n): string | null {\n debug('Searching for AppDelegate in directory: ' + dir);\n const files = fs.readdirSync(dir);\n const filePaths = files.map((f) => path.join(dir, f));\n return findAppDidFinishLaunchingWithOptions(filePaths);\n}\n\nfunction findAppDidFinishLaunchingWithOptions(files: string[]): string | null {\n debug(`Searching for AppDelegate in ${files.length} files`);\n\n // Iterate over subdirectories after iterating over files,\n // because the AppDelegate is usually in the top level\n const dirs: string[] = [];\n for (const filePath of files) {\n debug('Checking file: ' + filePath);\n if (\n filePath.endsWith('.swift') ||\n filePath.endsWith('.m') ||\n filePath.endsWith('.mm')\n ) {\n if (fs.existsSync(filePath) && isAppDelegateFile(filePath)) {\n debug('Found AppDelegate in ' + filePath);\n return filePath;\n }\n } else if (\n !path.basename(filePath).startsWith('.') &&\n !filePath.endsWith('.xcodeproj') &&\n !filePath.endsWith('.xcassets') &&\n fs.existsSync(filePath) &&\n fs.lstatSync(filePath).isDirectory()\n ) {\n dirs.push(filePath);\n }\n }\n\n for (const dr of dirs) {\n const result = findAppDidFinishLaunchingWithOptionsInDirectory(dr);\n if (result) {\n debug('Found AppDelegate in ' + dr);\n return result;\n }\n }\n return null;\n}\n\nexport function addCodeSnippetToProject(\n files: string[],\n dsn: string,\n enableLogs: boolean,\n): boolean {\n const appDelegate = findAppDidFinishLaunchingWithOptions(files);\n if (!appDelegate) {\n return false;\n }\n\n const fileContent = fs.readFileSync(appDelegate, 'utf8');\n const isSwift = appDelegate.toLowerCase().endsWith('.swift');\n const appLaunchRegex = isSwift ? swiftAppLaunchRegex : objcAppLaunchRegex;\n const importStatement = isSwift ? 'import Sentry\\n' : '@import Sentry;\\n';\n const checkForSentryInit = isSwift ? 'SentrySDK.start' : '[SentrySDK start';\n let codeSnippet = isSwift\n ? templates.getSwiftSnippet(dsn, enableLogs)\n : templates.getObjcSnippet(dsn, enableLogs);\n\n Sentry.setTag('code-language', isSwift ? 'swift' : 'objc');\n Sentry.setTag(\n 'ui-engine',\n swiftUIRegex.test(fileContent) ? 'swiftui' : 'uikit',\n );\n\n if (fileContent.includes(checkForSentryInit)) {\n //already initialized\n clack.log.info(\n 'Sentry is already initialized in your AppDelegate. Skipping adding the code snippet.',\n );\n return true;\n }\n\n let match = appLaunchRegex.exec(fileContent);\n if (!match) {\n const swiftUIMatch = swiftUIRegex.exec(fileContent);\n if (!swiftUIMatch) {\n // This branch is not reached, because we already checked for SwiftUI in isAppDelegateFile\n return false;\n }\n\n const afterStructContent = fileContent.slice(swiftUIMatch.index);\n const bodyMatch = /var\\s+body\\s*:/m.exec(afterStructContent);\n const searchRange = bodyMatch\n ? afterStructContent.slice(0, bodyMatch.index)\n : afterStructContent;\n\n const initMatch = swiftUIInitRegex.exec(searchRange);\n\n if (initMatch) {\n match = {\n index: swiftUIMatch.index + initMatch.index,\n 0: initMatch[0],\n } as RegExpExecArray;\n } else {\n match = swiftUIMatch;\n codeSnippet = ` init() {\\n${codeSnippet} }`;\n }\n }\n\n const insertIndex = match.index + match[0].length;\n let newFileContent =\n fileContent.slice(0, insertIndex) +\n '\\n' +\n codeSnippet +\n fileContent.slice(insertIndex);\n\n if (newFileContent.indexOf(importStatement) < 0) {\n const firstImport = /^[ \\t]*import +\\w+.*$/m.exec(newFileContent);\n if (firstImport) {\n const importIndex = firstImport.index + firstImport[0].length;\n newFileContent =\n newFileContent.slice(0, importIndex) +\n '\\n' +\n importStatement +\n newFileContent.slice(importIndex);\n } else {\n newFileContent = importStatement + newFileContent;\n }\n }\n\n fs.writeFileSync(appDelegate, newFileContent, 'utf8');\n\n clack.log.step('Added Sentry initialization code snippet to ' + appDelegate);\n return true;\n}\n\n/**\n * Exported for testing purposes, but should not be used in other modules.\n */\nexport let exportForTesting: {\n isAppDelegateFile: typeof isAppDelegateFile;\n findAppDidFinishLaunchingWithOptionsInDirectory: typeof findAppDidFinishLaunchingWithOptionsInDirectory;\n findAppDidFinishLaunchingWithOptions: typeof findAppDidFinishLaunchingWithOptions;\n};\nif (process.env.NODE_ENV === 'test') {\n exportForTesting = {\n isAppDelegateFile,\n findAppDidFinishLaunchingWithOptionsInDirectory,\n findAppDidFinishLaunchingWithOptions,\n };\n}\n"]}
@@ -44,12 +44,25 @@ async function configurePackageManager({ projectDir, }) {
44
44
  Sentry.setTag('cocoapod-exists', isCocoaPodsAvailable);
45
45
  (0, debug_1.debug)(`CocoaPods is ${isCocoaPodsAvailable ? 'installed' : 'not installed'}`);
46
46
  if (isCocoaPodsAvailable) {
47
- // If the user has CocoaPods installed, we need to ask them which package manager they want to use.
48
- // Otherwise, we can just use the Swift Package Manager.
47
+ prompts_1.default.log.warn('CocoaPods is being deprecated. No new updates will be released after June 2026.\nWe recommend migrating to Swift Package Manager (SPM).');
49
48
  (0, debug_1.debug)('Asking user to choose a package manager');
50
- const pm = (await (0, telemetry_1.traceStep)('Choose a package manager', () => (0, clack_1.askForItemSelection)(['Swift Package Manager', 'CocoaPods'], 'Which package manager would you like to use to add Sentry?'))).value;
49
+ const pm = await (0, telemetry_1.traceStep)('Choose a package manager', () => (0, clack_1.abortIfCancelled)(prompts_1.default.select({
50
+ message: 'Which package manager would you like to use to add Sentry?',
51
+ options: [
52
+ {
53
+ value: 'SPM',
54
+ label: 'Swift Package Manager',
55
+ hint: 'Recommended',
56
+ },
57
+ {
58
+ value: 'CocoaPods',
59
+ label: 'CocoaPods',
60
+ hint: 'Deprecated - no updates after June 2026',
61
+ },
62
+ ],
63
+ })));
51
64
  (0, debug_1.debug)(`User chose package manager: ${chalk_1.default.cyan(pm)}`);
52
- shouldUseSPM = pm === 'Swift Package Manager';
65
+ shouldUseSPM = pm === 'SPM';
53
66
  if (!shouldUseSPM) {
54
67
  (0, debug_1.debug)('Adding CocoaPods reference');
55
68
  const podAdded = await (0, telemetry_1.traceStep)('Add CocoaPods reference', () => cocoapod.addCocoaPods(projectDir));
@@ -61,7 +74,7 @@ async function configurePackageManager({ projectDir, }) {
61
74
  }
62
75
  }
63
76
  (0, debug_1.debug)(`Should use SPM: ${chalk_1.default.cyan(shouldUseSPM.toString())}`);
64
- Sentry.setTag('package-manager', shouldUseSPM ? 'SPM' : 'cocoapods');
77
+ Sentry.setTag('package-manager', shouldUseSPM ? 'SPM' : 'CocoaPods');
65
78
  return { shouldUseSPM };
66
79
  }
67
80
  exports.configurePackageManager = configurePackageManager;
@@ -1 +1 @@
1
- {"version":3,"file":"configure-package-manager.js","sourceRoot":"","sources":["../../../src/apple/configure-package-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACn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IAAA,aAAK,EAAC,8BAA8B,eAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;YAEvE,IAAI,CAAC,QAAQ,EAAE;gBACb,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,yKAAyK,CAC1K,CAAC;aACH;SACF;KACF;IACD,IAAA,aAAK,EAAC,mBAAmB,eAAK,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IAChE,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAErE,OAAO,EAAE,YAAY,EAAE,CAAC;AAC1B,CAAC;AApDD,0DAoDC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\n\nimport { traceStep } from '../telemetry';\nimport { askForItemSelection } from '../utils/clack';\nimport { debug } from '../utils/debug';\nimport * as cocoapod from './cocoapod';\n\nexport async function configurePackageManager({\n projectDir,\n}: {\n projectDir: string;\n}) {\n debug(\n `Checking if CocoaPods is installed at path: ${chalk.cyan(projectDir)}`,\n );\n\n // Xcode ships with the Swift Package Manager and potentially using CocoaPods.\n // We need to check if the user has CocoaPods set up.\n let shouldUseSPM = true;\n\n const isCocoaPodsAvailable = cocoapod.usesCocoaPod(projectDir);\n Sentry.setTag('cocoapod-exists', isCocoaPodsAvailable);\n debug(`CocoaPods is ${isCocoaPodsAvailable ? 'installed' : 'not installed'}`);\n\n if (isCocoaPodsAvailable) {\n // If the user has CocoaPods installed, we need to ask them which package manager they want to use.\n // Otherwise, we can just use the Swift Package Manager.\n debug('Asking user to choose a package manager');\n const pm = (\n await traceStep('Choose a package manager', () =>\n askForItemSelection(\n ['Swift Package Manager', 'CocoaPods'],\n 'Which package manager would you like to use to add Sentry?',\n ),\n )\n ).value;\n debug(`User chose package manager: ${chalk.cyan(pm)}`);\n\n shouldUseSPM = pm === 'Swift Package Manager';\n\n if (!shouldUseSPM) {\n debug('Adding CocoaPods reference');\n const podAdded = await traceStep('Add CocoaPods reference', () =>\n cocoapod.addCocoaPods(projectDir),\n );\n Sentry.setTag('cocoapod-added', podAdded);\n debug(`CocoaPods reference added: ${chalk.cyan(podAdded.toString())}`);\n\n if (!podAdded) {\n clack.log.warn(\n \"Could not add Sentry pod to your Podfile. You'll have to add it manually.\\nPlease follow the instructions at https://docs.sentry.io/platforms/apple/guides/ios/#install\",\n );\n }\n }\n }\n debug(`Should use SPM: ${chalk.cyan(shouldUseSPM.toString())}`);\n Sentry.setTag('package-manager', shouldUseSPM ? 'SPM' : 'cocoapods');\n\n return { shouldUseSPM };\n}\n"]}
1
+ {"version":3,"file":"configure-package-manager.js","sourceRoot":"","sources":["../../../src/apple/configure-package-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,kDAA0B;AAE1B,4CAAyC;AACzC,0CAAkD;AAClD,0CAAuC;AACvC,qDAAuC;AAEhC,KAAK,UAAU,uBAAuB,CAAC,EAC5C,UAAU,GAGX;IACC,IAAA,aAAK,EACH,+CAA+C,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CACxE,CAAC;IAEF,8EAA8E;IAC9E,qDAAqD;IACrD,IAAI,YAAY,GAAG,IAAI,CAAC;IAExB,MAAM,oBAAoB,GAAG,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAC/D,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;IACvD,IAAA,aAAK,EAAC,gBAAgB,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;IAE9E,IAAI,oBAAoB,EAAE;QACxB,iBAAK,CAAC,GAAG,C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,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAErE,OAAO,EAAE,YAAY,EAAE,CAAC;AAC1B,CAAC;AApED,0DAoEC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\n\nimport { traceStep } from '../telemetry';\nimport { abortIfCancelled } from '../utils/clack';\nimport { debug } from '../utils/debug';\nimport * as cocoapod from './cocoapod';\n\nexport async function configurePackageManager({\n projectDir,\n}: {\n projectDir: string;\n}) {\n debug(\n `Checking if CocoaPods is installed at path: ${chalk.cyan(projectDir)}`,\n );\n\n // Xcode ships with the Swift Package Manager and potentially using CocoaPods.\n // We need to check if the user has CocoaPods set up.\n let shouldUseSPM = true;\n\n const isCocoaPodsAvailable = cocoapod.usesCocoaPod(projectDir);\n Sentry.setTag('cocoapod-exists', isCocoaPodsAvailable);\n debug(`CocoaPods is ${isCocoaPodsAvailable ? 'installed' : 'not installed'}`);\n\n if (isCocoaPodsAvailable) {\n clack.log.warn(\n 'CocoaPods is being deprecated. No new updates will be released after June 2026.\\nWe recommend migrating to Swift Package Manager (SPM).',\n );\n\n debug('Asking user to choose a package manager');\n const pm: 'SPM' | 'CocoaPods' = await traceStep(\n 'Choose a package manager',\n () =>\n abortIfCancelled(\n clack.select({\n message:\n 'Which package manager would you like to use to add Sentry?',\n options: [\n {\n value: 'SPM',\n label: 'Swift Package Manager',\n hint: 'Recommended',\n },\n {\n value: 'CocoaPods',\n label: 'CocoaPods',\n hint: 'Deprecated - no updates after June 2026',\n },\n ],\n }),\n ),\n );\n debug(`User chose package manager: ${chalk.cyan(pm)}`);\n\n shouldUseSPM = pm === 'SPM';\n\n if (!shouldUseSPM) {\n debug('Adding CocoaPods reference');\n const podAdded = await traceStep('Add CocoaPods reference', () =>\n cocoapod.addCocoaPods(projectDir),\n );\n Sentry.setTag('cocoapod-added', podAdded);\n debug(`CocoaPods reference added: ${chalk.cyan(podAdded.toString())}`);\n\n if (!podAdded) {\n clack.log.warn(\n \"Could not add Sentry pod to your Podfile. You'll have to add it manually.\\nPlease follow the instructions at https://docs.sentry.io/platforms/apple/guides/ios/#install\",\n );\n }\n }\n }\n debug(`Should use SPM: ${chalk.cyan(shouldUseSPM.toString())}`);\n Sentry.setTag('package-manager', shouldUseSPM ? 'SPM' : 'CocoaPods');\n\n return { shouldUseSPM };\n}\n"]}
@@ -2,9 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configureXcodeProject = void 0;
4
4
  const telemetry_1 = require("../telemetry");
5
+ const sentry_swift_package_1 = require("./sentry-swift-package");
5
6
  function configureXcodeProject({ xcProject, project, target, shouldUseSPM, }) {
6
7
  (0, telemetry_1.traceStep)('Update Xcode project', () => {
7
- xcProject.updateXcodeProject(project, target, shouldUseSPM, true);
8
+ xcProject.updateXcodeProject(project, target, shouldUseSPM
9
+ ? {
10
+ product: sentry_swift_package_1.sentrySwiftPackageProductSpec,
11
+ existingFrameworkComment: sentry_swift_package_1.SENTRY_SPM_ALREADY_LINKED_FRAMEWORK_COMMENT,
12
+ successMessage: 'Added Sentry SPM dependency to your project',
13
+ }
14
+ : undefined, true);
8
15
  });
9
16
  }
10
17
  exports.configureXcodeProject = configureXcodeProject;
@@ -1 +1 @@
1
- {"version":3,"file":"configure-xcode-project.js","sourceRoot":"","sources":["../../../src/apple/configure-xcode-project.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AAIzC,SAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,OAAO,EACP,MAAM,EACN,YAAY,GAMb;IACC,IAAA,qBAAS,EAAC,sBAAsB,EAAE,GAAG,EAAE;QACrC,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC;AAdD,sDAcC","sourcesContent":["import { traceStep } from '../telemetry';\nimport { SentryProjectData } from '../utils/types';\nimport { XcodeProject } from './xcode-manager';\n\nexport function configureXcodeProject({\n xcProject,\n project,\n target,\n shouldUseSPM,\n}: {\n xcProject: XcodeProject;\n project: SentryProjectData;\n target: string;\n shouldUseSPM: boolean;\n}) {\n traceStep('Update Xcode project', () => {\n xcProject.updateXcodeProject(project, target, shouldUseSPM, true);\n });\n}\n"]}
1
+ {"version":3,"file":"configure-xcode-project.js","sourceRoot":"","sources":["../../../src/apple/configure-xcode-project.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AAEzC,iEAGgC;AAGhC,SAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,OAAO,EACP,MAAM,EACN,YAAY,GAMb;IACC,IAAA,qBAAS,EAAC,sBAAsB,EAAE,GAAG,EAAE;QACrC,SAAS,CAAC,kBAAkB,CAC1B,OAAO,EACP,MAAM,EACN,YAAY;YACV,CAAC,CAAC;gBACE,OAAO,EAAE,oDAA6B;gBACtC,wBAAwB,EACtB,kEAA2C;gBAC7C,cAAc,EAAE,6CAA6C;aAC9D;YACH,CAAC,CAAC,SAAS,EACb,IAAI,CACL,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AA1BD,sDA0BC","sourcesContent":["import { traceStep } from '../telemetry';\nimport { SentryProjectData } from '../utils/types';\nimport {\n SENTRY_SPM_ALREADY_LINKED_FRAMEWORK_COMMENT,\n sentrySwiftPackageProductSpec,\n} from './sentry-swift-package';\nimport { XcodeProject } from './xcode-manager';\n\nexport function configureXcodeProject({\n xcProject,\n project,\n target,\n shouldUseSPM,\n}: {\n xcProject: XcodeProject;\n project: SentryProjectData;\n target: string;\n shouldUseSPM: boolean;\n}) {\n traceStep('Update Xcode project', () => {\n xcProject.updateXcodeProject(\n project,\n target,\n shouldUseSPM\n ? {\n product: sentrySwiftPackageProductSpec,\n existingFrameworkComment:\n SENTRY_SPM_ALREADY_LINKED_FRAMEWORK_COMMENT,\n successMessage: 'Added Sentry SPM dependency to your project',\n }\n : undefined,\n true,\n );\n });\n}\n"]}
@@ -1,7 +1,10 @@
1
1
  import { XcodeProject } from './xcode-manager';
2
- export declare function lookupXcodeProject({ projectDir, }: {
2
+ export declare function lookupXcodeProject({ projectDir, nonInteractive, }: {
3
3
  projectDir: string;
4
- }): Promise<{
5
- xcProject: XcodeProject;
6
- target: string;
7
- }>;
4
+ nonInteractive?: boolean;
5
+ }): Promise<XcodeProject>;
6
+ export declare function selectXcodeTarget(xcProject: XcodeProject, { targetNames, noTargetMessage, promptMessage, }?: {
7
+ targetNames?: string[];
8
+ noTargetMessage?: string;
9
+ promptMessage?: string;
10
+ }): Promise<string>;
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.lookupXcodeProject = void 0;
29
+ exports.selectXcodeTarget = exports.lookupXcodeProject = void 0;
30
30
  // @ts-expect-error - clack is ESM and TS complains about that. It works though
31
31
  const prompts_1 = __importDefault(require("@clack/prompts"));
32
32
  const Sentry = __importStar(require("@sentry/node"));
@@ -38,7 +38,7 @@ const clack_1 = require("../utils/clack");
38
38
  const debug_1 = require("../utils/debug");
39
39
  const search_xcode_project_at_path_1 = require("./search-xcode-project-at-path");
40
40
  const xcode_manager_1 = require("./xcode-manager");
41
- async function lookupXcodeProject({ projectDir, }) {
41
+ async function lookupXcodeProject({ projectDir, nonInteractive = false, }) {
42
42
  (0, debug_1.debug)(`Looking for Xcode project in directory: ${chalk_1.default.cyan(projectDir)}`);
43
43
  const xcodeProjFiles = (0, search_xcode_project_at_path_1.searchXcodeProjectAtPath)(projectDir);
44
44
  if (xcodeProjFiles.length === 0) {
@@ -58,9 +58,16 @@ async function lookupXcodeProject({ projectDir, }) {
58
58
  else {
59
59
  (0, debug_1.debug)(`Found multiple Xcode projects, asking user to choose one`);
60
60
  Sentry.setTag('multiple-projects', true);
61
+ if (nonInteractive) {
62
+ prompts_1.default.log.error([
63
+ 'Multiple Xcode projects found in non-interactive mode.',
64
+ `Available projects: ${xcodeProjFiles.join(', ')}.`,
65
+ 'Run from a directory with a single .xcodeproj or pass --xcode-project-dir with a narrower project directory.',
66
+ ].join(' '));
67
+ return await (0, clack_1.abort)();
68
+ }
61
69
  xcodeProjFile = (await (0, telemetry_1.traceStep)('Choose Xcode project', () => (0, clack_1.askForItemSelection)(xcodeProjFiles, 'Which project do you want to add Sentry to?'))).value;
62
70
  }
63
- // Load the pbxproj file
64
71
  const pathToPbxproj = path.join(projectDir, xcodeProjFile, 'project.pbxproj');
65
72
  (0, debug_1.debug)(`Loading Xcode project pbxproj at path: ${chalk_1.default.cyan(pathToPbxproj)}`);
66
73
  if (!fs.existsSync(pathToPbxproj)) {
@@ -68,31 +75,29 @@ async function lookupXcodeProject({ projectDir, }) {
68
75
  Sentry.setTag('pbxproj-not-found', true);
69
76
  return await (0, clack_1.abort)();
70
77
  }
71
- const xcProject = new xcode_manager_1.XcodeProject(pathToPbxproj);
72
- const availableTargets = xcProject.getAllTargets();
73
- if (availableTargets.length == 0) {
74
- prompts_1.default.log.error(`No suitable Xcode target found in ${xcodeProjFile}`);
78
+ return new xcode_manager_1.XcodeProject(pathToPbxproj);
79
+ }
80
+ exports.lookupXcodeProject = lookupXcodeProject;
81
+ async function selectXcodeTarget(xcProject, { targetNames = xcProject.getAllTargets(), noTargetMessage = `No suitable Xcode target found in ${path.basename(xcProject.xcodeprojPath)}`, promptMessage = 'Which target do you want to add Sentry to?', } = {}) {
82
+ if (targetNames.length === 0) {
83
+ prompts_1.default.log.error(noTargetMessage);
75
84
  Sentry.setTag('No-Target', true);
76
85
  return await (0, clack_1.abort)();
77
86
  }
78
- (0, debug_1.debug)(`Found ${chalk_1.default.cyan(availableTargets.length.toString())} targets in Xcode project`);
79
- // Step - Lookup Xcode Target
87
+ (0, debug_1.debug)(`Found ${chalk_1.default.cyan(targetNames.length.toString())} targets in Xcode project`);
80
88
  let target;
81
- if (availableTargets.length == 1) {
89
+ if (targetNames.length === 1) {
82
90
  (0, debug_1.debug)(`Found exactly one target, using it`);
83
91
  Sentry.setTag('multiple-targets', false);
84
- target = availableTargets[0];
92
+ target = targetNames[0];
85
93
  }
86
94
  else {
87
95
  (0, debug_1.debug)(`Found multiple targets, asking user to choose one`);
88
96
  Sentry.setTag('multiple-targets', true);
89
- target = (await (0, telemetry_1.traceStep)('Choose target', () => (0, clack_1.askForItemSelection)(availableTargets, 'Which target do you want to add Sentry to?'))).value;
97
+ target = (await (0, telemetry_1.traceStep)('Choose target', () => (0, clack_1.askForItemSelection)(targetNames, promptMessage))).value;
90
98
  }
91
99
  (0, debug_1.debug)(`Selected target: ${chalk_1.default.cyan(target)}`);
92
- return {
93
- xcProject,
94
- target,
95
- };
100
+ return target;
96
101
  }
97
- exports.lookupXcodeProject = lookupXcodeProject;
102
+ exports.selectXcodeTarget = selectXcodeTarget;
98
103
  //# sourceMappingURL=lookup-xcode-project.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lookup-xcode-project.js","sourceRoot":"","sources":["../../../src/apple/lookup-xcode-project.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,kDAA0B;AAC1B,uCAAyB;AACzB,2CAA6B;AAE7B,4CAAyC;AACzC,0CAA4D;AAC5D,0CAAuC;AACvC,iFAA0E;AAC1E,mDAA+C;AAExC,KAAK,UAAU,kBAAkB,CAAC,EACvC,UAAU,GAGX;IAIC,IAAA,aAAK,EAAC,2CAA2C,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC3E,MAAM,cAAc,GAAG,IAAA,uDAAwB,EAAC,UAAU,CAAC,CAAC;IAC5D,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;QAC/B,iBAAK,CAAC,GAAG,CAAC,KAAK,CACb,gFAAgF,CACjF,CAAC;QACF,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BAAY,CAAC,aAAa,CAAC,CAAC;IAClD,MAAM,gBAAgB,GAAG,SAAS,CAAC,aAAa,EAAE,CAAC;IACnD,IAAI,gBAAgB,CAAC,MAAM,IAAI,CAAC,EAAE;QAChC,iBAAK,CAAC,GAAG,CAAC,KAAK,CAAC,qCAAqC,aAAa,EAAE,CAAC,CAAC;QACtE,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACjC,OAAO,MAAM,IAAA,aAAK,GAAE,CAAC;KACtB;IACD,IAAA,aAAK,EACH,SAAS,eAAK,CAAC,IAAI,CACjB,gBAAgB,CAAC,MAAM,CAAC,QAAQ,EAAE,CACnC,2BAA2B,CAC7B,CAAC;IAEF,6BAA6B;IAC7B,IAAI,MAAc,CAAC;IACnB,IAAI,gBAAgB,CAAC,MAAM,IAAI,CAAC,EAAE;QAChC,IAAA,aAAK,EAAC,oCAAoC,CAAC,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QACzC,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;KAC9B;SAAM;QACL,IAAA,aAAK,EAAC,mDAAmD,CAAC,CAAC;QAC3D,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QACxC,MAAM,GAAG,CACP,MAAM,IAAA,qBAAS,EAAC,eAAe,EAAE,GAAG,EAAE,CACpC,IAAA,2BAAmB,EACjB,gBAAgB,EAChB,4CAA4C,CAC7C,CACF,CACF,CAAC,KAAK,CAAC;KACT;IACD,IAAA,aAAK,EAAC,oBAAoB,eAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAEhD,OAAO;QACL,SAAS;QACT,MAAM;KACP,CAAC;AACJ,CAAC;AAzFD,gDAyFC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { traceStep } from '../telemetry';\nimport { abort, askForItemSelection } from '../utils/clack';\nimport { debug } from '../utils/debug';\nimport { searchXcodeProjectAtPath } from './search-xcode-project-at-path';\nimport { XcodeProject } from './xcode-manager';\n\nexport async function lookupXcodeProject({\n projectDir,\n}: {\n projectDir: string;\n}): Promise<{\n xcProject: XcodeProject;\n target: string;\n}> {\n debug(`Looking for Xcode project in directory: ${chalk.cyan(projectDir)}`);\n const xcodeProjFiles = searchXcodeProjectAtPath(projectDir);\n if (xcodeProjFiles.length === 0) {\n clack.log.error(\n 'No Xcode project found. Please run this command from the root of your project.',\n );\n Sentry.setTag('no-xcode-project', true);\n return await abort();\n }\n debug(\n `Found ${chalk.cyan(\n xcodeProjFiles.length.toString(),\n )} candidates for Xcode project`,\n );\n\n // In case there is only one Xcode project, we can use that one.\n // Otherwise, we need to ask the user which one they want to use.\n let xcodeProjFile: string;\n if (xcodeProjFiles.length === 1) {\n debug(`Found exactly one Xcode project, using it`);\n Sentry.setTag('multiple-projects', false);\n xcodeProjFile = xcodeProjFiles[0];\n } else {\n debug(`Found multiple Xcode projects, asking user to choose one`);\n Sentry.setTag('multiple-projects', true);\n xcodeProjFile = (\n await traceStep('Choose Xcode project', () =>\n askForItemSelection(\n xcodeProjFiles,\n 'Which project do you want to add Sentry to?',\n ),\n )\n ).value;\n }\n\n // Load the pbxproj file\n const pathToPbxproj = path.join(projectDir, xcodeProjFile, 'project.pbxproj');\n debug(`Loading Xcode project pbxproj at path: ${chalk.cyan(pathToPbxproj)}`);\n if (!fs.existsSync(pathToPbxproj)) {\n clack.log.error(`No pbxproj found at ${xcodeProjFile}`);\n Sentry.setTag('pbxproj-not-found', true);\n return await abort();\n }\n\n const xcProject = new XcodeProject(pathToPbxproj);\n const availableTargets = xcProject.getAllTargets();\n if (availableTargets.length == 0) {\n clack.log.error(`No suitable Xcode target found in ${xcodeProjFile}`);\n Sentry.setTag('No-Target', true);\n return await abort();\n }\n debug(\n `Found ${chalk.cyan(\n availableTargets.length.toString(),\n )} targets in Xcode project`,\n );\n\n // Step - Lookup Xcode Target\n let target: string;\n if (availableTargets.length == 1) {\n debug(`Found exactly one target, using it`);\n Sentry.setTag('multiple-targets', false);\n target = availableTargets[0];\n } else {\n debug(`Found multiple targets, asking user to choose one`);\n Sentry.setTag('multiple-targets', true);\n target = (\n await traceStep('Choose target', () =>\n askForItemSelection(\n availableTargets,\n 'Which target do you want to add Sentry to?',\n ),\n )\n ).value;\n }\n debug(`Selected target: ${chalk.cyan(target)}`);\n\n return {\n xcProject,\n target,\n };\n}\n"]}
1
+ {"version":3,"file":"lookup-xcode-project.js","sourceRoot":"","sources":["../../../src/apple/lookup-xcode-project.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,kDAA0B;AAC1B,uCAAyB;AACzB,2CAA6B;AAE7B,4CAAyC;AACzC,0CAA4D;AAC5D,0CAAuC;AACvC,iFAA0E;AAC1E,mDAA+C;AAExC,KAAK,UAAU,kBAAkB,CAAC,EACvC,UAAU,EACV,cAAc,GAAG,KAAK,GAIvB;IACC,IAAA,aAAK,EAAC,2CAA2C,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC3E,MAAM,cAAc,GAAG,IAAA,uDAAwB,EAAC,UAAU,CAAC,CAAC;IAC5D,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;QAC/B,iBAAK,CAAC,GAAG,CAAC,KAAK,CACb,gFAAgF,CACjF,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QACxC,OAAO,MAAM,IAAA,aAAK,GAAE,CAAC;KACtB;IACD,IAAA,aAAK,EACH,SAAS,eAAK,CAAC,IAAI,CACjB,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,CACjC,+BAA+B,CACjC,CAAC;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;AA1CD,8CA0CC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { traceStep } from '../telemetry';\nimport { abort, askForItemSelection } from '../utils/clack';\nimport { debug } from '../utils/debug';\nimport { searchXcodeProjectAtPath } from './search-xcode-project-at-path';\nimport { XcodeProject } from './xcode-manager';\n\nexport async function lookupXcodeProject({\n projectDir,\n nonInteractive = false,\n}: {\n projectDir: string;\n nonInteractive?: boolean;\n}): Promise<XcodeProject> {\n debug(`Looking for Xcode project in directory: ${chalk.cyan(projectDir)}`);\n const xcodeProjFiles = searchXcodeProjectAtPath(projectDir);\n if (xcodeProjFiles.length === 0) {\n clack.log.error(\n 'No Xcode project found. Please run this command from the root of your project.',\n );\n Sentry.setTag('no-xcode-project', true);\n return await abort();\n }\n debug(\n `Found ${chalk.cyan(\n xcodeProjFiles.length.toString(),\n )} candidates for Xcode project`,\n );\n\n // In case there is only one Xcode project, we can use that one.\n // Otherwise, we need to ask the user which one they want to use.\n let xcodeProjFile: string;\n if (xcodeProjFiles.length === 1) {\n debug(`Found exactly one Xcode project, using it`);\n Sentry.setTag('multiple-projects', false);\n xcodeProjFile = xcodeProjFiles[0];\n } else {\n debug(`Found multiple Xcode projects, asking user to choose one`);\n Sentry.setTag('multiple-projects', true);\n\n if (nonInteractive) {\n clack.log.error(\n [\n 'Multiple Xcode projects found in non-interactive mode.',\n `Available projects: ${xcodeProjFiles.join(', ')}.`,\n 'Run from a directory with a single .xcodeproj or pass --xcode-project-dir with a narrower project directory.',\n ].join(' '),\n );\n return await abort();\n }\n\n xcodeProjFile = (\n await traceStep('Choose Xcode project', () =>\n askForItemSelection(\n xcodeProjFiles,\n 'Which project do you want to add Sentry to?',\n ),\n )\n ).value;\n }\n\n const pathToPbxproj = path.join(projectDir, xcodeProjFile, 'project.pbxproj');\n debug(`Loading Xcode project pbxproj at path: ${chalk.cyan(pathToPbxproj)}`);\n if (!fs.existsSync(pathToPbxproj)) {\n clack.log.error(`No pbxproj found at ${xcodeProjFile}`);\n Sentry.setTag('pbxproj-not-found', true);\n return await abort();\n }\n\n return new XcodeProject(pathToPbxproj);\n}\n\nexport async function selectXcodeTarget(\n xcProject: XcodeProject,\n {\n targetNames = xcProject.getAllTargets(),\n noTargetMessage = `No suitable Xcode target found in ${path.basename(\n xcProject.xcodeprojPath,\n )}`,\n promptMessage = 'Which target do you want to add Sentry to?',\n }: {\n targetNames?: string[];\n noTargetMessage?: string;\n promptMessage?: string;\n } = {},\n): Promise<string> {\n if (targetNames.length === 0) {\n clack.log.error(noTargetMessage);\n Sentry.setTag('No-Target', true);\n return await abort();\n }\n debug(\n `Found ${chalk.cyan(\n targetNames.length.toString(),\n )} targets in Xcode project`,\n );\n\n let target: string;\n if (targetNames.length === 1) {\n debug(`Found exactly one target, using it`);\n Sentry.setTag('multiple-targets', false);\n target = targetNames[0];\n } else {\n debug(`Found multiple targets, asking user to choose one`);\n Sentry.setTag('multiple-targets', true);\n target = (\n await traceStep('Choose target', () =>\n askForItemSelection(targetNames, promptMessage),\n )\n ).value;\n }\n debug(`Selected target: ${chalk.cyan(target)}`);\n\n return target;\n}\n"]}
@@ -2,3 +2,8 @@ import { WizardOptions } from '../utils/types';
2
2
  export interface AppleWizardOptions extends WizardOptions {
3
3
  projectDir: string | undefined;
4
4
  }
5
+ export interface AppleSnapshotsWizardOptions extends AppleWizardOptions {
6
+ appTarget?: string;
7
+ hostedTestTarget?: string;
8
+ nonInteractive: boolean;
9
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/apple/options.ts"],"names":[],"mappings":"","sourcesContent":["import { WizardOptions } from '../utils/types';\n\nexport interface AppleWizardOptions extends WizardOptions {\n projectDir: string | undefined;\n}\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/apple/options.ts"],"names":[],"mappings":"","sourcesContent":["import { WizardOptions } from '../utils/types';\n\nexport interface AppleWizardOptions extends WizardOptions {\n projectDir: string | undefined;\n}\n\nexport interface AppleSnapshotsWizardOptions extends AppleWizardOptions {\n appTarget?: string;\n hostedTestTarget?: string;\n nonInteractive: boolean;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { SwiftPackageProductSpec, SwiftPackageSpec } from './xcode-manager';
2
+ export declare const SENTRY_SPM_ALREADY_LINKED_FRAMEWORK_COMMENT = "Sentry in Frameworks";
3
+ export declare const sentrySwiftPackageSpec: SwiftPackageSpec;
4
+ export declare const sentrySwiftPackageProductSpec: SwiftPackageProductSpec;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sentrySwiftPackageProductSpec = exports.sentrySwiftPackageSpec = exports.SENTRY_SPM_ALREADY_LINKED_FRAMEWORK_COMMENT = void 0;
4
+ exports.SENTRY_SPM_ALREADY_LINKED_FRAMEWORK_COMMENT = 'Sentry in Frameworks';
5
+ exports.sentrySwiftPackageSpec = {
6
+ repositoryURL: 'https://github.com/getsentry/sentry-cocoa/',
7
+ requirement: {
8
+ kind: 'upToNextMajorVersion',
9
+ minimumVersion: '9.0.0',
10
+ },
11
+ commentName: 'sentry-cocoa',
12
+ };
13
+ exports.sentrySwiftPackageProductSpec = {
14
+ package: exports.sentrySwiftPackageSpec,
15
+ productName: 'Sentry',
16
+ };
17
+ //# sourceMappingURL=sentry-swift-package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentry-swift-package.js","sourceRoot":"","sources":["../../../src/apple/sentry-swift-package.ts"],"names":[],"mappings":";;;AAKa,QAAA,2CAA2C,GACtD,sBAAsB,CAAC;AAEZ,QAAA,sBAAsB,GAAqB;IACtD,aAAa,EAAE,4CAA4C;IAC3D,WAAW,EAAE;QACX,IAAI,EAAE,sBAAsB;QAC5B,cAAc,EAAE,OAAO;KACxB;IACD,WAAW,EAAE,cAAc;CAC5B,CAAC;AAEW,QAAA,6BAA6B,GAA4B;IACpE,OAAO,EAAE,8BAAsB;IAC/B,WAAW,EAAE,QAAQ;CACtB,CAAC","sourcesContent":["import type {\n SwiftPackageProductSpec,\n SwiftPackageSpec,\n} from './xcode-manager';\n\nexport const SENTRY_SPM_ALREADY_LINKED_FRAMEWORK_COMMENT =\n 'Sentry in Frameworks';\n\nexport const sentrySwiftPackageSpec: SwiftPackageSpec = {\n repositoryURL: 'https://github.com/getsentry/sentry-cocoa/',\n requirement: {\n kind: 'upToNextMajorVersion',\n minimumVersion: '9.0.0',\n },\n commentName: 'sentry-cocoa',\n};\n\nexport const sentrySwiftPackageProductSpec: SwiftPackageProductSpec = {\n package: sentrySwiftPackageSpec,\n productName: 'Sentry',\n};\n"]}
@@ -0,0 +1,2 @@
1
+ import type { AppleSnapshotsWizardOptions } from '../options';
2
+ export declare function runAppleSnapshotsWizard(options: AppleSnapshotsWizardOptions): Promise<void>;