@leonxin/meetgames 0.1.8 → 0.1.11

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 (285) hide show
  1. package/.agents/skills/meet-sdk-regression/SKILL.md +93 -0
  2. package/.cursor/mcp.example.json +16 -0
  3. package/.cursor/mcp.json +11 -0
  4. package/.cursor/skills/meetgames-mcp/SKILL.md +48 -0
  5. package/.vite/vitest/results.json +1 -0
  6. package/README.md +31 -8
  7. package/dist/aab-converter/aab-entry.d.ts +3 -0
  8. package/dist/aab-converter/aab-entry.d.ts.map +1 -0
  9. package/dist/aab-converter/aab-entry.js +49 -0
  10. package/dist/aab-converter/aab-entry.js.map +1 -0
  11. package/dist/aab-converter/apksExtractor.d.ts +2 -0
  12. package/dist/aab-converter/apksExtractor.d.ts.map +1 -0
  13. package/dist/aab-converter/apksExtractor.js +108 -0
  14. package/dist/aab-converter/apksExtractor.js.map +1 -0
  15. package/dist/aab-converter/bundletoolRunner.d.ts +15 -0
  16. package/dist/aab-converter/bundletoolRunner.d.ts.map +1 -0
  17. package/dist/aab-converter/bundletoolRunner.js +46 -0
  18. package/dist/aab-converter/bundletoolRunner.js.map +1 -0
  19. package/dist/aab-converter/cliArgs.d.ts +27 -0
  20. package/dist/aab-converter/cliArgs.d.ts.map +1 -0
  21. package/dist/aab-converter/cliArgs.js +170 -0
  22. package/dist/aab-converter/cliArgs.js.map +1 -0
  23. package/dist/aab-converter/convertAabToApk.d.ts +7 -0
  24. package/dist/aab-converter/convertAabToApk.d.ts.map +1 -0
  25. package/dist/aab-converter/convertAabToApk.js +69 -0
  26. package/dist/aab-converter/convertAabToApk.js.map +1 -0
  27. package/dist/aab-converter/resourcePaths.d.ts +4 -0
  28. package/dist/aab-converter/resourcePaths.d.ts.map +1 -0
  29. package/dist/aab-converter/resourcePaths.js +42 -0
  30. package/dist/aab-converter/resourcePaths.js.map +1 -0
  31. package/dist/aab-converter/signingOptions.d.ts +9 -0
  32. package/dist/aab-converter/signingOptions.d.ts.map +1 -0
  33. package/dist/aab-converter/signingOptions.js +21 -0
  34. package/dist/aab-converter/signingOptions.js.map +1 -0
  35. package/dist/aab-converter/types.d.ts +24 -0
  36. package/dist/aab-converter/types.d.ts.map +1 -0
  37. package/dist/aab-converter/types.js +2 -0
  38. package/dist/aab-converter/types.js.map +1 -0
  39. package/dist/android/adapter.d.ts.map +1 -1
  40. package/dist/android/adapter.js +2 -2
  41. package/dist/android/adapter.js.map +1 -1
  42. package/dist/android/detect.d.ts +2 -2
  43. package/dist/android/detect.d.ts.map +1 -1
  44. package/dist/android/detect.js +36 -8
  45. package/dist/android/detect.js.map +1 -1
  46. package/dist/cli.d.ts.map +1 -1
  47. package/dist/cli.js +157 -31
  48. package/dist/cli.js.map +1 -1
  49. package/dist/config/meetSdkDefaultConfig.d.ts +19 -2
  50. package/dist/config/meetSdkDefaultConfig.d.ts.map +1 -1
  51. package/dist/config/meetSdkDefaultConfig.js +67 -5
  52. package/dist/config/meetSdkDefaultConfig.js.map +1 -1
  53. package/dist/config/meetSdkIosConfig.d.ts +21 -0
  54. package/dist/config/meetSdkIosConfig.d.ts.map +1 -0
  55. package/dist/config/meetSdkIosConfig.js +66 -0
  56. package/dist/config/meetSdkIosConfig.js.map +1 -0
  57. package/dist/config/meetSdkRemoteConfig.d.ts +18 -1
  58. package/dist/config/meetSdkRemoteConfig.d.ts.map +1 -1
  59. package/dist/config/meetSdkRemoteConfig.js +61 -25
  60. package/dist/config/meetSdkRemoteConfig.js.map +1 -1
  61. package/dist/contracts/types.d.ts +19 -6
  62. package/dist/contracts/types.d.ts.map +1 -1
  63. package/dist/core/doctor.d.ts +17 -0
  64. package/dist/core/doctor.d.ts.map +1 -0
  65. package/dist/core/doctor.js +444 -0
  66. package/dist/core/doctor.js.map +1 -0
  67. package/dist/core/pipeline.d.ts.map +1 -1
  68. package/dist/core/pipeline.js +0 -15
  69. package/dist/core/pipeline.js.map +1 -1
  70. package/dist/core/platform.d.ts +12 -0
  71. package/dist/core/platform.d.ts.map +1 -0
  72. package/dist/core/platform.js +40 -0
  73. package/dist/core/platform.js.map +1 -0
  74. package/dist/core/reporter.js +1 -1
  75. package/dist/core/reporter.js.map +1 -1
  76. package/dist/core/workspace.d.ts +2 -2
  77. package/dist/core/workspace.d.ts.map +1 -1
  78. package/dist/core/workspace.js +4 -5
  79. package/dist/core/workspace.js.map +1 -1
  80. package/dist/index.d.ts +3 -1
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +3 -1
  83. package/dist/index.js.map +1 -1
  84. package/dist/ios/channelConfig.d.ts +1 -0
  85. package/dist/ios/channelConfig.d.ts.map +1 -1
  86. package/dist/ios/channelConfig.js +82 -0
  87. package/dist/ios/channelConfig.js.map +1 -1
  88. package/dist/ios/codeUtils.d.ts +1 -0
  89. package/dist/ios/codeUtils.d.ts.map +1 -1
  90. package/dist/ios/codeUtils.js +11 -2
  91. package/dist/ios/codeUtils.js.map +1 -1
  92. package/dist/ios/detect.d.ts +2 -2
  93. package/dist/ios/detect.d.ts.map +1 -1
  94. package/dist/ios/detect.js +49 -10
  95. package/dist/ios/detect.js.map +1 -1
  96. package/dist/ios/entitlements.d.ts +4 -0
  97. package/dist/ios/entitlements.d.ts.map +1 -0
  98. package/dist/ios/entitlements.js +53 -0
  99. package/dist/ios/entitlements.js.map +1 -0
  100. package/dist/ios/fileManager.d.ts.map +1 -1
  101. package/dist/ios/fileManager.js +3 -2
  102. package/dist/ios/fileManager.js.map +1 -1
  103. package/dist/ios/infoPlist.d.ts +1 -1
  104. package/dist/ios/infoPlist.d.ts.map +1 -1
  105. package/dist/ios/infoPlist.js.map +1 -1
  106. package/dist/ios/integrate.d.ts.map +1 -1
  107. package/dist/ios/integrate.js +211 -36
  108. package/dist/ios/integrate.js.map +1 -1
  109. package/dist/ios/pbxprojEditor.d.ts +2 -0
  110. package/dist/ios/pbxprojEditor.d.ts.map +1 -1
  111. package/dist/ios/pbxprojEditor.js +179 -1
  112. package/dist/ios/pbxprojEditor.js.map +1 -1
  113. package/dist/ios/pluginConfig.d.ts +1 -0
  114. package/dist/ios/pluginConfig.d.ts.map +1 -1
  115. package/dist/ios/pluginConfig.js +36 -4
  116. package/dist/ios/pluginConfig.js.map +1 -1
  117. package/dist/ios/sdkBundle.d.ts +1 -1
  118. package/dist/ios/sdkBundle.d.ts.map +1 -1
  119. package/dist/ios/sdkBundle.js +7 -5
  120. package/dist/ios/sdkBundle.js.map +1 -1
  121. package/dist/ios/template.d.ts +1 -0
  122. package/dist/ios/template.d.ts.map +1 -1
  123. package/dist/ios/template.js +14 -1
  124. package/dist/ios/template.js.map +1 -1
  125. package/dist/ios/types.d.ts +2 -2
  126. package/dist/ios/types.d.ts.map +1 -1
  127. package/dist/mcp/server.d.ts.map +1 -1
  128. package/dist/mcp/server.js +14 -13
  129. package/dist/mcp/server.js.map +1 -1
  130. package/dist/mcp/service.d.ts +8 -6
  131. package/dist/mcp/service.d.ts.map +1 -1
  132. package/dist/mcp/service.js +34 -14
  133. package/dist/mcp/service.js.map +1 -1
  134. package/dist/ops/handlers.d.ts.map +1 -1
  135. package/dist/ops/handlers.js +10 -4
  136. package/dist/ops/handlers.js.map +1 -1
  137. package/dist/remote/sdkHomeDownload.d.ts +65 -0
  138. package/dist/remote/sdkHomeDownload.d.ts.map +1 -0
  139. package/dist/remote/sdkHomeDownload.js +208 -0
  140. package/dist/remote/sdkHomeDownload.js.map +1 -0
  141. package/dist/remote/topsdkDownloadSdkConfig.d.ts.map +1 -1
  142. package/dist/remote/topsdkDownloadSdkConfig.js +11 -1
  143. package/dist/remote/topsdkDownloadSdkConfig.js.map +1 -1
  144. package/dist/shared/errors.d.ts +7 -0
  145. package/dist/shared/errors.d.ts.map +1 -0
  146. package/dist/shared/errors.js +16 -0
  147. package/dist/shared/errors.js.map +1 -0
  148. package/dist/shared/fileUtils.d.ts +5 -0
  149. package/dist/shared/fileUtils.d.ts.map +1 -0
  150. package/dist/shared/fileUtils.js +35 -0
  151. package/dist/shared/fileUtils.js.map +1 -0
  152. package/dist/shared/logger.d.ts +10 -0
  153. package/dist/shared/logger.d.ts.map +1 -0
  154. package/dist/shared/logger.js +37 -0
  155. package/dist/shared/logger.js.map +1 -0
  156. package/dist/shared/pathUtils.d.ts +4 -0
  157. package/dist/shared/pathUtils.d.ts.map +1 -0
  158. package/dist/shared/pathUtils.js +22 -0
  159. package/dist/shared/pathUtils.js.map +1 -0
  160. package/dist/shared/processRunner.d.ts +12 -0
  161. package/dist/shared/processRunner.d.ts.map +1 -0
  162. package/dist/shared/processRunner.js +31 -0
  163. package/dist/shared/processRunner.js.map +1 -0
  164. package/docs/AAB_CONVERTER_CLI_PLAN.md +392 -0
  165. package/docs/API.md +246 -32
  166. package/docs/CLI.md +292 -0
  167. package/docs/INTEGRATION.md +116 -0
  168. package/docs/MCP.md +86 -0
  169. package/docs/README.md +19 -10
  170. package/docs/{api → archive/api}/downloadSDKConfig.md +8 -6
  171. package/docs/{api → archive/api}/getChannelConfig-meetgames.md +1 -1
  172. package/docs/archive/ios-migration.md +2139 -0
  173. package/docs/{ → archive/product/}/346/212/200/346/234/257/346/226/271/346/241/210/350/260/203/347/240/224.md +7 -7
  174. package/docs/{ → archive/product/}/351/234/200/346/261/202/346/226/207/346/241/243.md +15 -14
  175. package/logs/convert-20260622-155037.log +5 -0
  176. package/logs/convert-20260622-155226.log +6 -0
  177. package/meetsdk-android.json +2 -1
  178. package/meetsdk-ios.json +15 -0
  179. package/package.json +10 -36
  180. package/scripts/package-aab-cli-win.mjs +193 -0
  181. package/src/aab-converter/aab-entry.ts +48 -0
  182. package/src/aab-converter/apksExtractor.ts +119 -0
  183. package/src/aab-converter/bundletoolRunner.ts +63 -0
  184. package/src/aab-converter/cliArgs.ts +194 -0
  185. package/src/aab-converter/convertAabToApk.ts +81 -0
  186. package/src/aab-converter/resourcePaths.ts +43 -0
  187. package/src/aab-converter/signingOptions.ts +29 -0
  188. package/src/aab-converter/types.ts +26 -0
  189. package/src/android/adapter.ts +9 -0
  190. package/src/android/assembleIntegrationJson.ts +33 -0
  191. package/src/android/detect.ts +132 -0
  192. package/src/android/downloadGoogleServicesJson.ts +56 -0
  193. package/src/android/gradle.ts +116 -0
  194. package/src/android/manifest.ts +50 -0
  195. package/src/android/meetSdkRemoteGradle.ts +837 -0
  196. package/src/cli.ts +488 -0
  197. package/src/config/fetchConfigWrite.ts +30 -0
  198. package/src/config/loadAndroidIntegration.ts +41 -0
  199. package/src/config/loadManifest.ts +40 -0
  200. package/src/config/meetSdkDefaultConfig.ts +99 -0
  201. package/src/config/meetSdkIosConfig.ts +87 -0
  202. package/src/config/meetSdkRemoteConfig.ts +1211 -0
  203. package/src/config/topsdkFeatureModules.ts +92 -0
  204. package/src/contracts/types.ts +121 -0
  205. package/src/core/doctor.ts +485 -0
  206. package/src/core/patch.ts +64 -0
  207. package/src/core/pipeline.ts +107 -0
  208. package/src/core/platform.ts +47 -0
  209. package/src/core/previewPatches.ts +23 -0
  210. package/src/core/reporter.ts +24 -0
  211. package/src/core/workspace.ts +29 -0
  212. package/src/entry.ts +7 -0
  213. package/src/index.ts +133 -0
  214. package/src/ios/channelConfig.ts +128 -0
  215. package/src/ios/codeUtils.ts +160 -0
  216. package/src/ios/detect.ts +105 -0
  217. package/src/ios/entitlements.ts +61 -0
  218. package/src/ios/fileManager.ts +48 -0
  219. package/src/ios/infoPlist.ts +55 -0
  220. package/src/ios/integrate.ts +516 -0
  221. package/src/ios/pbxprojEditor.ts +383 -0
  222. package/src/ios/pluginConfig.ts +97 -0
  223. package/src/ios/reserved.ts +8 -0
  224. package/src/ios/sdkBundle.ts +36 -0
  225. package/src/ios/template.ts +36 -0
  226. package/src/ios/types.ts +65 -0
  227. package/src/mcp/server.ts +170 -0
  228. package/src/mcp/service.ts +222 -0
  229. package/src/mcp-entry.ts +7 -0
  230. package/src/ops/fileStore.ts +56 -0
  231. package/src/ops/handlers.ts +304 -0
  232. package/src/remote/fetchJson.ts +22 -0
  233. package/src/remote/sdkHomeDownload.ts +274 -0
  234. package/src/remote/topsdkDownloadSdkConfig.ts +93 -0
  235. package/src/remote/topsdkGetSdkConfig.ts +122 -0
  236. package/src/remote/topsdkSign.ts +10 -0
  237. package/src/shared/errors.ts +16 -0
  238. package/src/shared/fileUtils.ts +41 -0
  239. package/src/shared/logger.ts +49 -0
  240. package/src/shared/pathUtils.ts +24 -0
  241. package/src/shared/processRunner.ts +43 -0
  242. package/test-projects/README.md +51 -0
  243. package/test-projects/_preview/pipeline.patch +281 -0
  244. package/tests/aab-converter.test.ts +213 -0
  245. package/tests/assemble.test.ts +12 -0
  246. package/tests/doctor.test.ts +89 -0
  247. package/tests/downloadGoogleServicesJson.test.ts +47 -0
  248. package/tests/fetch-remote.test.ts +23 -0
  249. package/tests/fetchConfigOverrides.test.ts +28 -0
  250. package/tests/fetchConfigWrite.test.ts +54 -0
  251. package/tests/gradle.test.ts +33 -0
  252. package/tests/integration-json.test.ts +29 -0
  253. package/tests/ios.codeUtils.test.ts +23 -0
  254. package/tests/ios.sdkBundle.test.ts +16 -0
  255. package/tests/loadManifest.test.ts +15 -0
  256. package/tests/manifest-xml.test.ts +30 -0
  257. package/tests/mcp.e2e.ts +217 -0
  258. package/tests/mcp.service.test.ts +53 -0
  259. package/tests/meetSdkRemoteConfig.test.ts +456 -0
  260. package/tests/meetSdkRemoteGradle.test.ts +414 -0
  261. package/tests/pipeline.android.test.ts +96 -0
  262. package/tests/pipeline.integration-json.test.ts +58 -0
  263. package/tests/pipeline.ios.test.ts +385 -0
  264. package/tests/pipeline.preview.patch.test.ts +85 -0
  265. package/tests/platformSelection.test.ts +77 -0
  266. package/tests/sdkHomeDownload.test.ts +124 -0
  267. package/tests/sdkVersionConfig.test.ts +130 -0
  268. package/tests/test-projects-hosts.test.ts +78 -0
  269. package/tests/topsdk.test.ts +53 -0
  270. package/tests/topsdkDownloadSdkConfig.test.ts +81 -0
  271. package/tests/topsdkFeatureModules.test.ts +116 -0
  272. package/tsconfig.json +19 -0
  273. package/vitest.config.ts +9 -0
  274. package/vitest.mcp.config.ts +11 -0
  275. package/bundled/android/sample.txt +0 -1
  276. package/docs/ANDROID.md +0 -133
  277. package/docs/CURSOR-MCP-SETUP.md +0 -72
  278. package/docs/MCP-SKILL.md +0 -63
  279. package/fixtures/api-samples/getChannelConfig-meetgames.sample.json +0 -123
  280. package/fixtures/meetsdk-remote-config.download-shape.json +0 -20
  281. package/fixtures/meetsdk-remote-config.mock.json +0 -69
  282. package/fixtures/recipes/android-default.fixture.yaml +0 -15
  283. package/fixtures/recipes/android-integration.fixture.json +0 -29
  284. package/fixtures/topsdk-config-reference.json +0 -39
  285. /package/docs/{api → archive/api}/getSDKConfig.md +0 -0
@@ -0,0 +1,213 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import zlib from "node:zlib";
5
+ import { afterEach, describe, expect, it } from "vitest";
6
+ import { extractUniversalApk } from "../src/aab-converter/apksExtractor.js";
7
+ import { buildBundletoolArgs, redactedBundletoolCommand } from "../src/aab-converter/bundletoolRunner.js";
8
+ import { parseAabCliArgv, validateConvertArgs } from "../src/aab-converter/cliArgs.js";
9
+ import { resolveOutputPaths } from "../src/aab-converter/convertAabToApk.js";
10
+
11
+ const tempDirs: string[] = [];
12
+
13
+ afterEach(() => {
14
+ for (const dir of tempDirs.splice(0)) {
15
+ fs.rmSync(dir, { recursive: true, force: true });
16
+ }
17
+ delete process.env.TEST_KS_PASS;
18
+ delete process.env.TEST_KEY_PASS;
19
+ });
20
+
21
+ function tempDir(): string {
22
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "aab-converter-test-"));
23
+ tempDirs.push(dir);
24
+ return dir;
25
+ }
26
+
27
+ function crc32(buf: Buffer): number {
28
+ let crc = 0xffffffff;
29
+ for (const b of buf) {
30
+ crc ^= b;
31
+ for (let i = 0; i < 8; i += 1) {
32
+ crc = (crc >>> 1) ^ (0xedb88320 & -(crc & 1));
33
+ }
34
+ }
35
+ return (crc ^ 0xffffffff) >>> 0;
36
+ }
37
+
38
+ function u16(value: number): Buffer {
39
+ const buf = Buffer.alloc(2);
40
+ buf.writeUInt16LE(value);
41
+ return buf;
42
+ }
43
+
44
+ function u32(value: number): Buffer {
45
+ const buf = Buffer.alloc(4);
46
+ buf.writeUInt32LE(value);
47
+ return buf;
48
+ }
49
+
50
+ function createZip(entries: Array<{ name: string; content: Buffer }>): Buffer {
51
+ const localParts: Buffer[] = [];
52
+ const centralParts: Buffer[] = [];
53
+ let offset = 0;
54
+ for (const entry of entries) {
55
+ const name = Buffer.from(entry.name, "utf8");
56
+ const compressed = zlib.deflateRawSync(entry.content);
57
+ const crc = crc32(entry.content);
58
+ const local = Buffer.concat([
59
+ u32(0x04034b50),
60
+ u16(20),
61
+ u16(0),
62
+ u16(8),
63
+ u16(0),
64
+ u16(0),
65
+ u32(crc),
66
+ u32(compressed.length),
67
+ u32(entry.content.length),
68
+ u16(name.length),
69
+ u16(0),
70
+ name,
71
+ compressed,
72
+ ]);
73
+ localParts.push(local);
74
+ centralParts.push(
75
+ Buffer.concat([
76
+ u32(0x02014b50),
77
+ u16(20),
78
+ u16(20),
79
+ u16(0),
80
+ u16(8),
81
+ u16(0),
82
+ u16(0),
83
+ u32(crc),
84
+ u32(compressed.length),
85
+ u32(entry.content.length),
86
+ u16(name.length),
87
+ u16(0),
88
+ u16(0),
89
+ u16(0),
90
+ u16(0),
91
+ u32(0),
92
+ u32(offset),
93
+ name,
94
+ ])
95
+ );
96
+ offset += local.length;
97
+ }
98
+ const centralDir = Buffer.concat(centralParts);
99
+ const eocd = Buffer.concat([
100
+ u32(0x06054b50),
101
+ u16(0),
102
+ u16(0),
103
+ u16(entries.length),
104
+ u16(entries.length),
105
+ u32(centralDir.length),
106
+ u32(offset),
107
+ u16(0),
108
+ ]);
109
+ return Buffer.concat([...localParts, centralDir, eocd]);
110
+ }
111
+
112
+ describe("AAB converter CLI args", () => {
113
+ it("parses env passwords and defaults to overwrite", () => {
114
+ const dir = tempDir();
115
+ const aab = path.join(dir, "sample.aab");
116
+ const jks = path.join(dir, "sample.jks");
117
+ fs.writeFileSync(aab, "aab");
118
+ fs.writeFileSync(jks, "jks");
119
+ process.env.TEST_KS_PASS = "store-pass";
120
+ process.env.TEST_KEY_PASS = "key-pass";
121
+
122
+ const parsed = parseAabCliArgv([
123
+ "node",
124
+ "aab-entry.js",
125
+ "convert",
126
+ "--aab",
127
+ aab,
128
+ "--out-dir",
129
+ path.join(dir, "out"),
130
+ "--ks",
131
+ jks,
132
+ "--ks-key-alias",
133
+ "release",
134
+ "--ks-pass-env",
135
+ "TEST_KS_PASS",
136
+ "--key-pass-env",
137
+ "TEST_KEY_PASS",
138
+ ]);
139
+ const validated = validateConvertArgs(parsed);
140
+ expect(validated.overwrite).toBe(true);
141
+ expect(validated.signing.keyStorePassword).toBe("store-pass");
142
+ expect(validated.signing.keyPassword).toBe("key-pass");
143
+ });
144
+
145
+ it("supports --no-overwrite", () => {
146
+ const parsed = parseAabCliArgv(["node", "aab-entry.js", "convert", "--no-overwrite"]);
147
+ expect(parsed.overwrite).toBe(false);
148
+ });
149
+ });
150
+
151
+ describe("bundletool command", () => {
152
+ it("builds signed universal APK set args and redacts passwords", () => {
153
+ const args = buildBundletoolArgs({
154
+ bundletoolPath: "tools/bundletool.jar",
155
+ aabPath: "game.aab",
156
+ apksPath: "game.apks",
157
+ overwrite: true,
158
+ signing: {
159
+ keyStorePath: "release.jks",
160
+ keyAlias: "release",
161
+ keyStorePassword: "store-secret-value",
162
+ keyPassword: "key-secret-value",
163
+ },
164
+ });
165
+ expect(args).toContain("build-apks");
166
+ expect(args).toContain("--mode=universal");
167
+ expect(args).toContain("--overwrite");
168
+ expect(args).toContain("--ks-pass=pass:store-secret-value");
169
+ expect(args).toContain("--key-pass=pass:key-secret-value");
170
+ const redacted = redactedBundletoolCommand("java", args);
171
+ expect(redacted).toContain("--ks-pass=pass:******");
172
+ expect(redacted).toContain("--key-pass=pass:******");
173
+ expect(redacted).not.toContain("store-secret-value");
174
+ expect(redacted).not.toContain("key-secret-value");
175
+ });
176
+ });
177
+
178
+ describe("APKS extraction", () => {
179
+ it("extracts universal.apk from a zip based .apks file", async () => {
180
+ const dir = tempDir();
181
+ const apks = path.join(dir, "sample.apks");
182
+ const apk = path.join(dir, "sample.apk");
183
+ fs.writeFileSync(
184
+ apks,
185
+ createZip([
186
+ { name: "toc.pb", content: Buffer.from("toc") },
187
+ { name: "universal.apk", content: Buffer.from("apk-binary") },
188
+ ])
189
+ );
190
+ await extractUniversalApk(apks, apk, true);
191
+ expect(fs.readFileSync(apk, "utf8")).toBe("apk-binary");
192
+ });
193
+
194
+ it("fails when output exists and overwrite is disabled", async () => {
195
+ const dir = tempDir();
196
+ const apks = path.join(dir, "sample.apks");
197
+ const apk = path.join(dir, "sample.apk");
198
+ fs.writeFileSync(apks, createZip([{ name: "universal.apk", content: Buffer.from("new") }]));
199
+ fs.writeFileSync(apk, "old");
200
+ await expect(extractUniversalApk(apks, apk, false)).rejects.toThrow(/already exists/);
201
+ });
202
+ });
203
+
204
+ describe("output paths", () => {
205
+ it("uses the AAB base name for default APK and APKS outputs", () => {
206
+ const paths = resolveOutputPaths({
207
+ aabPath: path.join("D:", "pkg", "game.aab"),
208
+ outDir: path.join("D:", "out"),
209
+ });
210
+ expect(paths.apksPath.endsWith(`${path.sep}game.apks`)).toBe(true);
211
+ expect(paths.apkPath.endsWith(`${path.sep}game_universal.apk`)).toBe(true);
212
+ });
213
+ });
@@ -0,0 +1,12 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { unwrapRemoteIntegrationPayload } from "../src/android/assembleIntegrationJson.js";
3
+
4
+ describe("assembleIntegrationJson", () => {
5
+ it("unwraps common envelopes", () => {
6
+ const inner = { version: 1, steps: [{ op: "gradle.insertRepositories", args: { urls: ["mavenCentral"] } }] };
7
+ expect(unwrapRemoteIntegrationPayload(inner)).toBe(inner);
8
+ expect(unwrapRemoteIntegrationPayload({ data: inner })).toEqual(inner);
9
+ expect(unwrapRemoteIntegrationPayload({ config: inner })).toEqual(inner);
10
+ expect(unwrapRemoteIntegrationPayload({ android: inner })).toEqual(inner);
11
+ });
12
+ });
@@ -0,0 +1,89 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
+ import { loadManifestFile } from "../src/config/loadManifest.js";
6
+ import { runDoctor } from "../src/core/doctor.js";
7
+ import { detectSinglePlatform, platformContext } from "../src/core/platform.js";
8
+ import { runPipeline } from "../src/core/pipeline.js";
9
+ import { buildWorkspaceContext } from "../src/core/workspace.js";
10
+
11
+ const pkgRoot = path.resolve(__dirname, "..");
12
+ const androidLatestRoot = path.join(pkgRoot, "fixtures", "android-test-project", "android-latest-project");
13
+ const iosProjectRoot = path.join(pkgRoot, "fixtures", "ios-test-project", "tooltest");
14
+ const iosRemoteConfigFixture = path.join(pkgRoot, "fixtures", "meetsdk-remote-config.ios-tooltest.json");
15
+ const hasIosProjectFixture = fs.existsSync(iosProjectRoot);
16
+
17
+ function copyIosProjectToTemp(): string {
18
+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "meet-ios-doctor-"));
19
+ fs.cpSync(iosProjectRoot, tmp, { recursive: true });
20
+ fs.copyFileSync(iosRemoteConfigFixture, path.join(tmp, "meetsdk-remote-config.json"));
21
+ return tmp;
22
+ }
23
+
24
+ function stubSdkHomeVersion(): void {
25
+ vi.stubGlobal(
26
+ "fetch",
27
+ vi.fn(async () => ({
28
+ ok: true,
29
+ status: 200,
30
+ text: async () =>
31
+ JSON.stringify({
32
+ code: 200,
33
+ data: {
34
+ result: {
35
+ android: { ver: "1.6.1.3", date: "2026-05-25" },
36
+ ios: { ver: "1.6.0.5", date: "2026-06-09" },
37
+ },
38
+ },
39
+ }),
40
+ })) as unknown as typeof fetch
41
+ );
42
+ }
43
+
44
+ describe("doctor", () => {
45
+ beforeEach(() => {
46
+ stubSdkHomeVersion();
47
+ });
48
+
49
+ afterEach(() => {
50
+ vi.unstubAllGlobals();
51
+ });
52
+
53
+ it("checks Android integration details from project-root config", async () => {
54
+ const ctx = buildWorkspaceContext(androidLatestRoot, pkgRoot);
55
+ const detected = detectSinglePlatform(ctx);
56
+ expect(detected.ok && detected.platform).toBe("android");
57
+
58
+ const report = await runDoctor(platformContext(ctx, "android"), "android");
59
+
60
+ expect(report.platform).toBe("android");
61
+ expect(report.checks.map((c) => c.name)).toContain("android.repositories");
62
+ expect(report.checks.map((c) => c.name)).toContain("android.dependencies");
63
+ expect(report.checks.map((c) => c.name)).toContain("android.resValues");
64
+ });
65
+
66
+ it.skipIf(!hasIosProjectFixture)("checks iOS integration details from project-root config", async () => {
67
+ const tmp = copyIosProjectToTemp();
68
+ try {
69
+ const manifest = loadManifestFile(path.join(pkgRoot, "recipes", "ios-default.yaml"));
70
+ const applyCtx = buildWorkspaceContext(tmp, pkgRoot);
71
+ const { report: applyReport } = await runPipeline(applyCtx, manifest, { dryRun: false });
72
+ expect(applyReport.errors).toEqual([]);
73
+
74
+ const ctx = buildWorkspaceContext(tmp, pkgRoot);
75
+ const detected = detectSinglePlatform(ctx);
76
+ expect(detected.ok && detected.platform).toBe("ios");
77
+
78
+ const report = await runDoctor(platformContext(ctx, "ios"), "ios");
79
+
80
+ expect(report.platform).toBe("ios");
81
+ expect(report.checks.map((c) => c.name)).toContain("ios.frameworkFiles");
82
+ expect(report.checks.map((c) => c.name)).toContain("ios.urlSchemes.present");
83
+ expect(report.checks.map((c) => c.name)).toContain("ios.appDelegateInjection");
84
+ expect(report.errors).toEqual([]);
85
+ } finally {
86
+ fs.rmSync(tmp, { recursive: true, force: true });
87
+ }
88
+ });
89
+ });
@@ -0,0 +1,47 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { resolveGoogleServicesJsonTarget } from "../src/android/downloadGoogleServicesJson.js";
3
+
4
+ describe("resolveGoogleServicesJsonTarget", () => {
5
+ const root = "/proj";
6
+
7
+ it("places file under detected application module with configured name", () => {
8
+ const abs = resolveGoogleServicesJsonTarget(
9
+ root,
10
+ {
11
+ firebase_file_url: "https://x/y.json",
12
+ firebase_file_name: "google-services.json",
13
+ },
14
+ "app"
15
+ );
16
+ expect(abs).toBe("/proj/app/google-services.json");
17
+ });
18
+
19
+ it("uses non-default module directory", () => {
20
+ const abs = resolveGoogleServicesJsonTarget(
21
+ root,
22
+ { firebase_file_url: "https://x/y.json", firebase_file_name: "google-services.json" },
23
+ "launcher"
24
+ );
25
+ expect(abs).toBe("/proj/launcher/google-services.json");
26
+ });
27
+
28
+ it("preserves upload file name with extension", () => {
29
+ const abs = resolveGoogleServicesJsonTarget(
30
+ root,
31
+ {
32
+ firebase_file_url: "https://x/y.json",
33
+ firebase_file_name: "google-services.json",
34
+ },
35
+ "app"
36
+ );
37
+ expect(abs.endsWith("google-services.json")).toBe(true);
38
+ });
39
+
40
+ it("falls back to project root when application module unknown", () => {
41
+ const abs = resolveGoogleServicesJsonTarget(root, {
42
+ firebase_file_url: "https://x/y.json",
43
+ firebase_file_name: "google-services.json",
44
+ });
45
+ expect(abs).toBe("/proj/google-services.json");
46
+ });
47
+ });
@@ -0,0 +1,23 @@
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+ import { fetchJsonGet } from "../src/remote/fetchJson.js";
3
+
4
+ describe("fetchJsonGet", () => {
5
+ afterEach(() => {
6
+ vi.unstubAllGlobals();
7
+ });
8
+
9
+ it("parses JSON bodies", async () => {
10
+ vi.stubGlobal(
11
+ "fetch",
12
+ vi.fn(async () => ({
13
+ ok: true,
14
+ status: 200,
15
+ headers: { get: () => "application/json" },
16
+ text: async () => JSON.stringify({ hello: "world" }),
17
+ })) as unknown as typeof fetch
18
+ );
19
+
20
+ const body = await fetchJsonGet("https://example.com/cfg.json");
21
+ expect(body).toEqual({ hello: "world" });
22
+ });
23
+ });
@@ -0,0 +1,28 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { applyFetchConfigCliOverrides, defaultSdkModules } from "../src/config/meetSdkRemoteConfig.js";
3
+
4
+ describe("applyFetchConfigCliOverrides", () => {
5
+ const base = {
6
+ packageName: "com.from.server",
7
+ channel: "google",
8
+ topsdk: {
9
+ appId: "111",
10
+ appSecret: "server-secret",
11
+ version: "",
12
+ groupId: "",
13
+ repositories: [],
14
+ },
15
+ sdkModules: defaultSdkModules(),
16
+ };
17
+
18
+ it("overrides topsdk appId and root channel only", () => {
19
+ const out = applyFetchConfigCliOverrides(base, {
20
+ appId: "222",
21
+ channelType: "google",
22
+ });
23
+ expect(out.topsdk.appId).toBe("222");
24
+ expect(out.channel).toBe("GOOGLE");
25
+ expect(out.topsdk.appSecret).toBe("server-secret");
26
+ expect(out.packageName).toBe("com.from.server");
27
+ });
28
+ });
@@ -0,0 +1,54 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { afterEach, describe, expect, it } from "vitest";
5
+ import {
6
+ validateDownloadSdkConfigForWrite,
7
+ writeDownloadSdkConfigRaw,
8
+ } from "../src/config/fetchConfigWrite.js";
9
+
10
+ describe("fetchConfigWrite", () => {
11
+ const tmpDirs: string[] = [];
12
+
13
+ afterEach(() => {
14
+ for (const dir of tmpDirs) {
15
+ fs.rmSync(dir, { recursive: true, force: true });
16
+ }
17
+ tmpDirs.length = 0;
18
+ });
19
+
20
+ it("writeDownloadSdkConfigRaw preserves response bytes (no JSON re-serialize)", () => {
21
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "meet-fetch-"));
22
+ tmpDirs.push(dir);
23
+ const out = path.join(dir, "meetsdk-remote-config.json");
24
+ const raw = `{
25
+ "packageName": "com.example.game",
26
+ "channel": "GOOGLE",
27
+ "devicePlatform": "android",
28
+ "topsdk": { "appId": "1", "appSecret": "sec" },
29
+ "sdkModules": { "login": {}, "payment": {}, "analytics": {} }
30
+ }`;
31
+
32
+ writeDownloadSdkConfigRaw(out, raw);
33
+ expect(fs.readFileSync(out, "utf8")).toBe(raw);
34
+ });
35
+
36
+ it("validateDownloadSdkConfigForWrite accepts valid remote config without meetsdk-android fields", () => {
37
+ const body = {
38
+ packageName: "com.example.game",
39
+ channel: "GOOGLE",
40
+ devicePlatform: "android",
41
+ topsdk: { appId: "1", appSecret: "sec" },
42
+ sdkModules: { login: {}, payment: {}, analytics: {} },
43
+ };
44
+ const result = validateDownloadSdkConfigForWrite(body);
45
+ expect(result?.parsed.packageName).toBe("com.example.game");
46
+ expect(result?.parsed.topsdk.version).toBe("");
47
+ expect((result?.parsed as { dependencies?: unknown }).dependencies).toBeUndefined();
48
+ });
49
+
50
+ it("validateDownloadSdkConfigForWrite rejects invalid documents", () => {
51
+ expect(validateDownloadSdkConfigForWrite(null)).toBeNull();
52
+ expect(validateDownloadSdkConfigForWrite({ topsdk: {} })).toBeNull();
53
+ });
54
+ });
@@ -0,0 +1,33 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { updateModuleBuildGradleDependencies, updateRootBuildGradleRepositories } from "../src/android/gradle.js";
3
+
4
+ describe("gradle editors", () => {
5
+ it("inserts managed repositories", () => {
6
+ const root = `
7
+ allprojects {
8
+ repositories {
9
+ google()
10
+ }
11
+ }
12
+ `;
13
+ const res = updateRootBuildGradleRepositories(root, ["https://m.example.com"]);
14
+ expect(res.ok).toBe(true);
15
+ if (!res.ok) return;
16
+ expect(res.content).toContain("MEET_INTEGRATE REPOS");
17
+ expect(res.content).toContain("m.example.com");
18
+ });
19
+
20
+ it("inserts managed dependencies", () => {
21
+ const mod = `
22
+ apply plugin: 'com.android.application'
23
+ android { defaultConfig { } }
24
+ dependencies {
25
+ }
26
+ `;
27
+ const res = updateModuleBuildGradleDependencies(mod, [` implementation 'com.demo:lib:1.0'`]);
28
+ expect(res.ok).toBe(true);
29
+ if (!res.ok) return;
30
+ expect(res.content).toContain("MEET_INTEGRATE BLOCK");
31
+ expect(res.content).toContain("com.demo:lib");
32
+ });
33
+ });
@@ -0,0 +1,29 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { describe, expect, it } from "vitest";
5
+ import { loadAndroidIntegrationFile } from "../src/config/loadAndroidIntegration.js";
6
+
7
+ describe("android integration json", () => {
8
+ it("loads and validates integration file", () => {
9
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "meet-int-json-"));
10
+ const p = path.join(dir, "cfg.json");
11
+ fs.writeFileSync(
12
+ p,
13
+ JSON.stringify(
14
+ {
15
+ version: 1,
16
+ meta: { sourceUrl: "https://example.com/cfg", fetchedAt: "2026-01-01T00:00:00.000Z" },
17
+ steps: [{ op: "gradle.insertRepositories", platform: "android", args: { urls: ["mavenCentral"] } }],
18
+ },
19
+ null,
20
+ 2
21
+ ),
22
+ "utf8"
23
+ );
24
+ const doc = loadAndroidIntegrationFile(p);
25
+ expect(doc.version).toBe(1);
26
+ expect(doc.steps.length).toBe(1);
27
+ fs.rmSync(dir, { recursive: true, force: true });
28
+ });
29
+ });
@@ -0,0 +1,23 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { CodeUtils } from "../src/ios/codeUtils.js";
3
+
4
+ describe("CodeUtils", () => {
5
+ it("adds header and method body without duplicating", () => {
6
+ const initial = `@implementation AppDelegate
7
+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
8
+ return YES;
9
+ }
10
+ @end
11
+ `;
12
+ const cu = new CodeUtils("AppDelegate.m", initial);
13
+ cu.addHeader('#import <TOPSDK/TopSDK.h>');
14
+ cu.addCodeToMethod(
15
+ "- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions",
16
+ "[TopSDK.sharedInstance application:application didFinishLaunchingWithOptions:launchOptions]"
17
+ );
18
+ cu.addHeader('#import <TOPSDK/TopSDK.h>');
19
+ expect(cu.text).toContain("#import <TOPSDK/TopSDK.h>");
20
+ expect(cu.text).toContain("TopSDK.sharedInstance");
21
+ expect(cu.text.split("#import <TOPSDK/TopSDK.h>").length - 1).toBe(1);
22
+ });
23
+ });
@@ -0,0 +1,16 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { describe, expect, it } from "vitest";
5
+ import { resolveIosSdkRoot } from "../src/ios/sdkBundle.js";
6
+
7
+ const pkgRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
8
+
9
+ describe("resolveIosSdkRoot", () => {
10
+ it("finds nested TopSDK package under bundled/ios-sdk", () => {
11
+ const root = resolveIosSdkRoot(pkgRoot);
12
+ expect(root).toContain(`${path.sep}bundled${path.sep}ios-sdk`);
13
+ expect(fs.existsSync(path.join(root, "sdk", "topsdkConfig.t.json"))).toBe(true);
14
+ expect(fs.existsSync(path.join(root, "plugins", "GuestSignin", "config.t.json"))).toBe(true);
15
+ });
16
+ });
@@ -0,0 +1,15 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { describe, expect, it } from "vitest";
5
+ import { loadManifestFile } from "../src/config/loadManifest.js";
6
+
7
+ describe("loadManifest", () => {
8
+ it("rejects invalid manifests", () => {
9
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "meet-int-"));
10
+ const p = path.join(dir, "bad.yaml");
11
+ fs.writeFileSync(p, "version: 1\n", "utf8");
12
+ expect(() => loadManifestFile(p)).toThrow(/Manifest validation failed/);
13
+ fs.rmSync(dir, { recursive: true, force: true });
14
+ });
15
+ });
@@ -0,0 +1,30 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { extractPermissionName, insertPermissions } from "../src/android/manifest.js";
3
+
4
+ describe("android manifest", () => {
5
+ it("inserts permissions block before closing manifest", () => {
6
+ const xml = `<?xml version="1.0" encoding="utf-8"?>
7
+ <manifest package="a.b">
8
+ <application />
9
+ </manifest>`;
10
+ const { content, changed } = insertPermissions(xml, ["android.permission.INTERNET"]);
11
+ expect(changed).toBe(true);
12
+ expect(content).toContain("uses-permission");
13
+ expect(content).toContain("INTERNET");
14
+ });
15
+
16
+ it("updates permission by android:name instead of duplicating", () => {
17
+ const xml = `<?xml version="1.0" encoding="utf-8"?>
18
+ <manifest package="a.b">
19
+ <uses-permission android:name="android.permission.INTERNET" />
20
+ <!-- MEET_INTEGRATE PERMISSIONS START -->
21
+ <uses-permission android:name="android.permission.INTERNET" />
22
+ <!-- MEET_INTEGRATE PERMISSIONS END -->
23
+ <application />
24
+ </manifest>`;
25
+ const { content } = insertPermissions(xml, ["android.permission.INTERNET"]);
26
+ const permLines = content.split("\n").filter((l) => extractPermissionName(l));
27
+ expect(permLines.length).toBe(1);
28
+ expect(content).toContain('android:name="android.permission.INTERNET"');
29
+ });
30
+ });