@sentry/wizard 6.11.0 → 6.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/bin.js +16 -1
  3. package/dist/bin.js.map +1 -1
  4. package/dist/e2e-tests/tests/angular-17.test.js +3 -4
  5. package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
  6. package/dist/e2e-tests/tests/angular-19.test.js +3 -4
  7. package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
  8. package/dist/e2e-tests/tests/cloudflare-worker.test.js +5 -0
  9. package/dist/e2e-tests/tests/cloudflare-worker.test.js.map +1 -1
  10. package/dist/e2e-tests/tests/flutter.test.js +60 -0
  11. package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
  12. package/dist/e2e-tests/tests/help-message.test.js +8 -3
  13. package/dist/e2e-tests/tests/help-message.test.js.map +1 -1
  14. package/dist/e2e-tests/tests/nuxt-3.test.js +12 -6
  15. package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
  16. package/dist/e2e-tests/tests/nuxt-4.test.js +12 -6
  17. package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
  18. package/dist/e2e-tests/tests/pnpm-workspace.test.js +8 -4
  19. package/dist/e2e-tests/tests/pnpm-workspace.test.js.map +1 -1
  20. package/dist/e2e-tests/tests/react-router-instrumentation-api.test.js +96 -0
  21. package/dist/e2e-tests/tests/react-router-instrumentation-api.test.js.map +1 -0
  22. package/dist/e2e-tests/tests/react-router.test.js +6 -7
  23. package/dist/e2e-tests/tests/react-router.test.js.map +1 -1
  24. package/dist/e2e-tests/tests/remix.test.js +2 -4
  25. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  26. package/dist/e2e-tests/tests/sveltekit-hooks.test.js +24 -8
  27. package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -1
  28. package/dist/e2e-tests/tests/sveltekit-tracing.test.js +8 -4
  29. package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -1
  30. package/dist/lib/Constants.d.ts +1 -0
  31. package/dist/lib/Constants.js +5 -0
  32. package/dist/lib/Constants.js.map +1 -1
  33. package/dist/lib/Steps/Integrations/Electron.js +2 -2
  34. package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
  35. package/dist/src/android/android-wizard.js +3 -0
  36. package/dist/src/android/android-wizard.js.map +1 -1
  37. package/dist/src/angular/codemods/main.d.ts +1 -1
  38. package/dist/src/angular/codemods/main.js +0 -1
  39. package/dist/src/angular/codemods/main.js.map +1 -1
  40. package/dist/src/apple/apple-wizard.js +2 -3
  41. package/dist/src/apple/apple-wizard.js.map +1 -1
  42. package/dist/src/apple/check-installed-cli.d.ts +1 -1
  43. package/dist/src/apple/check-installed-cli.js +13 -7
  44. package/dist/src/apple/check-installed-cli.js.map +1 -1
  45. package/dist/src/apple/code-tools.js +17 -3
  46. package/dist/src/apple/code-tools.js.map +1 -1
  47. package/dist/src/apple/configure-package-manager.js +18 -5
  48. package/dist/src/apple/configure-package-manager.js.map +1 -1
  49. package/dist/src/apple/configure-xcode-project.js +8 -1
  50. package/dist/src/apple/configure-xcode-project.js.map +1 -1
  51. package/dist/src/apple/lookup-xcode-project.d.ts +8 -5
  52. package/dist/src/apple/lookup-xcode-project.js +22 -17
  53. package/dist/src/apple/lookup-xcode-project.js.map +1 -1
  54. package/dist/src/apple/options.d.ts +5 -0
  55. package/dist/src/apple/options.js.map +1 -1
  56. package/dist/src/apple/sentry-swift-package.d.ts +4 -0
  57. package/dist/src/apple/sentry-swift-package.js +17 -0
  58. package/dist/src/apple/sentry-swift-package.js.map +1 -0
  59. package/dist/src/apple/snapshots/apple-snapshots-wizard.d.ts +2 -0
  60. package/dist/src/apple/snapshots/apple-snapshots-wizard.js +251 -0
  61. package/dist/src/apple/snapshots/apple-snapshots-wizard.js.map +1 -0
  62. package/dist/src/apple/snapshots/configure-snapshotpreviews-xcode-project.d.ts +13 -0
  63. package/dist/src/apple/snapshots/configure-snapshotpreviews-xcode-project.js +48 -0
  64. package/dist/src/apple/snapshots/configure-snapshotpreviews-xcode-project.js.map +1 -0
  65. package/dist/src/apple/snapshots/snapshot-test-file.d.ts +18 -0
  66. package/dist/src/apple/snapshots/snapshot-test-file.js +122 -0
  67. package/dist/src/apple/snapshots/snapshot-test-file.js.map +1 -0
  68. package/dist/src/apple/snapshots/snapshot-verification-scheme.d.ts +6 -0
  69. package/dist/src/apple/snapshots/snapshot-verification-scheme.js +147 -0
  70. package/dist/src/apple/snapshots/snapshot-verification-scheme.js.map +1 -0
  71. package/dist/src/apple/snapshots/snapshotpreviews-package.d.ts +4 -0
  72. package/dist/src/apple/snapshots/snapshotpreviews-package.js +8 -0
  73. package/dist/src/apple/snapshots/snapshotpreviews-package.js.map +1 -0
  74. package/dist/src/apple/snapshots/snapshots-cli-preflight.d.ts +23 -0
  75. package/dist/src/apple/snapshots/snapshots-cli-preflight.js +136 -0
  76. package/dist/src/apple/snapshots/snapshots-cli-preflight.js.map +1 -0
  77. package/dist/src/apple/xcode-manager.d.ts +59 -1
  78. package/dist/src/apple/xcode-manager.js +507 -106
  79. package/dist/src/apple/xcode-manager.js.map +1 -1
  80. package/dist/src/cloudflare/cloudflare-wizard.js +5 -0
  81. package/dist/src/cloudflare/cloudflare-wizard.js.map +1 -1
  82. package/dist/src/cloudflare/sdk-setup.d.ts +1 -0
  83. package/dist/src/cloudflare/sdk-setup.js.map +1 -1
  84. package/dist/src/cloudflare/templates.d.ts +1 -0
  85. package/dist/src/cloudflare/templates.js +7 -1
  86. package/dist/src/cloudflare/templates.js.map +1 -1
  87. package/dist/src/cloudflare/wrap-worker.d.ts +1 -0
  88. package/dist/src/cloudflare/wrap-worker.js +7 -0
  89. package/dist/src/cloudflare/wrap-worker.js.map +1 -1
  90. package/dist/src/flutter/flutter-wizard.js +3 -0
  91. package/dist/src/flutter/flutter-wizard.js.map +1 -1
  92. package/dist/src/nextjs/templates.js +12 -6
  93. package/dist/src/nextjs/templates.js.map +1 -1
  94. package/dist/src/nuxt/templates.js +12 -6
  95. package/dist/src/nuxt/templates.js.map +1 -1
  96. package/dist/src/react-native/expo.d.ts +6 -0
  97. package/dist/src/react-native/expo.js +27 -1
  98. package/dist/src/react-native/expo.js.map +1 -1
  99. package/dist/src/react-native/git.d.ts +5 -0
  100. package/dist/src/react-native/git.js +32 -1
  101. package/dist/src/react-native/git.js.map +1 -1
  102. package/dist/src/react-native/javascript.js +3 -1
  103. package/dist/src/react-native/javascript.js.map +1 -1
  104. package/dist/src/react-native/react-native-wizard.js +12 -6
  105. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  106. package/dist/src/react-router/codemods/client.entry.d.ts +1 -1
  107. package/dist/src/react-router/codemods/client.entry.js +124 -26
  108. package/dist/src/react-router/codemods/client.entry.js.map +1 -1
  109. package/dist/src/react-router/codemods/react-router-config.js +1 -1
  110. package/dist/src/react-router/codemods/react-router-config.js.map +1 -1
  111. package/dist/src/react-router/codemods/server-entry.d.ts +1 -1
  112. package/dist/src/react-router/codemods/server-entry.js +40 -4
  113. package/dist/src/react-router/codemods/server-entry.js.map +1 -1
  114. package/dist/src/react-router/codemods/vite.js +46 -1
  115. package/dist/src/react-router/codemods/vite.js.map +1 -1
  116. package/dist/src/react-router/react-router-wizard.js +62 -21
  117. package/dist/src/react-router/react-router-wizard.js.map +1 -1
  118. package/dist/src/react-router/sdk-setup.d.ts +5 -3
  119. package/dist/src/react-router/sdk-setup.js +44 -16
  120. package/dist/src/react-router/sdk-setup.js.map +1 -1
  121. package/dist/src/react-router/templates.d.ts +2 -4
  122. package/dist/src/react-router/templates.js +89 -87
  123. package/dist/src/react-router/templates.js.map +1 -1
  124. package/dist/src/remix/sdk-setup.js +1 -2
  125. package/dist/src/remix/sdk-setup.js.map +1 -1
  126. package/dist/src/run.d.ts +4 -1
  127. package/dist/src/run.js +13 -0
  128. package/dist/src/run.js.map +1 -1
  129. package/dist/src/sourcemaps/tools/remix.js +4 -4
  130. package/dist/src/sourcemaps/tools/remix.js.map +1 -1
  131. package/dist/src/sourcemaps/tools/vite.js +1 -1
  132. package/dist/src/sourcemaps/tools/vite.js.map +1 -1
  133. package/dist/src/sveltekit/sdk-setup/setup.js +17 -4
  134. package/dist/src/sveltekit/sdk-setup/setup.js.map +1 -1
  135. package/dist/src/sveltekit/sdk-setup/vite.js +1 -1
  136. package/dist/src/sveltekit/sdk-setup/vite.js.map +1 -1
  137. package/dist/src/sveltekit/templates.js +12 -6
  138. package/dist/src/sveltekit/templates.js.map +1 -1
  139. package/dist/src/utils/ast-utils.d.ts +10 -0
  140. package/dist/src/utils/ast-utils.js +19 -1
  141. package/dist/src/utils/ast-utils.js.map +1 -1
  142. package/dist/src/utils/clack/index.d.ts +2 -1
  143. package/dist/src/utils/clack/index.js +17 -6
  144. package/dist/src/utils/clack/index.js.map +1 -1
  145. package/dist/src/utils/files.d.ts +2 -0
  146. package/dist/src/utils/files.js +58 -0
  147. package/dist/src/utils/files.js.map +1 -0
  148. package/dist/src/utils/git.d.ts +3 -1
  149. package/dist/src/utils/git.js +2 -1
  150. package/dist/src/utils/git.js.map +1 -1
  151. package/dist/src/utils/line-endings.d.ts +1 -0
  152. package/dist/src/utils/line-endings.js +76 -0
  153. package/dist/src/utils/line-endings.js.map +1 -0
  154. package/dist/src/version.d.ts +1 -1
  155. package/dist/src/version.js +1 -1
  156. package/dist/src/version.js.map +1 -1
  157. package/dist/test/angular/angular-wizard.test.js +0 -5
  158. package/dist/test/angular/angular-wizard.test.js.map +1 -1
  159. package/dist/test/apple/code-tools.test.js +78 -0
  160. package/dist/test/apple/code-tools.test.js.map +1 -1
  161. package/dist/test/apple/configure-package-manager.test.d.ts +1 -0
  162. package/dist/test/apple/configure-package-manager.test.js +161 -0
  163. package/dist/test/apple/configure-package-manager.test.js.map +1 -0
  164. package/dist/test/apple/lookup-xcode-project.test.d.ts +1 -0
  165. package/dist/test/apple/lookup-xcode-project.test.js +167 -0
  166. package/dist/test/apple/lookup-xcode-project.test.js.map +1 -0
  167. package/dist/test/apple/snapshots/apple-snapshots-wizard.test.d.ts +1 -0
  168. package/dist/test/apple/snapshots/apple-snapshots-wizard.test.js +487 -0
  169. package/dist/test/apple/snapshots/apple-snapshots-wizard.test.js.map +1 -0
  170. package/dist/test/apple/snapshots/hosted-test-target-fixture.d.ts +24 -0
  171. package/dist/test/apple/snapshots/hosted-test-target-fixture.js +191 -0
  172. package/dist/test/apple/snapshots/hosted-test-target-fixture.js.map +1 -0
  173. package/dist/test/apple/snapshots/snapshot-test-file.test.d.ts +1 -0
  174. package/dist/test/apple/snapshots/snapshot-test-file.test.js +110 -0
  175. package/dist/test/apple/snapshots/snapshot-test-file.test.js.map +1 -0
  176. package/dist/test/apple/snapshots/snapshot-verification-scheme.test.d.ts +1 -0
  177. package/dist/test/apple/snapshots/snapshot-verification-scheme.test.js +146 -0
  178. package/dist/test/apple/snapshots/snapshot-verification-scheme.test.js.map +1 -0
  179. package/dist/test/apple/snapshots/snapshotpreviews-xcode-smoke.test.d.ts +1 -0
  180. package/dist/test/apple/snapshots/snapshotpreviews-xcode-smoke.test.js +186 -0
  181. package/dist/test/apple/snapshots/snapshotpreviews-xcode-smoke.test.js.map +1 -0
  182. package/dist/test/apple/snapshots/snapshots-cli-preflight.test.d.ts +1 -0
  183. package/dist/test/apple/snapshots/snapshots-cli-preflight.test.js +192 -0
  184. package/dist/test/apple/snapshots/snapshots-cli-preflight.test.js.map +1 -0
  185. package/dist/test/apple/snapshots/source-file-insertion.test.d.ts +1 -0
  186. package/dist/test/apple/snapshots/source-file-insertion.test.js +77 -0
  187. package/dist/test/apple/snapshots/source-file-insertion.test.js.map +1 -0
  188. package/dist/test/apple/xcode-manager.test.js +452 -43
  189. package/dist/test/apple/xcode-manager.test.js.map +1 -1
  190. package/dist/test/cloudflare/sdk-setup.test.js +20 -2
  191. package/dist/test/cloudflare/sdk-setup.test.js.map +1 -1
  192. package/dist/test/cloudflare/templates.test.js +54 -0
  193. package/dist/test/cloudflare/templates.test.js.map +1 -1
  194. package/dist/test/cloudflare/wrap-worker.test.js +74 -11
  195. package/dist/test/cloudflare/wrap-worker.test.js.map +1 -1
  196. package/dist/test/constants.test.d.ts +1 -0
  197. package/dist/test/constants.test.js +12 -0
  198. package/dist/test/constants.test.js.map +1 -0
  199. package/dist/test/nextjs/templates.test.js +66 -33
  200. package/dist/test/nextjs/templates.test.js.map +1 -1
  201. package/dist/test/nuxt/templates.test.js +66 -36
  202. package/dist/test/nuxt/templates.test.js.map +1 -1
  203. package/dist/test/react-native/expo.test.js +140 -0
  204. package/dist/test/react-native/expo.test.js.map +1 -1
  205. package/dist/test/react-native/git.test.d.ts +1 -0
  206. package/dist/test/react-native/git.test.js +160 -0
  207. package/dist/test/react-native/git.test.js.map +1 -0
  208. package/dist/test/react-router/codemods/client-entry.test.js +38 -5
  209. package/dist/test/react-router/codemods/client-entry.test.js.map +1 -1
  210. package/dist/test/react-router/codemods/server-entry.test.js +83 -0
  211. package/dist/test/react-router/codemods/server-entry.test.js.map +1 -1
  212. package/dist/test/react-router/codemods/vite.test.js +89 -0
  213. package/dist/test/react-router/codemods/vite.test.js.map +1 -1
  214. package/dist/test/react-router/sdk-setup.test.js +98 -6
  215. package/dist/test/react-router/sdk-setup.test.js.map +1 -1
  216. package/dist/test/react-router/templates.test.js +50 -38
  217. package/dist/test/react-router/templates.test.js.map +1 -1
  218. package/dist/test/remix/build-script.test.d.ts +1 -0
  219. package/dist/test/remix/build-script.test.js +124 -0
  220. package/dist/test/remix/build-script.test.js.map +1 -0
  221. package/dist/test/remix/client-entry.test.js +4 -10
  222. package/dist/test/remix/client-entry.test.js.map +1 -1
  223. package/dist/test/run.test.d.ts +1 -0
  224. package/dist/test/run.test.js +137 -0
  225. package/dist/test/run.test.js.map +1 -0
  226. package/dist/test/sourcemaps/tools/vite.test.js +12 -8
  227. package/dist/test/sourcemaps/tools/vite.test.js.map +1 -1
  228. package/dist/test/sveltekit/templates.test.js +78 -27
  229. package/dist/test/sveltekit/templates.test.js.map +1 -1
  230. package/dist/test/utils/ast-utils.test.js +22 -0
  231. package/dist/test/utils/ast-utils.test.js.map +1 -1
  232. package/dist/test/utils/clack/index.test.js +101 -0
  233. package/dist/test/utils/clack/index.test.js.map +1 -1
  234. package/dist/test/utils/git.test.js +10 -0
  235. package/dist/test/utils/git.test.js.map +1 -1
  236. package/dist/test/utils/line-endings.test.d.ts +1 -0
  237. package/dist/test/utils/line-endings.test.js +103 -0
  238. package/dist/test/utils/line-endings.test.js.map +1 -0
  239. package/package.json +2 -2
  240. package/dist/src/react-router/codemods/root.d.ts +0 -1
  241. package/dist/src/react-router/codemods/root.js +0 -171
  242. package/dist/src/react-router/codemods/root.js.map +0 -1
  243. package/dist/test/react-router/codemods/root.test.js +0 -178
  244. package/dist/test/react-router/codemods/root.test.js.map +0 -1
  245. /package/dist/{test/react-router/codemods/root.test.d.ts → e2e-tests/tests/react-router-instrumentation-api.test.d.ts} +0 -0
@@ -0,0 +1,191 @@
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.hostedTestTargetFixtureIds = exports.addHostedUnitTestTarget = exports.copySingleTargetProjectToTemp = void 0;
27
+ const fs = __importStar(require("node:fs"));
28
+ const os = __importStar(require("node:os"));
29
+ const path = __importStar(require("node:path"));
30
+ const fixtureProjectPath = path.resolve(__dirname, '../../../fixtures/test-applications/apple/spm-swiftui-single-target/Project.xcodeproj/project.pbxproj');
31
+ function copySingleTargetProjectToTemp(prefix) {
32
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
33
+ const xcodeprojDir = path.join(tempDir, 'Project.xcodeproj');
34
+ fs.mkdirSync(xcodeprojDir, { recursive: true });
35
+ fs.mkdirSync(path.join(tempDir, 'Sources'), { recursive: true });
36
+ fs.copyFileSync(fixtureProjectPath, path.join(xcodeprojDir, 'project.pbxproj'));
37
+ return path.join(xcodeprojDir, 'project.pbxproj');
38
+ }
39
+ exports.copySingleTargetProjectToTemp = copySingleTargetProjectToTemp;
40
+ function addHostedUnitTestTarget(xcodeProject, options) {
41
+ const name = options.name ?? 'ProjectTests';
42
+ const ids = options.ids ?? hostedTestTargetFixtureIds(name);
43
+ const hostAppName = options.hostAppName ?? 'Project';
44
+ const buildSettings = hostedUnitTestBuildSettings({
45
+ bundleLoader: options.bundleLoader,
46
+ hostAppName,
47
+ name,
48
+ testHost: options.testHost,
49
+ });
50
+ xcodeProject.objects.PBXFileReference = {
51
+ ...(xcodeProject.objects.PBXFileReference ?? {}),
52
+ [ids.productReferenceId]: {
53
+ isa: 'PBXFileReference',
54
+ explicitFileType: 'wrapper.cfbundle',
55
+ includeInIndex: 0,
56
+ path: `${name}.xctest`,
57
+ sourceTree: 'BUILT_PRODUCTS_DIR',
58
+ },
59
+ [`${ids.productReferenceId}_comment`]: `${name}.xctest`,
60
+ };
61
+ xcodeProject.objects.PBXFrameworksBuildPhase = {
62
+ ...(xcodeProject.objects.PBXFrameworksBuildPhase ?? {}),
63
+ [ids.frameworksBuildPhaseId]: {
64
+ isa: 'PBXFrameworksBuildPhase',
65
+ buildActionMask: 2147483647,
66
+ files: [],
67
+ runOnlyForDeploymentPostprocessing: 0,
68
+ },
69
+ [`${ids.frameworksBuildPhaseId}_comment`]: 'Frameworks',
70
+ };
71
+ const buildPhases = [
72
+ ...(options.includeSourcesBuildPhase && ids.sourcesBuildPhaseId
73
+ ? [
74
+ {
75
+ value: ids.sourcesBuildPhaseId,
76
+ comment: 'Sources',
77
+ },
78
+ ]
79
+ : []),
80
+ {
81
+ value: ids.frameworksBuildPhaseId,
82
+ comment: 'Frameworks',
83
+ },
84
+ ];
85
+ if (options.includeSourcesBuildPhase && ids.sourcesBuildPhaseId) {
86
+ xcodeProject.objects.PBXSourcesBuildPhase = {
87
+ ...(xcodeProject.objects.PBXSourcesBuildPhase ?? {}),
88
+ [ids.sourcesBuildPhaseId]: {
89
+ isa: 'PBXSourcesBuildPhase',
90
+ buildActionMask: 2147483647,
91
+ files: [],
92
+ runOnlyForDeploymentPostprocessing: 0,
93
+ },
94
+ [`${ids.sourcesBuildPhaseId}_comment`]: 'Sources',
95
+ };
96
+ }
97
+ xcodeProject.objects.PBXNativeTarget = {
98
+ ...(xcodeProject.objects.PBXNativeTarget ?? {}),
99
+ [ids.targetId]: {
100
+ isa: 'PBXNativeTarget',
101
+ buildConfigurationList: ids.buildConfigurationListId,
102
+ buildPhases,
103
+ buildRules: [],
104
+ dependencies: [],
105
+ name,
106
+ packageProductDependencies: [],
107
+ productName: name,
108
+ productReference: ids.productReferenceId,
109
+ productType: '"com.apple.product-type.bundle.unit-test"',
110
+ },
111
+ [`${ids.targetId}_comment`]: name,
112
+ };
113
+ xcodeProject.objects.XCBuildConfiguration = {
114
+ ...(xcodeProject.objects.XCBuildConfiguration ?? {}),
115
+ [ids.debugBuildConfigurationId]: {
116
+ isa: 'XCBuildConfiguration',
117
+ buildSettings,
118
+ name: 'Debug',
119
+ },
120
+ [`${ids.debugBuildConfigurationId}_comment`]: 'Debug',
121
+ [ids.releaseBuildConfigurationId]: {
122
+ isa: 'XCBuildConfiguration',
123
+ buildSettings,
124
+ name: 'Release',
125
+ },
126
+ [`${ids.releaseBuildConfigurationId}_comment`]: 'Release',
127
+ };
128
+ xcodeProject.objects.XCConfigurationList = {
129
+ ...(xcodeProject.objects.XCConfigurationList ?? {}),
130
+ [ids.buildConfigurationListId]: {
131
+ isa: 'XCConfigurationList',
132
+ buildConfigurations: [
133
+ {
134
+ value: ids.debugBuildConfigurationId,
135
+ comment: 'Debug',
136
+ },
137
+ {
138
+ value: ids.releaseBuildConfigurationId,
139
+ comment: 'Release',
140
+ },
141
+ ],
142
+ defaultConfigurationIsVisible: 0,
143
+ defaultConfigurationName: 'Release',
144
+ },
145
+ [`${ids.buildConfigurationListId}_comment`]: `Build configuration list for PBXNativeTarget "${name}"`,
146
+ };
147
+ const project = xcodeProject.objects.PBXProject?.[options.projectObjectId];
148
+ if (project && typeof project !== 'string') {
149
+ project.targets = [
150
+ ...(project.targets ?? []),
151
+ {
152
+ value: ids.targetId,
153
+ comment: name,
154
+ },
155
+ ];
156
+ }
157
+ const productsGroup = xcodeProject.objects.PBXGroup?.[options.productsGroupId];
158
+ if (productsGroup && typeof productsGroup !== 'string') {
159
+ productsGroup.children = [
160
+ ...(productsGroup.children ?? []),
161
+ {
162
+ value: ids.productReferenceId,
163
+ comment: `${name}.xctest`,
164
+ },
165
+ ];
166
+ }
167
+ return ids;
168
+ }
169
+ exports.addHostedUnitTestTarget = addHostedUnitTestTarget;
170
+ function hostedTestTargetFixtureIds(name) {
171
+ const idPrefix = name.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
172
+ return {
173
+ targetId: `${idPrefix}000000000000000001`,
174
+ frameworksBuildPhaseId: `${idPrefix}000000000000000002`,
175
+ debugBuildConfigurationId: `${idPrefix}000000000000000003`,
176
+ releaseBuildConfigurationId: `${idPrefix}000000000000000004`,
177
+ buildConfigurationListId: `${idPrefix}000000000000000005`,
178
+ productReferenceId: `${idPrefix}000000000000000006`,
179
+ };
180
+ }
181
+ exports.hostedTestTargetFixtureIds = hostedTestTargetFixtureIds;
182
+ function hostedUnitTestBuildSettings({ bundleLoader, hostAppName, name, testHost, }) {
183
+ return {
184
+ BUNDLE_LOADER: bundleLoader ?? '"$(TEST_HOST)"',
185
+ PRODUCT_BUNDLE_IDENTIFIER: `com.getsentry.${name}`,
186
+ PRODUCT_NAME: '"$(TARGET_NAME)"',
187
+ TEST_HOST: testHost ??
188
+ `"$(BUILT_PRODUCTS_DIR)/${hostAppName}.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/${hostAppName}"`,
189
+ };
190
+ }
191
+ //# sourceMappingURL=hosted-test-target-fixture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-test-target-fixture.js","sourceRoot":"","sources":["../../../../test/apple/snapshots/hosted-test-target-fixture.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,4CAA8B;AAC9B,gDAAkC;AAqBlC,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CACrC,SAAS,EACT,uGAAuG,CACxG,CAAC;AAaF,SAAgB,6BAA6B,CAAC,MAAc;IAC1D,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;IAC7D,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,EAAE,CAAC,YAAY,CACb,kBAAk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AC;AACJ,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport type {\n PBXFileReference,\n PBXNativeTarget,\n PBXSourcesBuildPhase,\n XCBuildConfiguration,\n XCConfigurationList,\n} from 'xcode';\n\nimport type { XcodeProject } from '../../../src/apple/xcode-manager';\n\nexport type HostedTestTargetFixtureIds = {\n targetId: string;\n frameworksBuildPhaseId: string;\n sourcesBuildPhaseId?: string;\n debugBuildConfigurationId: string;\n releaseBuildConfigurationId: string;\n buildConfigurationListId: string;\n productReferenceId: string;\n};\n\nconst fixtureProjectPath = path.resolve(\n __dirname,\n '../../../fixtures/test-applications/apple/spm-swiftui-single-target/Project.xcodeproj/project.pbxproj',\n);\n\ntype HostedTestTargetFixtureOptions = {\n name?: string;\n hostAppName?: string;\n testHost?: string;\n bundleLoader?: string;\n ids?: HostedTestTargetFixtureIds;\n includeSourcesBuildPhase?: boolean;\n projectObjectId: string;\n productsGroupId: string;\n};\n\nexport function copySingleTargetProjectToTemp(prefix: string): string {\n const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));\n const xcodeprojDir = path.join(tempDir, 'Project.xcodeproj');\n fs.mkdirSync(xcodeprojDir, { recursive: true });\n fs.mkdirSync(path.join(tempDir, 'Sources'), { recursive: true });\n fs.copyFileSync(\n fixtureProjectPath,\n path.join(xcodeprojDir, 'project.pbxproj'),\n );\n return path.join(xcodeprojDir, 'project.pbxproj');\n}\n\nexport function addHostedUnitTestTarget(\n xcodeProject: XcodeProject,\n options: HostedTestTargetFixtureOptions,\n): HostedTestTargetFixtureIds {\n const name = options.name ?? 'ProjectTests';\n const ids = options.ids ?? hostedTestTargetFixtureIds(name);\n const hostAppName = options.hostAppName ?? 'Project';\n const buildSettings = hostedUnitTestBuildSettings({\n bundleLoader: options.bundleLoader,\n hostAppName,\n name,\n testHost: options.testHost,\n });\n\n xcodeProject.objects.PBXFileReference = {\n ...(xcodeProject.objects.PBXFileReference ?? {}),\n [ids.productReferenceId]: {\n isa: 'PBXFileReference',\n explicitFileType: 'wrapper.cfbundle',\n includeInIndex: 0,\n path: `${name}.xctest`,\n sourceTree: 'BUILT_PRODUCTS_DIR',\n } as unknown as PBXFileReference,\n [`${ids.productReferenceId}_comment`]: `${name}.xctest`,\n };\n\n xcodeProject.objects.PBXFrameworksBuildPhase = {\n ...(xcodeProject.objects.PBXFrameworksBuildPhase ?? {}),\n [ids.frameworksBuildPhaseId]: {\n isa: 'PBXFrameworksBuildPhase',\n buildActionMask: 2147483647,\n files: [],\n runOnlyForDeploymentPostprocessing: 0,\n },\n [`${ids.frameworksBuildPhaseId}_comment`]: 'Frameworks',\n };\n\n const buildPhases = [\n ...(options.includeSourcesBuildPhase && ids.sourcesBuildPhaseId\n ? [\n {\n value: ids.sourcesBuildPhaseId,\n comment: 'Sources',\n },\n ]\n : []),\n {\n value: ids.frameworksBuildPhaseId,\n comment: 'Frameworks',\n },\n ];\n\n if (options.includeSourcesBuildPhase && ids.sourcesBuildPhaseId) {\n xcodeProject.objects.PBXSourcesBuildPhase = {\n ...(xcodeProject.objects.PBXSourcesBuildPhase ?? {}),\n [ids.sourcesBuildPhaseId]: {\n isa: 'PBXSourcesBuildPhase',\n buildActionMask: 2147483647,\n files: [],\n runOnlyForDeploymentPostprocessing: 0,\n } as PBXSourcesBuildPhase,\n [`${ids.sourcesBuildPhaseId}_comment`]: 'Sources',\n };\n }\n\n xcodeProject.objects.PBXNativeTarget = {\n ...(xcodeProject.objects.PBXNativeTarget ?? {}),\n [ids.targetId]: {\n isa: 'PBXNativeTarget',\n buildConfigurationList: ids.buildConfigurationListId,\n buildPhases,\n buildRules: [],\n dependencies: [],\n name,\n packageProductDependencies: [],\n productName: name,\n productReference: ids.productReferenceId,\n productType: '\"com.apple.product-type.bundle.unit-test\"',\n } as PBXNativeTarget,\n [`${ids.targetId}_comment`]: name,\n };\n\n xcodeProject.objects.XCBuildConfiguration = {\n ...(xcodeProject.objects.XCBuildConfiguration ?? {}),\n [ids.debugBuildConfigurationId]: {\n isa: 'XCBuildConfiguration',\n buildSettings,\n name: 'Debug',\n } as XCBuildConfiguration,\n [`${ids.debugBuildConfigurationId}_comment`]: 'Debug',\n [ids.releaseBuildConfigurationId]: {\n isa: 'XCBuildConfiguration',\n buildSettings,\n name: 'Release',\n } as XCBuildConfiguration,\n [`${ids.releaseBuildConfigurationId}_comment`]: 'Release',\n };\n\n xcodeProject.objects.XCConfigurationList = {\n ...(xcodeProject.objects.XCConfigurationList ?? {}),\n [ids.buildConfigurationListId]: {\n isa: 'XCConfigurationList',\n buildConfigurations: [\n {\n value: ids.debugBuildConfigurationId,\n comment: 'Debug',\n },\n {\n value: ids.releaseBuildConfigurationId,\n comment: 'Release',\n },\n ],\n defaultConfigurationIsVisible: 0,\n defaultConfigurationName: 'Release',\n } as XCConfigurationList,\n [`${ids.buildConfigurationListId}_comment`]: `Build configuration list for PBXNativeTarget \"${name}\"`,\n };\n\n const project = xcodeProject.objects.PBXProject?.[options.projectObjectId];\n if (project && typeof project !== 'string') {\n project.targets = [\n ...(project.targets ?? []),\n {\n value: ids.targetId,\n comment: name,\n },\n ];\n }\n\n const productsGroup =\n xcodeProject.objects.PBXGroup?.[options.productsGroupId];\n if (productsGroup && typeof productsGroup !== 'string') {\n productsGroup.children = [\n ...(productsGroup.children ?? []),\n {\n value: ids.productReferenceId,\n comment: `${name}.xctest`,\n },\n ];\n }\n\n return ids;\n}\n\nexport function hostedTestTargetFixtureIds(\n name: string,\n): HostedTestTargetFixtureIds {\n const idPrefix = name.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();\n return {\n targetId: `${idPrefix}000000000000000001`,\n frameworksBuildPhaseId: `${idPrefix}000000000000000002`,\n debugBuildConfigurationId: `${idPrefix}000000000000000003`,\n releaseBuildConfigurationId: `${idPrefix}000000000000000004`,\n buildConfigurationListId: `${idPrefix}000000000000000005`,\n productReferenceId: `${idPrefix}000000000000000006`,\n };\n}\n\nfunction hostedUnitTestBuildSettings({\n bundleLoader,\n hostAppName,\n name,\n testHost,\n}: {\n bundleLoader?: string;\n hostAppName: string;\n name: string;\n testHost?: string;\n}): Record<string, string> {\n return {\n BUNDLE_LOADER: bundleLoader ?? '\"$(TEST_HOST)\"',\n PRODUCT_BUNDLE_IDENTIFIER: `com.getsentry.${name}`,\n PRODUCT_NAME: '\"$(TARGET_NAME)\"',\n TEST_HOST:\n testHost ??\n `\"$(BUILT_PRODUCTS_DIR)/${hostAppName}.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/${hostAppName}\"`,\n };\n}\n"]}
@@ -0,0 +1,110 @@
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
+ const fs = __importStar(require("node:fs"));
27
+ const os = __importStar(require("node:os"));
28
+ const path = __importStar(require("node:path"));
29
+ const vitest_1 = require("vitest");
30
+ const snapshot_test_file_1 = require("../../../src/apple/snapshots/snapshot-test-file");
31
+ const xcode_manager_1 = require("../../../src/apple/xcode-manager");
32
+ const hosted_test_target_fixture_1 = require("./hosted-test-target-fixture");
33
+ vitest_1.vi.mock('@clack/prompts', () => ({
34
+ log: {
35
+ info: vitest_1.vi.fn(),
36
+ success: vitest_1.vi.fn(),
37
+ step: vitest_1.vi.fn(),
38
+ },
39
+ }));
40
+ (0, vitest_1.describe)('ensureSnapshotTestFile', () => {
41
+ (0, vitest_1.it)('creates a minimal SnapshotTest file and reruns without duplication', () => {
42
+ const xcodeProject = new xcode_manager_1.XcodeProject((0, hosted_test_target_fixture_1.copySingleTargetProjectToTemp)('snapshot-test-file-'));
43
+ const firstResult = (0, snapshot_test_file_1.ensureSnapshotTestFile)({
44
+ xcodeProject,
45
+ hostedTestTargetName: 'Project',
46
+ });
47
+ const secondResult = (0, snapshot_test_file_1.ensureSnapshotTestFile)({
48
+ xcodeProject,
49
+ hostedTestTargetName: 'Project',
50
+ });
51
+ (0, vitest_1.expect)(firstResult.changed).toBe(true);
52
+ (0, vitest_1.expect)(firstResult.included).toBe(true);
53
+ (0, vitest_1.expect)(secondResult.changed).toBe(false);
54
+ (0, vitest_1.expect)(secondResult.included).toBe(true);
55
+ if (!firstResult.included || !secondResult.included) {
56
+ throw new Error('Expected snapshot test files to be included');
57
+ }
58
+ (0, vitest_1.expect)(firstResult.className).toBe('ProjectSnapshotTest');
59
+ (0, vitest_1.expect)(secondResult.className).toBe('ProjectSnapshotTest');
60
+ (0, vitest_1.expect)(firstResult.filePath).toBe(path.join(xcodeProject.baseDir, 'Sources', 'ProjectSnapshotTest.swift'));
61
+ (0, vitest_1.expect)(fs.readFileSync(firstResult.filePath ?? '', 'utf8')).toContain('final class ProjectSnapshotTest: SnapshotTest');
62
+ (0, vitest_1.expect)(xcodeProject
63
+ .getSourceFilesForTarget('Project')
64
+ ?.filter((filePath) => filePath.endsWith('ProjectSnapshotTest.swift'))).toHaveLength(1);
65
+ });
66
+ (0, vitest_1.it)('reuses the actual SnapshotTest class name from an existing file', () => {
67
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'snapshot-test-file-existing-'));
68
+ const existingFilePath = path.join(tempDir, 'CustomSnapshots.swift');
69
+ fs.writeFileSync(existingFilePath, 'import SnapshottingTests\n\nfinal class CustomSnapshots: SnapshotTest {}\n', 'utf8');
70
+ const addSwiftSourceFileToTarget = vitest_1.vi.fn();
71
+ const xcodeProject = {
72
+ addSwiftSourceFileToTarget,
73
+ getSourceFilesForTarget: vitest_1.vi.fn(() => [existingFilePath]),
74
+ getSynchronizedRootGroupPathsForTarget: vitest_1.vi.fn(() => []),
75
+ };
76
+ const result = (0, snapshot_test_file_1.ensureSnapshotTestFile)({
77
+ xcodeProject,
78
+ hostedTestTargetName: 'ProjectTests',
79
+ });
80
+ (0, vitest_1.expect)(result).toEqual({
81
+ changed: false,
82
+ className: 'CustomSnapshots',
83
+ filePath: existingFilePath,
84
+ included: true,
85
+ });
86
+ (0, vitest_1.expect)(addSwiftSourceFileToTarget).not.toHaveBeenCalled();
87
+ });
88
+ (0, vitest_1.it)('removes a newly created SnapshotTest file when target membership fails', () => {
89
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'snapshot-test-file-fail-'));
90
+ const xcodeProject = {
91
+ baseDir: tempDir,
92
+ addSwiftSourceFileToTarget: vitest_1.vi.fn(() => ({
93
+ changed: false,
94
+ included: false,
95
+ })),
96
+ getSourceFilesForTarget: vitest_1.vi.fn(() => []),
97
+ getSynchronizedRootGroupPathsForTarget: vitest_1.vi.fn(() => []),
98
+ };
99
+ const result = (0, snapshot_test_file_1.ensureSnapshotTestFile)({
100
+ xcodeProject,
101
+ hostedTestTargetName: 'ProjectTests',
102
+ });
103
+ (0, vitest_1.expect)(result).toEqual({ changed: false, included: false });
104
+ (0, vitest_1.expect)(fs.existsSync(path.join(tempDir, 'ProjectTests', 'ProjectTestsSnapshotTest.swift'))).toBe(false);
105
+ });
106
+ (0, vitest_1.it)('generates Swift-safe type names', () => {
107
+ (0, vitest_1.expect)((0, snapshot_test_file_1.swiftSafeTypeName)('123 My-App Tests')).toBe('_123MyAppTests');
108
+ });
109
+ });
110
+ //# sourceMappingURL=snapshot-test-file.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-test-file.test.js","sourceRoot":"","sources":["../../../../test/apple/snapshots/snapshot-test-file.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,4CAA8B;AAC9B,gDAAkC;AAClC,mCAAkD;AAElD,wFAGyD;AACzD,oEAAgE;AAChE,6EAA6E;AAE7E,WAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC;IAC/B,GAAG,EAAE;QACH,IAAI,EAAE,WAAE,CAAC,EAAE,EAAE;QACb,OAAO,EAAE,WAAE,CAAC,EAAE,EAAE;QAChB,IAAI,EAAE,WAAE,CAAC,EAAE,EAAE;KACd;CACF,CAAC,CAAC,CAAC;AAEJ,IAAA,iBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,IAAA,WAAE,EAAC,oEAAoE,EAAE,GAAG,EAAE;QAC5E,MAAM,YAAY,GAAG,IAAI,4BAAY,CACnC,IAAA,0DAA6B,EAAC,qBAAqB,CAAC,CACrD,CAAC;QAEF,MAAM,WAAW,GAAG,IAAA,2CAAsB,EAAC;YACzC,YAAY;YACZ,oBAAoB,EAAE,SAAS;SAChC,CAAC,CAAC;QACH,MAAM,YAAY,GAAG,IAAA,2CAAsB,EAAC;YAC1C,YAAY;YACZ,oBAAoB,EAAE,SAAS;SAChC,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,IAAA,eAAM,EAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,IAAA,eAAM,EAAC,YAAY,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC,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,EAAC;YACpC,YAAY;YACZ,oBAAoB,EAAE,cAAc;SACrC,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAA,eAAM,EACJ,EAAE,CAAC,UAAU,CACX,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,gCAAgC,CAAC,CACrE,CACF,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,IAAA,eAAM,EAAC,IAAA,sCAAiB,EAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport { describe, expect, it, vi } from 'vitest';\n\nimport {\n ensureSnapshotTestFile,\n swiftSafeTypeName,\n} from '../../../src/apple/snapshots/snapshot-test-file';\nimport { XcodeProject } from '../../../src/apple/xcode-manager';\nimport { copySingleTargetProjectToTemp } from './hosted-test-target-fixture';\n\nvi.mock('@clack/prompts', () => ({\n log: {\n info: vi.fn(),\n success: vi.fn(),\n step: vi.fn(),\n },\n}));\n\ndescribe('ensureSnapshotTestFile', () => {\n it('creates a minimal SnapshotTest file and reruns without duplication', () => {\n const xcodeProject = new XcodeProject(\n copySingleTargetProjectToTemp('snapshot-test-file-'),\n );\n\n const firstResult = ensureSnapshotTestFile({\n xcodeProject,\n hostedTestTargetName: 'Project',\n });\n const secondResult = ensureSnapshotTestFile({\n xcodeProject,\n hostedTestTargetName: 'Project',\n });\n\n expect(firstResult.changed).toBe(true);\n expect(firstResult.included).toBe(true);\n expect(secondResult.changed).toBe(false);\n expect(secondResult.included).toBe(true);\n if (!firstResult.included || !secondResult.included) {\n throw new Error('Expected snapshot test files to be included');\n }\n expect(firstResult.className).toBe('ProjectSnapshotTest');\n expect(secondResult.className).toBe('ProjectSnapshotTest');\n expect(firstResult.filePath).toBe(\n path.join(xcodeProject.baseDir, 'Sources', 'ProjectSnapshotTest.swift'),\n );\n expect(fs.readFileSync(firstResult.filePath ?? '', 'utf8')).toContain(\n 'final class ProjectSnapshotTest: SnapshotTest',\n );\n expect(\n xcodeProject\n .getSourceFilesForTarget('Project')\n ?.filter((filePath) => filePath.endsWith('ProjectSnapshotTest.swift')),\n ).toHaveLength(1);\n });\n\n it('reuses the actual SnapshotTest class name from an existing file', () => {\n const tempDir = fs.mkdtempSync(\n path.join(os.tmpdir(), 'snapshot-test-file-existing-'),\n );\n const existingFilePath = path.join(tempDir, 'CustomSnapshots.swift');\n fs.writeFileSync(\n existingFilePath,\n 'import SnapshottingTests\\n\\nfinal class CustomSnapshots: SnapshotTest {}\\n',\n 'utf8',\n );\n const addSwiftSourceFileToTarget = vi.fn();\n const xcodeProject = {\n addSwiftSourceFileToTarget,\n getSourceFilesForTarget: vi.fn(() => [existingFilePath]),\n getSynchronizedRootGroupPathsForTarget: vi.fn(() => []),\n } as unknown as XcodeProject;\n\n const result = ensureSnapshotTestFile({\n xcodeProject,\n hostedTestTargetName: 'ProjectTests',\n });\n\n expect(result).toEqual({\n changed: false,\n className: 'CustomSnapshots',\n filePath: existingFilePath,\n included: true,\n });\n expect(addSwiftSourceFileToTarget).not.toHaveBeenCalled();\n });\n\n it('removes a newly created SnapshotTest file when target membership fails', () => {\n const tempDir = fs.mkdtempSync(\n path.join(os.tmpdir(), 'snapshot-test-file-fail-'),\n );\n const xcodeProject = {\n baseDir: tempDir,\n addSwiftSourceFileToTarget: vi.fn(() => ({\n changed: false,\n included: false,\n })),\n getSourceFilesForTarget: vi.fn(() => []),\n getSynchronizedRootGroupPathsForTarget: vi.fn(() => []),\n } as unknown as XcodeProject;\n\n const result = ensureSnapshotTestFile({\n xcodeProject,\n hostedTestTargetName: 'ProjectTests',\n });\n\n expect(result).toEqual({ changed: false, included: false });\n expect(\n fs.existsSync(\n path.join(tempDir, 'ProjectTests', 'ProjectTestsSnapshotTest.swift'),\n ),\n ).toBe(false);\n });\n\n it('generates Swift-safe type names', () => {\n expect(swiftSafeTypeName('123 My-App Tests')).toBe('_123MyAppTests');\n });\n});\n"]}
@@ -0,0 +1,146 @@
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
+ const fs = __importStar(require("node:fs"));
27
+ const os = __importStar(require("node:os"));
28
+ const path = __importStar(require("node:path"));
29
+ const vitest_1 = require("vitest");
30
+ const snapshot_verification_scheme_1 = require("../../../src/apple/snapshots/snapshot-verification-scheme");
31
+ function createXcodeProject() {
32
+ const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'snapshot-verification-scheme-'));
33
+ const xcodeprojPath = path.join(projectDir, 'App.xcodeproj');
34
+ fs.mkdirSync(xcodeprojPath, { recursive: true });
35
+ return xcodeprojPath;
36
+ }
37
+ function writeScheme({ name, testTargetNames, xcodeprojPath, }) {
38
+ const schemeDirectory = path.join(xcodeprojPath, 'xcshareddata', 'xcschemes');
39
+ fs.mkdirSync(schemeDirectory, { recursive: true });
40
+ fs.writeFileSync(path.join(schemeDirectory, `${name}.xcscheme`), getSchemeXml(testTargetNames), 'utf8');
41
+ }
42
+ function writeSchemeManagementPlist({ schemeNames, xcodeprojPath, }) {
43
+ const schemeDirectory = path.join(xcodeprojPath, 'xcuserdata', 'cam.xcuserdatad', 'xcschemes');
44
+ fs.mkdirSync(schemeDirectory, { recursive: true });
45
+ fs.writeFileSync(path.join(schemeDirectory, 'xcschememanagement.plist'), getSchemeManagementPlistXml(schemeNames), 'utf8');
46
+ }
47
+ function getSchemeXml(testTargetNames) {
48
+ return `<?xml version="1.0" encoding="UTF-8"?>
49
+ <Scheme version="1.7">
50
+ <TestAction>
51
+ <Testables>
52
+ ${testTargetNames
53
+ .map((testTargetName) => ` <TestableReference skipped="NO">
54
+ <BuildableReference
55
+ BlueprintIdentifier="${testTargetName.toUpperCase()}ID"
56
+ BlueprintName="${testTargetName}"
57
+ BuildableName="${testTargetName}.xctest">
58
+ </BuildableReference>
59
+ </TestableReference>`)
60
+ .join('\n')}
61
+ </Testables>
62
+ </TestAction>
63
+ </Scheme>
64
+ `;
65
+ }
66
+ function getSchemeManagementPlistXml(schemeNames) {
67
+ return `<?xml version="1.0" encoding="UTF-8"?>
68
+ <plist version="1.0">
69
+ <dict>
70
+ <key>SchemeUserState</key>
71
+ <dict>
72
+ ${schemeNames
73
+ .map((schemeName) => ` <key>${schemeName}.xcscheme_^#shared#^_</key>
74
+ <dict>
75
+ <key>orderHint</key>
76
+ <integer>0</integer>
77
+ </dict>`)
78
+ .join('\n')}
79
+ </dict>
80
+ </dict>
81
+ </plist>
82
+ `;
83
+ }
84
+ (0, vitest_1.describe)('resolveSnapshotVerificationSchemeName', () => {
85
+ (0, vitest_1.it)('returns the explicit scheme that contains the hosted test target', () => {
86
+ const xcodeprojPath = createXcodeProject();
87
+ writeScheme({
88
+ name: 'App-Staging',
89
+ testTargetNames: ['AppTests'],
90
+ xcodeprojPath,
91
+ });
92
+ writeScheme({
93
+ name: 'App-Production',
94
+ testTargetNames: ['OtherTests'],
95
+ xcodeprojPath,
96
+ });
97
+ (0, vitest_1.expect)((0, snapshot_verification_scheme_1.resolveSnapshotVerificationSchemeName)({
98
+ hostedTestTargetName: 'AppTests',
99
+ xcodeprojPath,
100
+ })).toBe('App-Staging');
101
+ });
102
+ (0, vitest_1.it)('returns undefined when the only explicit scheme does not contain the hosted test target', () => {
103
+ const xcodeprojPath = createXcodeProject();
104
+ writeScheme({
105
+ name: 'App-CI',
106
+ testTargetNames: ['OtherTests'],
107
+ xcodeprojPath,
108
+ });
109
+ (0, vitest_1.expect)((0, snapshot_verification_scheme_1.resolveSnapshotVerificationSchemeName)({
110
+ hostedTestTargetName: 'AppTests',
111
+ xcodeprojPath,
112
+ })).toBeUndefined();
113
+ });
114
+ (0, vitest_1.it)('returns the only managed implicit scheme when no scheme file exists', () => {
115
+ const xcodeprojPath = createXcodeProject();
116
+ writeSchemeManagementPlist({
117
+ schemeNames: ['cake'],
118
+ xcodeprojPath,
119
+ });
120
+ (0, vitest_1.expect)((0, snapshot_verification_scheme_1.resolveSnapshotVerificationSchemeName)({
121
+ hostedTestTargetName: 'sausageTests',
122
+ xcodeprojPath,
123
+ })).toBe('cake');
124
+ });
125
+ (0, vitest_1.it)('returns undefined for ambiguous schemes', () => {
126
+ const xcodeprojPath = createXcodeProject();
127
+ writeSchemeManagementPlist({
128
+ schemeNames: ['App-Staging', 'App-Production'],
129
+ xcodeprojPath,
130
+ });
131
+ (0, vitest_1.expect)((0, snapshot_verification_scheme_1.resolveSnapshotVerificationSchemeName)({
132
+ hostedTestTargetName: 'AppTests',
133
+ xcodeprojPath,
134
+ })).toBeUndefined();
135
+ });
136
+ (0, vitest_1.it)('returns undefined when scheme discovery cannot traverse the project path', () => {
137
+ const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'snapshot-verification-scheme-file-'));
138
+ const xcodeprojPath = path.join(projectDir, 'App.xcodeproj');
139
+ fs.writeFileSync(xcodeprojPath, '', 'utf8');
140
+ (0, vitest_1.expect)((0, snapshot_verification_scheme_1.resolveSnapshotVerificationSchemeName)({
141
+ hostedTestTargetName: 'AppTests',
142
+ xcodeprojPath,
143
+ })).toBeUndefined();
144
+ });
145
+ });
146
+ //# sourceMappingURL=snapshot-verification-scheme.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-verification-scheme.test.js","sourceRoot":"","sources":["../../../../test/apple/snapshots/snapshot-verification-scheme.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,4CAA8B;AAC9B,gDAAkC;AAClC,mCAA8C;AAE9C,4GAAkH;AAElH,SAAS,kBAAkB;IACzB,MAAM,UAAU,GAAG,EAAE,CAAC,WAAW,CAC/B,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,+BAA+B,CAAC,CACxD,CAAC;IACF,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAC7D,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,WAAW,CAAC,EACnB,IAAI,EACJ,eAAe,EACf,aAAa,GAKd;IACC,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;IAC9E,EAAE,CAAC,SAAS,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,EAAE,CAAC,aAAa,CACd,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,I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,WAAE,EAAC,0EAA0E,EAAE,GAAG,EAAE;QAClF,MAAM,UAAU,GAAG,EAAE,CAAC,WAAW,CAC/B,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,oCAAoC,CAAC,CAC7D,CAAC;QACF,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QAC7D,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAE5C,IAAA,eAAM,EACJ,IAAA,oEAAqC,EAAC;YACpC,oBAAoB,EAAE,UAAU;YAChC,aAAa;SACd,CAAC,CACH,CAAC,aAAa,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport { describe, expect, it } from 'vitest';\n\nimport { resolveSnapshotVerificationSchemeName } from '../../../src/apple/snapshots/snapshot-verification-scheme';\n\nfunction createXcodeProject(): string {\n const projectDir = fs.mkdtempSync(\n path.join(os.tmpdir(), 'snapshot-verification-scheme-'),\n );\n const xcodeprojPath = path.join(projectDir, 'App.xcodeproj');\n fs.mkdirSync(xcodeprojPath, { recursive: true });\n return xcodeprojPath;\n}\n\nfunction writeScheme({\n name,\n testTargetNames,\n xcodeprojPath,\n}: {\n name: string;\n testTargetNames: string[];\n xcodeprojPath: string;\n}): void {\n const schemeDirectory = path.join(xcodeprojPath, 'xcshareddata', 'xcschemes');\n fs.mkdirSync(schemeDirectory, { recursive: true });\n fs.writeFileSync(\n path.join(schemeDirectory, `${name}.xcscheme`),\n getSchemeXml(testTargetNames),\n 'utf8',\n );\n}\n\nfunction writeSchemeManagementPlist({\n schemeNames,\n xcodeprojPath,\n}: {\n schemeNames: string[];\n xcodeprojPath: string;\n}): void {\n const schemeDirectory = path.join(\n xcodeprojPath,\n 'xcuserdata',\n 'cam.xcuserdatad',\n 'xcschemes',\n );\n fs.mkdirSync(schemeDirectory, { recursive: true });\n fs.writeFileSync(\n path.join(schemeDirectory, 'xcschememanagement.plist'),\n getSchemeManagementPlistXml(schemeNames),\n 'utf8',\n );\n}\n\nfunction getSchemeXml(testTargetNames: string[]): string {\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme version=\"1.7\">\n <TestAction>\n <Testables>\n${testTargetNames\n .map(\n (testTargetName) => ` <TestableReference skipped=\"NO\">\n <BuildableReference\n BlueprintIdentifier=\"${testTargetName.toUpperCase()}ID\"\n BlueprintName=\"${testTargetName}\"\n BuildableName=\"${testTargetName}.xctest\">\n </BuildableReference>\n </TestableReference>`,\n )\n .join('\\n')}\n </Testables>\n </TestAction>\n</Scheme>\n`;\n}\n\nfunction getSchemeManagementPlistXml(schemeNames: string[]): string {\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<plist version=\"1.0\">\n <dict>\n <key>SchemeUserState</key>\n <dict>\n${schemeNames\n .map(\n (schemeName) => ` <key>${schemeName}.xcscheme_^#shared#^_</key>\n <dict>\n <key>orderHint</key>\n <integer>0</integer>\n </dict>`,\n )\n .join('\\n')}\n </dict>\n </dict>\n</plist>\n`;\n}\n\ndescribe('resolveSnapshotVerificationSchemeName', () => {\n it('returns the explicit scheme that contains the hosted test target', () => {\n const xcodeprojPath = createXcodeProject();\n writeScheme({\n name: 'App-Staging',\n testTargetNames: ['AppTests'],\n xcodeprojPath,\n });\n writeScheme({\n name: 'App-Production',\n testTargetNames: ['OtherTests'],\n xcodeprojPath,\n });\n\n expect(\n resolveSnapshotVerificationSchemeName({\n hostedTestTargetName: 'AppTests',\n xcodeprojPath,\n }),\n ).toBe('App-Staging');\n });\n\n it('returns undefined when the only explicit scheme does not contain the hosted test target', () => {\n const xcodeprojPath = createXcodeProject();\n writeScheme({\n name: 'App-CI',\n testTargetNames: ['OtherTests'],\n xcodeprojPath,\n });\n\n expect(\n resolveSnapshotVerificationSchemeName({\n hostedTestTargetName: 'AppTests',\n xcodeprojPath,\n }),\n ).toBeUndefined();\n });\n\n it('returns the only managed implicit scheme when no scheme file exists', () => {\n const xcodeprojPath = createXcodeProject();\n writeSchemeManagementPlist({\n schemeNames: ['cake'],\n xcodeprojPath,\n });\n\n expect(\n resolveSnapshotVerificationSchemeName({\n hostedTestTargetName: 'sausageTests',\n xcodeprojPath,\n }),\n ).toBe('cake');\n });\n\n it('returns undefined for ambiguous schemes', () => {\n const xcodeprojPath = createXcodeProject();\n writeSchemeManagementPlist({\n schemeNames: ['App-Staging', 'App-Production'],\n xcodeprojPath,\n });\n\n expect(\n resolveSnapshotVerificationSchemeName({\n hostedTestTargetName: 'AppTests',\n xcodeprojPath,\n }),\n ).toBeUndefined();\n });\n\n it('returns undefined when scheme discovery cannot traverse the project path', () => {\n const projectDir = fs.mkdtempSync(\n path.join(os.tmpdir(), 'snapshot-verification-scheme-file-'),\n );\n const xcodeprojPath = path.join(projectDir, 'App.xcodeproj');\n fs.writeFileSync(xcodeprojPath, '', 'utf8');\n\n expect(\n resolveSnapshotVerificationSchemeName({\n hostedTestTargetName: 'AppTests',\n xcodeprojPath,\n }),\n ).toBeUndefined();\n });\n});\n"]}