@sentry/wizard 3.39.0 → 3.41.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 (221) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/README.md +21 -21
  3. package/bin.ts +5 -0
  4. package/codecov.yml +15 -0
  5. package/dist/bin.js +4 -0
  6. package/dist/bin.js.map +1 -1
  7. package/dist/e2e-tests/jest.config.d.ts +1 -0
  8. package/dist/e2e-tests/jest.config.js +1 -0
  9. package/dist/e2e-tests/jest.config.js.map +1 -1
  10. package/dist/e2e-tests/tests/flutter.test.d.ts +1 -0
  11. package/dist/e2e-tests/tests/flutter.test.js +190 -0
  12. package/dist/e2e-tests/tests/flutter.test.js.map +1 -0
  13. package/dist/e2e-tests/utils/index.d.ts +11 -0
  14. package/dist/e2e-tests/utils/index.js +36 -1
  15. package/dist/e2e-tests/utils/index.js.map +1 -1
  16. package/dist/lib/Constants.d.ts +1 -0
  17. package/dist/lib/Constants.js +5 -0
  18. package/dist/lib/Constants.js.map +1 -1
  19. package/dist/package.json +3 -2
  20. package/dist/src/apple/apple-wizard.js +2 -3
  21. package/dist/src/apple/apple-wizard.js.map +1 -1
  22. package/dist/src/apple/code-tools.d.ts +10 -0
  23. package/dist/src/apple/code-tools.js +16 -12
  24. package/dist/src/apple/code-tools.js.map +1 -1
  25. package/dist/src/apple/fastlane.d.ts +23 -0
  26. package/dist/src/apple/fastlane.js +11 -7
  27. package/dist/src/apple/fastlane.js.map +1 -1
  28. package/dist/src/apple/templates.d.ts +1 -1
  29. package/dist/src/apple/templates.js +0 -2
  30. package/dist/src/apple/templates.js.map +1 -1
  31. package/dist/src/apple/xcode-manager.d.ts +13 -9
  32. package/dist/src/apple/xcode-manager.js +146 -61
  33. package/dist/src/apple/xcode-manager.js.map +1 -1
  34. package/dist/src/flutter/code-tools.d.ts +17 -0
  35. package/dist/src/flutter/code-tools.js +263 -0
  36. package/dist/src/flutter/code-tools.js.map +1 -0
  37. package/dist/src/flutter/flutter-wizard.d.ts +2 -0
  38. package/dist/src/flutter/flutter-wizard.js +171 -0
  39. package/dist/src/flutter/flutter-wizard.js.map +1 -0
  40. package/dist/src/flutter/templates.d.ts +9 -0
  41. package/dist/src/flutter/templates.js +40 -0
  42. package/dist/src/flutter/templates.js.map +1 -0
  43. package/dist/src/nextjs/nextjs-wizard.js +5 -3
  44. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  45. package/dist/src/nuxt/nuxt-wizard.js +6 -4
  46. package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
  47. package/dist/src/nuxt/sdk-setup.d.ts +1 -1
  48. package/dist/src/nuxt/sdk-setup.js +2 -1
  49. package/dist/src/nuxt/sdk-setup.js.map +1 -1
  50. package/dist/src/react-native/react-native-wizard.js +5 -3
  51. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  52. package/dist/src/remix/remix-wizard.js +5 -3
  53. package/dist/src/remix/remix-wizard.js.map +1 -1
  54. package/dist/src/run.d.ts +2 -1
  55. package/dist/src/run.js +40 -32
  56. package/dist/src/run.js.map +1 -1
  57. package/dist/src/sveltekit/sveltekit-wizard.js +5 -3
  58. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  59. package/dist/src/utils/clack-utils.d.ts +4 -2
  60. package/dist/src/utils/clack-utils.js +18 -12
  61. package/dist/src/utils/clack-utils.js.map +1 -1
  62. package/dist/src/utils/package-manager.d.ts +1 -0
  63. package/dist/src/utils/package-manager.js +5 -0
  64. package/dist/src/utils/package-manager.js.map +1 -1
  65. package/dist/src/utils/types.d.ts +9 -0
  66. package/dist/src/utils/types.js.map +1 -1
  67. package/dist/test/apple/cocoapod.test.d.ts +1 -0
  68. package/dist/test/apple/cocoapod.test.js +409 -0
  69. package/dist/test/apple/cocoapod.test.js.map +1 -0
  70. package/dist/test/apple/code-tools.test.d.ts +1 -0
  71. package/dist/test/apple/code-tools.test.js +673 -0
  72. package/dist/test/apple/code-tools.test.js.map +1 -0
  73. package/dist/test/apple/fastfile.test.d.ts +1 -0
  74. package/dist/test/apple/fastfile.test.js +431 -0
  75. package/dist/test/apple/fastfile.test.js.map +1 -0
  76. package/dist/test/apple/templates.test.d.ts +1 -0
  77. package/dist/test/apple/templates.test.js +73 -0
  78. package/dist/test/apple/templates.test.js.map +1 -0
  79. package/dist/test/apple/xcode-manager.test.d.ts +1 -0
  80. package/dist/test/apple/xcode-manager.test.js +834 -0
  81. package/dist/test/apple/xcode-manager.test.js.map +1 -0
  82. package/dist/test/flutter/code-tools.test.d.ts +1 -0
  83. package/dist/test/flutter/code-tools.test.js +84 -0
  84. package/dist/test/flutter/code-tools.test.js.map +1 -0
  85. package/dist/test/flutter/templates.test.d.ts +1 -0
  86. package/dist/test/flutter/templates.test.js +41 -0
  87. package/dist/test/flutter/templates.test.js.map +1 -0
  88. package/dist/test/utils/clack-utils.test.js +89 -0
  89. package/dist/test/utils/clack-utils.test.js.map +1 -1
  90. package/e2e-tests/README.md +5 -1
  91. package/e2e-tests/jest.config.ts +1 -0
  92. package/e2e-tests/test-applications/apple/damaged-missing-configuration-list/Project.xcodeproj/project.pbxproj +52 -0
  93. package/e2e-tests/test-applications/apple/damaged-missing-configuration-list/Project.xcodeproj/xcshareddata/xcschemes/Project1.xcscheme +78 -0
  94. package/e2e-tests/test-applications/apple/no-targets/Project.xcodeproj/project.pbxproj +62 -0
  95. package/e2e-tests/test-applications/apple/no-targets/Project.xcodeproj/xcshareddata/xcschemes/Project1.xcscheme +78 -0
  96. package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project.xcodeproj/project.pbxproj +470 -0
  97. package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project.xcodeproj/xcshareddata/xcschemes/Project1.xcscheme +78 -0
  98. package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project1/ContentView.swift +7 -0
  99. package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project1/Project1App.swift +10 -0
  100. package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project2/ContentView.swift +7 -0
  101. package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project2/Project2App.swift +10 -0
  102. package/e2e-tests/test-applications/apple/spm-swiftui-single-target/Project.xcodeproj/project.pbxproj +382 -0
  103. package/e2e-tests/test-applications/apple/spm-swiftui-single-target/Project.xcodeproj/xcshareddata/xcschemes/Project.xcscheme +78 -0
  104. package/e2e-tests/test-applications/apple/spm-swiftui-single-target/Sources/ContentView.swift +7 -0
  105. package/e2e-tests/test-applications/apple/spm-swiftui-single-target/Sources/MainApp.swift +10 -0
  106. package/e2e-tests/test-applications/flutter-test-app/.metadata +45 -0
  107. package/e2e-tests/test-applications/flutter-test-app/README.md +16 -0
  108. package/e2e-tests/test-applications/flutter-test-app/analysis_options.yaml +28 -0
  109. package/e2e-tests/test-applications/flutter-test-app/android/app/build.gradle +44 -0
  110. package/e2e-tests/test-applications/flutter-test-app/android/app/src/debug/AndroidManifest.xml +7 -0
  111. package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/AndroidManifest.xml +45 -0
  112. package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/kotlin/com/example/flutter_magic/MainActivity.kt +5 -0
  113. package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/drawable/launch_background.xml +12 -0
  114. package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/drawable-v21/launch_background.xml +12 -0
  115. package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  116. package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  117. package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  118. package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  119. package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  120. package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/values/styles.xml +18 -0
  121. package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/values-night/styles.xml +18 -0
  122. package/e2e-tests/test-applications/flutter-test-app/android/app/src/profile/AndroidManifest.xml +7 -0
  123. package/e2e-tests/test-applications/flutter-test-app/android/build.gradle +18 -0
  124. package/e2e-tests/test-applications/flutter-test-app/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  125. package/e2e-tests/test-applications/flutter-test-app/android/gradle.properties +3 -0
  126. package/e2e-tests/test-applications/flutter-test-app/android/settings.gradle +25 -0
  127. package/e2e-tests/test-applications/flutter-test-app/lib/main.dart +125 -0
  128. package/e2e-tests/test-applications/flutter-test-app/linux/CMakeLists.txt +145 -0
  129. package/e2e-tests/test-applications/flutter-test-app/linux/flutter/CMakeLists.txt +88 -0
  130. package/e2e-tests/test-applications/flutter-test-app/linux/flutter/generated_plugin_registrant.cc +11 -0
  131. package/e2e-tests/test-applications/flutter-test-app/linux/flutter/generated_plugin_registrant.h +15 -0
  132. package/e2e-tests/test-applications/flutter-test-app/linux/flutter/generated_plugins.cmake +23 -0
  133. package/e2e-tests/test-applications/flutter-test-app/linux/main.cc +6 -0
  134. package/e2e-tests/test-applications/flutter-test-app/linux/my_application.cc +124 -0
  135. package/e2e-tests/test-applications/flutter-test-app/linux/my_application.h +18 -0
  136. package/e2e-tests/test-applications/flutter-test-app/macos/Flutter/Flutter-Debug.xcconfig +2 -0
  137. package/e2e-tests/test-applications/flutter-test-app/macos/Flutter/Flutter-Release.xcconfig +2 -0
  138. package/e2e-tests/test-applications/flutter-test-app/macos/Flutter/GeneratedPluginRegistrant.swift +10 -0
  139. package/e2e-tests/test-applications/flutter-test-app/macos/Podfile +43 -0
  140. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/AppDelegate.swift +9 -0
  141. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
  142. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png +0 -0
  143. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png +0 -0
  144. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png +0 -0
  145. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png +0 -0
  146. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png +0 -0
  147. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png +0 -0
  148. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png +0 -0
  149. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Base.lproj/MainMenu.xib +343 -0
  150. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Configs/AppInfo.xcconfig +14 -0
  151. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Configs/Debug.xcconfig +2 -0
  152. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Configs/Release.xcconfig +2 -0
  153. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Configs/Warnings.xcconfig +13 -0
  154. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/DebugProfile.entitlements +12 -0
  155. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Info.plist +32 -0
  156. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/MainFlutterWindow.swift +15 -0
  157. package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Release.entitlements +8 -0
  158. package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcodeproj/project.pbxproj +705 -0
  159. package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  160. package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +98 -0
  161. package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcworkspace/contents.xcworkspacedata +7 -0
  162. package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  163. package/e2e-tests/test-applications/flutter-test-app/macos/RunnerTests/RunnerTests.swift +12 -0
  164. package/e2e-tests/test-applications/flutter-test-app/pubspec.lock +213 -0
  165. package/e2e-tests/test-applications/flutter-test-app/pubspec.yaml +89 -0
  166. package/e2e-tests/test-applications/flutter-test-app/test/widget_test.dart +30 -0
  167. package/e2e-tests/test-applications/flutter-test-app/web/favicon.png +0 -0
  168. package/e2e-tests/test-applications/flutter-test-app/web/icons/Icon-192.png +0 -0
  169. package/e2e-tests/test-applications/flutter-test-app/web/icons/Icon-512.png +0 -0
  170. package/e2e-tests/test-applications/flutter-test-app/web/icons/Icon-maskable-192.png +0 -0
  171. package/e2e-tests/test-applications/flutter-test-app/web/icons/Icon-maskable-512.png +0 -0
  172. package/e2e-tests/test-applications/flutter-test-app/web/index.html +38 -0
  173. package/e2e-tests/test-applications/flutter-test-app/web/manifest.json +35 -0
  174. package/e2e-tests/test-applications/flutter-test-app/windows/CMakeLists.txt +108 -0
  175. package/e2e-tests/test-applications/flutter-test-app/windows/flutter/CMakeLists.txt +109 -0
  176. package/e2e-tests/test-applications/flutter-test-app/windows/flutter/generated_plugin_registrant.cc +11 -0
  177. package/e2e-tests/test-applications/flutter-test-app/windows/flutter/generated_plugin_registrant.h +15 -0
  178. package/e2e-tests/test-applications/flutter-test-app/windows/flutter/generated_plugins.cmake +23 -0
  179. package/e2e-tests/test-applications/flutter-test-app/windows/runner/CMakeLists.txt +40 -0
  180. package/e2e-tests/test-applications/flutter-test-app/windows/runner/Runner.rc +121 -0
  181. package/e2e-tests/test-applications/flutter-test-app/windows/runner/flutter_window.cpp +71 -0
  182. package/e2e-tests/test-applications/flutter-test-app/windows/runner/flutter_window.h +33 -0
  183. package/e2e-tests/test-applications/flutter-test-app/windows/runner/main.cpp +43 -0
  184. package/e2e-tests/test-applications/flutter-test-app/windows/runner/resource.h +16 -0
  185. package/e2e-tests/test-applications/flutter-test-app/windows/runner/resources/app_icon.ico +0 -0
  186. package/e2e-tests/test-applications/flutter-test-app/windows/runner/runner.exe.manifest +14 -0
  187. package/e2e-tests/test-applications/flutter-test-app/windows/runner/utils.cpp +65 -0
  188. package/e2e-tests/test-applications/flutter-test-app/windows/runner/utils.h +19 -0
  189. package/e2e-tests/test-applications/flutter-test-app/windows/runner/win32_window.cpp +288 -0
  190. package/e2e-tests/test-applications/flutter-test-app/windows/runner/win32_window.h +102 -0
  191. package/e2e-tests/tests/flutter.test.ts +127 -0
  192. package/e2e-tests/utils/index.ts +33 -0
  193. package/lib/Constants.ts +5 -0
  194. package/package.json +3 -2
  195. package/src/apple/apple-wizard.ts +2 -3
  196. package/src/apple/code-tools.ts +21 -6
  197. package/src/apple/fastlane.ts +18 -2
  198. package/src/apple/templates.ts +2 -2
  199. package/src/apple/xcode-manager.ts +186 -99
  200. package/src/flutter/code-tools.ts +284 -0
  201. package/src/flutter/flutter-wizard.ts +164 -0
  202. package/src/flutter/templates.ts +90 -0
  203. package/src/nextjs/nextjs-wizard.ts +5 -2
  204. package/src/nuxt/nuxt-wizard.ts +6 -3
  205. package/src/nuxt/sdk-setup.ts +2 -0
  206. package/src/react-native/react-native-wizard.ts +5 -2
  207. package/src/remix/remix-wizard.ts +5 -2
  208. package/src/run.ts +9 -0
  209. package/src/sveltekit/sveltekit-wizard.ts +5 -2
  210. package/src/utils/clack-utils.ts +16 -4
  211. package/src/utils/package-manager.ts +6 -0
  212. package/src/utils/types.ts +10 -0
  213. package/test/apple/cocoapod.test.ts +306 -0
  214. package/test/apple/code-tools.test.ts +1042 -0
  215. package/test/apple/fastfile.test.ts +550 -0
  216. package/test/apple/templates.test.ts +191 -0
  217. package/test/apple/xcode-manager.test.ts +1066 -0
  218. package/test/flutter/code-tools.test.ts +212 -0
  219. package/test/flutter/templates.test.ts +100 -0
  220. package/test/utils/clack-utils.test.ts +92 -0
  221. package/types/xcode.d.ts +526 -0
@@ -0,0 +1,288 @@
1
+ #include "win32_window.h"
2
+
3
+ #include <dwmapi.h>
4
+ #include <flutter_windows.h>
5
+
6
+ #include "resource.h"
7
+
8
+ namespace {
9
+
10
+ /// Window attribute that enables dark mode window decorations.
11
+ ///
12
+ /// Redefined in case the developer's machine has a Windows SDK older than
13
+ /// version 10.0.22000.0.
14
+ /// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
15
+ #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
16
+ #define DWMWA_USE_IMMERSIVE_DARK_MODE 20
17
+ #endif
18
+
19
+ constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
20
+
21
+ /// Registry key for app theme preference.
22
+ ///
23
+ /// A value of 0 indicates apps should use dark mode. A non-zero or missing
24
+ /// value indicates apps should use light mode.
25
+ constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
26
+ L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
27
+ constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
28
+
29
+ // The number of Win32Window objects that currently exist.
30
+ static int g_active_window_count = 0;
31
+
32
+ using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
33
+
34
+ // Scale helper to convert logical scaler values to physical using passed in
35
+ // scale factor
36
+ int Scale(int source, double scale_factor) {
37
+ return static_cast<int>(source * scale_factor);
38
+ }
39
+
40
+ // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
41
+ // This API is only needed for PerMonitor V1 awareness mode.
42
+ void EnableFullDpiSupportIfAvailable(HWND hwnd) {
43
+ HMODULE user32_module = LoadLibraryA("User32.dll");
44
+ if (!user32_module) {
45
+ return;
46
+ }
47
+ auto enable_non_client_dpi_scaling =
48
+ reinterpret_cast<EnableNonClientDpiScaling*>(
49
+ GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
50
+ if (enable_non_client_dpi_scaling != nullptr) {
51
+ enable_non_client_dpi_scaling(hwnd);
52
+ }
53
+ FreeLibrary(user32_module);
54
+ }
55
+
56
+ } // namespace
57
+
58
+ // Manages the Win32Window's window class registration.
59
+ class WindowClassRegistrar {
60
+ public:
61
+ ~WindowClassRegistrar() = default;
62
+
63
+ // Returns the singleton registrar instance.
64
+ static WindowClassRegistrar* GetInstance() {
65
+ if (!instance_) {
66
+ instance_ = new WindowClassRegistrar();
67
+ }
68
+ return instance_;
69
+ }
70
+
71
+ // Returns the name of the window class, registering the class if it hasn't
72
+ // previously been registered.
73
+ const wchar_t* GetWindowClass();
74
+
75
+ // Unregisters the window class. Should only be called if there are no
76
+ // instances of the window.
77
+ void UnregisterWindowClass();
78
+
79
+ private:
80
+ WindowClassRegistrar() = default;
81
+
82
+ static WindowClassRegistrar* instance_;
83
+
84
+ bool class_registered_ = false;
85
+ };
86
+
87
+ WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
88
+
89
+ const wchar_t* WindowClassRegistrar::GetWindowClass() {
90
+ if (!class_registered_) {
91
+ WNDCLASS window_class{};
92
+ window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
93
+ window_class.lpszClassName = kWindowClassName;
94
+ window_class.style = CS_HREDRAW | CS_VREDRAW;
95
+ window_class.cbClsExtra = 0;
96
+ window_class.cbWndExtra = 0;
97
+ window_class.hInstance = GetModuleHandle(nullptr);
98
+ window_class.hIcon =
99
+ LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
100
+ window_class.hbrBackground = 0;
101
+ window_class.lpszMenuName = nullptr;
102
+ window_class.lpfnWndProc = Win32Window::WndProc;
103
+ RegisterClass(&window_class);
104
+ class_registered_ = true;
105
+ }
106
+ return kWindowClassName;
107
+ }
108
+
109
+ void WindowClassRegistrar::UnregisterWindowClass() {
110
+ UnregisterClass(kWindowClassName, nullptr);
111
+ class_registered_ = false;
112
+ }
113
+
114
+ Win32Window::Win32Window() {
115
+ ++g_active_window_count;
116
+ }
117
+
118
+ Win32Window::~Win32Window() {
119
+ --g_active_window_count;
120
+ Destroy();
121
+ }
122
+
123
+ bool Win32Window::Create(const std::wstring& title,
124
+ const Point& origin,
125
+ const Size& size) {
126
+ Destroy();
127
+
128
+ const wchar_t* window_class =
129
+ WindowClassRegistrar::GetInstance()->GetWindowClass();
130
+
131
+ const POINT target_point = {static_cast<LONG>(origin.x),
132
+ static_cast<LONG>(origin.y)};
133
+ HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
134
+ UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
135
+ double scale_factor = dpi / 96.0;
136
+
137
+ HWND window = CreateWindow(
138
+ window_class, title.c_str(), WS_OVERLAPPEDWINDOW,
139
+ Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
140
+ Scale(size.width, scale_factor), Scale(size.height, scale_factor),
141
+ nullptr, nullptr, GetModuleHandle(nullptr), this);
142
+
143
+ if (!window) {
144
+ return false;
145
+ }
146
+
147
+ UpdateTheme(window);
148
+
149
+ return OnCreate();
150
+ }
151
+
152
+ bool Win32Window::Show() {
153
+ return ShowWindow(window_handle_, SW_SHOWNORMAL);
154
+ }
155
+
156
+ // static
157
+ LRESULT CALLBACK Win32Window::WndProc(HWND const window,
158
+ UINT const message,
159
+ WPARAM const wparam,
160
+ LPARAM const lparam) noexcept {
161
+ if (message == WM_NCCREATE) {
162
+ auto window_struct = reinterpret_cast<CREATESTRUCT*>(lparam);
163
+ SetWindowLongPtr(window, GWLP_USERDATA,
164
+ reinterpret_cast<LONG_PTR>(window_struct->lpCreateParams));
165
+
166
+ auto that = static_cast<Win32Window*>(window_struct->lpCreateParams);
167
+ EnableFullDpiSupportIfAvailable(window);
168
+ that->window_handle_ = window;
169
+ } else if (Win32Window* that = GetThisFromHandle(window)) {
170
+ return that->MessageHandler(window, message, wparam, lparam);
171
+ }
172
+
173
+ return DefWindowProc(window, message, wparam, lparam);
174
+ }
175
+
176
+ LRESULT
177
+ Win32Window::MessageHandler(HWND hwnd,
178
+ UINT const message,
179
+ WPARAM const wparam,
180
+ LPARAM const lparam) noexcept {
181
+ switch (message) {
182
+ case WM_DESTROY:
183
+ window_handle_ = nullptr;
184
+ Destroy();
185
+ if (quit_on_close_) {
186
+ PostQuitMessage(0);
187
+ }
188
+ return 0;
189
+
190
+ case WM_DPICHANGED: {
191
+ auto newRectSize = reinterpret_cast<RECT*>(lparam);
192
+ LONG newWidth = newRectSize->right - newRectSize->left;
193
+ LONG newHeight = newRectSize->bottom - newRectSize->top;
194
+
195
+ SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
196
+ newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
197
+
198
+ return 0;
199
+ }
200
+ case WM_SIZE: {
201
+ RECT rect = GetClientArea();
202
+ if (child_content_ != nullptr) {
203
+ // Size and position the child window.
204
+ MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
205
+ rect.bottom - rect.top, TRUE);
206
+ }
207
+ return 0;
208
+ }
209
+
210
+ case WM_ACTIVATE:
211
+ if (child_content_ != nullptr) {
212
+ SetFocus(child_content_);
213
+ }
214
+ return 0;
215
+
216
+ case WM_DWMCOLORIZATIONCOLORCHANGED:
217
+ UpdateTheme(hwnd);
218
+ return 0;
219
+ }
220
+
221
+ return DefWindowProc(window_handle_, message, wparam, lparam);
222
+ }
223
+
224
+ void Win32Window::Destroy() {
225
+ OnDestroy();
226
+
227
+ if (window_handle_) {
228
+ DestroyWindow(window_handle_);
229
+ window_handle_ = nullptr;
230
+ }
231
+ if (g_active_window_count == 0) {
232
+ WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
233
+ }
234
+ }
235
+
236
+ Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
237
+ return reinterpret_cast<Win32Window*>(
238
+ GetWindowLongPtr(window, GWLP_USERDATA));
239
+ }
240
+
241
+ void Win32Window::SetChildContent(HWND content) {
242
+ child_content_ = content;
243
+ SetParent(content, window_handle_);
244
+ RECT frame = GetClientArea();
245
+
246
+ MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
247
+ frame.bottom - frame.top, true);
248
+
249
+ SetFocus(child_content_);
250
+ }
251
+
252
+ RECT Win32Window::GetClientArea() {
253
+ RECT frame;
254
+ GetClientRect(window_handle_, &frame);
255
+ return frame;
256
+ }
257
+
258
+ HWND Win32Window::GetHandle() {
259
+ return window_handle_;
260
+ }
261
+
262
+ void Win32Window::SetQuitOnClose(bool quit_on_close) {
263
+ quit_on_close_ = quit_on_close;
264
+ }
265
+
266
+ bool Win32Window::OnCreate() {
267
+ // No-op; provided for subclasses.
268
+ return true;
269
+ }
270
+
271
+ void Win32Window::OnDestroy() {
272
+ // No-op; provided for subclasses.
273
+ }
274
+
275
+ void Win32Window::UpdateTheme(HWND const window) {
276
+ DWORD light_mode;
277
+ DWORD light_mode_size = sizeof(light_mode);
278
+ LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
279
+ kGetPreferredBrightnessRegValue,
280
+ RRF_RT_REG_DWORD, nullptr, &light_mode,
281
+ &light_mode_size);
282
+
283
+ if (result == ERROR_SUCCESS) {
284
+ BOOL enable_dark_mode = light_mode == 0;
285
+ DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
286
+ &enable_dark_mode, sizeof(enable_dark_mode));
287
+ }
288
+ }
@@ -0,0 +1,102 @@
1
+ #ifndef RUNNER_WIN32_WINDOW_H_
2
+ #define RUNNER_WIN32_WINDOW_H_
3
+
4
+ #include <windows.h>
5
+
6
+ #include <functional>
7
+ #include <memory>
8
+ #include <string>
9
+
10
+ // A class abstraction for a high DPI-aware Win32 Window. Intended to be
11
+ // inherited from by classes that wish to specialize with custom
12
+ // rendering and input handling
13
+ class Win32Window {
14
+ public:
15
+ struct Point {
16
+ unsigned int x;
17
+ unsigned int y;
18
+ Point(unsigned int x, unsigned int y) : x(x), y(y) {}
19
+ };
20
+
21
+ struct Size {
22
+ unsigned int width;
23
+ unsigned int height;
24
+ Size(unsigned int width, unsigned int height)
25
+ : width(width), height(height) {}
26
+ };
27
+
28
+ Win32Window();
29
+ virtual ~Win32Window();
30
+
31
+ // Creates a win32 window with |title| that is positioned and sized using
32
+ // |origin| and |size|. New windows are created on the default monitor. Window
33
+ // sizes are specified to the OS in physical pixels, hence to ensure a
34
+ // consistent size this function will scale the inputted width and height as
35
+ // as appropriate for the default monitor. The window is invisible until
36
+ // |Show| is called. Returns true if the window was created successfully.
37
+ bool Create(const std::wstring& title, const Point& origin, const Size& size);
38
+
39
+ // Show the current window. Returns true if the window was successfully shown.
40
+ bool Show();
41
+
42
+ // Release OS resources associated with window.
43
+ void Destroy();
44
+
45
+ // Inserts |content| into the window tree.
46
+ void SetChildContent(HWND content);
47
+
48
+ // Returns the backing Window handle to enable clients to set icon and other
49
+ // window properties. Returns nullptr if the window has been destroyed.
50
+ HWND GetHandle();
51
+
52
+ // If true, closing this window will quit the application.
53
+ void SetQuitOnClose(bool quit_on_close);
54
+
55
+ // Return a RECT representing the bounds of the current client area.
56
+ RECT GetClientArea();
57
+
58
+ protected:
59
+ // Processes and route salient window messages for mouse handling,
60
+ // size change and DPI. Delegates handling of these to member overloads that
61
+ // inheriting classes can handle.
62
+ virtual LRESULT MessageHandler(HWND window,
63
+ UINT const message,
64
+ WPARAM const wparam,
65
+ LPARAM const lparam) noexcept;
66
+
67
+ // Called when CreateAndShow is called, allowing subclass window-related
68
+ // setup. Subclasses should return false if setup fails.
69
+ virtual bool OnCreate();
70
+
71
+ // Called when Destroy is called.
72
+ virtual void OnDestroy();
73
+
74
+ private:
75
+ friend class WindowClassRegistrar;
76
+
77
+ // OS callback called by message pump. Handles the WM_NCCREATE message which
78
+ // is passed when the non-client area is being created and enables automatic
79
+ // non-client DPI scaling so that the non-client area automatically
80
+ // responds to changes in DPI. All other messages are handled by
81
+ // MessageHandler.
82
+ static LRESULT CALLBACK WndProc(HWND const window,
83
+ UINT const message,
84
+ WPARAM const wparam,
85
+ LPARAM const lparam) noexcept;
86
+
87
+ // Retrieves a class instance pointer for |window|
88
+ static Win32Window* GetThisFromHandle(HWND const window) noexcept;
89
+
90
+ // Update the window frame's theme to match the system theme.
91
+ static void UpdateTheme(HWND const window);
92
+
93
+ bool quit_on_close_ = false;
94
+
95
+ // window handle for top level window.
96
+ HWND window_handle_ = nullptr;
97
+
98
+ // window handle for hosted content.
99
+ HWND child_content_ = nullptr;
100
+ };
101
+
102
+ #endif // RUNNER_WIN32_WINDOW_H_
@@ -0,0 +1,127 @@
1
+ /* eslint-disable jest/expect-expect */
2
+ import { Integration } from '../../lib/Constants';
3
+ import {
4
+ // checkEnvBuildPlugin,
5
+ cleanupGit,
6
+ KEYS,
7
+ revertLocalChanges,
8
+ } from '../utils';
9
+ import { startWizardInstance } from '../utils';
10
+ import {
11
+ checkFileContents,
12
+ // checkFileExists,
13
+ checkSentryProperties,
14
+ checkIfFlutterBuilds,
15
+ } from '../utils';
16
+ import * as path from 'path';
17
+ import * as fs from 'fs';
18
+
19
+ describe('Flutter', () => {
20
+ const integration = Integration.flutter;
21
+ const projectDir = path.resolve(
22
+ __dirname,
23
+ '../test-applications/flutter-test-app',
24
+ );
25
+
26
+ describe('with apple platforms', () => {
27
+ beforeAll(async () => {
28
+ const wizardInstance = startWizardInstance(integration, projectDir);
29
+
30
+ const tracingOptionPrompted = await wizardInstance.waitForOutput(
31
+ // "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
32
+ 'to track the performance of your application?',
33
+ );
34
+
35
+ const profilingOptionPrompted = tracingOptionPrompted &&
36
+ (await wizardInstance.sendStdinAndWaitForOutput(
37
+ [KEYS.ENTER],
38
+ // "Do you want to enable Profiling", sometimes doesn't work as `Profiling` can be printed in bold.
39
+ 'to analyze CPU usage and optimize performance-critical code on iOS & macOS?',
40
+ ));
41
+
42
+ profilingOptionPrompted &&
43
+ (await wizardInstance.sendStdinAndWaitForOutput(
44
+ [KEYS.ENTER],
45
+ 'Successfully installed the Sentry Flutter SDK!',
46
+ ));
47
+
48
+ wizardInstance.kill();
49
+ });
50
+
51
+ afterAll(() => {
52
+ revertLocalChanges(projectDir);
53
+ cleanupGit(projectDir);
54
+ });
55
+
56
+ test('pubspec.yaml is updated.', () => {
57
+ checkFileContents(`${projectDir}/pubspec.yaml`, `sentry_flutter:`); // dependencies
58
+ checkFileContents(`${projectDir}/pubspec.yaml`, `sentry_dart_plugin:`); // dev_dependencies
59
+ checkFileContents(`${projectDir}/pubspec.yaml`, `sentry:`); // gradle plugin options
60
+ });
61
+
62
+ test('sentry.properties exists and has auth token', () => {
63
+ checkSentryProperties(projectDir);
64
+ });
65
+
66
+ test('.gitignore has sentry.properties', () => {
67
+ checkFileContents(`${projectDir}/.gitignore`, `sentry.properties`);
68
+ });
69
+
70
+ test('lib/main.dart calls sentry init', () => {
71
+ checkFileContents(`${projectDir}/lib/main.dart`, `import 'package:sentry_flutter/sentry_flutter.dart';`);
72
+ checkFileContents(`${projectDir}/lib/main.dart`, `await SentryFlutter.init(`);
73
+ });
74
+
75
+ test('lib/main.dart enables tracing and profiling', () => {
76
+ checkFileContents(`${projectDir}/lib/main.dart`, `options.tracesSampleRate = 1.0;`);
77
+ checkFileContents(`${projectDir}/lib/main.dart`, `options.profilesSampleRate = 1.0;`);
78
+ });
79
+
80
+ test('builds correctly', async () => {
81
+ await checkIfFlutterBuilds(projectDir, '✓ Built build/web');
82
+ });
83
+ });
84
+
85
+ describe('without apple platforms', () => {
86
+ beforeAll(async () => {
87
+
88
+ const wizardInstance = startWizardInstance(integration, projectDir);
89
+
90
+ if (fs.existsSync(`${projectDir}/ios`)) {
91
+ fs.renameSync(`${projectDir}/ios`, `${projectDir}/_ios`);
92
+ }
93
+ if (fs.existsSync(`${projectDir}/macos`)) {
94
+ fs.renameSync(`${projectDir}/macos`, `${projectDir}/_macos`);
95
+ }
96
+
97
+ const continueOnUncommitedFilesPromted = await wizardInstance.waitForOutput(
98
+ 'Do you want to continue anyway?'
99
+ )
100
+
101
+ const tracingOptionPrompted = continueOnUncommitedFilesPromted &&
102
+ (await wizardInstance.sendStdinAndWaitForOutput(
103
+ [KEYS.ENTER],
104
+ // "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
105
+ 'to track the performance of your application?',
106
+ ));
107
+
108
+ tracingOptionPrompted &&
109
+ (await wizardInstance.sendStdinAndWaitForOutput(
110
+ [KEYS.ENTER],
111
+ 'Successfully installed the Sentry Flutter SDK!',
112
+ ));
113
+
114
+ wizardInstance.kill();
115
+ });
116
+
117
+ afterAll(() => {
118
+ revertLocalChanges(projectDir);
119
+ cleanupGit(projectDir);
120
+ });
121
+
122
+ test('lib/main.dart does not add profiling with missing ios and macos folder', () => {
123
+ const fileContent = fs.readFileSync(`${projectDir}/lib/main.dart`, 'utf-8');
124
+ expect(fileContent).not.toContain(`options.profilesSampleRate = 1.0;`);
125
+ });
126
+ });
127
+ });
@@ -348,6 +348,18 @@ export function checkEnvBuildPlugin(projectDir: string) {
348
348
  }
349
349
 
350
350
  /**
351
+ * Check if the sentry.properties contains the auth token
352
+ * @param projectDir
353
+ */
354
+ export function checkSentryProperties(projectDir: string) {
355
+ checkFileContents(
356
+ `${projectDir}/sentry.properties`,
357
+ `auth_token=${TEST_ARGS.AUTH_TOKEN}`,
358
+ );
359
+ }
360
+
361
+ /**
362
+ * Check if the project builds
351
363
  * Check if the project builds and ends with status code 0.
352
364
  * @param projectDir
353
365
  */
@@ -363,6 +375,27 @@ export async function checkIfBuilds(projectDir: string) {
363
375
  ).resolves.toBe(true);
364
376
  }
365
377
 
378
+ /**
379
+ * Check if the flutter project builds
380
+ * @param projectDir
381
+ */
382
+ export async function checkIfFlutterBuilds(
383
+ projectDir: string,
384
+ expectedOutput: string,
385
+ debug = false,
386
+ ) {
387
+ const testEnv = new WizardTestEnv('flutter', ['build', 'web'], {
388
+ cwd: projectDir,
389
+ debug: debug,
390
+ });
391
+
392
+ await expect(
393
+ testEnv.waitForOutput(expectedOutput, {
394
+ timeout: 120_000,
395
+ }),
396
+ ).resolves.toBe(true);
397
+ }
398
+
366
399
  /**
367
400
  * Check if the project runs on dev mode
368
401
  * @param projectDir
package/lib/Constants.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /** Key value should be the same here */
2
2
  export enum Integration {
3
3
  reactNative = 'reactNative',
4
+ flutter = 'flutter',
4
5
  ios = 'ios',
5
6
  android = 'android',
6
7
  cordova = 'cordova',
@@ -41,6 +42,8 @@ export function getIntegrationDescription(type: string): string {
41
42
  return 'Android';
42
43
  case Integration.reactNative:
43
44
  return 'React Native';
45
+ case Integration.flutter:
46
+ return 'Flutter';
44
47
  case Integration.cordova:
45
48
  return 'Cordova';
46
49
  case Integration.electron:
@@ -66,6 +69,8 @@ export function mapIntegrationToPlatform(type: string): string | undefined {
66
69
  return 'android';
67
70
  case Integration.reactNative:
68
71
  return 'react-native';
72
+ case Integration.flutter:
73
+ return 'flutter';
69
74
  case Integration.cordova:
70
75
  return 'cordova';
71
76
  case Integration.electron:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/wizard",
3
- "version": "3.39.0",
3
+ "version": "3.41.0",
4
4
  "homepage": "https://github.com/getsentry/sentry-wizard",
5
5
  "repository": "https://github.com/getsentry/sentry-wizard",
6
6
  "description": "Sentry wizard helping you to configure your project",
@@ -123,5 +123,6 @@
123
123
  "volta": {
124
124
  "node": "14.18.3",
125
125
  "yarn": "1.22.19"
126
- }
126
+ },
127
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
127
128
  }
@@ -17,7 +17,6 @@ import { traceStep, withTelemetry } from '../telemetry';
17
17
  import * as cocoapod from './cocoapod';
18
18
  import * as fastlane from './fastlane';
19
19
 
20
- const xcode = require('xcode');
21
20
  /* eslint-enable @typescript-eslint/no-unused-vars */
22
21
 
23
22
  import {
@@ -109,7 +108,7 @@ async function runAppleWizardWithTelementry(
109
108
  const availableTargets = xcProject.getAllTargets();
110
109
 
111
110
  if (availableTargets.length == 0) {
112
- clack.log.error(`No suttable target found in ${xcodeProjFile}`);
111
+ clack.log.error(`No suitable target found in ${xcodeProjFile}`);
113
112
  Sentry.setTag('No-Target', true);
114
113
  await abort();
115
114
  return;
@@ -161,7 +160,7 @@ async function runAppleWizardWithTelementry(
161
160
 
162
161
  Sentry.setTag('package-manager', hasCocoa ? 'cocoapods' : 'SPM');
163
162
  traceStep('Update Xcode project', () => {
164
- xcProject.updateXcodeProject(project, target, apiKey, !hasCocoa, true);
163
+ xcProject.updateXcodeProject(project, target, !hasCocoa, true);
165
164
  });
166
165
 
167
166
  const codeAdded = traceStep('Add code snippet', () => {
@@ -1,15 +1,15 @@
1
+ import * as Sentry from '@sentry/node';
1
2
  import * as fs from 'fs';
2
3
  import * as path from 'path';
3
4
  import * as templates from './templates';
4
- import * as Sentry from '@sentry/node';
5
5
  // @ts-ignore - clack is ESM and TS complains about that. It works though
6
- import clack from '@clack/prompts';
6
+ import * as clack from '@clack/prompts';
7
7
 
8
8
  const swiftAppLaunchRegex =
9
- /(func\s+application\s*\(_\sapplication:[^,]+,\s*didFinishLaunchingWithOptions[^,]+:[^)]+\)\s+->\s+Bool\s+{)|func\s+applicationDidFinishLaunching\(_\s+aNotification:\s+Notification\)\s+{/im;
9
+ /(func\s+application\s*\(\s*_\s+application:\s*[^,]+,\s*didFinishLaunchingWithOptions[^,]+:\s*[^)]+\s*\)\s+->\s+Bool\s+{)|func\s+applicationDidFinishLaunching\s*\(\s*_\s+aNotification:\s+Notification\s*\)\s*{/im;
10
10
  const objcAppLaunchRegex =
11
- /-\s*\(BOOL\)\s*application:\s*\(UIApplication\s*\*\)\s*application\s+didFinishLaunchingWithOptions:\s*\(NSDictionary\s*\*\)\s*launchOptions\s*{/im;
12
- const swiftUIRegex = /@main\s+struct[^:]+:\s*App\s*{/im;
11
+ /-\s*\(\s*BOOL\s*\)\s*application:\s*\(\s*UIApplication\s*\*\s*\)\s*application\s+didFinishLaunchingWithOptions:\s*\(\s*NSDictionary\s*\*\s*\)\s*launchOptions\s*{/im;
12
+ const swiftUIRegex = /@main\s+struct[^:]+:\s*(SwiftUI\.)?App\s*{/im;
13
13
 
14
14
  function isAppDelegateFile(filePath: string): boolean {
15
15
  const appLaunchRegex = filePath.toLowerCase().endsWith('.swift')
@@ -43,7 +43,7 @@ function findAppDidFinishLaunchingWithOptions(
43
43
  return filePath;
44
44
  }
45
45
  } else if (
46
- !filePath.startsWith('.') &&
46
+ !path.basename(filePath).startsWith('.') &&
47
47
  !filePath.endsWith('.xcodeproj') &&
48
48
  !filePath.endsWith('.xcassets') &&
49
49
  fs.existsSync(filePath) &&
@@ -97,6 +97,7 @@ export function addCodeSnippetToProject(
97
97
  if (!match) {
98
98
  const swiftUIMatch = swiftUIRegex.exec(fileContent);
99
99
  if (!swiftUIMatch) {
100
+ // This branch is not reached, because we already checked for SwiftUI in isAppDelegateFile
100
101
  return false;
101
102
  }
102
103
  //Is SwiftUI with no init
@@ -130,3 +131,17 @@ export function addCodeSnippetToProject(
130
131
  clack.log.step('Added Sentry initialization code snippet to ' + appDelegate);
131
132
  return true;
132
133
  }
134
+
135
+ /**
136
+ * Exported for testing purposes, but should not be used in other modules.
137
+ */
138
+ export let exportForTesting: {
139
+ isAppDelegateFile: typeof isAppDelegateFile;
140
+ findAppDidFinishLaunchingWithOptions: typeof findAppDidFinishLaunchingWithOptions;
141
+ };
142
+ if (process.env.NODE_ENV === 'test') {
143
+ exportForTesting = {
144
+ isAppDelegateFile,
145
+ findAppDidFinishLaunchingWithOptions,
146
+ };
147
+ }