ios-app-review-plugin 1.0.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 (205) hide show
  1. package/.claude/settings.local.json +42 -0
  2. package/.github/actions/ios-review/action.yml +106 -0
  3. package/.github/workflows/ci.yml +103 -0
  4. package/.github/workflows/publish.yml +57 -0
  5. package/CHANGELOG.md +66 -0
  6. package/CONTRIBUTING.md +175 -0
  7. package/LICENSE +21 -0
  8. package/README.md +205 -0
  9. package/bitrise/step.sh +128 -0
  10. package/bitrise/step.yml +101 -0
  11. package/dist/analyzer.d.ts.map +1 -0
  12. package/dist/analyzers/asc-iap.d.ts.map +1 -0
  13. package/dist/analyzers/asc-metadata.d.ts.map +1 -0
  14. package/dist/analyzers/asc-screenshots.d.ts.map +1 -0
  15. package/dist/analyzers/asc-version.d.ts.map +1 -0
  16. package/dist/analyzers/code-scanner.d.ts.map +1 -0
  17. package/dist/analyzers/deprecated-api.d.ts.map +1 -0
  18. package/dist/analyzers/entitlements.d.ts.map +1 -0
  19. package/dist/analyzers/index.d.ts.map +1 -0
  20. package/dist/analyzers/info-plist.d.ts.map +1 -0
  21. package/dist/analyzers/privacy.d.ts.map +1 -0
  22. package/dist/analyzers/private-api.d.ts.map +1 -0
  23. package/dist/analyzers/security.d.ts.map +1 -0
  24. package/dist/analyzers/ui-ux.d.ts.map +1 -0
  25. package/dist/asc/auth.d.ts.map +1 -0
  26. package/dist/asc/client.d.ts.map +1 -0
  27. package/dist/asc/endpoints/apps.d.ts.map +1 -0
  28. package/dist/asc/endpoints/iap.d.ts.map +1 -0
  29. package/dist/asc/endpoints/screenshots.d.ts.map +1 -0
  30. package/dist/asc/endpoints/versions.d.ts.map +1 -0
  31. package/dist/asc/errors.d.ts.map +1 -0
  32. package/dist/asc/index.d.ts.map +1 -0
  33. package/dist/asc/types.d.ts.map +1 -0
  34. package/dist/badge/generator.d.ts.map +1 -0
  35. package/dist/badge/index.d.ts.map +1 -0
  36. package/dist/badge/types.d.ts.map +1 -0
  37. package/dist/cache/file-cache.d.ts.map +1 -0
  38. package/dist/cache/index.d.ts.map +1 -0
  39. package/dist/cache/types.d.ts.map +1 -0
  40. package/dist/cli/commands/help.d.ts.map +1 -0
  41. package/dist/cli/commands/scan.d.ts.map +1 -0
  42. package/dist/cli/commands/version.d.ts.map +1 -0
  43. package/dist/cli/index.d.ts.map +1 -0
  44. package/dist/cli/types.d.ts.map +1 -0
  45. package/dist/git/diff.d.ts.map +1 -0
  46. package/dist/git/index.d.ts.map +1 -0
  47. package/dist/git/types.d.ts.map +1 -0
  48. package/dist/guidelines/database.d.ts.map +1 -0
  49. package/dist/guidelines/index.d.ts.map +1 -0
  50. package/dist/guidelines/matcher.d.ts.map +1 -0
  51. package/dist/guidelines/types.d.ts.map +1 -0
  52. package/dist/history/comparator.d.ts.map +1 -0
  53. package/dist/history/index.d.ts.map +1 -0
  54. package/dist/history/store.d.ts.map +1 -0
  55. package/dist/history/types.d.ts.map +1 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +994 -0
  58. package/dist/parsers/index.d.ts.map +1 -0
  59. package/dist/parsers/plist.d.ts.map +1 -0
  60. package/dist/parsers/xcodeproj.d.ts.map +1 -0
  61. package/dist/progress/index.d.ts.map +1 -0
  62. package/dist/progress/reporter.d.ts.map +1 -0
  63. package/dist/progress/types.d.ts.map +1 -0
  64. package/dist/reports/html.d.ts.map +1 -0
  65. package/dist/reports/index.d.ts.map +1 -0
  66. package/dist/reports/json.d.ts.map +1 -0
  67. package/dist/reports/markdown.d.ts.map +1 -0
  68. package/dist/reports/types.d.ts.map +1 -0
  69. package/dist/rules/engine.d.ts.map +1 -0
  70. package/dist/rules/index.d.ts.map +1 -0
  71. package/dist/rules/loader.d.ts.map +1 -0
  72. package/dist/rules/types.d.ts.map +1 -0
  73. package/dist/types/index.d.ts.map +1 -0
  74. package/docs/ANALYZERS.md +237 -0
  75. package/docs/API.md +308 -0
  76. package/docs/BADGES.md +130 -0
  77. package/docs/CI_CD.md +283 -0
  78. package/docs/CLI.md +140 -0
  79. package/docs/REPORTS.md +212 -0
  80. package/docs/ROADMAP.md +267 -0
  81. package/docs/RULES.md +182 -0
  82. package/docs/SECURITY.md +89 -0
  83. package/docs/TROUBLESHOOTING.md +227 -0
  84. package/docs/tutorials/ASC_SETUP.md +188 -0
  85. package/docs/tutorials/CI_INTEGRATION.md +292 -0
  86. package/docs/tutorials/CUSTOM_RULES.md +291 -0
  87. package/docs/tutorials/GETTING_STARTED.md +226 -0
  88. package/docs/video-scripts/01-introduction.md +106 -0
  89. package/docs/video-scripts/02-cli-usage.md +120 -0
  90. package/docs/video-scripts/03-ci-integration.md +198 -0
  91. package/eslint.config.js +33 -0
  92. package/examples/.ios-review-rules.json +82 -0
  93. package/examples/bitrise-workflow.yml +129 -0
  94. package/examples/fastlane-lane.rb +71 -0
  95. package/examples/github-action.yml +147 -0
  96. package/fastlane/Fastfile.example +114 -0
  97. package/fastlane/README.md +99 -0
  98. package/jest.config.js +36 -0
  99. package/package.json +65 -0
  100. package/scripts/benchmark.ts +112 -0
  101. package/scripts/debug-parser.ts +37 -0
  102. package/scripts/debug-pbxproj.ts +36 -0
  103. package/scripts/debug-specific.ts +47 -0
  104. package/scripts/test-analyze.ts +67 -0
  105. package/scripts/xcode-cloud-review.sh +167 -0
  106. package/src/analyzer.ts +227 -0
  107. package/src/analyzers/asc-iap.ts +300 -0
  108. package/src/analyzers/asc-metadata.ts +326 -0
  109. package/src/analyzers/asc-screenshots.ts +310 -0
  110. package/src/analyzers/asc-version.ts +368 -0
  111. package/src/analyzers/code-scanner.ts +408 -0
  112. package/src/analyzers/deprecated-api.ts +390 -0
  113. package/src/analyzers/entitlements.ts +345 -0
  114. package/src/analyzers/index.ts +12 -0
  115. package/src/analyzers/info-plist.ts +409 -0
  116. package/src/analyzers/privacy.ts +376 -0
  117. package/src/analyzers/private-api.ts +377 -0
  118. package/src/analyzers/security.ts +327 -0
  119. package/src/analyzers/ui-ux.ts +509 -0
  120. package/src/asc/auth.ts +204 -0
  121. package/src/asc/client.ts +258 -0
  122. package/src/asc/endpoints/apps.ts +115 -0
  123. package/src/asc/endpoints/iap.ts +171 -0
  124. package/src/asc/endpoints/screenshots.ts +164 -0
  125. package/src/asc/endpoints/versions.ts +174 -0
  126. package/src/asc/errors.ts +109 -0
  127. package/src/asc/index.ts +108 -0
  128. package/src/asc/types.ts +369 -0
  129. package/src/badge/generator.ts +48 -0
  130. package/src/badge/index.ts +2 -0
  131. package/src/badge/types.ts +5 -0
  132. package/src/cache/file-cache.ts +75 -0
  133. package/src/cache/index.ts +2 -0
  134. package/src/cache/types.ts +10 -0
  135. package/src/cli/commands/help.ts +41 -0
  136. package/src/cli/commands/scan.ts +44 -0
  137. package/src/cli/commands/version.ts +12 -0
  138. package/src/cli/index.ts +92 -0
  139. package/src/cli/types.ts +17 -0
  140. package/src/git/diff.ts +21 -0
  141. package/src/git/index.ts +2 -0
  142. package/src/git/types.ts +5 -0
  143. package/src/guidelines/database.ts +344 -0
  144. package/src/guidelines/index.ts +4 -0
  145. package/src/guidelines/matcher.ts +84 -0
  146. package/src/guidelines/types.ts +28 -0
  147. package/src/history/comparator.ts +114 -0
  148. package/src/history/index.ts +3 -0
  149. package/src/history/store.ts +135 -0
  150. package/src/history/types.ts +40 -0
  151. package/src/index.ts +1113 -0
  152. package/src/parsers/index.ts +3 -0
  153. package/src/parsers/plist.ts +253 -0
  154. package/src/parsers/xcodeproj.ts +265 -0
  155. package/src/progress/index.ts +2 -0
  156. package/src/progress/reporter.ts +65 -0
  157. package/src/progress/types.ts +9 -0
  158. package/src/reports/html.ts +322 -0
  159. package/src/reports/index.ts +20 -0
  160. package/src/reports/json.ts +92 -0
  161. package/src/reports/markdown.ts +187 -0
  162. package/src/reports/types.ts +26 -0
  163. package/src/rules/engine.ts +121 -0
  164. package/src/rules/index.ts +3 -0
  165. package/src/rules/loader.ts +83 -0
  166. package/src/rules/types.ts +25 -0
  167. package/src/types/index.ts +247 -0
  168. package/tests/analyzer.test.ts +142 -0
  169. package/tests/analyzers/asc-iap.test.ts +228 -0
  170. package/tests/analyzers/asc-metadata.test.ts +210 -0
  171. package/tests/analyzers/asc-screenshots.test.ts +135 -0
  172. package/tests/analyzers/asc-version.test.ts +259 -0
  173. package/tests/analyzers/code-scanner.test.ts +745 -0
  174. package/tests/analyzers/deprecated-api.test.ts +286 -0
  175. package/tests/analyzers/entitlements.test.ts +411 -0
  176. package/tests/analyzers/info-plist.test.ts +148 -0
  177. package/tests/analyzers/privacy.test.ts +623 -0
  178. package/tests/analyzers/private-api.test.ts +255 -0
  179. package/tests/analyzers/security.test.ts +300 -0
  180. package/tests/analyzers/ui-ux.test.ts +357 -0
  181. package/tests/asc/auth.test.ts +189 -0
  182. package/tests/asc/client.test.ts +207 -0
  183. package/tests/asc/endpoints.test.ts +1359 -0
  184. package/tests/badge/generator.test.ts +73 -0
  185. package/tests/cache/file-cache.test.ts +124 -0
  186. package/tests/cli/cli-index.test.ts +510 -0
  187. package/tests/cli/commands.test.ts +67 -0
  188. package/tests/cli/scan.test.ts +152 -0
  189. package/tests/git/diff.test.ts +69 -0
  190. package/tests/guidelines/matcher.test.ts +209 -0
  191. package/tests/history/comparator.test.ts +272 -0
  192. package/tests/history/store.test.ts +200 -0
  193. package/tests/integration/cli.test.ts +95 -0
  194. package/tests/integration/e2e.test.ts +130 -0
  195. package/tests/parsers/plist.test.ts +240 -0
  196. package/tests/parsers/xcodeproj.test.ts +289 -0
  197. package/tests/progress/reporter.test.ts +117 -0
  198. package/tests/reports/html.test.ts +176 -0
  199. package/tests/reports/json.test.ts +235 -0
  200. package/tests/reports/markdown.test.ts +196 -0
  201. package/tests/rules/engine.test.ts +229 -0
  202. package/tests/rules/loader.test.ts +187 -0
  203. package/tests/setup.ts +15 -0
  204. package/tsconfig.json +27 -0
  205. package/tsconfig.test.json +9 -0
@@ -0,0 +1,207 @@
1
+ import { ASCAPIError, ASCAuthError } from '../../src/asc/errors';
2
+
3
+ // Mock the auth module before importing client
4
+ jest.mock('../../src/asc/auth', () => ({
5
+ getToken: jest.fn().mockResolvedValue('mock-jwt-token'),
6
+ }));
7
+
8
+ import { get, getAllPages, resetRateLimiter } from '../../src/asc/client';
9
+
10
+ // Save original fetch
11
+ const originalFetch = global.fetch;
12
+
13
+ describe('ASC Client', () => {
14
+ let mockFetch: jest.Mock;
15
+
16
+ beforeEach(() => {
17
+ mockFetch = jest.fn();
18
+ global.fetch = mockFetch;
19
+ resetRateLimiter();
20
+ });
21
+
22
+ afterEach(() => {
23
+ global.fetch = originalFetch;
24
+ });
25
+
26
+ describe('get', () => {
27
+ it('should make authenticated GET request', async () => {
28
+ const mockData = { data: { id: '123', type: 'apps' } };
29
+ mockFetch.mockResolvedValueOnce({
30
+ ok: true,
31
+ status: 200,
32
+ json: async () => mockData,
33
+ });
34
+
35
+ const result = await get('/apps');
36
+
37
+ expect(mockFetch).toHaveBeenCalledWith(
38
+ 'https://api.appstoreconnect.apple.com/v1/apps',
39
+ expect.objectContaining({
40
+ method: 'GET',
41
+ headers: expect.objectContaining({
42
+ Authorization: 'Bearer mock-jwt-token',
43
+ }),
44
+ })
45
+ );
46
+ expect(result).toEqual(mockData);
47
+ });
48
+
49
+ it('should append query parameters', async () => {
50
+ const mockData = { data: [] };
51
+ mockFetch.mockResolvedValueOnce({
52
+ ok: true,
53
+ status: 200,
54
+ json: async () => mockData,
55
+ });
56
+
57
+ await get('/apps', { 'filter[bundleId]': 'com.test.app', limit: 10 });
58
+
59
+ const calledUrl = mockFetch.mock.calls[0]?.[0] as string;
60
+ expect(calledUrl).toContain('filter%5BbundleId%5D=com.test.app');
61
+ expect(calledUrl).toContain('limit=10');
62
+ });
63
+
64
+ it('should skip undefined parameters', async () => {
65
+ const mockData = { data: [] };
66
+ mockFetch.mockResolvedValueOnce({
67
+ ok: true,
68
+ status: 200,
69
+ json: async () => mockData,
70
+ });
71
+
72
+ await get('/apps', { 'filter[bundleId]': 'com.test.app', limit: undefined });
73
+
74
+ const calledUrl = mockFetch.mock.calls[0]?.[0] as string;
75
+ expect(calledUrl).toContain('filter%5BbundleId%5D=com.test.app');
76
+ expect(calledUrl).not.toContain('limit');
77
+ });
78
+ });
79
+
80
+ describe('error handling', () => {
81
+ it('should throw ASCAuthError on 401', async () => {
82
+ mockFetch.mockResolvedValueOnce({
83
+ ok: false,
84
+ status: 401,
85
+ headers: new Headers(),
86
+ text: async () => JSON.stringify({ errors: [{ detail: 'Unauthorized' }] }),
87
+ });
88
+
89
+ await expect(get('/apps')).rejects.toThrow(ASCAuthError);
90
+ });
91
+
92
+ it('should throw ASCAuthError on 403', async () => {
93
+ mockFetch.mockResolvedValueOnce({
94
+ ok: false,
95
+ status: 403,
96
+ headers: new Headers(),
97
+ text: async () => JSON.stringify({ errors: [{ detail: 'Forbidden' }] }),
98
+ });
99
+
100
+ await expect(get('/apps')).rejects.toThrow(ASCAuthError);
101
+ });
102
+
103
+ it('should throw ASCAPIError on other errors', async () => {
104
+ mockFetch.mockResolvedValueOnce({
105
+ ok: false,
106
+ status: 404,
107
+ headers: new Headers(),
108
+ text: async () =>
109
+ JSON.stringify({
110
+ errors: [{ title: 'Not Found', detail: 'App not found', status: '404' }],
111
+ }),
112
+ });
113
+
114
+ await expect(get('/apps/123')).rejects.toThrow(ASCAPIError);
115
+ });
116
+
117
+ it('should retry on 429 with Retry-After header', async () => {
118
+ // First call returns 429
119
+ mockFetch
120
+ .mockResolvedValueOnce({
121
+ ok: false,
122
+ status: 429,
123
+ headers: new Headers({ 'Retry-After': '1' }),
124
+ text: async () => '',
125
+ })
126
+ // Second call succeeds
127
+ .mockResolvedValueOnce({
128
+ ok: true,
129
+ status: 200,
130
+ json: async () => ({ data: [] }),
131
+ });
132
+
133
+ const result = await get('/apps');
134
+
135
+ expect(result).toEqual({ data: [] });
136
+ expect(mockFetch).toHaveBeenCalledTimes(2);
137
+ });
138
+
139
+ it('should retry on 5xx errors', async () => {
140
+ // First call returns 500
141
+ mockFetch
142
+ .mockResolvedValueOnce({
143
+ ok: false,
144
+ status: 500,
145
+ headers: new Headers(),
146
+ text: async () => '',
147
+ })
148
+ // Second call succeeds
149
+ .mockResolvedValueOnce({
150
+ ok: true,
151
+ status: 200,
152
+ json: async () => ({ data: [] }),
153
+ });
154
+
155
+ const result = await get('/apps');
156
+
157
+ expect(result).toEqual({ data: [] });
158
+ expect(mockFetch).toHaveBeenCalledTimes(2);
159
+ });
160
+ });
161
+
162
+ describe('getAllPages', () => {
163
+ it('should fetch all pages', async () => {
164
+ // Page 1
165
+ mockFetch.mockResolvedValueOnce({
166
+ ok: true,
167
+ status: 200,
168
+ json: async () => ({
169
+ data: [{ id: '1', type: 'apps' }],
170
+ links: { next: 'https://api.appstoreconnect.apple.com/v1/apps?cursor=abc' },
171
+ }),
172
+ });
173
+ // Page 2
174
+ mockFetch.mockResolvedValueOnce({
175
+ ok: true,
176
+ status: 200,
177
+ json: async () => ({
178
+ data: [{ id: '2', type: 'apps' }],
179
+ links: {},
180
+ }),
181
+ });
182
+
183
+ const results = await getAllPages('/apps');
184
+
185
+ expect(results).toHaveLength(2);
186
+ expect(results[0]?.id).toBe('1');
187
+ expect(results[1]?.id).toBe('2');
188
+ });
189
+
190
+ it('should respect maxPages limit', async () => {
191
+ // Page 1
192
+ mockFetch.mockResolvedValueOnce({
193
+ ok: true,
194
+ status: 200,
195
+ json: async () => ({
196
+ data: [{ id: '1', type: 'apps' }],
197
+ links: { next: 'https://api.appstoreconnect.apple.com/v1/apps?cursor=abc' },
198
+ }),
199
+ });
200
+
201
+ const results = await getAllPages('/apps', undefined, 1);
202
+
203
+ expect(results).toHaveLength(1);
204
+ expect(mockFetch).toHaveBeenCalledTimes(1);
205
+ });
206
+ });
207
+ });