@leonxin/meetgames 0.1.18 → 0.1.20

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 (109) hide show
  1. package/README.md +16 -6
  2. package/dist/android/detect.d.ts +6 -1
  3. package/dist/android/detect.d.ts.map +1 -1
  4. package/dist/android/detect.js +41 -17
  5. package/dist/android/detect.js.map +1 -1
  6. package/dist/android/gradle.d.ts.map +1 -1
  7. package/dist/android/gradle.js +8 -1
  8. package/dist/android/gradle.js.map +1 -1
  9. package/dist/android/meetSdkRemoteGradle.d.ts +1 -0
  10. package/dist/android/meetSdkRemoteGradle.d.ts.map +1 -1
  11. package/dist/android/meetSdkRemoteGradle.js +44 -21
  12. package/dist/android/meetSdkRemoteGradle.js.map +1 -1
  13. package/dist/cache.d.ts +16 -0
  14. package/dist/cache.d.ts.map +1 -1
  15. package/dist/cache.js +21 -0
  16. package/dist/cache.js.map +1 -1
  17. package/dist/cli.d.ts.map +1 -1
  18. package/dist/cli.js +52 -23
  19. package/dist/cli.js.map +1 -1
  20. package/dist/config/meetSdkDefaultConfig.d.ts +7 -11
  21. package/dist/config/meetSdkDefaultConfig.d.ts.map +1 -1
  22. package/dist/config/meetSdkDefaultConfig.js +216 -53
  23. package/dist/config/meetSdkDefaultConfig.js.map +1 -1
  24. package/dist/config/meetSdkIosConfig.d.ts +4 -5
  25. package/dist/config/meetSdkIosConfig.d.ts.map +1 -1
  26. package/dist/config/meetSdkIosConfig.js +19 -19
  27. package/dist/config/meetSdkIosConfig.js.map +1 -1
  28. package/dist/contracts/types.d.ts +18 -0
  29. package/dist/contracts/types.d.ts.map +1 -1
  30. package/dist/core/doctor.d.ts.map +1 -1
  31. package/dist/core/doctor.js +18 -1
  32. package/dist/core/doctor.js.map +1 -1
  33. package/dist/core/platform.js +1 -1
  34. package/dist/core/platform.js.map +1 -1
  35. package/dist/core/previewPatches.d.ts +2 -2
  36. package/dist/core/previewPatches.d.ts.map +1 -1
  37. package/dist/core/previewPatches.js +3 -3
  38. package/dist/core/previewPatches.js.map +1 -1
  39. package/dist/core/workspace.d.ts.map +1 -1
  40. package/dist/core/workspace.js +3 -1
  41. package/dist/core/workspace.js.map +1 -1
  42. package/dist/index.d.ts +4 -4
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +4 -4
  45. package/dist/index.js.map +1 -1
  46. package/dist/mcp/server.d.ts.map +1 -1
  47. package/dist/mcp/server.js +12 -7
  48. package/dist/mcp/server.js.map +1 -1
  49. package/dist/mcp/service.d.ts +6 -0
  50. package/dist/mcp/service.d.ts.map +1 -1
  51. package/dist/mcp/service.js +17 -9
  52. package/dist/mcp/service.js.map +1 -1
  53. package/dist/ops/handlers.d.ts.map +1 -1
  54. package/dist/ops/handlers.js +25 -3
  55. package/dist/ops/handlers.js.map +1 -1
  56. package/dist/remote/sdkHomeDownload.d.ts +4 -5
  57. package/dist/remote/sdkHomeDownload.d.ts.map +1 -1
  58. package/dist/remote/sdkHomeDownload.js +38 -12
  59. package/dist/remote/sdkHomeDownload.js.map +1 -1
  60. package/docs/API.md +13 -13
  61. package/docs/CLI.md +27 -13
  62. package/docs/INTEGRATION.md +7 -6
  63. package/package.json +1 -1
  64. package/src/android/detect.ts +47 -17
  65. package/src/android/gradle.ts +16 -1
  66. package/src/android/meetSdkRemoteGradle.ts +50 -22
  67. package/src/cache.ts +37 -0
  68. package/src/cli.ts +51 -21
  69. package/src/config/meetSdkDefaultConfig.ts +243 -59
  70. package/src/config/meetSdkIosConfig.ts +17 -21
  71. package/src/contracts/types.ts +21 -0
  72. package/src/core/doctor.ts +17 -1
  73. package/src/core/platform.ts +1 -1
  74. package/src/core/previewPatches.ts +3 -3
  75. package/src/core/workspace.ts +3 -1
  76. package/src/index.ts +5 -3
  77. package/src/mcp/server.ts +12 -7
  78. package/src/mcp/service.ts +30 -10
  79. package/src/ops/handlers.ts +27 -3
  80. package/src/remote/sdkHomeDownload.ts +48 -16
  81. package/config/meetsdk-android.json +0 -171
  82. package/config/meetsdk-ios.json +0 -15
  83. package/tests/assemble.test.ts +0 -12
  84. package/tests/doctor.test.ts +0 -131
  85. package/tests/downloadGoogleServicesJson.test.ts +0 -47
  86. package/tests/fetch-remote.test.ts +0 -23
  87. package/tests/fetchConfigOverrides.test.ts +0 -28
  88. package/tests/fetchConfigWrite.test.ts +0 -54
  89. package/tests/fixtures-hosts.test.ts +0 -78
  90. package/tests/gradle.test.ts +0 -33
  91. package/tests/integration-json.test.ts +0 -29
  92. package/tests/ios.codeUtils.test.ts +0 -23
  93. package/tests/ios.sdkBundle.test.ts +0 -21
  94. package/tests/loadManifest.test.ts +0 -15
  95. package/tests/manifest-xml.test.ts +0 -30
  96. package/tests/mcp.e2e.ts +0 -214
  97. package/tests/mcp.service.test.ts +0 -53
  98. package/tests/meetSdkRemoteConfig.test.ts +0 -482
  99. package/tests/meetSdkRemoteGradle.test.ts +0 -414
  100. package/tests/pipeline.android.test.ts +0 -149
  101. package/tests/pipeline.integration-json.test.ts +0 -58
  102. package/tests/pipeline.ios.test.ts +0 -609
  103. package/tests/pipeline.preview.patch.test.ts +0 -85
  104. package/tests/platformSelection.test.ts +0 -77
  105. package/tests/sdkHomeDownload.test.ts +0 -275
  106. package/tests/sdkVersionConfig.test.ts +0 -131
  107. package/tests/topsdk.test.ts +0 -53
  108. package/tests/topsdkDownloadSdkConfig.test.ts +0 -81
  109. package/tests/topsdkFeatureModules.test.ts +0 -116
@@ -1,414 +0,0 @@
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 {
6
- collectMeetSdkRemoteApplyPlugins,
7
- collectMeetSdkRemoteBuildscriptClasspaths,
8
- collectMeetSdkRemoteBuildscriptRepositories,
9
- collectMeetSdkRemotePluginsDslForModule,
10
- collectMeetSdkRemotePluginsDslForRoot,
11
- collectMeetSdkRemoteRepositories,
12
- applyMeetSdkDefaultConfig,
13
- tryParseAsMeetSdkRemoteConfig,
14
- validateMeetSdkRemoteConfig,
15
- } from "../src/config/meetSdkRemoteConfig.js";
16
- import { loadBuiltInMeetSdkDefaultConfig } from "../src/config/meetSdkDefaultConfig.js";
17
- import {
18
- TOPSDK_AUTO_START,
19
- TOPSDK_AUTO_END,
20
- TOPSDK_PLUGIN_AUTO_START,
21
- TOPSDK_REPO_AUTO_START,
22
- detectModuleGradlePluginStyle,
23
- extractApplyPluginId,
24
- extractClasspathCoordinate,
25
- extractImplementationKey,
26
- extractPluginsDslId,
27
- extractResValueKey,
28
- mavenGroupArtifactKey,
29
- mergeApplyPluginsInContent,
30
- mergeClasspathsInBlock,
31
- mergePluginsDslInContent,
32
- mergeRepositoriesInBlock,
33
- mergeResValuesInDefaultConfigBlock,
34
- removeImplementationLinesByGroupArtifact,
35
- updateModuleBuildGradleMeetSdkRemote,
36
- updateRootBuildGradleMeetSdkRemote,
37
- updateSettingsGradleMeetSdkRemote,
38
- } from "../src/android/meetSdkRemoteGradle.js";
39
-
40
- const here = path.dirname(fileURLToPath(import.meta.url));
41
- const sampleConfigPath = path.join(here, "..", "fixtures", "meetsdk-remote-config.mock.json");
42
-
43
- describe("meetSdkRemoteGradle", () => {
44
- it("writes repositories and module blocks from meetsdk-remote-config mock shape", () => {
45
- const raw = JSON.parse(fs.readFileSync(sampleConfigPath, "utf8")) as unknown;
46
- const cfg = tryParseAsMeetSdkRemoteConfig(raw);
47
- expect(cfg).not.toBeNull();
48
- expect(validateMeetSdkRemoteConfig(cfg!).ok).toBe(true);
49
- const resolved = applyMeetSdkDefaultConfig(cfg!, loadBuiltInMeetSdkDefaultConfig());
50
-
51
- const rootIn = `
52
- allprojects {
53
- repositories {
54
- google()
55
- }
56
- }
57
- `;
58
- const rootOut = updateRootBuildGradleMeetSdkRemote(rootIn, {
59
- repositories: collectMeetSdkRemoteRepositories(resolved),
60
- buildscriptRepositories: collectMeetSdkRemoteBuildscriptRepositories(resolved),
61
- buildscriptClasspaths: collectMeetSdkRemoteBuildscriptClasspaths(resolved),
62
- });
63
- expect(rootOut.ok).toBe(true);
64
- if (!rootOut.ok) return;
65
- expect(rootOut.content).toContain(TOPSDK_REPO_AUTO_START);
66
- expect(rootOut.content).toContain("storage-sdk-gameplus");
67
- expect(rootOut.content).toContain("google()");
68
- expect(rootOut.content).toContain("mavenCentral()");
69
- expect(rootOut.content).toContain("storage-sdk-gameplus");
70
- expect(rootOut.content).not.toContain("//Firebase");
71
- expect(rootOut.content).not.toContain("//Appsflyer");
72
- expect(rootOut.content).not.toContain("//TOPSdk");
73
- expect(rootOut.content).toContain("buildscript");
74
- expect(rootOut.content).toContain("com.google.gms:google-services:4.4.4");
75
-
76
- const modIn = `
77
- apply plugin: 'com.android.application'
78
-
79
- android {
80
- defaultConfig {
81
- applicationId "com.example.app"
82
- }
83
- }
84
-
85
- dependencies {
86
- }
87
- `;
88
- const modOut = updateModuleBuildGradleMeetSdkRemote(modIn, resolved, collectMeetSdkRemoteApplyPlugins(resolved));
89
- expect(modOut.ok).toBe(true);
90
- if (!modOut.ok) return;
91
- expect(modOut.content).toContain(TOPSDK_AUTO_START);
92
- expect(modOut.content).toContain("top_channel_id");
93
- expect(modOut.content).toContain("top_app_id");
94
- expect(modOut.content).toContain(resolved.topsdk.appId);
95
- expect(modOut.content).toContain(resolved.topsdk.version);
96
- expect(modOut.content).toContain('implementation "$groupId:ui:$topsdk_version"');
97
- expect(modOut.content).toContain(':google:');
98
- expect(modOut.content).not.toContain("top_package_name");
99
- expect(modOut.content).toContain(`applicationId "${resolved.packageName}"`);
100
- expect(modOut.content).toContain("facebook_app_id");
101
- expect(modOut.content).toContain("apply plugin: 'com.google.gms.google-services'");
102
- });
103
-
104
- it("updates existing resValue by key instead of duplicating", () => {
105
- const blockIn = `
106
- applicationId 'com.feishu.topsdk'
107
- resValue('string', 'top_channel_id', 'GOOGLE')
108
- resValue('string', 'facebook_app_id', 'old-id')
109
- `;
110
- const snippet = `${TOPSDK_AUTO_START}
111
- resValue('string', 'top_channel_id', 'GOOGLE')
112
- resValue('string', 'top_app_id', '791251136341225472')
113
- resValue('string', 'facebook_app_id', 'new-id')
114
- resValue('string', 'kakao_app_id', 'kakao-key')
115
- ${TOPSDK_AUTO_END}`;
116
- const out = mergeResValuesInDefaultConfigBlock(blockIn, snippet);
117
- expect(extractResValueKey("resValue('string', 'facebook_app_id', 'old-id')")).toBe("facebook_app_id");
118
- expect((out.match(/facebook_app_id/g) ?? []).length).toBe(1);
119
- expect(out).toContain("'new-id'");
120
- expect(out).not.toContain("'old-id'");
121
- expect(out).toContain("kakao_app_id");
122
- expect(out).not.toContain("kakao_native_app_key");
123
- expect(out).toContain("top_app_id");
124
- });
125
-
126
- it("inserts apply plugin block directly after com.android.application", () => {
127
- const modIn = `
128
- apply plugin: 'com.android.application'
129
-
130
- dependencies {
131
- }
132
-
133
- android {
134
- defaultConfig { applicationId "com.example.app" }
135
- }
136
- `;
137
- const raw = JSON.parse(fs.readFileSync(sampleConfigPath, "utf8")) as unknown;
138
- const cfg = tryParseAsMeetSdkRemoteConfig(raw);
139
- const resolved = applyMeetSdkDefaultConfig(cfg!, loadBuiltInMeetSdkDefaultConfig());
140
- const modOut = updateModuleBuildGradleMeetSdkRemote(modIn, resolved, collectMeetSdkRemoteApplyPlugins(resolved));
141
- expect(modOut.ok).toBe(true);
142
- if (!modOut.ok) return;
143
- const lines = modOut.content.split("\n").map((l) => l.trimEnd());
144
- const appPluginIdx = lines.findIndex((l) => l.includes("com.android.application"));
145
- const googleServicesIdx = lines.findIndex((l) => l.includes("com.google.gms.google-services"));
146
- const depsIdx = lines.findIndex((l) => l.trim() === "dependencies {");
147
- expect(appPluginIdx).toBeGreaterThanOrEqual(0);
148
- expect(googleServicesIdx).toBeGreaterThan(appPluginIdx);
149
- expect(depsIdx).toBeGreaterThan(googleServicesIdx);
150
- expect(modOut.content.indexOf(TOPSDK_PLUGIN_AUTO_START)).toBeLessThan(modOut.content.indexOf("dependencies"));
151
- });
152
-
153
- it("keeps an existing apply plugin with the same id instead of duplicating or rewriting", () => {
154
- const modIn = `
155
- apply plugin: 'com.android.application'
156
- apply plugin: 'com.google.gms.google-services'
157
-
158
- android {
159
- defaultConfig { applicationId "com.example.app" }
160
- }
161
- dependencies { }
162
- `;
163
- const raw = JSON.parse(fs.readFileSync(sampleConfigPath, "utf8")) as unknown;
164
- const cfg = tryParseAsMeetSdkRemoteConfig(raw);
165
- const resolved = applyMeetSdkDefaultConfig(cfg!, loadBuiltInMeetSdkDefaultConfig());
166
- const modOut = updateModuleBuildGradleMeetSdkRemote(modIn, resolved, collectMeetSdkRemoteApplyPlugins(resolved));
167
- expect(modOut.ok).toBe(true);
168
- if (!modOut.ok) return;
169
- expect(extractApplyPluginId("apply plugin: 'com.google.gms.google-services'")).toBe(
170
- "com.google.gms.google-services"
171
- );
172
- const pluginLines = modOut.content
173
- .split("\n")
174
- .filter((l) => l.includes("com.google.gms.google-services"));
175
- expect(pluginLines.length).toBe(1);
176
- expect(modOut.content).not.toContain(TOPSDK_PLUGIN_AUTO_START);
177
- });
178
-
179
- it("updates classpath by group:artifact instead of duplicating", () => {
180
- const blockIn = `
181
- classpath 'com.google.gms:google-services:4.3.0'
182
- `;
183
- const out = mergeClasspathsInBlock(blockIn, ["com.google.gms:google-services:4.4.4"]);
184
- expect(mavenGroupArtifactKey("com.google.gms:google-services:4.3.0")).toBe("com.google.gms:google-services");
185
- const classpathLines = out.split("\n").filter((l) => extractClasspathCoordinate(l));
186
- expect(classpathLines.length).toBe(1);
187
- expect(classpathLines[0]).toContain("4.4.4");
188
- expect(out).not.toContain("4.3.0");
189
- });
190
-
191
- it("updates implementation by group:artifact instead of duplicating", () => {
192
- const blockIn = `
193
- def groupId = "com.sino.topsdk"
194
- implementation "com.sino.topsdk:facebook:1.0.0"
195
- implementation "com.sino.topsdk:google:9.9.9"
196
- `;
197
- const cleaned = removeImplementationLinesByGroupArtifact(
198
- blockIn,
199
- new Set(["com.sino.topsdk:facebook"]),
200
- "com.sino.topsdk"
201
- );
202
- expect(
203
- extractImplementationKey('implementation "com.sino.topsdk:facebook:1.0.0"', blockIn, "com.sino.topsdk")
204
- ).toBe("com.sino.topsdk:facebook");
205
- expect(cleaned).not.toContain("1.0.0");
206
- expect(cleaned).toContain("com.sino.topsdk:google:9.9.9");
207
- const fbLines = cleaned.split("\n").filter(
208
- (l) => extractImplementationKey(l, cleaned, "com.sino.topsdk") === "com.sino.topsdk:facebook"
209
- );
210
- expect(fbLines.length).toBe(0);
211
- });
212
-
213
- it("updates repositories by key instead of skipping or duplicating", () => {
214
- const blockIn = `
215
- google()
216
- maven { url 'https://storage-sdk-gameplus.meetsocial.com/repository/TopSdk/' }
217
- `;
218
- const out = mergeRepositoriesInBlock(blockIn, [
219
- "google",
220
- "mavenCentral",
221
- "https://storage-sdk-gameplus.meetsocial.com/repository/TopSdk/",
222
- ]);
223
- expect((out.match(/\bgoogle\s*\(\s*\)/g) ?? []).length).toBe(1);
224
- expect(out).toContain("mavenCentral()");
225
- expect((out.match(/storage-sdk-gameplus/g) ?? []).length).toBe(1);
226
- expect(out).toContain(TOPSDK_REPO_AUTO_START);
227
- });
228
-
229
- it("merges power-raid style pre-existing resValue and dependencies without duplicates", () => {
230
- const modIn = `
231
- apply plugin: 'com.android.application'
232
-
233
- dependencies {
234
- implementation 'androidx.multidex:multidex:2.0.1'
235
- def topsdk_version = "1.6.1.1"
236
- def groupId = "com.sino.topsdk"
237
- implementation "$groupId:facebook:$topsdk_version"
238
- }
239
-
240
- android {
241
- defaultConfig {
242
- applicationId 'com.feishu.topsdk'
243
- resValue('string', 'facebook_app_id', 'old-fb-id')
244
- resValue('string', 'af_dev_key', 'old-af-key')
245
- }
246
- }
247
- `;
248
- const raw = JSON.parse(fs.readFileSync(sampleConfigPath, "utf8")) as unknown;
249
- const cfg = tryParseAsMeetSdkRemoteConfig(raw);
250
- const resolved = applyMeetSdkDefaultConfig(cfg!, loadBuiltInMeetSdkDefaultConfig());
251
- const modOut = updateModuleBuildGradleMeetSdkRemote(modIn, resolved, collectMeetSdkRemoteApplyPlugins(resolved));
252
- expect(modOut.ok).toBe(true);
253
- if (!modOut.ok) return;
254
- expect((modOut.content.match(/facebook_app_id/g) ?? []).length).toBe(1);
255
- expect((modOut.content.match(/af_dev_key/g) ?? []).length).toBe(1);
256
- expect(modOut.content).not.toContain("old-fb-id");
257
- const fbImpl = modOut.content
258
- .split("\n")
259
- .filter(
260
- (l) => extractImplementationKey(l, modOut.content, resolved.topsdk.groupId) === "com.sino.topsdk:facebook"
261
- );
262
- expect(fbImpl.length).toBe(1);
263
- });
264
-
265
- it("detects plugins-dsl vs apply-plugin module style", () => {
266
- expect(
267
- detectModuleGradlePluginStyle(`
268
- plugins {
269
- alias(libs.plugins.android.application)
270
- }
271
- android { defaultConfig { applicationId "com.example.app" } }
272
- dependencies { }
273
- `)
274
- ).toBe("plugins-dsl");
275
- expect(
276
- detectModuleGradlePluginStyle(`
277
- apply plugin: 'com.android.application'
278
- android { defaultConfig { applicationId "com.example.app" } }
279
- dependencies { }
280
- `)
281
- ).toBe("apply-plugin");
282
- });
283
-
284
- it("writes Firebase google-services via plugins DSL for modern templates", () => {
285
- const raw = JSON.parse(fs.readFileSync(sampleConfigPath, "utf8")) as unknown;
286
- const cfg = tryParseAsMeetSdkRemoteConfig(raw);
287
- const resolved = applyMeetSdkDefaultConfig(cfg!, loadBuiltInMeetSdkDefaultConfig());
288
-
289
- const rootIn = `
290
- plugins {
291
- alias(libs.plugins.android.application) apply false
292
- alias(libs.plugins.kotlin.compose) apply false
293
- }
294
- `;
295
- const rootOut = updateRootBuildGradleMeetSdkRemote(rootIn, {
296
- repositories: [],
297
- rootPluginsDsl: collectMeetSdkRemotePluginsDslForRoot(resolved),
298
- });
299
- expect(rootOut.ok).toBe(true);
300
- if (!rootOut.ok) return;
301
- expect(rootOut.content).toContain(TOPSDK_PLUGIN_AUTO_START);
302
- expect(rootOut.content).toContain("id 'com.google.gms.google-services' version '4.4.4' apply false");
303
- expect(rootOut.content).not.toContain("buildscript");
304
-
305
- const modIn = `
306
- plugins {
307
- alias(libs.plugins.android.application)
308
- alias(libs.plugins.kotlin.compose)
309
- }
310
-
311
- android {
312
- defaultConfig {
313
- applicationId "com.example.app"
314
- }
315
- }
316
-
317
- dependencies {
318
- }
319
- `;
320
- const modOut = updateModuleBuildGradleMeetSdkRemote(modIn, resolved, {
321
- style: "plugins-dsl",
322
- pluginsDsl: collectMeetSdkRemotePluginsDslForModule(resolved),
323
- });
324
- expect(modOut.ok).toBe(true);
325
- if (!modOut.ok) return;
326
- expect(extractPluginsDslId(" id 'com.google.gms.google-services'")).toBe("com.google.gms.google-services");
327
- expect(modOut.content).toContain("id 'com.google.gms.google-services'");
328
- expect(modOut.content).not.toContain("apply plugin: 'com.google.gms.google-services'");
329
- const pluginLines = modOut.content
330
- .split("\n")
331
- .filter((l) => l.includes("com.google.gms.google-services"));
332
- expect(pluginLines.length).toBe(1);
333
- const pluginsClose = modOut.content.indexOf("}", modOut.content.indexOf("plugins {"));
334
- const androidIdx = modOut.content.indexOf("android {");
335
- const googleIdx = modOut.content.indexOf("com.google.gms.google-services");
336
- expect(googleIdx).toBeGreaterThan(modOut.content.indexOf("plugins {"));
337
- expect(googleIdx).toBeLessThan(pluginsClose);
338
- expect(androidIdx).toBeGreaterThan(pluginsClose);
339
- });
340
-
341
- it("migrates mixed Firebase config from buildscript/apply plugin to plugins DSL", () => {
342
- const raw = JSON.parse(fs.readFileSync(sampleConfigPath, "utf8")) as unknown;
343
- const cfg = tryParseAsMeetSdkRemoteConfig(raw);
344
- const resolved = applyMeetSdkDefaultConfig(cfg!, loadBuiltInMeetSdkDefaultConfig());
345
-
346
- const rootIn = `
347
- buildscript {
348
- repositories { google() }
349
- dependencies {
350
- classpath 'com.google.gms:google-services:4.3.0'
351
- }
352
- }
353
- plugins {
354
- alias(libs.plugins.android.application) apply false
355
- }
356
- `;
357
- const rootOut = updateRootBuildGradleMeetSdkRemote(rootIn, {
358
- repositories: [],
359
- rootPluginsDsl: collectMeetSdkRemotePluginsDslForRoot(resolved),
360
- stripBuildscriptClasspaths: collectMeetSdkRemoteBuildscriptClasspaths(resolved),
361
- });
362
- expect(rootOut.ok).toBe(true);
363
- if (!rootOut.ok) return;
364
- expect(rootOut.content).toContain("id 'com.google.gms.google-services' version '4.4.4' apply false");
365
- expect(rootOut.content).not.toContain("4.3.0");
366
-
367
- const modIn = `
368
- plugins {
369
- alias(libs.plugins.android.application)
370
- }
371
- apply plugin: 'com.google.gms.google-services'
372
-
373
- android {
374
- defaultConfig { applicationId "com.example.app" }
375
- }
376
- dependencies { }
377
- `;
378
- const modOut = updateModuleBuildGradleMeetSdkRemote(modIn, resolved, {
379
- style: "plugins-dsl",
380
- pluginsDsl: collectMeetSdkRemotePluginsDslForModule(resolved),
381
- });
382
- expect(modOut.ok).toBe(true);
383
- if (!modOut.ok) return;
384
- expect(modOut.content).not.toContain("apply plugin: 'com.google.gms.google-services'");
385
- expect(modOut.content).toContain("id 'com.google.gms.google-services'");
386
- });
387
-
388
- it("writes repositories into dependencyResolutionManagement in settings.gradle", () => {
389
- const settingsIn = `
390
- pluginManagement {
391
- repositories {
392
- google()
393
- mavenCentral()
394
- }
395
- }
396
- dependencyResolutionManagement {
397
- repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
398
- repositories {
399
- google()
400
- mavenCentral()
401
- }
402
- }
403
- `;
404
- const settingsOut = updateSettingsGradleMeetSdkRemote(settingsIn, [
405
- "google",
406
- "mavenCentral",
407
- "https://storage-sdk-gameplus.meetsocial.com/repository/TopSdk/",
408
- ]);
409
- expect(settingsOut.ok).toBe(true);
410
- if (!settingsOut.ok) return;
411
- expect(settingsOut.content).toContain(TOPSDK_REPO_AUTO_START);
412
- expect(settingsOut.content).toContain("storage-sdk-gameplus");
413
- });
414
- });
@@ -1,149 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
- import { loadManifestFile } from "../src/config/loadManifest.js";
6
- import { buildWorkspaceContext } from "../src/core/workspace.js";
7
- import { runPipeline } from "../src/core/pipeline.js";
8
-
9
- const here = path.dirname(fileURLToPath(import.meta.url));
10
- const pkgRoot = path.resolve(here, "..");
11
- const androidFixtureRoot = path.join(pkgRoot, "fixtures", "android-test-project");
12
- const androidLatestRoot = path.join(androidFixtureRoot, "android-latest-project");
13
- const recipeFixtureRoot = path.join(pkgRoot, "fixtures", "recipes");
14
-
15
- function stubSdkHomeVersion(): void {
16
- vi.stubGlobal(
17
- "fetch",
18
- vi.fn(async () => ({
19
- ok: true,
20
- status: 200,
21
- text: async () =>
22
- JSON.stringify({
23
- code: 200,
24
- data: {
25
- result: {
26
- android: { ver: "1.6.1.3", date: "2026-05-25" },
27
- ios: { ver: "1.6.0.5", date: "2026-06-09" },
28
- },
29
- },
30
- }),
31
- })) as unknown as typeof fetch
32
- );
33
- }
34
-
35
- function testProjectRoot(...names: string[]): string {
36
- for (const name of names) {
37
- const candidate = path.join(androidFixtureRoot, name);
38
- if (fs.existsSync(candidate)) return candidate;
39
- }
40
- return path.join(androidFixtureRoot, names[0] ?? "");
41
- }
42
-
43
- async function runAndroidPipelineDryRun(
44
- projectRoot: string,
45
- opts?: { requirePackageNameInPatch?: boolean; requireRemoteValuesInPatch?: boolean; allowEmptyPatch?: boolean }
46
- ) {
47
- const manifest = loadManifestFile(path.join(recipeFixtureRoot, "android-default.fixture.yaml"));
48
- const cfg = JSON.parse(fs.readFileSync(path.join(projectRoot, "meetsdk-remote-config.json"), "utf8")) as {
49
- packageName: string;
50
- channel: string;
51
- topsdk: { appId: string };
52
- };
53
- const ctx = buildWorkspaceContext(projectRoot, pkgRoot);
54
- expect(ctx.android?.ok).toBe(true);
55
- const { report, patch, binaryCopies } = await runPipeline(ctx, manifest, { dryRun: true });
56
- expect(report.errors).toEqual([]);
57
- if (!opts?.allowEmptyPatch) {
58
- expect(patch.length).toBeGreaterThan(0);
59
- }
60
- expect(binaryCopies).toEqual([]);
61
- if (!opts?.allowEmptyPatch || patch.length > 0) {
62
- expect(patch).toContain("TOPSDK REPO AUTO");
63
- expect(patch).toContain("TOPSDK AUTO");
64
- }
65
- if (opts?.requirePackageNameInPatch !== false) {
66
- expect(patch).toContain(cfg.packageName);
67
- }
68
- if (opts?.requireRemoteValuesInPatch !== false) {
69
- expect(patch).toContain(cfg.topsdk.appId);
70
- expect(patch).toContain(cfg.channel);
71
- expect(patch).toContain("facebook_app_id");
72
- expect(patch).toContain("top_app_id");
73
- }
74
- return { ctx, patch };
75
- }
76
-
77
- function copyAndroidLatestToTemp(): string {
78
- const tmp = fs.mkdtempSync(path.join(fs.realpathSync("/tmp"), "meet-android-idempotent-"));
79
- fs.cpSync(androidLatestRoot, tmp, { recursive: true });
80
- return tmp;
81
- }
82
-
83
- describe("pipeline android fixture", () => {
84
- beforeEach(() => {
85
- stubSdkHomeVersion();
86
- });
87
-
88
- afterEach(() => {
89
- vi.unstubAllGlobals();
90
- });
91
-
92
- it("dry-run on android-latest-project (plugins DSL / :app)", async () => {
93
- const { patch } = await runAndroidPipelineDryRun(androidLatestRoot);
94
- expect(patch).toContain("twitter_redirect_url");
95
- expect(patch).toContain("kakao_app_id");
96
- expect(patch).toContain("id 'com.google.gms.google-services'");
97
- });
98
-
99
- const powerRaidRoot = testProjectRoot("power-raid");
100
- const hasPowerRaidConfig = fs.existsSync(path.join(powerRaidRoot, "meetsdk-remote-config.json"));
101
-
102
- it.skipIf(!hasPowerRaidConfig)("dry-run on power-raid (:launcher)", async () => {
103
- const { ctx, patch } = await runAndroidPipelineDryRun(powerRaidRoot, {
104
- requirePackageNameInPatch: false,
105
- requireRemoteValuesInPatch: false,
106
- allowEmptyPatch: true,
107
- });
108
- expect(ctx.android?.ok && ctx.android.moduleName).toBe(":launcher");
109
- const addedLines = patch.split("\n").filter((line) => line.startsWith("+")).join("\n");
110
- expect(addedLines).not.toContain("//Firebase");
111
- expect(addedLines).not.toContain("//Appsflyer");
112
- });
113
-
114
- it("apply is idempotent and logs Android value updates", async () => {
115
- const tmp = copyAndroidLatestToTemp();
116
- try {
117
- const manifest = loadManifestFile(path.join(recipeFixtureRoot, "android-default.fixture.yaml"));
118
- const buildGradlePath = path.join(tmp, "app", "build.gradle");
119
- const beforeGradle = fs.readFileSync(buildGradlePath, "utf8");
120
- fs.writeFileSync(
121
- buildGradlePath,
122
- beforeGradle.replace(
123
- 'versionName "1.0"',
124
- `versionName "1.0"
125
- resValue('string', 'top_app_id', 'old-app-id')
126
- resValue('string', 'facebook_app_id', 'old-facebook-id')`
127
- ),
128
- "utf8"
129
- );
130
-
131
- const ctx = buildWorkspaceContext(tmp, pkgRoot);
132
- const first = await runPipeline(ctx, manifest, { dryRun: false });
133
- expect(first.report.errors).toEqual([]);
134
- const logs = (first.report.logs ?? []).join("\n");
135
- expect(logs).toContain("Android applicationId com.example.myapplication -> com.meet.integrate.androidsample");
136
- expect(logs).toContain("Android resValue top_app_id string:old-app-id -> string:mock-topsdk-app-id");
137
- expect(logs).toContain("Android resValue facebook_app_id string:old-facebook-id -> string:0000000000000000");
138
-
139
- const second = await runPipeline(buildWorkspaceContext(tmp, pkgRoot), manifest, { dryRun: false });
140
- expect(second.report.errors).toEqual([]);
141
- const after = fs.readFileSync(buildGradlePath, "utf8");
142
- expect((after.match(/resValue\('string', 'top_app_id'/g) ?? []).length).toBe(1);
143
- expect((after.match(/resValue\('string', 'facebook_app_id'/g) ?? []).length).toBe(1);
144
- expect((after.match(/applicationId "com.meet.integrate.androidsample"/g) ?? []).length).toBe(1);
145
- } finally {
146
- fs.rmSync(tmp, { recursive: true, force: true });
147
- }
148
- });
149
- });
@@ -1,58 +0,0 @@
1
- import path from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
4
- import { loadAndroidIntegrationFile } from "../src/config/loadAndroidIntegration.js";
5
- import { buildWorkspaceContext } from "../src/core/workspace.js";
6
- import { runPipeline } from "../src/core/pipeline.js";
7
- import type { AndroidIntegrationDocument, Manifest } from "../src/contracts/types.js";
8
-
9
- const here = path.dirname(fileURLToPath(import.meta.url));
10
- const pkgRoot = path.resolve(here, "..");
11
- const recipeFixtureRoot = path.join(pkgRoot, "fixtures", "recipes");
12
-
13
- function stubSdkHomeVersion(): void {
14
- vi.stubGlobal(
15
- "fetch",
16
- vi.fn(async () => ({
17
- ok: true,
18
- status: 200,
19
- text: async () =>
20
- JSON.stringify({
21
- code: 200,
22
- data: {
23
- result: {
24
- android: { ver: "1.6.1.3", date: "2026-05-25" },
25
- ios: { ver: "1.6.0.5", date: "2026-06-09" },
26
- },
27
- },
28
- }),
29
- })) as unknown as typeof fetch
30
- );
31
- }
32
-
33
- function toManifest(doc: AndroidIntegrationDocument): Manifest {
34
- const { meta: _m, remote: _r, ...rest } = doc;
35
- void _m;
36
- void _r;
37
- return rest;
38
- }
39
-
40
- describe("pipeline integration json", () => {
41
- beforeEach(() => {
42
- stubSdkHomeVersion();
43
- });
44
-
45
- afterEach(() => {
46
- vi.unstubAllGlobals();
47
- });
48
-
49
- it("dry-run accepts assembled android integration file", async () => {
50
- const doc = loadAndroidIntegrationFile(path.join(recipeFixtureRoot, "android-integration.fixture.json"));
51
- const manifest = toManifest(doc);
52
- const ctx = buildWorkspaceContext(path.join(pkgRoot, "fixtures", "android-test-project", "android-latest-project"), pkgRoot);
53
- const { report, patch } = await runPipeline(ctx, manifest, { dryRun: true });
54
- expect(report.errors).toEqual([]);
55
- expect(patch.length).toBeGreaterThan(0);
56
- expect(patch).toContain("TOPSDK AUTO");
57
- });
58
- });