@sentry/wizard 4.5.0 → 4.7.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 (293) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/README.md +23 -19
  3. package/dist/bin.js +22 -0
  4. package/dist/bin.js.map +1 -1
  5. package/dist/e2e-tests/tests/flutter.test.js +16 -16
  6. package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
  7. package/dist/e2e-tests/tests/help-message.test.js +56 -0
  8. package/dist/e2e-tests/tests/help-message.test.js.map +1 -0
  9. package/dist/e2e-tests/tests/nextjs-14.test.js +17 -16
  10. package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
  11. package/dist/e2e-tests/tests/nextjs-15.test.js +16 -16
  12. package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
  13. package/dist/e2e-tests/tests/nuxt-3.test.js +13 -12
  14. package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
  15. package/dist/e2e-tests/tests/nuxt-4.test.js +13 -12
  16. package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
  17. package/dist/e2e-tests/tests/remix.test.js +20 -20
  18. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  19. package/dist/e2e-tests/tests/sveltekit.test.js +20 -20
  20. package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
  21. package/dist/e2e-tests/utils/index.d.ts +1 -1
  22. package/dist/e2e-tests/utils/index.js +35 -13
  23. package/dist/e2e-tests/utils/index.js.map +1 -1
  24. package/dist/lib/Constants.d.ts +7 -1
  25. package/dist/lib/Constants.js.map +1 -1
  26. package/dist/lib/Helper/File.d.ts +1 -1
  27. package/dist/lib/Helper/File.js +1 -3
  28. package/dist/lib/Helper/File.js.map +1 -1
  29. package/dist/lib/Helper/Logging.d.ts +4 -1
  30. package/dist/lib/Helper/Logging.js +3 -0
  31. package/dist/lib/Helper/Logging.js.map +1 -1
  32. package/dist/lib/Helper/Package.d.ts +5 -3
  33. package/dist/lib/Helper/Package.js +2 -2
  34. package/dist/lib/Helper/Package.js.map +1 -1
  35. package/dist/lib/Helper/SentryCli.d.ts +20 -7
  36. package/dist/lib/Helper/SentryCli.js +21 -13
  37. package/dist/lib/Helper/SentryCli.js.map +1 -1
  38. package/dist/lib/Helper/Wizard.js +9 -5
  39. package/dist/lib/Helper/Wizard.js.map +1 -1
  40. package/dist/lib/Helper/__tests__/File.js +9 -9
  41. package/dist/lib/Helper/__tests__/File.js.map +1 -1
  42. package/dist/lib/Helper/__tests__/MergeConfig.js +17 -17
  43. package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
  44. package/dist/lib/Helper/__tests__/SentryCli.js +39 -21
  45. package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
  46. package/dist/lib/Setup.d.ts +4 -1
  47. package/dist/lib/Setup.js +12 -2
  48. package/dist/lib/Setup.js.map +1 -1
  49. package/dist/lib/Steps/BaseStep.d.ts +1 -1
  50. package/dist/lib/Steps/BaseStep.js.map +1 -1
  51. package/dist/lib/Steps/Integrations/BaseIntegration.js +1 -2
  52. package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
  53. package/dist/lib/Steps/Integrations/Cordova.js +14 -10
  54. package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
  55. package/dist/lib/Steps/Integrations/Electron.d.ts +4 -1
  56. package/dist/lib/Steps/Integrations/Electron.js +1 -1
  57. package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
  58. package/dist/lib/Steps/Integrations/MobileProject.d.ts +3 -1
  59. package/dist/lib/Steps/Integrations/MobileProject.js +1 -1
  60. package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
  61. package/dist/lib/Steps/PromptForParameters.d.ts +4 -1
  62. package/dist/lib/Steps/PromptForParameters.js.map +1 -1
  63. package/dist/lib/Steps/SentryProjectSelector.d.ts +42 -1
  64. package/dist/lib/Steps/SentryProjectSelector.js +1 -1
  65. package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
  66. package/dist/lib/Steps/WaitForSentry.d.ts +3 -1
  67. package/dist/lib/Steps/WaitForSentry.js +4 -4
  68. package/dist/lib/Steps/WaitForSentry.js.map +1 -1
  69. package/dist/lib/Steps/Welcome.js +5 -0
  70. package/dist/lib/Steps/Welcome.js.map +1 -1
  71. package/dist/lib/Types.d.ts +14 -0
  72. package/dist/lib/Types.js +3 -0
  73. package/dist/lib/Types.js.map +1 -0
  74. package/dist/lib/__tests__/Env.js +10 -16
  75. package/dist/lib/__tests__/Env.js.map +1 -1
  76. package/dist/src/android/android-wizard.js +15 -12
  77. package/dist/src/android/android-wizard.js.map +1 -1
  78. package/dist/src/android/code-tools.js +1 -1
  79. package/dist/src/android/code-tools.js.map +1 -1
  80. package/dist/src/android/gradle.js +4 -4
  81. package/dist/src/android/gradle.js.map +1 -1
  82. package/dist/src/android/manifest.js +1 -1
  83. package/dist/src/android/manifest.js.map +1 -1
  84. package/dist/src/apple/apple-wizard.d.ts +2 -2
  85. package/dist/src/apple/apple-wizard.js +54 -175
  86. package/dist/src/apple/apple-wizard.js.map +1 -1
  87. package/dist/src/apple/check-installed-cli.d.ts +1 -0
  88. package/dist/src/apple/check-installed-cli.js +60 -0
  89. package/dist/src/apple/check-installed-cli.js.map +1 -0
  90. package/dist/src/apple/cocoapod.js +1 -1
  91. package/dist/src/apple/cocoapod.js.map +1 -1
  92. package/dist/src/apple/code-tools.js +1 -1
  93. package/dist/src/apple/code-tools.js.map +1 -1
  94. package/dist/src/apple/configure-fastlane.d.ts +5 -0
  95. package/dist/src/apple/configure-fastlane.js +66 -0
  96. package/dist/src/apple/configure-fastlane.js.map +1 -0
  97. package/dist/src/apple/configure-package-manager.d.ts +5 -0
  98. package/dist/src/apple/configure-package-manager.js +68 -0
  99. package/dist/src/apple/configure-package-manager.js.map +1 -0
  100. package/dist/src/apple/configure-sentry-cli.d.ts +4 -0
  101. package/dist/src/apple/configure-sentry-cli.js +47 -0
  102. package/dist/src/apple/configure-sentry-cli.js.map +1 -0
  103. package/dist/src/apple/configure-xcode-project.d.ts +8 -0
  104. package/dist/src/apple/configure-xcode-project.js +11 -0
  105. package/dist/src/apple/configure-xcode-project.js.map +1 -0
  106. package/dist/src/apple/fastlane.d.ts +1 -1
  107. package/dist/src/apple/fastlane.js +5 -5
  108. package/dist/src/apple/fastlane.js.map +1 -1
  109. package/dist/src/apple/inject-code-snippet.d.ts +6 -0
  110. package/dist/src/apple/inject-code-snippet.js +54 -0
  111. package/dist/src/apple/inject-code-snippet.js.map +1 -0
  112. package/dist/src/apple/lookup-xcode-project.d.ts +7 -0
  113. package/dist/src/apple/lookup-xcode-project.js +98 -0
  114. package/dist/src/apple/lookup-xcode-project.js.map +1 -0
  115. package/dist/src/apple/options.d.ts +4 -0
  116. package/dist/src/apple/options.js +3 -0
  117. package/dist/src/apple/options.js.map +1 -0
  118. package/dist/src/apple/search-xcode-project-at-path.d.ts +1 -0
  119. package/dist/src/apple/search-xcode-project-at-path.js +70 -0
  120. package/dist/src/apple/search-xcode-project-at-path.js.map +1 -0
  121. package/dist/src/apple/templates.js +11 -7
  122. package/dist/src/apple/templates.js.map +1 -1
  123. package/dist/src/apple/xcode-manager.js +4 -7
  124. package/dist/src/apple/xcode-manager.js.map +1 -1
  125. package/dist/src/flutter/code-tools.js +3 -3
  126. package/dist/src/flutter/code-tools.js.map +1 -1
  127. package/dist/src/flutter/flutter-wizard.js +21 -15
  128. package/dist/src/flutter/flutter-wizard.js.map +1 -1
  129. package/dist/src/flutter/templates.js +4 -4
  130. package/dist/src/flutter/templates.js.map +1 -1
  131. package/dist/src/nextjs/nextjs-wizard.js +118 -43
  132. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  133. package/dist/src/nextjs/templates.d.ts +10 -1
  134. package/dist/src/nextjs/templates.js +192 -62
  135. package/dist/src/nextjs/templates.js.map +1 -1
  136. package/dist/src/nuxt/nuxt-wizard.js +21 -16
  137. package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
  138. package/dist/src/nuxt/sdk-example.js +3 -3
  139. package/dist/src/nuxt/sdk-example.js.map +1 -1
  140. package/dist/src/nuxt/sdk-setup.js +9 -9
  141. package/dist/src/nuxt/sdk-setup.js.map +1 -1
  142. package/dist/src/nuxt/templates.js +173 -58
  143. package/dist/src/nuxt/templates.js.map +1 -1
  144. package/dist/src/nuxt/utils.js +6 -3
  145. package/dist/src/nuxt/utils.js.map +1 -1
  146. package/dist/src/react-native/expo-env-file.js +1 -1
  147. package/dist/src/react-native/expo-env-file.js.map +1 -1
  148. package/dist/src/react-native/expo-metro.js +4 -4
  149. package/dist/src/react-native/expo-metro.js.map +1 -1
  150. package/dist/src/react-native/expo.js +4 -4
  151. package/dist/src/react-native/expo.js.map +1 -1
  152. package/dist/src/react-native/javascript.d.ts +6 -4
  153. package/dist/src/react-native/javascript.js +31 -15
  154. package/dist/src/react-native/javascript.js.map +1 -1
  155. package/dist/src/react-native/metro.js +8 -8
  156. package/dist/src/react-native/metro.js.map +1 -1
  157. package/dist/src/react-native/react-native-wizard.d.ts +5 -1
  158. package/dist/src/react-native/react-native-wizard.js +66 -36
  159. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  160. package/dist/src/react-native/uninstall.js +8 -5
  161. package/dist/src/react-native/uninstall.js.map +1 -1
  162. package/dist/src/react-native/xcode.d.ts +9 -4
  163. package/dist/src/react-native/xcode.js +65 -22
  164. package/dist/src/react-native/xcode.js.map +1 -1
  165. package/dist/src/remix/codemods/handle-error.js +4 -1
  166. package/dist/src/remix/codemods/handle-error.js.map +1 -1
  167. package/dist/src/remix/remix-wizard.js +23 -18
  168. package/dist/src/remix/remix-wizard.js.map +1 -1
  169. package/dist/src/remix/sdk-example.js +163 -64
  170. package/dist/src/remix/sdk-example.js.map +1 -1
  171. package/dist/src/remix/sdk-setup.js +11 -7
  172. package/dist/src/remix/sdk-setup.js.map +1 -1
  173. package/dist/src/run.d.ts +3 -1
  174. package/dist/src/run.js +29 -9
  175. package/dist/src/run.js.map +1 -1
  176. package/dist/src/sourcemaps/sourcemaps-wizard.js +30 -28
  177. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  178. package/dist/src/sourcemaps/tools/angular.js +3 -3
  179. package/dist/src/sourcemaps/tools/angular.js.map +1 -1
  180. package/dist/src/sourcemaps/tools/create-react-app.js +3 -3
  181. package/dist/src/sourcemaps/tools/create-react-app.js.map +1 -1
  182. package/dist/src/sourcemaps/tools/esbuild.js +6 -6
  183. package/dist/src/sourcemaps/tools/esbuild.js.map +1 -1
  184. package/dist/src/sourcemaps/tools/nextjs.js +5 -5
  185. package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
  186. package/dist/src/sourcemaps/tools/remix.js +4 -4
  187. package/dist/src/sourcemaps/tools/remix.js.map +1 -1
  188. package/dist/src/sourcemaps/tools/rollup.js +6 -6
  189. package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
  190. package/dist/src/sourcemaps/tools/sentry-cli.js +15 -15
  191. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  192. package/dist/src/sourcemaps/tools/tsc.js +6 -6
  193. package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
  194. package/dist/src/sourcemaps/tools/vite.js +12 -12
  195. package/dist/src/sourcemaps/tools/vite.js.map +1 -1
  196. package/dist/src/sourcemaps/tools/webpack.js +10 -10
  197. package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
  198. package/dist/src/sourcemaps/utils/detect-tool.js +2 -2
  199. package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
  200. package/dist/src/sourcemaps/utils/other-wizards.js +5 -5
  201. package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
  202. package/dist/src/sourcemaps/utils/sdk-version.js +7 -7
  203. package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
  204. package/dist/src/sveltekit/sdk-example.js +1 -1
  205. package/dist/src/sveltekit/sdk-example.js.map +1 -1
  206. package/dist/src/sveltekit/sdk-setup.js +15 -14
  207. package/dist/src/sveltekit/sdk-setup.js.map +1 -1
  208. package/dist/src/sveltekit/sveltekit-wizard.js +25 -20
  209. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  210. package/dist/src/sveltekit/templates.js +126 -37
  211. package/dist/src/sveltekit/templates.js.map +1 -1
  212. package/dist/src/telemetry.js +11 -0
  213. package/dist/src/telemetry.js.map +1 -1
  214. package/dist/src/utils/{clack-utils.d.ts → clack/index.d.ts} +45 -7
  215. package/dist/src/utils/{clack-utils.js → clack/index.js} +75 -20
  216. package/dist/src/utils/clack/index.js.map +1 -0
  217. package/dist/src/utils/debug.js +1 -1
  218. package/dist/src/utils/debug.js.map +1 -1
  219. package/dist/src/utils/find-files-with-extension.d.ts +1 -0
  220. package/dist/src/utils/find-files-with-extension.js +39 -0
  221. package/dist/src/utils/find-files-with-extension.js.map +1 -0
  222. package/dist/src/utils/package-manager.d.ts +8 -1
  223. package/dist/src/utils/package-manager.js +79 -23
  224. package/dist/src/utils/package-manager.js.map +1 -1
  225. package/dist/src/utils/sentrycli-utils.js +0 -1
  226. package/dist/src/utils/sentrycli-utils.js.map +1 -1
  227. package/dist/src/utils/types.d.ts +4 -0
  228. package/dist/src/utils/types.js.map +1 -1
  229. package/dist/src/version.d.ts +1 -1
  230. package/dist/src/version.js +1 -1
  231. package/dist/src/version.js.map +1 -1
  232. package/dist/test/android/code-tools.test.js +13 -13
  233. package/dist/test/android/code-tools.test.js.map +1 -1
  234. package/dist/test/apple/cocoapod.test.js +78 -73
  235. package/dist/test/apple/cocoapod.test.js.map +1 -1
  236. package/dist/test/apple/code-tools.test.js +174 -167
  237. package/dist/test/apple/code-tools.test.js.map +1 -1
  238. package/dist/test/apple/fastfile.test.js +87 -84
  239. package/dist/test/apple/fastfile.test.js.map +1 -1
  240. package/dist/test/apple/templates.test.js +32 -27
  241. package/dist/test/apple/templates.test.js.map +1 -1
  242. package/dist/test/apple/xcode-manager.test.js +208 -185
  243. package/dist/test/apple/xcode-manager.test.js.map +1 -1
  244. package/dist/test/flutter/code-tools.test.js +29 -30
  245. package/dist/test/flutter/code-tools.test.js.map +1 -1
  246. package/dist/test/flutter/templates.test.js +38 -37
  247. package/dist/test/flutter/templates.test.js.map +1 -1
  248. package/dist/test/nextjs/templates.test.js +155 -103
  249. package/dist/test/nextjs/templates.test.js.map +1 -1
  250. package/dist/test/nuxt/templates.test.js +25 -24
  251. package/dist/test/nuxt/templates.test.js.map +1 -1
  252. package/dist/test/react-native/expo-metro.test.js +12 -11
  253. package/dist/test/react-native/expo-metro.test.js.map +1 -1
  254. package/dist/test/react-native/expo.test.js +11 -10
  255. package/dist/test/react-native/expo.test.js.map +1 -1
  256. package/dist/test/react-native/gradle.test.js +27 -26
  257. package/dist/test/react-native/gradle.test.js.map +1 -1
  258. package/dist/test/react-native/javascript.test.js +109 -59
  259. package/dist/test/react-native/javascript.test.js.map +1 -1
  260. package/dist/test/react-native/metro.test.js +66 -65
  261. package/dist/test/react-native/metro.test.js.map +1 -1
  262. package/dist/test/react-native/xcode.test.js +138 -37
  263. package/dist/test/react-native/xcode.test.js.map +1 -1
  264. package/dist/test/remix/client-entry.test.js +8 -7
  265. package/dist/test/remix/client-entry.test.js.map +1 -1
  266. package/dist/test/remix/server-instrumentation.test.js +6 -5
  267. package/dist/test/remix/server-instrumentation.test.js.map +1 -1
  268. package/dist/test/sourcemaps/tools/sentry-cli.test.js +21 -21
  269. package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
  270. package/dist/test/sourcemaps/tools/tsc.test.js +13 -14
  271. package/dist/test/sourcemaps/tools/tsc.test.js.map +1 -1
  272. package/dist/test/sourcemaps/tools/vite.test.js +13 -14
  273. package/dist/test/sourcemaps/tools/vite.test.js.map +1 -1
  274. package/dist/test/sourcemaps/tools/webpack.test.js +19 -20
  275. package/dist/test/sourcemaps/tools/webpack.test.js.map +1 -1
  276. package/dist/test/sveltekit/templates.test.js +13 -12
  277. package/dist/test/sveltekit/templates.test.js.map +1 -1
  278. package/dist/test/utils/ast-utils.test.js +45 -44
  279. package/dist/test/utils/ast-utils.test.js.map +1 -1
  280. package/dist/test/utils/clack/index.test.d.ts +1 -0
  281. package/dist/test/utils/clack/index.test.js +375 -0
  282. package/dist/test/utils/clack/index.test.js.map +1 -0
  283. package/dist/test/utils/package-manager.test.d.ts +1 -0
  284. package/dist/test/utils/package-manager.test.js +30 -0
  285. package/dist/test/utils/package-manager.test.js.map +1 -0
  286. package/package.json +10 -38
  287. package/dist/e2e-tests/jest.config.d.ts +0 -17
  288. package/dist/e2e-tests/jest.config.js +0 -23
  289. package/dist/e2e-tests/jest.config.js.map +0 -1
  290. package/dist/src/utils/clack-utils.js.map +0 -1
  291. package/dist/test/utils/clack-utils.test.js +0 -306
  292. package/dist/test/utils/clack-utils.test.js.map +0 -1
  293. /package/dist/{test/utils/clack-utils.test.d.ts → e2e-tests/tests/help-message.test.d.ts} +0 -0
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.injectCodeSnippet = void 0;
30
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
31
+ const prompts_1 = __importDefault(require("@clack/prompts"));
32
+ const Sentry = __importStar(require("@sentry/node"));
33
+ const chalk_1 = __importDefault(require("chalk"));
34
+ const telemetry_1 = require("../telemetry");
35
+ const debug_1 = require("../utils/debug");
36
+ const codeTools = __importStar(require("./code-tools"));
37
+ function injectCodeSnippet({ project, target, dsn, }) {
38
+ (0, debug_1.debug)(`Injecting code snippet into project at path: ${chalk_1.default.cyan(project.projectPath)}`);
39
+ const codeAdded = (0, telemetry_1.traceStep)('Add code snippet', () => {
40
+ const files = project.filesForTarget(target);
41
+ if (files === undefined || files.length == 0) {
42
+ Sentry.setTag('snippet-candidate-files-not-found', true);
43
+ return false;
44
+ }
45
+ return codeTools.addCodeSnippetToProject(project.projectPath, files, dsn);
46
+ });
47
+ Sentry.setTag('Snippet-Added', codeAdded);
48
+ (0, debug_1.debug)(`Snippet added: ${chalk_1.default.cyan(codeAdded.toString())}`);
49
+ if (!codeAdded) {
50
+ prompts_1.default.log.warn('Added the Sentry dependency to your project but could not add the Sentry code snippet. Please add the code snippet manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure');
51
+ }
52
+ }
53
+ exports.injectCodeSnippet = injectCodeSnippet;
54
+ //# sourceMappingURL=inject-code-snippet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject-code-snippet.js","sourceRoot":"","sources":["../../../src/apple/inject-code-snippet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,kDAA0B;AAC1B,4CAAyC;AACzC,0CAAuC;AACvC,wDAA0C;AAG1C,SAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,GAAG,GAKJ;IACC,IAAA,aAAK,EACH,gDAAgD,eAAK,CAAC,IAAI,CACxD,OAAO,CAAC,WAAW,CACpB,EAAE,CACJ,CAAC;IACF,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,kBAAkB,EAAE,GAAG,EAAE;QACnD,MAAM,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;YAC5C,MAAM,CAAC,MAAM,CAAC,mCAAmC,EAAE,IAAI,CAAC,CAAC;YACzD,OAAO,KAAK,CAAC;SACd;QAED,OAAO,SAAS,CAAC,uBAAuB,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAC1C,IAAA,aAAK,EAAC,kBAAkB,eAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IAE5D,IAAI,CAAC,SAAS,EAAE;QACd,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,iNAAiN,CAClN,CAAC;KACH;AACH,CAAC;AA/BD,8CA+BC","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 { traceStep } from '../telemetry';\nimport { debug } from '../utils/debug';\nimport * as codeTools from './code-tools';\nimport { XcodeProject } from './xcode-manager';\n\nexport function injectCodeSnippet({\n project,\n target,\n dsn,\n}: {\n project: XcodeProject;\n target: string;\n dsn: string;\n}) {\n debug(\n `Injecting code snippet into project at path: ${chalk.cyan(\n project.projectPath,\n )}`,\n );\n const codeAdded = traceStep('Add code snippet', () => {\n const files = project.filesForTarget(target);\n if (files === undefined || files.length == 0) {\n Sentry.setTag('snippet-candidate-files-not-found', true);\n return false;\n }\n\n return codeTools.addCodeSnippetToProject(project.projectPath, files, dsn);\n });\n Sentry.setTag('Snippet-Added', codeAdded);\n debug(`Snippet added: ${chalk.cyan(codeAdded.toString())}`);\n\n if (!codeAdded) {\n clack.log.warn(\n 'Added the Sentry dependency to your project but could not add the Sentry code snippet. Please add the code snippet manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure',\n );\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { XcodeProject } from './xcode-manager';
2
+ export declare function lookupXcodeProject({ projectDir, }: {
3
+ projectDir: string;
4
+ }): Promise<{
5
+ xcProject: XcodeProject;
6
+ target: string;
7
+ }>;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.lookupXcodeProject = void 0;
30
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
31
+ const prompts_1 = __importDefault(require("@clack/prompts"));
32
+ const Sentry = __importStar(require("@sentry/node"));
33
+ const chalk_1 = __importDefault(require("chalk"));
34
+ const fs = __importStar(require("fs"));
35
+ const path = __importStar(require("path"));
36
+ const telemetry_1 = require("../telemetry");
37
+ const clack_1 = require("../utils/clack");
38
+ const debug_1 = require("../utils/debug");
39
+ const search_xcode_project_at_path_1 = require("./search-xcode-project-at-path");
40
+ const xcode_manager_1 = require("./xcode-manager");
41
+ async function lookupXcodeProject({ projectDir, }) {
42
+ (0, debug_1.debug)(`Looking for Xcode project in directory: ${chalk_1.default.cyan(projectDir)}`);
43
+ const xcodeProjFiles = (0, search_xcode_project_at_path_1.searchXcodeProjectAtPath)(projectDir);
44
+ if (xcodeProjFiles.length === 0) {
45
+ prompts_1.default.log.error('No Xcode project found. Please run this command from the root of your project.');
46
+ Sentry.setTag('no-xcode-project', true);
47
+ return await (0, clack_1.abort)();
48
+ }
49
+ (0, debug_1.debug)(`Found ${chalk_1.default.cyan(xcodeProjFiles.length.toString())} candidates for Xcode project`);
50
+ // In case there is only one Xcode project, we can use that one.
51
+ // Otherwise, we need to ask the user which one they want to use.
52
+ let xcodeProjFile;
53
+ if (xcodeProjFiles.length === 1) {
54
+ (0, debug_1.debug)(`Found exactly one Xcode project, using it`);
55
+ Sentry.setTag('multiple-projects', false);
56
+ xcodeProjFile = xcodeProjFiles[0];
57
+ }
58
+ else {
59
+ (0, debug_1.debug)(`Found multiple Xcode projects, asking user to choose one`);
60
+ Sentry.setTag('multiple-projects', true);
61
+ 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
+ }
63
+ // Load the pbxproj file
64
+ const pathToPbxproj = path.join(projectDir, xcodeProjFile, 'project.pbxproj');
65
+ (0, debug_1.debug)(`Loading Xcode project pbxproj at path: ${chalk_1.default.cyan(pathToPbxproj)}`);
66
+ if (!fs.existsSync(pathToPbxproj)) {
67
+ prompts_1.default.log.error(`No pbxproj found at ${xcodeProjFile}`);
68
+ Sentry.setTag('pbxproj-not-found', true);
69
+ return await (0, clack_1.abort)();
70
+ }
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}`);
75
+ Sentry.setTag('No-Target', true);
76
+ return await (0, clack_1.abort)();
77
+ }
78
+ (0, debug_1.debug)(`Found ${chalk_1.default.cyan(availableTargets.length.toString())} targets in Xcode project`);
79
+ // Step - Lookup Xcode Target
80
+ let target;
81
+ if (availableTargets.length == 1) {
82
+ (0, debug_1.debug)(`Found exactly one target, using it`);
83
+ Sentry.setTag('multiple-targets', false);
84
+ target = availableTargets[0];
85
+ }
86
+ else {
87
+ (0, debug_1.debug)(`Found multiple targets, asking user to choose one`);
88
+ 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;
90
+ }
91
+ (0, debug_1.debug)(`Selected target: ${chalk_1.default.cyan(target)}`);
92
+ return {
93
+ xcProject,
94
+ target,
95
+ };
96
+ }
97
+ exports.lookupXcodeProject = lookupXcodeProject;
98
+ //# sourceMappingURL=lookup-xcode-project.js.map
@@ -0,0 +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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BAAgB,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"]}
@@ -0,0 +1,4 @@
1
+ import { WizardOptions } from '../utils/types';
2
+ export interface AppleWizardOptions extends WizardOptions {
3
+ projectDir: string | undefined;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=options.js.map
@@ -0,0 +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"]}
@@ -0,0 +1 @@
1
+ export declare function searchXcodeProjectAtPath(searchPath: string): string[];
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.searchXcodeProjectAtPath = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ const path = __importStar(require("path"));
29
+ const debug_1 = require("../utils/debug");
30
+ const find_files_with_extension_1 = require("../utils/find-files-with-extension");
31
+ function searchXcodeProjectAtPath(searchPath) {
32
+ (0, debug_1.debug)('Searching for Xcode project at path: ' + searchPath);
33
+ const projs = (0, find_files_with_extension_1.findFilesWithExtension)(searchPath, '.xcodeproj');
34
+ if (projs.length > 0) {
35
+ (0, debug_1.debug)('Found Xcode project at paths:');
36
+ projs.forEach((proj) => (0, debug_1.debug)(' ' + proj));
37
+ return projs;
38
+ }
39
+ (0, debug_1.debug)('Searching for Xcode workspace at path: ' + searchPath);
40
+ const workspace = (0, find_files_with_extension_1.findFilesWithExtension)(searchPath, '.xcworkspace');
41
+ if (workspace.length == 0) {
42
+ (0, debug_1.debug)('No Xcode workspace found at path: ' + searchPath);
43
+ return [];
44
+ }
45
+ (0, debug_1.debug)('Found Xcode workspace at path: ' + workspace[0]);
46
+ const xsworkspacedata = path.join(searchPath, workspace[0], 'contents.xcworkspacedata');
47
+ if (!fs.existsSync(xsworkspacedata)) {
48
+ (0, debug_1.debug)('No Xcode workspace data found at path: ' + xsworkspacedata);
49
+ return [];
50
+ }
51
+ (0, debug_1.debug)('Parsing Xcode workspace data at path: ' + xsworkspacedata);
52
+ const groupRegex = /location *= *"group:([^"]+)"/gim;
53
+ const content = fs.readFileSync(xsworkspacedata, 'utf8');
54
+ let matches = groupRegex.exec(content);
55
+ while (matches) {
56
+ const group = matches[1];
57
+ const groupPath = path.join(searchPath, group);
58
+ if (!group.endsWith('Pods.xcodeproj') &&
59
+ group.endsWith('.xcodeproj') &&
60
+ fs.existsSync(groupPath)) {
61
+ projs.push(group);
62
+ }
63
+ matches = groupRegex.exec(content);
64
+ }
65
+ (0, debug_1.debug)('Found Xcode project at paths:');
66
+ projs.forEach((proj) => (0, debug_1.debug)(' ' + proj));
67
+ return projs;
68
+ }
69
+ exports.searchXcodeProjectAtPath = searchXcodeProjectAtPath;
70
+ //# sourceMappingURL=search-xcode-project-at-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-xcode-project-at-path.js","sourceRoot":"","sources":["../../../src/apple/search-xcode-project-at-path.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,0CAAuC;AACvC,kFAA4E;AAE5E,SAAgB,wBAAwB,CAAC,UAAkB;IACzD,IAAA,aAAK,EAAC,uCAAuC,GAAG,UAAU,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,IAAA,kDAAsB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC/D,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QACpB,IAAA,aAAK,EAAC,+BAA+B,CAAC,CAAC;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,aAAK,EAAC,IAAI,GAAG,IAAI,CAAC,CAAC,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,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KACpC;IAED,IAAA,aAAK,EAAC,+BAA+B,CAAC,CAAC;IACvC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,aAAK,EAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC;AACf,CAAC;AAhDD,4DAgDC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport { debug } from '../utils/debug';\nimport { findFilesWithExtension } from '../utils/find-files-with-extension';\n\nexport function searchXcodeProjectAtPath(searchPath: string): string[] {\n debug('Searching for Xcode project at path: ' + searchPath);\n const projs = findFilesWithExtension(searchPath, '.xcodeproj');\n if (projs.length > 0) {\n debug('Found Xcode project at paths:');\n projs.forEach((proj) => debug(' ' + proj));\n return projs;\n }\n\n debug('Searching for Xcode workspace at path: ' + searchPath);\n const workspace = findFilesWithExtension(searchPath, '.xcworkspace');\n if (workspace.length == 0) {\n debug('No Xcode workspace found at path: ' + searchPath);\n return [];\n }\n\n debug('Found Xcode workspace at path: ' + workspace[0]);\n const xsworkspacedata = path.join(\n searchPath,\n workspace[0],\n 'contents.xcworkspacedata',\n );\n if (!fs.existsSync(xsworkspacedata)) {\n debug('No Xcode workspace data found at path: ' + xsworkspacedata);\n return [];\n }\n\n debug('Parsing Xcode workspace data at path: ' + xsworkspacedata);\n const groupRegex = /location *= *\"group:([^\"]+)\"/gim;\n const content = fs.readFileSync(xsworkspacedata, 'utf8');\n let matches = groupRegex.exec(content);\n\n while (matches) {\n const group = matches[1];\n const groupPath = path.join(searchPath, group);\n if (\n !group.endsWith('Pods.xcodeproj') &&\n group.endsWith('.xcodeproj') &&\n fs.existsSync(groupPath)\n ) {\n projs.push(group);\n }\n matches = groupRegex.exec(content);\n }\n\n debug('Found Xcode project at paths:');\n projs.forEach((proj) => debug(' ' + proj));\n return projs;\n}\n"]}
@@ -6,7 +6,7 @@ function getRunScriptTemplate(orgSlug, projectSlug, uploadSource, includeHomebre
6
6
  const includeHomebrew = includeHomebrewPath
7
7
  ? '\\nif [[ "$(uname -m)" == arm64 ]]; then\\nexport PATH="/opt/homebrew/bin:$PATH"\\nfi'
8
8
  : '';
9
- return `# This script is responsable to upload 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 ${uploadSource ? '--include-sources ' : ''}"$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`;
9
+ 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 ${uploadSource ? '--include-sources ' : ''}"$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`;
10
10
  }
11
11
  exports.getRunScriptTemplate = getRunScriptTemplate;
12
12
  exports.scriptInputPath = '"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}"';
@@ -18,9 +18,11 @@ function getSwiftSnippet(dsn) {
18
18
  // We recommend adjusting this value in production.
19
19
  options.tracesSampleRate = 1.0
20
20
 
21
- // Sample rate for profiling, applied on top of TracesSampleRate.
22
- // We recommend adjusting this value in production.
23
- options.profilesSampleRate = 1.0
21
+ // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.
22
+ options.configureProfiling = {
23
+ $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.
24
+ $0.lifecycle = .trace
25
+ }
24
26
 
25
27
  // Uncomment the following lines to add more data to your events
26
28
  // options.attachScreenshot = true // This adds a screenshot to the error events
@@ -38,9 +40,11 @@ function getObjcSnippet(dsn) {
38
40
  // We recommend adjusting this value in production.
39
41
  options.tracesSampleRate = @1.0;
40
42
 
41
- // Sample rate for profiling, applied on top of TracesSampleRate.
42
- // We recommend adjusting this value in production.
43
- options.profilesSampleRate = @1.0;
43
+ // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.
44
+ options.configureProfiling = ^(SentryProfileOptions *profiling) {
45
+ profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.
46
+ profiling.lifecycle = SentryProfilingLifecycleTrace;
47
+ };
44
48
 
45
49
  //Uncomment the following lines to add more data to your events
46
50
  //options.attachScreenshot = YES; //This will add a screenshot to the error events
@@ -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,sFAAsF,eAAe,+DAA+D,OAAO,4BAA4B,WAAW,4CACvN,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;;;;;;;;;;;;;;;iEAeiC,CAAC;AAClE,CAAC;AAlBD,0CAkBC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO;0BACiB,GAAG;;;;;;;;;;;;;;;2DAe8B,CAAC;AAC5D,CAAC;AAlBD,wCAkBC;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 responsable to upload 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 // Sample rate for profiling, applied on top of TracesSampleRate.\n // We recommend adjusting this value in production.\n options.profilesSampleRate = 1.0 \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 // Sample rate for profiling, applied on top of TracesSampleRate.\n // We recommend adjusting this value in production.\n options.profilesSampleRate = @1.0;\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;;;;;;;;;;;;;;;;;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"]}
@@ -22,17 +22,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
26
  exports.XcodeProject = void 0;
30
27
  /* eslint-disable max-lines */
31
28
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
32
29
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
33
30
  /* eslint-disable @typescript-eslint/no-unsafe-call */
34
- // @ts-ignore - clack is ESM and TS complains about that. It works though
35
- const prompts_1 = __importDefault(require("@clack/prompts"));
31
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
32
+ const clack = __importStar(require("@clack/prompts"));
36
33
  const fs = __importStar(require("node:fs"));
37
34
  const path = __importStar(require("node:path"));
38
35
  const templates = __importStar(require("./templates"));
@@ -169,7 +166,7 @@ function addSentrySPM(proj, targetName) {
169
166
  };
170
167
  xcObjects.XCSwiftPackageProductDependency[`${sentrySPMUUID}_comment`] =
171
168
  'Sentry';
172
- prompts_1.default.log.step('Added Sentry SPM dependency to your project');
169
+ clack.log.step('Added Sentry SPM dependency to your project');
173
170
  }
174
171
  function addUploadSymbolsScript(xcodeProject, sentryProject, targetName, uploadSource) {
175
172
  const xcObjects = xcodeProject.hash.project.objects;
@@ -207,7 +204,7 @@ function addUploadSymbolsScript(xcodeProject, sentryProject, targetName, uploadS
207
204
  shellPath: '/bin/sh',
208
205
  shellScript: templates.getRunScriptTemplate(sentryProject.organization.slug, sentryProject.slug, uploadSource, isHomebrewInstalled),
209
206
  });
210
- prompts_1.default.log.step(`Added Sentry upload script to "${targetName}" build phase`);
207
+ clack.log.step(`Added Sentry upload script to "${targetName}" build phase`);
211
208
  }
212
209
  class XcodeProject {
213
210
  projectPath;
@@ -1 +1 @@
1
- {"version":3,"file":"xcode-manager.js","sourceRoot":"","sources":["../../../src/apple/xcode-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+DAA+D;AAC/D,4DAA4D;AAC5D,sDAAsD;AACtD,yEAAyE;AACzE,6DAAmC;AACnC,4CAA8B;AAC9B,gDAAkC;AAElC,uDAAyC;AAEzC,iCASe;AAOf,SAAS,mCAAmC,CAC1C,IAAa,EACb,UAAkB;IAElB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC5C,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE;QAC9B,SA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AAS;iBACV;gBACD,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CACnC,cAAc,EACd,cAAc,CAAC,IAAI;oBACjB,CAAC,CAAC,GAAG,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG;oBACpD,CAAC,CAAC,IAAI,CACT,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;aAC/B;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAnJD,oCAmJC","sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport type { SentryProjectData } from '../utils/types';\nimport * as templates from './templates';\n\nimport {\n project as createXcodeProject,\n type PBXBuildFile,\n type PBXGroup,\n type PBXNativeTarget,\n type PBXObjects,\n type PBXSourcesBuildPhase,\n type Project,\n type XCConfigurationList,\n} from 'xcode';\n\ninterface ProjectFile {\n key: string;\n path: string;\n}\n\nfunction setDebugInformationFormatAndSandbox(\n proj: Project,\n targetName: string,\n): void {\n const xcObjects = proj.hash.project.objects;\n if (!xcObjects.PBXNativeTarget) {\n xcObjects.PBXNativeTarget = {};\n }\n const targetKey: string = Object.keys(xcObjects.PBXNativeTarget).filter(\n (key) => {\n const value = xcObjects.PBXNativeTarget?.[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value?.name === targetName\n );\n },\n )[0];\n const target = xcObjects.PBXNativeTarget[targetKey] as\n | PBXNativeTarget\n | undefined;\n\n if (!xcObjects.XCBuildConfiguration) {\n xcObjects.XCBuildConfiguration = {};\n }\n if (!xcObjects.XCConfigurationList) {\n xcObjects.XCConfigurationList = {};\n }\n const buildConfigurationListId = target?.buildConfigurationList ?? '';\n const configurationList = xcObjects.XCConfigurationList?.[\n buildConfigurationListId\n ] as XCConfigurationList | undefined;\n const buildListConfigurationIds =\n configurationList?.buildConfigurations ?? [];\n for (const buildListConfigId of buildListConfigurationIds) {\n const config =\n xcObjects.XCBuildConfiguration[buildListConfigId.value] ?? {};\n if (typeof config === 'string') {\n // Ignore comments\n continue;\n }\n\n const buildSettings = config.buildSettings ?? {};\n buildSettings.DEBUG_INFORMATION_FORMAT = '\"dwarf-with-dsym\"';\n buildSettings.ENABLE_USER_SCRIPT_SANDBOXING = '\"NO\"';\n\n config.buildSettings = buildSettings;\n xcObjects.XCBuildConfiguration[buildListConfigId.value] = config;\n }\n}\n\nfunction addSentrySPM(proj: Project, targetName: string): void {\n const xcObjects = proj.hash.project.objects;\n\n const sentryFrameworkUUID = proj.generateUuid();\n const sentrySPMUUID = proj.generateUuid();\n\n // Check whether xcObjects already have sentry framework\n if (xcObjects.PBXFrameworksBuildPhase) {\n for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {\n const frameworkBuildPhase = xcObjects.PBXFrameworksBuildPhase[key];\n if (key.endsWith('_comment') || typeof frameworkBuildPhase === 'string') {\n // Ignore comments\n continue;\n }\n for (const framework of frameworkBuildPhase.files ?? []) {\n // We identify the Sentry framework by the comment \"Sentry in Frameworks\",\n // which is set by this manager in previous runs.\n if (framework.comment === 'Sentry in Frameworks') {\n return;\n }\n }\n }\n }\n\n if (!xcObjects.PBXBuildFile) {\n xcObjects.PBXBuildFile = {};\n }\n xcObjects.PBXBuildFile[sentryFrameworkUUID] = {\n isa: 'PBXBuildFile',\n productRef: sentrySPMUUID,\n productRef_comment: 'Sentry',\n };\n xcObjects.PBXBuildFile[`${sentryFrameworkUUID}_comment`] =\n 'Sentry in Frameworks';\n\n if (!xcObjects.PBXFrameworksBuildPhase) {\n xcObjects.PBXFrameworksBuildPhase = {};\n }\n for (const key in xcObjects.PBXFrameworksBuildPhase) {\n const value = xcObjects.PBXFrameworksBuildPhase[key];\n if (key.endsWith('_comment') || typeof value === 'string') {\n // Ignore comments\n continue;\n }\n\n const frameworks = value.files ?? [];\n frameworks.push({\n value: sentryFrameworkUUID,\n comment: 'Sentry in Frameworks',\n });\n value.files = frameworks;\n\n xcObjects.PBXFrameworksBuildPhase[key] = value;\n }\n\n if (!xcObjects.PBXNativeTarget) {\n xcObjects.PBXNativeTarget = {};\n }\n const targetKey = Object.keys(xcObjects.PBXNativeTarget || {}).filter(\n (key) => {\n const value = xcObjects.PBXNativeTarget?.[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value?.name === targetName\n );\n },\n )[0];\n const target = xcObjects.PBXNativeTarget[targetKey] as PBXNativeTarget;\n\n if (!target.packageProductDependencies) {\n target.packageProductDependencies = [];\n }\n target.packageProductDependencies.push({\n value: sentrySPMUUID,\n comment: 'Sentry',\n });\n\n const sentrySwiftPackageUUID = proj.generateUuid();\n const xcProject = proj.getFirstProject().firstProject;\n if (!xcProject.packageReferences) {\n xcProject.packageReferences = [];\n }\n xcProject.packageReferences.push({\n value: sentrySwiftPackageUUID,\n comment: 'XCRemoteSwiftPackageReference \"sentry-cocoa\"',\n });\n\n if (!xcObjects.XCRemoteSwiftPackageReference) {\n xcObjects.XCRemoteSwiftPackageReference = {};\n }\n\n xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID] = {\n isa: 'XCRemoteSwiftPackageReference',\n repositoryURL: '\"https://github.com/getsentry/sentry-cocoa/\"',\n requirement: {\n kind: 'upToNextMajorVersion',\n minimumVersion: '8.0.0',\n },\n };\n xcObjects.XCRemoteSwiftPackageReference[`${sentrySwiftPackageUUID}_comment`] =\n 'XCRemoteSwiftPackageReference \"sentry-cocoa\"';\n\n if (!xcObjects.XCSwiftPackageProductDependency) {\n xcObjects.XCSwiftPackageProductDependency = {};\n }\n xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID] = {\n isa: 'XCSwiftPackageProductDependency',\n package: sentrySwiftPackageUUID,\n package_comment: 'XCRemoteSwiftPackageReference \"sentry-cocoa\"',\n productName: 'Sentry',\n };\n xcObjects.XCSwiftPackageProductDependency[`${sentrySPMUUID}_comment`] =\n 'Sentry';\n\n clack.log.step('Added Sentry SPM dependency to your project');\n}\n\nfunction addUploadSymbolsScript(\n xcodeProject: Project,\n sentryProject: SentryProjectData,\n targetName: string,\n uploadSource: boolean,\n): void {\n const xcObjects = xcodeProject.hash.project.objects;\n if (!xcObjects.PBXNativeTarget) {\n xcObjects.PBXNativeTarget = {};\n }\n const targetKey = Object.keys(xcObjects.PBXNativeTarget).filter((key) => {\n const value = xcObjects.PBXNativeTarget?.[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value?.name === targetName\n );\n })[0];\n\n if (!xcObjects.PBXShellScriptBuildPhase) {\n xcObjects.PBXShellScriptBuildPhase = {};\n }\n for (const key in xcObjects.PBXShellScriptBuildPhase) {\n const value = xcObjects.PBXShellScriptBuildPhase[key] ?? {};\n if (typeof value === 'string') {\n // Ignore comments\n continue;\n }\n\n // Sentry script already exists, update it\n if (value.shellScript?.includes('sentry-cli')) {\n delete xcObjects.PBXShellScriptBuildPhase?.[key];\n delete xcObjects.PBXShellScriptBuildPhase?.[`${key}_comment`];\n break;\n }\n xcObjects.PBXShellScriptBuildPhase[key] = value;\n }\n\n const isHomebrewInstalled = fs.existsSync('/opt/homebrew/bin/sentry-cli');\n xcodeProject.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n targetKey,\n {\n inputFileListPaths: [],\n outputFileListPaths: [],\n inputPaths: [templates.scriptInputPath],\n shellPath: '/bin/sh',\n shellScript: templates.getRunScriptTemplate(\n sentryProject.organization.slug,\n sentryProject.slug,\n uploadSource,\n isHomebrewInstalled,\n ),\n },\n );\n clack.log.step(`Added Sentry upload script to \"${targetName}\" build phase`);\n}\n\nexport class XcodeProject {\n projectPath: string;\n project: Project;\n objects: PBXObjects;\n files: ProjectFile[] | undefined;\n\n /**\n * Creates a new XcodeProject instance, a wrapper around the Xcode project file `<PROJECT>.xcodeproj/project.pbxproj`.\n *\n * @param projectPath - The path to the Xcode project file\n */\n public constructor(projectPath: string) {\n this.projectPath = projectPath;\n this.project = createXcodeProject(projectPath);\n this.project.parseSync();\n this.objects = this.project.hash.project.objects;\n }\n\n public getAllTargets(): string[] {\n const targets = this.objects.PBXNativeTarget ?? {};\n return Object.keys(targets)\n .filter((key) => {\n const value = targets[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value.productType.startsWith('\"com.apple.product-type.application')\n );\n })\n .map((key) => {\n return (targets[key] as PBXNativeTarget).name;\n });\n }\n\n public updateXcodeProject(\n sentryProject: SentryProjectData,\n target: string,\n addSPMReference: boolean,\n uploadSource = true,\n ): void {\n addUploadSymbolsScript(this.project, sentryProject, target, uploadSource);\n if (uploadSource) {\n setDebugInformationFormatAndSandbox(this.project, target);\n }\n if (addSPMReference) {\n addSentrySPM(this.project, target);\n }\n const newContent = this.project.writeSync();\n fs.writeFileSync(this.projectPath, newContent);\n }\n\n public filesForTarget(target: string): string[] | undefined {\n const files = this.projectFiles();\n const fileDictionary: Record<string, string> = {};\n files.forEach((file) => {\n fileDictionary[file.key] = file.path;\n });\n\n const targets = this.objects.PBXNativeTarget || {};\n const nativeTarget = Object.keys(targets).filter((key) => {\n const value = targets[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value.name === target\n );\n })[0];\n\n if (nativeTarget === undefined) {\n return undefined;\n }\n\n const buildPhaseKey = (\n targets[nativeTarget] as PBXNativeTarget\n ).buildPhases?.filter((phase) => {\n return this.objects.PBXSourcesBuildPhase?.[phase.value] !== undefined;\n })[0];\n\n if (buildPhaseKey === undefined) {\n return undefined;\n }\n\n const buildPhase = this.objects.PBXSourcesBuildPhase?.[\n buildPhaseKey.value\n ] as PBXSourcesBuildPhase;\n const buildPhaseFiles = buildPhase?.files ?? [];\n\n const baseDir = path.dirname(path.dirname(this.projectPath));\n\n return buildPhaseFiles\n .map((file) => {\n const fileRef = (\n this.objects.PBXBuildFile?.[file.value] as PBXBuildFile\n )?.fileRef;\n if (!fileRef) {\n return '';\n }\n const buildFile = fileDictionary[fileRef];\n if (!buildFile) {\n return '';\n }\n return path.join(baseDir, buildFile);\n })\n .filter((f: string) => f.length > 0);\n }\n\n projectFiles(): ProjectFile[] {\n if (this.files === undefined) {\n const proj = this.project.getFirstProject();\n const mainGroupKey = proj.firstProject.mainGroup;\n const mainGroup = this.objects.PBXGroup?.[mainGroupKey];\n if (!mainGroup || typeof mainGroup === 'string') {\n return [];\n }\n this.files = this.buildGroup(mainGroup);\n }\n return this.files;\n }\n\n buildGroup(group: PBXGroup, path = ''): ProjectFile[] {\n const result: ProjectFile[] = [];\n for (const child of group.children ?? []) {\n const fileReference = this.objects.PBXFileReference?.[child.value];\n const groupReference = this.objects.PBXGroup?.[child.value];\n if (fileReference) {\n if (typeof fileReference === 'string') {\n continue;\n }\n result.push({\n key: child.value,\n path: `${path}${fileReference.path.replace(/\"/g, '')}`,\n });\n } else if (groupReference) {\n if (typeof groupReference === 'string') {\n continue;\n }\n const groupChildren = this.buildGroup(\n groupReference,\n groupReference.path\n ? `${path}${groupReference.path.replace(/\"/g, '')}/`\n : path,\n );\n result.push(...groupChildren);\n }\n }\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"xcode-manager.js","sourceRoot":"","sources":["../../../src/apple/xcode-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+DAA+D;AAC/D,4DAA4D;AAC5D,sDAAsD;AACtD,+EAA+E;AAC/E,sDAAwC;AACxC,4CAA8B;AAC9B,gDAAkC;AAElC,uDAAyC;AAEzC,iCASe;AAOf,SAAS,mCAAmC,CAC1C,IAAa,EACb,UAAkB;IAElB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC5C,IAAI,CAA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cAAc,KAAK,QAAQ,EAAE;oBACtC,SAAS;iBACV;gBACD,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CACnC,cAAc,EACd,cAAc,CAAC,IAAI;oBACjB,CAAC,CAAC,GAAG,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG;oBACpD,CAAC,CAAC,IAAI,CACT,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;aAC/B;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAnJD,oCAmJC","sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport type { SentryProjectData } from '../utils/types';\nimport * as templates from './templates';\n\nimport {\n project as createXcodeProject,\n type PBXBuildFile,\n type PBXGroup,\n type PBXNativeTarget,\n type PBXObjects,\n type PBXSourcesBuildPhase,\n type Project,\n type XCConfigurationList,\n} from 'xcode';\n\ninterface ProjectFile {\n key: string;\n path: string;\n}\n\nfunction setDebugInformationFormatAndSandbox(\n proj: Project,\n targetName: string,\n): void {\n const xcObjects = proj.hash.project.objects;\n if (!xcObjects.PBXNativeTarget) {\n xcObjects.PBXNativeTarget = {};\n }\n const targetKey: string = Object.keys(xcObjects.PBXNativeTarget).filter(\n (key) => {\n const value = xcObjects.PBXNativeTarget?.[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value?.name === targetName\n );\n },\n )[0];\n const target = xcObjects.PBXNativeTarget[targetKey] as\n | PBXNativeTarget\n | undefined;\n\n if (!xcObjects.XCBuildConfiguration) {\n xcObjects.XCBuildConfiguration = {};\n }\n if (!xcObjects.XCConfigurationList) {\n xcObjects.XCConfigurationList = {};\n }\n const buildConfigurationListId = target?.buildConfigurationList ?? '';\n const configurationList = xcObjects.XCConfigurationList?.[\n buildConfigurationListId\n ] as XCConfigurationList | undefined;\n const buildListConfigurationIds =\n configurationList?.buildConfigurations ?? [];\n for (const buildListConfigId of buildListConfigurationIds) {\n const config =\n xcObjects.XCBuildConfiguration[buildListConfigId.value] ?? {};\n if (typeof config === 'string') {\n // Ignore comments\n continue;\n }\n\n const buildSettings = config.buildSettings ?? {};\n buildSettings.DEBUG_INFORMATION_FORMAT = '\"dwarf-with-dsym\"';\n buildSettings.ENABLE_USER_SCRIPT_SANDBOXING = '\"NO\"';\n\n config.buildSettings = buildSettings;\n xcObjects.XCBuildConfiguration[buildListConfigId.value] = config;\n }\n}\n\nfunction addSentrySPM(proj: Project, targetName: string): void {\n const xcObjects = proj.hash.project.objects;\n\n const sentryFrameworkUUID = proj.generateUuid();\n const sentrySPMUUID = proj.generateUuid();\n\n // Check whether xcObjects already have sentry framework\n if (xcObjects.PBXFrameworksBuildPhase) {\n for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {\n const frameworkBuildPhase = xcObjects.PBXFrameworksBuildPhase[key];\n if (key.endsWith('_comment') || typeof frameworkBuildPhase === 'string') {\n // Ignore comments\n continue;\n }\n for (const framework of frameworkBuildPhase.files ?? []) {\n // We identify the Sentry framework by the comment \"Sentry in Frameworks\",\n // which is set by this manager in previous runs.\n if (framework.comment === 'Sentry in Frameworks') {\n return;\n }\n }\n }\n }\n\n if (!xcObjects.PBXBuildFile) {\n xcObjects.PBXBuildFile = {};\n }\n xcObjects.PBXBuildFile[sentryFrameworkUUID] = {\n isa: 'PBXBuildFile',\n productRef: sentrySPMUUID,\n productRef_comment: 'Sentry',\n };\n xcObjects.PBXBuildFile[`${sentryFrameworkUUID}_comment`] =\n 'Sentry in Frameworks';\n\n if (!xcObjects.PBXFrameworksBuildPhase) {\n xcObjects.PBXFrameworksBuildPhase = {};\n }\n for (const key in xcObjects.PBXFrameworksBuildPhase) {\n const value = xcObjects.PBXFrameworksBuildPhase[key];\n if (key.endsWith('_comment') || typeof value === 'string') {\n // Ignore comments\n continue;\n }\n\n const frameworks = value.files ?? [];\n frameworks.push({\n value: sentryFrameworkUUID,\n comment: 'Sentry in Frameworks',\n });\n value.files = frameworks;\n\n xcObjects.PBXFrameworksBuildPhase[key] = value;\n }\n\n if (!xcObjects.PBXNativeTarget) {\n xcObjects.PBXNativeTarget = {};\n }\n const targetKey = Object.keys(xcObjects.PBXNativeTarget || {}).filter(\n (key) => {\n const value = xcObjects.PBXNativeTarget?.[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value?.name === targetName\n );\n },\n )[0];\n const target = xcObjects.PBXNativeTarget[targetKey] as PBXNativeTarget;\n\n if (!target.packageProductDependencies) {\n target.packageProductDependencies = [];\n }\n target.packageProductDependencies.push({\n value: sentrySPMUUID,\n comment: 'Sentry',\n });\n\n const sentrySwiftPackageUUID = proj.generateUuid();\n const xcProject = proj.getFirstProject().firstProject;\n if (!xcProject.packageReferences) {\n xcProject.packageReferences = [];\n }\n xcProject.packageReferences.push({\n value: sentrySwiftPackageUUID,\n comment: 'XCRemoteSwiftPackageReference \"sentry-cocoa\"',\n });\n\n if (!xcObjects.XCRemoteSwiftPackageReference) {\n xcObjects.XCRemoteSwiftPackageReference = {};\n }\n\n xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID] = {\n isa: 'XCRemoteSwiftPackageReference',\n repositoryURL: '\"https://github.com/getsentry/sentry-cocoa/\"',\n requirement: {\n kind: 'upToNextMajorVersion',\n minimumVersion: '8.0.0',\n },\n };\n xcObjects.XCRemoteSwiftPackageReference[`${sentrySwiftPackageUUID}_comment`] =\n 'XCRemoteSwiftPackageReference \"sentry-cocoa\"';\n\n if (!xcObjects.XCSwiftPackageProductDependency) {\n xcObjects.XCSwiftPackageProductDependency = {};\n }\n xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID] = {\n isa: 'XCSwiftPackageProductDependency',\n package: sentrySwiftPackageUUID,\n package_comment: 'XCRemoteSwiftPackageReference \"sentry-cocoa\"',\n productName: 'Sentry',\n };\n xcObjects.XCSwiftPackageProductDependency[`${sentrySPMUUID}_comment`] =\n 'Sentry';\n\n clack.log.step('Added Sentry SPM dependency to your project');\n}\n\nfunction addUploadSymbolsScript(\n xcodeProject: Project,\n sentryProject: SentryProjectData,\n targetName: string,\n uploadSource: boolean,\n): void {\n const xcObjects = xcodeProject.hash.project.objects;\n if (!xcObjects.PBXNativeTarget) {\n xcObjects.PBXNativeTarget = {};\n }\n const targetKey = Object.keys(xcObjects.PBXNativeTarget).filter((key) => {\n const value = xcObjects.PBXNativeTarget?.[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value?.name === targetName\n );\n })[0];\n\n if (!xcObjects.PBXShellScriptBuildPhase) {\n xcObjects.PBXShellScriptBuildPhase = {};\n }\n for (const key in xcObjects.PBXShellScriptBuildPhase) {\n const value = xcObjects.PBXShellScriptBuildPhase[key] ?? {};\n if (typeof value === 'string') {\n // Ignore comments\n continue;\n }\n\n // Sentry script already exists, update it\n if (value.shellScript?.includes('sentry-cli')) {\n delete xcObjects.PBXShellScriptBuildPhase?.[key];\n delete xcObjects.PBXShellScriptBuildPhase?.[`${key}_comment`];\n break;\n }\n xcObjects.PBXShellScriptBuildPhase[key] = value;\n }\n\n const isHomebrewInstalled = fs.existsSync('/opt/homebrew/bin/sentry-cli');\n xcodeProject.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n targetKey,\n {\n inputFileListPaths: [],\n outputFileListPaths: [],\n inputPaths: [templates.scriptInputPath],\n shellPath: '/bin/sh',\n shellScript: templates.getRunScriptTemplate(\n sentryProject.organization.slug,\n sentryProject.slug,\n uploadSource,\n isHomebrewInstalled,\n ),\n },\n );\n clack.log.step(`Added Sentry upload script to \"${targetName}\" build phase`);\n}\n\nexport class XcodeProject {\n projectPath: string;\n project: Project;\n objects: PBXObjects;\n files: ProjectFile[] | undefined;\n\n /**\n * Creates a new XcodeProject instance, a wrapper around the Xcode project file `<PROJECT>.xcodeproj/project.pbxproj`.\n *\n * @param projectPath - The path to the Xcode project file\n */\n public constructor(projectPath: string) {\n this.projectPath = projectPath;\n this.project = createXcodeProject(projectPath);\n this.project.parseSync();\n this.objects = this.project.hash.project.objects;\n }\n\n public getAllTargets(): string[] {\n const targets = this.objects.PBXNativeTarget ?? {};\n return Object.keys(targets)\n .filter((key) => {\n const value = targets[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value.productType.startsWith('\"com.apple.product-type.application')\n );\n })\n .map((key) => {\n return (targets[key] as PBXNativeTarget).name;\n });\n }\n\n public updateXcodeProject(\n sentryProject: SentryProjectData,\n target: string,\n addSPMReference: boolean,\n uploadSource = true,\n ): void {\n addUploadSymbolsScript(this.project, sentryProject, target, uploadSource);\n if (uploadSource) {\n setDebugInformationFormatAndSandbox(this.project, target);\n }\n if (addSPMReference) {\n addSentrySPM(this.project, target);\n }\n const newContent = this.project.writeSync();\n fs.writeFileSync(this.projectPath, newContent);\n }\n\n public filesForTarget(target: string): string[] | undefined {\n const files = this.projectFiles();\n const fileDictionary: Record<string, string> = {};\n files.forEach((file) => {\n fileDictionary[file.key] = file.path;\n });\n\n const targets = this.objects.PBXNativeTarget || {};\n const nativeTarget = Object.keys(targets).filter((key) => {\n const value = targets[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value.name === target\n );\n })[0];\n\n if (nativeTarget === undefined) {\n return undefined;\n }\n\n const buildPhaseKey = (\n targets[nativeTarget] as PBXNativeTarget\n ).buildPhases?.filter((phase) => {\n return this.objects.PBXSourcesBuildPhase?.[phase.value] !== undefined;\n })[0];\n\n if (buildPhaseKey === undefined) {\n return undefined;\n }\n\n const buildPhase = this.objects.PBXSourcesBuildPhase?.[\n buildPhaseKey.value\n ] as PBXSourcesBuildPhase;\n const buildPhaseFiles = buildPhase?.files ?? [];\n\n const baseDir = path.dirname(path.dirname(this.projectPath));\n\n return buildPhaseFiles\n .map((file) => {\n const fileRef = (\n this.objects.PBXBuildFile?.[file.value] as PBXBuildFile\n )?.fileRef;\n if (!fileRef) {\n return '';\n }\n const buildFile = fileDictionary[fileRef];\n if (!buildFile) {\n return '';\n }\n return path.join(baseDir, buildFile);\n })\n .filter((f: string) => f.length > 0);\n }\n\n projectFiles(): ProjectFile[] {\n if (this.files === undefined) {\n const proj = this.project.getFirstProject();\n const mainGroupKey = proj.firstProject.mainGroup;\n const mainGroup = this.objects.PBXGroup?.[mainGroupKey];\n if (!mainGroup || typeof mainGroup === 'string') {\n return [];\n }\n this.files = this.buildGroup(mainGroup);\n }\n return this.files;\n }\n\n buildGroup(group: PBXGroup, path = ''): ProjectFile[] {\n const result: ProjectFile[] = [];\n for (const child of group.children ?? []) {\n const fileReference = this.objects.PBXFileReference?.[child.value];\n const groupReference = this.objects.PBXGroup?.[child.value];\n if (fileReference) {\n if (typeof fileReference === 'string') {\n continue;\n }\n result.push({\n key: child.value,\n path: `${path}${fileReference.path.replace(/\"/g, '')}`,\n });\n } else if (groupReference) {\n if (typeof groupReference === 'string') {\n continue;\n }\n const groupChildren = this.buildGroup(\n groupReference,\n groupReference.path\n ? `${path}${groupReference.path.replace(/\"/g, '')}/`\n : path,\n );\n result.push(...groupChildren);\n }\n }\n return result;\n }\n}\n"]}
@@ -30,11 +30,11 @@ exports.getDevDependenciesLocation = exports.getDependenciesLocation = exports.g
30
30
  const fs = __importStar(require("fs"));
31
31
  const path = __importStar(require("path"));
32
32
  const Sentry = __importStar(require("@sentry/node"));
33
- // @ts-ignore - clack is ESM and TS complains about that. It works though
33
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
34
34
  const clack = __importStar(require("@clack/prompts"));
35
35
  const chalk_1 = __importDefault(require("chalk"));
36
36
  const templates_1 = require("./templates");
37
- const clack_utils_1 = require("../utils/clack-utils");
37
+ const clack_1 = require("../utils/clack");
38
38
  /**
39
39
  * Recursively finds a file per name in subfolders.
40
40
  * @param dir - The directory to start searching.
@@ -156,7 +156,7 @@ async function patchMain(mainFile, dsn, canEnableProfiling) {
156
156
  enabledHint: 'recommended, tracing must be enabled',
157
157
  });
158
158
  }
159
- const selectedFeatures = await (0, clack_utils_1.featureSelectionPrompt)(features);
159
+ const selectedFeatures = await (0, clack_1.featureSelectionPrompt)(features);
160
160
  const normalizedSelectedFeatures = {
161
161
  tracing: selectedFeatures.tracing ?? false,
162
162
  profiling: selectedFeatures.profiling ?? false,
@@ -1 +1 @@
1
- {"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/flutter/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,qDAAuC;AACvC,yEAAyE;AACzE,sDAAwC;AACxC,kDAA0B;AAC1B,2CAKqB;AACrB,sDAA8D;AAE9D;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,IAAY;IAChD,MAAM,KAAK,GAAa,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,QAAQ,GAAW,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAa,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;YACvB,MAAM,MAAM,GAAkB,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACvD,IAAI,MAAM,EAAE;gBACV,OAAO,MAAM,CAAC;aACf;SACF;aAAM,IAAI,IAAI,KAAK,IAAI,EAAE;YACxB,OAAO,QAAQ,CAAC;SACjB;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAlBD,4BAkBC;AAED,SAAgB,YAAY,CAC1B,WAA0B,EAC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AC,CAAC;KACjC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as Sentry from '@sentry/node';\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport {\n sentryImport,\n pubspecOptions,\n sentryProperties,\n initSnippet,\n} from './templates';\nimport { featureSelectionPrompt } from '../utils/clack-utils';\n\n/**\n * Recursively finds a file per name in subfolders.\n * @param dir - The directory to start searching.\n * @param name - The name of the file including path extension.\n * @returns The path to the main.dart file or null if not found.\n */\nexport function findFile(dir: string, name: string): string | null {\n const files: string[] = fs.readdirSync(dir);\n\n for (const file of files) {\n const fullPath: string = path.join(dir, file);\n const stats: fs.Stats = fs.statSync(fullPath);\n\n if (stats.isDirectory()) {\n const result: string | null = findFile(fullPath, name);\n if (result) {\n return result;\n }\n } else if (file === name) {\n return fullPath;\n }\n }\n\n return null;\n}\n\nexport function patchPubspec(\n pubspecFile: string | null,\n sentryDartFlutterVersion: string,\n sentryDartPluginVersion: string,\n project: string,\n org: string,\n): boolean {\n try {\n if (!pubspecFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n let pubspecContent = fs.readFileSync(pubspecFile, 'utf8');\n\n if (!pubspecContent.includes('sentry_flutter:')) {\n const dependenciesIndex = getDependenciesLocation(pubspecContent);\n\n pubspecContent =\n pubspecContent.slice(0, dependenciesIndex) +\n ` sentry_flutter: ${sentryDartFlutterVersion}\\n` +\n pubspecContent.slice(dependenciesIndex);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_flutter')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_flutter')} is already included in pubspec.yaml`,\n ),\n );\n }\n\n if (!pubspecContent.includes('sentry_dart_plugin:')) {\n const devDependenciesIndex = getDevDependenciesLocation(pubspecContent);\n pubspecContent =\n pubspecContent.slice(0, devDependenciesIndex) +\n ` sentry_dart_plugin: ${sentryDartPluginVersion}\\n` +\n pubspecContent.slice(devDependenciesIndex);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_dart_plugin')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold(\n 'sentry_dart_plugin',\n )} is already included in pubspec.yaml`,\n ),\n );\n }\n\n if (!pubspecContent.includes('sentry:')) {\n pubspecContent += '\\n';\n pubspecContent += pubspecOptions(project, org);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry plugin configuration')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold(\n 'sentry plugin configuration',\n )} is already included in pubspec.yaml`,\n ),\n );\n }\n\n fs.writeFileSync(pubspecFile, pubspecContent, 'utf8');\n\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport function addProperties(pubspecFile: string | null, authToken: string) {\n try {\n if (!pubspecFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n const pubspecDir = path.dirname(pubspecFile);\n const sentryPropertiesFileName = 'sentry.properties';\n const sentryPropertiesFile = path.join(\n pubspecDir,\n sentryPropertiesFileName,\n );\n const sentryPropertiesContent = sentryProperties(authToken);\n\n fs.writeFileSync(sentryPropertiesFile, sentryPropertiesContent, 'utf8');\n\n const gitignoreFile = path.join(pubspecDir, '.gitignore');\n if (fs.existsSync(gitignoreFile)) {\n fs.appendFileSync(gitignoreFile, `\\n${sentryPropertiesFileName}\\n`);\n } else {\n fs.writeFileSync(gitignoreFile, `${sentryPropertiesFileName}\\n`, 'utf8');\n }\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport async function patchMain(\n mainFile: string | null,\n dsn: string,\n canEnableProfiling: boolean,\n): Promise<boolean> {\n try {\n if (!mainFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n let mainContent = fs.readFileSync(mainFile, 'utf8');\n if (\n /import\\s+['\"]package[:]sentry_flutter\\/sentry_flutter\\.dart['\"];?/i.test(\n mainContent,\n )\n ) {\n // sentry is already configured\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('main.dart')} already has Sentry configured.`,\n ),\n );\n return true;\n }\n\n const features = [\n {\n id: 'tracing',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n ];\n if (canEnableProfiling) {\n features.push({\n id: 'profiling',\n prompt: `Do you want to enable ${chalk.bold(\n 'Profiling',\n )} to analyze CPU usage and optimize performance-critical code on iOS & macOS?`,\n enabledHint: 'recommended, tracing must be enabled',\n });\n }\n\n const selectedFeatures = await featureSelectionPrompt(features);\n const normalizedSelectedFeatures = {\n tracing: selectedFeatures.tracing ?? false,\n profiling: selectedFeatures.profiling ?? false,\n };\n mainContent = patchMainContent(\n dsn,\n mainContent,\n normalizedSelectedFeatures,\n );\n\n fs.writeFileSync(mainFile, mainContent, 'utf8');\n\n clack.log.success(\n chalk.greenBright(\n `Patched ${chalk.bold(\n 'main.dart',\n )} with the Sentry setup and test error snippet.`,\n ),\n );\n\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('main.dart')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport function patchMainContent(\n dsn: string,\n mainContent: string,\n selectedFeatures: {\n tracing: boolean;\n profiling: boolean;\n },\n): string {\n const importIndex = getLastImportLineLocation(mainContent);\n mainContent =\n mainContent.slice(0, importIndex) +\n sentryImport +\n mainContent.slice(importIndex);\n\n // Find and replace `runApp(...)`\n mainContent = mainContent.replace(\n /runApp\\(([\\s\\S]*?)\\);/g, // Match the `runApp(...)` invocation\n (_, runAppArgs) => initSnippet(dsn, selectedFeatures, runAppArgs as string),\n );\n\n // Make the `main` function async if it's not already\n mainContent = mainContent.replace(\n /void\\s+main\\(\\)\\s*\\{/g,\n 'Future<void> main() async {',\n );\n\n return mainContent;\n}\n\nexport function getLastImportLineLocation(sourceCode: string): number {\n const importRegex = /import\\s+['\"].*['\"].*;/gim;\n return getLastReqExpLocation(sourceCode, importRegex);\n}\n\nexport function getDependenciesLocation(sourceCode: string): number {\n const dependencyRegex = /^dependencies:\\s*$/gim;\n return getLastReqExpLocation(sourceCode, dependencyRegex);\n}\n\nexport function getDevDependenciesLocation(sourceCode: string): number {\n const dependencyRegex = /^dev_dependencies:\\s*$/gim;\n return getLastReqExpLocation(sourceCode, dependencyRegex);\n}\n\n// Helper\n\nfunction getLastReqExpLocation(sourceCode: string, regExp: RegExp): number {\n let match = regExp.exec(sourceCode);\n let importIndex = 0;\n while (match) {\n importIndex = match.index + match[0].length + 1;\n match = regExp.exec(sourceCode);\n }\n return importIndex;\n}\n"]}
1
+ {"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/flutter/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,qDAAuC;AACvC,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,2CAKqB;AACrB,0CAAwD;AAExD;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,IAAY;IAChD,MAAM,KAAK,GAAa,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,QAAQ,GAAW,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAa,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;YACvB,MAAM,MAAM,GAAkB,QAAQ,CAAC,QAAQ,EAAE,IAAI,C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,UAAU,CAAC,CAAC;IACpC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,OAAO,KAAK,EAAE;QACZ,WAAW,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAChD,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KACjC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as Sentry from '@sentry/node';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport {\n sentryImport,\n pubspecOptions,\n sentryProperties,\n initSnippet,\n} from './templates';\nimport { featureSelectionPrompt } from '../utils/clack';\n\n/**\n * Recursively finds a file per name in subfolders.\n * @param dir - The directory to start searching.\n * @param name - The name of the file including path extension.\n * @returns The path to the main.dart file or null if not found.\n */\nexport function findFile(dir: string, name: string): string | null {\n const files: string[] = fs.readdirSync(dir);\n\n for (const file of files) {\n const fullPath: string = path.join(dir, file);\n const stats: fs.Stats = fs.statSync(fullPath);\n\n if (stats.isDirectory()) {\n const result: string | null = findFile(fullPath, name);\n if (result) {\n return result;\n }\n } else if (file === name) {\n return fullPath;\n }\n }\n\n return null;\n}\n\nexport function patchPubspec(\n pubspecFile: string | null,\n sentryDartFlutterVersion: string,\n sentryDartPluginVersion: string,\n project: string,\n org: string,\n): boolean {\n try {\n if (!pubspecFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n let pubspecContent = fs.readFileSync(pubspecFile, 'utf8');\n\n if (!pubspecContent.includes('sentry_flutter:')) {\n const dependenciesIndex = getDependenciesLocation(pubspecContent);\n\n pubspecContent =\n pubspecContent.slice(0, dependenciesIndex) +\n ` sentry_flutter: ${sentryDartFlutterVersion}\\n` +\n pubspecContent.slice(dependenciesIndex);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_flutter')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_flutter')} is already included in pubspec.yaml`,\n ),\n );\n }\n\n if (!pubspecContent.includes('sentry_dart_plugin:')) {\n const devDependenciesIndex = getDevDependenciesLocation(pubspecContent);\n pubspecContent =\n pubspecContent.slice(0, devDependenciesIndex) +\n ` sentry_dart_plugin: ${sentryDartPluginVersion}\\n` +\n pubspecContent.slice(devDependenciesIndex);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_dart_plugin')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold(\n 'sentry_dart_plugin',\n )} is already included in pubspec.yaml`,\n ),\n );\n }\n\n if (!pubspecContent.includes('sentry:')) {\n pubspecContent += '\\n';\n pubspecContent += pubspecOptions(project, org);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry plugin configuration')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold(\n 'sentry plugin configuration',\n )} is already included in pubspec.yaml`,\n ),\n );\n }\n\n fs.writeFileSync(pubspecFile, pubspecContent, 'utf8');\n\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport function addProperties(pubspecFile: string | null, authToken: string) {\n try {\n if (!pubspecFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n const pubspecDir = path.dirname(pubspecFile);\n const sentryPropertiesFileName = 'sentry.properties';\n const sentryPropertiesFile = path.join(\n pubspecDir,\n sentryPropertiesFileName,\n );\n const sentryPropertiesContent = sentryProperties(authToken);\n\n fs.writeFileSync(sentryPropertiesFile, sentryPropertiesContent, 'utf8');\n\n const gitignoreFile = path.join(pubspecDir, '.gitignore');\n if (fs.existsSync(gitignoreFile)) {\n fs.appendFileSync(gitignoreFile, `\\n${sentryPropertiesFileName}\\n`);\n } else {\n fs.writeFileSync(gitignoreFile, `${sentryPropertiesFileName}\\n`, 'utf8');\n }\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport async function patchMain(\n mainFile: string | null,\n dsn: string,\n canEnableProfiling: boolean,\n): Promise<boolean> {\n try {\n if (!mainFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n let mainContent = fs.readFileSync(mainFile, 'utf8');\n if (\n /import\\s+['\"]package[:]sentry_flutter\\/sentry_flutter\\.dart['\"];?/i.test(\n mainContent,\n )\n ) {\n // sentry is already configured\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('main.dart')} already has Sentry configured.`,\n ),\n );\n return true;\n }\n\n const features = [\n {\n id: 'tracing',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n ];\n if (canEnableProfiling) {\n features.push({\n id: 'profiling',\n prompt: `Do you want to enable ${chalk.bold(\n 'Profiling',\n )} to analyze CPU usage and optimize performance-critical code on iOS & macOS?`,\n enabledHint: 'recommended, tracing must be enabled',\n });\n }\n\n const selectedFeatures = await featureSelectionPrompt(features);\n const normalizedSelectedFeatures = {\n tracing: selectedFeatures.tracing ?? false,\n profiling: selectedFeatures.profiling ?? false,\n };\n mainContent = patchMainContent(\n dsn,\n mainContent,\n normalizedSelectedFeatures,\n );\n\n fs.writeFileSync(mainFile, mainContent, 'utf8');\n\n clack.log.success(\n chalk.greenBright(\n `Patched ${chalk.bold(\n 'main.dart',\n )} with the Sentry setup and test error snippet.`,\n ),\n );\n\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('main.dart')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport function patchMainContent(\n dsn: string,\n mainContent: string,\n selectedFeatures: {\n tracing: boolean;\n profiling: boolean;\n },\n): string {\n const importIndex = getLastImportLineLocation(mainContent);\n mainContent =\n mainContent.slice(0, importIndex) +\n sentryImport +\n mainContent.slice(importIndex);\n\n // Find and replace `runApp(...)`\n mainContent = mainContent.replace(\n /runApp\\(([\\s\\S]*?)\\);/g, // Match the `runApp(...)` invocation\n (_, runAppArgs) => initSnippet(dsn, selectedFeatures, runAppArgs as string),\n );\n\n // Make the `main` function async if it's not already\n mainContent = mainContent.replace(\n /void\\s+main\\(\\)\\s*\\{/g,\n 'Future<void> main() async {',\n );\n\n return mainContent;\n}\n\nexport function getLastImportLineLocation(sourceCode: string): number {\n const importRegex = /import\\s+['\"].*['\"].*;/gim;\n return getLastReqExpLocation(sourceCode, importRegex);\n}\n\nexport function getDependenciesLocation(sourceCode: string): number {\n const dependencyRegex = /^dependencies:\\s*$/gim;\n return getLastReqExpLocation(sourceCode, dependencyRegex);\n}\n\nexport function getDevDependenciesLocation(sourceCode: string): number {\n const dependencyRegex = /^dev_dependencies:\\s*$/gim;\n return getLastReqExpLocation(sourceCode, dependencyRegex);\n}\n\n// Helper\n\nfunction getLastReqExpLocation(sourceCode: string, regExp: RegExp): number {\n let match = regExp.exec(sourceCode);\n let importIndex = 0;\n while (match) {\n importIndex = match.index + match[0].length + 1;\n match = regExp.exec(sourceCode);\n }\n return importIndex;\n}\n"]}